Search is not available for this dataset
query
stringlengths
7
355k
document
stringlengths
9
341k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Reset sidebar state when sidebar changes Use React key to unmount/remount the children See
function ResetOnSidebarChange({children}) { const sidebar = useDocsSidebar(); return ( <React.Fragment key={sidebar?.name ?? 'noSidebar'}> {children} </React.Fragment> ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "enableSidebar() {\n this.resizeWindow()\n if (localStorage.sidebarState) {\n this.sidebar = JSON.parse(localStorage.sidebarState)\n localStorage.removeItem(\"sidebarState\");\n }\n this.setState({disabledSidebar: false})\n }", "toggleSidebar() {\n\t\tthis.setS...
[ "0.6693865", "0.66780686", "0.66545933", "0.6477997", "0.6455181", "0.63474476", "0.6305745", "0.6301851", "0.6267503", "0.61053157", "0.606347", "0.60297346", "0.59794635", "0.59686464", "0.5963151", "0.5941402", "0.5935572", "0.5918034", "0.5914497", "0.5877891", "0.5852757...
0.72458947
0
It's an implementation of the FileSystem interface which reads and writes directly to the real file system.
function createRealFileSystem(caseSensitive = false) { // read cache const existsCache = new Map(); const readStatsCache = new Map(); const readFileCache = new Map(); const readDirCache = new Map(); const realPathCache = new Map(); function normalizePath(path) { return caseSensitive ? path_1.normalize(path) : path_1.normalize(path).toLowerCase(); } // read methods function exists(path) { const normalizedPath = normalizePath(path); if (!existsCache.has(normalizedPath)) { existsCache.set(normalizedPath, fs_extra_1.default.existsSync(normalizedPath)); } return !!existsCache.get(normalizedPath); } function readStats(path) { const normalizedPath = normalizePath(path); if (!readStatsCache.has(normalizedPath)) { if (exists(normalizedPath)) { readStatsCache.set(normalizedPath, fs_extra_1.default.statSync(normalizedPath)); } } return readStatsCache.get(normalizedPath); } function readFile(path, encoding) { const normalizedPath = normalizePath(path); if (!readFileCache.has(normalizedPath)) { const stats = readStats(normalizedPath); if (stats && stats.isFile()) { readFileCache.set(normalizedPath, fs_extra_1.default.readFileSync(normalizedPath, { encoding: encoding }).toString()); } else { readFileCache.set(normalizedPath, undefined); } } return readFileCache.get(normalizedPath); } function readDir(path) { const normalizedPath = normalizePath(path); if (!readDirCache.has(normalizedPath)) { const stats = readStats(normalizedPath); if (stats && stats.isDirectory()) { readDirCache.set(normalizedPath, fs_extra_1.default.readdirSync(normalizedPath, { withFileTypes: true })); } else { readDirCache.set(normalizedPath, []); } } return readDirCache.get(normalizedPath) || []; } function getRealPath(path) { const normalizedPath = normalizePath(path); if (!realPathCache.has(normalizedPath)) { let base = normalizedPath; let nested = ''; while (base !== path_1.dirname(base)) { if (exists(base)) { realPathCache.set(normalizedPath, normalizePath(path_1.join(fs_extra_1.default.realpathSync(base), nested))); break; } nested = path_1.join(path_1.basename(base), nested); base = path_1.dirname(base); } } return realPathCache.get(normalizedPath) || normalizedPath; } function createDir(path) { const normalizedPath = normalizePath(path); fs_extra_1.default.mkdirSync(normalizedPath, { recursive: true }); // update cache existsCache.set(normalizedPath, true); if (readDirCache.has(path_1.dirname(normalizedPath))) { readDirCache.delete(path_1.dirname(normalizedPath)); } if (readStatsCache.has(normalizedPath)) { readStatsCache.delete(normalizedPath); } } function writeFile(path, data) { const normalizedPath = normalizePath(path); if (!exists(path_1.dirname(normalizedPath))) { createDir(path_1.dirname(normalizedPath)); } fs_extra_1.default.writeFileSync(normalizedPath, data); // update cache existsCache.set(normalizedPath, true); if (readDirCache.has(path_1.dirname(normalizedPath))) { readDirCache.delete(path_1.dirname(normalizedPath)); } if (readStatsCache.has(normalizedPath)) { readStatsCache.delete(normalizedPath); } if (readFileCache.has(normalizedPath)) { readFileCache.delete(normalizedPath); } } function deleteFile(path) { if (exists(path)) { const normalizedPath = normalizePath(path); fs_extra_1.default.unlinkSync(normalizedPath); // update cache existsCache.set(normalizedPath, false); if (readDirCache.has(path_1.dirname(normalizedPath))) { readDirCache.delete(path_1.dirname(normalizedPath)); } if (readStatsCache.has(normalizedPath)) { readStatsCache.delete(normalizedPath); } if (readFileCache.has(normalizedPath)) { readFileCache.delete(normalizedPath); } } } function updateTimes(path, atime, mtime) { if (exists(path)) { const normalizedPath = normalizePath(path); fs_extra_1.default.utimesSync(normalizePath(path), atime, mtime); // update cache if (readStatsCache.has(normalizedPath)) { readStatsCache.delete(normalizedPath); } } } return { exists(path) { return exists(getRealPath(path)); }, readFile(path, encoding) { return readFile(getRealPath(path), encoding); }, readDir(path) { return readDir(getRealPath(path)); }, readStats(path) { return readStats(getRealPath(path)); }, realPath(path) { return getRealPath(path); }, normalizePath(path) { return normalizePath(path); }, writeFile(path, data) { writeFile(getRealPath(path), data); }, deleteFile(path) { deleteFile(getRealPath(path)); }, createDir(path) { createDir(getRealPath(path)); }, updateTimes(path, atime, mtime) { updateTimes(getRealPath(path), atime, mtime); }, clearCache() { existsCache.clear(); readStatsCache.clear(); readFileCache.clear(); readDirCache.clear(); realPathCache.clear(); }, }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function FileSystem() {\n (0, _classCallCheck3.default)(this, FileSystem);\n\n var _this = (0, _possibleConstructorReturn3.default)(this, (FileSystem.__proto__ || (0, _getPrototypeOf2.default)(FileSystem)).call(this, SERVICE_ID, true));\n\n var defaults = { list: null };\n _this.configure(defaults);\n\...
[ "0.69153494", "0.66294533", "0.65270483", "0.6498064", "0.634216", "0.63108456", "0.5935721", "0.58612883", "0.5843901", "0.57971245", "0.57014847", "0.5643625", "0.56069165", "0.5588468", "0.5586951", "0.5586951", "0.55285114", "0.550546", "0.5478593", "0.54779506", "0.54737...
0.6057955
6
this function will read the database from the backend
getState(){ var gameStateRef= database.ref('gamestate'); gameStateRef.on("value",function (data) { gameState=data.val(); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "readFromDB() {\n return readFile(\"db/db.json\", \"utf8\");\n }", "function ReadDB () {\r\n const transactions = Budgetdb.transaction([\"pending\"], \"readwrite\")\r\n const stores = transactions.objectStore(\"pending\")\r\n // getAll() method for matching specified parameter OR\r\n // all...
[ "0.7486441", "0.74746335", "0.7101922", "0.7034355", "0.6993339", "0.6976037", "0.6930744", "0.6927841", "0.6890205", "0.6888497", "0.6819156", "0.6747999", "0.6738161", "0.6727995", "0.6642779", "0.6603184", "0.66022366", "0.65734816", "0.6477305", "0.6440159", "0.64132214",...
0.0
-1
update function will update the gameState in the database to a value passed to it inside the ()
update(state){ database.ref('/').update({gamestate:state}) gameState=state; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "update(state)\r\n {\r\n // refer to gameState field and set as 1 or 0\r\n database.ref(\"/\").update({\r\n gameState: state\r\n })\r\n }", "update(state){\r\n\r\n database.ref('/').update({\r\n gameState: state\r\n });\r\n\r\n }", "update(state)...
[ "0.83509296", "0.81290007", "0.8118329", "0.80836374", "0.8080882", "0.8080339", "0.80572945", "0.8030668", "0.8024705", "0.7998752", "0.79166883", "0.79030734", "0.7855043", "0.78190833", "0.7817052", "0.7741015", "0.7736783", "0.76067805", "0.73734033", "0.735462", "0.73070...
0.7980765
10
var contestanX = ''; var contestanX = ''; contestX += event.target.matches('td').value; contestX += event.target.matches('td').value; agregando reset
function reset() { window.location.reload(); // recargar la pagina -location se refiere a la url }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function myInputEvent() {\n if(document.getElementById(\"rowNum\").value == \"\")\n puzzle_N = default_N;\n puzzle_N = document.getElementById(\"rowNum\").value;\n reset = true;\n}", "function resetear(){\n resultado.innerHTML = \"0\";\n operandoa = 0;\n operandob = 0;\n ...
[ "0.6514277", "0.6304862", "0.611951", "0.60845643", "0.60687536", "0.6013614", "0.60111874", "0.58601636", "0.584529", "0.58364373", "0.5826845", "0.5826035", "0.58051986", "0.58032286", "0.5793624", "0.5786213", "0.5786213", "0.57565445", "0.57329893", "0.572091", "0.5718373...
0.0
-1
just hard code a secure connection. We got Let's encrypt...
function login() { socket.emit('controllogin'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Authenticate(){\n var speakeasy = require('speakeasy');\n var key = speakeasy.generateSeceret();\n}", "__ssl() {\n /// TODO: nothing, I guess?\n }", "function encryptedFortune() {\n var p = terminal.println;\n p( \"\\n\\n=========================================\\n\\n\" );\n p( \"Thread...
[ "0.64089257", "0.63284785", "0.61666554", "0.61211777", "0.5995153", "0.5871108", "0.5818002", "0.5807722", "0.5802796", "0.5798142", "0.5722086", "0.5693899", "0.55601215", "0.5496894", "0.5486835", "0.54837424", "0.547219", "0.5457353", "0.5456685", "0.54525733", "0.5422378...
0.0
-1
To change icon when clicked
function changeIcons(icon) { icon.classList.toggle("fa-user-times"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function toggleIcon() {\n $(this).toggleClass('open-accordion');\n $(this).find(\".toggle-accordion\").html($(this).text() == 'Ver más' ? 'Ver menos' : 'Ver m&aacute;s');\n }", "function navBarIconClick(icon) {\n changeIcon(icon);\n openCloseNavBar();\n}", "setIcon(i) {\n this.icon = ...
[ "0.75271755", "0.75062704", "0.7447763", "0.74330366", "0.7400002", "0.73533356", "0.73303026", "0.7292451", "0.7208362", "0.72076994", "0.7191394", "0.7151959", "0.712506", "0.70978534", "0.7088715", "0.7054869", "0.6993555", "0.6990359", "0.6988816", "0.6945714", "0.6927932...
0.6415373
70
Create the Model Class
function Cards(defaultValues){ var privateState = {}; privateState.accountId = defaultValues?(defaultValues["accountId"]?defaultValues["accountId"]:null):null; privateState.Action = defaultValues?(defaultValues["Action"]?defaultValues["Action"]:null):null; privateState.cardHolderName = defaultValues?(defaultValues["cardHolderName"]?defaultValues["cardHolderName"]:null):null; privateState.cardId = defaultValues?(defaultValues["cardId"]?defaultValues["cardId"]:null):null; privateState.cardNumber = defaultValues?(defaultValues["cardNumber"]?defaultValues["cardNumber"]:null):null; privateState.cardStatus = defaultValues?(defaultValues["cardStatus"]?defaultValues["cardStatus"]:null):null; privateState.cardType = defaultValues?(defaultValues["cardType"]?defaultValues["cardType"]:null):null; privateState.errmsg = defaultValues?(defaultValues["errmsg"]?defaultValues["errmsg"]:null):null; privateState.expiryDate = defaultValues?(defaultValues["expiryDate"]?defaultValues["expiryDate"]:null):null; privateState.Reason = defaultValues?(defaultValues["Reason"]?defaultValues["Reason"]:null):null; privateState.success = defaultValues?(defaultValues["success"]?defaultValues["success"]:null):null; privateState.userId = defaultValues?(defaultValues["userId"]?defaultValues["userId"]:null):null; privateState.userName = defaultValues?(defaultValues["userName"]?defaultValues["userName"]:null):null; privateState.creditLimit = defaultValues?(defaultValues["creditLimit"]?defaultValues["creditLimit"]:null):null; privateState.availableCredit = defaultValues?(defaultValues["availableCredit"]?defaultValues["availableCredit"]:null):null; privateState.serviceProvider = defaultValues?(defaultValues["serviceProvider"]?defaultValues["serviceProvider"]:null):null; privateState.billingAddress = defaultValues?(defaultValues["billingAddress"]?defaultValues["billingAddress"]:null):null; privateState.cardProductName = defaultValues?(defaultValues["cardProductName"]?defaultValues["cardProductName"]:null):null; privateState.secondaryCardHolder = defaultValues?(defaultValues["secondaryCardHolder"]?defaultValues["secondaryCardHolder"]:null):null; privateState.withdrawlLimit = defaultValues?(defaultValues["withdrawlLimit"]?defaultValues["withdrawlLimit"]:null):null; privateState.accountNumber = defaultValues?(defaultValues["accountNumber"]?defaultValues["accountNumber"]:null):null; privateState.accountName = defaultValues?(defaultValues["accountName"]?defaultValues["accountName"]:null):null; privateState.maskedAccountNumber = defaultValues?(defaultValues["maskedAccountNumber"]?defaultValues["maskedAccountNumber"]:null):null; privateState.maskedCardNumber = defaultValues?(defaultValues["maskedCardNumber"]?defaultValues["maskedCardNumber"]:null):null; privateState.isInternational = defaultValues?(defaultValues["isInternational"]?defaultValues["isInternational"]:null):null; privateState.ids = defaultValues?(defaultValues["ids"]?defaultValues["ids"]:null):null; privateState.Destinations = defaultValues?(defaultValues["Destinations"]?defaultValues["Destinations"]:null):null; privateState.Cards = defaultValues?(defaultValues["Cards"]?defaultValues["Cards"]:null):null; privateState.Channel_id = defaultValues?(defaultValues["Channel_id"]?defaultValues["Channel_id"]:null):null; privateState.StartDate = defaultValues?(defaultValues["StartDate"]?defaultValues["StartDate"]:null):null; privateState.EndDate = defaultValues?(defaultValues["EndDate"]?defaultValues["EndDate"]:null):null; privateState.additionNotes = defaultValues?(defaultValues["additionNotes"]?defaultValues["additionNotes"]:null):null; privateState.phonenumber = defaultValues?(defaultValues["phonenumber"]?defaultValues["phonenumber"]:null):null; privateState.request_id = defaultValues?(defaultValues["request_id"]?defaultValues["request_id"]:null):null; privateState.bankName = defaultValues?(defaultValues["bankName"]?defaultValues["bankName"]:null):null; privateState.AccountType = defaultValues?(defaultValues["AccountType"]?defaultValues["AccountType"]:null):null; privateState.RequestCode = defaultValues?(defaultValues["RequestCode"]?defaultValues["RequestCode"]:null):null; privateState.RequestReason = defaultValues?(defaultValues["RequestReason"]?defaultValues["RequestReason"]:null):null; privateState.Channel = defaultValues?(defaultValues["Channel"]?defaultValues["Channel"]:null):null; privateState.Address_id = defaultValues?(defaultValues["Address_id"]?defaultValues["Address_id"]:null):null; privateState.communication_id = defaultValues?(defaultValues["communication_id"]?defaultValues["communication_id"]:null):null; privateState.CardNumbers = defaultValues?(defaultValues["CardNumbers"]?defaultValues["CardNumbers"]:null):null; privateState.lastNinetyDays = defaultValues?(defaultValues["lastNinetyDays"]?defaultValues["lastNinetyDays"]:null):null; //Using parent contructor to create other properties req. to kony sdk BaseModel.call(this); //Defining Getter/Setters Object.defineProperties(this,{ "accountId" : { get : function(){return privateState.accountId}, set : function(val){ setterFunctions['accountId'].call(this,val,privateState); }, enumerable : true, }, "Action" : { get : function(){return privateState.Action}, set : function(val){ setterFunctions['Action'].call(this,val,privateState); }, enumerable : true, }, "cardHolderName" : { get : function(){return privateState.cardHolderName}, set : function(val){ setterFunctions['cardHolderName'].call(this,val,privateState); }, enumerable : true, }, "cardId" : { get : function(){return privateState.cardId}, set : function(val){ setterFunctions['cardId'].call(this,val,privateState); }, enumerable : true, }, "cardNumber" : { get : function(){return privateState.cardNumber}, set : function(val){ setterFunctions['cardNumber'].call(this,val,privateState); }, enumerable : true, }, "cardStatus" : { get : function(){return privateState.cardStatus}, set : function(val){ setterFunctions['cardStatus'].call(this,val,privateState); }, enumerable : true, }, "cardType" : { get : function(){return privateState.cardType}, set : function(val){ setterFunctions['cardType'].call(this,val,privateState); }, enumerable : true, }, "errmsg" : { get : function(){return privateState.errmsg}, set : function(val){ setterFunctions['errmsg'].call(this,val,privateState); }, enumerable : true, }, "expiryDate" : { get : function(){return privateState.expiryDate}, set : function(val){ setterFunctions['expiryDate'].call(this,val,privateState); }, enumerable : true, }, "Reason" : { get : function(){return privateState.Reason}, set : function(val){ setterFunctions['Reason'].call(this,val,privateState); }, enumerable : true, }, "success" : { get : function(){return privateState.success}, set : function(val){ setterFunctions['success'].call(this,val,privateState); }, enumerable : true, }, "userId" : { get : function(){return privateState.userId}, set : function(val){ setterFunctions['userId'].call(this,val,privateState); }, enumerable : true, }, "userName" : { get : function(){return privateState.userName}, set : function(val){ setterFunctions['userName'].call(this,val,privateState); }, enumerable : true, }, "creditLimit" : { get : function(){return privateState.creditLimit}, set : function(val){ setterFunctions['creditLimit'].call(this,val,privateState); }, enumerable : true, }, "availableCredit" : { get : function(){return privateState.availableCredit}, set : function(val){ setterFunctions['availableCredit'].call(this,val,privateState); }, enumerable : true, }, "serviceProvider" : { get : function(){return privateState.serviceProvider}, set : function(val){ setterFunctions['serviceProvider'].call(this,val,privateState); }, enumerable : true, }, "billingAddress" : { get : function(){return privateState.billingAddress}, set : function(val){ setterFunctions['billingAddress'].call(this,val,privateState); }, enumerable : true, }, "cardProductName" : { get : function(){return privateState.cardProductName}, set : function(val){ setterFunctions['cardProductName'].call(this,val,privateState); }, enumerable : true, }, "secondaryCardHolder" : { get : function(){return privateState.secondaryCardHolder}, set : function(val){ setterFunctions['secondaryCardHolder'].call(this,val,privateState); }, enumerable : true, }, "withdrawlLimit" : { get : function(){return privateState.withdrawlLimit}, set : function(val){ setterFunctions['withdrawlLimit'].call(this,val,privateState); }, enumerable : true, }, "accountNumber" : { get : function(){return privateState.accountNumber}, set : function(val){ setterFunctions['accountNumber'].call(this,val,privateState); }, enumerable : true, }, "accountName" : { get : function(){return privateState.accountName}, set : function(val){ setterFunctions['accountName'].call(this,val,privateState); }, enumerable : true, }, "maskedAccountNumber" : { get : function(){return privateState.maskedAccountNumber}, set : function(val){ setterFunctions['maskedAccountNumber'].call(this,val,privateState); }, enumerable : true, }, "maskedCardNumber" : { get : function(){return privateState.maskedCardNumber}, set : function(val){ setterFunctions['maskedCardNumber'].call(this,val,privateState); }, enumerable : true, }, "isInternational" : { get : function(){return privateState.isInternational}, set : function(val){ setterFunctions['isInternational'].call(this,val,privateState); }, enumerable : true, }, "ids" : { get : function(){return privateState.ids}, set : function(val){ setterFunctions['ids'].call(this,val,privateState); }, enumerable : true, }, "Destinations" : { get : function(){return privateState.Destinations}, set : function(val){ setterFunctions['Destinations'].call(this,val,privateState); }, enumerable : true, }, "Cards" : { get : function(){return privateState.Cards}, set : function(val){ setterFunctions['Cards'].call(this,val,privateState); }, enumerable : true, }, "Channel_id" : { get : function(){return privateState.Channel_id}, set : function(val){ setterFunctions['Channel_id'].call(this,val,privateState); }, enumerable : true, }, "StartDate" : { get : function(){return privateState.StartDate}, set : function(val){ setterFunctions['StartDate'].call(this,val,privateState); }, enumerable : true, }, "EndDate" : { get : function(){return privateState.EndDate}, set : function(val){ setterFunctions['EndDate'].call(this,val,privateState); }, enumerable : true, }, "additionNotes" : { get : function(){return privateState.additionNotes}, set : function(val){ setterFunctions['additionNotes'].call(this,val,privateState); }, enumerable : true, }, "phonenumber" : { get : function(){return privateState.phonenumber}, set : function(val){ setterFunctions['phonenumber'].call(this,val,privateState); }, enumerable : true, }, "request_id" : { get : function(){return privateState.request_id}, set : function(val){ setterFunctions['request_id'].call(this,val,privateState); }, enumerable : true, }, "bankName" : { get : function(){return privateState.bankName}, set : function(val){ setterFunctions['bankName'].call(this,val,privateState); }, enumerable : true, }, "AccountType" : { get : function(){return privateState.AccountType}, set : function(val){ setterFunctions['AccountType'].call(this,val,privateState); }, enumerable : true, }, "RequestCode" : { get : function(){return privateState.RequestCode}, set : function(val){ setterFunctions['RequestCode'].call(this,val,privateState); }, enumerable : true, }, "RequestReason" : { get : function(){return privateState.RequestReason}, set : function(val){ setterFunctions['RequestReason'].call(this,val,privateState); }, enumerable : true, }, "Channel" : { get : function(){return privateState.Channel}, set : function(val){ setterFunctions['Channel'].call(this,val,privateState); }, enumerable : true, }, "Address_id" : { get : function(){return privateState.Address_id}, set : function(val){ setterFunctions['Address_id'].call(this,val,privateState); }, enumerable : true, }, "communication_id" : { get : function(){return privateState.communication_id}, set : function(val){ setterFunctions['communication_id'].call(this,val,privateState); }, enumerable : true, }, "CardNumbers" : { get : function(){return privateState.CardNumbers}, set : function(val){ setterFunctions['CardNumbers'].call(this,val,privateState); }, enumerable : true, }, "lastNinetyDays" : { get : function(){return privateState.lastNinetyDays}, set : function(val){ setterFunctions['lastNinetyDays'].call(this,val,privateState); }, enumerable : true, }, }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Model() {}", "function Model() {\n\n }", "function Model() {\n}", "function createModel() {\n var model = new Model();\n\n // give model the default values provided by the service\n model.color = DEFAULT_COLOR;\n model.shape = DEFAULT_SHAPE;\n model.texture = DEFAULT_TEXTURE;\n\n ...
[ "0.7569927", "0.7501261", "0.7361481", "0.7232894", "0.70144516", "0.70144516", "0.689631", "0.6844842", "0.67324704", "0.6634917", "0.6624342", "0.6551518", "0.65295154", "0.6502686", "0.6451706", "0.6443694", "0.640879", "0.6397692", "0.63938564", "0.6392954", "0.6383797", ...
0.0
-1
=====================FUNCTIONS==================================== Here is the functions of the main code Ronan Rodrigues ===================================================================
function OrdenaJson(lista, chave, ordem) { return lista.sort(function(a, b) { var x = a[chave]; var y = b[chave]; if (ordem === 'ASC') { return ((x < y) ? -1 : ((x > y) ? 1 : 0)); } if (ordem === 'DESC') { return ((x > y) ? -1 : ((x < y) ? 1 : 0)); } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function main(){\n\n\n}", "function Main()\n {\n \n }", "private internal function m248() {}", "function main(){\n\t\n}", "static private internal function m121() {}", "function _____SHARED_functions_____(){}", "private public function m246() {}", "function Scdr() {\r\n}", "function mai...
[ "0.6411274", "0.6393211", "0.6252296", "0.62266433", "0.6210057", "0.6124264", "0.6070701", "0.60499483", "0.5990403", "0.59710664", "0.5861775", "0.58405674", "0.57686096", "0.5692988", "0.5662434", "0.5650158", "0.56477", "0.5644543", "0.5605591", "0.55985534", "0.5593268",...
0.0
-1
EXECUTA UMA QUERY EM UM DB
function SQL_void(sqlQry) { conn = mysql.createConnection({ host: process.env.host_name, port: process.env.port_db, user: process.env.user_name, password: process.env.pass_key, database: process.env.database }); console.log(sqlQry) conn.query(sqlQry, function(error, results, fields){ if(error){ process.exit(1) console.log(error) conn.destroy() }else{ console.log("query ok") conn.destroy() } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function execQuery(message) {\n var db = openDatabaseSync(\"org.moedict\", \"1\", \"\", 64 * 1024 * 1024)\n var result = []\n db.readTransaction(function(tx) {\n var rs = tx.executeSql(message.query, message.params)\n for (var i = 0; i < rs.rows.length; ...
[ "0.6586436", "0.6375786", "0.6375786", "0.6288221", "0.6133847", "0.6115354", "0.61125183", "0.607049", "0.607049", "0.6057819", "0.6054336", "0.6034127", "0.60108024", "0.6009699", "0.5991694", "0.5932987", "0.5923601", "0.59128565", "0.5907342", "0.59042174", "0.58965844", ...
0.0
-1
const mix = ['z','b','C'];
function ourvery(myArray , callback){ for(let i = 0 ; i < myArray.length;i++){ if(!callback(myArray[i])){ return false; } } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mixCharacters(array) {\n for (let i = array.length - 1; i > 0; i--) {\n let j = Math.floor(Math.random() * (i + 1));\n [array[i], array[j]] = [array[j], array[i]];\n }\n return array;\n}", "mix(b, s) {\r\n return this.map((x, i) => (1 - s) * x + s * b[i]);\r\n }", "function lett...
[ "0.686162", "0.64543176", "0.62112826", "0.6004453", "0.5701267", "0.568749", "0.5654988", "0.5637774", "0.5590121", "0.5450004", "0.5351437", "0.5327842", "0.530029", "0.5294267", "0.52858114", "0.5284415", "0.5282573", "0.52789587", "0.5270884", "0.52521276", "0.5242477", ...
0.0
-1
extract locationNames from filmsByTitle json objects
function extractLocations(filmsByTitle) { return _.uniq(_.flatMap(filmsByTitle, film => film.locations.filter(location => location !== null))); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getAllLocationsCallback(response){\n\tconsole.log(response.results.forEach(function(locations){\n\t\tconsole.log(locations.name);\n\t}))\n}", "function showTitles() {\n geojson\n .features\n .forEach((place) => {\n const location = document.createElement('h3');\n l...
[ "0.5676147", "0.5658873", "0.55734867", "0.5495842", "0.54094756", "0.53771466", "0.53769064", "0.53628844", "0.52685153", "0.525627", "0.5254317", "0.51941925", "0.51615137", "0.5153334", "0.5120371", "0.5101574", "0.5068384", "0.5058056", "0.5050483", "0.5050483", "0.504356...
0.73876387
0
fetch location data from google api for all given locationNames
function fetchLocationData(locationNames) { console.log(`fetching ${locationNames.length} locations`); return Promise.all(locationNames.map(_findPlaceIdFor)) .then(placeIds => Promise.all(placeIds.map(_fetchPlaceByPlaceId))) .then(places => _formatResult(places, locationNames)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static list() {\n return api_base_1.default.request('locations/').then((locations) => {\n return locations.data.map(each => new Location_1.default(each));\n });\n }", "function _findAllLocationsBy(locationName) {\n let input = locationName.replace(/\\s/g, '+');\n return new Promise(...
[ "0.70915014", "0.69961417", "0.67679644", "0.66840833", "0.66727746", "0.6670714", "0.65905476", "0.6567674", "0.6478549", "0.6449448", "0.64107114", "0.634843", "0.62063485", "0.6189793", "0.61827606", "0.61797434", "0.6172168", "0.613416", "0.6124263", "0.61227554", "0.6119...
0.74662477
0
return object by locationName
function _formatResult(places, locationNames) { let result = {}; for (let i = 0; i < places.length; i++) { let place = places[i]; if (place && place.address_components) delete place.address_components; result[locationNames[i]] = place; } return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getLocationObj(locationName){\n return axios.get(\"/api/result\", {\n params: {\n name: locationName\n }\n })\n }", "function getLocation(object) {\n return fetch(`https://api.flickr.com/services/rest/?method=flickr.photos.geo.getLocation&api_key=${flickKey}&photo_i...
[ "0.71087956", "0.60575724", "0.6029532", "0.59670365", "0.589791", "0.5875645", "0.5832998", "0.5831399", "0.5809446", "0.5801243", "0.57778394", "0.5761491", "0.57551736", "0.5727511", "0.57159793", "0.5671067", "0.5659533", "0.5651709", "0.56469005", "0.5625204", "0.5591279...
0.0
-1
find google place_id by location name using google autocomplete api naive approach takes the first place_id result by google
function _findPlaceIdFor(locationName) { return _findAllLocationsBy(locationName) .then(predictions => { if (predictions.length <= 0) return null; return predictions[0].place_id; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function searchPlace() {\n var input = document.getElementById('search_new_place');\n var autocomplete = new google.maps.places.Autocomplete(input);\n google.maps.event.addListener(autocomplete, 'place_changed', function () {\n autocomplete.getPlace();\n //alert(\"This fu...
[ "0.693996", "0.6784302", "0.6692667", "0.6588941", "0.6567495", "0.6531602", "0.6522785", "0.65172946", "0.65114117", "0.6492426", "0.63977826", "0.63969874", "0.6385513", "0.6375631", "0.63748646", "0.6367624", "0.63214374", "0.632047", "0.6302164", "0.6288938", "0.62802166"...
0.6030076
48
fetch single place by id from google maps api
function _fetchPlaceByPlaceId(placeId) { return new Promise((resolve, reject) => { request.get(GOOGLE_MAPS_PLACE_API_URL) .use(throttle.plugin()) .query({ key: GOOGLE_MAPS_KEY }) .query({ placeid: placeId }) .end((err, res) => { ++googleRequestCount; console.log(googleRequestCount); if (err || res.body.error_message) { console.error(`ERR PLACE API: skipping ${err || res.body.error_message}`); return resolve({}); } resolve(res.body.result || {}); }) }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getPlace(id) {\n detailsService.getDetails({\n placeId: id\n }, callback)\n\n // callback is the object returned from google containing the place information\n function callback(place) {\n loadDetails(place);\n moveMap(place.geometry.location)\n }\n}", "function getPl...
[ "0.81261075", "0.77554786", "0.7493163", "0.7271624", "0.7084204", "0.7035854", "0.69489765", "0.6670099", "0.66193765", "0.66082174", "0.64345676", "0.63887614", "0.63584447", "0.63357115", "0.6303358", "0.62832636", "0.6269144", "0.6252571", "0.6243554", "0.62396413", "0.62...
0.7163167
4
find locations fuzzy by using autocomplete api
function _findAllLocationsBy(locationName) { let input = locationName.replace(/\s/g, '+'); return new Promise((resolve, reject) => { request.get(GOOGLE_MAPS_AUTOCOMPLETE_API_URL) .use(throttle.plugin()) .query({ key: GOOGLE_MAPS_KEY }) .query({ input: `${input}+near+san+francisco+ca` }) .query({ radius: 10000 }) .end((err, res) => { ++googleRequestCount; console.log(googleRequestCount); if (err || res.body.error_message) { console.error(`ERR AUTOCOMPLETE: skipping ${err || res.body.error_message}`); return resolve([]); }; // only consider predictions with a place id resolve(res.body.predictions.filter(prediction => prediction.place_id)); }) }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getSuggestedLocations(response){\n var suggestions ='';\n if(!(response.results === undefined || response.results === null) ) {\n for(i=0;i<response.results.length;i++){\n suggestions += '\\n' + response.results[i].city +',' + response.results[i].state ;\n }\n }\n return sugge...
[ "0.68306494", "0.67279124", "0.6685525", "0.6633305", "0.6627429", "0.6618685", "0.6604534", "0.6528845", "0.6513257", "0.6507444", "0.6501214", "0.6488516", "0.6487461", "0.64801407", "0.6458079", "0.64574814", "0.6456899", "0.6450807", "0.64263636", "0.64104205", "0.6362268...
0.63245815
22
If brush is too small, reset view as origin
function resetAll() { //reset scale $(".zoomUnit").text("1"); scaling.domain([0, sequence.length - 1]); scalingPosition.range([0, sequence.length - 1]); var seq = displaySequence(sequence.length); if (seq === false && !svgContainer.selectAll(".AA").empty()) svgContainer.selectAll(".seqGroup").remove(); transition_data(features, 0); reset_axis(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "clean() {\n const height = this.ctx.canvas.height;\n const width = this.ctx.canvas.width;\n // Origin is at the center, so start painting from bottom left.\n this.ctx.clearRect(width * -1 / 2, height * -1 / 2, width, height);\n }", "clear() {\n this.initExtent_ = null;\n var cl = '.' + this.br...
[ "0.6476026", "0.6432023", "0.6406941", "0.63067454", "0.6151516", "0.6095056", "0.60267067", "0.6012314", "0.597619", "0.5965265", "0.59409744", "0.593964", "0.59281194", "0.5899927", "0.58996135", "0.5866982", "0.5865915", "0.5865915", "0.5858312", "0.5831681", "0.5831681", ...
0.0
-1
send a message generated by the game
sendSystemMessage(message) { this.socket.emit('message', { author: 's', message }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sendMessage() {\n // Create a new message object\n var message = {\n text: vm.messageText\n };\n\n // Emit a 'gameMessage' message event\n Socket.emit('gameMessage', message);\n\n // Clear the message text\n vm.messageText = '';\n }", "function sendMessage() ...
[ "0.7751502", "0.75352097", "0.73547137", "0.73381305", "0.72015226", "0.71839905", "0.71601504", "0.71272326", "0.71263546", "0.71263546", "0.71263546", "0.71263546", "0.7095822", "0.70828533", "0.7076857", "0.70706624", "0.70581985", "0.7054318", "0.7052195", "0.7044975", "0...
0.65451103
78
send a message generated by one of the players
sendMessage(message) { this.socket.emit('message', message); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "sendTo(id, message) {\n var player = this.players.find((p) => p.id === id);\n player.connection.send(JSON.stringify(message));\n }", "sendToPlayer(aMessage) {\n\n for (let i = 0, len = this.players.length; i < len; i++) {\n if (this.players[i].playerId === aMessage.playerId) {\n ...
[ "0.79639065", "0.7776158", "0.75619465", "0.7207952", "0.7166972", "0.7135259", "0.69588274", "0.68574667", "0.6812895", "0.67871135", "0.6784861", "0.66565686", "0.6652135", "0.66487366", "0.66414315", "0.66342926", "0.66291404", "0.659166", "0.65823734", "0.65701365", "0.65...
0.0
-1
send a signal to the start of the game with the names of the players
startGame(name) { this.socket.emit('start', name); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startGame() {\n setMessage(player1 + ' gets to start.');\n}", "function startGame() {\n\tsocket.emit('start', {name: 'James'});\n}", "function start(){\n setupSocket();\n socket.emit('reqStartGame', gameConfig.userName);\n}", "function onNewPlayer (data) {\n \n}", "function start(){\r\n\tlet s...
[ "0.6884759", "0.6808482", "0.67596066", "0.6488705", "0.6474066", "0.6470885", "0.6468273", "0.64069504", "0.63981265", "0.6353156", "0.6343898", "0.63357323", "0.63175076", "0.6305977", "0.6287929", "0.6238478", "0.6212315", "0.6196422", "0.6192186", "0.61864316", "0.6163270...
0.665488
3
send a signal at the end of the game with the results
finishGame(result) { this.socket.emit('finish', result); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function end() {\n game.end();\n console.log('End!!, thank you for playing');\n }", "function handleEndGame() {\n\n}", "endGame(){\n score.addToScore(this.result, 'somejsontoken');\n this.scene.pause();\n const sceneEnd = this.scene.get('end');\n sceneEnd.scene.start();\n ...
[ "0.69510496", "0.6919027", "0.6847142", "0.67791104", "0.67781633", "0.6745507", "0.6679234", "0.66576", "0.66119057", "0.6600259", "0.6576552", "0.6538539", "0.6536058", "0.652828", "0.64970875", "0.64900976", "0.6465883", "0.64477736", "0.6447252", "0.6418915", "0.6395811",...
0.7161394
0
send a signal to reset the game for the next round
resetGame() { this.socket.emit('reset'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function reset() {\n //Reset the game\n channelResetGame();\n }", "function actionOnResetClick () {\n gameRestart();\n }", "resetGame() {\n\t\tthis.channel.push(\"reset\")\n .receive(\"ok\", this.onUpdate.bind(this));\t\n\t}", "resetGame() {\n\t\tthis.App.setGetter...
[ "0.7672655", "0.76647264", "0.76626587", "0.7553113", "0.7537287", "0.74972427", "0.74664915", "0.7408815", "0.737038", "0.73553544", "0.73511213", "0.7348525", "0.732928", "0.7314645", "0.72512853", "0.7236731", "0.7213177", "0.7209031", "0.71973866", "0.71859974", "0.717178...
0.7244821
15
send an opponent's turn at the end of the game
sendOpponentsTurn(turn) { this.socket.emit('opponent', turn); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "endTurn() {\n if (this.inProgress) {\n // Switch to next player's turn\n this.currentPlayer = this.getOtherPlayer(this.currentPlayer);\n this.startTurn();\n }\n }", "end () {\n this.game.newTurn()\n }", "endTurn() {\n if (this.board.checkWin(this.players[this.turn].token)) {\n ...
[ "0.76886964", "0.7676435", "0.7572936", "0.7259848", "0.7193252", "0.7177299", "0.7068617", "0.702776", "0.6910701", "0.68996096", "0.6873713", "0.6868094", "0.6856423", "0.68256366", "0.6820661", "0.6809798", "0.67920053", "0.6784056", "0.67697823", "0.67512333", "0.6748593"...
0.73576385
3
send a session id for the link generating
sendSessionId(id) { this.socket.emit('session', id); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createSessionLinkClicked() {\n m_AgentModel.createAgentSessionAndInvite(\"Guest\" + Date.now()).then(createAgentSessionAndInviteSuccess, createAgentSessionAndInviteFailure);\n }", "function generateURL(){\n\tbroadcastURL.innerHTML = baseURL+senderID;\n}", "function generateSessionID() {\n ...
[ "0.63716143", "0.62573135", "0.60630876", "0.6060723", "0.60326695", "0.5904934", "0.57281554", "0.5722326", "0.5656421", "0.562573", "0.5612139", "0.56084967", "0.5601752", "0.56007695", "0.55892795", "0.5568918", "0.5544686", "0.5542657", "0.5499129", "0.5470323", "0.545218...
0.61705726
2
send a player's turn
sendTurn(turn) { this.socket.emit('turn', turn); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "sendOpponentsTurn(turn) {\n this.socket.emit('opponent', turn);\n }", "function playerTurn(pIndex){\n\n\t//setTimeout(playerRespond, 10000);\n\n\tconsole.log('player ' + pIndex + ' turn');\n\n\tif(typeof SOCKET_LIST[pIndex] != 'undefined') {\n\n\tSOCKET_LIST[pIndex].emit('yourTurn', {msg: 'Your Turn'});\n\t\...
[ "0.71964073", "0.7136052", "0.7042372", "0.7031824", "0.6980621", "0.6948236", "0.69419414", "0.6849114", "0.6752371", "0.67469144", "0.66673136", "0.66418225", "0.66360927", "0.66275555", "0.6605708", "0.65964633", "0.6579888", "0.65728617", "0.65242845", "0.6493146", "0.646...
0.7435881
0
send a signal when the opponent leaves the game
onOpponentLeft() { this.socket.emit('left'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function leaveGame() {\n console.log(\"Leaving game...\");\n channelLeaveGame();\n }", "function leaveGame() {\n var gameID = currentGame.id;\n currentGame = undefined;\n socket.emit('boardleave', {\n gameID: gameID,\n boardID: boardID\n });\n openHomeScreen($(\"#gameLobbyScreen\"));\n}", "ha...
[ "0.79494196", "0.7415157", "0.71713495", "0.71672815", "0.7158593", "0.71479404", "0.6962964", "0.6952823", "0.6929892", "0.68846196", "0.68840754", "0.6879331", "0.6873736", "0.685218", "0.68362164", "0.6834251", "0.6826878", "0.6809137", "0.6785282", "0.67839384", "0.672170...
0.6277336
100
subscribe to client events with callback
subscribeTo(event, callback) { this.socket.on(event, callback); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "onClientSubscribed(callback) {\n this.subCallback = callback;\n }", "_subscribe (event, callback)\n {\n diva.Events.subscribe(event, callback, this.settings.ID);\n }", "function connectCallback(){\n\t\tconsole.log('connected');\t\t\n\t\tvar subscription = client.subscribe(\"/fx/prices\",...
[ "0.7907841", "0.72954357", "0.7145744", "0.69435334", "0.68627805", "0.6801563", "0.6798207", "0.6758364", "0.6728477", "0.67246217", "0.6704742", "0.6698427", "0.6682001", "0.66458625", "0.6644557", "0.66059804", "0.6578772", "0.6567718", "0.65609795", "0.6544383", "0.643832...
0.6737308
8
2. Given several arrays, create new array containing only unique elements for all of input arrays.
function uniteUnique(a,...arr) { const flattenArray = a.concat(arr.reduce((a, b) => a.concat(b))); return Array.from(new Set(flattenArray)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function uniteUnique(arr) {\nlet args = Array.protoype.slice.call(arguments);\nreturn args.reduce(function(a,b) {\n\nreturn a.concat(b.filter(function(subArray) {\n\nreturn a.indexOf(subArray) <0;\n\n}));\n});\n}", "function uniteUnique(arr) {\n var args = [...arguments];\n var result = [];\n for (var i = 0; ...
[ "0.83339137", "0.80901194", "0.80727464", "0.8022451", "0.7994129", "0.7990886", "0.79598975", "0.7909366", "0.7869001", "0.7827043", "0.7791869", "0.77429104", "0.77390736", "0.7737588", "0.77358884", "0.77215385", "0.77174586", "0.7709312", "0.77014667", "0.76974946", "0.76...
0.80011255
4
3. Convert the characters &, , " (double quote), and ' (apostrophe), in a string to their corresponding HTML entities.
function convertHTML(str) { const entities = { "&": "&amp;", "<": "&lt;", ">": "&gt;", "''": "&quot;", '"': "&quot;", "'": "&apos;" } return str.split('').map(item => item.replace(item, entities[item] || item)).join('') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function htmlEntities(str) {\n return String(str).replace(/&/g, '&').replace(/</g, '<')\n .replace(/>/g, '>').replace(/\"/g, '\"');\n}", "function convertHTML(str) {\n //split string into character array\n var placeHolder = str.split(\"\");\n //itterate through character array\n for(var i=0; i<plac...
[ "0.8279029", "0.8235238", "0.823395", "0.823395", "0.8196192", "0.8196192", "0.8196192", "0.8196192", "0.8196192", "0.8196192", "0.81928855", "0.8165583", "0.8165583", "0.8165583", "0.8165583", "0.8140383", "0.8129418", "0.8129418", "0.80808413", "0.8039946", "0.80050004", ...
0.76388174
42
4. Sum All Odd Fibonacci Numbers
function sumFibs(num) { let sequence = [0, 1]; let sumOdds = 0; for (let i = 2; i <= num; i++) { sequence.push(sequence[i - 1] + sequence[i - 2]); } let sum = sequence.filter(number => number <= num && number % 2 !== 0 ? sumOdds += number : false) .reduce((a, b) => a + b); return sum }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sumFibs(num) {\n\n //gets all Odd Fibonacci numbers and sums them. \n let oddFibArr = Fib(num).filter(x => x % 2 != 0);\n return oddFibArr.reduce((accumulator, currentValue) => {return accumulator + currentValue});\n\n}", "function sumFib() {\n\tvar fib = [1, 2]\n\tvar current = 0\n\tvar out = null\n...
[ "0.8024634", "0.795909", "0.7843713", "0.7808373", "0.77670485", "0.77382916", "0.7731607", "0.771222", "0.7683033", "0.76814675", "0.76800686", "0.7641087", "0.7640752", "0.76381356", "0.7626844", "0.7622938", "0.7618212", "0.7611541", "0.7601409", "0.75814205", "0.7580189",...
0.71339035
83
5. Sum All Primes up to given number
function sumPrimes(num) { let primes = []; for (let i = 0; i <= num; i++) { if (isPrime(i)) { primes.push(i); } } function isPrime(num) { for(let i = 2; i < num; i++) { if (num % i === 0) { return false } } return num !== 1 } return primes.reduce((a, b) => a + b) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sumAllPrimes() {}", "function sumPrimes(num) {\n if (typeof num !== 'number') {\n throw new Error('input should be a number.');\n }\n if (num % 1 !== 0) {\n throw new Error('input should be an integer.');\n }\n\n if (num === 1) {\n return 1;\n }\n var res = 0;\n\n for (var i = 2; i <= n...
[ "0.84147274", "0.7977097", "0.78900814", "0.78714657", "0.7844721", "0.7780234", "0.76993644", "0.7697142", "0.7669963", "0.76681334", "0.7667236", "0.76465327", "0.7643645", "0.764132", "0.7614474", "0.7612451", "0.75924844", "0.7580491", "0.75600594", "0.75530624", "0.75409...
0.7401906
28
7. Return an English translated sentence of the passed binary string.
function binaryAgent(str) { const stringArray = str.split(' '); const result = stringArray.map(number => String.fromCharCode(parseInt(number, 2))).join('') return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function toEnglish(str) {\r\n let binaryArray = str.split(\" \");\r\n let sentence = '';\r\n for (let i = 0; i < binaryArray.length; i++) {\r\n sentence += String.fromCharCode(parseInt(binaryArray[i], 2).toString(10))\r\n }\r\n return sentence;\r\n}", "function binaryAgent(str) {\n let e...
[ "0.81085414", "0.72315377", "0.63683426", "0.6237396", "0.6235842", "0.62287545", "0.6213609", "0.6163725", "0.6130035", "0.61133075", "0.6089286", "0.60805833", "0.60020393", "0.5993406", "0.5954138", "0.5942796", "0.5930398", "0.5917613", "0.5910548", "0.5909492", "0.587852...
0.0
-1
8. Given the array arr, iterate through and remove each element starting from the first element (the 0 index) until the function func returns true when the iterated element is passed through it.
function dropElements(arr, func) { const index = arr.map(item => func(item) ? true : false).indexOf(true) return index > -1 ? arr.slice(index) : [] ; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function dropElements(arr, func) {\n var limit = arr.length;\n\n for (i = 0; i < limit; i++) {\n var isTrue = func(arr[0]);\n\n if (isTrue) {\n return arr;\n }\n arr.shift();\n }\n\n return arr;\n}", "function dropElements(arr, func) {\n let originalLen = arr.length;\n for (let i = 0; i < ...
[ "0.831696", "0.8249444", "0.81684875", "0.81000185", "0.8077026", "0.8074772", "0.8006344", "0.7999665", "0.7990105", "0.7957879", "0.79576856", "0.7931272", "0.7914959", "0.79080933", "0.78776985", "0.7746103", "0.7704685", "0.75225264", "0.74975747", "0.74501663", "0.735028...
0.76238585
17
9. Flatten nested array of arrays
function steamrollArray(arr) { return arr.reduce((a, b) => Array.isArray(b) ? a.concat(steamrollArray(b)) : a.concat(b), []) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function myFlatten(arr) {}", "function flatten(arr) {\r\n const result = []\r\n\r\n arr.forEach(function(i) {\r\n if (Array.isArray(i)) {\r\n result.push(...flatten(i))\r\n } else {\r\n result.push(i)\r\n }\r\n })\r\n\r\n return result\r\n}", "function fla...
[ "0.7918741", "0.78472596", "0.7805369", "0.77169555", "0.77120024", "0.76833785", "0.767027", "0.76566625", "0.7643538", "0.7620274", "0.7619685", "0.7619458", "0.7601216", "0.7595509", "0.75951886", "0.7594552", "0.7577928", "0.75739753", "0.75490534", "0.7548975", "0.754788...
0.0
-1
10. Convert string to Spinal Tap Case. Spinal case is alllowercasewordsjoinedbydashes.
function spinalCase(str) { const splitChars = new RegExp(/(?=[A-Z])|[\s_-]/g); const stringArray = str.split(splitChars).map(item => item.toLowerCase()); return stringArray.join('-') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function spinalTap(str) {\n let lowercase = str.toLowerCase();\n let spinalCase = lowercase.replace(/ /g, \"-\"); //when using replace looking for the variable goes between / /g and g means global, second parameter is what it will be replaced with\n return spinalCase;\n}", "function spinalCase(str) {\n ...
[ "0.7296118", "0.72900563", "0.727541", "0.71348673", "0.71167713", "0.7096832", "0.70756185", "0.7068432", "0.7060628", "0.7017251", "0.7001353", "0.69898444", "0.69818485", "0.69571394", "0.6929263", "0.6885668", "0.6879267", "0.6875264", "0.68656", "0.68385196", "0.6823557"...
0.6874905
18
11. Count the letters in string and present it with Object
function count (string) { let stringArray = string.split(''); let result = string !== '' ? Object.assign(...stringArray.map(item => ({ [item] : 0 }))) : {}; stringArray.forEach(item => result[item] += 1) return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function countLetters(str) {\n var characters = str.split(' ').join('');\n var objectArray = {}\n // var charCount = 1;\n // for (occurences of characters) {\n for (var i = 0; i < characters.length; i++) {\n // for (char of characters) {\n if (objectArray[characters[i]]) {\n objectArray[charact...
[ "0.8228531", "0.8154193", "0.8095229", "0.80106884", "0.7987101", "0.797532", "0.79630435", "0.79344636", "0.79269964", "0.7924289", "0.7914112", "0.7891541", "0.7882526", "0.7878705", "0.78761005", "0.7872892", "0.787115", "0.7858569", "0.7848937", "0.7835935", "0.78324294",...
0.7089729
76
12. Merge arrays with consecutive indexes from both arrays
function mergeArrays(a, b) { let mergedString = []; for(var i = 0; i < a.length || i < b.length; i++) { if(i < a.length) mergedString.push(a[i]); if(i < b.length) mergedString.push(b[i]); } return Array.from(mergedString); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mergeArrayAlt(x, y) {\n\tvar temp = [];\n\tvar finalArray = [];\n\t\n\tif (x.length<y.length) { z = y.length}\n\t\telse { z = x.length}\n\tfor (var i = 0; i <= z; i++) {\n\t\t\n\t\t(temp.push(x[i]) && temp.push(y[i]))\n\t\n\t}\n\tfor (var i = 0; i <= temp.length; i++) {\n\t\ttemp[i] && finalArray.push(tem...
[ "0.6694973", "0.65318877", "0.64957553", "0.64656264", "0.6449475", "0.6405565", "0.6393141", "0.6390898", "0.6385321", "0.6373132", "0.6366437", "0.6353725", "0.6337797", "0.632875", "0.63012487", "0.63012487", "0.63012487", "0.63012487", "0.63012487", "0.63012487", "0.63012...
0.0
-1
13. Return index of value (+1) which differs from others in array (odd or even)
function iqTest(numbers){ const numbersArray = numbers.split(' ').map(Number) const evens = numbersArray.filter(number => number % 2 === 0) const odds = numbersArray.filter(number => number % 2 !== 0) return evens.length > odds.length ? numbersArray.indexOf(odds[0]) + 1 : numbersArray.indexOf(evens[0]) + 1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function determineMissingVal(array){\n for(var i=0; i<array; i++)\n if(i + 1 !== i + 1){\n return (i + 1)\n }\n }", "function findEvenIndex(array) {\n const sum = (accu, num) => accu + num;\n \n for (let idx = 0; idx < array.length; idx++) {\n let leftSum = 0;\n let rightSum = 0;\n \n if (id...
[ "0.7321246", "0.7246589", "0.71512914", "0.714647", "0.7073964", "0.6993564", "0.6939178", "0.69388974", "0.6893795", "0.6884639", "0.68802464", "0.68762577", "0.68651927", "0.68651927", "0.68651927", "0.68651927", "0.6848911", "0.68405044", "0.6829813", "0.68178165", "0.6807...
0.0
-1
14. Find how manyletters occurs more than once in string
function duplicateCount(text){ const textArray = text.toLowerCase().split(''); let result = 0; let counts = Object.assign({}, ...textArray.map(item => ({ [item] : 0}))); for (let i = 0; i < textArray.length; i++) { counts[textArray[i]] += 1 } for (key in counts) { counts[key] > 1 ? result += 1 : false } return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function noOfOccurance(str) {\n\tvar count=0;\n\tfor(let i=0; i<str.length; ++i) {\n\t\tif(str[i]==\"m\") count++\n\t}\n\treturn count;\n}", "function findDupe(string) { \n var dupeCheck = /(.)\\1/gi; // look for duplicated characters (character immediately followed by itself)\n var repeatTest = dupeCheck.test(...
[ "0.6976581", "0.6923063", "0.68574107", "0.6843052", "0.6833726", "0.6757124", "0.66626865", "0.6654922", "0.66428834", "0.6507143", "0.6463572", "0.64279276", "0.64036596", "0.6394487", "0.6387951", "0.6374103", "0.6374103", "0.63694507", "0.6369342", "0.63574046", "0.630152...
0.62331903
27
15. Find missing letters in string basing on alphabetical order
function findMissingLetter(array) { const letters = array.map(letter => letter.charCodeAt()); let desiredLetters = []; for (let i = letters[0]; i <= letters[letters.length - 1]; i++) { desiredLetters.push(String.fromCharCode(i)) } return desiredLetters.filter(item => array.indexOf(item) === -1).join('') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fearNotLetter(str) {\n //make an alphabet variable\n //run through alphabet to check for missing letters. break if i pasts str.length\n //\n\n var alphabet = \"abcdefghijklmnopqrstuvxyz\";\n var missed = [];\n\n// for (var j = 0; j < str.length; j++) { doesn't work\n for (var i = 0; i < alph...
[ "0.8457246", "0.8442286", "0.8323898", "0.8293135", "0.82247645", "0.82065976", "0.8132436", "0.8124905", "0.8113067", "0.8018683", "0.8008891", "0.8003773", "0.79565966", "0.7956227", "0.79148257", "0.7858123", "0.7853228", "0.78267664", "0.7763278", "0.77022886", "0.7701705...
0.77081543
19
Second take find missing one
function missingLetter(arr) { const charCodes = arr.map(letter => letter.charCodeAt()) let missingLetter = '' for (let i = 0; i < charCodes.length; i++) { if (charCodes[i] - charCodes[i - 1] !== 1) { missingLetter = charCodes[i - 1] + 1 } } return String.fromCharCode(missingLetter) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findMissing(arr) {}", "function findMissing(arr, size) \n{ \n // First separate positive and \n // negative numbers \n let shift = moveNegToLeft(arr, size); \n let arr2 = [];\n let j = 0; \n for (let i = shift; i < arr.length; i++) { \n arr2[j] = arr[i]; \n j++; \n } \...
[ "0.6601595", "0.61444175", "0.60305583", "0.6028692", "0.6021894", "0.5976524", "0.59475046", "0.5917172", "0.5914425", "0.58616865", "0.58186674", "0.5810592", "0.57475656", "0.5739567", "0.57071036", "0.56950474", "0.5673385", "0.56725246", "0.5668374", "0.56479454", "0.563...
0.0
-1
16. Deep comparison of objects
function deepEqual(a, b){ if (a && b && typeof a == 'object' && typeof b == 'object') { if (Object.keys(a).length != Object.keys(b).length) return false; for (var key in a) if (!deepEqual(a[key], b[key])) return false; return true; } else return a === b }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deepEqual(obj1, obj2) {\n // Your code here\n}", "function deepCompare(objA, objB, equivalent) {\n // keep track of references that have been compared to find circular references while walking down either object\n var refsComparedA = [];\n var refsComparedB = [];\n var compare = Boolean(equ...
[ "0.7577784", "0.7351779", "0.7342702", "0.7342702", "0.7287281", "0.7250316", "0.72388905", "0.7224809", "0.72019285", "0.71998537", "0.7181442", "0.7181442", "0.7181442", "0.71781975", "0.71781975", "0.7178109", "0.7170191", "0.7159835", "0.7151451", "0.7107348", "0.7079773"...
0.67104685
52
19. Sort a String by Its Last Character
function sortByLast(str) { const sortedWords = str.split(' ').map(word => word).sort((a, b) => { if (a[a.length - 1] < b[b.length - 1]) { return -1 } else if (a[a.length - 1] > b[b.length - 1]) { return 1 } else { return 0 } }) return sortedWords.join(' ') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function urutkanAbjad2(str) {\n return str.split('').sort().join('')\n}", "function getSortedString(string){\n return string.split(\"\").sort().toString(); \n}", "function getSortedString(string) {let sortStrin = string.split(\"\"); sortStrin.sort(); return sortStrin.join(\"\");\r\n}", "function sortStri...
[ "0.73504514", "0.7336824", "0.72816396", "0.72572213", "0.71808577", "0.7065178", "0.7016823", "0.6996387", "0.68869996", "0.6860201", "0.6860201", "0.6860201", "0.683683", "0.6812374", "0.6777139", "0.67342144", "0.66990286", "0.6686181", "0.6684203", "0.66410565", "0.661801...
0.77595496
0
20. Remove Surrounding Duplicate Items
function uniqueInOrder(sequence) { let uniques = []; const seq = Array.from(sequence); for (let i = 0; i < seq.length; i++) { if (seq[i] !== seq[i + 1]) { uniques.push(seq[i]) } } return uniques }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_dedupe(ary) {\n return ary.sort().filter((item, ndx, _ary)=>{\n if (ndx!=0 && item == ary[ndx-1]) return false;\n return true;\n });\n }", "function removeDuplicates (input) {\n\t\t\tlet result = input.filter(function(item, pos) {\n\t\t\t\treturn input.indexOf(item) == pos;\n\t\t\t});\n\t\t\tr...
[ "0.6711983", "0.6588869", "0.65707386", "0.64771503", "0.6367818", "0.6337578", "0.63142693", "0.62739086", "0.6251929", "0.6157323", "0.61516106", "0.6134493", "0.6129573", "0.60934573", "0.60917705", "0.6083215", "0.60722315", "0.60650355", "0.6044694", "0.6029644", "0.6028...
0.0
-1
21. Sort array by string length
function sortByLength(arr) { return arr.sort((a, b) => a.length - b.length); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sortByLength(strs) {\n let sortedArray = \n strs.sort((sortedArray, valueLength) => {return sortedArray.length - valueLength.length})\n return sortedArray;\n}", "function lengthSort(arr) {\n const strLength = arr.sort((a, b) => {\n return a.length > b.length\n })\n return st...
[ "0.8184822", "0.79398924", "0.77538085", "0.7751571", "0.7698661", "0.76981646", "0.74773765", "0.74591637", "0.73479635", "0.72697186", "0.72274846", "0.7005432", "0.69486356", "0.68758756", "0.68354577", "0.6825232", "0.68046784", "0.6792436", "0.6639663", "0.66071326", "0....
0.7706217
4
22. Calculate shortest path
function shortestDistance(str) { const [x1, y1, x2, y2] = str.split(',').map(Number); const distance = parseFloat((Math.hypot(x2 - x1, y2 - y1)).toFixed(2)) return distance }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findShortestPath(){\n\t\tstate.edgesOfSP = [];\n\t\tstate.shortestPath = [];\n\t\t\t\t\n\t\tGraph.instance.nodes.forEach(\n function(key, node)\n {\n\t\t\t\t\t\t\t\t\n\t\t\t\tnode.state.distance = Number.MAX_SAFE_INTEGER;\n\t\t\t\tnode.state.predecessor = null;\n });\n\n ...
[ "0.786536", "0.759348", "0.7533884", "0.7437864", "0.7371489", "0.73416996", "0.734095", "0.72980666", "0.72614545", "0.7248142", "0.72400343", "0.70577806", "0.7053828", "0.70215183", "0.70094174", "0.6996425", "0.69814694", "0.6951859", "0.692815", "0.6876241", "0.68689764"...
0.0
-1
23. Create a function that, given a string with at least three characters, returns an array of its: Length. First character. Last character. Middle character, if the string has an odd number of characters. Middle TWO characters, if the string has an even number of characters.
function allAboutStrings(str) { const length = str.length; const firstChar = str.charAt(0); const secondChar = str.charAt(1); const lastChar = str.charAt(length -1); const middle = function() { return length % 2 === 0 ? str.slice(length / 2 - 1, length / 2 + 1) : str[Math.floor(length / 2)] } const index = function() { const indexOfChar = str.indexOf(secondChar, 2) return indexOfChar > -1 ? `@ index ${indexOfChar}` : 'not found' } return [length, firstChar, lastChar, middle(), index()] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function evenIndexOddLength(str){\r\n\tvar arr2=[]\r\n\tfor(i=0;i<str.length;i++){\r\n\t\tif(i%2==0){\r\n\t\t\tvar length=str[i].length;\r\n\t\t\tif(length%2==1){\r\n\t\t\t\tarr2.push(str[i])\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\nreturn arr2;\r\n}", "function evenIndexOddLength(str){\n newArray=[];\n newIndex=0;...
[ "0.7128366", "0.68216336", "0.6791437", "0.64848226", "0.6484448", "0.64346665", "0.6254088", "0.6238378", "0.6236261", "0.62094754", "0.6184258", "0.6179053", "0.6172659", "0.6172527", "0.61677796", "0.6154831", "0.6114847", "0.60897005", "0.6078952", "0.6074194", "0.6074033...
0.0
-1
24. Count letters in string and return most common characters
function getWordsNums(str) { const lettersCount = {} str.split('').forEach(letter => { if (lettersCount[letter]) { lettersCount[letter] += 1 } else { lettersCount[letter] = 1 } }) const maxNum = Math.max.apply(null, Object.values(lettersCount)) let mostCommonLetters = []; for (let letter in lettersCount) { if (lettersCount[letter] === maxNum) { mostCommonLetters.push(letter) } } return mostCommonLetters }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mostCommonLetter(string){\n var max_val = 0;\n var max = [];\n const hash = makeObject(string.split(\"\"));\n for (var property in hash){\n var value = hash[property];\n if (value > max_val && property.match(/[a-z]/)){\n max_val = value;\n max = [property,va...
[ "0.77775264", "0.77656007", "0.77375805", "0.7708366", "0.7609125", "0.7542989", "0.75277066", "0.7465178", "0.74535584", "0.74526507", "0.7444204", "0.74433523", "0.74248946", "0.74248946", "0.7418291", "0.74140966", "0.74076575", "0.73985255", "0.7386941", "0.7385994", "0.7...
0.7798117
0
26. Write a function that takes a string and calculates the number of letters and digits within it. Return the result as an object.
function countAll(str) { const numbers = /\d/g const letters = /[a-zA-Z]/g const numbersCount = (str.match(numbers) || []).length const lettersCount = (str.match(letters) || []).length const result = Object.assign({}, { "LETTERS": lettersCount, "DIGITS": numbersCount}) return result }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function countLetters(str) {\n // 3. initialize a return value of the correct type\n var letterCounts = {};\n\n // 4. iterate over the arguments\n for (var i = 0; i < str.length; i++) {\n // 5. modify the return value\n var letter = str[i];\n // skip the spaces\n if (letter === ' ') {\n contin...
[ "0.742529", "0.7414194", "0.7278642", "0.7190122", "0.71704197", "0.7161027", "0.7134542", "0.712796", "0.7121764", "0.709006", "0.70786476", "0.7070044", "0.7021065", "0.70179474", "0.7017341", "0.699543", "0.69640326", "0.6959378", "0.6921073", "0.68797046", "0.6869294", ...
0.71877253
4
27. Separate number with tousands
function formatNum(num) { const number = num.toString(10).split(''); for (let i = number.length - 3; i > 0; i -= 3) { number.splice(i, 0, '-') } return number.join('') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "formateraPris(num) {\n return num.toString().replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1 ')\n }", "function crore(number){\n\t\t\t\tif(number.length==8){\n\t\t\t\t\tsubnum=number[1]+number[2]+number[3]+number[4]+number[5]+number[6]+number[7];\n\t\t\t\t\tword= first[number[0]]+\" \"+unit[3]+\" \"+lakh(subnum);\...
[ "0.6862047", "0.6659993", "0.6618155", "0.6591738", "0.65577644", "0.64357054", "0.642178", "0.6397444", "0.636832", "0.63642603", "0.63539493", "0.6338837", "0.63181895", "0.63173443", "0.6303549", "0.62787986", "0.6269384", "0.62636954", "0.62489116", "0.622622", "0.6224757...
0.61692286
23
30. Show number of letters that occurs more than once in string
function duplicateCount(str) { const string = str.split('').sort() const regex = /(.)\1+/g return (string.join('').match(regex) || []).length }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function duplicateCount(text){\n text = text.toLowerCase().split(\"\")\n const countedletters = text.reduce((allLetters, letter) => {\n if(letter in allLetters) {\n allLetters[letter]++\n } \n else {\n allLetters[letter] = 1\n }\n return allLetters \n }, {})\n const filterDup = Object.val...
[ "0.78741354", "0.7830165", "0.78235537", "0.76727176", "0.7591548", "0.7586402", "0.7573049", "0.7564191", "0.7556518", "0.7490383", "0.7477371", "0.7449258", "0.74243796", "0.7411731", "0.7324794", "0.7319751", "0.7292305", "0.7251579", "0.7218156", "0.7206858", "0.7206858",...
0.7793539
3
31. Convert "Zero" and "One" Text to '1' and '0'
function textToNumberBinary(str) { const numberText = str.split(' ').map(item => item.toLowerCase()); const toNumber = numberText .filter(num => num === 'one' || num === 'zero') .map(num => num === 'one' ? 1 : 0) const modulo = toNumber.length % 8 return modulo < toNumber.length ? toNumber.slice(0, toNumber.length - modulo).join('') : '' }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function transformZeroOne(str) {\n let result = \"\";\n let i;\n for (i = 0; i < str.length; i++) {\n if (str.charAt(i) == '0') {\n result = result + \"1\";\n }\n else if (str.charAt(i) == '1') {\n result = result + \"0\";\n }\n else {\n ...
[ "0.70748353", "0.6656873", "0.62984365", "0.6231381", "0.61003757", "0.5966611", "0.59325844", "0.5909509", "0.58878833", "0.58697844", "0.5795095", "0.5785131", "0.5779857", "0.5777689", "0.5684896", "0.5668184", "0.5635173", "0.56226027", "0.5614832", "0.56143063", "0.55969...
0.64143234
2
32. Truncate String at a Given Length. Return full words only.
function truncate(string, length) { const words = string.split(' ') const lengths = words .map(word => word.length + 1) .reduce((a, x, i) => [...a, x + (a[i - 1]|| 0)], []); const lastToReturn = lengths.filter(word => word <= length + 1); return words.slice(0, lastToReturn.length).join(' ') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function truncate(text, length) {\n\torg_length = text.length;\n\ttext = text.split(\" \"); // word boundary\n\ttext = text.slice(0, length);\n\ttext = text.join(\" \");\n if(org_length != text.length) {\n return text + \" [...]\";\n }\n return text;\n}", "function _usfTruncateWords (str, size = ...
[ "0.7822646", "0.72504795", "0.7189429", "0.7139332", "0.7066584", "0.7030608", "0.7025828", "0.701365", "0.69669276", "0.69648504", "0.6947168", "0.6884133", "0.67702615", "0.67450327", "0.67443657", "0.67405105", "0.6707129", "0.66868484", "0.6686247", "0.6672268", "0.665915...
0.7835502
0
33. Delete digit from number and find the max number
function deleteDigit(n) { const stringNum = n.toString().split(''); const numbers = []; stringNum.map((elem, index) => { const strings = [...stringNum]; strings.splice(index, 1); numbers.push(strings.join('')); }) return Math.max(...numbers) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deleteDigit(n) {\n n = n.toString();\n var largestNum = 0;\n\n for(var i = 0; i < n.length; i++){\n var string;\n if(i == 0){\n string = n.substring(1,n.length);\n largestNum = largestNum;\n } else {\n string = n.substring(0,i)+n.substring(i+1);\n }\n if(parseInt(string)>l...
[ "0.7570189", "0.73849106", "0.71563727", "0.71302646", "0.68143743", "0.67663825", "0.6549432", "0.65159374", "0.6462695", "0.642658", "0.6415886", "0.63775885", "0.6370742", "0.6366339", "0.6364066", "0.6362354", "0.6353597", "0.63357896", "0.6233341", "0.620129", "0.6199203...
0.7367003
2
Triggered on a button click, or some other target
function deletePhoto() { $scope.work.email = $rootScope.email; $scope.menuOpened = 'closed'; if(confirm('Delete this photo?')){ $scope.work.src = ''; } //$state.reload(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "click(event) {\n if (event.target === this.get('element')) {\n this.sendAction();\n }\n }", "buttonClicked() {\n alert(\"buttonclicked of button\");\n }", "handleClick() {}", "click() { }", "clickHandler() {\n // Activate if not active\n if (this.active === false) {\n ...
[ "0.7129205", "0.71274203", "0.70519394", "0.70100874", "0.7009356", "0.69695574", "0.6947523", "0.6925836", "0.68973273", "0.6869489", "0.68631476", "0.68496287", "0.68113595", "0.6802331", "0.6797954", "0.67514503", "0.6745544", "0.6745544", "0.66927975", "0.6691575", "0.668...
0.0
-1
REVIEW: Private methods declared here live only within the scope of the wrapping IIFE
function render(repo) { var source = $('#repo-template').html(); var template = Handlebars.compile(source); return template(repo); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _privateFn(){}", "_privateFunction() {}", "privateMethod() {\n\t}", "function modulePrivateMethod () {\n return;\n }", "function modulePrivateMethod () {\n return;\n }", "private public function m246() {}", "function __it() {}", "transient protected internal function m189() {}", "t...
[ "0.690412", "0.6643857", "0.6379963", "0.6324414", "0.6324414", "0.6299605", "0.6270576", "0.62692714", "0.6226121", "0.6181532", "0.607718", "0.60644317", "0.60604095", "0.60559607", "0.6045605", "0.5982101", "0.5975253", "0.59735763", "0.59726804", "0.59563035", "0.59415483...
0.0
-1
Given an arbitrary input string, return the first nonrepeating character. For strings with all repeats, return 'sorry'.
function firstNonRepeatedCharacter (string) { var array = string.split(""); var repeats = []; var result = array.shift(); while(array.length > 1) { if(~array.indexOf(result) || ~repeats.indexOf(result)) { repeats.push(result) result = array.shift(); } else return result; } return 'sorry'; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function firstNotRepeatingCharacter(s) {\n\tlet strings = s.split('');\n\tlet repeating = {};\n\tlet nonRepeat = '';\n\tfor (let i = 0; i < s.length; i++) {\n\t\trepeating[strings[i]] ? repeating[strings[i]]++ : repeating[strings[i]] = 1;\n\t}\n\tfor (let str in repeating) {\n\t\t!nonRepeat && repeating[str] === 1...
[ "0.86891407", "0.8262015", "0.82429105", "0.82408106", "0.82123095", "0.8188155", "0.81409717", "0.81328577", "0.80891097", "0.8057813", "0.7959438", "0.7924877", "0.7823694", "0.7752391", "0.7719638", "0.7688991", "0.76845646", "0.7565949", "0.7553666", "0.7551158", "0.74939...
0.88065624
0
so that when we run a function addTo80
function addTo80(n) { return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addTo80(n) {}", "function addTo80(n) {\n return n + 80;\n}", "function addTo80(n){\n console.log('long time');\n return n + 80;\n}", "function addTo80(n) {\n console.log('long time')\n return n + 80;\n}", "function addTo80(n) {\n console.log('long time')\n return n + 80;\n}", ...
[ "0.75746405", "0.67722994", "0.6433007", "0.6424085", "0.6424085", "0.6424085", "0.6424085", "0.6424085", "0.6424085", "0.6424085", "0.6424085", "0.61973006", "0.6074274", "0.60254574", "0.602396", "0.6014254", "0.6011228", "0.59030515", "0.5880982", "0.55996233", "0.55572796...
0.6708402
4
& we put in five 5
function addTo80(n) { return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function timesFive(num) {\n\treturn num * 5;\n}", "function fifth(v){\n var v = limiter(v,0,4);\n pitches[2] = afifth+treatfifth[v];\n if(DBUG) note(root);\n}", "function timesFive(num) {\nreturn num * 5;\n}", "function timesFive(num){\n return num * 5;\n }", "function timesFive (num) {\n return nu...
[ "0.6648669", "0.65702885", "0.6551639", "0.6550911", "0.64089316", "0.6404878", "0.6397679", "0.63919663", "0.63919663", "0.63919663", "0.63919663", "0.63919663", "0.63919663", "0.63919663", "0.63511616", "0.62883174", "0.627781", "0.62745094", "0.6239804", "0.6230296", "0.61...
0.0
-1
nice & simple. right? but if I run this function again
function addTo80(n) { return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private internal function m248() {}", "static private internal function m121() {}", "private public function m246() {}", "function wa(){}", "protected internal function m252() {}", "transient protected internal function m189() {}", "transient private protected internal function m182() {}", "function ...
[ "0.6215401", "0.5873983", "0.5818654", "0.57975453", "0.5759312", "0.5651396", "0.5635911", "0.5630121", "0.55799127", "0.556169", "0.5551402", "0.5550368", "0.55422485", "0.55333966", "0.55167127", "0.55087084", "0.55024445", "0.54726094", "0.5468923", "0.543009", "0.5375162...
0.0
-1
I have go through this step again return n + 80; & add 80 to the answer & if I do this again do the same thing
function addTo80(n) { return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addTo80(n) {\n console.log('long time')\n return n + 80;\n}", "function addTo80(n) {\n console.log('long time')\n return n + 80;\n}", "function addTo80(n) {\n console.log('long time')\n return n + 80;\n}", "function addTo80(n) {\n console.log('long time')\n return n + 80;\n}"...
[ "0.724438", "0.724438", "0.724438", "0.724438", "0.724438", "0.724438", "0.724438", "0.724438", "0.72220695", "0.70546263", "0.7026345", "0.68467134", "0.65265113", "0.64872193", "0.6460005", "0.64497674", "0.6447124", "0.6444865", "0.64275545", "0.6412231", "0.64044386", "...
0.7019965
13
I have ran the calculation three times but what if this operation took a really rerally long time? what if I have a console log here
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "solve() {\n\t\tlet times = [];\n\t\tlet iteration = 10\n\n\t\tfor(let i = 0; i < iteration; i++) {\n\t\t\tlet start = 0;\n\t\t\tlet end = 1;\n\t\t\tlet step = Math.pow(2, -20);\n\n\t\t\tlet timeAtStart = performance.now();\n\t\t\tlet res = this.integrate(start, end, step);\n\t\t\tlet timeAtEnd = performance.now();...
[ "0.64715916", "0.6462244", "0.6272199", "0.62267506", "0.62025696", "0.6147368", "0.6142876", "0.61333543", "0.61049813", "0.60215896", "0.60205746", "0.5997257", "0.5922241", "0.58758354", "0.58460355", "0.5845805", "0.58074087", "0.57976097", "0.5793311", "0.5776071", "0.57...
0.0
-1
the first time I run this function
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "firstRun() { }", "function init() {\n\n// reset();\n lastTime = Date.now();\n main();\n }", "function init() {\n lastTime = Date.now();\n main();\n }", "function init() {\n lastTime = Date.now();\n main();\n }", "function init() {\n //UH HUH,...
[ "0.6766388", "0.64585394", "0.63310313", "0.63310313", "0.6261697", "0.6229116", "0.62076616", "0.6197378", "0.6190601", "0.6190601", "0.6190601", "0.6190601", "0.61785424", "0.616066", "0.61581904", "0.6155999", "0.6155999", "0.61158854", "0.61062133", "0.6067028", "0.605246...
0.0
-1
so it didnt calculate the long time lets try it again
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "tryLoadingAgain(){\n\t\t examTime = this.state.defaultTime;\n\t\tvar LoadingInterval = setInterval(function() {\n\t\t\n\t\tif(examTime){\n\t\t var timer = examTime.split(':');\n\t\t var minutes = parseInt(timer[0], 10);\n\t\t var seconds = parseInt(timer[1], 10);\n\t\t --seconds;\n\t\t minutes = (seconds < 0)...
[ "0.6502362", "0.6455605", "0.6438532", "0.6398023", "0.6382952", "0.63810414", "0.6353288", "0.6341388", "0.6311998", "0.6293727", "0.6266198", "0.6253219", "0.6170833", "0.61694825", "0.61454624", "0.6145053", "0.61179984", "0.6097807", "0.60648113", "0.6038079", "0.60293424...
0.0
-1
just so we can distinguish them so the first call & the second call
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function callTwice(func) {\n func();\n func();\n}", "function callFunctions(first, second) {\r\n closeOther(first);\r\n toggleCurrent(second);\r\n updateParentHeight(second);\r\n }", "function multiple (first, second){\n first()\n second()\n}", "function ca...
[ "0.5893672", "0.58352244", "0.573554", "0.5735526", "0.5421523", "0.5420741", "0.53956956", "0.53685725", "0.53230196", "0.5322318", "0.528796", "0.52845323", "0.52634495", "0.52513844", "0.524748", "0.5226222", "0.52007794", "0.51630896", "0.51612103", "0.51384246", "0.51239...
0.0
-1
if the parameter changes
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static _valueHasChanged(value,old,hasChanged=notEqual){return hasChanged(value,old);}", "static _valueHasChanged(value,old,hasChanged=notEqual){return hasChanged(value,old)}", "_paramsChanged() {\n this._loading = true;\n this._getChanges().then(results => {\n this._results = results;\n ...
[ "0.73293924", "0.71837115", "0.69686353", "0.6932063", "0.675416", "0.663468", "0.65994817", "0.65682524", "0.6559453", "0.653697", "0.6506872", "0.6473931", "0.64618635", "0.63650185", "0.63650185", "0.63650185", "0.63600886", "0.63600886", "0.63589513", "0.6316801", "0.6292...
0.0
-1
there you go thats better
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private internal function m248() {}", "protected internal function m252() {}", "static private internal function m121() {}", "private public function m246() {}", "transient protected internal function m189() {}", "function l(){t={},u=\"\",w=\"\"}", "function comportement (){\n\t }", "static private p...
[ "0.60988706", "0.5668204", "0.55833787", "0.5539155", "0.52815396", "0.5177308", "0.51577413", "0.51366395", "0.5063135", "0.5042506", "0.5030319", "0.5023027", "0.49880368", "0.4968764", "0.49663088", "0.49312937", "0.492277", "0.49224707", "0.49149388", "0.491374", "0.49103...
0.0
-1
so remember this memoizatioin is simply a way to remember a solution to a solved problem so you dont have to calculate it again /////////////////////////////////////////// 15. MCI Memoization 2 welcome back I wanna improve this function just a little bit
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_updateMemo(validTeam) {\n for (let pairIdx = 0; pairIdx < validTeam.length; ++pairIdx) {\n let p1Idx = this.players.indexOf(validTeam[pairIdx].value[0]);\n let p2Idx = this.players.indexOf(validTeam[pairIdx].value[1]);\n this.memo[p1Idx][p2Idx] = 1;\n this.memo[p2Idx][p1Idx] = 1;\n }\n ...
[ "0.6236899", "0.6231103", "0.6106422", "0.5949426", "0.59163874", "0.5773342", "0.5757453", "0.56437784", "0.5638813", "0.56343824", "0.56265354", "0.5604042", "0.55448", "0.5538416", "0.55228716", "0.5520899", "0.5517151", "0.54846984", "0.5475922", "0.5471079", "0.5462006",...
0.0
-1
you see ideally we dont wanna fill the cache in what we call the global scope that is to be living outside of this function
function addTo80(n) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Cache() {}", "function cacheToMemory(){\n // need to implement\n}", "function MapCache() {\n }", "function EntryCache() {}", "function _cache() {\n $window = $(window);\n $body = $('body');\n $html = $('html');\n $header = $...
[ "0.75936097", "0.7376213", "0.72212726", "0.7167553", "0.7128271", "0.6979924", "0.6979924", "0.6950778", "0.69125533", "0.6906052", "0.688847", "0.6859728", "0.6859043", "0.68208766", "0.6772378", "0.6772378", "0.6772378", "0.67403704", "0.6722784", "0.6707961", "0.66989124"...
0.0
-1
ideally is good practice to have memory or in this cache to live inside of the function & not polluting the global scope & there is many ways to do this based on the language in javascript we can use something call closures this is what it looks will look like & I am showing you this becasue when it comes to dynamic programming you are gonna see this pattern a lot luckely for dynamic programming the pattern is always the same so when you learn this it becomes easier & easier so the way we bring this inside of a function its to bring it like that
function addTo80(n) { console.log('long time') return n + 80; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Cache() {}", "function advanceMemoizedAddTo80(){\n let functionChache = {}; // We put cache inside the function to avoide polutting global scope and keep it priivate\n\n // We return a function and use cache from HOF to trigger closure\n return function(n){\n if (n in functionChache){\n retur...
[ "0.69127244", "0.6480688", "0.6432459", "0.6394184", "0.63591576", "0.63591576", "0.63591576", "0.6242968", "0.62227196", "0.6214833", "0.615352", "0.61446387", "0.61055446", "0.6091892", "0.6085023", "0.6042529", "0.6024485", "0.59990686", "0.59977555", "0.5924102", "0.58701...
0.0
-1
we get long time, because the cache gets reset everytime the function gets called so cache become an emty object to get arround this we have closures in javascriipt & we can return another function so a function that return another function
function memoizedAddTo80(n) { let cache = {}; return function() {} if (n in cache) { return cache[n]; } else { console.log('long time'); cache[n] = n + 80; return cache[n]; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cacheFn(fn) {\n var cache={}\n return function(arg){\n if (cache[arg]){\n return cache[arg];\n }\n else{\n cache[arg] = fn(arg);\n return cache[arg];\n }\n }\n}", "function cacheFn(fn) {\n var cache={};\n \n return function(arg...
[ "0.8099808", "0.8068072", "0.77801967", "0.7729668", "0.7729668", "0.7729668", "0.7434575", "0.73842865", "0.7382386", "0.73792297", "0.7323842", "0.72769976", "0.7234652", "0.7234652", "0.7234652", "0.7234652", "0.72054297", "0.7196953", "0.71960175", "0.71960175", "0.719414...
0.0
-1
& we will have the logic inside of this function
function memoizedAddTo80(n) { let cache = {}; return function(n) { if (n in cache) { return cache[n]; } else { console.log('long time'); cache[n] = n + 80; return cache[n]; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private internal function m248() {}", "protected internal function m252() {}", "private public function m246() {}", "transient protected internal function m189() {}", "static private internal function m121() {}", "transient private protected internal function m182() {}", "function comportement (){\n\t ...
[ "0.6288217", "0.6086061", "0.59922093", "0.5880195", "0.58064514", "0.5777362", "0.5760509", "0.57602364", "0.56292623", "0.55947435", "0.54689884", "0.5452931", "0.5375683", "0.5307052", "0.5307052", "0.5301729", "0.5296738", "0.52511704", "0.5244812", "0.5237455", "0.522825...
0.0
-1
now this isnt a course about javascript so you can read on closures on your on this is just a way for us to avoid that global scope so that this time arround we can do something like this we can simply says const memoize equals memoized add to eighty
function memoizedAddTo80(n) { let cache = {}; return function(n) { if (n in cache) { return cache[n]; } else { console.log('long time'); cache[n] = n + 80; return cache[n]; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function advanceMemoizedAddTo80(){\n let functionChache = {}; // We put cache inside the function to avoide polutting global scope and keep it priivate\n\n // We return a function and use cache from HOF to trigger closure\n return function(n){\n if (n in functionChache){\n return functionChache[n]; \n ...
[ "0.7932556", "0.75566965", "0.75435054", "0.7467715", "0.74546564", "0.7367088", "0.7303672", "0.7288813", "0.6953555", "0.69526356", "0.6825191", "0.6822666", "0.67915165", "0.674904", "0.6740133", "0.6722825", "0.6680449", "0.66787326", "0.66735655", "0.65716076", "0.656641...
0.728849
8
& we will run this function, & we can actuually remove the parameter from here
function memoizedAddTo80(n) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function remove(params) {\n \n}", "function removeParam(param) {\n param.parentNode.remove();\n paramNum--;\n filterProjects();\n}", "function removeParam(elem)\n{\n\telem.parentNode.remove();\n\tparamNum--;\n\tupdateParameterIDs();\n\tupdateParameterDisplay();\n\tupdateDateParameterDisplay();\n}", "re...
[ "0.6878291", "0.68744487", "0.6767936", "0.6425514", "0.6425514", "0.6397087", "0.6201814", "0.6118643", "0.6079193", "0.60693455", "0.60566753", "0.5993444", "0.59789896", "0.5912986", "0.5877159", "0.5866871", "0.5775134", "0.57604605", "0.5748253", "0.5697254", "0.56784284...
0.0
-1
If I hit run
function memoizedAddTo80(n) { let cache = {}; return function(n) { if (n in cache) { return cache[n]; } else { console.log('long time'); cache[n] = n + 80; return cache[n]; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function run() {}", "function run() {\n\n }", "function run() {\n }", "Run() {\n\n }", "run () {\n }", "firstRun() { }", "function run() {\n\n}", "run() {\n console.log('running');\n }", "function Runner() {\n }", "function Main()\n {\n \n }", "function run() {\...
[ "0.764136", "0.7634096", "0.76048684", "0.7555137", "0.75201917", "0.7480115", "0.7270924", "0.7023327", "0.65426934", "0.64890146", "0.6455395", "0.62470204", "0.6234097", "0.6210931", "0.6200068", "0.61896044", "0.6189454", "0.6185233", "0.6185233", "0.6185233", "0.6185233"...
0.0
-1
still get the same thing but if I do five & five & I hit run
function memoizedAddTo80(n) { let cache = {}; return function(n) { if (n in cache) { return cache[n]; } else { console.log('long time'); cache[n] = n + 80; return cache[n]; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function test6() {\n\tcpuThing();\n\tcpuThing();\n\tcpuThing();\n}", "function call3Times(fun) {\n fun();\n fun();\n fun();\n }", "ba () {\n\t\tfor (let i = 0; i < 3; i++)\n\t\t\tthis.b();\n\t}", "private internal function m248() {}", "function run() {}", "fa () {\n\t\tfor (let i = 0; i < 3; i+...
[ "0.604852", "0.5832404", "0.5760929", "0.5684098", "0.56361157", "0.56291527", "0.55893254", "0.5586596", "0.5581819", "0.5561391", "0.5531154", "0.547901", "0.54715115", "0.54676247", "0.5460531", "0.5451479", "0.54401296", "0.5430763", "0.5428161", "0.54092216", "0.5376181"...
0.0
-1
the first thing is I wanna have a function purchase item
function purchaseItem() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function purchaseItem() {\n return\n}", "function buyItem() {\n\n}", "function purchaseItem(...fns)\n\n\n{} // & these spreads functions", "buyItem(item) {\n console.log(\"Buying Item:\", item.name);\n }", "async purchaseItem(itemId) {\n const purchase_result = await this.__request(`htt...
[ "0.8342371", "0.7989643", "0.79634017", "0.74341846", "0.7175238", "0.7161689", "0.71031296", "0.7054489", "0.70529747", "0.7047216", "0.6994746", "0.6994746", "0.6922395", "0.6867456", "0.6867275", "0.6837554", "0.68308353", "0.68210524", "0.67894405", "0.6778703", "0.676953...
0.9116018
1
well we wanna add items to cart so I am gonna create another function function item to cart
function purchaseItem() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addItemToCart() {}", "function addItemToCart() {}", "function addItemToCart(user, item) {\n\n}", "function addItemToCart(user, item) {}", "function addSelectedItemToCart() {\n // TODO: suss out the item picked from the select list\n let selectedItem = event.target.items.value;\n console.log(sel...
[ "0.8940321", "0.8940321", "0.8155021", "0.81098574", "0.7791912", "0.77705944", "0.7721911", "0.7632187", "0.7620293", "0.7620024", "0.761393", "0.7609286", "0.7605263", "0.758573", "0.75797313", "0.7572231", "0.75492984", "0.75395", "0.7538596", "0.7520567", "0.749862", "0...
0.7573287
19
lets keep it in a single line now because we dont have anything what else? we wanna going to add tax so I am going to create another function called apply tax to items
function purchaseItem() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function applyTaxToItems(user){}", "function applyTaxToItems(user){\n return user\n}", "function applyTaxToItems(user){\n return user\n}", "function applyTaxToItems(user){\n return user\n}", "function applyTaxToItems(user){\n const\n}", "function applyTaxToItems(user){\n const {cart} = use...
[ "0.82794803", "0.7679643", "0.7679643", "0.7679643", "0.767222", "0.7354384", "0.72163326", "0.7209355", "0.7174598", "0.7147243", "0.70932364", "0.70679075", "0.7009929", "0.69942296", "0.6977067", "0.6943837", "0.69415694", "0.68762374", "0.6773404", "0.6766114", "0.6765331...
0.0
-1
we have function buy item which physically move the cart to purchases
function purchaseItem() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buyItem() {\n\n}", "function onClickActionBuyItem(){\n\t\tconst itemlist = CashShop.cartItem;\n\t\tCashShop.cartItemLen = itemlist.length;\n\n\t\tCashShop.ui.find('#purchase-btn').prop('disabled', true);\n\t\tUIManager.showPromptBox( 'Are you sure you want to buy this items?', 'ok', 'cancel', function()...
[ "0.775649", "0.7679755", "0.7633439", "0.7633439", "0.74070024", "0.7394752", "0.7386125", "0.73530257", "0.72818875", "0.72294647", "0.7205487", "0.7161662", "0.7105715", "0.7081886", "0.70432967", "0.7015942", "0.70101935", "0.70070195", "0.69522434", "0.6883477", "0.685434...
0.78279006
2
& then we finally do the empty cart so function emty cart
function purchaseItem() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function clearCart() {}", "function clearCart() {}", "function clearCart() {}", "function emptyCart(){\n\t\t\tvar itemsLength = items.length;\n\t\t\t\n\t\t\tfor(var i = items.length-1; i > -1; i--){\n\t\t\t\tvar item = items[i];\n\t\t\t\tremoveItem(item);\n\t\t\t}\n\t\t}", "function cleanCart1() {\n car...
[ "0.77301615", "0.77301615", "0.77301615", "0.7599717", "0.73499167", "0.7247057", "0.72282135", "0.71791124", "0.7101905", "0.7101905", "0.7059855", "0.705698", "0.7005569", "0.6946875", "0.6930711", "0.69159544", "0.6883997", "0.68674487", "0.68501097", "0.68275934", "0.6816...
0.0
-1
alright, so we have a function that its gonna affect the data that we have that is the user now based on what I have learnt about functional programming I want to keep this pure But it also looks like that I am applying a lot of steps to the same data maybe we can use something like compose to compose all these steps so that purchase item does well all these things overhere so the first thing I want to do is ... just to test out that it is working lets just create the naive approach where we return from the purchase item
function purchaseItem() { return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function purchaseItem(...fns) => fns.reduce(compose)\n\n{} // & act over the data that we receive", "function purchaseItem(...fns)\n\n\n{} // & these spreads functions", "function purchaseItem(...fns) => fns\n\n{} // so what I am going to do is I am going to use reduce", "function purchaseItem(...fns) => fns...
[ "0.75663817", "0.72611165", "0.71876824", "0.7094834", "0.67399645", "0.6666149", "0.64740074", "0.64740074", "0.64740074", "0.64740074", "0.64740074", "0.64740074", "0.64454186", "0.6055888", "0.5888335", "0.5810008", "0.5718459", "0.57121986", "0.5688035", "0.5681305", "0.5...
0.66171724
6
& you know lets remane this to add item to cart
function addItemToCart() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "add() {\n\t\torinoco.cart.add({ imageUrl: this.imageUrl, name: this.name, price: this.price, _id: this._id });\n\t}", "addItemsToCart() {\n\n Model.addItemsToCart(this.currentItems);\n }", "function addItemToCart(user, item) {}", "add_item(item){\n this.cart.push(item);\n }", "function plusIt...
[ "0.80289423", "0.7951706", "0.782097", "0.77059007", "0.76256496", "0.7609333", "0.7531692", "0.7489221", "0.7471281", "0.7468693", "0.7456459", "0.7432144", "0.74275243", "0.73932433", "0.7347546", "0.73469263", "0.7327334", "0.7311202", "0.73070645", "0.7220665", "0.7216613...
0.86462176
1
so I have compose now I also want to define purchase item & this purchase item, actually we have it over here so lets come down here
function purchaseItem(user, item) { return Object.assign({}, user, {purchases: item}) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem(...fns)\n\n\n{} // & these spreads functions", "function purchaseItem() {\n return\n}", "const...
[ "0.727297", "0.727297", "0.727297", "0.727297", "0.727297", "0.727297", "0.70026785", "0.6661041", "0.64595735", "0.63892055", "0.61534715", "0.6072996", "0.60124046", "0.59969634", "0.5984104", "0.59651357", "0.59627867", "0.59553546", "0.59493595", "0.59424603", "0.59066206...
0.5769069
32
this purchase item we want to change the things up a bit overhere
function purchaseItem() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function toggleItem(item)\r\n{\r\n\tif( item != null) {\r\n\t\titem.purchased = !item.purchased;\r\n\t}\r\n\tstoreGroceryItems();\r\n}", "function purchaseItem() {\n return\n}", "function buyPart(item) {\n let protoBotCopy = protoBot\n let shopCopy = shop\n \n if(item.purchased == false){\n ...
[ "0.6632466", "0.65459836", "0.6524627", "0.63573635", "0.63125753", "0.62897676", "0.6277555", "0.6234478", "0.61377096", "0.61035097", "0.6078959", "0.6075155", "0.60364413", "0.60189277", "0.6002777", "0.6000541", "0.59729636", "0.5970764", "0.5959535", "0.5957957", "0.5942...
0.6934476
4
& we dont necessarily know how many I am going to just spread these options
function purchaseItem(...fns) {} // & these spreads functions
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "setOptions() {\n let defaultObj = {numChar: 1, limitNum: 3, orderBlock: [\"suggest\",\"collection\",\"product\"]};\n if(!this.options)\n {\n this.options = defaultObj; // set default if user not put arg\n }\n else {\n for(let key in defaultObj) // \n ...
[ "0.6296692", "0.6229331", "0.60555184", "0.6036937", "0.59611887", "0.5857179", "0.5850716", "0.58108497", "0.5807634", "0.57800317", "0.5762394", "0.5762276", "0.5688545", "0.5688545", "0.5647844", "0.56362975", "0.56268764", "0.5605479", "0.5605479", "0.55404353", "0.552853...
0.0
-1
are going to well return what I wanna use these functions & I want to be able to compose them
function purchaseItem(...fns) => fns {} // so what I am going to do is I am going to use reduce
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compose(fns) {\n\n\n}", "function purchaseItem(...fns) => fns.reduce(compose)\n\n{} // so I have to make sure that I have returned in here this property", "function composeb(func1,func2){ //is this binary because it returns not one, but two functions?\n return function (g,f, num){ // add 2,3, 7\n ...
[ "0.6607604", "0.6416578", "0.6068393", "0.5940703", "0.59095144", "0.59085655", "0.58972174", "0.5883336", "0.5865786", "0.5855806", "0.5815793", "0.57466054", "0.5741605", "0.5714493", "0.57067674", "0.56651366", "0.5653502", "0.5622856", "0.55920035", "0.55890065", "0.55773...
0.5766416
11
& if you are not sure what reduce is make sure that you check out the video that I linked to with advanced arrays. see Apendix
function purchaseItem(...fns) => fns.reduce() {} // & in reduce I am going to pass a callback function
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function myReduceFunc() {\n \n\n\n}", "reduce() {\r\n if(Array.flatten) {\r\n return this.data.flatten().reduce();\r\n } else {\r\n let result = 0;\r\n this.data.forEach(row => {\r\n row.forEach(col => {\r\n result+=col;\r\n });\r\n });\r\n return result;\r\n }\r\n }", "f...
[ "0.70079684", "0.700092", "0.69834745", "0.6824466", "0.6821715", "0.6779021", "0.67678154", "0.6656209", "0.6577741", "0.657169", "0.6560853", "0.65490896", "0.65481114", "0.6509517", "0.65061", "0.6496124", "0.64708626", "0.6467925", "0.64503884", "0.64462924", "0.6436405",...
0.0
-1
that will take a previous value & the current value or an acumulator & the next value (metabox VSC) so if I pass compose here
function purchaseItem(...fns) => fns.reduce(compose) {} // the reduce function which is in itself a higher order function
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function prev() {\n setValue(()=>{\n return checkValue(value-1)\n })\n }", "next() {\n if (this.current == \"one\") {\n this.current = \"two\";\n return { done: false, value: \"one\" };\n } else if (this.current == \"two\") {...
[ "0.6041371", "0.557325", "0.55440396", "0.5481243", "0.54521555", "0.5446675", "0.5441352", "0.5373858", "0.53607875", "0.532396", "0.5307277", "0.5293061", "0.5290401", "0.52287143", "0.5175065", "0.5166755", "0.5137306", "0.51222676", "0.51196367", "0.51195794", "0.5101783"...
0.0
-1
so that we can compose these function
function purchaseItem(...fns) => fns.reduce(compose) {} // & act over the data that we receive
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compose(fns) {\n\n\n}", "function purchaseItem(...fns) => fns.reduce(compose)\n\n{} // so I have to make sure that I have returned in here this property", "function composeb(func1,func2){ //is this binary because it returns not one, but two functions?\n return function (g,f, num){ // add 2,3, 7\n ...
[ "0.6345967", "0.615991", "0.56928635", "0.5634372", "0.5570481", "0.55608267", "0.5547047", "0.547136", "0.54338455", "0.5426822", "0.5402632", "0.53909796", "0.5327671", "0.53140926", "0.53140926", "0.53102547", "0.53102475", "0.52887946", "0.52790856", "0.52790856", "0.5279...
0.5532358
7
alright. so lets go step by step now & see what we can do the first thing that we wanna do is add item to the cart
function addItemToCart() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addItemToCart(user, item) {}", "addItemsToCart() {\n\n Model.addItemsToCart(this.currentItems);\n }", "function plusItem() {\n const productId = this.name;\n const cartList = JSON.parse(sessionStorage.getItem(\"shoppingCartItems\"));\n const item = cartList.find(product => product.id == p...
[ "0.7884259", "0.78679025", "0.7798888", "0.7790149", "0.7696799", "0.76712114", "0.7661179", "0.76113385", "0.7587312", "0.75871974", "0.7568137", "0.75622666", "0.7552005", "0.7528808", "0.75203323", "0.7518572", "0.74920255", "0.74919647", "0.7483685", "0.74645793", "0.7458...
0.8706155
0
so with add item to cart is going to receive a user & the item
function addItemToCart(user, item) {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addItemToCart(user, item) {\n\n}", "function addItemToCart() {}", "function addItemToCart() {}", "function addItemToCart(user, item) {\n const updateCart =\n}", "function addItemToCart(user, items){\n let updateCart = user.cart.concat(items);\n // NOTE: data is userClone = Object.assign({...
[ "0.86442643", "0.78838146", "0.78838146", "0.7850546", "0.78492063", "0.78016156", "0.762496", "0.7584301", "0.7567533", "0.75562954", "0.7517896", "0.7493544", "0.7486697", "0.7315249", "0.7228306", "0.71794397", "0.71628356", "0.7137561", "0.7130775", "0.7121816", "0.712102...
0.87651664
0
& in here we are going just to create a simple function
function addItemToCart(user, item) { }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function miFuncion (){}", "function miFuncion(){}", "function miFuncion(){}", "function miFuncion(){}", "function fuction() {\n\n}", "function FunctionUtils() {}", "function fn() {\n\t\t }", "function fuctionPanier(){\n\n}", "function fun() { }", "function Func_s() {\n}", "function wa(){}", "...
[ "0.6846714", "0.66745746", "0.66745746", "0.66745746", "0.6510141", "0.6484599", "0.64455307", "0.6414932", "0.63165045", "0.6299673", "0.62687385", "0.6230335", "0.6230335", "0.6230335", "0.6224723", "0.62069297", "0.62023824", "0.6182819", "0.6175313", "0.61737627", "0.6166...
0.0
-1
we want to add updated cart
function addItemToCart(user, item) { const updateCart = }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addItemToCart() {}", "function addItemToCart() {}", "function updateCart(){\n reset();\n cart.forEach(product =>{\n appendProduct(product);\n }); \n}", "function updateCart(){if(window.Cart&&window.Cart.updateCart){window.Cart.updateCart();}}", "addItemsToCart() {\n\n Model.addI...
[ "0.8023247", "0.8023247", "0.78119016", "0.7780558", "0.7669045", "0.76668334", "0.7640263", "0.760191", "0.75257057", "0.7512255", "0.7428099", "0.74118245", "0.7401798", "0.74007976", "0.7391378", "0.7379137", "0.7378248", "0.7376177", "0.73525816", "0.7335645", "0.73255366...
0.70222306
57
that is completely different & copyed from the previous array or the original array & in here I am going to pass the item that we are buying
function itemToCart(user, item) { const updateCart = user.cart.concat(item) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function repItem(arr, currentItem, newItem) {\n let copiedArr = arr.map((x) => x);\n let index = copiedArr.indexOf(currentItem);\n copiedArr[index] = newItem;\n return copiedArr\n}", "function copy(copyArr, originalArr) { \n copyArr = [...originalArr]; \n return copyArr;\n}", "shiftItems...
[ "0.6815738", "0.64752036", "0.6192296", "0.6188991", "0.6161992", "0.613069", "0.6128394", "0.6104195", "0.6063231", "0.6041329", "0.6027541", "0.60241276", "0.5995722", "0.59897804", "0.5968565", "0.58765817", "0.5843857", "0.5839801", "0.5824132", "0.5813239", "0.5783303", ...
0.0
-1
so that we can finally return object dot assign
function addItemToCart(user, item) { const updateCart = user.cart.concat(item) return Object.assign() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function obj(objec){\nreturn objec;\n}", "function va(t){if(null==t)throw new TypeError(\"Object.assign cannot be called with null or undefined\");return Object(t)}", "function obj() { return this; }", "static _assignValue(path, value, object) {\n object = object || ApplicationState._state;\n\n ...
[ "0.6274991", "0.61238664", "0.608425", "0.6035963", "0.60276204", "0.6004529", "0.6002419", "0.5988431", "0.59763557", "0.59763557", "0.5954386", "0.5940906", "0.59347355", "0.5934214", "0.5923343", "0.5923343", "0.59211713", "0.58987343", "0.5883731", "0.5881172", "0.5826062...
0.0
-1
& in here we return a new object once again
function addItemToCart(user, item) { const updateCart = user.cart.concat(item) return Object.assign({}, ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "clone() {\n let dupe = new this.constructor();\n dupe.reset(this);\n return dupe;\n }", "copy()\n\t{\n\t\treturn this.constructor.createNewInstance(this);\n\t}", "_copy () {\n return new this.constructor()\n }", "_copy () {\n return new this.constructor()\n }", "function cre...
[ "0.657636", "0.63893676", "0.6364459", "0.6364459", "0.63483757", "0.63348764", "0.63084733", "0.6158661", "0.6122519", "0.61044735", "0.6052735", "0.5989147", "0.59789383", "0.59742403", "0.59719545", "0.59447813", "0.59289485", "0.58715993", "0.5862494", "0.5821202", "0.581...
0.0
-1
user with a new cart item
function addItemToCart(user, item) { const updateCart = user.cart.concat(item) return Object.assign({}, user, { cart: updateCart }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addItemToCart(user, item) {}", "function addItemToCart(user, item) {\n\n}", "function addItemToCart() {}", "function addItemToCart() {}", "function addToCart(newItem) {\n console.log(newItem);\n const index = findCartItem(\n newItem.product.id,\n newItem.toppings,\n newItem.re...
[ "0.82395875", "0.7978252", "0.7760381", "0.7760381", "0.72897327", "0.71969545", "0.71794224", "0.71717244", "0.71566486", "0.7147307", "0.71265256", "0.7104232", "0.7067987", "0.703836", "0.69683385", "0.6932553", "0.6902601", "0.68475765", "0.6825322", "0.6822244", "0.68034...
0.6456069
75
alright. in order to see that this works lets from all the other functions you see I am returning a new user state so in all these fuunctions I am going to have a user
function applyTaxToItems(user){}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "user(state, user) {\n state.user = user;\n }", "user(state) {\n return state.user;\n }", "function getUserState() {}", "authUser (state, userData) {\n \t\tstate.idToken = userData.token\n \t\tstate.userId = userData.userId\n \t}", "setUserData(state, user){\n console.log(\"[DEU...
[ "0.7273137", "0.7270626", "0.7173517", "0.7024309", "0.6937717", "0.6777617", "0.67558646", "0.67555803", "0.67399144", "0.6671136", "0.6637633", "0.6628149", "0.6592974", "0.6562243", "0.65427953", "0.64737827", "0.64362234", "0.641464", "0.64080155", "0.64080155", "0.639339...
0.0
-1