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
Convert time (in seconds) to sample frames.
function timeToSampleFrame(time, sampleRate) { return Math.floor(0.5 + time * sampleRate); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function get_frame(time, rate) {\n // time, modulo 1000\n var tm = time % 1000;\n\n return FRAMES.find(function(row) {\n return in_range(tm, row.t) && in_range(rate, row.p);\n }) || FRAMES[0];\n }", "function convertFBXTimeToSeconds( time ) {\n \n return time / 46186158000;\n \...
[ "0.6350146", "0.59681106", "0.57764506", "0.57042986", "0.55744076", "0.5537533", "0.55334747", "0.53582275", "0.53066754", "0.5302927", "0.52929574", "0.526894", "0.52566713", "0.52218205", "0.51708126", "0.5166514", "0.5132372", "0.5121376", "0.50552726", "0.50326866", "0.5...
0.76305866
1
Compute the number of sample frames consumed by noteGrainOn with the specified |grainOffset|, |duration|, and |sampleRate|.
function grainLengthInSampleFrames(grainOffset, duration, sampleRate) { var startFrame = timeToSampleFrame(grainOffset, sampleRate); var endFrame = timeToSampleFrame(grainOffset + duration, sampleRate); return endFrame - startFrame; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function countSamples() {\r\n\treturn samplesPayload.length;\r\n}", "function timeGetNoteDuration(frameCount, framerate) {\r\n // multiply and devide by 100 to get around floating precision issues\r\n return ((frameCount * 100) * (1 / framerate)) / 100;\r\n }", "function extractRegions(peaks, ...
[ "0.54483503", "0.5200871", "0.49365148", "0.48975325", "0.48564744", "0.48074478", "0.47971657", "0.47572035", "0.4742263", "0.4742263", "0.47342214", "0.47128752", "0.46815202", "0.46801907", "0.46679893", "0.46470097", "0.46269438", "0.46092045", "0.459472", "0.45821646", "...
0.80002797
1
True if the number is not an infinity or NaN
function isValidNumber(x) { return !isNaN(x) && (x != Infinity) && (x != -Infinity); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isInfinite(val) {\n return val === Infinity;\n}", "function isInfinity(num) {\n \treturn num === Infinity || num === -Infinity\n }", "function _is_finite(val) {\n return Number.isFinite(val);\n}", "function infinity (data) {\n return data === neginf || data === posinf;\n }", "funct...
[ "0.83113205", "0.7954703", "0.7877363", "0.7829695", "0.77674556", "0.7473482", "0.7283507", "0.72724444", "0.7270449", "0.7215269", "0.71945333", "0.7182642", "0.71646", "0.7135317", "0.7135317", "0.7135317", "0.7114644", "0.703502", "0.6985724", "0.69838434", "0.6982191", ...
0.7208824
11
Compute the (linear) signaltonoise ratio between |actual| and |expected|. The result is NOT in dB! If the |actual| and |expected| have different lengths, the shorter length is used.
function computeSNR(actual, expected) { var signalPower = 0; var noisePower = 0; var length = Math.min(actual.length, expected.length); for (var k = 0; k < length; ++k) { var diff = actual[k] - expected[k]; signalPower += expected[k] * expected[k]; noisePower += diff * diff; } return signalPower / noisePower; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _getExpectedBandwidthValue() {\n var expectedBandwithValue;\n if (config.carreraHistoricalPercentileToUse === 20) {\n expectedBandwithValue = _expectedBandwidth.bandwidth20Percentile;\n } else if (config.carreraHistoricalPercentileToUse === 90) {\n expectedBandwi...
[ "0.5154946", "0.5017675", "0.499605", "0.49512017", "0.4935788", "0.49323398", "0.49150115", "0.4839564", "0.48385224", "0.48289174", "0.48261806", "0.480619", "0.47847325", "0.4780171", "0.47348353", "0.47194365", "0.47194365", "0.46878043", "0.46868166", "0.4670587", "0.466...
0.64634144
0
ShouldModel internal class. For the exposed (factory) method, it is the return value of this closure.
function ShouldModel(desc, target, opts) { this.desc = desc; this.target = target; // Check if the target contains any NaN value. this._checkNaN(this.target, 'ACTUAL'); // |_testPassed| and |_testFailed| set this appropriately. this._success = false; // If the number of errors is greater than this, the rest of error // messages are suppressed. the value is fairly arbitrary, but shouldn't // be too small or too large. this.NUM_ERRORS_LOG = opts.numberOfErrorLog; // If the number of array elements is greater than this, the rest of // elements will be omitted. this.NUM_ARRAY_LOG = opts.numberOfArrayLog; // If true, verbose output for the failure case is printed, for methods where this makes // sense. this.verbose = !opts.brief; // If set, this is the precision with which numbers will be printed. this.PRINT_PRECISION = opts.precision; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Model() {}", "model() {\n return internal(this).model;\n }", "function Model() {\n}", "static getModel() {\n return routineModel;\n }", "function basicModel() {\n \n }", "function Model() {\n\n }", "function ModelHelper() {\n\t\t_classCallCheck(this, ModelHelper);\n\...
[ "0.62028885", "0.6197895", "0.59545344", "0.5945527", "0.59162444", "0.59136474", "0.5836788", "0.57529134", "0.5716754", "0.5716754", "0.56531435", "0.5636745", "0.56162685", "0.5605941", "0.5591446", "0.5563791", "0.5544396", "0.5444619", "0.54355425", "0.5387195", "0.53866...
0.0
-1
Strip headers in certain JSON editor instances
function removeSurplusHeaders(headers) { headers.each(function(i, x) { var p = jQuery(x).parent().parent().parent(); if (p.attr('data-schematype') === 'object') { if (p.children(':nth-child(2)')[0].tagName === 'SELECT') { x.remove(); } } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function strip_headers (message) {\n return _.chain(message)\n .omit('fluenttag')\n .omit('headers')\n .value()\n}", "function fixJson(json) {\n let errorPos = json.indexOf('}<br');\n return errorPos > -1\n ? json.substring(0, errorPos + 1)\n : json;\...
[ "0.6204736", "0.61748415", "0.60104775", "0.58575886", "0.58575886", "0.5811076", "0.5730324", "0.56786734", "0.56786734", "0.56786734", "0.5671428", "0.56273216", "0.55995786", "0.5585817", "0.556497", "0.5551799", "0.55355114", "0.55069745", "0.5496576", "0.54460347", "0.54...
0.5348192
23
Display title in headers
function displayHeaders(x) { x.find('h3 span[style="display: none;"]').attr('style', ''); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function header(title) {\r\n console.log(\"===================================\")\r\n console.log(\" \"+title)\r\n console.log(\"===================================\")\r\n }", "function printHeader(){\n\t\t\t\t\t\t// title\n\t\t\t\t\t\tif (title !== \"\"){\n\t\t\t\t\t\t\tdoc.setFont(myFont,\"bold\");...
[ "0.8019258", "0.75148916", "0.75016415", "0.73750424", "0.73750424", "0.73750424", "0.73750424", "0.73750424", "0.73750424", "0.72748125", "0.7182724", "0.7070212", "0.70236015", "0.7007795", "0.69933045", "0.69797283", "0.6903122", "0.6879097", "0.6878557", "0.687239", "0.68...
0.0
-1
Load binary executable file
function loadExecutable() { return new Promise((resolve, reject) => { const input = document.createElement('input'); input.type = 'file'; input.onchange = (event) => { resolve(event.target.files[0]); } input.click(); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function load_appbin(file) {\n let mrbreader = new FileReader();\n mrbbin = null;\n mrbreader.onload = function() {\n // initialize sequence number\n wrtseq = 0;\n mrbbin = new Uint8Array(mrbreader.result);\n document.getElementById(\"load_status\").innerText += \" loaded.\";\n }\n mrbreader.readA...
[ "0.6373058", "0.61452144", "0.59468627", "0.59468627", "0.59462476", "0.5887935", "0.5882859", "0.58736014", "0.57451487", "0.56787026", "0.56787026", "0.56787026", "0.56787026", "0.56787026", "0.5607702", "0.5580628", "0.5526667", "0.5499195", "0.5440852", "0.54091257", "0.5...
0.58485913
8
global xhrLoadJSON, sortArrayByProperties, html2fragment, dateToIsoDate, toggleClass DOCUMENT READY without jQuery, IE9+
function ready(callback) { if (document.readyState !== 'loading') { callback(); } else { document.addEventListener('DOMContentLoaded', callback); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadJSONCallBack(data) {\n\tdocument.todos = data;\n\tdisplayToDos(todoDisplayConfig);\n\tgenerateSelectDateButtGroup();\n generateSelectTagButtGroup();\n}", "function loadJSONs( url, which ){\n var AJAX_req = new XMLHttpRequest();\n AJAX_req.overrideMimeType(\"application/json\");\n AJAX_req.open...
[ "0.5867031", "0.5843885", "0.57327056", "0.5732231", "0.57292104", "0.5681123", "0.5626627", "0.5561626", "0.5555187", "0.55373174", "0.545564", "0.5441956", "0.540481", "0.5336009", "0.5335759", "0.5311982", "0.530824", "0.5305358", "0.5302272", "0.5300963", "0.53004533", ...
0.0
-1
select event from event list that is nearest today's date
function selectNearestEvent(list) { const today = dateToIsoDate(); for (let i = 0; i < list.length; ++i) { if (list[i].getAttribute('aria-label') >= today) { list[i].click(); break; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "fetchClosestEvent(context) {\n return new Promise((resolve, reject) => {\n HTTP.get('events/', {\n headers: {\n 'Authorization': 'Token ' + context.state.token\n }\n })\n .then((response) => {\n // date ...
[ "0.64623785", "0.64091116", "0.59861034", "0.55447406", "0.5431274", "0.5422294", "0.54206127", "0.5412271", "0.54041237", "0.5300801", "0.52712387", "0.52607554", "0.5256995", "0.5256774", "0.5238601", "0.5238382", "0.51978445", "0.5188055", "0.5185487", "0.5174478", "0.5173...
0.74301726
0
Convert 4 uint8 values to a single int32 value
function uchar2int32(arr, off) { var u8arr = new Uint8Array([arr[off], arr[off+1], arr[off+2], arr[off+3]]); return new Int32Array(u8arr.buffer)[0]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function bytes_to_int32 (arr, off) {\n\tconst first = arr[off + 3] << 24;\n\tconst second = arr[off + 2] << 16;\n\tconst third = arr[off + 1] << 8;\n\tconst fourth = arr[off];\n\treturn first | second | third | fourth;\n}", "function bytes_to_int32(arr, off) {\n return (arr[off + 3] << 24) | (arr[off + 2]...
[ "0.7634906", "0.75258386", "0.7496103", "0.72058517", "0.70201105", "0.69868195", "0.69846404", "0.697494", "0.68102145", "0.6782383", "0.67340297", "0.672449", "0.6707146", "0.6706376", "0.6706376", "0.6676822", "0.6629398", "0.65469074", "0.6536801", "0.65287894", "0.647865...
0.7381298
3
Write a four byte integer into the byte array
function write_int32(arr, off, val) { var i32arr = new Int32Array([val]); var u8arr = new Uint8Array(i32arr.buffer); for (var i = 0; i < u8arr.length; ++i) { arr[off + i] = u8arr[i]; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "writeInt(num = 0) {\n let bytes = [];\n\n for (let i = 0; i < 4; i++) {\n let byte = num & 0xff;\n bytes.push(byte);\n num = (num - byte) / 256;\n }\n\n this.buf = this.buf.concat(bytes);\n this.offset += 4;\n }", "writeUB4(value) {\n if (...
[ "0.72743213", "0.702786", "0.64158887", "0.63632214", "0.63319796", "0.6260878", "0.62272745", "0.6216541", "0.6216541", "0.6216541", "0.62162006", "0.62138253", "0.61147785", "0.6003115", "0.6003115", "0.599699", "0.59913945", "0.5986381", "0.5986381", "0.592916", "0.5898242...
0.6046525
13
processingPaths[key] > [callbackN .. callback1 onRead1 ... onReadN]
function addFileToQueue(filename, callback){ if (processingPaths[filename]) { if (typeof callback == 'function') processingPaths[filename].unshift(callback); return; } processingPaths[filename] = typeof callback == 'function' ? [callback].concat(readCallbacks) : readCallbacks.slice(); if (readingCount < READ_LIMIT) readFile(filename); else { logMsg('fs', relativePath(filename) + ' ' + chalk.yellow('(add file to queue)'), true); filesToRead.push(filename); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "map(callback, ...names) {\n const result = [];\n this.each((path, index) => {\n result[index] = callback(path, index);\n }, ...names);\n return result;\n }", "_loop(index0, callback) {\n for (const key0 in index0) callback(key0);\n }", "function processKey(key, callback) {\n call...
[ "0.6286285", "0.55189586", "0.55110484", "0.5452118", "0.54299724", "0.5394351", "0.516959", "0.5100569", "0.5092256", "0.5092256", "0.5092256", "0.5092256", "0.5092256", "0.50861984", "0.50857806", "0.5066147", "0.50651526", "0.5054322", "0.50195336", "0.4982668", "0.4982350...
0.46250632
64
convert an array of things with names to obj[name] = thing
function loadAnything(what, input, transformer) { const ret = {}; if (input === undefined) return ret; const _transformer = transformer || ((i) => i); for (const myThing of input) { ret[myThing.name] = _transformer(myThing); } return ret; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function objectify(array){\n\toutobject = {}\n\tfor(var i = 0; i < array.length; i++){\n\t\toutobject[array[i][0]] = array[i][1]\n\t}\n\treturn outobject;\n}", "function toObject(arr) {\r\n\tvar rv = {};\r\n \tfor (var i = 0; i < arr.length; ++i) {\r\n \t\trv[arr[i].name] = arr[i].value;\r\n \t}\r\n\treturn rv;...
[ "0.6188368", "0.5986043", "0.59619623", "0.59542894", "0.58586913", "0.5805252", "0.5775838", "0.5720033", "0.5678412", "0.5666025", "0.56539345", "0.5622708", "0.5576196", "0.5576196", "0.557374", "0.55518126", "0.55518126", "0.55518126", "0.55518126", "0.55518126", "0.55518...
0.50385696
80
convert array of variables to hash function args, fields, it's all good
function loadProperties(input) { return loadAnything('property', input); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "convertHashArgsIfNeeded(inputArgs) {\n if (!(inputArgs.length == 1 && typeof inputArgs[0] == 'object' && !Array.isArray(inputArgs[0]))) return [[], inputArgs];\n inputArgs = inputArgs[0]; //first element is hashmap\n\n let args = [], errors = [];\n\n for (let inputName of Object.keys(inputArgs)) {\n ...
[ "0.59125674", "0.5779992", "0.5739556", "0.5665879", "0.56109965", "0.5553021", "0.5386699", "0.5368973", "0.53588796", "0.5271747", "0.50920063", "0.50767875", "0.5074217", "0.5057153", "0.5043764", "0.50402766", "0.5039924", "0.50306016", "0.5000576", "0.49759313", "0.49427...
0.0
-1
convert array of methods to hash
function loadMethods(input) { return loadAnything('function', input, (myFunc) => new InspectorFunction(myFunc)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function instantize(obj, methodArray)\n{\n const undone = [];\n let f;\n for(let i = 0, len = methodArray.length; i < len; ++i) {\n const m = methodArray[i];\n f = obj[m];\n if(f) { // SIC single =\n obj[m] = f;\n }else{\n undone.push(m);\n }\n }\n return undone; // return list of u...
[ "0.5772325", "0.56302917", "0.5608695", "0.55253786", "0.5488549", "0.537607", "0.53411037", "0.5309069", "0.5289103", "0.5264115", "0.52518713", "0.52420187", "0.52420187", "0.5215125", "0.52046305", "0.52046305", "0.52046305", "0.52046305", "0.52046305", "0.52046305", "0.52...
0.0
-1
convert array of classes to hash
function loadClasses(input) { const ret = {}; for (const myClass in input) { if ({}.hasOwnProperty.call(input, myClass)) { ret[myClass] = new InspectorClass(input[myClass]); } } return ret; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function hashClasses() {\n for (i in classes) {\n nodeHash[classes[i].class] = classes[i]\n }\n for (i in relations) {\n relations[i].source = nodeHash[relations[i].source]\n relations[i].target = nodeHash[relations[i].target]\n }\n }", "function classes() {\n var classes = [];\n ...
[ "0.680082", "0.5882", "0.5829021", "0.5792205", "0.5789032", "0.572261", "0.5675641", "0.5665474", "0.5665474", "0.564708", "0.5580964", "0.5520635", "0.5488449", "0.5424676", "0.54057187", "0.53751403", "0.5369497", "0.53503144", "0.534026", "0.5339771", "0.52531725", "0.5...
0.592439
1
the argument should be a javascript object in the form outputted by the debug language TODO: should probably copy the object first
constructor(typeInformationModel) { this.rootTypes = loadClasses(typeInformationModel.rootTypes); this.enums = loadEnums(typeInformationModel.enums); this.allCallbacks = loadMethods(typeInformationModel.allCallbacks); this.referencedTypes = new Set(typeInformationModel.referencedTypes); this.typePrefix = typeInformationModel.typePrefix; this.baseClass = typeInformationModel.baseClass; this.namespace = typeInformationModel.namespace; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function argToString(obj){if(typeof obj==='string'){return obj;}else{var platform=PlatformSupport.getPlatform();try{return platform.formatJSON(obj);}catch(e){// Converting to JSON failed, just log the object directly\nreturn obj;}}}", "function Capture(obj)\n{\n\tdocument.write(obj);\t\n}", "function xxxdebugP...
[ "0.6553346", "0.63087535", "0.6294159", "0.6255759", "0.61545634", "0.6092746", "0.60768634", "0.6007305", "0.5996592", "0.59403676", "0.5876246", "0.5872039", "0.5855973", "0.58507895", "0.5848545", "0.5846784", "0.5835644", "0.58296305", "0.58208656", "0.5819233", "0.581906...
0.0
-1
Make dashes for letters in hangman
function makeIntoDashes(word) { var dashes = ""; for (i = 0; i < word.length - 1; i++) { dashes += "_ "; } dashes += "_"; return dashes; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function changeToDashes(letters){\n var dashes = \"\";\n for (var i = 0; i < letters.length; i++) {\n dashesCurrentWord.push(\" _ \");\n }\n}", "function createDash(wordToGuess) {\n document.getElementById(\"dash\").innerHTML = \"\";\n for (let i = 0; i < wordToGuess.length; i++) {\n ...
[ "0.7827454", "0.73348576", "0.7325446", "0.7227364", "0.7215377", "0.7123555", "0.7057904", "0.6910219", "0.6860875", "0.6654698", "0.6592856", "0.6485853", "0.6482179", "0.6470948", "0.6465376", "0.6458367", "0.64555854", "0.6375918", "0.63634163", "0.63607246", "0.6331427",...
0.7393224
1
Main function that controls what to do when you type
function playGame(letter) { var letter = letter.toLowerCase(); // Checks if key is a letter if (alphabet.indexOf(letter) > -1) { if (wordAsArr.indexOf(letter) > -1) { correctGuesses++; displayLetter(letter); } else { if (lettersGuessed.indexOf(letter) > -1) { return; } else { guessesLeft--; document.getElementById("guessesLeft").innerHTML = guessesLeft; lettersGuessed.push(letter); document.getElementById("lettersGuessed").innerHTML = lettersGuessed.join(' '); if (guessesLeft == 0) { alert("Sorry! The correct answer is " + currentWord); initialize(); numLosses++; document.getElementById("losses").innerHTML = numLosses; } } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function runApp() {\n\n// switch case for the user input argument\nswitch (userInput) {\n case \"concert-this\":\n concertThis();\n break;\n\n case \"spotify-this-song\":\n spotifyThis();\n break;\n\n case \"movie-this\":\n movieThis();\n break;\n\n case \"do-w...
[ "0.67033935", "0.65263665", "0.6522406", "0.65214324", "0.6448926", "0.641371", "0.63911515", "0.63664955", "0.6363651", "0.6310801", "0.6269228", "0.6245269", "0.62333804", "0.6232125", "0.62198526", "0.618825", "0.61610466", "0.61591995", "0.6156979", "0.6134055", "0.612801...
0.0
-1
Displays letter if it's in word
function displayLetter(letter) { // for each char in wordAsDashes, if matches currentWord --> display for (i = 0; i < currentWord.length; i++) { if (letter == wordAsArr[i]) { dashesArray[i * 2] = letter; console.log(dashesArray); } } document.getElementById("currentWord").innerHTML = dashesArray.join(""); checkForWin(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "displayWord(word,letters){\n\tlet dWord = '';\n\tfor(let i=0; i< word.length; i++){\n\t\tif (letters.indexOf(word[i]) === -1) {\n\t\t\tdWord = dWord + '_';\n\t\t} else {\n\t\t\tdWord = dWord + '' + word[i];\n\t\t}\n\t}\n\treturn dWord;\n}", "function getLetter(word,letter,display){\r\n var newdisp = '';\r\n ...
[ "0.7865424", "0.7677229", "0.7629296", "0.73929363", "0.7338088", "0.72565144", "0.7186724", "0.7086788", "0.7077557", "0.706987", "0.7038866", "0.7026298", "0.70185983", "0.70072794", "0.695972", "0.69325554", "0.68963575", "0.6893275", "0.68690836", "0.6863134", "0.683821",...
0.6959885
14
looks for win by looking for "_"
function checkForWin() { if (dashesArray.indexOf("_") === -1) { alert("You got it! The correct answer is " + currentWord); numWins++; document.getElementById("wins").innerHTML = numWins; initialize(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ifYouWin() {\n if(underscoreArray.indexOf(\"_\") === -1) \n {\n wins++;\n alert(\"You win!\");\n $(\"#windiv\").html(\"wins: \" + wins);\n return;\n }\n}", "function checkWin()\n{\n var iUnderScorePos = underScoreDOM.indexOf(\"_\", 0);\n\n if (iUnderScorePos == -...
[ "0.69915146", "0.6822249", "0.6652872", "0.6598626", "0.6537433", "0.653705", "0.6490112", "0.6437188", "0.6357072", "0.6276529", "0.6276529", "0.62650543", "0.6179201", "0.6139926", "0.61254823", "0.60778195", "0.5979342", "0.5960601", "0.5956541", "0.59521735", "0.5866403",...
0.66342777
3
Display all the exercises in the json file
function displayData(data) { let searchTextBox = document.getElementById("keyword"); let queryItem = searchTextBox.value; queryItem = queryItem.trim().toLowerCase(); let mainContainer = document.getElementById("search-list"); // Clear any previous search result while (mainContainer.firstChild) { mainContainer.removeChild(mainContainer.firstChild); } // Create ul list and append to container let ul = document.createElement('ul'); ul.setAttribute('id', 'ul-results'); mainContainer.appendChild(ul); // Display everything if no input if (queryItem == '') { for (let i = 0; i < data.Sheet1.length; i++) { if (!itemsChosen.includes(data.Sheet1[i].Exercise_name)) { let liItem = document.createElement("li"); let aElem = document.createElement("a"); let link = document.createTextNode(data.Sheet1[i].Exercise_name); aElem.setAttribute('onClick', `addAFormItem(${data.Sheet1[i].undefined}, "${data.Sheet1[i].Exercise_name}"); removeListItem(${data.Sheet1[i].undefined});`); aElem.appendChild(link); liItem.setAttribute('id', data.Sheet1[i].undefined); liItem.appendChild(aElem); ul.appendChild(liItem); } } } // Filter items and display the filtered result else { let foundAName = false; // Display all the exercise names that contain the query name for (let i = 0; i < data.Sheet1.length; i++) { // If a exercise name has part of the query, display it if (data.Sheet1[i].Exercise_name.toLowerCase().indexOf(queryItem) > -1 && !itemsChosen.includes(data.Sheet1[i].Exercise_name)) { let liItem = document.createElement("li"); let aElem = document.createElement("a"); let link = document.createTextNode(data.Sheet1[i].Exercise_name); aElem.setAttribute('onClick', `addAFormItem(${data.Sheet1[i].undefined}, "${data.Sheet1[i].Exercise_name}"); removeListItem(${data.Sheet1[i].undefined})`); aElem.appendChild(link); liItem.setAttribute('id', data.Sheet1[i].undefined); liItem.appendChild(aElem); ul.appendChild(liItem); foundAName = true; } } // If no results show, display message if (foundAName == false) { let msg = document.createTextNode("Sorry, we can't find what you're looking for. Instead, add your own item."); let liItem = document.createElement("li"); let aElem = document.createElement("a"); liItem.setAttribute('style', 'color:white'); aElem.appendChild(msg); liItem.appendChild(aElem); ul.appendChild(liItem); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getExercises() {\n\t\t\t\tworkout.getExercises().then(function(result) {\n\t\t\t\t\t//$resource object returned to controller \n\t\t\t\t\tvm.exercises = result;\n\t\t\t\t\tconsole.log(vm.exercises);\n\t\t\t\t\t}, function(error) {\n\t\t\t\t\tconsole.log(error);\n\t\t\t\t});\n\t\t\t}", "function showAllE...
[ "0.70182794", "0.6546243", "0.65318584", "0.65244937", "0.62901545", "0.6014115", "0.59732664", "0.5919572", "0.59008", "0.5846057", "0.58381134", "0.583205", "0.5828584", "0.5816634", "0.5788778", "0.57188636", "0.5714871", "0.5709155", "0.5683145", "0.5679202", "0.5670848",...
0.0
-1
Adds a form entry
function addAFormItem(itemNum, itemName) { let resultsArea = document.getElementById('results-container'); createForm(itemName, resultsArea, itemNum); itemsChosen.push(itemName); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function NewEntryForm() {\n $(\"#addCancel\").click(this.clearForm);\n $(\"#addButton\").click(this.submitForm);\n }", "function addEntry() {\n var title = document.getElementById(\"add_title\").value;\n var date = document.getElementById(\"add_date\").value;\n date = formatDate(date);\...
[ "0.67497736", "0.66477305", "0.6621912", "0.66119576", "0.6609042", "0.6477225", "0.64262766", "0.63420784", "0.63307583", "0.62688184", "0.6258252", "0.6207475", "0.6182975", "0.6162022", "0.61599994", "0.6142728", "0.6132209", "0.61290246", "0.6109595", "0.6101736", "0.6093...
0.5770039
64
Remove the selected exercise name from the list of exercises
function removeListItem(liItem) { let liElem = document.getElementById(liItem); liElem.parentNode.removeChild(liElem); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function removeItem(nameInput, timeInput, removeBtn, br1, br2, isFromList) {\n // Remove the name of the exercise from the itemsChosen array\n if (isFromList) {\n const index = itemsChosen.indexOf(nameInput.value);\n if (index > -1) {\n itemsChosen.splice(index, 1);\n }\n }...
[ "0.6265687", "0.61822385", "0.6131126", "0.60711455", "0.6068673", "0.60638", "0.60559416", "0.5945268", "0.5933415", "0.592421", "0.586615", "0.58613235", "0.584102", "0.5839327", "0.5822874", "0.58062583", "0.5801241", "0.5778338", "0.5747176", "0.57437605", "0.57297194", ...
0.0
-1
Remove a form entry
function removeItem(nameInput, timeInput, removeBtn, br1, br2, isFromList) { // Remove the name of the exercise from the itemsChosen array if (isFromList) { const index = itemsChosen.indexOf(nameInput.value); if (index > -1) { itemsChosen.splice(index, 1); } } // Remove nameInput element let elem = document.getElementById(nameInput.id); elem.remove(); // Remove timeInput element elem = document.getElementById(timeInput.id); elem.remove(); // Remove the remove button element elem = document.getElementById(removeBtn.id); elem.remove(); // Remove first line break elem = document.getElementById(br1.id); elem.remove(); // Remove second line break elem = document.getElementById(br2.id); elem.remove(); if (isFromList) { --numOfSelectedItems; } else { --numOfCustomItems; } showExercises(event); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function delAdditForm(event) {\n event.target.parentNode.remove();\n}", "function deleteEntry(ENTRY){\n ENTRY_LIST.splice(ENTRY.id,1)\n updateUI()\n}", "removeElement(){\n // TODO alert() if want to remove the current form element \n this.props.handleDelete(this.state.id);\n }", "remo...
[ "0.75457925", "0.6999844", "0.67107743", "0.6666895", "0.6635637", "0.6574902", "0.6565991", "0.65129435", "0.65065074", "0.64214784", "0.6368355", "0.63539624", "0.6342396", "0.63123745", "0.62848336", "0.6262203", "0.62198573", "0.62161183", "0.6212481", "0.6197683", "0.619...
0.0
-1
Creates the components of a form entry from the list of exercises
function createForm(itemName, resultsArea) { // Name input, but disabled because the name is from json file let labelElem = document.createElement("input"); labelElem.setAttribute('name', `item${numOfSelectedItems}`); labelElem.setAttribute('class', 'form-control mr-5 mb-4 shadow'); labelElem.setAttribute('id', `item${numOfSelectedItems}`); labelElem.setAttribute('type', 'text'); labelElem.setAttribute('placeholder', 'Exercise name'); labelElem.setAttribute('value', itemName); labelElem.required = true; labelElem.readOnly = true; // Time input let inputTimeElement = document.createElement("input"); inputTimeElement.setAttribute('type', 'number'); inputTimeElement.setAttribute('name', `item${numOfSelectedItems}timeInput`); inputTimeElement.setAttribute('id', `item${numOfSelectedItems}timeInput`); inputTimeElement.setAttribute('class', 'form-control mr-5 mb-4 shadow'); inputTimeElement.setAttribute('placeholder', 'Minutes exercised'); inputTimeElement.setAttribute('step', '1'); inputTimeElement.setAttribute('min', '1'); inputTimeElement.required = true; // Remove (X) button let removeEntry = document.createElement("button"); removeEntry.setAttribute('id', `remove${numOfSelectedItems}Entry`); removeEntry.setAttribute('class', 'btn btn-danger mb-4 shadow'); removeEntry.setAttribute('type', 'button'); removeEntry.innerHTML = "X"; // 2 line breakers for space consistency between entries let linebreakElem = document.createElement("br"); linebreakElem.setAttribute('id', `br1${numOfSelectedItems}`); let linebreakElem2 = document.createElement("br"); linebreakElem2.setAttribute('id', `br2${numOfSelectedItems}`); // Create onclick listner to know when to remove an entry removeEntry.setAttribute('onClick', `renameAttributes('item${numOfSelectedItems}',` + `'item${numOfSelectedItems}timeInput',` + `'remove${numOfSelectedItems}Entry',` + `'br1${numOfSelectedItems}',` + `'br2${numOfSelectedItems}',` + `true)`); inputTimeElement.setAttribute('onInput', 'validate_time_field(this)'); // Appends the entry components to the entry area resultsArea.appendChild(labelElem); resultsArea.appendChild(inputTimeElement); resultsArea.appendChild(removeEntry); resultsArea.appendChild(linebreakElem); resultsArea.appendChild(linebreakElem2); ++numOfSelectedItems; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function enterExercises() {\n $(\"#exerciseEntryForm\").empty();\n console.log(\"Inside creating of exercise form function: kay = \" + kay + \", e = \" + e);\n // temporary take out: \"<h2><span class='namebox'>Enter exercise \" + e + \" of workout</span></h2>\"\n $(\"#exerciseEntryFo...
[ "0.64056945", "0.5989257", "0.58974355", "0.57577604", "0.5731731", "0.56795335", "0.56791306", "0.56182665", "0.56134444", "0.56124896", "0.5604029", "0.55856085", "0.5532535", "0.5482975", "0.5462791", "0.54600924", "0.5417638", "0.54173005", "0.54014015", "0.53997463", "0....
0.56570655
7
Creates the components of a form entry based off of user input
function addCustomItem() { let resultsArea = document.getElementById('results-container'); // Name input, which can be edited let exerciseNameInput = document.createElement("input"); exerciseNameInput.setAttribute('type', 'text'); exerciseNameInput.setAttribute('name', `item${numOfCustomItems}customName`); exerciseNameInput.setAttribute('id', `item${numOfCustomItems}customName`); exerciseNameInput.setAttribute('class', 'form-control mr-5 mb-4 shadow'); exerciseNameInput.setAttribute('placeholder', 'Exercise name'); exerciseNameInput.required = true; // Calorie input let caloriesInput = document.createElement("input"); caloriesInput.setAttribute('type', 'number'); caloriesInput.setAttribute('name', `item${numOfCustomItems}calories`); caloriesInput.setAttribute('id', `item${numOfCustomItems}calories`); caloriesInput.setAttribute('class', 'form-control mr-5 mb-4 shadow'); caloriesInput.setAttribute('placeholder', 'Calories burned'); caloriesInput.setAttribute('step', '0.01'); caloriesInput.setAttribute('min', '0.01'); caloriesInput.required = true; // Remove (X) button let removeEntry = document.createElement("button"); removeEntry.setAttribute('id', `remove${numOfCustomItems}customEntry`); removeEntry.setAttribute('class', 'btn btn-outline-danger mb-4 shadow'); removeEntry.setAttribute('type', 'button'); removeEntry.innerHTML = "X"; // 2 line breakers for space consistency between entries let linebreakElem = document.createElement("br"); linebreakElem.setAttribute('id', `br1${numOfCustomItems}custom`); let linebreakElem2 = document.createElement("br"); linebreakElem2.setAttribute('id', `br2${numOfCustomItems}custom`); // Create onclick listner to know when to remove an entry removeEntry.setAttribute('onClick', `renameAttributes('item${numOfCustomItems}customName',` + `'item${numOfCustomItems}calories',` + `'remove${numOfCustomItems}customEntry',` + `'br1${numOfCustomItems}custom',` + `'br2${numOfCustomItems}custom',` + `false)`); caloriesInput.setAttribute('onInput', 'validate_second_field(this)'); exerciseNameInput.setAttribute('oninput', 'validate_name_field(this)'); // Appends the entry components to the entry area resultsArea.appendChild(exerciseNameInput); resultsArea.appendChild(caloriesInput); resultsArea.appendChild(removeEntry); resultsArea.appendChild(linebreakElem); resultsArea.appendChild(linebreakElem2); ++numOfCustomItems; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function formal_field_create(params) {\n var form = params.form;\n var key = params.key;\n var label = params.label;\n var description = params.description;\n var value = params.value;\n var field_type = params.field_type;\n var input_type = params.input_type;\n var has_error = false; //...
[ "0.61506724", "0.60742205", "0.6005274", "0.5952689", "0.5855088", "0.5845772", "0.58227634", "0.5820782", "0.5807655", "0.5801654", "0.5799842", "0.5795541", "0.5783268", "0.5755507", "0.57476604", "0.5716737", "0.571268", "0.56845313", "0.5668793", "0.5664608", "0.56545603"...
0.0
-1
Renames the ids and names of each element
function renameAttributes(nameInput_id, second_input_id, removeBtn_id, br1_id, br2_id, isFromList) { let nameInput = document.getElementById(nameInput_id); let second_input = document.getElementById(second_input_id); let removeBtn = document.getElementById(removeBtn_id); let br1 = document.getElementById(br1_id); let br2 = document.getElementById(br2_id); // Retrieves the element's index let itemNum; if (isFromList) { itemNum = parseInt(br1_id.replace('br1', '')); } else { itemNum = br1_id.replace('br1', ''); itemNum = parseInt(itemNum.replace('custom', '')); } removeItem(nameInput, second_input, removeBtn, br1, br2, isFromList); let numOfItems = isFromList ? numOfSelectedItems : numOfCustomItems; // Loop through the elements after the current element's index for (let i = itemNum + 1; i <= numOfItems; ++i) { // Find the elements of the ith index nameInput = isFromList ? document.getElementById(`item${i}`) : document.getElementById(`item${i}customName`); second_input = isFromList ? document.getElementById(`item${i}timeInput`) : document.getElementById(`item${i}calories`); removeBtn = isFromList ? document.getElementById(`remove${i}Entry`) : document.getElementById(`remove${i}customEntry`); br1 = isFromList ? document.getElementById(`br1${i}`) : document.getElementById(`br1${i}custom`); br2 = isFromList ? document.getElementById(`br2${i}`) : document.getElementById(`br2${i}custom`); // Rename ids and names if (isFromList) { nameInput.setAttribute('id', `item${i - 1}`); nameInput.setAttribute('name', `item${i - 1}`); second_input.setAttribute('id', `item${i - 1}timeInput`); second_input.setAttribute('name', `item${i - 1}timeInput`); removeBtn.setAttribute('id', `remove${i - 1}Entry`); br1.setAttribute('id', `br1${i - 1}`); br2.setAttribute('id', `br2${i - 1}`); } else { nameInput.setAttribute('id', `item${i - 1}customName`); nameInput.setAttribute('name', `item${i - 1}customName`); second_input.setAttribute('id', `item${i - 1}calories`); second_input.setAttribute('name', `item${i - 1}calories`); removeBtn.setAttribute('id', `remove${i - 1}customEntry`); br1.setAttribute('id', `br1${i - 1}custom`); br2.setAttribute('id', `br2${i - 1}custom`); } // Rename the onClick to the appropriate ith index if (isFromList) { removeBtn.setAttribute('onClick', `renameAttributes('item${i - 1}',` + `'item${i - 1}timeInput',` + `'remove${i - 1}Entry',` + `'br1${i - 1}',` + `'br2${i - 1}',` + `true)`); second_input.setAttribute('onInput', 'validate_time_field(this)'); } else { removeBtn.setAttribute('onClick', `renameAttributes('item${i - 1}customName',` + `'item${i - 1}calories',` + `'remove${i - 1}customEntry',` + `'br1${i - 1}custom',` + `'br2${i - 1}custom',` + `false)`); second_input.setAttribute('onInput', 'validate_second_field(this)'); nameInput.setAttribute('onInput', 'validate_name_field(this)'); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function update_name_and_id(element,value){\n input_value = element.value;\n element.value = input_value.replace(/ #.*$/,'');\n $(element.id.replace(/_names$/,'_ids')).value +=\n input_value.replace(/^.*#/,'') + ', ';\n}", "function assignUniqueId(prefix, elements) {\n for (let i = 0; i < elements.lengt...
[ "0.6796552", "0.650769", "0.6390151", "0.6274693", "0.62743044", "0.62537795", "0.613833", "0.60722256", "0.60120106", "0.59072936", "0.58904654", "0.57996565", "0.57732606", "0.57663333", "0.5761017", "0.57350284", "0.5693129", "0.569156", "0.5686097", "0.5681971", "0.566854...
0.60672134
8
returns 0 <= x < 2PI
function cart2rad(x,y) { if (x === 0) { return (y === 0) ? 0 : (y > 0) ? Math.PI/2 : 3*Math.PI/2; } return (x > 0) ? Math.atan(y/x) : Math.PI+Math.atan(y/x); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function pointInCircle(x, y) {\n return Math.sqrt(x * x + y * y) < 1;\n}", "function toLessThanHalfPi(Ctor, x) {\r\n var t,\r\n isNeg = x.s < 0,\r\n pi = getPi(Ctor, Ctor.precision, 1),\r\n halfPi = pi.times(0.5);\r\n\r\n x = x.abs();\r\n\r\n if (x.lte(halfPi)) ...
[ "0.66443014", "0.6149387", "0.6108762", "0.6051584", "0.6051584", "0.6049494", "0.60395813", "0.60395813", "0.60395813", "0.60395813", "0.60395813", "0.60395813", "0.6030227", "0.602112", "0.60197324", "0.60197324", "0.60197324", "0.60197324", "0.60197324", "0.60197324", "0.6...
0.0
-1
return PI <= x < PI
function anglediff(x1,y1,x2,y2) { var rad = cart2rad(x2,y2) - cart2rad(x1,y1); return (rad < -Math.PI) ? rad+Math.PI : (rad >= Math.PI) ? rad-Math.PI : rad; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function prim(x) {\n if (x < 2) return false;\n\n for (let i = 2; i < x; i++) {\n if (x % i === 0) {\n return false;\n }\n }\n return true;\n}", "function pointInCircle(x, y) {\n return Math.sqrt(x * x + y * y) < 1;\n}", "function positive(x) {\r\n return x > 0;\r\n}", "function checkPri...
[ "0.67734295", "0.66479504", "0.66450596", "0.6440295", "0.6390736", "0.63420105", "0.6323378", "0.6258501", "0.6251737", "0.6238015", "0.6234971", "0.62320226", "0.62320226", "0.62320226", "0.62320226", "0.62320226", "0.62320226", "0.622565", "0.62194186", "0.6176865", "0.616...
0.0
-1
filter out VNodes without attributes (which are unrankeable), and add `index`/`rank` properties to be used in sorting.
function prepareVNodeForRanking(vnode, index) { vnode.index = index; vnode.rank = rankChild(vnode); return vnode.attributes; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "sort() {\n for (const vertex of Object.values(this.nodes)) {\n if (vertex.state !== 0 /* NOT_VISITED */) {\n continue;\n }\n this.visit(vertex);\n }\n const sortedList = this.sortedNodeList.reverse();\n this.nodes = {};\n this.sorte...
[ "0.5399391", "0.52747965", "0.5222867", "0.51587534", "0.51081294", "0.5020349", "0.501703", "0.5006041", "0.5006041", "0.5006041", "0.4944784", "0.48438334", "0.4809072", "0.47154605", "0.46991038", "0.46827647", "0.4654674", "0.4653932", "0.45706302", "0.45397314", "0.45336...
0.66499215
2
Check if the given URL can be handled by any router instances.
function canRoute(url) { for (var i = ROUTERS.length; i--;) { if (ROUTERS[i].canRoute(url)) { return true; } } return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function canRoute(url) {\n\tfor (var i = ROUTERS.length; i--;) {\n\t\tif (ROUTERS[i].canRoute(url)) return true;\n\t}\n\treturn false;\n}", "function canRoute(url) {\n\t\tfor (var i = ROUTERS.length; i--;) {\n\t\t\tif (ROUTERS[i].canRoute(url)) return true;\n\t\t}\n\t\treturn false;\n\t}", "function routeTo(ur...
[ "0.7862719", "0.7841556", "0.6633927", "0.66211295", "0.6571325", "0.6530883", "0.6240535", "0.62120575", "0.61851287", "0.61547565", "0.61547565", "0.60675925", "0.60295683", "0.59907675", "0.59291553", "0.5927804", "0.5906821", "0.5903642", "0.5867273", "0.586109", "0.58522...
0.7845167
3
Tell all router instances to handle the given URL.
function routeTo(url) { var didRoute = false; for (var i = 0; i < ROUTERS.length; i++) { if (ROUTERS[i].routeTo(url) === true) { didRoute = true; } } for (var i$1 = subscribers.length; i$1--;) { subscribers[i$1](url); } return didRoute; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "on(...pageRoutes) {\n //increment the number of routes registered\n this.numRegistered += 1;\n for (const {route, handler} of pageRoutes) {\n if (Array.isArray(route)) {\n for (const path of route) {\n const [regPath, params] = getRegexFromRouteStri...
[ "0.63254666", "0.6322665", "0.6020782", "0.5978404", "0.59178823", "0.578206", "0.5731197", "0.5723412", "0.571798", "0.5682337", "0.5660946", "0.5630985", "0.5598131", "0.5500071", "0.5471036", "0.5441258", "0.5438472", "0.5413374", "0.54000723", "0.53971636", "0.5357814", ...
0.5775685
8
Copyright 2017 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Do a deepcopy of basic JavaScript Objects or Arrays.
function deepCopy(value) { return deepExtend(undefined, value); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deepCopy(source){\n return JSON.parse(JSON.stringify(source));\n}", "copy(obj){\n return JSON.parse(JSON.stringify(obj));\n }", "function copy(o) {\n return JSON.parse(JSON.stringify(o));\n}", "function deepCopy(obj){\n return JSON.parse(JSON.stringify(obj));\n}", "function deepCopy(src) ...
[ "0.7376675", "0.7309223", "0.71951663", "0.7177703", "0.7167657", "0.71350265", "0.7133641", "0.71313584", "0.7063589", "0.7034854", "0.7034854", "0.7027634", "0.7000219", "0.6936068", "0.69195396", "0.6882209", "0.6871705", "0.6839413", "0.68161756", "0.6815857", "0.6807057"...
0.0
-1
Copy properties from source to target (recursively allows extension of Objects and Arrays). Scalar values in the target are overwritten. If target is undefined, an object of the appropriate type will be created (and returned). We recursively copy all child properties of plain Objects in the source so that namespace like dictionaries are merged. Note that the target can be a function, in which case the properties in the source Object are copied onto it as static properties of the Function.
function deepExtend(target, source) { if (!(source instanceof Object)) { return source; } switch (source.constructor) { case Date: // Treat Dates like scalars; if the target date object had any child // properties - they will be lost! var dateValue = source; return new Date(dateValue.getTime()); case Object: if (target === undefined) { target = {}; } break; case Array: // Always copy the array source and overwrite the target. target = []; break; default: // Not a plain Object - treat it as a scalar. return source; } for (var prop in source) { if (!source.hasOwnProperty(prop)) { continue; } target[prop] = deepExtend(target[prop], source[prop]); } return target; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deepExtend(target, source) {\n if (!(source instanceof Object)) {\n return source;\n }\n\n switch (source.constructor) {\n case Date:\n // Treat Dates like scalars; if the target date object had any child\n // properties - they will be lost!\n var da...
[ "0.7500846", "0.74389493", "0.74249786", "0.74249786", "0.74249786", "0.74249786", "0.74249786", "0.74249786", "0.74183905", "0.74183905", "0.73868513", "0.73616", "0.7356405", "0.733986", "0.733986", "0.733986", "0.733986", "0.733986", "0.733986", "0.733986", "0.733986", "...
0.74095887
23
TODO: Really needed (for JSCompiler type checking)?
function patchProperty(obj, prop, value) { obj[prop] = value; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Js(e){return(Js=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e})(e)}", "function Type() {}", "__eval__(__source__, __boundValues__) { return...
[ "0.6290559", "0.5804038", "0.56958884", "0.56572133", "0.5631806", "0.56059617", "0.5565331", "0.55441624", "0.551333", "0.550832", "0.55078125", "0.55031407", "0.5477075", "0.54719603", "0.5467539", "0.5466426", "0.5463673", "0.54627925", "0.5454312", "0.5441944", "0.5438133...
0.0
-1
Export for faking in tests
function patchCapture(captureFake) { var result = captureStackTrace; captureStackTrace = captureFake; return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function setup() {}", "setup() {}", "setup() {}", "setup() {}", "function fakeUsage() {\n var fakeObj = fake('example');\n fakeObj.mock('foo').map([], 'bar');\n fakeObj.foo();\n }", "function AeUtil() {}", "async setup() { }", "function MockedProvider() {\n /* ... */\n}", "expected(_...
[ "0.63395375", "0.62538314", "0.62538314", "0.62538314", "0.59652007", "0.592908", "0.59203243", "0.5870511", "0.58335674", "0.5803979", "0.5803955", "0.5799477", "0.5797888", "0.5797888", "0.5751915", "0.5734973", "0.5734036", "0.5698406", "0.567787", "0.5670397", "0.56570923...
0.0
-1
Helper to make a Subscribe function (just like Promise helps make a Thenable).
function createSubscribe(executor, onNoObservers) { var proxy = new ObserverProxy(executor, onNoObservers); return proxy.subscribe.bind(proxy); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "subscribe(fn) {\n return this._subscribe(fn);\n }", "subscribe() {}", "subscribe(s) { return dispatcher.subscribe(s); }", "function subscribe ( util, uri, handler ) {\n var ws = util.connection ? util.connection : util;\n var p = Packet\n .make()\n .uri( uri )\...
[ "0.7111695", "0.69480175", "0.6911661", "0.6881512", "0.6807628", "0.6789229", "0.6763905", "0.66531384", "0.6646185", "0.6622463", "0.6600869", "0.6600869", "0.6600869", "0.6600869", "0.6600869", "0.6600869", "0.6600869", "0.6600869", "0.6600869", "0.6600869", "0.65936077", ...
0.65715325
43
Turn synchronous function into one called asynchronously.
function index_esm_async(fn, onError) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } Promise.resolve(true).then(function () { fn.apply(void 0, args); }).catch(function (error) { if (onError) { onError(error); } }); }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async function MyAsyncFn () {}", "async function asyncFunction(arg) {\r\n return arg;\r\n}", "async function fn(){ //This is the newer way of doing an async function\n return 'hello';\n}", "async function asyncFn(){\n\n return 1;\n}", "async function f(){\n return something\n}", "function async(f...
[ "0.7155934", "0.7116087", "0.70804554", "0.68879116", "0.68725556", "0.6768867", "0.67274386", "0.6606676", "0.6605907", "0.6605907", "0.6598512", "0.6598512", "0.65512455", "0.65512455", "0.65438145", "0.65246886", "0.65200365", "0.6504154", "0.6503758", "0.64964813", "0.649...
0.0
-1
Return true if the object passed in implements any of the named methods.
function implementsAnyMethods(obj, methods) { if (typeof obj !== 'object' || obj === null) { return false; } for (var _i = 0, methods_1 = methods; _i < methods_1.length; _i++) { var method = methods_1[_i]; if (method in obj && typeof obj[method] === 'function') { return true; } } return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function implementsAnyMethods(obj, methods) {\r\n if (typeof obj !== 'object' || obj === null) {\r\n return false;\r\n }\r\n var object = obj;\r\n for (var _i = 0, methods_1 = methods; _i < methods_1.length; _i++) {\r\n var method = methods_1[_i];\r\n if (method in object && typeof...
[ "0.78970456", "0.78970456", "0.78970456", "0.7886716", "0.7886716", "0.7886716", "0.7886716", "0.7859883", "0.78397715", "0.78397715", "0.78397715", "0.78397715", "0.78397715", "0.78397715", "0.78397715", "0.78397715", "0.78397715", "0.78397715", "0.78374755", "0.78374755", "...
0.78223383
39
Return a firebase namespace object. In production, this will be called exactly once and the result assigned to the 'firebase' global. It may be called multiple times in unit tests.
function createFirebaseNamespace() { var apps_ = {}; var factories = {}; var appHooks = {}; // A namespace is a plain JavaScript Object. var namespace = { // Hack to prevent Babel from modifying the object returned // as the firebase namespace. __esModule: true, initializeApp: initializeApp, app: app, apps: null, Promise: Promise, SDK_VERSION: '5.0.4', INTERNAL: { registerService: registerService, createFirebaseNamespace: createFirebaseNamespace, extendNamespace: extendNamespace, createSubscribe: createSubscribe, ErrorFactory: ErrorFactory, removeApp: removeApp, factories: factories, useAsService: useAsService, Promise: Promise, deepExtend: deepExtend } }; // Inject a circular default export to allow Babel users who were previously // using: // // import firebase from 'firebase'; // which becomes: var firebase = require('firebase').default; // // instead of // // import * as firebase from 'firebase'; // which becomes: var firebase = require('firebase'); patchProperty(namespace, 'default', namespace); // firebase.apps is a read-only getter. Object.defineProperty(namespace, 'apps', { get: getApps }); /** * Called by App.delete() - but before any services associated with the App * are deleted. */ function removeApp(name) { var app = apps_[name]; callAppHooks(app, 'delete'); delete apps_[name]; } /** * Get the App object for a given name (or DEFAULT). */ function app(name) { name = name || DEFAULT_ENTRY_NAME; if (!index_esm_contains(apps_, name)) { error('no-app', { name: name }); } return apps_[name]; } patchProperty(app, 'App', index_esm_FirebaseAppImpl); function initializeApp(options, rawConfig) { if (rawConfig === void 0) { rawConfig = {}; } if (typeof rawConfig !== 'object' || rawConfig === null) { var name_1 = rawConfig; rawConfig = { name: name_1 }; } var config = rawConfig; if (config.name === undefined) { config.name = DEFAULT_ENTRY_NAME; } var name = config.name; if (typeof name !== 'string' || !name) { error('bad-app-name', { name: name + '' }); } if (index_esm_contains(apps_, name)) { error('duplicate-app', { name: name }); } var app = new index_esm_FirebaseAppImpl(options, config, namespace); apps_[name] = app; callAppHooks(app, 'create'); return app; } /* * Return an array of all the non-deleted FirebaseApps. */ function getApps() { // Make a copy so caller cannot mutate the apps list. return Object.keys(apps_).map(function (name) { return apps_[name]; }); } /* * Register a Firebase Service. * * firebase.INTERNAL.registerService() * * TODO: Implement serviceProperties. */ function registerService(name, createService, serviceProperties, appHook, allowMultipleInstances) { // Cannot re-register a service that already exists if (factories[name]) { error('duplicate-service', { name: name }); } // Capture the service factory for later service instantiation factories[name] = createService; // Capture the appHook, if passed if (appHook) { appHooks[name] = appHook; // Run the **new** app hook on all existing apps getApps().forEach(function (app) { appHook('create', app); }); } // The Service namespace is an accessor function ... var serviceNamespace = function serviceNamespace(appArg) { if (appArg === void 0) { appArg = app(); } if (typeof appArg[name] !== 'function') { // Invalid argument. // This happens in the following case: firebase.storage('gs:/') error('invalid-app-argument', { name: name }); } // Forward service instance lookup to the FirebaseApp. return appArg[name](); }; // ... and a container for service-level properties. if (serviceProperties !== undefined) { deepExtend(serviceNamespace, serviceProperties); } // Monkey-patch the serviceNamespace onto the firebase namespace namespace[name] = serviceNamespace; // Patch the FirebaseAppImpl prototype index_esm_FirebaseAppImpl.prototype[name] = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var serviceFxn = this._getService.bind(this, name); return serviceFxn.apply(this, allowMultipleInstances ? args : []); }; return serviceNamespace; } /** * Patch the top-level firebase namespace with additional properties. * * firebase.INTERNAL.extendNamespace() */ function extendNamespace(props) { deepExtend(namespace, props); } function callAppHooks(app, eventName) { Object.keys(factories).forEach(function (serviceName) { // Ignore virtual services var factoryName = useAsService(app, serviceName); if (factoryName === null) { return; } if (appHooks[factoryName]) { appHooks[factoryName](eventName, app); } }); } // Map the requested service to a registered service name // (used to map auth to serverAuth service when needed). function useAsService(app, name) { if (name === 'serverAuth') { return null; } var useService = name; var options = app.options; return useService; } return namespace; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createFirebaseNamespace() {\n var apps_ = {};\n var factories = {};\n var appHooks = {};\n // A namespace is a plain JavaScript Object.\n var namespace = {\n // Hack to prevent Babel from modifying the object returned\n // as the firebase namespace.\n __esModule: true,\...
[ "0.7395141", "0.7395141", "0.73942155", "0.7384561", "0.7325029", "0.73250115", "0.7324753", "0.7304083", "0.7299323", "0.729379", "0.7291825", "0.72814983", "0.7240384", "0.723716", "0.72275066", "0.72275066", "0.70833606", "0.6663889", "0.5964844", "0.5919311", "0.58579993"...
0.7100445
16
Called by App.delete() but before any services associated with the App are deleted.
function removeApp(name) { var app = apps_[name]; callAppHooks(app, 'delete'); delete apps_[name]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async delete() {\r\n const services = Array.from(this.instances.values());\r\n await Promise.all([\r\n ...services\r\n .filter(service => 'INTERNAL' in service) // legacy services\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n ...
[ "0.6529951", "0.63229233", "0.61973095", "0.5973669", "0.5904189", "0.5874682", "0.58137155", "0.58137155", "0.58137155", "0.58137155", "0.58137155", "0.58137155", "0.57807356", "0.5741414", "0.57388115", "0.5734138", "0.57299674", "0.57051516", "0.5684808", "0.56539464", "0....
0.0
-1
Get the App object for a given name (or DEFAULT).
function app(name) { name = name || DEFAULT_ENTRY_NAME; if (!index_esm_contains(apps_, name)) { error('no-app', { name: name }); } return apps_[name]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function app(name) {\r\n name = name || DEFAULT_ENTRY_NAME;\r\n if (!util.contains(apps, name)) {\r\n throw ERROR_FACTORY.create(\"no-app\" /* NO_APP */, { appName: name });\r\n }\r\n return apps[name];\r\n }", "function app(name) {\r\n name = name || DEFAULT_ENTR...
[ "0.85640585", "0.85640585", "0.85640585", "0.85640585", "0.85640585", "0.85560256", "0.85454327", "0.85454327", "0.84141004", "0.84141004", "0.84141004", "0.83911544", "0.8369064", "0.8369064", "0.8369064", "0.8369064", "0.8369064", "0.8369064", "0.8369064", "0.8369064", "0.8...
0.8034346
31
Return an array of all the nondeleted FirebaseApps.
function getApps() { // Make a copy so caller cannot mutate the apps list. return Object.keys(apps_).map(function (name) { return apps_[name]; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getApps() {\r\n return Array.from(_apps.values());\r\n}", "function destroyFirebaseApps() {\n var deletions = _firebase.default.apps.map(function (app) {\n return app.delete();\n });\n Ember.RSVP.all(deletions).then(function () {\n return run(function () {\n // NOOP to delay...
[ "0.64772916", "0.62303036", "0.62077487", "0.62077487", "0.60681945", "0.60569656", "0.60530764", "0.60530764", "0.60530764", "0.60530764", "0.60530764", "0.60530764", "0.6050903", "0.6050903", "0.6050903", "0.603927", "0.60314476", "0.60314476", "0.60314476", "0.60314476", "...
0.5979054
36
Register a Firebase Service. firebase.INTERNAL.registerService() TODO: Implement serviceProperties.
function registerService(name, createService, serviceProperties, appHook, allowMultipleInstances) { // Cannot re-register a service that already exists if (factories[name]) { error('duplicate-service', { name: name }); } // Capture the service factory for later service instantiation factories[name] = createService; // Capture the appHook, if passed if (appHook) { appHooks[name] = appHook; // Run the **new** app hook on all existing apps getApps().forEach(function (app) { appHook('create', app); }); } // The Service namespace is an accessor function ... var serviceNamespace = function serviceNamespace(appArg) { if (appArg === void 0) { appArg = app(); } if (typeof appArg[name] !== 'function') { // Invalid argument. // This happens in the following case: firebase.storage('gs:/') error('invalid-app-argument', { name: name }); } // Forward service instance lookup to the FirebaseApp. return appArg[name](); }; // ... and a container for service-level properties. if (serviceProperties !== undefined) { deepExtend(serviceNamespace, serviceProperties); } // Monkey-patch the serviceNamespace onto the firebase namespace namespace[name] = serviceNamespace; // Patch the FirebaseAppImpl prototype index_esm_FirebaseAppImpl.prototype[name] = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var serviceFxn = this._getService.bind(this, name); return serviceFxn.apply(this, allowMultipleInstances ? args : []); }; return serviceNamespace; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function RegisterService() { }", "function registerService(name, createService, serviceProperties, appHook, allowMultipleInstances) {\n // Cannot re-register a service that already exists\n if (factories[name]) {\n error('duplicate-service', { name: name });\n }\n // Captur...
[ "0.7036886", "0.7000226", "0.7000226", "0.69690084", "0.695451", "0.6954312", "0.6954312", "0.69425637", "0.6938254", "0.6938254", "0.6938254", "0.6932339", "0.6932339", "0.68991476", "0.6894283", "0.6894283", "0.6885988", "0.68220675", "0.68220675", "0.6578979", "0.63520294"...
0.686263
17
Patch the toplevel firebase namespace with additional properties. firebase.INTERNAL.extendNamespace()
function extendNamespace(props) { deepExtend(namespace, props); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function extendNamespace(props) {\n Object(_firebase_util__WEBPACK_IMPORTED_MODULE_1__[\"deepExtend\"])(namespace, props);\n }", "function extendNamespace(props) {\n Object(_firebase_util__WEBPACK_IMPORTED_MODULE_1__[\"deepExtend\"])(namespace, props);\n }", "function extendNamespace(props)...
[ "0.7601572", "0.7601572", "0.7601572", "0.7601572", "0.75983995", "0.75983995", "0.75533146", "0.7525545", "0.7525545", "0.7478086", "0.74745446", "0.74745446", "0.7244001", "0.66542375", "0.6581733", "0.6581733", "0.64319474", "0.64125645", "0.63201916", "0.63201916", "0.632...
0.6549842
17
Map the requested service to a registered service name (used to map auth to serverAuth service when needed).
function useAsService(app, name) { if (name === 'serverAuth') { return null; } var useService = name; var options = app.options; return useService; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function serviceName (ctx) {\n const {mu, server} = ctx\n\n const handle = pattern(mu)\n\n // set up the component\n component({name}, ctx)\n\n // set up API routes for services\n\n server.route({\n method: 'GET',\n path: '/service-name/one',\n handler: handle({role: name, cmd: 'one'})\n })\n\n //...
[ "0.6320599", "0.6283144", "0.6266805", "0.62394845", "0.622061", "0.6161741", "0.6161741", "0.6161741", "0.6161741", "0.6161741", "0.6161741", "0.6155655", "0.6155655", "0.6155655", "0.6155655", "0.6155655", "0.6155655", "0.6155655", "0.6155655", "0.60720485", "0.6062312", ...
0.59126645
32
Gives you an instance of a Logger to capture messages according to Firebase's logging scheme.
function Logger(name) { this.name = name; /** * The log level of the given Logger instance. */ this._logLevel = defaultLogLevel; /** * The log handler for the Logger instance. */ this._logHandler = defaultLogHandler; /** * Capture the current instance for later use */ instances.push(this); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getLogger() {\n if (logger) return logger;\n var ccLogger = ccHandler(serializer);\n logger = new logger$1.Logger('@firebase/performance/cc');\n logger.logHandler = ccLogger;\n return logger;\n}", "function getLogger() {\r\n if (logger) {\r\n return logger;\r\n }\r\n var ccLogger = ...
[ "0.69871086", "0.6934629", "0.6588027", "0.64713556", "0.6424434", "0.63117254", "0.62567455", "0.62341416", "0.62000084", "0.6198142", "0.60282594", "0.60161453", "0.5994681", "0.5946441", "0.5935197", "0.59308237", "0.59282786", "0.59014946", "0.5883471", "0.5873547", "0.58...
0.54807884
66
Copyright 2017 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
function setLogLevel(level) { instances.forEach(function (inst) { inst.logLevel = level; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function me(e,t,a,s){var n,i=arguments.length,r=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,a):s;if(\"object\"==typeof Reflect&&\"function\"==typeof Reflect.decorate)r=Reflect.decorate(e,t,a,s);else for(var d=e.length-1;d>=0;d--)(n=e[d])&&(r=(i<3?n(r):i>3?n(t,a,r):n(t,a))||r);return i>3&&r&&Object.definePro...
[ "0.57520545", "0.53445894", "0.528733", "0.52403855", "0.50753653", "0.50556743", "0.5053055", "0.5053055", "0.5051795", "0.5027746", "0.49905986", "0.49867564", "0.49741954", "0.495711", "0.4916699", "0.48884004", "0.48746502", "0.48595467", "0.48595467", "0.48479086", "0.48...
0.0
-1
Helper methods are needed because variables can't be exported as read/write
function getLogLevel(){if(logClient.logLevel===LogLevel.DEBUG){return LogLevel$1.DEBUG;}else if(logClient.logLevel===LogLevel.SILENT){return LogLevel$1.SILENT;}else{return LogLevel$1.ERROR;}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function TempVars() {\n}", "transient protected internal function m189() {}", "private public function m246() {}", "function main_loadfiles_readvar(){ //re-loads variables that require g.module_lang.current - in case user changes language from default\n /**\n Lists the keys from {@link module:g.medic...
[ "0.5930117", "0.5599128", "0.55292356", "0.54622537", "0.5433793", "0.5416455", "0.5377996", "0.5373309", "0.5371368", "0.53637725", "0.53470784", "0.5328742", "0.53234553", "0.5302376", "0.5292876", "0.5282595", "0.5280479", "0.5252725", "0.52519196", "0.5248912", "0.5248479...
0.0
-1
Converts an additional log parameter to a string representation.
function argToString(obj){if(typeof obj==='string'){return obj;}else{var platform=PlatformSupport.getPlatform();try{return platform.formatJSON(obj);}catch(e){// Converting to JSON failed, just log the object directly return obj;}}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_logString () {\n return logItemHelper('ItemFormat', this, `key:${JSON.stringify(this.key)},value:${JSON.stringify(this.value)}`)\n }", "function formatLogArgs(args) {\n return utils.toArray(args).join(' ');\n }", "function generate_log_message(parameters)\n{\n\t// преобразовать все аргументы функции в...
[ "0.614184", "0.57417536", "0.5731708", "0.55286884", "0.54774034", "0.5453822", "0.5445583", "0.5430303", "0.5415994", "0.5383256", "0.537116", "0.5347783", "0.53391105", "0.5324835", "0.5307512", "0.5307512", "0.52950346", "0.52950346", "0.52950346", "0.52950346", "0.5295034...
0.53555286
11
Returns the representation of an empty "proto" byte string for the platform.
function emptyByteString(){return PlatformSupport.getPlatform().emptyByteString;}/** * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */// TODO(mcg): Change to a string enum once we've upgraded to typescript 2.4.
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function emptyByteString() {\n return PlatformSupport.getPlatform().emptyByteString;\n}", "function emptyByteString() {\n return PlatformSupport.getPlatform().emptyByteString;\n}", "function emptyByteString() {\n return PlatformSupport.getPlatform().emptyByteString;\n}", "function emptyByteString() {\...
[ "0.6917151", "0.6916997", "0.6916997", "0.6916997", "0.6916997", "0.6916997", "0.6916997", "0.6905829", "0.6905829", "0.6905829", "0.68579036", "0.5797874", "0.57551724", "0.5628136", "0.5501535", "0.5501535", "0.5501535", "0.53710234", "0.51884246", "0.5060383", "0.50599575"...
0.67679554
11
Copyright 2017 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Helper function to prevent instantiation through the constructor. This method creates a new constructor that throws when it's invoked. The prototype of that constructor is then set to the prototype of the hidden "class" to expose all the prototype methods and allow for instanceof checks. To also make all the static methods available, all properties of the original constructor are copied to the new constructor.
function makeConstructorPrivate(cls,optionalMessage){function PublicConstructor(){var error='This constructor is private.';if(optionalMessage){error+=' ';error+=optionalMessage;}throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,error);}// Make sure instanceof checks work and all methods are exposed on the public // constructor PublicConstructor.prototype=cls.prototype;// Copy any static methods/members for(var staticProperty in cls){if(cls.hasOwnProperty(staticProperty)){PublicConstructor[staticProperty]=cls[staticProperty];}}return PublicConstructor;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor() {\n throw Exception.staticClassConstructorInvocation;\n }", "constructor() {\n throw Exception.staticClassConstructorInvocation;\n }", "constructor() {\n\t\tthrow new Error('Sorry, this class can`t be instanciated, it is only for static methods');\n\t}", "function cheapNew(c...
[ "0.6931482", "0.6931482", "0.655827", "0.65526485", "0.65526485", "0.64370996", "0.6423341", "0.6423341", "0.64162785", "0.64151514", "0.64151514", "0.64151514", "0.6371872", "0.63680506", "0.6356677", "0.6356677", "0.6235148", "0.6235148", "0.6235148", "0.6235148", "0.623514...
0.65488124
5
Copyright 2017 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
function dist_index_esm_contains(obj,key){return Object.prototype.hasOwnProperty.call(obj,key);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function me(e,t,a,s){var n,i=arguments.length,r=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,a):s;if(\"object\"==typeof Reflect&&\"function\"==typeof Reflect.decorate)r=Reflect.decorate(e,t,a,s);else for(var d=e.length-1;d>=0;d--)(n=e[d])&&(r=(i<3?n(r):i>3?n(t,a,r):n(t,a))||r);return i>3&&r&&Object.definePro...
[ "0.57512176", "0.5345903", "0.52893716", "0.5242048", "0.5074461", "0.50543845", "0.50521696", "0.5051502", "0.5051502", "0.5027637", "0.4989611", "0.498545", "0.49730507", "0.49567991", "0.4916299", "0.48886392", "0.4876151", "0.48606881", "0.48606881", "0.48490617", "0.4849...
0.0
-1
Returns the given value if it's defined or the defaultValue otherwise.
function defaulted(value,defaultValue){return value!==undefined?value:defaultValue;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function valueOrDefault(value, defaultValue) {\n\t\treturn typeof value === 'undefined' ? defaultValue : value;\n\t}", "function definedOr (value, defaultValue) {\n return (value === undefined)\n ? defaultValue\n : value\n}", "function defaulted(value, defaultValue) {\n return value !== undefined...
[ "0.82908034", "0.81254375", "0.77680767", "0.77680767", "0.77680767", "0.77680767", "0.77680767", "0.77680767", "0.7755296", "0.77449536", "0.7722309", "0.76916206", "0.76916206", "0.76916206", "0.75909656", "0.75880873", "0.7505557", "0.74702954", "0.7395833", "0.7389611", "...
0.75593966
16
Copyright 2017 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Validates the invocation of functionName has the exact number of arguments. Forward the magic "arguments" variable as second parameter on which the parameter validation is performed: validateExactNumberOfArgs('myFunction', arguments, 2);
function validateExactNumberOfArgs(functionName,args,numberOfArgs){if(args.length!==numberOfArgs){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Function "+functionName+"() requires "+formatPlural(numberOfArgs,'argument')+', but was called with '+formatPlural(args.length,'argument')+'.');}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateExactNumberOfArgs(functionName, args, numberOfArgs) {\n if (args.length !== numberOfArgs) {\n throw new __WEBPACK_IMPORTED_MODULE_1__error__[\"b\" /* FirestoreError */](__WEBPACK_IMPORTED_MODULE_1__error__[\"a\" /* Code */].INVALID_ARGUMENT, \"Function \" + functionName + \"() requires \...
[ "0.8240362", "0.8210775", "0.8210775", "0.8117692", "0.8098006", "0.8098006", "0.8098006", "0.809355", "0.809355", "0.809355", "0.8077222", "0.78972024", "0.78820854", "0.78820854", "0.78557414", "0.7813766", "0.77924615", "0.77924615", "0.77924615", "0.7783497", "0.7783497",...
0.8119256
3
Validates the invocation of functionName has at least the provided number of arguments (but can have many more). Forward the magic "arguments" variable as second parameter on which the parameter validation is performed: validateAtLeastNumberOfArgs('myFunction', arguments, 2);
function validateAtLeastNumberOfArgs(functionName,args,minNumberOfArgs){if(args.length<minNumberOfArgs){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Function "+functionName+"() requires at least "+formatPlural(minNumberOfArgs,'argument')+', but was called with '+formatPlural(args.length,'argument')+'.');}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateAtLeastNumberOfArgs(functionName, args, minNumberOfArgs) {\n if (args.length < minNumberOfArgs) {\n throw new __WEBPACK_IMPORTED_MODULE_1__error__[\"b\" /* FirestoreError */](__WEBPACK_IMPORTED_MODULE_1__error__[\"a\" /* Code */].INVALID_ARGUMENT, \"Function \" + functionName + \"() requ...
[ "0.8461188", "0.84453064", "0.8432159", "0.8432159", "0.84224814", "0.84224814", "0.84224814", "0.8406888", "0.83729947", "0.83729947", "0.83729947", "0.8180236", "0.8137709", "0.8137709", "0.81294006", "0.8095482", "0.8095482", "0.8095482", "0.8092157", "0.808989", "0.808989...
0.82190293
11
Validates the invocation of functionName has number of arguments between the values provided. Forward the magic "arguments" variable as second parameter on which the parameter validation is performed: validateBetweenNumberOfArgs('myFunction', arguments, 2, 3);
function validateBetweenNumberOfArgs(functionName,args,minNumberOfArgs,maxNumberOfArgs){if(args.length<minNumberOfArgs||args.length>maxNumberOfArgs){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Function "+functionName+"() requires between "+minNumberOfArgs+" and "+(maxNumberOfArgs+" arguments, but was called with ")+formatPlural(args.length,'argument')+'.');}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateBetweenNumberOfArgs(functionName, args, minNumberOfArgs, maxNumberOfArgs) {\n if (args.length < minNumberOfArgs || args.length > maxNumberOfArgs) {\n throw new FirestoreError(Code.INVALID_ARGUMENT, \"Function \" + functionName + \"() requires between \" + minNumberOfArgs + \" and \" + ...
[ "0.80966854", "0.8073803", "0.80476785", "0.80476785", "0.80384445", "0.80384445", "0.80384445", "0.8034436", "0.79852146", "0.79852146", "0.79852146", "0.7798083", "0.777584", "0.777584", "0.77482533", "0.768981", "0.768981", "0.768981", "0.76817983", "0.7679759", "0.7679759...
0.7760045
14
Validates the provided argument is an array and has as least the expected number of elements.
function validateNamedArrayAtLeastNumberOfElements(functionName,value,name,minNumberOfElements){if(!(value instanceof Array)||value.length<minNumberOfElements){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Function "+functionName+"() requires its "+name+" argument to be an "+'array with at least '+(formatPlural(minNumberOfElements,'element')+"."));}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateNamedArrayAtLeastNumberOfElements(functionName, value, name, minNumberOfElements) {\n if (!(value instanceof Array) || value.length < minNumberOfElements) {\n throw new FirestoreError(Code.INVALID_ARGUMENT, \"Function \" + functionName + \"() requires its \" + name + \" argument to be ...
[ "0.724494", "0.7112797", "0.71082884", "0.71082884", "0.7086457", "0.7086457", "0.7086457", "0.7058282", "0.70570356", "0.70570356", "0.70570356", "0.7048037", "0.7048037", "0.68446654", "0.68446654", "0.6841751", "0.68364954", "0.6823918", "0.6787488", "0.67826134", "0.67704...
0.7423331
0
Validates the provided positional argument has the native JavaScript type using typeof checks.
function validateArgType(functionName,type,position,argument){validateType(functionName,type,ordinal(position)+" argument",argument);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateArgType(functionName, type, position, argument) {\n validateType(functionName, type, ordinal(position) + \" argument\", argument);\n }", "function validateArgType(functionName, type, position, argument) {\r\n validateType(functionName, type, ordinal(position) + \" argument\", argument...
[ "0.6249961", "0.62223715", "0.62223715", "0.62223715", "0.61980295", "0.61980295", "0.61980295", "0.61980295", "0.61980295", "0.61980295", "0.6161284", "0.6084415", "0.5762431", "0.57334834", "0.57107604", "0.5643761", "0.5629433", "0.5609814", "0.55449045", "0.5538697", "0.5...
0.64657027
0
Validates the provided argument has the native JavaScript type using typeof checks or is undefined.
function validateOptionalArgType(functionName,type,position,argument){if(argument!==undefined){validateArgType(functionName,type,position,argument);}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function typeValidation(variable, type) {\n // Your code should be here ;) \n return typeof(variable) === type;\n}", "function ifDataType(source, dataType) {\n return \"[object \" + dataType + \"]\" === {}.toString.call(source)\n}", "function isType(t) {\n\t\tif (t == 'int' || t == 'char' || t == 'void')\n\...
[ "0.5874425", "0.5763152", "0.5756349", "0.57186764", "0.5716415", "0.57005125", "0.5699812", "0.56807876", "0.5669081", "0.5669081", "0.5664594", "0.5662284", "0.56236243", "0.56234914", "0.56225836", "0.5603749", "0.56012094", "0.55941314", "0.5581786", "0.5572417", "0.55701...
0.0
-1
Validates the provided named option has the native JavaScript type using typeof checks.
function validateNamedType(functionName,type,optionName,argument){validateType(functionName,type,optionName+" option",argument);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateNamedType(functionName, type, optionName, argument) {\n validateType(functionName, type, optionName + \" option\", argument);\n }", "function validateNamedType(functionName, type, optionName, argument) {\r\n validateType(functionName, type, optionName + \" option\", argument);\r\n}", ...
[ "0.59438556", "0.59080034", "0.59080034", "0.59080034", "0.59051704", "0.58616436", "0.58616436", "0.58616436", "0.58616436", "0.58616436", "0.58616436", "0.5826456", "0.5689854", "0.5563775", "0.54354936", "0.54079735", "0.5402815", "0.53677917", "0.53677917", "0.53677917", ...
0.62361896
0
Validates the provided named option has the native JavaScript type using typeof checks or is undefined.
function validateNamedOptionalType(functionName,type,optionName,argument){if(argument!==undefined){validateNamedType(functionName,type,optionName,argument);}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateNamedType(functionName,type,optionName,argument){validateType(functionName,type,optionName+\" option\",argument);}", "function validateNamedType(functionName, type, optionName, argument) {\n validateType(functionName, type, optionName + \" option\", argument);\n }", "function validateN...
[ "0.6216687", "0.5895453", "0.5845024", "0.5845024", "0.5845024", "0.5832246", "0.5788133", "0.5788133", "0.5788133", "0.5788133", "0.5788133", "0.5788133", "0.5773505", "0.57698154", "0.57698154", "0.57698154", "0.5757949", "0.5757949", "0.5757949", "0.5757949", "0.5757949", ...
0.6173635
1
Validates that the provided named option equals one of the expected values.
function validateNamedPropertyEquals(functionName,inputName,optionName,input,expected){var expectedDescription=[];for(var _i=0,expected_1=expected;_i<expected_1.length;_i++){var val=expected_1[_i];if(val===input){return;}expectedDescription.push(valueDescription(val));}var actualDescription=valueDescription(input);throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Invalid value "+actualDescription+" provided to function "+functionName+"() for option \""+optionName+"\". Acceptable values: "+expectedDescription.join(', '));}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateNamedPropertyEquals(functionName, inputName, optionName, input, expected) {\n var expectedDescription = [];\n\n for (var _i = 0, expected_1 = expected; _i < expected_1.length; _i++) {\n var val = expected_1[_i];\n\n if (val === input) {\n return;\n }\n\n ...
[ "0.68611276", "0.68418366", "0.68418366", "0.68197274", "0.68029356", "0.68029356", "0.68029356", "0.6559001", "0.6534936", "0.6522112", "0.6515694", "0.65007055", "0.65007055", "0.65007055", "0.648938", "0.6469382", "0.6469382", "0.6469382", "0.6467212", "0.6467212", "0.6430...
0.67124176
7
Validates that the provided named option equals one of the expected values or is undefined.
function validateNamedOptionalPropertyEquals(functionName,inputName,optionName,input,expected){if(input!==undefined){validateNamedPropertyEquals(functionName,inputName,optionName,input,expected);}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateNamedOptionalPropertyEquals(functionName, inputName, optionName, input, expected) {\n if (input !== undefined) {\n validateNamedPropertyEquals(functionName, inputName, optionName, input, expected);\n }\n }", "function validateNamedOptionalPropertyEquals(functionName, inputNam...
[ "0.6772076", "0.6757881", "0.6734659", "0.6734659", "0.6734659", "0.6731869", "0.6731869", "0.6731869", "0.6607187", "0.655746", "0.6544361", "0.6544361", "0.65225357", "0.6517619", "0.6517619", "0.6517619", "0.6503045", "0.6468524", "0.6457104", "0.6457104", "0.64264554", ...
0.6841093
0
Helper to validate the type of a provided input.
function validateType(functionName,type,inputName,input){if(typeof input!==type||type==='object'&&!isPlainObject(input)){var description=valueDescription(input);throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Function "+functionName+"() requires its "+inputName+" "+("to be of type "+type+", but it was: "+description));}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateType(functionName, type, inputName, input) {\n var valid = false;\n\n if (type === 'object') {\n valid = isPlainObject(input);\n } else if (type === 'non-empty string') {\n valid = typeof input === 'string' && input !== '';\n } else {\n valid = typeof input...
[ "0.75121284", "0.74279046", "0.74279046", "0.7410363", "0.73741347", "0.7356353", "0.7356353", "0.7356353", "0.7180964", "0.7064134", "0.70528865", "0.70528865", "0.7012502", "0.6857837", "0.68572414", "0.66779417", "0.6677258", "0.65915096", "0.65504295", "0.6504299", "0.650...
0.6796742
15
Returns true if it's a nonnull object without a custom prototype (i.e. excludes Array, Date, etc.).
function isPlainObject(input){return typeof input==='object'&&input!==null&&(Object.getPrototypeOf(input)===Object.prototype||Object.getPrototypeOf(input)===null);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function hasDefaultPrototype(obj) {\n return Object.getPrototypeOf(obj) === OBJECT_PROTOTYPE;\n}", "function builtinprototypesarenotinstances() {\n try {\n Boolean.prototype.valueOf(); return false;\n } catch(e) {}\n try {\n Number.prototype.valueOf(); return false;\n } catch(e) {}\n tr...
[ "0.7025118", "0.6949823", "0.69336766", "0.68798876", "0.6821428", "0.66448534", "0.6598173", "0.6588191", "0.6559596", "0.6553961", "0.6553961", "0.65346706", "0.6475443", "0.6475443", "0.6475443", "0.6475443", "0.6463763", "0.64305127", "0.6430075", "0.64299124", "0.6425419...
0.0
-1
Returns a string describing the type / value of the provided input.
function valueDescription(input){if(input===undefined){return'undefined';}else if(input===null){return'null';}else if(typeof input==='string'){if(input.length>20){input=input.substring(0,20)+"...";}return JSON.stringify(input);}else if(typeof input==='number'||typeof input==='boolean'){return''+input;}else if(typeof input==='object'){if(input instanceof Array){return'an array';}else{var customObjectName=tryGetCustomObjectType(input);if(customObjectName){return"a custom "+customObjectName+" object";}else{return'an object';}}}else if(typeof input==='function'){return'a function';}else{return fail('Unknown wrong type: '+typeof input);}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function valueDescription(input) {\n if (input === undefined) {\n return 'undefined';\n } else if (input === null) {\n return 'null';\n } else if (typeof input === 'string') {\n if (input.length > 20) {\n input = input.substring(0, 20) + \"...\";\n }\n\n r...
[ "0.803756", "0.8000282", "0.8000282", "0.8000282", "0.7991012", "0.7991012", "0.7991012", "0.7974383", "0.79724085", "0.79724085", "0.7888147", "0.7657586", "0.7533577", "0.7486703", "0.7486703", "0.745504", "0.745504", "0.745504", "0.74114835", "0.7402083", "0.735218", "0....
0.7560747
12
Hacky method to try to get the constructor name for an object.
function tryGetCustomObjectType(input){if(input.constructor){var funcNameRegex=/function\s+([^\s(]+)\s*\(/;var results=funcNameRegex.exec(input.constructor.toString());if(results&&results.length>1){return results[1];}}return null;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getConstructorName(obj) {\n var receiver = obj.receiver\n return (receiver.constructor && receiver.constructor.name) || null\n}", "function getConstructorName(obj) {\n var receiver = obj.receiver\n return (receiver.constructor && receiver.constructor.name) || null\n}", "function getConstructorName...
[ "0.8018996", "0.8018996", "0.8018996", "0.8012797", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", "0.80048895", ...
0.63110113
33
Validates the provided argument is defined.
function validateDefined(functionName,position,argument){if(argument===undefined){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Function "+functionName+"() requires a valid "+ordinal(position)+" "+"argument, but it was undefined.");}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function verify_required_arg(arg, errorMsg) {\n if ((_.isUndefined(arg) || _.isNull(arg))) {\n console.error(errorMsg);\n helpAndExit(1);\n }\n}", "function verifyArgumentIsDefined(value) {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new Error(\"Invalid usage:...
[ "0.7803842", "0.7141236", "0.6951819", "0.69442165", "0.6896325", "0.6893261", "0.6893261", "0.6838038", "0.68017936", "0.6799719", "0.6799719", "0.6799719", "0.6778133", "0.67557573", "0.67548805", "0.67548805", "0.67529154", "0.67529154", "0.67529154", "0.6730802", "0.66674...
0.6590163
23
Validates the provided positional argument is an object, and its keys and values match the expected keys and types provided in optionTypes.
function validateOptionNames(functionName,options,optionNames){index_esm_forEach(options,function(key,_){if(optionNames.indexOf(key)<0){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Unknown option '"+key+"' passed to function "+functionName+"(). "+'Available options: '+optionNames.join(', '));}});}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkArgs(o) {\n let count = 0;\n for (let key in o) {\n if (o[key] == true) count++;\n }\n if (count == 0) {\n confirm(\"Please select at least one parameter\");\n setOptions(o);\n } else return;\n}", "function validateArgType(functionName, type, position, argument) {\n validateType(...
[ "0.63089746", "0.59274846", "0.58094746", "0.5802314", "0.5802314", "0.5802314", "0.57934976", "0.5789164", "0.5789164", "0.5789164", "0.5789164", "0.5789164", "0.5789164", "0.57839227", "0.5765007", "0.57247484", "0.5707698", "0.565867", "0.5615783", "0.5615783", "0.5615783"...
0.0
-1
Helper method to throw an error that the provided argument did not pass an instanceof check.
function invalidClassError(functionName,type,position,argument){var description=valueDescription(argument);return new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Function "+functionName+"() requires its "+ordinal(position)+" "+("argument to be a "+type+", but it was: "+description));}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ofTypeOrThrow(obj, type, error) {\n if (typeof obj == type || false) {\n return obj;\n } else {\n throw error || 'Invalid type: must be a ' + type;\n }\n }", "function validateArgumentType(arg, argName, expectedType) {\n if (typeof arg === 'undefined') {\...
[ "0.6436671", "0.6347351", "0.58347404", "0.57101685", "0.56268775", "0.56268775", "0.56268775", "0.5523934", "0.54984576", "0.54591095", "0.53176457", "0.53166044", "0.5307028", "0.53069675", "0.5303297", "0.5303297", "0.5303297", "0.5303297", "0.5303297", "0.52993727", "0.52...
0.0
-1
Converts a number to its english word representation
function ordinal(num){switch(num){case 1:return'first';case 2:return'second';case 3:return'third';default:return num+'th';}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function numberToEnglish (number) {\n\tvar result;\n\tvar number = number.valueOf();\n\tif(numbersToWords[number]){\n\t\tresult = numbersToWords[number];\n\t}\n\telse if(number < 100){\n\t\tvar numberPlace = Math.floor(number/10);\n\t\tvar numberLeft = number % 10;\n\t\tresult = numbersToWords[numberPlace * 10] ...
[ "0.8081384", "0.7972498", "0.76775545", "0.7607342", "0.75963223", "0.75391525", "0.7535628", "0.75275105", "0.7272447", "0.71734214", "0.7056939", "0.70009774", "0.6951007", "0.693467", "0.6932612", "0.684089", "0.67088884", "0.6702164", "0.66897476", "0.6665003", "0.6602271...
0.0
-1
Formats the given word as plural conditionally given the preceding number.
function formatPlural(num,str){return num+" "+str+(num===1?'':'s');}/** * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */// tslint:disable-next-line:class-as-namespace
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function pluralize(count,word){return count>1?`${word}s`:word;}", "function plural(word,num){var forms=word.split('_');return num % 10 === 1 && num % 100 !== 11?forms[0]:num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20)?forms[1]:forms[2];}", "function plural(word, num) {\n\t var form...
[ "0.77003545", "0.7425191", "0.7412613", "0.7412613", "0.7412613", "0.7397472", "0.7397472", "0.7397472", "0.7384102", "0.7384102", "0.7384102", "0.73646", "0.73646", "0.73646", "0.73646", "0.73646", "0.73646", "0.73646", "0.73646", "0.73646", "0.73646", "0.73646", "0.7364...
0.0
-1
Helper to compare nullable (or undefinedable) objects using isEqual().
function equals(left,right){if(left!==null&&left!==undefined){return!!(right&&left.isEqual(right));}else{// HACK: Explicitly cast since TypeScript's type narrowing apparently isn't // smart enough. return left===right;}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Null$prototype$equals(other) {\n return true;\n }", "function Null$prototype$equals(other) {\n return true;\n }", "function isNullOrUndefined(obj) {\n return obj == null;\n}", "function isNullOrUndefined(value){return value===null||value===undefined;}", "function isNull(obj) {\n retu...
[ "0.70634496", "0.70634496", "0.6800676", "0.6701692", "0.6586762", "0.6568164", "0.6476375", "0.646078", "0.6438877", "0.6430954", "0.6430954", "0.6430954", "0.6430954", "0.64122814", "0.63949007", "0.6391917", "0.63870764", "0.63870764", "0.63870764", "0.63870764", "0.638707...
0.66734743
4
Helper to compare arrays using isEqual().
function arrayEquals(left,right){if(left.length!==right.length){return false;}for(var i=0;i<left.length;i++){if(!left[i].isEqual(right[i])){return false;}}return true;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function eqArrays(arr1, arr2) {\n for (let i = 0; i < arr1.length; i++) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}", "function arraysEqual(a1,a2) {\n return JSON.stringify(a1)==JSON.stringify(a2);\n}", "equalsArray(a, b) {\n if (a === b) return true;\n if (a...
[ "0.8143134", "0.8116504", "0.80521864", "0.8014738", "0.79779136", "0.7891935", "0.7891935", "0.7875506", "0.784294", "0.78214705", "0.780702", "0.7803265", "0.7798216", "0.7798216", "0.77719086", "0.7757777", "0.7757777", "0.7755249", "0.77485657", "0.7743211", "0.7721887", ...
0.7815179
10
Returns the largest lexicographically smaller string of equal or smaller length. Returns an empty string if there is no such predecessor (if the input is empty). Strings returned from this method can be invalid UTF16 but this is sufficent in use for indexeddb because that depends on lexicographical ordering but shouldn't be used elsewhere.
function immediatePredecessor(s){// We can decrement the last character in the string and be done // unless that character is 0 (0x0000), in which case we have to erase the // last character. var lastIndex=s.length-1;if(s.length===0){// Special case the empty string. return'';}else if(s.charAt(lastIndex)==='\0'){return s.substring(0,lastIndex);}else{return s.substring(0,lastIndex)+String.fromCharCode(s.charCodeAt(lastIndex)-1);}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function smallestString(strings) {\n var smallest = strings[0];\n strings.forEach(function (string) {\n if (string.length < smallest.length) {\n smallest = string;\n }\n });\n return smallest;\n}", "function shortestString(shortStr) {\n var leastAmntOfCharacters = shortStr.reduce((x,y) => x.len...
[ "0.6128452", "0.5992519", "0.58672637", "0.58421236", "0.57786626", "0.5737861", "0.57195383", "0.569656", "0.563552", "0.56347704", "0.5627504", "0.5619174", "0.5611114", "0.5608608", "0.5608608", "0.5608608", "0.5608608", "0.5605767", "0.55993277", "0.55787504", "0.5576341"...
0.5748623
5
Returns the immediate lexicographicallyfollowing string. This is useful to construct an inclusive range for indexeddb iterators.
function immediateSuccessor(s){// Return the input string, with an additional NUL byte appended. return s+'\0';}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "prevMatchInRange(state, from, to) {\n for (let pos = to;;) {\n let start = Math.max(from, pos - 10000 /* ChunkSize */ - this.spec.unquoted.length);\n let cursor = stringCursor(this.spec, state, start, pos), range = null;\n while (!cursor.nextOverlapping().done)\n ...
[ "0.57775134", "0.55713147", "0.5497756", "0.5435346", "0.54240525", "0.53239775", "0.53239775", "0.53239775", "0.53239775", "0.530667", "0.5293821", "0.5293821", "0.5293821", "0.5293821", "0.5271439", "0.5241453", "0.52348924", "0.52345765", "0.5172728", "0.51420873", "0.5120...
0.0
-1
Copyright 2017 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Helper function to assert Uint8Array is available at runtime.
function assertUint8ArrayAvailable(){if(typeof Uint8Array==='undefined'){throw new index_esm_FirestoreError(Code.UNIMPLEMENTED,'Uint8Arrays are not available in this environment.');}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function assertUint8ArrayAvailable() {\n if (typeof Uint8Array === 'undefined') {\n throw new __WEBPACK_IMPORTED_MODULE_2__util_error__[\"b\" /* FirestoreError */](__WEBPACK_IMPORTED_MODULE_2__util_error__[\"a\" /* Code */].UNIMPLEMENTED, 'Uint8Arrays are not available in this environment.');\n }\n}",...
[ "0.7876093", "0.78726774", "0.78726774", "0.756602", "0.756602", "0.756602", "0.7326665", "0.69799626", "0.65564317", "0.65278", "0.6502137", "0.6458509", "0.63533777", "0.5899189", "0.5882152", "0.58561087", "0.5853734", "0.585248", "0.585248", "0.585248", "0.585248", "0.5...
0.7205278
7
Helper function to assert Base64 functions are available at runtime.
function assertBase64Available(){if(!PlatformSupport.getPlatform().base64Available){throw new index_esm_FirestoreError(Code.UNIMPLEMENTED,'Blobs are unavailable in Firestore in this environment.');}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function assertBase64Available() {\n if (!__WEBPACK_IMPORTED_MODULE_0__platform_platform__[\"a\" /* PlatformSupport */].getPlatform().base64Available) {\n throw new __WEBPACK_IMPORTED_MODULE_2__util_error__[\"b\" /* FirestoreError */](__WEBPACK_IMPORTED_MODULE_2__util_error__[\"a\" /* Code */].UNIMPLEMEN...
[ "0.733246", "0.7320779", "0.7320779", "0.7121405", "0.71076256", "0.71076256", "0.71076256", "0.7105488", "0.7103158", "0.7103158", "0.7103158", "0.6919044", "0.6864891", "0.66024363", "0.63437057", "0.63437057", "0.63437057", "0.60986626", "0.5976058", "0.5953972", "0.595090...
0.68884385
12
Constructs a DatabaseInfo using the provided host, databaseId and persistenceKey.
function DatabaseInfo(databaseId,persistenceKey,host,ssl){this.databaseId=databaseId;this.persistenceKey=persistenceKey;this.host=host;this.ssl=ssl;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function DatabaseInfo(databaseId, persistenceKey, host, ssl) {\n this.databaseId = databaseId;\n this.persistenceKey = persistenceKey;\n this.host = host;\n this.ssl = ssl;\n }", "function DatabaseInfo(databaseId, persistenceKey, host, ssl) {\n this.databaseId = databaseId;\...
[ "0.804405", "0.804405", "0.804405", "0.804405", "0.804405", "0.804405", "0.8031602", "0.775553", "0.77277887", "0.77025133", "0.77025133", "0.5756065", "0.5552022", "0.54475504", "0.53182656", "0.5306032", "0.527562", "0.52086323", "0.5188464", "0.513209", "0.513209", "0.50...
0.78051037
7
Utility function to compare doubles (using Firestore semantics for NaN).
function numericComparator(left,right){if(left<right){return-1;}else if(left>right){return 1;}else if(left===right){return 0;}else{// one or both are NaN. if(isNaN(left)){return isNaN(right)?0:-1;}else{return 1;}}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wt(t) {\n return !!t && \"doubleValue\" in t && isNaN(Number(t.doubleValue));\n}", "function numericEquals(left,right){// Implemented based on Object.is() polyfill from\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\nif(left===right){// +0 != -0\nreturn...
[ "0.6733727", "0.66536635", "0.6608436", "0.6592568", "0.6459227", "0.64057493", "0.63839304", "0.63550997", "0.63143176", "0.6302297", "0.62940747", "0.62551856", "0.62551856", "0.62551856", "0.6252862", "0.6252862", "0.6252862", "0.6252862", "0.6252862", "0.6252862", "0.6222...
0.0
-1
Utility function to check numbers for equality using Firestore semantics (NaN === NaN, 0.0 !== 0.0).
function numericEquals(left,right){// Implemented based on Object.is() polyfill from // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is if(left===right){// +0 != -0 return left!==0||1/left===1/right;}else{// NaN == NaN return left!==left&&right!==right;}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function numericEquals(left, right) {\n // Implemented based on Object.is() polyfill from\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n if (left === right) {\n // +0 != -0\n return left !== 0 || 1 / left === 1 / right;\n } else {...
[ "0.659099", "0.65570164", "0.65569055", "0.65233856", "0.65233856", "0.65233856", "0.65233856", "0.65233856", "0.65233856", "0.65127695", "0.65127695", "0.65127695", "0.63850826", "0.63850826", "0.63850826", "0.63850826", "0.63850826", "0.63850826", "0.63850826", "0.63850826", ...
0.6858948
0
Returns whether a variable is either undefined or null.
function isNullOrUndefined(value){return value===null||value===undefined;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isUndefined(variable) {\n return typeof variable == 'undefined';\n}", "function isset(variable) {\n return typeof (variable) != \"undefined\" && variable !== null;\n}", "function isDefined(thing) {\n return typeof thing !== \"undefined\" && thing !== null;\n}", "function isDefined(thing) {\...
[ "0.80726296", "0.78380376", "0.7800111", "0.7800111", "0.7800111", "0.7800111", "0.7800111", "0.7549459", "0.7543323", "0.75313514", "0.75269866", "0.7455774", "0.74325645", "0.74133927", "0.74133927", "0.73665917", "0.7363862", "0.73249805", "0.73249805", "0.7321498", "0.731...
0.0
-1
Returns whether a value is an integer and in the safe integer range
function isSafeInteger(value){return isInteger(value)&&value<=MAX_SAFE_INTEGER&&value>=MIN_SAFE_INTEGER;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isInt() {\n\treturn (Number(value) === parseInt(value, 10));\n}", "function isInt(value) {\n return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10));\n }", "function isInt(value)\r\n{\r\n return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parse...
[ "0.81474674", "0.79034317", "0.7890967", "0.7890802", "0.7865139", "0.7865139", "0.7865139", "0.7847501", "0.78456104", "0.78456104", "0.78456104", "0.78456104", "0.78456104", "0.78456104", "0.78395355", "0.7799111", "0.77818316", "0.77603483", "0.7753971", "0.7749543", "0.77...
0.81046134
1
TODO(b/33078163): just use simplest form of existence filter for now
function ExistenceFilter(count){this.count=count;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "exists(){}", "contains(data) {\n return this.find(data) !== -1 ? true : false\n }", "getExists(filterMask) {\n return this._node.eachGet(this._node.all, element => element.currently.exists(), filterMask);\n }", "static existsFilter() {\n return new SubscriptionFilter([{ exists: true }]);...
[ "0.6772156", "0.61619043", "0.6076152", "0.6051931", "0.6051931", "0.60334224", "0.60089093", "0.5976336", "0.5877802", "0.5842089", "0.5827747", "0.58199006", "0.5775196", "0.57493734", "0.57343316", "0.57209015", "0.56896853", "0.56405765", "0.5637867", "0.5620132", "0.5619...
0.58947986
8
Maps an error Code from a GRPC status identifier like 'NOT_FOUND'.
function mapCodeFromRpcStatus(status){// tslint:disable-next-line:no-any lookup by string var code=RpcCode[status];if(code===undefined){return undefined;}return mapCodeFromRpcCode(code);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mapCodeFromHttpResponseErrorStatus(status) {\n var serverError = status.toLowerCase().replace('_', '-');\n return Object.values(Code).indexOf(serverError) >= 0 ? serverError : Code.UNKNOWN;\n }", "function mapCodeFromHttpResponseErrorStatus(status) {\r\n var serverError = status.toLowerC...
[ "0.771246", "0.76523376", "0.76523376", "0.75357014", "0.74697876", "0.74308735", "0.74018973", "0.7370941", "0.7370941", "0.7370941", "0.7368656", "0.7368656", "0.7363789", "0.73483866", "0.73398924", "0.73364544", "0.7307457", "0.7307457", "0.7299557", "0.72701013", "0.7210...
0.7053747
33
Maps an error Code from GRPC status code number, like 0, 1, or 14. These are not the same as HTTP status codes.
function mapCodeFromRpcCode(code){if(code===undefined){// This shouldn't normally happen, but in certain error cases (like trying // to send invalid proto messages) we may get an error with no GRPC code. index_esm_error('GRPC error has no .code');return Code.UNKNOWN;}switch(code){case RpcCode.OK:return Code.OK;case RpcCode.CANCELLED:return Code.CANCELLED;case RpcCode.UNKNOWN:return Code.UNKNOWN;case RpcCode.DEADLINE_EXCEEDED:return Code.DEADLINE_EXCEEDED;case RpcCode.RESOURCE_EXHAUSTED:return Code.RESOURCE_EXHAUSTED;case RpcCode.INTERNAL:return Code.INTERNAL;case RpcCode.UNAVAILABLE:return Code.UNAVAILABLE;case RpcCode.UNAUTHENTICATED:return Code.UNAUTHENTICATED;case RpcCode.INVALID_ARGUMENT:return Code.INVALID_ARGUMENT;case RpcCode.NOT_FOUND:return Code.NOT_FOUND;case RpcCode.ALREADY_EXISTS:return Code.ALREADY_EXISTS;case RpcCode.PERMISSION_DENIED:return Code.PERMISSION_DENIED;case RpcCode.FAILED_PRECONDITION:return Code.FAILED_PRECONDITION;case RpcCode.ABORTED:return Code.ABORTED;case RpcCode.OUT_OF_RANGE:return Code.OUT_OF_RANGE;case RpcCode.UNIMPLEMENTED:return Code.UNIMPLEMENTED;case RpcCode.DATA_LOSS:return Code.DATA_LOSS;default:return fail('Unknown status code: '+code);}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mapCodeFromHttpResponseErrorStatus(status) {\n var serverError = status.toLowerCase().replace('_', '-');\n return Object.values(Code).indexOf(serverError) >= 0 ? serverError : Code.UNKNOWN;\n }", "function mapCodeFromRpcCode(code) {\n if (code === undefined) {\n // This shouldn't ...
[ "0.77321076", "0.7678112", "0.7643651", "0.7643651", "0.7616671", "0.7606668", "0.75644237", "0.7549784", "0.7549784", "0.7549784", "0.75445735", "0.7537092", "0.7537092", "0.7500197", "0.7470519", "0.7442063", "0.7442063", "0.74252266", "0.7424042", "0.74133104", "0.74116206...
0.7573227
6
Maps an RPC code from a Code. This is the reverse operation from mapCodeFromRpcCode and should really only be used in tests.
function mapRpcCodeFromCode(code){if(code===undefined){return RpcCode.OK;}switch(code){case Code.OK:return RpcCode.OK;case Code.CANCELLED:return RpcCode.CANCELLED;case Code.UNKNOWN:return RpcCode.UNKNOWN;case Code.DEADLINE_EXCEEDED:return RpcCode.DEADLINE_EXCEEDED;case Code.RESOURCE_EXHAUSTED:return RpcCode.RESOURCE_EXHAUSTED;case Code.INTERNAL:return RpcCode.INTERNAL;case Code.UNAVAILABLE:return RpcCode.UNAVAILABLE;case Code.UNAUTHENTICATED:return RpcCode.UNAUTHENTICATED;case Code.INVALID_ARGUMENT:return RpcCode.INVALID_ARGUMENT;case Code.NOT_FOUND:return RpcCode.NOT_FOUND;case Code.ALREADY_EXISTS:return RpcCode.ALREADY_EXISTS;case Code.PERMISSION_DENIED:return RpcCode.PERMISSION_DENIED;case Code.FAILED_PRECONDITION:return RpcCode.FAILED_PRECONDITION;case Code.ABORTED:return RpcCode.ABORTED;case Code.OUT_OF_RANGE:return RpcCode.OUT_OF_RANGE;case Code.UNIMPLEMENTED:return RpcCode.UNIMPLEMENTED;case Code.DATA_LOSS:return RpcCode.DATA_LOSS;default:return fail('Unknown status code: '+code);}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mapCodeFromRpcCode(code) {\n if (code === undefined) {\n // This shouldn't normally happen, but in certain error cases (like trying\n // to send invalid proto messages) we may get an error with no GRPC code.\n error$1('GRPC error has no .code');\n return Code.UNKNOWN;\n }...
[ "0.81055766", "0.80867696", "0.80669624", "0.8050561", "0.8039022", "0.8039022", "0.80281925", "0.80281925", "0.80281925", "0.7958045", "0.7958045", "0.7958045", "0.795753", "0.7952236", "0.7945062", "0.7943833", "0.7943833", "0.7943833", "0.79264355", "0.7759837", "0.7571448...
0.7869572
19
Converts an HTTP Status Code to the equivalent error code.
function mapCodeFromHttpStatus(status){// The canonical error codes for Google APIs [1] specify mapping onto HTTP // status codes but the mapping is not bijective. In each case of ambiguity // this function chooses a primary error. // // [1] // https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto switch(status){case 200:// OK return Code.OK;case 400:// Bad Request return Code.INVALID_ARGUMENT;// Other possibilities based on the forward mapping // return Code.FAILED_PRECONDITION; // return Code.OUT_OF_RANGE; case 401:// Unauthorized return Code.UNAUTHENTICATED;case 403:// Forbidden return Code.PERMISSION_DENIED;case 404:// Not Found return Code.NOT_FOUND;case 409:// Conflict return Code.ABORTED;// Other possibilities: // return Code.ALREADY_EXISTS; case 416:// Range Not Satisfiable return Code.OUT_OF_RANGE;case 429:// Too Many Requests return Code.RESOURCE_EXHAUSTED;case 499:// Client Closed Request return Code.CANCELLED;case 500:// Internal Server Error return Code.UNKNOWN;// Other possibilities: // return Code.INTERNAL; // return Code.DATA_LOSS; case 501:// Unimplemented return Code.UNIMPLEMENTED;case 503:// Service Unavailable return Code.UNAVAILABLE;case 504:// Gateway Timeout return Code.DEADLINE_EXCEEDED;default:if(status>=200&&status<300)return Code.OK;if(status>=400&&status<500)return Code.FAILED_PRECONDITION;if(status>=500&&status<600)return Code.INTERNAL;return Code.UNKNOWN;}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function errorFromStatusCode(status) {\n var error = null\n if (status === 0 || (status >= 400 && status < 600)) {\n var message = (typeof body === \"string\" ? body : false) ||\n messages[String(status).charAt(0)]\n error = new Error(message)\...
[ "0.76832145", "0.76616544", "0.76616544", "0.7637732", "0.76323783", "0.76323783", "0.7621343", "0.74586535", "0.74586535", "0.74586535", "0.7365355", "0.70964533", "0.7088966", "0.7084609", "0.7084609", "0.70287585", "0.70287585", "0.70247346", "0.70226204", "0.6831744", "0....
0.72359264
11
Checks for a specific oneof tag in a protocol buffer message. This intentionally accommodates two distinct cases: 1) Messages containing a type tag: these are the format produced by GRPC in return values. These may contain defaultvalue mappings for all tags in the oneof but the type tag specifies which one was actually set. 2) Messages that don't contain a type tag: these are the format required by GRPC as inputs. If we emitted objects with type tags, ProtoBuf.js would choke claiming that the tags aren't fields in the Message. Allowing both formats here makes the serializer able to consume the outputs it produces: for all messages it supports, fromX(toX(value)) == value. Note that case 2 suffers from ambiguity: if multiple tags are present without a type tag then the callers are structured in such a way that the first invocation will win. Since we only parse in this mode when parsing the output of a serialize method this works, but it's not a general solution. Unfortunately there is no general solution here because proto3 makes it impossible to distinguish unset from explicitly set fields: both have the default value for the type. Without the type tag but multiple value tags it's possible to have default values for each tag in the oneof and not be able to know which was actually in effect.
function hasTag(obj,type,tag){return type===tag||!type&&tag in obj;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validateOneOfIsNotUsedWithUnsupportedConstraints(context) {\n // oneOf can be used like the following:\n //\n // oneOf:\n // - ...\n // - ...\n // ...\n //\n // where its effectively a combination of \"one of these two constraints\"\n // and \"also these other constraits\" which is ef...
[ "0.55464906", "0.52813286", "0.47830045", "0.4725269", "0.43887547", "0.43524694", "0.42546213", "0.42546213", "0.42546213", "0.42546213", "0.42365816", "0.41186327", "0.4108018", "0.41061324", "0.4098332", "0.40831503", "0.40823883", "0.4071602", "0.4071602", "0.4071602", "0...
0.42603126
6
Creates a FieldPath from the provided field names. If more than one field name is provided, the path will point to a nested field in a document.
function FieldPath$$1(){var fieldNames=[];for(var _i=0;_i<arguments.length;_i++){fieldNames[_i]=arguments[_i];}validateNamedArrayAtLeastNumberOfElements('FieldPath',fieldNames,'fieldNames',1);for(var i=0;i<fieldNames.length;++i){validateArgType('FieldPath','string',i,fieldNames[i]);if(fieldNames[i].length===0){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). "+'Field names must not be empty.');}}this._internalPath=new index_esm_FieldPath(fieldNames);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function FieldPath$1() {\n var fieldNames = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n fieldNames[_i] = arguments[_i];\n }\n\n validateNamedArrayAtLeastNumberOfElements('FieldPath', fieldNames, 'fieldNames', 1);\n\n for (var i = 0; i < fieldNames.length; ++i) {\n validateArg...
[ "0.77150905", "0.7680039", "0.7680039", "0.7680039", "0.76166165", "0.76124454", "0.76124454", "0.76124454", "0.75105655", "0.7352907", "0.7352907", "0.60033125", "0.5966112", "0.59505975", "0.59505945", "0.5932884", "0.5910237", "0.5902292", "0.58927613", "0.5879341", "0.587...
0.7376104
9
Parses a field path string into a FieldPath, treating dots as separators.
function fromDotSeparatedString(path){var found=path.search(RESERVED);if(found>=0){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Invalid field path ("+path+"). Paths must not contain "+"'~', '*', '/', '[', or ']'");}try{return new(FieldPath$1.bind.apply(FieldPath$1,[void 0].concat(path.split('.'))))();}catch(e){throw new index_esm_FirestoreError(Code.INVALID_ARGUMENT,"Invalid field path ("+path+"). Paths must not be empty, "+"begin with '.', end with '.', or contain '..'");}}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fromDotSeparatedString(path) {\n var found = path.search(RESERVED);\n\n if (found >= 0) {\n throw new FirestoreError(Code.INVALID_ARGUMENT, \"Invalid field path (\" + path + \"). Paths must not contain \" + \"'~', '*', '/', '[', or ']'\");\n }\n\n try {\n return new (Fiel...
[ "0.7825314", "0.7731984", "0.77015865", "0.77015865", "0.77015865", "0.7688934", "0.7688934", "0.76420045", "0.76055986", "0.75797063", "0.75797063", "0.71822906", "0.7063504", "0.7063504", "0.7063504", "0.7063504", "0.7063504", "0.7063504", "0.70529085", "0.7032021", "0.7007...
0.7502382
11
The default ordering is by key if the comparator is omitted
function DocumentSet(comp){// We are adding document key comparator to the end as it's the only // guaranteed unique property of a document. if(comp){this.comparator=function(d1,d2){return comp(d1,d2)||DocumentKey.comparator(d1.key,d2.key);};}else{this.comparator=function(d1,d2){return DocumentKey.comparator(d1.key,d2.key);};}this.keyedMap=documentMap();this.sortedSet=new SortedMap(this.comparator);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "compareBy(key) {\n return function (a, b) {\n if (a[key] < b[key]) return -1;\n if (a[key] > b[key]) return 1;\n return 0;\n };\n }", "get comparator() {\n return null;\n }", "get comparator() {\n return null;\n }", "get sortingOrder() {}", "function increasingOrde...
[ "0.6302417", "0.592849", "0.592849", "0.5847215", "0.58423996", "0.5826604", "0.5757907", "0.5723279", "0.5723279", "0.57043874", "0.56809765", "0.56568086", "0.56234825", "0.5613971", "0.56019133", "0.55602187", "0.5559307", "0.55535144", "0.55459714", "0.55392116", "0.55330...
0.0
-1
Encodes a resource path into a IndexedDbcompatible string form.
function encode(path){var result='';for(var i=0;i<path.length;i++){if(result.length>0){result=encodeSeparator(result);}result=encodeSegment(path.get(i),result);}return encodeSeparator(result);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function encode(path) { return encodeURIComponent(path) }", "function encode(path) { return encodeURIComponent(path); }", "function encode(path) {\r\n var result = '';\r\n for (var i = 0; i < path.length; i++) {\r\n if (result.length > 0) {\r\n result = encodeSeparator(result);\r\n ...
[ "0.66030896", "0.65620214", "0.62843513", "0.62843513", "0.62843513", "0.62385696", "0.6229867", "0.6229867", "0.6229867", "0.6229867", "0.6229867", "0.6229867", "0.62187856", "0.57748324", "0.57748324", "0.5745083", "0.5548475", "0.5384502", "0.52170795", "0.5203726", "0.518...
0.6624666
0
Encodes a single segment of a resource path into the given result
function encodeSegment(segment,resultBuf){var result=resultBuf;var length=segment.length;for(var i=0;i<length;i++){var c=segment.charAt(i);switch(c){case'\0':result+=escapeChar+encodedNul;break;case escapeChar:result+=escapeChar+encodedEscape;break;default:result+=c;}}return result;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function encode(path){var result='';for(var i=0;i<path.length;i++){if(result.length>0){result=encodeSeparator(result);}result=encodeSegment(path.get(i),result);}return encodeSeparator(result);}", "function encodeSegment(segment, resultBuf) {\r\n var result = resultBuf;\r\n var length = segment.length;\r\n ...
[ "0.6545016", "0.6511343", "0.6511343", "0.6511343", "0.64955485", "0.6472346", "0.6472346", "0.6472346", "0.6472346", "0.6472346", "0.6472346", "0.64658237", "0.6234521", "0.61268014", "0.611432", "0.61082727", "0.6083156", "0.60538757", "0.60538757", "0.60538757", "0.6036894...
0.6738832
0
Encodes a path separator into the given result
function encodeSeparator(result){return result+escapeChar+encodedSeparatorChar;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function encodeSeparator(result) {\n return result + escapeChar + encodedSeparatorChar;\n }", "function encodeSeparator(result) {\n return result + escapeChar + encodedSeparatorChar;\n}", "function encodeSeparator(result) {\n return result + escapeChar + encodedSeparatorChar;\n}", "function enc...
[ "0.763443", "0.76262575", "0.76262575", "0.76262575", "0.76262575", "0.76262575", "0.76262575", "0.76194006", "0.7601404", "0.7601404", "0.7601404", "0.75986487", "0.7220876", "0.70907485", "0.70796216", "0.70796216", "0.70796216", "0.70796216", "0.70796216", "0.70796216", "0...
0.7704302
0
Decodes the given IndexedDbcompatible string form of a resource path into a ResourcePath instance. Note that this method is not suitable for use with decoding resource names from the server; those are One Platform format strings.
function decode$1(path){// Event the empty path must encode as a path of at least length 2. A path // with exactly 2 must be the empty path. var length=path.length;index_esm_assert(length>=2,'Invalid path '+path);if(length===2){index_esm_assert(path.charAt(0)===escapeChar&&path.charAt(1)===encodedSeparatorChar,'Non-empty path '+path+' had length 2');return index_esm_ResourcePath.EMPTY_PATH;}// Escape characters cannot exist past the second-to-last position in the // source value. var lastReasonableEscapeIndex=length-2;var segments=[];var segmentBuilder='';for(var start=0;start<length;){// The last two characters of a valid encoded path must be a separator, so // there must be an end to this segment. var end=path.indexOf(escapeChar,start);if(end<0||end>lastReasonableEscapeIndex){fail('Invalid encoded resource path: "'+path+'"');}var next=path.charAt(end+1);switch(next){case encodedSeparatorChar:var currentPiece=path.substring(start,end);var segment=void 0;if(segmentBuilder.length===0){// Avoid copying for the common case of a segment that excludes \0 // and \001 segment=currentPiece;}else{segmentBuilder+=currentPiece;segment=segmentBuilder;segmentBuilder='';}segments.push(segment);break;case encodedNul:segmentBuilder+=path.substring(start,end);segmentBuilder+='\0';break;case encodedEscape:// The escape character can be used in the output to encode itself. segmentBuilder+=path.substring(start,end+1);break;default:fail('Invalid encoded resource path: "'+path+'"');}start=end+2;}return new index_esm_ResourcePath(segments);}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function decode(path) {\n // Event the empty path must encode as a path of at least length 2. A path\n // with exactly 2 must be the empty path.\n var length = path.length;\n assert(length >= 2, 'Invalid path ' + path);\n\n if (length === 2) {\n assert(path.charAt(0) === escapeChar ...
[ "0.6234687", "0.6209203", "0.61613846", "0.61613846", "0.61613846", "0.6117231", "0.6117231", "0.6082539", "0.582468", "0.5704872", "0.5704872", "0.5135804", "0.51283574", "0.51283574", "0.5105815", "0.4926316", "0.48105234", "0.48017195", "0.4799645", "0.46857026", "0.461335...
0.5527619
11
Performs database creation and schema upgrades. Note that in production, this method is only ever used to upgrade the schema to SCHEMA_VERSION. Different values of toVersion are only used for testing and local feature development.
function createOrUpgradeDb(db,txn,fromVersion,toVersion){index_esm_assert(fromVersion<toVersion&&fromVersion>=0&&toVersion<=SCHEMA_VERSION,'Unexpected schema upgrade from v${fromVersion} to v{toVersion}.');if(fromVersion<1&&toVersion>=1){createOwnerStore(db);createMutationQueue(db);createQueryCache(db);createRemoteDocumentCache(db);}// Migration 2 to populate the targetGlobal object no longer needed since // migration 3 unconditionally clears it. var p=PersistencePromise.resolve();if(fromVersion<3&&toVersion>=3){// Brand new clients don't need to drop and recreate--only clients that // potentially have corrupt data. if(fromVersion!==0){dropQueryCache(db);createQueryCache(db);}p=p.next(function(){return writeEmptyTargetGlobalEntry(txn);});}return p;}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "init(database: SQLite.SQLiteDatabase): Promise<void> {\n let dbVersion: number = 1;\n console.log('Beginning database updates...');\n\n // First: create tables if they do not already exist\n return database\n .transaction(this._createTables)\n .then(() => {\n // Get the current databas...
[ "0.58368415", "0.5795141", "0.5636012", "0.5633977", "0.5633977", "0.55971134", "0.55341333", "0.55263", "0.5472958", "0.53752124", "0.5313832", "0.52930707", "0.5251488", "0.52407974", "0.5237372", "0.521745", "0.5183013", "0.5059713", "0.504434", "0.5013345", "0.49978563", ...
0.66962194
0