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
Don't emit readable right away in sync mode, because this can trigger another read() call => stack overflow. This way, it might trigger a nextTick recursion warning, but that's not so bad.
function emitReadable(stream) { var state = stream._readableState; state.needReadable = false; if (!state.emittedReadable) { debug('emitReadable', state.flowing); state.emittedReadable = true; if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(!state.emittedReadable){debug(\"emitReadable\",state.flowing);state.emittedReadable=true;if(state.sync)processNextTick(emitReadable_,stream);else emitReadable_(stream)}}", "function emitReadable(stream){var state=stream._re...
[ "0.7174339", "0.711771", "0.711771", "0.6980705", "0.6934712", "0.692287", "0.6903377", "0.68976504", "0.6884873", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.68748367", "0.6874...
0.0
-1
at this point, the user has presumably seen the 'readable' event, and called read() to consume some data. that may have triggered in turn another _read(n) call, in which case reading = true if it's in progress. However, if we're not ended, or reading, and the length < hwm, then go ahead and try to read some more preemptively.
function maybeReadMore(stream, state) { if (!state.readingMore) { state.readingMore = true; pna.nextTick(maybeReadMore_, stream, state); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_read() {\r\n\t\tthis._readingPaused = false\r\n\t\tsetImmediate(this._onReadable.bind(this))\r\n\t}", "_onReadable() {\r\n\t\t// Read all the data until one of two conditions is met\r\n\t\t// 1. there is nothing left to read on the socket\r\n\t\t// 2. reading is paused because the consumer is slow\r\n\t\twhile ...
[ "0.7301529", "0.69759184", "0.676946", "0.6744838", "0.6744838", "0.6742702", "0.6742702", "0.6721936", "0.6689668", "0.6663449", "0.6654217", "0.6618481", "0.6566745", "0.6501123", "0.65003943", "0.65003943", "0.6484717", "0.6468223", "0.6466056", "0.63834864", "0.63818634",...
0.0
-1
if the dest has an error, then stop piping into it. however, don't suppress the throwing behavior for this.
function onerror(er) { debug('onerror', er); unpipe(); dest.removeListener('error', onerror); if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onerror(er){debug(\"onerror\",er);unpipe();dest.removeListener(\"error\",onerror);if(EElistenerCount(dest,\"error\")===0)dest.emit(\"error\",er)}", "function onerror(er){debug('onerror',er);unpipe();dest.removeListener('error',onerror);if(EElistenerCount(dest,'error')===0)dest.emit('error',er);}// Make ...
[ "0.7603676", "0.7207491", "0.7207491", "0.7207491", "0.7148509", "0.7148509", "0.71428335", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0.71253103", "0...
0.0
-1
Both close and finish should trigger unpipe, but only once.
function onclose() { dest.removeListener('finish', onfinish); unpipe(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onclose() {\n\t dest.removeListener('finish', onfinish);\n\t unpipe();\n\t }", "function onclose() {\n\t dest.removeListener('finish', onfinish);\n\t unpipe();\n\t }", "function onclose() {\n\t dest.removeListener('finish', onfinish);\n\t unpipe();\n\t }", "function onclose() {\...
[ "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "0.7979085", "...
0.0
-1
Pluck off n bytes from an array of buffers. Length is the combined lengths of all the buffers in the list. This function is designed to be inlinable, so please take care when making changes to the function body.
function fromList(n, state) { // nothing buffered if (state.length === 0) return null; var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); state.buffer.clear(); } else { // read part of list ret = fromListPartial(n, state.buffer, state.decoder); } return ret; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n\n if (...
[ "0.65626067", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756", "0.65611756"...
0.0
-1
Extracts only enough buffered data to satisfy the amount requested. This function is designed to be inlinable, so please take care when making changes to the function body.
function fromListPartial(n, list, hasStrings) { var ret; if (n < list.head.data.length) { // slice is the same for buffers and strings ret = list.head.data.slice(0, n); list.head.data = list.head.data.slice(n); } else if (n === list.head.data.length) { // first chunk is a perfect match ret = list.shift(); } else { // result spans more than one buffer ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); } return ret; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _sliceBuffer(amount) {\n var newBuffer = _itemsWaitingToBeRendered.slice(amount, _itemsWaitingToBeRendered.length);\n var returnedObjArray = _itemsWaitingToBeRendered.slice(0, amount);\n _itemsWaitingToBeRendered = newBuffer;\n return returnedObjArray;\n }", "async readWait(length...
[ "0.620986", "0.6176825", "0.5868571", "0.58036065", "0.5688536", "0.55528647", "0.5504195", "0.5504195", "0.5498154", "0.5498154", "0.54965955", "0.54882735", "0.5452782", "0.5448647", "0.5446132", "0.5446132", "0.54243827", "0.54192686", "0.54192686", "0.54192686", "0.541926...
0.0
-1
Copies a specified amount of characters from the list of buffered data chunks. This function is designed to be inlinable, so please take care when making changes to the function body.
function copyFromBufferString(n, list) { var p = list.head; var c = 1; var ret = p.data; n -= ret.length; while (p = p.next) { var str = p.data; var nb = n > str.length ? str.length : n; if (nb === str.length) ret += str;else ret += str.slice(0, n); n -= nb; if (n === 0) { if (nb === str.length) { ++c; if (p.next) list.head = p.next;else list.head = list.tail = null; } else { list.head = p; p.data = str.slice(nb); } break; } ++c; } list.length -= c; return ret; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function copyFromBufferString(n,list){var p=list.head;var c=1;var ret=p.data;n-=ret.length;while(p=p.next){var str=p.data;var nb=n>str.length?str.length:n;if(nb===str.length)ret+=str;else ret+=str.slice(0,n);n-=nb;if(n===0){if(nb===str.length){++c;if(p.next)list.head=p.next;else list.head=list.tail=null;}else{list...
[ "0.7563655", "0.7563655", "0.7563655", "0.75149834", "0.7505612", "0.685258", "0.6747803", "0.6714964" ]
0.0
-1
Copies a specified amount of bytes from the list of buffered data chunks. This function is designed to be inlinable, so please take care when making changes to the function body.
function copyFromBuffer(n, list) { var ret = Buffer.allocUnsafe(n); var p = list.head; var c = 1; p.data.copy(ret); n -= p.data.length; while (p = p.next) { var buf = p.data; var nb = n > buf.length ? buf.length : n; buf.copy(ret, ret.length - n, 0, nb); n -= nb; if (n === 0) { if (nb === buf.length) { ++c; if (p.next) list.head = p.next;else list.head = list.tail = null; } else { list.head = p; p.data = buf.slice(nb); } break; } ++c; } list.length -= c; return ret; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function copyFromBufferString(n,list){var p=list.head;var c=1;var ret=p.data;n-=ret.length;while(p=p.next){var str=p.data;var nb=n>str.length?str.length:n;if(nb===str.length)ret+=str;else ret+=str.slice(0,n);n-=nb;if(n===0){if(nb===str.length){++c;if(p.next)list.head=p.next;else list.head=list.tail=null;}else{list...
[ "0.71230704", "0.71230704", "0.71230704", "0.6895239", "0.68703276", "0.6340849", "0.63128674", "0.63093835" ]
0.0
-1
It seems a linked list but it is not there will be only 2 of these for each stream
function CorkedRequest(state) { var _this = this; this.next = null; this.entry = null; this.finish = function () { onCorkedFinish(_this, state); }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "isStream(){\n return this.iterators.length > 0 && this.iterators[0].streamer && Util.isStreamer(this.iterators[0].streamer);\n }", "prnt() {\n console.log(this.size);\n let current = this.head;\n while (current != null) {\n console.log(current);\n current = current.next;\n ...
[ "0.60562474", "0.5973577", "0.59712476", "0.5895271", "0.58480227", "0.58089036", "0.5804585", "0.5793426", "0.5782114", "0.5744417", "0.57425845", "0.57248867", "0.57130986", "0.5713064", "0.5695168", "0.56762546", "0.566372", "0.5656899", "0.5649103", "0.56442535", "0.56214...
0.0
-1
Checks that a usersupplied chunk is valid, especially for the particular mode the stream is in. Currently this means that `null` is never accepted and undefined/nonstring values are only allowed in object mode.
function validChunk(stream, state, chunk, cb) { var valid = true; var er = false; if (chunk === null) { er = new TypeError('May not write null values to stream'); } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { er = new TypeError('Invalid non-string/buffer chunk'); } if (er) { stream.emit('error', er); pna.nextTick(cb, er); valid = false; } return valid; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validChunk(stream,state,chunk,cb){var valid=true;var er=false;if(chunk===null){er=new TypeError(\"May not write null values to stream\")}else if(typeof chunk!==\"string\"&&chunk!==undefined&&!state.objectMode){er=new TypeError(\"Invalid non-string/buffer chunk\")}if(er){stream.emit(\"error\",er);processNe...
[ "0.80093753", "0.7968506", "0.7958901", "0.79458404", "0.7909733", "0.79038304", "0.78475356", "0.7831503", "0.7831503", "0.781094", "0.78047717", "0.7803307", "0.7803307", "0.78027385", "0.78027385", "0.7795045", "0.7795045", "0.7795045", "0.7795045", "0.7795045", "0.7792291...
0.0
-1
if we're already writing something, then just put this in the queue, and wait our turn. Otherwise, call _write If we return false, then we need a drain event, so set that flag.
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { var newChunk = decodeChunk(state, chunk, encoding); if (chunk !== newChunk) { isBuf = true; encoding = 'buffer'; chunk = newChunk; } } var len = state.objectMode ? 1 : chunk.length; state.length += len; var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; if (state.writing || state.corked) { var last = state.lastBufferedRequest; state.lastBufferedRequest = { chunk: chunk, encoding: encoding, isBuf: isBuf, callback: cb, next: null }; if (last) { last.next = state.lastBufferedRequest; } else { state.bufferedRequest = state.lastBufferedRequest; } state.bufferedRequestCount += 1; } else { doWrite(stream, state, false, len, chunk, encoding, cb); } return ret; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit('drain');}}// if there's something in the buffer waiting, then process it", "function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit('drain');}}// if the...
[ "0.7143378", "0.7143378", "0.7143378", "0.7143378", "0.69726384", "0.6951576", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", "0.6889258", ...
0.0
-1
Must force callback to be called on nextTick, so that we don't emit 'drain' before the write() consumer gets the 'false' return value, and has a chance to attach a 'drain' listener.
function onwriteDrain(stream, state) { if (state.length === 0 && state.needDrain) { state.needDrain = false; stream.emit('drain'); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit(\"drain\")}}", "onDrain() {\n this.writeBuffer.splice(0, this.prevBufferLen); // setting prevBufferLen = 0 is very important\n // for example, when upgrading, upgrade packet is sent over,\n // and...
[ "0.6865807", "0.68425786", "0.6840534", "0.6840534", "0.6840534", "0.6840534", "0.68187344", "0.6766642", "0.6766642", "0.6757269", "0.6720652", "0.6720652", "0.6720652", "0.6720652", "0.6720652", "0.6720652", "0.6720652", "0.6720652", "0.6720652", "0.6720652", "0.6720652", ...
0.0
-1
if there's something in the buffer waiting, then process it
function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; if (stream._writev && entry && entry.next) { // Fast case, write everything using _writev() var l = state.bufferedRequestCount; var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; var count = 0; var allBuffers = true; while (entry) { buffer[count] = entry; if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } buffer.allBuffers = allBuffers; doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time // as the hot path ends with doWrite state.pendingcb++; state.lastBufferedRequest = null; if (holder.next) { state.corkedRequestsFree = holder.next; holder.next = null; } else { state.corkedRequestsFree = new CorkedRequest(state); } state.bufferedRequestCount = 0; } else { // Slow case, write chunks one-by-one while (entry) { var chunk = entry.chunk; var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then // it means that we need to wait until it does. // also, that means that the chunk and cb are currently // being processed, so move the buffer counter past them. if (state.writing) { break; } } if (entry === null) state.lastBufferedRequest = null; } state.bufferedRequest = entry; state.bufferProcessing = false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "processBuffer () {\n this.ready = true\n this._triggerBuffer()\n this.queue.waterfall(() => this.buffer.guardian)\n }", "function drainBuffer(cb) {\n if (!state.buffer.length)\n return cb()\n var done = multicb()\n var wait = false\n state.buffer.forEach(function(entry) {\n if (ha...
[ "0.6989099", "0.6406414", "0.63613397", "0.620778", "0.60211736", "0.59515584", "0.59415096", "0.59415096", "0.59415096", "0.59415096", "0.59035516", "0.5865887", "0.58270913", "0.58201474", "0.58172125", "0.5805252", "0.5790036", "0.5763926", "0.5763926", "0.5763926", "0.576...
0.0
-1
undocumented cb() API, needed for core, not for public API
function destroy(err, cb) { var _this = this; var readableDestroyed = this._readableState && this._readableState.destroyed; var writableDestroyed = this._writableState && this._writableState.destroyed; if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { pna.nextTick(emitErrorNT, this, err); } return this; } // we set destroyed to true before firing error callbacks in order // to make it re-entrance safe in case destroy() is called within callbacks if (this._readableState) { this._readableState.destroyed = true; } // if this is a duplex stream mark the writable part as destroyed as well if (this._writableState) { this._writableState.destroyed = true; } this._destroy(err || null, function (err) { if (!cb && err) { pna.nextTick(emitErrorNT, _this, err); if (_this._writableState) { _this._writableState.errorEmitted = true; } } else if (cb) { cb(err); } }); return this; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function callback() {}", "function callback() {}", "function callback() {}", "function callback() {}", "function callback() {}", "function callback(){}", "function cb () {\n\t\tcallback();\n\t}", "function callback(cb){\n\n cb(1);\n}", "function callbackDriver() {\n cb();\n }", "function _...
[ "0.7928905", "0.7928905", "0.7928905", "0.7928905", "0.7928905", "0.7877934", "0.77447444", "0.73254204", "0.7234518", "0.71503025", "0.71441734", "0.71441734", "0.71282893", "0.7032806", "0.70259714", "0.6999851", "0.6972972", "0.6934845", "0.6920968", "0.6806171", "0.680617...
0.0
-1
Do not cache `Buffer.isEncoding` when checking encoding names as some modules monkeypatch it to support additional encodings
function normalizeEncoding(enc) { var nenc = _normalizeEncoding(enc); if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); return nenc || enc; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function detectUTF8(txt) {\n if(txt) return txt.match(/([\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEF][\\x80-\\xBF][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[\\xF1-\\xF7][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|\\xF8[\\x88-\\xBF][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|[...
[ "0.6635265", "0.65760595", "0.65354884", "0.6478273", "0.6463494", "0.62667626", "0.62661046", "0.62631136", "0.62570816", "0.6208488", "0.61463493", "0.61388755", "0.61089295", "0.61089295", "0.61089295", "0.61089295", "0.61089295", "0.61089295", "0.61089295", "0.61089295", ...
0.0
-1
Checks the type of a UTF8 byte, whether it's ASCII, a leading byte, or a continuation byte. If an invalid byte is detected, 2 is returned.
function utf8CheckByte(byte) { if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; return byte >> 6 === 0x02 ? -1 : -2; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utf8CheckByte(_byte) {\n if (_byte <= 0x7F) return 0;else if (_byte >> 5 === 0x06) return 2;else if (_byte >> 4 === 0x0E) return 3;else if (_byte >> 3 === 0x1E) return 4;\n return _byte >> 6 === 0x02 ? -1 : -2;\n} // Checks at most 3 bytes at the end of a Buffer in order to detect an", "function $lrG1...
[ "0.80071485", "0.7941057", "0.7896804", "0.78160745", "0.78160745", "0.77788097", "0.77684426", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", "0.77556324", ...
0.0
-1
Checks at most 3 bytes at the end of a Buffer in order to detect an incomplete multibyte UTF8 character. The total number of bytes (2, 3, or 4) needed to complete the UTF8 character (if applicable) are returned.
function utf8CheckIncomplete(self, buf, i) { var j = buf.length - 1; if (j < i) return 0; var nb = utf8CheckByte(buf[j]); if (nb >= 0) { if (nb > 0) self.lastNeed = nb - 1; return nb; } if (--j < i || nb === -2) return 0; nb = utf8CheckByte(buf[j]); if (nb >= 0) { if (nb > 0) self.lastNeed = nb - 2; return nb; } if (--j < i || nb === -2) return 0; nb = utf8CheckByte(buf[j]); if (nb >= 0) { if (nb > 0) { if (nb === 2) nb = 0;else self.lastNeed = nb - 3; } return nb; } return 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);if(nb>=0){if(nb>0)self.lastNeed=nb-1;return nb;}if(--j<i||nb===-2)return 0;nb=utf8CheckByte(buf[j]);if(nb>=0){if(nb>0)self.lastNeed=nb-2;return nb;}if(--j<i||nb===-2)return 0;nb=utf8CheckByte(buf[j]);if(nb>=0){...
[ "0.82110626", "0.82110626", "0.81340784", "0.81340784", "0.8053497", "0.8053497", "0.80296516", "0.8010968", "0.78475666", "0.7843401", "0.7776888", "0.77501607", "0.77501607", "0.77501607", "0.77501607", "0.77501607", "0.77501607", "0.77501607", "0.77501607", "0.77501607", "...
0.0
-1
Validates as many continuation bytes for a multibyte UTF8 character as needed or are available. If we see a noncontinuation byte where we expect one, we "replace" the validated continuation bytes we've seen so far with a single UTF8 replacement character ('\ufffd'), to match v8's UTF8 decoding behavior. The continuation byte check is included three times in the case where all of the continuation bytes for a character exist in the same buffer. It is also done this way as a slight performance increase instead of using a loop.
function utf8CheckExtraBytes(self, buf, p) { if ((buf[0] & 0xC0) !== 0x80) { self.lastNeed = 0; return '\ufffd'; } if (self.lastNeed > 1 && buf.length > 1) { if ((buf[1] & 0xC0) !== 0x80) { self.lastNeed = 1; return '\ufffd'; } if (self.lastNeed > 2 && buf.length > 2) { if ((buf[2] & 0xC0) !== 0x80) { self.lastNeed = 2; return '\ufffd'; } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j<i)return 0;var nb=utf8CheckByte(buf[j]);if(nb>=0){if(nb>0)self.lastNeed=nb-1;return nb;}if(--j<i||nb===-2)return 0;nb=utf8CheckByte(buf[j]);if(nb>=0){if(nb>0)self.lastNeed=nb-2;return nb;}if(--j<i||nb===-2)return 0;nb=utf8CheckByte(buf[j]);if(nb>=0){...
[ "0.79382133", "0.79382133", "0.746637", "0.7310104", "0.7310104", "0.7114822", "0.670945", "0.65889984", "0.6557506", "0.65448034", "0.64812857", "0.64359194", "0.63850605", "0.62734044", "0.5986173", "0.5986173", "0.5986173", "0.5986173", "0.5986173", "0.5986173", "0.5986173...
0.0
-1
Attempts to complete a multibyte UTF8 character using bytes from a Buffer.
function utf8FillLast(buf) { var p = this.lastTotal - this.lastNeed; var r = utf8CheckExtraBytes(this, buf, p); if (r !== undefined) return r; if (this.lastNeed <= buf.length) { buf.copy(this.lastChar, p, 0, this.lastNeed); return this.lastChar.toString(this.encoding, 0, this.lastTotal); } buf.copy(this.lastChar, p, 0, buf.length); this.lastNeed -= buf.length; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utf8CheckExtraBytes(self,buf,p){if((buf[0]&0xC0)!==0x80){self.lastNeed=0;return '\\ufffd';}if(self.lastNeed>1&&buf.length>1){if((buf[1]&0xC0)!==0x80){self.lastNeed=1;return '\\ufffd';}if(self.lastNeed>2&&buf.length>2){if((buf[2]&0xC0)!==0x80){self.lastNeed=2;return '\\ufffd';}}}}// Attempts to complete a ...
[ "0.71285844", "0.701326", "0.678287", "0.67024726", "0.6565176", "0.64727366", "0.64727366", "0.6346288", "0.63428015", "0.63428015", "0.6312178", "0.616763", "0.616763", "0.616763", "0.616763", "0.616763", "0.616763", "0.616763", "0.616763", "0.616763", "0.616763", "0.6167...
0.0
-1
Returns all complete UTF8 characters in a Buffer. If the Buffer ended on a partial character, the character's bytes are buffered until the required number of bytes are available.
function utf8Text(buf, i) { var total = utf8CheckIncomplete(this, buf, i); if (!this.lastNeed) return buf.toString('utf8', i); this.lastTotal = total; var end = buf.length - (total - this.lastNeed); buf.copy(this.lastChar, 0, end); return buf.toString('utf8', i, end); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[]
[]
0.0
-1
For UTF8, a replacement character is added when ending on a partial character.
function utf8End(buf) { var r = buf && buf.length ? this.write(buf) : ''; if (this.lastNeed) return r + '\ufffd'; return r; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utf8Text(buf,i){var total=utf8CheckIncomplete(this,buf,i);if(!this.lastNeed)return buf.toString('utf8',i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);buf.copy(this.lastChar,0,end);return buf.toString('utf8',i,end);}// For UTF-8, a replacement character is added when ending on a partial",...
[ "0.6675062", "0.6675062", "0.6231528", "0.6222556", "0.6221065", "0.6221065", "0.5836165", "0.58046544", "0.58046544", "0.5802127", "0.5802127", "0.5802127", "0.5802127", "0.5802127", "0.5802127", "0.5802127", "0.56987494", "0.5690213", "0.5690213", "0.5660663", "0.5636449", ...
0.0
-1
UTF16LE typically needs two bytes per character, but even if we have an even number of bytes available, we need to check if we end on a leading/high surrogate. In that case, we need to wait for the next two bytes in order to decode the last character properly.
function utf16Text(buf, i) { if ((buf.length - i) % 2 === 0) { var r = buf.toString('utf16le', i); if (r) { var c = r.charCodeAt(r.length - 1); if (c >= 0xD800 && c <= 0xDBFF) { this.lastNeed = 2; this.lastTotal = 4; this.lastChar[0] = buf[buf.length - 2]; this.lastChar[1] = buf[buf.length - 1]; return r.slice(0, -1); } } return r; } this.lastNeed = 1; this.lastTotal = 2; this.lastChar[0] = buf[buf.length - 1]; return buf.toString('utf16le', i, buf.length - 1); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isUTF16 (data) {\n var i = 0\n var len = data && data.length\n var pos = null\n var b1, b2, next, prev\n\n if (len < 2) {\n if (data[0] > 0xFF) {\n return false\n }\n } else {\n b1 = data[0]\n b2 = data[1]\n if (b1 === 0xFF && // BOM (little-endian)\n ...
[ "0.6966989", "0.6922426", "0.6922426", "0.6817468", "0.6748273", "0.6748273", "0.6737087", "0.6737087", "0.6727744", "0.66424835" ]
0.0
-1
For UTF16LE we do not explicitly append special replacement characters if we end on a partial character, we simply let v8 handle that.
function utf16End(buf) { var r = buf && buf.length ? this.write(buf) : ''; if (this.lastNeed) { var end = this.lastTotal - this.lastNeed; return r + this.lastChar.toString('utf16le', 0, end); } return r; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function $lrG1$var$utf16Text(buf, i) {\n if ((buf.length - i) % 2 === 0) {\n var r = buf.toString('utf16le', i);\n\n if (r) {\n var c = r.charCodeAt(r.length - 1);\n\n if (c >= 0xD800 && c <= 0xDBFF) {\n this.lastNeed = 2;\n this.lastTotal = 4;\n this.lastChar[0] = buf[buf.len...
[ "0.61741793", "0.61722815", "0.6166875", "0.6157539", "0.6157539", "0.60805225", "0.6043108", "0.5879082", "0.5879082", "0.5811586", "0.5811586", "0.5811586", "0.5811586", "0.5811586", "0.5811586", "0.5811586", "0.57904005", "0.57904005", "0.5742406", "0.57081676", "0.5700781...
0.0
-1
Pass bytes on through for singlebyte encodings (e.g. ascii, latin1, hex)
function simpleWrite(buf) { return buf.toString(this.encoding); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utf8CheckExtraBytes(self,buf,p){if((buf[0]&0xC0)!==0x80){self.lastNeed=0;return\"\\uFFFD\";}if(self.lastNeed>1&&buf.length>1){if((buf[1]&0xC0)!==0x80){self.lastNeed=1;return\"\\uFFFD\";}if(self.lastNeed>2&&buf.length>2){if((buf[2]&0xC0)!==0x80){self.lastNeed=2;return\"\\uFFFD\";}}}}// Attempts to complete...
[ "0.6349106", "0.6320545", "0.6203621", "0.6178444", "0.6119716", "0.60451204", "0.595599", "0.5950051", "0.59132457", "0.59132457", "0.59132457", "0.5899401", "0.5895261", "0.58929884", "0.5869207", "0.5869207", "0.5869207", "0.5869207", "0.5787332", "0.5768909", "0.57253253"...
0.0
-1
alternative to using Object.keys for old browsers
function copyProps (src, dst) { for (var key in src) { dst[key] = src[key] } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getKeys(obj) {\n return Object.keys(obj); // Yes it is builtin!\n }", "function Object_keys(obj) {\n\t if (Object.keys) return Object.keys(obj)\n\t else {\n\t var res = [];\n\t for (var key in obj) res.push(key);\n\t return res;\n\t }\n\t}", "function keys(obj){\n return Object....
[ "0.7382736", "0.7311627", "0.723966", "0.7199875", "0.7199875", "0.7199875", "0.7199875", "0.7199875", "0.7199875", "0.7199875", "0.7199875", "0.7199875", "0.7109948", "0.69957906", "0.69584274", "0.6930815", "0.6926222", "0.6915537", "0.6879077", "0.68776375", "0.686874", ...
0.0
-1
prototype class for hash functions
function Hash (blockSize, finalSize) { this._block = Buffer.alloc(blockSize) this._finalSize = finalSize this._blockSize = blockSize this._len = 0 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Hash() {}", "function Hash() {}", "function Hash() {\r\n}", "function Hashers() {\n}", "GetHashCode() {\n\n }", "_generateHash() {\n\n }", "hash() {\n return this.is()\n }", "function Hasher()\n{\n this.truckHash = {};\n}", "calculateHash(){\n return SHA256(this.index + this.pr...
[ "0.8444925", "0.8444925", "0.8012337", "0.7593274", "0.7441991", "0.7378374", "0.73555523", "0.7269683", "0.71957415", "0.718947", "0.7186965", "0.71654564", "0.7144473", "0.71247315", "0.70964617", "0.7088249", "0.70709276", "0.7060434", "0.70601094", "0.7054379", "0.702781"...
0.0
-1
oldstyle streams. Note that the pipe method (the only relevant part of this class) is overridden in the Readable class.
function Stream() { EE.call(this); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function pipe(stream) {\n var cache, scope = this;\n if(stream) {\n // add to the pipeline\n this.fuse(stream);\n // ensure return values are also added to the pipeline\n cache = stream.pipe;\n stream.pipe = function(/* dest */) {\n // restore cached method when called\n this.pipe = cach...
[ "0.73901516", "0.7193427", "0.6899974", "0.6535375", "0.6493014", "0.6414353", "0.6313415", "0.62904894", "0.62847817", "0.62847817", "0.6234615", "0.621473", "0.61951", "0.61840194", "0.61840194", "0.6139886", "0.6127902", "0.6105061", "0.6105061", "0.6087349", "0.6048191", ...
0.0
-1
don't leave dangling pipes when there are errors.
function onerror(er) { cleanup(); if (EE.listenerCount(this, 'error') === 0) { throw er; // Unhandled stream error in pipe. } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function brokenPipe() {\n throw Error('artoo.asyncStore: broken pipe.');\n }", "function onerror(error) {\n cleanup();\n if (!hasListeners(this, 'error'))\n throw error; // Unhandled stream error in pipe.\n }", "function onerror(er){debug(\"onerror\",er);unpipe();dest.removeListener(\"e...
[ "0.69866925", "0.6516497", "0.6399389", "0.6383316", "0.63701004", "0.63701004", "0.63701004", "0.63701004", "0.63701004", "0.6333437", "0.6292604", "0.6285128", "0.6285128", "0.6274714", "0.6233449", "0.62333864", "0.6221305", "0.62146306", "0.62146306", "0.62146306", "0.621...
0.0
-1
remove all the event listeners that were added.
function cleanup() { source.removeListener('data', ondata); dest.removeListener('drain', ondrain); source.removeListener('end', onend); source.removeListener('close', onclose); source.removeListener('error', onerror); dest.removeListener('error', onerror); source.removeListener('end', cleanup); source.removeListener('close', cleanup); dest.removeListener('close', cleanup); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeListeners() {}", "removeListeners() {}", "removeListeners() {}", "function removeEventListeners(){\n _.forEach(unlistenCallbacks, function(unlisten){\n unlisten();\n });\n unlistenCallbacks = [];\n }", "_clearListeners() {\n for (let liste...
[ "0.8521039", "0.8521039", "0.8521039", "0.8423259", "0.8304111", "0.8296624", "0.8282094", "0.8274838", "0.82720345", "0.8261525", "0.81342524", "0.8060971", "0.8031993", "0.7983937", "0.7970812", "0.7962308", "0.7867754", "0.78554255", "0.7834158", "0.77878404", "0.77458024"...
0.0
-1
SEND TO PET PAGE
function petClicked(id) { window.location.href = ("./pet.html?" + id); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sendMessage(target, page, title) {\n if ('twitter' === target) {\n document.location.href = `https://twitter.com/intent/tweet?original_referer=${encodeURI(page)}&text=${encodeURI(title) + ' @DevMindFr'}&tw_p=tweetbutton&url=${encodeURI(page)}`;\n }\n else if ('linkedin' === target) {\n ...
[ "0.6328842", "0.56546193", "0.56312555", "0.56266934", "0.5624233", "0.5621727", "0.55679184", "0.5554036", "0.5550344", "0.5519918", "0.551401", "0.5503541", "0.5482589", "0.54467314", "0.54070854", "0.53956085", "0.53907186", "0.53865516", "0.538576", "0.5374538", "0.536772...
0.55455595
9
EVENTS > READ GET DATA
function getPets() { $("#user-pets").empty(); const user = JSON.parse(sessionStorage.user); db.collection("pets").where("user", "==", user.uid).get().then(snapshot => { if (snapshot.size > 0) { snapshot.forEach(snap => { displayPetCard(snap.data(), snap.id, user); }) } else { $("#user-pets").append(`No Pets Yet!`); } $("#preload").fadeOut(() => { $("#user-pets").fadeIn(); }) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function get_data() {}", "GetData() {}", "getData(){}", "function getData (event) {\n var msg = JSON.parse(event.data);\n //console.log(msg);\n // We can select specific JSON groups by using msg.name, where JSON contains \"name\":x\n // Every type MUST have msg.type to determine w...
[ "0.74353325", "0.71248376", "0.68410105", "0.6817295", "0.66842294", "0.6579573", "0.65628755", "0.6562308", "0.6497682", "0.6447957", "0.64449716", "0.64377874", "0.640069", "0.6390636", "0.6384874", "0.6331476", "0.63095504", "0.63089216", "0.63018715", "0.62390536", "0.623...
0.0
-1
> UPDATE OPEN EDIT FORM
function editPet(id) { db.collection("pets").doc(id).get().then(snapshot => { var pet = Object.assign(snapshot.data()); $($("#edit-pet input")[1])[0].value = pet.name; $($("#edit-pet input")[2])[0].value = pet.dob; $($("#edit-pet input")[3])[0].value = pet.sex; $($("#edit-pet input")[4])[0].value = pet.breed; $($("#edit-pet input")[5])[0].value = pet.weight; $("#edit-pet-popup").fadeIn(); }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _edit() {\n $('name').value = this.name;\n $('key').value = this.key;\n $('action').value = this.action;\n switchToView('edit-form');\n}", "function update_entity_edit() {\n var form_record = Domain.entities[current_entity];\n Forms.init(form_record);\n update_edit_form_display();\n...
[ "0.74080265", "0.72648585", "0.70942825", "0.69304895", "0.69304895", "0.69304895", "0.69304895", "0.69304895", "0.69304895", "0.69304895", "0.6856121", "0.6850608", "0.6840631", "0.6821734", "0.67755777", "0.67753345", "0.67721134", "0.67584884", "0.6749332", "0.6749332", "0...
0.0
-1
> DELETE DELETE MODAL
function deletePet(id) { db.collection("pets").doc(id).get().then(snapshot => { console.log(snapshot.data()); $("#modal-title").html(`Are you sure you want to delete ${snapshot.data().name}?`) $("#confirm-delete").attr("pet", id); var modal = M.Modal.getInstance($("#delete-confirm")); modal.open(); }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_onDeleteClicked() {\n $('<p>')\n .text(_`\n This integration will be permanently removed. This cannot\n be undone.\n `)\n .modalBox({\n buttons: [\n $('<button>')\n .text(_`Cancel`),\n ...
[ "0.7504706", "0.7326092", "0.72281253", "0.7162987", "0.7152994", "0.7130971", "0.709373", "0.70449054", "0.7017481", "0.69576705", "0.69495285", "0.6947013", "0.69406027", "0.6852701", "0.6852077", "0.6836309", "0.68220943", "0.6813955", "0.68135947", "0.68075883", "0.679482...
0.0
-1
Create new state handler for the HTTP call where we work the information received
function stateHandlerListCategories() { if ( xmlHttpObj.readyState == 4 && xmlHttpObj.status == 200) { var categoriesList = new Array(); var docxml = xmlHttpObj.responseXML; var nodelist = docxml.getElementsByTagName("categoria"); for (var i = 0; i < nodelist.length; i++) { var value = nodelist[i].textContent; if (!checkIfExists(categoriesList, value)) { categoriesList.push(value); }; }; document.getElementById("scategories").innerHTML += CreateSelectHTML(categoriesList); ListBooksByCategory(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _getStateHandler(data) {\n print2Console(\"RESPONSE\", data.xml);\n}", "_createState(route, options){\n\n\t}", "function requestState( state ){\n \n console.log(\"REQUESTING STATE \" + state)\n \n var targetURL;\n var targetApplicationState;\n var params;\n var email, password,...
[ "0.61279833", "0.61116534", "0.6052916", "0.60059285", "0.57766646", "0.5752508", "0.57008064", "0.56996626", "0.56518334", "0.56311244", "0.56155086", "0.56155086", "0.56155086", "0.56155086", "0.56155086", "0.56155086", "0.56155086", "0.56155086", "0.56155086", "0.56155086", ...
0.0
-1
Create new HTTP Call to the service indicated by the argument
function MakeXMLHTTPCallListCategories(method, url) { xmlHttpObj = CreateXmlHttpRequestObject(); if (xmlHttpObj) { xmlHttpObj.open(method, url, true); xmlHttpObj.onreadystatechange = stateHandlerListCategories; xmlHttpObj.send(null); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function makeRequest(serviceMethod, data, params) {\n return $http({\n method: serviceMethod.httpMethod || 'GET',\n url: getServiceUrl(serviceMethod),\n data: data || {},\n params: params || {}\n });\n }", "function service(arg) {\n if (_typeof(arg) === 'object') {\n ...
[ "0.6263031", "0.60855097", "0.60048175", "0.58879775", "0.58879775", "0.58879775", "0.58879775", "0.587793", "0.5874425", "0.5817452", "0.5817452", "0.57695204", "0.5751338", "0.57485104", "0.5733879", "0.5733879", "0.5674206", "0.5666082", "0.5647524", "0.5626366", "0.562146...
0.0
-1
The main function for the list categories
function ListCategories () { MakeXMLHTTPCallListCategories("GET", "http://uvm061.dei.isep.ipp.pt/ARQSI/Widget/WidgetAPI/EditorAPI.php?type=GetAllCategories"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function displayCategory() {\n displayHeading();\n displayList();\n}", "function categories() {\n // assign categories object to a variable\n var categories = memory.categories;\n // loop through categories\n for (category in categories) {\n // cal...
[ "0.7223296", "0.68076", "0.6800256", "0.6795968", "0.6709581", "0.67035073", "0.6653035", "0.65990835", "0.6595726", "0.6589761", "0.65270054", "0.65250266", "0.65180606", "0.6500613", "0.64992934", "0.64796495", "0.6475869", "0.6469602", "0.64653", "0.6465141", "0.6444369", ...
0.7217855
1
Riffle Shuffle / 1. Split the deck approximately in half 2. One half in the left hand, the other half in the right hand 3. Riffle the edges of both sets so they intermingle 4. Push the cards together 5. Repeat the process for 6 times or more
function shuffle(deck) { const cutDeckVariant = deck.length / 2 + Math.floor(Math.random() * 9) - 4; const leftHalf = deck.splice(0, cutDeckVariant); let leftCount = leftHalf.length; let rightCount = deck.length - Math.floor(Math.random() * 4); while(leftCount > 0) { const takeAmount = Math.floor(Math.random() * 4); deck.splice(rightCount, 0, ...leftHalf.splice(leftCount, takeAmount)); leftCount -= takeAmount; rightCount = rightCount - Math.floor(Math.random() * 4) + takeAmount; } deck.splice(rightCount, 0, ...leftHalf); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "realShuffle() {\n const shuffled = [];\n\n const {half1, half2} = this.halveDeck();\n\n let onHalf1 = true;\n let counter = 0;\n \n while (half1.length > 0 || half2.length > 0) {\n\n if (onHalf1) {\n\n if (!half1.length) {\n onHalf1 = !onHalf1;\n counter = 0;\n ...
[ "0.74809545", "0.70599777", "0.6877629", "0.684717", "0.6742009", "0.6713707", "0.66870886", "0.6663174", "0.6644023", "0.66213506", "0.6618641", "0.6616935", "0.66044", "0.66033953", "0.65810484", "0.65407485", "0.65294045", "0.65284795", "0.65015084", "0.64942527", "0.64921...
0.7190228
1
rgb2hex(rgb) function is borrowed from
function rgb2hex(rgb){ rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); return "#" + ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) + ("0" + parseInt(rgb[3],10).toString(16)).slice(-2); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function rgb2hex(rgb){\n rgb = rgb.match(/^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$/);\n return rgb ? \"#\" +\n (\"0\" + parseInt(rgb[1],10).toString(16)).slice(-2) +\n (\"0\" + parseInt(rgb[2],10).toString(16)).slice(-2) +\n (\"0\" + parseInt(rgb[3],10).toString(16)).slice...
[ "0.88249797", "0.87684107", "0.8758326", "0.8742307", "0.86851597", "0.8684691", "0.8677611", "0.86772746", "0.8667237", "0.86553633", "0.8653287", "0.8653161", "0.86491597", "0.8642759", "0.8642759", "0.8640203", "0.86384666", "0.86151296", "0.86090267", "0.86090267", "0.860...
0.8878183
0
e is the standard DOM event object
handleChange(e) { // e.currentTarget: DOM element we attached the event handler to // use the value property to read its current value this.setState({ input: e.currentTarget.value }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function xl_GetEvent(e) \n{\n\t// e gives access to the event in all browsers\n\tif (!e) var e = window.event; \n\t\n\treturn e; \n}", "function Utilities_GetEvent(e)\r\n{\r\n return e || window.event;\r\n}", "function xl_GetEventTarg(e) \n{\n\tvar EventObj; \n\tvar e = xl_GetEvent(e); \n\t\n\tif (e.target) ...
[ "0.71195644", "0.70377535", "0.6960898", "0.6918632", "0.69156265", "0.6858194", "0.6858194", "0.6858194", "0.6858194", "0.6858194", "0.6820185", "0.6717468", "0.6697286", "0.66541004", "0.6647255", "0.66437334", "0.6634303", "0.661451", "0.6608323", "0.6603127", "0.65511066"...
0.0
-1
has finished loading in the browser.
function showTheChat(chat, sec) { setTimeout(function () { chat.style.display = "block"; }, sec); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadDone() {\n return true;\n }", "function loadComplete() {\n\thasLoaded = true;\n}", "function pageFullyLoaded () {}", "function finishedLoad() {\n console.log('finishedLoad()');\n if (externalIsLoaded()) {\n init();\n }\n }", "function onLoadComplete()\n {\n this.lo...
[ "0.75903344", "0.73198736", "0.7153369", "0.70527005", "0.6929781", "0.6825354", "0.6823386", "0.66756654", "0.6654849", "0.66131467", "0.66131467", "0.66110796", "0.66009635", "0.65965", "0.65844256", "0.65844256", "0.65844256", "0.65844256", "0.6570404", "0.6567171", "0.655...
0.0
-1
play 5 round game
function game(win){ for (let i = 0; i < 5; i++){ let win = playRound(); switch (win){ case 1: playerScore++; break; case 2: computerScore++; break; case 3: draws++; break; } //alert(`win ${win} playerScore ${playerScore} computerscore ${computerScore} round ${i}`) } //add disable play button and reset button if(computerScore > playerScore){ alert(`Oh no! you lost ${computerScore} to ${playerScore}. ${draws} draws.`); }else if (playerScore > computerScore){ alert(`Well done! you won ${playerScore} to ${computerScore}. ${draws} draws.`); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function game(){\n\twhile(rounds<5){\n\t\tconst playerSelection = playerPLay();\n\t\tconst computerSelection = computerPlay();\n\t\tconsole.log(playRound(playerSelection, computerSelection));\n\t\tconsole.log(\"Scoreboard: Won: \" + won + \" Lost: \" + lost + \" Drawn: \" + drawn );\n\t\trounds++;\n\t}\n\n}", "f...
[ "0.76948947", "0.74845207", "0.7479477", "0.7396535", "0.7344169", "0.72763824", "0.72435963", "0.72267437", "0.71683156", "0.7131276", "0.7111724", "0.7070816", "0.7066701", "0.70108277", "0.69837713", "0.69166803", "0.6896058", "0.68894935", "0.68469155", "0.6834712", "0.68...
0.7215968
8
compare user and computer choice
function playRound(playerSelection, computerSelection) { playerSelection = userChoice; computerSelection = computerChoice; let playerWin; switch (playerSelection){ case computerSelection: playerWin = 3; break; case "rock": if (computerSelection == "scissors"){ playerWin = 1; } else if (computerSelection == "paper"){ playerWin = 2; } break; case "paper": if (computerSelection == "rock"){ playerWin = 1; } else if (computerSelection == "scissors"){ playerWin = 2; } break; case "scissors": if (computerSelection == "paper"){ playerWin = 1; }else if (computerSelection == "rock"){ playerWin =2; } break; } switch(playerWin){ case 1: round.textContent = `You win! ${playerSelection} beats ${computerSelection}.`; return playerWin; break; case 2: round.textContent = `You loose! ${computerSelection} beats ${playerSelection}`; return playerWin; break; case 3: round.textContent = `WOW! ${playerSelection} vs ${computerSelection} it's a draw!`; return playerWin; break; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compareChoices(userSelection, computerSelection) {\n clearPreviousAlerts();\n\n if (rounds < 5) {\n rounds++;\n }\n\n if (userSelection === computerSelection) {\n $(\".tie\").show();\n ties++;\n } else if (\n (userSelection === \"rock\" && computerSelection === \"scissors\") ||\n (user...
[ "0.71171516", "0.7086824", "0.70657337", "0.7054372", "0.70536125", "0.7049375", "0.69436496", "0.6903555", "0.68633497", "0.68328804", "0.6802112", "0.6779254", "0.6752433", "0.67331934", "0.6727019", "0.66917986", "0.66803426", "0.6679248", "0.6663939", "0.66405463", "0.661...
0.0
-1
create a new post
createPost(id, timestamp, title, body, author, category) { console.log('onCreate', id, timestamp, title, body, author, category); Api.addPost(id, timestamp, title, body, author, category).then((post) => { // console.log('res ',post); this.props.addPost(post); }).catch((err) => { console.log('error when persisting post: ', err); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createPost() {\n}", "newPost(post) {\n\n }", "function addPost(post) {\n return PostsModel.create(post);\n}", "function createPost(req, res) {\n var post = new Post();\n post._id = new ObjectID();\n post.title = req.body.title;\n post.type = req.body.type;\n post.price = req.body....
[ "0.8242593", "0.81065476", "0.7654327", "0.7518669", "0.7511522", "0.750402", "0.7430222", "0.74262244", "0.7422644", "0.74204165", "0.74079263", "0.73831743", "0.733665", "0.7317212", "0.72421", "0.7223112", "0.71948236", "0.7175566", "0.71679384", "0.7164915", "0.71567065",...
0.7502742
6
function to add field to list of filled fields
function addFields(p, ...fields) { if (!p.state.fields) { p.state.fields = [...fields] } else { fields.filter(f => !p.state.fields.includes(f)).forEach(f => p.state.fields.push(f)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addMoreFields(field) {\n var name = \"product[\"+field+\"][]\";\n if(field == 'images')\n name += '[img_path]'\n $(\"<input type='text' value='' />\")\n .attr(\"name\", name)\n .appendTo(\"#\"+field);\n}", "function addFields(){\n var fields=[\"id\",\"query2\", \"sameAs\"];\n \n var...
[ "0.68326205", "0.6637296", "0.660361", "0.6435505", "0.63701487", "0.635481", "0.63482696", "0.634238", "0.6329716", "0.63063127", "0.6267341", "0.6254801", "0.624701", "0.6224502", "0.61904466", "0.6168713", "0.610564", "0.6087245", "0.6081404", "0.60556734", "0.6052261", ...
0.6815565
1
function to remove a flag from fields list when flag is unchecked
function removeFields(p, ...fields) { if (!p.state.fields) { return } else { fields.forEach(f => { let index = p.state.fields.indexOf(f); if (index > -1) { p.state.fields.splice(index, 1); } }); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkUncheck(e) {\n const itemId = e.target.id;\n\n if (list[itemId].done == false) {\n list[itemId].done = true;\n } else {\n list[itemId].done = false;\n }\n\n updateLocalStore();\n loadList();\n}", "function checkUncheckAllForMultipleDetail(isCheck, formName, fieldName, statusFlag)\r\n{\r...
[ "0.6414068", "0.6375232", "0.63284516", "0.621044", "0.61230785", "0.6114955", "0.6102945", "0.605799", "0.6054969", "0.60499823", "0.60499316", "0.603829", "0.6023395", "0.6020382", "0.5998657", "0.5984719", "0.59431964", "0.59430814", "0.59330964", "0.59300745", "0.5914972"...
0.56597686
56
TODO: add a generic bind() function
function mapNextUniqId2() { window.setTimeout(mapNextUniqId3, CLICK_LOAD_DELAY); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function simpleBind(context,fn){return function(value){fn.call(context,value);};}", "Bind(IDispatch, string, string) {\n\n }", "function bind(fn,ctx){function boundFn(a){var l=arguments.length;return l?l>1?fn.apply(ctx,arguments):fn.call(ctx,a):fn.call(ctx);}// record original fn length\nboundFn._length=fn....
[ "0.7354985", "0.7333845", "0.7269693", "0.7269693", "0.71582544", "0.70968765", "0.7057731", "0.69922155", "0.69922155", "0.69861144", "0.69621927", "0.69515264", "0.6932434", "0.6932434", "0.6926049", "0.6926049", "0.6926049", "0.6926049", "0.6926049", "0.6926049", "0.692604...
0.0
-1
Display the footer of the popup
_displayDialogFooter () { const { newTask, closeModal } = this.props; return ( <div className="modal-footer"> { newTask ? <button className="add-button button" type="submit" onClick={this._addTask}> {buttonsLabels.add_task_button_label} </button> : <div className="left-buttons-container"> <button className="save-button button" type="submit" onClick={this._editTask}> <img className="icon" src={assets.saveIcon} alt="" /> <div>{buttonsLabels.save_task_button}</div> </button> <button className="delete-button button" type="submit" onClick={this._deleteTask}> <img className="icon" src={assets.deleteIcon} alt="" /> <div>{buttonsLabels.delete_task_button}</div> </button> </div> } <button className="cancel-button button" onClick={closeModal}> {buttonsLabels.cancel_button} </button> </div> ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "displayFooter() {\n }", "function footer_func(){\n showfooter();\n hideicon();\n }", "function ShowTextPopup(PopUpHeader, PopUpContent, PopUpFooter)\n{\n $('.popup-wrap2').fadeIn(250);\n\t $('.popup-box2').removeClass('transform-out').addClass('transform-in');\n\t\t$(\"#PU_header\").html(PopUpHea...
[ "0.7370727", "0.7013707", "0.6801526", "0.6656114", "0.6596412", "0.64637136", "0.642996", "0.64059454", "0.6367824", "0.6305404", "0.62922007", "0.628223", "0.627824", "0.6247534", "0.62313604", "0.62237394", "0.62147695", "0.6195005", "0.6182845", "0.61451113", "0.61159647"...
0.5598283
81
Slide 16 set up the inputs
function setupWebInput() { let choices = document.getElementsByClassName("choice"); let cat = document.getElementById("cat"); let elephant = document.getElementById("elephant"); cat.addEventListener("click", userPick); elephant.addEventListener("click", userPick); for (let i = 0; i < choices.length; i++) { choices[i].addEventListener("click", userPick); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function slider_setup(s_name, sample, index) {\n var s = document.getElementById(s_name);\n var s_out = document.getElementById(s_name+\"_out\");\n var s_out2 = document.getElementById(\"ex4_\"+s_name);\n var s_out3 = document.getElementById(\"ex5_\"+s_name);\n s.value = sample[index];\n s_out.innerHTM...
[ "0.6371694", "0.61439204", "0.61213946", "0.5952436", "0.5918183", "0.59051746", "0.58922833", "0.58647317", "0.5845431", "0.5816585", "0.5813328", "0.57881147", "0.57851344", "0.5772182", "0.5751158", "0.5744353", "0.57023895", "0.5624105", "0.56165457", "0.5615085", "0.5611...
0.0
-1
Slide 17 get the user choice which starts the game
function userPick(evt) { userChoice = this.id; console.log(userChoice); playGame(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function chooseStimulus1() {makeChoice(selection=1)}", "function playerChoice(id){\n var choixJ = id.alt;\n console.log(choixJ);\n gameStart(choixJ);\n}", "static choosingOpponent(){\n //console.info(\"step5\")\n KB.listen([\n {key: Const.KEYBOARD_INT, callback: Lands.choiceQttOst}, // 0-9\...
[ "0.73294675", "0.7116935", "0.7113943", "0.69982475", "0.6838551", "0.6829047", "0.68167996", "0.676782", "0.67609525", "0.6749641", "0.6683467", "0.66652244", "0.66200227", "0.66179466", "0.6592817", "0.6576619", "0.6559508", "0.6554784", "0.65242827", "0.6519005", "0.651343...
0.66059613
14
Slide 18 set up the game logic (play the game) and call the output
function playGame() { let answers = ["rock", "paper", "scissors", "cat"]; computerChoice = answers[Math.floor(Math.random() * 4)]; console.log(computerChoice); catState = 2; let result = ""; if (userChoice === computerChoice) { result = "it's a draw!" } else if ((userChoice === "cat") || (computerChoice === "cat")) { catState = Math.floor(Math.random() * 2); console.log(catState); if (userChoice === "cat") { if (catState === 0) { result = "The user picked angry cat! The computer wins!"; } else { result = "The user picked happy cat! The user wins!"; } } else { if (catState === 0) { result = "The computer picked angry cat! The user wins!"; } else { result = "The computer picked happy cat! The computer wins!"; } } } else if (userChoice === "rock") { if (computerChoice === "scissors") { result = "you win, as rock blunts scissors!"; } else { result = "the computer wins, as paper wraps rock!"; } } else if (userChoice === "paper") { if (computerChoice === "rock") { result = "you win, as paper wraps rock!!"; } else { result = "the computer wins, as scissors cuts paper!"; } } else if (userChoice === "scissors") { if (computerChoice === "paper") { result = "you win, as scissors cuts paper!!"; } else { result = "the computer wins, as rock blunts scissors!!"; } } if (result === "") { gameAnswer = `User picked ${userChoice}, this is not a valid choice, please try again`; } else { gameAnswer = `User picked ${userChoice} , computer picked ${computerChoice} - ${result}`; } userOutput() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function runGame() {\n\t// DISPLAY WELCOME BANNER\n\n\t// STORE INITIAL GAME STATE\n\n\t// WHILE LOOP FOR WHEN GAME IS NOT WON\n}", "function startGame() {\n pairMovieWithSounds();\n randomSounds(movie);\n addPhraseToDisplay();\n keyboardSetup();\n}", "function main() {\n /* Get our time delta infor...
[ "0.71748173", "0.7144816", "0.71168536", "0.6997403", "0.69901925", "0.6947193", "0.69374776", "0.690446", "0.6831793", "0.68270123", "0.6822336", "0.6808198", "0.6791547", "0.67903215", "0.6789373", "0.678158", "0.67661035", "0.6764731", "0.6733878", "0.67266214", "0.6725693...
0.0
-1
Slide 19 display the output
function userOutput() { if ((userChoice === "cat") || (computerChoice ==="cat")) { let myAudio = document.getElementById("myAudio"); let myCatAudio = ""; if (catState === 1) { myCatAudio = "Catmeow1.mp3"; } else if (catState === 0) { myCatAudio = "AngryCat.mp3"; } myAudio.src = myCatAudio; myAudio.addEventListener("canplaythrough", function(){myAudio.play()}); } let winner = document.getElementById("winner"); winner.innerHTML = gameAnswer; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _display(){\n\t\t\t$(levelID).html(level);\n\t\t\t$(pointsID).html(points);\n\t\t\t$(linesID).html(lines);\n\t\t}", "function displayToScreen() {\n\n\n\t}", "presentation() {\n\t\tconsole.log('Le personnage s\\'appelle : ' + this.NAME);\n\t\tconsole.log('current ID : ' + this.ID);\n\t\tconsole.log('IM...
[ "0.67133266", "0.64770174", "0.64627844", "0.6449356", "0.6381097", "0.6281531", "0.62607354", "0.62514466", "0.6238299", "0.6218007", "0.6206229", "0.62033105", "0.6201278", "0.61248195", "0.6111249", "0.6080556", "0.60734487", "0.6047463", "0.6038747", "0.6027305", "0.60103...
0.0
-1
Init all internal data
constructor() { this.m_xDim = 0; this.m_yDim = 0; this.m_zDim = 0; this.m_stack3d = null; this.m_maxStack3d = 0; this.m_indexStack3d = 0; this.m_numFilled3d = 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function init () {\n // Here below all inits you need\n }", "function init() {\n\t\t\tresetData();\n\t\t\trefreshTotalCount();\n\t\t\tloadVocabs();\n\t\t}", "function _init() {\n addEvent();\n getData();\n }", "function initData() {\n initLtr_factor();\n initBosunit();\n initHero(...
[ "0.7984853", "0.79424834", "0.7931414", "0.7891047", "0.7678833", "0.7564601", "0.7564407", "0.7525892", "0.7474785", "0.74739414", "0.74430525", "0.7439018", "0.743616", "0.743616", "0.7432752", "0.74179894", "0.73684114", "0.7327663", "0.7298696", "0.72204995", "0.7219873",...
0.0
-1
Apply the rawignoreregex option. Return the modified html, and a function that recovers line/column numbers of issues.
function rawIgnoreRegex(html, options) { const ignore = options["raw-ignore-regex"]; if (!ignore) { return html; } return html.replace((new RegExp(ignore, "gm")), function(match) { return match.replace(/[^\n\t\n\r]/g, "¤"); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function stripHtml(...args) {\n // let extractedInputs = new Set(\n // JSON.parse(\n // fs.readFileSync(path.resolve(\"./test/util/extractedInputs.json\"), \"utf8\")\n // )\n // );\n // if (typeof args[0] === \"string\" && args[0].trim().length > 3) {\n // extractedInputs.add(args[0]);\n // fs....
[ "0.53842604", "0.53379184", "0.5234418", "0.5148536", "0.5039616", "0.50360775", "0.50360775", "0.50063103", "0.49855205", "0.4949308", "0.4939795", "0.49372882", "0.4928766", "0.49035624", "0.48491928", "0.4833677", "0.4816147", "0.48147166", "0.47953978", "0.47653732", "0.4...
0.56612295
1
REMOVE: after v1, rules will only receive TreeNodes
lintByLine(rule, lines) { return lines.map((line) => { // this.inlineConfig.getOptsAtIndex(line.index); return this.callRuleLint(rule, line);//, this.inlineConfigs.current); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "anchoredNodeRemoved(node) {}", "remove(value) {\n this.root = this.removeVisitor(this.root, value)\n }", "remove(tree){\n let replaceWith;\n if(this.left && this.right){\n const next = this.right.getLeftmostChild();\n this.low = next.low;\n this.high = n...
[ "0.64386606", "0.6380425", "0.6355589", "0.6349218", "0.633667", "0.63078254", "0.62934875", "0.61842495", "0.6176571", "0.61399007", "0.6121926", "0.6109569", "0.6104579", "0.6093716", "0.6079177", "0.60260665", "0.6009594", "0.6005983", "0.6000191", "0.5944988", "0.5930063"...
0.0
-1
TODO: Remove after v1
callRuleLint(rule, raw) { const issues = []; function report(data) { const meta = { ...data.meta, severity: rule.severity }; issues.push(new Issue( data.code, data.position, rule.name, meta )); } rule.need ? rule.lint(raw, this.config.legacy_config, { report, rules: this.config.activatedRules }) : rule.lint(raw, rule.config, { report }); return issues; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private public function m246() {}", "private internal function m248() {}", "protected internal function m252() {}", "transient private protected internal function m182() {}", "transient private internal function m185() {}", "transient protected internal function m189() {}", "transient final protected i...
[ "0.68101764", "0.64340585", "0.62249184", "0.6182766", "0.6052821", "0.59527016", "0.58985794", "0.5737881", "0.5728914", "0.56370556", "0.56195796", "0.56094825", "0.55589503", "0.5524512", "0.5493151", "0.5487611", "0.54612476", "0.5453937", "0.53796333", "0.53680205", "0.5...
0.0
-1
convention method to wrap minimatch for the given file
function is(...patterns) { return patterns.some((pattern) => { if (minimatch(fileName, pattern)) { return true; } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "minifyFile(file) {\n // The hash meteor provides seems to change more than\n // necessary, so we create our own here based on only what \n // affects the minified output\n let key\n Profile.time('hash', () => {\n key = this._deepHash({\n content: file.getContentsAsString(),\n sour...
[ "0.5433874", "0.5396781", "0.53411776", "0.5238935", "0.5177372", "0.51580524", "0.51441073", "0.51297617", "0.5081722", "0.5060609", "0.5046817", "0.5010978", "0.50093603", "0.49734014", "0.4949765", "0.49160546", "0.48884895", "0.48371965", "0.48274007", "0.4809469", "0.480...
0.0
-1
Encontrar la length de una lista / length: list>number Hallar la length de una lista function length(list) length([1,2,3,4])>4 length([])>0 length([0])>1
function length(list) { if(isEmpty(list)) { return 0; } else { return 1 + length(rest(list)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function listLength(){\n return list.length;\n}", "function length() {\n array = ['1', '2', '3'];\n return array.length\n}", "function length(xs){\r\n return xs.length;\r\n}", "function length(xs) {\n for (var i = 0; !is_empty_list(xs); ++i) {\n\t\txs = tail(xs);\n }\n return i;\n}", "...
[ "0.7409954", "0.7272885", "0.7251318", "0.72197694", "0.70779467", "0.7034012", "0.70213664", "0.7015795", "0.70146585", "0.7003693", "0.69473493", "0.68112355", "0.67341673", "0.67307425", "0.6651546", "0.6612045", "0.6612045", "0.6524742", "0.64799005", "0.6473605", "0.6472...
0.79612714
0
sumAll:list>number Sumar todos los elementos de una lista function sumAll(list) sumAll([1,2,3])>6 sumAll([0,1])>1 sumAll([1,1])>0
function sumAll(list) { if(length(list) == 1) { return first(list); } else { return first(list) + sumAll(rest(list)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sumAll(list) {\n if(length(list) == 1) {\n return first(list);\n } else {\n return first(list) + sumAll(rest(list));\n }\n}", "function sumAll( ) {\n let sum = 0;\n // TODO: loop to add items\n return sum;\n}", "function sumList(l) {\n\tlet sum = 0;\n\tfor (let i = 0; i < l.l...
[ "0.82270014", "0.762839", "0.754866", "0.73812145", "0.7321067", "0.7315798", "0.7231009", "0.72046065", "0.7128877", "0.70032007", "0.6956851", "0.6940685", "0.6890668", "0.6880845", "0.6864643", "0.6859363", "0.6858683", "0.6851558", "0.6838799", "0.68218637", "0.68062884",...
0.82037854
1
multiplyAll:list>number Multiplica todos los elementos de una lista. S function multiplyAll(list) multiplyAll([1,2,3])>6 multiplyAll([0,1])>0 multiplyAll([1,1,5])>5
function multiplyAll(list) { if(length(list)==1) { return first(list); } else { return first(list) * multiplyAll(rest(list)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function multiplyAll() {\n var sum = 1;\n for (var i = 0; i < arguments.length; i++) {\n sum *= arguments[i];\n }\n return sum;\n\n}", "function multiplyNumbers(numberList){\n var multiplied = 1;\n for(i=0; i<numberList.length; i++){\n multiplied *= numberList[i]\n }\n retur...
[ "0.78231555", "0.782297", "0.7758679", "0.77257574", "0.75517976", "0.7534918", "0.7376909", "0.7374298", "0.735744", "0.72968316", "0.7295184", "0.7283051", "0.7277243", "0.72751945", "0.7255816", "0.72471815", "0.7235147", "0.70945925", "0.7078581", "0.70738494", "0.6991042...
0.85972476
0
invert:list>list Invierte los elementos de una lista invert([1,2,3])>[3,2,1] invert([3,2,1])>[1,2,3]
function invert(list) { if(length(list)==0) { return []; } else { return cons(last(list),invert(pop(list))); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function invert(list) {\n if(length(list)==0) {\n return [];\n } else {\n return cons(last(list),invert(pop(list)));\n }\n}", "function invertir(list) {\n if(longitud(list)==0){\n return [];\n } else {\n return cons(last(list),invertir(pop(list)));\n }\n}", "functi...
[ "0.81242526", "0.7971842", "0.79231286", "0.70068747", "0.6762789", "0.66901475", "0.6658883", "0.6598854", "0.658907", "0.6394313", "0.6331753", "0.62577516", "0.62554884", "0.6230901", "0.61796653", "0.6166118", "0.6166118", "0.6166118", "0.6166118", "0.6166118", "0.6166118...
0.8094879
1
removeAllX:list,number>list Remueve todos los elementos X que se encuentre en una lista removeAllX([1,2,3],2)> [1,3] removeAllX([0,2,9,7,1,0], 9) > [0,2,7,1,0] removeAllX([1,1,2,2],2) > [1,1]
function removeAllX(list,x) { if(isEmpty(list)) { return []; } else if(first(list)==x) { return removeAllX(rest(list),x); } else { return cons(first(list),removeAllX(rest(list),x)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeAll() {\n for (const id of this.compareList.keys()) {\n this._removeItem(id);\n }\n }", "function removeFromArray(arr,x){\n\tfor (i=0 ; i<arr.length;i++){\n\t\tif(arr[i] == x){\n\t\tarr.splice(i,1);\n\t\ti = i-1;\n\t\t} \n\t}\n\treturn arr;\n}", "removeAllTodos() {\n let i = 0;\n ...
[ "0.59380233", "0.5930293", "0.58921117", "0.58920383", "0.58703995", "0.58417416", "0.5831137", "0.5807421", "0.58052415", "0.5764462", "0.5756017", "0.5698798", "0.5691397", "0.566131", "0.5653099", "0.56518567", "0.5647349", "0.563539", "0.55682", "0.5566958", "0.5561746", ...
0.8037523
0
Concatene dos listas /append:list,list>list Concatena dos listas, en el orden en que cada una tiene sus elementos append([1,2,3],[4,5,6])>[1,2,3,4,5,6] append([2,1],[0,0])>[2,1,0,0] append([],[1,2,3])>[1,2,3] append([1,2],[])>[1,2]
function append(list1,list2) { if(isEmpty(list1)){ return list2; } else { return cons(first(list1),append(rest(list1),list2)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function concat(list1, list2)\n{\n// concatenate 2 arrays\n\n// build a 3rd array which is the result of the 2 lists ,\n// only add items to the list if the starget ource array is not empty\n var list3 = []; // initialize the array\n if (list1.length >0){ // only add from list1 if its not empty\n ...
[ "0.7027369", "0.69005924", "0.68246925", "0.6629465", "0.65794337", "0.6502546", "0.6332338", "0.6322995", "0.62115616", "0.6202517", "0.6138647", "0.6137989", "0.60667247", "0.6032472", "0.6028379", "0.60070515", "0.5988056", "0.59743285", "0.5958824", "0.5946305", "0.593730...
0.65812373
4
down:list>list Ordena una lista en orden descendente down([1,2,3])>[3,2,1] down([5,7,1,0,3,9])>[9,7,5,3,1,0]
function down(list) { if(length(list)==1) { return list; } else { return cons(maxList(list),down(removeX(list,maxList(list)))); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function invertir(list) {\n if(longitud(list)==0){\n return [];\n } else {\n return cons(last(list),invertir(pop(list)));\n }\n}", "function reverseList(list) {\n let buf = [];\n\n for (let n = list; n != null; n = n.next) {\n buf.push(n.data);\n }\n\n return revArrayToL...
[ "0.6139434", "0.5881532", "0.5802744", "0.57736415", "0.56161153", "0.5616019", "0.56142086", "0.5579915", "0.55656856", "0.5562994", "0.55487233", "0.55487233", "0.55487233", "0.55487233", "0.55487233", "0.55487233", "0.55487233", "0.55487233", "0.55487233", "0.55487233", "0...
0.74364036
0
static display components / event handlers
customSizeHandler(newState) { const state = { size: BoardSizes.CUSTOM, rows: newState.rows || this.state.rows, cols: newState.cols || this.state.cols, numMines: newState.numMines || this.state.numMines, }; this.props.changeSize(state); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "render() {\n this._addChooserHandler();\n this._addLoggerListeners();\n this._addButtonHandler();\n }", "static rendered () {}", "static rendered () {}", "function main() {\n init();\n render();\n handleVisibilityChange();\n}", "displayScene() {\n\n //Process all component...
[ "0.6961778", "0.6678392", "0.6678392", "0.6509121", "0.64703476", "0.6403252", "0.6342639", "0.6260272", "0.6232546", "0.6196294", "0.6187066", "0.61865664", "0.61660933", "0.6132773", "0.61145025", "0.6035958", "0.6030676", "0.6020146", "0.60148925", "0.59924364", "0.5982424...
0.0
-1
This is a recursive function that draws the prime factorization tree for the input number n.
function primeFactors(n, p, x, y, prev) { if (n <= 1) { graph.addNode(x, y, n.toString(), radius); } while (n > 1) { // base case if (n == p) { let leaf = graph.addNode(x, y, n.toString(), radius, radius); leaf.nodeEllipse.style.stroke = '#1bc075'; if (prev != null) { let edge = graph.addEdge(prev, leaf).style.stroke = '#333333'; } return; } // check if the current prime divides the current number. If so, draw the // and the prime factor nodes with an edge between them. Otherwise, call this // function again with the next prime number. if (n % p == 0) { // draw nodes and edges let node = graph.addNode(x, y, n.toString(), radius, radius); node.nodeEllipse.style.stroke = '#333333'; let leaf = graph.addNode(x - 64, y + 64, p.toString(), radius, radius); if (prev) { graph.addEdge(prev, node).style.stroke = '#333333'; } graph.addEdge(node, leaf).style.stroke = '#333333'; leaf.nodeEllipse.style.stroke = '#1bc075'; // update variables n = n / p; x += 64; y += 64; prev = node; } else { p = nextPrime(p); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function primeFactorization(n) {\n var factors = [],\n divisor = 2;\n\n while (n >= 2) {\n if (n % divisor == 0 ) {\n factors.push(divisor);\n n = n / divisor;\n }\n else {\n divisor++;\n }\n }\n return factors;\n}", "function primeF...
[ "0.6913972", "0.6880843", "0.6860621", "0.68521947", "0.6797213", "0.67726016", "0.6728849", "0.67203456", "0.6711669", "0.6686903", "0.6619655", "0.6617041", "0.6606457", "0.65930843", "0.6577986", "0.65776634", "0.6548178", "0.6532805", "0.65279347", "0.64855134", "0.647741...
0.7521755
0
Worst: O(n) time | O(n) space
function findClosestValueInBst(tree, target) { return findClosestValueInBstHelper(tree, target, Infinity); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function solution(a) { // O(N)\n let max1; // O(1)\n let max2; // O(1)\n\n for (let value of a) { // O(N)\n ...
[ "0.69607484", "0.63074785", "0.60324997", "0.59338874", "0.5930371", "0.59152275", "0.58737236", "0.58107764", "0.5809814", "0.57677877", "0.57537836", "0.57359546", "0.5732138", "0.5723706", "0.56955147", "0.56924915", "0.56691045", "0.56568545", "0.5653764", "0.5628573", "0...
0.0
-1
Gives back the id of the asset or makes a new asset
GetAsset(path, type){ var assets = this.assets.getChildren(); //Check there already is an asset entry for this path for(var i = 0; i < assets.length; i++) if(assets[i].getAttribute("src") === path) return assets[i].getAttribute("id"); //Create a new asset entry if it did not exist yet var asset = document.createElement(type); asset.setAttribute("src",path); //Asset id var id = "asset-" + this.asset_id++; asset.setAttribute("id", id); this.assets.appendChild(asset); return id; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getAssetId (index) {\n const newAsset = this.filteredAssets[index]\n const result = this.uploadedAssets.find(asset => asset.name === newAsset)\n if (result && result.id) {\n return result.id\n }\n return -1\n }", "function getAsset(assetId) {\n\n // find the asset\n var...
[ "0.6776127", "0.6742735", "0.65310824", "0.65288943", "0.63195705", "0.6302168", "0.6283423", "0.6222852", "0.60851216", "0.60726696", "0.6070996", "0.60332114", "0.6005652", "0.59481317", "0.59154123", "0.59154123", "0.59107244", "0.59047353", "0.588191", "0.5868168", "0.586...
0.637831
4
Return spherical distance between points on earth surface in meters p1 and p2 given as array [lon,lat]
function pointDistance(p1, p2) { var lon1 = p1[0] * deg2rad; var lon2 = p2[0] * deg2rad; var lat1 = p1[1] * deg2rad; var lat2 = p2[1] * deg2rad; a = Math.sin(lat1)*Math.sin(lat2) + Math.cos(lat1)*Math.cos(lat2) * Math.cos(lon2-lon1); // due to rounding errors a may exceed the legal argument range for acos if (a < -1.0) { a = -1.0; } if (a > 1.0) { a = 1.0; } return Math.acos(a) * R; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sphericalDistance(a, b) {\n\t var x = lonToMeters(a[0] - b[0], (a[1] + b[1]) / 2),\n\t y = latToMeters(a[1] - b[1]);\n\t return Math.sqrt((x * x) + (y * y));\n\t}", "function sphericalDistance(lam1, phi1, lam2, phi2) {\n var dlam = lam2 - lam1,\n dphi = phi2 - phi1,\n a = M...
[ "0.7437743", "0.733985", "0.72668856", "0.72580886", "0.7224401", "0.7212317", "0.7190487", "0.70879495", "0.70514625", "0.6997556", "0.6971698", "0.69597197", "0.69541484", "0.69528157", "0.69281584", "0.6923197", "0.6906247", "0.69006747", "0.68871176", "0.6884561", "0.6877...
0.7124219
8
Eliminate points from a way unnecessary at a coarse precision
function scarceWay(coords, deviation) { // one node minimum assert(coords.length); if (coords.length < 2) { return coords; } // 2-node way if (coords.length == 2) { if (pointDistance(coords[0],coords[1]) <= deviation) { // for a 2-point way with minimal length, shrink to a single point return [[(coords[0][0]+coords[1][0])*0.5, (coords[0][1]+coords[1][1])*0.5]]; } else { return coords; } } // 3-plus-node-way var scarce = processForwardInTriplets(coords, deviation, dropTheMiddleman); scarce = processBackwardInTriplets(coords, deviation, dropTheMiddleman); // call recursively as long as the scarcity can be improved if (scarce.length < coords.length) { return scarceWay(scarce, deviation); } return scarce; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function antiAliase(stations) {\n var m = refPts;\n stations[m].lat = stations[m].lat * cur +\n stations[m-1].lat * oneOff + stations[m+1].lat * oneOff +\n stations[m-2].lat * twoOff + stations[m+2].lat * twoOff;\n\n stations[m].lng = stations[m].lng * cur +\n stations[m-1].lng ...
[ "0.6315107", "0.6173462", "0.6111221", "0.6088243", "0.6061998", "0.60539246", "0.6042643", "0.6042643", "0.59813124", "0.59536225", "0.59536225", "0.59536225", "0.59536225", "0.59536225", "0.59536225", "0.59536225", "0.5946711", "0.5946711", "0.591609", "0.5857821", "0.58578...
0.0
-1
This call memoizes intermediate results in the recursive invocation. The scope of the memo cache is the resolve() call, so that multiple resolve() calls don't walk all over each other, and memory used for the memoization can be garbage collected. The memoization addresses issue 232. It looks like the memoization uses only the context and doesn't look at originalName, stop_spine and stop_branch arguments. This is valid because whenever in every recursive call operates on a "deeper" or else a newly created context. Therefore the collection of [originalName, stop_spine, stop_branch] can all be associated with a unique context. This argument is easier to see in a recursive rewrite of the resolveCtx function than with the while loop optimization where the recursive steps always operate on a different context. This might make it seem that the resolution results can be stored on the context object itself, but that would not work in general because multiple resolve() calls will walk over each other's cache results, which fails tests. So the memoization uses only a context's unique instance numbers as the memoization key and is local to each resolve() call. With this memoization, the time complexity of the resolveCtx call is no longer exponential for the cases in issue 232.
function resolveCtx(originalName, ctx, stop_spine, stop_branch, cache) { if (!ctx) { return originalName; } var key = ctx.instNum; return cache[key] || (cache[key] = resolveCtxFull(originalName, ctx, stop_spine, stop_branch, cache)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "resolver(name, depth, callback) {\n // Exceeded recursive maximum depth\n if (depth === 0) {\n const errMsg = `could not resolve name (recursion limit of ${defaultMaximumRecursiveDepth} exceeded)`;\n log.error(errMsg);\n return callback(errcode(new Error(errMsg), 'ERR_RESOLVE_RECURSION_LIMIT')...
[ "0.5418757", "0.51672536", "0.5159967", "0.5159967", "0.5087206", "0.506638", "0.4995027", "0.49744466", "0.49744466", "0.48883986", "0.48671627", "0.48212388", "0.47679302", "0.4729788", "0.4721245", "0.46949247", "0.46911404", "0.4663517", "0.4611715", "0.46062994", "0.4606...
0.70064014
0
fun () > Num
function fresh() { return nextFresh++; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function numfunc(num) {\n // Defines a function - with one arguement that ust be a number and must returna number\n return num + 1;\n}", "function num1() {\n return 10;\n}", "function retorno2(num1){\n return num1;\n}", "function fun(a){\n // console.log(\"a got :\" + a);\n return a>33;\n}"...
[ "0.65743196", "0.64378536", "0.62033254", "0.61884373", "0.6116618", "0.60564345", "0.5928299", "0.5924359", "0.59099394", "0.58900404", "0.58700585", "0.5849647", "0.5848096", "0.58336616", "0.5829366", "0.5829366", "0.5829366", "0.5829366", "0.5829366", "0.5829366", "0.5829...
0.0
-1
wraps the array of syntax objects in the delimiters given by the second argument ([...CSyntax], CSyntax) > [...CSyntax]
function wrapDelim(towrap, delimSyntax) { assert(delimSyntax.token.type === parser.Token.Delimiter, 'expecting a delimiter token'); return syntaxFromToken({ type: parser.Token.Delimiter, value: delimSyntax.token.value, inner: towrap, range: delimSyntax.token.range, startLineNumber: delimSyntax.token.startLineNumber, lineStart: delimSyntax.token.lineStart }, delimSyntax); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function SSyntax() {\r\n}", "function newSyntax() {\n foo::bar();\n const { abc } = { ...oneTwoThree };\n return new.target;\n }", "insertImplicitCloseParen() {\n let argListCode = this.slice(\n this.args[0].contentStart, this.args[this.args.length - 1].contentEnd);\n let isArgListMultilin...
[ "0.5688169", "0.55967265", "0.5357904", "0.5290633", "0.51772964", "0.51772964", "0.51772964", "0.5155771", "0.5089622", "0.50681895", "0.50666285", "0.504761", "0.50194293", "0.50102824", "0.49902156", "0.49351317", "0.48759824", "0.4871724", "0.48672825", "0.48601577", "0.4...
0.49037382
16
A TermTree is the core data structure for the macro expansion process. It acts as a semistructured representation of the syntax.
function TermTree() { }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function expandTermTreeToFinal(term, context) {\n assert(context && context.env, 'environment map is required');\n if (term.isArrayLiteral) {\n term.array.delim.token.inner = expand(term.array.delim.expose().token.inner, context);\n return term;\n } else if (term.isBlock)...
[ "0.6618771", "0.5954941", "0.58743894", "0.5807066", "0.5762332", "0.56107986", "0.54209614", "0.53674185", "0.53674185", "0.5338555", "0.52622247", "0.523543", "0.5233892", "0.52177334", "0.5181093", "0.51378644", "0.5136577", "0.5131451", "0.5129106", "0.5105356", "0.510443...
0.77228624
0
This should only be used on things that can't be rebound except by macros (puncs, keywords).
function resolveFast(stx, env) { var name = unwrapSyntax(stx); return env.names.get(name) ? resolve(stx) : name; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function bindable(){\n\t\t\n\t}", "function Bind_A_Oother() {\r\n}", "function Bind_A_Obound() {\r\n}", "function hardBound(){\n hard.call(obj)\n}", "function Bind_A_A_R() {\r\n}", "function wrappedCallbackPreprocessor(val) {\n // Matches either an isolated identifier or something ending with a p...
[ "0.5658762", "0.55640066", "0.5505738", "0.5474551", "0.542629", "0.53443706", "0.5343808", "0.53326213", "0.5325792", "0.53203434", "0.5315431", "0.5270324", "0.5270324", "0.5270324", "0.5267028", "0.5260755", "0.52444047", "0.5241858", "0.52308846", "0.5219925", "0.5212031"...
0.0
-1
enforest the tokens, returns an object with the `result` TermTree and the uninterpreted `rest` of the syntax
function enforest(toks, context, prevStx, prevTerms) { assert(toks.length > 0, 'enforest assumes there are tokens to work with'); prevStx = prevStx || []; prevTerms = prevTerms || []; if (expandCount >= maxExpands) { return { result: null, rest: toks }; } function step(head, rest, opCtx) { var innerTokens; assert(Array.isArray(rest), 'result must at least be an empty array'); if (head.isTermTree) { var isCustomOp = false; var uopMacroObj; var uopSyntax; if (head.isPunc || head.isKeyword || head.isId) { if (head.isPunc) { uopSyntax = head.punc; } else if (head.isKeyword) { uopSyntax = head.keyword; } else if (head.isId) { uopSyntax = head.id; } uopMacroObj = getMacroInEnv(uopSyntax, rest, context.env); isCustomOp = uopMacroObj && uopMacroObj.isOp; } // look up once (we want to check multiple properties on bopMacroObj // without repeatedly calling getMacroInEnv) var bopMacroObj; if (rest[0] && rest[1]) { bopMacroObj = getMacroInEnv(rest[0], rest.slice(1), context.env); } // unary operator if (isCustomOp && uopMacroObj.unary || uopSyntax && stxIsUnaryOp(uopSyntax)) { var uopPrec; if (isCustomOp && uopMacroObj.unary) { uopPrec = uopMacroObj.unary.prec; } else { uopPrec = getUnaryOpPrec(unwrapSyntax(uopSyntax)); } var opRest = rest; var uopMacroName; if (uopMacroObj) { uopMacroName = [uopSyntax].concat(rest.slice(0, uopMacroObj.fullName.length - 1)); opRest = rest.slice(uopMacroObj.fullName.length - 1); } var leftLeft = opCtx.prevTerms[0] && opCtx.prevTerms[0].isPartial ? opCtx.prevTerms[0] : null; var unopTerm = PartialOperation.create(head, leftLeft); var unopPrevStx = tagWithTerm(unopTerm, head.destruct().reverse()).concat(opCtx.prevStx); var unopPrevTerms = [unopTerm].concat(opCtx.prevTerms); var unopOpCtx = _.extend({}, opCtx, { combine: function (t) { if (t.isExpr) { if (isCustomOp && uopMacroObj.unary) { var rt$2 = expandMacro(uopMacroName.concat(t.destruct()), context, opCtx, 'unary'); var newt = get_expression(rt$2.result, context); assert(newt.rest.length === 0, 'should never have left over syntax'); return opCtx.combine(newt.result); } return opCtx.combine(UnaryOp.create(uopSyntax, t)); } else { // not actually an expression so don't create // a UnaryOp term just return with the punctuator return opCtx.combine(head); } }, prec: uopPrec, prevStx: unopPrevStx, prevTerms: unopPrevTerms, op: unopTerm }); return step(opRest[0], opRest.slice(1), unopOpCtx); } // BinOp else if (head.isExpr && (rest[0] && rest[1] && (stxIsBinOp(rest[0]) && !bopMacroObj || bopMacroObj && bopMacroObj.isOp && bopMacroObj.binary))) { var opRes; var op = rest[0]; var left = head; var rightStx = rest.slice(1); var leftLeft = opCtx.prevTerms[0] && opCtx.prevTerms[0].isPartial ? opCtx.prevTerms[0] : null; var leftTerm = PartialExpression.create(head.destruct(), leftLeft, function () { return step(head, [], opCtx); }); var opTerm = PartialOperation.create(op, leftTerm); var opPrevStx = tagWithTerm(opTerm, [rest[0]]).concat(tagWithTerm(leftTerm, head.destruct()).reverse(), opCtx.prevStx); var opPrevTerms = [ opTerm, leftTerm ].concat(opCtx.prevTerms); var isCustomOp = bopMacroObj && bopMacroObj.isOp && bopMacroObj.binary; var bopPrec; var bopAssoc; if (isCustomOp && bopMacroObj.binary) { bopPrec = bopMacroObj.binary.prec; bopAssoc = bopMacroObj.binary.assoc; } else { bopPrec = getBinaryOpPrec(unwrapSyntax(op)); bopAssoc = getBinaryOpAssoc(unwrapSyntax(op)); } assert(bopPrec !== undefined, 'expecting a precedence for operator: ' + op); var newStack; if (comparePrec(bopPrec, opCtx.prec, bopAssoc)) { var bopCtx = opCtx; var combResult = opCtx.combine(head); if (opCtx.stack.length > 0) { return step(combResult.term, rest, opCtx.stack[0]); } left = combResult.term; newStack = opCtx.stack; opPrevStx = combResult.prevStx; opPrevTerms = combResult.prevTerms; } else { newStack = [opCtx].concat(opCtx.stack); } assert(opCtx.combine !== undefined, 'expecting a combine function'); var opRightStx = rightStx; var bopMacroName; if (isCustomOp) { bopMacroName = rest.slice(0, bopMacroObj.fullName.length); opRightStx = rightStx.slice(bopMacroObj.fullName.length - 1); } var bopOpCtx = _.extend({}, opCtx, { combine: function (right) { if (right.isExpr) { if (isCustomOp && bopMacroObj.binary) { var leftStx = left.destruct(); var rightStx$2 = right.destruct(); var rt$2 = expandMacro(bopMacroName.concat(syn.makeDelim('()', leftStx, leftStx[0]), syn.makeDelim('()', rightStx$2, rightStx$2[0])), context, opCtx, 'binary'); var newt = get_expression(rt$2.result, context); assert(newt.rest.length === 0, 'should never have left over syntax'); return { term: newt.result, prevStx: opCtx.prevStx, prevTerms: opCtx.prevTerms }; } return { term: BinOp.create(left, op, right), prevStx: opCtx.prevStx, prevTerms: opCtx.prevTerms }; } else { return { term: head, prevStx: opCtx.prevStx, prevTerms: opCtx.prevTerms }; } }, prec: bopPrec, op: opTerm, stack: newStack, prevStx: opPrevStx, prevTerms: opPrevTerms }); return step(opRightStx[0], opRightStx.slice(1), bopOpCtx); } // Call else if (head.isExpr && (rest[0] && rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()')) { var argRes, enforestedArgs = [], commas = []; rest[0].expose(); innerTokens = rest[0].token.inner; while (innerTokens.length > 0) { argRes = enforest(innerTokens, context); if (!argRes.result) { break; } enforestedArgs.push(argRes.result); innerTokens = argRes.rest; if (innerTokens[0] && innerTokens[0].token.value === ',') { // record the comma for later commas.push(innerTokens[0]); // but dump it for the next loop turn innerTokens = innerTokens.slice(1); } else { // either there are no more tokens or // they aren't a comma, either way we // are done with the loop break; } } var argsAreExprs = _.all(enforestedArgs, function (argTerm) { return argTerm.isExpr; }); // only a call if we can completely enforest each argument and // each argument is an expression if (innerTokens.length === 0 && argsAreExprs) { return step(Call.create(head, enforestedArgs, rest[0], commas), rest.slice(1), opCtx); } } // Conditional ( x ? true : false) else if (head.isExpr && (rest[0] && resolveFast(rest[0], context.env) === '?')) { var question = rest[0]; var condRes = enforest(rest.slice(1), context); if (condRes.result) { var truExpr = condRes.result; var condRight = condRes.rest; if (truExpr.isExpr && condRight[0] && resolveFast(condRight[0], context.env) === ':') { var colon = condRight[0]; var flsRes = enforest(condRight.slice(1), context); var flsExpr = flsRes.result; if (flsExpr.isExpr) { return step(ConditionalExpression.create(head, question, truExpr, colon, flsExpr), flsRes.rest, opCtx); } } } } // Constructor else if (head.isKeyword && resolveFast(head.keyword, context.env) === 'new' && rest[0]) { var newCallRes = enforest(rest, context); if (newCallRes && newCallRes.result.isExpr) { return step(Const.create(head, newCallRes.result), newCallRes.rest, opCtx); } } // Arrow functions with expression bodies else if (head.isDelimiter && head.delim.token.value === '()' && rest[0] && rest[0].token.type === parser.Token.Punctuator && resolveFast(rest[0], context.env) === '=>') { var arrowRes = enforest(rest.slice(1), context); if (arrowRes.result && arrowRes.result.isExpr) { return step(ArrowFun.create(head.delim, rest[0], arrowRes.result.destruct()), arrowRes.rest, opCtx); } else { throwSyntaxError('enforest', 'Body of arrow function must be an expression', rest.slice(1)); } } // Arrow functions with expression bodies else if (head.isId && rest[0] && rest[0].token.type === parser.Token.Punctuator && resolveFast(rest[0], context.env) === '=>') { var res = enforest(rest.slice(1), context); if (res.result && res.result.isExpr) { return step(ArrowFun.create(head.id, rest[0], res.result.destruct()), res.rest, opCtx); } else { throwSyntaxError('enforest', 'Body of arrow function must be an expression', rest.slice(1)); } } // ParenExpr else if (head.isDelimiter && head.delim.token.value === '()') { innerTokens = head.delim.expose().token.inner; // empty parens are acceptable but enforest // doesn't accept empty arrays so short // circuit here if (innerTokens.length === 0) { head.delim.token.inner = [Empty.create()]; return step(ParenExpression.create(head), rest, opCtx); } else { var innerTerm = get_expression(innerTokens, context); if (innerTerm.result && innerTerm.result.isExpr && innerTerm.rest.length === 0) { head.delim.token.inner = [innerTerm.result]; return step(ParenExpression.create(head), rest, opCtx); } } // if the tokens inside the paren aren't an expression // we just leave it as a delimiter } // AssignmentExpression else if (head.isExpr && ((head.isId || head.isObjGet || head.isObjDotGet || head.isThisExpression) && rest[0] && rest[1] && !bopMacroObj && stxIsAssignOp(rest[0]))) { var opRes = enforestAssignment(rest, context, head, prevStx, prevTerms); if (opRes && opRes.result) { return step(opRes.result, opRes.rest, _.extend({}, opCtx, { prevStx: opRes.prevStx, prevTerms: opRes.prevTerms })); } } // Postfix else if (head.isExpr && (rest[0] && (unwrapSyntax(rest[0]) === '++' || unwrapSyntax(rest[0]) === '--'))) { // Check if the operator is a macro first. if (context.env.has(resolveFast(rest[0], context.env))) { var headStx = tagWithTerm(head, head.destruct().reverse()); var opPrevStx = headStx.concat(prevStx); var opPrevTerms = [head].concat(prevTerms); var opRes = enforest(rest, context, opPrevStx, opPrevTerms); if (opRes.prevTerms.length < opPrevTerms.length) { return opRes; } else if (opRes.result) { return step(head, opRes.result.destruct().concat(opRes.rest), opCtx); } } return step(PostfixOp.create(head, rest[0]), rest.slice(1), opCtx); } // ObjectGet (computed) else if (head.isExpr && (rest[0] && rest[0].token.value === '[]')) { return step(ObjGet.create(head, Delimiter.create(rest[0].expose())), rest.slice(1), opCtx); } // ObjectGet else if (head.isExpr && (rest[0] && unwrapSyntax(rest[0]) === '.' && !context.env.has(resolveFast(rest[0], context.env)) && rest[1] && (rest[1].token.type === parser.Token.Identifier || rest[1].token.type === parser.Token.Keyword))) { // Check if the identifier is a macro first. if (context.env.has(resolveFast(rest[1], context.env))) { var headStx = tagWithTerm(head, head.destruct().reverse()); var dotTerm = Punc.create(rest[0]); var dotTerms = [dotTerm].concat(head, prevTerms); var dotStx = tagWithTerm(dotTerm, [rest[0]]).concat(headStx, prevStx); var dotRes = enforest(rest.slice(1), context, dotStx, dotTerms); if (dotRes.prevTerms.length < dotTerms.length) { return dotRes; } else if (dotRes.result) { return step(head, [rest[0]].concat(dotRes.result.destruct(), dotRes.rest), opCtx); } } return step(ObjDotGet.create(head, rest[0], rest[1]), rest.slice(2), opCtx); } // ArrayLiteral else if (head.isDelimiter && head.delim.token.value === '[]') { return step(ArrayLiteral.create(head), rest, opCtx); } // Block else if (head.isDelimiter && head.delim.token.value === '{}') { return step(Block.create(head), rest, opCtx); } // quote syntax else if (head.isId && unwrapSyntax(head.id) === '#quoteSyntax' && rest[0] && rest[0].token.value === '{}') { var tempId = fresh(); context.templateMap.set(tempId, rest[0].token.inner); return step(syn.makeIdent('getTemplate', head.id), [syn.makeDelim('()', [syn.makeValue(tempId, head.id)], head.id)].concat(rest.slice(1)), opCtx); } // let statements else if (head.isKeyword && unwrapSyntax(head.keyword) === 'let') { var nameTokens = []; if (rest[0] && rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()') { nameTokens = rest[0].token.inner; } else { nameTokens.push(rest[0]); } // Let macro if (rest[1] && rest[1].token.value === '=' && rest[2] && rest[2].token.value === 'macro') { var mac = enforest(rest.slice(2), context); if (mac.result) { if (!mac.result.isAnonMacro) { throwSyntaxError('enforest', 'expecting an anonymous macro definition in syntax let binding', rest.slice(2)); } return step(LetMacro.create(nameTokens, mac.result.body), mac.rest, opCtx); } } // Let statement else { var lsRes = enforestVarStatement(rest, context, head.keyword); if (lsRes && lsRes.result) { return step(LetStatement.create(head, lsRes.result), lsRes.rest, opCtx); } } } // VariableStatement else if (head.isKeyword && unwrapSyntax(head.keyword) === 'var' && rest[0]) { var vsRes = enforestVarStatement(rest, context, head.keyword); if (vsRes && vsRes.result) { return step(VariableStatement.create(head, vsRes.result), vsRes.rest, opCtx); } } // Const Statement else if (head.isKeyword && unwrapSyntax(head.keyword) === 'const' && rest[0]) { var csRes = enforestVarStatement(rest, context, head.keyword); if (csRes && csRes.result) { return step(ConstStatement.create(head, csRes.result), csRes.rest, opCtx); } } // for statement else if (head.isKeyword && unwrapSyntax(head.keyword) === 'for' && rest[0] && rest[0].token.value === '()') { return step(ForStatement.create(head.keyword, rest[0]), rest.slice(1), opCtx); } // yield statement else if (head.isKeyword && unwrapSyntax(head.keyword) === 'yield') { var yieldExprRes = enforest(rest, context); if (yieldExprRes.result && yieldExprRes.result.isExpr) { return step(YieldExpression.create(head.keyword, yieldExprRes.result), yieldExprRes.rest, opCtx); } } } else { assert(head && head.token, 'assuming head is a syntax object'); var macroObj = expandCount < maxExpands && getMacroInEnv(head, rest, context.env); // macro invocation if (macroObj && !macroObj.isOp) { var rt = expandMacro([head].concat(rest), context, opCtx, null, macroObj); var newOpCtx = opCtx; if (rt.prevTerms && rt.prevTerms.length < opCtx.prevTerms.length) { newOpCtx = rewindOpCtx(opCtx, rt); } if (rt.result.length > 0) { return step(rt.result[0], rt.result.slice(1).concat(rt.rest), newOpCtx); } else { return step(Empty.create(), rt.rest, newOpCtx); } } // anon macro definition else if (head.token.type === parser.Token.Identifier && resolve(head) === 'macro' && rest[0] && rest[0].token.value === '{}') { return step(AnonMacro.create(rest[0].expose().token.inner), rest.slice(1), opCtx); } // macro definition else if (head.token.type === parser.Token.Identifier && resolve(head) === 'macro') { var nameTokens = []; if (rest[0] && rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()') { nameTokens = rest[0].expose().token.inner; } else { nameTokens.push(rest[0]); } if (rest[1] && rest[1].token.type === parser.Token.Delimiter) { return step(Macro.create(nameTokens, rest[1].expose().token.inner), rest.slice(2), opCtx); } else { throwSyntaxError('enforest', 'Macro declaration must include body', rest[1]); } } // operator definition // unaryop (neg) 1 { macro { rule { $op:expr } => { $op } } } else if (head.token.type === parser.Token.Identifier && head.token.value === 'unaryop' && rest[0] && rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()' && rest[1] && rest[1].token.type === parser.Token.NumericLiteral && rest[2] && rest[2].token.type === parser.Token.Delimiter && rest[2] && rest[2].token.value === '{}') { var trans = enforest(rest[2].expose().token.inner, context); return step(OperatorDefinition.create('unary', rest[0].expose().token.inner, rest[1], null, trans.result.body), rest.slice(3), opCtx); } // operator definition // binaryop (neg) 1 left { macro { rule { $op:expr } => { $op } } } else if (head.token.type === parser.Token.Identifier && head.token.value === 'binaryop' && rest[0] && rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()' && rest[1] && rest[1].token.type === parser.Token.NumericLiteral && rest[2] && rest[2].token.type === parser.Token.Identifier && rest[3] && rest[3].token.type === parser.Token.Delimiter && rest[3] && rest[3].token.value === '{}') { var trans = enforest(rest[3].expose().token.inner, context); return step(OperatorDefinition.create('binary', rest[0].expose().token.inner, rest[1], rest[2], trans.result.body), rest.slice(4), opCtx); } // module definition else if (unwrapSyntax(head) === 'module' && rest[0] && rest[0].token.value === '{}') { return step(Module.create(rest[0], []), rest.slice(1), opCtx); } // function definition else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'function' && rest[0] && rest[0].token.type === parser.Token.Identifier && rest[1] && rest[1].token.type === parser.Token.Delimiter && rest[1].token.value === '()' && rest[2] && rest[2].token.type === parser.Token.Delimiter && rest[2].token.value === '{}') { rest[1].token.inner = rest[1].expose().token.inner; rest[2].token.inner = rest[2].expose().token.inner; return step(NamedFun.create(head, null, rest[0], rest[1], rest[2]), rest.slice(3), opCtx); } // generator function definition else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'function' && rest[0] && rest[0].token.type === parser.Token.Punctuator && rest[0].token.value === '*' && rest[1] && rest[1].token.type === parser.Token.Identifier && rest[2] && rest[2].token.type === parser.Token.Delimiter && rest[2].token.value === '()' && rest[3] && rest[3].token.type === parser.Token.Delimiter && rest[3].token.value === '{}') { rest[2].token.inner = rest[2].expose().token.inner; rest[3].token.inner = rest[3].expose().token.inner; return step(NamedFun.create(head, rest[0], rest[1], rest[2], rest[3]), rest.slice(4), opCtx); } // anonymous function definition else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'function' && rest[0] && rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()' && rest[1] && rest[1].token.type === parser.Token.Delimiter && rest[1].token.value === '{}') { rest[0].token.inner = rest[0].expose().token.inner; rest[1].token.inner = rest[1].expose().token.inner; return step(AnonFun.create(head, null, rest[0], rest[1]), rest.slice(2), opCtx); } // anonymous generator function definition else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'function' && rest[0] && rest[0].token.type === parser.Token.Punctuator && rest[0].token.value === '*' && rest[1] && rest[1].token.type === parser.Token.Delimiter && rest[1].token.value === '()' && rest[2] && rest[2].token.type === parser.Token.Delimiter && rest[2].token.value === '{}') { rest[1].token.inner = rest[1].expose().token.inner; rest[2].token.inner = rest[2].expose().token.inner; return step(AnonFun.create(head, rest[0], rest[1], rest[2]), rest.slice(3), opCtx); } // arrow function else if ((head.token.type === parser.Token.Delimiter && head.token.value === '()' || head.token.type === parser.Token.Identifier) && rest[0] && rest[0].token.type === parser.Token.Punctuator && resolveFast(rest[0], context.env) === '=>' && rest[1] && rest[1].token.type === parser.Token.Delimiter && rest[1].token.value === '{}') { return step(ArrowFun.create(head, rest[0], rest[1]), rest.slice(2), opCtx); } // catch statement else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'catch' && rest[0] && rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()' && rest[1] && rest[1].token.type === parser.Token.Delimiter && rest[1].token.value === '{}') { rest[0].token.inner = rest[0].expose().token.inner; rest[1].token.inner = rest[1].expose().token.inner; return step(CatchClause.create(head, rest[0], rest[1]), rest.slice(2), opCtx); } // this expression else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'this') { return step(ThisExpression.create(head), rest, opCtx); } // literal else if (head.token.type === parser.Token.NumericLiteral || head.token.type === parser.Token.StringLiteral || head.token.type === parser.Token.BooleanLiteral || head.token.type === parser.Token.RegularExpression || head.token.type === parser.Token.NullLiteral) { return step(Lit.create(head), rest, opCtx); } // export else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'export' && rest[0] && (rest[0].token.type === parser.Token.Identifier || rest[0].token.type === parser.Token.Keyword || rest[0].token.type === parser.Token.Punctuator || rest[0].token.type === parser.Token.Delimiter && rest[0].token.value === '()')) { return step(Export.create(rest[0]), rest.slice(1), opCtx); } // identifier else if (head.token.type === parser.Token.Identifier) { return step(Id.create(head), rest, opCtx); } // punctuator else if (head.token.type === parser.Token.Punctuator) { return step(Punc.create(head), rest, opCtx); } else if (head.token.type === parser.Token.Keyword && unwrapSyntax(head) === 'with') { throwSyntaxError('enforest', 'with is not supported in sweet.js', head); } // keyword else if (head.token.type === parser.Token.Keyword) { return step(Keyword.create(head), rest, opCtx); } // Delimiter else if (head.token.type === parser.Token.Delimiter) { return step(Delimiter.create(head.expose()), rest, opCtx); } else if (head.token.type === parser.Token.Template) { return step(Template.create(head), rest, opCtx); } // end of file else if (head.token.type === parser.Token.EOF) { assert(rest.length === 0, 'nothing should be after an EOF'); return step(EOF.create(head), [], opCtx); } else { // todo: are we missing cases? assert(false, 'not implemented'); } } // Potentially an infix macro if (head.isExpr && rest.length && nameInEnv(rest[0], rest.slice(1), context.env)) { var infLeftTerm = opCtx.prevTerms[0] && opCtx.prevTerms[0].isPartial ? opCtx.prevTerms[0] : null; var infTerm = PartialExpression.create(head.destruct(), infLeftTerm, function () { return step(head, [], opCtx); }); var infPrevStx = tagWithTerm(infTerm, head.destruct()).reverse().concat(opCtx.prevStx); var infPrevTerms = [infTerm].concat(opCtx.prevTerms); var infRes = expandMacro(rest, context, { prevStx: infPrevStx, prevTerms: infPrevTerms }); if (infRes.prevTerms && infRes.prevTerms.length < infPrevTerms.length) { var infOpCtx = rewindOpCtx(opCtx, infRes); return step(infRes.result[0], infRes.result.slice(1).concat(infRes.rest), infOpCtx); } else { return step(head, infRes.result.concat(infRes.rest), opCtx); } } // done with current step so combine and continue on var combResult = opCtx.combine(head); if (opCtx.stack.length === 0) { return { result: combResult.term, rest: rest, prevStx: combResult.prevStx, prevTerms: combResult.prevTerms }; } else { return step(combResult.term, rest, opCtx.stack[0]); } } return step(toks[0], toks.slice(1), { combine: function (t) { return { term: t, prevStx: prevStx, prevTerms: prevTerms }; }, prec: 0, stack: [], op: null, prevStx: prevStx, prevTerms: prevTerms }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "enforest() {\n\t let type = arguments.length <= 0 || arguments[0] === undefined ? \"Module\" : arguments[0];\n\n\t // initialize the term\n\t this.term = null;\n\n\t if (this.rest.size === 0) {\n\t this.done = true;\n\t return this.term;\n\t }\n\n\t if (this.isEOF(this.peek())) {\n\t ...
[ "0.6682996", "0.6266196", "0.59369326", "0.5789823", "0.55184007", "0.5444358", "0.5374127", "0.53472996", "0.530861", "0.52536815", "0.52536815", "0.52536815", "0.52536815", "0.516102", "0.51416516", "0.5139411", "0.5071999", "0.506615", "0.5062205", "0.5062205", "0.5062205"...
0.70109814
0
mark each syntax object in the pattern environment, mutating the environment
function applyMarkToPatternEnv(newMark, env) { /* Takes a `match` object: { level: <num>, match: [<match> or <syntax>] } where the match property is an array of syntax objects at the bottom (0) level. Does a depth-first search and applys the mark to each syntax object. */ function dfs(match) { if (match.level === 0) { // replace the match property with the marked syntax match.match = _.map(match.match, function (stx) { return stx.mark(newMark); }); } else { _.each(match.match, function (match$2) { dfs(match$2); }); } } _.keys(env).forEach(function (key) { dfs(env[key]); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updatePattern(pat){ // call the pattern currently being created\n switch(pat) {\n case 0:\n rainbow();\n break;\n case 1:\n rainbowCycle();\n break;\n case 2:\n theaterChaseRainbow();\n break;\n case 3:\n colorWipe(strip.Color(255, 0, 0)); // ...
[ "0.5055013", "0.5052834", "0.5038943", "0.49668983", "0.4940772", "0.4907777", "0.4907777", "0.48936927", "0.48829216", "0.48823985", "0.4879836", "0.48612398", "0.4812791", "0.47954997", "0.47916326", "0.4739307", "0.46989194", "0.46893525", "0.46801847", "0.46701443", "0.46...
0.6791206
0
given the syntax for a macro, produce a macro transformer (Macro) > (([...CSyntax]) > ReadTree)
function loadMacroDef(body, context) { // raw function primitive form if (!(body[0] && body[0].token.type === parser.Token.Keyword && body[0].token.value === 'function')) { throwSyntaxError('load macro', 'Primitive macro form must contain a function for the macro body', body); } var stub = parser.read('()'); stub[0].token.inner = body; var expanded = expand(stub, context); expanded = expanded[0].destruct().concat(expanded[1].eof); var flattend = flatten(expanded); var bodyCode = codegen.generate(parser.parse(flattend)); var macroFn = scopedEval(bodyCode, { makeValue: syn.makeValue, makeRegex: syn.makeRegex, makeIdent: syn.makeIdent, makeKeyword: syn.makeKeyword, makePunc: syn.makePunc, makeDelim: syn.makeDelim, require: function (id) { if (context.requireModule) { return context.requireModule(id, context.filename); } return require(id); }, getExpr: function (stx) { var r; if (stx.length === 0) { return { success: false, result: [], rest: [] }; } r = get_expression(stx, context); return { success: r.result !== null, result: r.result === null ? [] : r.result.destruct(), rest: r.rest }; }, getIdent: function (stx) { if (stx[0] && stx[0].token.type === parser.Token.Identifier) { return { success: true, result: [stx[0]], rest: stx.slice(1) }; } return { success: false, result: [], rest: stx }; }, getLit: function (stx) { if (stx[0] && patternModule.typeIsLiteral(stx[0].token.type)) { return { success: true, result: [stx[0]], rest: stx.slice(1) }; } return { success: false, result: [], rest: stx }; }, unwrapSyntax: syn.unwrapSyntax, throwSyntaxError: throwSyntaxError, throwSyntaxCaseError: throwSyntaxCaseError, prettyPrint: syn.prettyPrint, parser: parser, __fresh: fresh, _: _, patternModule: patternModule, getPattern: function (id) { return context.patternMap.get(id); }, getTemplate: function (id) { return syn.cloneSyntaxArray(context.templateMap.get(id)); }, applyMarkToPatternEnv: applyMarkToPatternEnv, mergeMatches: function (newMatch, oldMatch) { newMatch.patternEnv = _.extend({}, oldMatch.patternEnv, newMatch.patternEnv); return newMatch; } }); return macroFn; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function macroExpand(syntaxTree) {\n\t\tvar i;\n\t\t\n\t\tfor (i = 0; i < syntaxTree.length; i++) {\n\t\t\tif (Array.isArray(syntaxTree[i])) {\n\t\t\t\tsyntaxTree[i] = macroExpand(syntaxTree[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (syntaxTree.length > 0 && typeof macros[syntaxTree[0]] === 'function') {\n\t\t\treturn ma...
[ "0.60955095", "0.5406199", "0.53547174", "0.53318083", "0.51143336", "0.5076067", "0.5049688", "0.5002471", "0.49963763", "0.4980343", "0.49352366", "0.49352366", "0.49352366", "0.49201155", "0.49112839", "0.4890799", "0.4852491", "0.4840356", "0.48382154", "0.48179978", "0.4...
0.51713055
4
similar to `parse2` in the honu paper except here we don't generate an AST yet (TermTree, Map, Map) > TermTree
function expandTermTreeToFinal(term, context) { assert(context && context.env, 'environment map is required'); if (term.isArrayLiteral) { term.array.delim.token.inner = expand(term.array.delim.expose().token.inner, context); return term; } else if (term.isBlock) { term.body.delim.token.inner = expand(term.body.delim.expose().token.inner, context); return term; } else if (term.isParenExpression) { assert(term.expr.delim.token.inner.length === 1, 'Paren expressions always have a single term inside the delimiter'); term.expr.delim.token.inner = [expandTermTreeToFinal(term.expr.delim.token.inner[0], context)]; return term; } else if (term.isCall) { term.fun = expandTermTreeToFinal(term.fun, context); term.args = _.map(term.args, function (arg) { return expandTermTreeToFinal(arg, context); }); return term; } else if (term.isConst) { term.call = expandTermTreeToFinal(term.call, context); return term; } else if (term.isUnaryOp) { term.expr = expandTermTreeToFinal(term.expr, context); return term; } else if (term.isBinOp || term.isAssignmentExpression) { term.left = expandTermTreeToFinal(term.left, context); term.right = expandTermTreeToFinal(term.right, context); return term; } else if (term.isObjGet) { term.left = expandTermTreeToFinal(term.left, context); term.right.delim.token.inner = expand(term.right.delim.expose().token.inner, context); return term; } else if (term.isObjDotGet) { term.left = expandTermTreeToFinal(term.left, context); term.right = expandTermTreeToFinal(term.right, context); return term; } else if (term.isConditionalExpression) { term.cond = expandTermTreeToFinal(term.cond, context); term.tru = expandTermTreeToFinal(term.tru, context); term.fls = expandTermTreeToFinal(term.fls, context); return term; } else if (term.isVariableDeclaration) { if (term.init) { term.init = expandTermTreeToFinal(term.init, context); } return term; } else if (term.isVariableStatement) { term.decls = _.map(term.decls, function (decl) { return expandTermTreeToFinal(decl, context); }); return term; } else if (term.isDelimiter) { // expand inside the delimiter and then continue on term.delim.token.inner = expand(term.delim.expose().token.inner, context); return term; } else if (term.isNamedFun || term.isAnonFun || term.isCatchClause || term.isArrowFun || term.isModule) { // function definitions need a bunch of hygiene logic // push down a fresh definition context var newDef = []; var bodyContext = makeExpanderContext(_.defaults({ defscope: newDef }, context)); var paramSingleIdent = term.params && term.params.token.type === parser.Token.Identifier; var params; if (term.params && term.params.token.type === parser.Token.Delimiter) { params = term.params.expose(); } else if (paramSingleIdent) { params = term.params; } else { params = syn.makeDelim('()', [], null); } var bodies; if (Array.isArray(term.body)) { bodies = syn.makeDelim('{}', term.body, null); } else { bodies = term.body; } bodies = bodies.addDefCtx(newDef); var paramNames = _.map(getParamIdentifiers(params), function (param) { var freshName = fresh(); return { freshName: freshName, originalParam: param, renamedParam: param.rename(param, freshName) }; }); // rename the function body for each of the parameters var renamedBody = _.reduce(paramNames, function (accBody, p) { return accBody.rename(p.originalParam, p.freshName); }, bodies); renamedBody = renamedBody.expose(); var expandedResult = expandToTermTree(renamedBody.token.inner, bodyContext); var bodyTerms = expandedResult.terms; if (expandedResult.restStx) { // The expansion was halted prematurely. Just stop and // return what we have so far, along with the rest of the syntax renamedBody.token.inner = expandedResult.terms.concat(expandedResult.restStx); if (Array.isArray(term.body)) { term.body = renamedBody.token.inner; } else { term.body = renamedBody; } return term; } var renamedParams = _.map(paramNames, function (p) { return p.renamedParam; }); var flatArgs; if (paramSingleIdent) { flatArgs = renamedParams[0]; } else { flatArgs = syn.makeDelim('()', joinSyntax(renamedParams, ','), term.params || null); } var expandedArgs = expand([flatArgs], bodyContext); assert(expandedArgs.length === 1, 'should only get back one result'); // stitch up the function with all the renamings if (term.params) { term.params = expandedArgs[0]; } bodyTerms = _.map(bodyTerms, function (bodyTerm) { // add the definition context to the result of // expansion (this makes sure that syntax objects // introduced by expansion have the def context) if (bodyTerm.isBlock) { // we need to expand blocks before adding the defctx since // blocks defer macro expansion. var blockFinal = expandTermTreeToFinal(bodyTerm, expandedResult.context); return blockFinal.addDefCtx(newDef); } else { var termWithCtx = bodyTerm.addDefCtx(newDef); // finish expansion return expandTermTreeToFinal(termWithCtx, expandedResult.context); } }); if (term.isModule) { bodyTerms = _.filter(bodyTerms, function (bodyTerm) { if (bodyTerm.isExport) { term.exports.push(bodyTerm); return false; } else { return true; } }); } renamedBody.token.inner = bodyTerms; if (Array.isArray(term.body)) { term.body = renamedBody.token.inner; } else { term.body = renamedBody; } // and continue expand the rest return term; } // the term is fine as is return term; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function TermTree() {\n }", "parseTerm() {\n const assertion = this.maybeParseAssertion();\n if (assertion) {\n return assertion;\n }\n return {\n type: 'Term',\n capturingParenthesesBefore: this.capturingGroups.length,\n Atom: this.parseAtom(),\n Quantifier: this.maybePar...
[ "0.6481999", "0.62800974", "0.6020416", "0.56803274", "0.5636488", "0.5622504", "0.53980356", "0.53980356", "0.53980356", "0.53980356", "0.5350911", "0.52682894", "0.52641803", "0.52227634", "0.5216205", "0.521228", "0.519589", "0.51795083", "0.51542884", "0.513525", "0.51006...
0.6080196
2
similar to `parse` in the honu paper ([Syntax], Map, Map) > [TermTree]
function expand(stx, context) { assert(context, 'must provide an expander context'); var trees = expandToTermTree(stx, context); var terms = _.map(trees.terms, function (term) { return expandTermTreeToFinal(term, trees.context); }); if (trees.restStx) { terms.push.apply(terms, trees.restStx); } return terms; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function TermTree() {\n }", "parseTerm() {\n const assertion = this.maybeParseAssertion();\n if (assertion) {\n return assertion;\n }\n return {\n type: 'Term',\n capturingParenthesesBefore: this.capturingGroups.length,\n Atom: this.parseAtom(),\n Quantifier: this.maybePar...
[ "0.66163296", "0.6509015", "0.5855849", "0.57619786", "0.57346493", "0.5703886", "0.5515664", "0.5485622", "0.54301363", "0.53547525", "0.52678543", "0.52534336", "0.52269846", "0.5222215", "0.5187693", "0.51669896", "0.5139939", "0.5139939", "0.5139939", "0.5139939", "0.5066...
0.0
-1
a hack to make the top level hygiene work out
function expandTopLevel(stx, moduleContexts, options) { moduleContexts = moduleContexts || []; maxExpands = (_.isNumber(options) ? options : options && options._maxExpands) || Infinity; expandCount = 0; var context = makeTopLevelExpanderContext(options); var modBody = syn.makeDelim('{}', stx, null); modBody = _.reduce(moduleContexts, function (acc, mod) { context.env.extend(mod.env); context.env.names.extend(mod.env.names); return loadModuleExports(acc, context.env, mod.exports, mod.env); }, modBody); var res = expand([ syn.makeIdent('module', null), modBody ], context); res = res[0].destruct(); return flatten(res[0].token.inner); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "enterPrefixedname(ctx) {\n\t}", "enterDotted_as_name(ctx) {\n\t}", "function l(e,t){\"\"===e&&(e=\".\"),e=e.replace(/\\/$/,\"\");\n// XXX: It is possible to remove this block, and the tests still pass!\nvar n=o(e);return\"/\"==t.charAt(0)&&n&&\"/\"==n.path?t.slice(1):0===t.indexOf(e+\"/\")?t.substr(e.length+1)...
[ "0.54198885", "0.5295679", "0.5266057", "0.5253597", "0.52387434", "0.51907146", "0.5184963", "0.51506007", "0.5141844", "0.5089169", "0.50848925", "0.5082414", "0.50673586", "0.5066328", "0.50571984", "0.5050616", "0.5037815", "0.4937327", "0.49357924", "0.49275586", "0.4926...
0.0
-1
break delimiter tree structure down to flat array of syntax objects
function flatten(stx) { return _.reduce(stx, function (acc, stx$2) { if (stx$2.token.type === parser.Token.Delimiter) { var exposed = stx$2.expose(); var openParen = syntaxFromToken({ type: parser.Token.Punctuator, value: stx$2.token.value[0], range: stx$2.token.startRange, sm_range: typeof stx$2.token.sm_startRange == 'undefined' ? stx$2.token.startRange : stx$2.token.sm_startRange, lineNumber: stx$2.token.startLineNumber, sm_lineNumber: typeof stx$2.token.sm_startLineNumber == 'undefined' ? stx$2.token.startLineNumber : stx$2.token.sm_startLineNumber, lineStart: stx$2.token.startLineStart, sm_lineStart: typeof stx$2.token.sm_startLineStart == 'undefined' ? stx$2.token.startLineStart : stx$2.token.sm_startLineStart }, exposed); var closeParen = syntaxFromToken({ type: parser.Token.Punctuator, value: stx$2.token.value[1], range: stx$2.token.endRange, sm_range: typeof stx$2.token.sm_endRange == 'undefined' ? stx$2.token.endRange : stx$2.token.sm_endRange, lineNumber: stx$2.token.endLineNumber, sm_lineNumber: typeof stx$2.token.sm_endLineNumber == 'undefined' ? stx$2.token.endLineNumber : stx$2.token.sm_endLineNumber, lineStart: stx$2.token.endLineStart, sm_lineStart: typeof stx$2.token.sm_endLineStart == 'undefined' ? stx$2.token.endLineStart : stx$2.token.sm_endLineStart }, exposed); if (stx$2.token.leadingComments) { openParen.token.leadingComments = stx$2.token.leadingComments; } if (stx$2.token.trailingComments) { openParen.token.trailingComments = stx$2.token.trailingComments; } acc.push(openParen); push.apply(acc, flatten(exposed.token.inner)); acc.push(closeParen); return acc; } stx$2.token.sm_lineNumber = stx$2.token.sm_lineNumber ? stx$2.token.sm_lineNumber : stx$2.token.lineNumber; stx$2.token.sm_lineStart = stx$2.token.sm_lineStart ? stx$2.token.sm_lineStart : stx$2.token.lineStart; stx$2.token.sm_range = stx$2.token.sm_range ? stx$2.token.sm_range : stx$2.token.range; acc.push(stx$2); return acc; }, []); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parse(tree, depth) {\n if (Array.isArray(tree)) {\n return tree.map(node => this.parse(node, depth + 1)).join('');\n\n } else if(isProperty(tree)) {\n return this.addComment(tree, depth) + this.parseProperty(tree, depth);\n\n } else if (isExprStatement(tree)) {\n ...
[ "0.59107566", "0.5872243", "0.5872243", "0.5872243", "0.5872243", "0.58146274", "0.57734203", "0.57732946", "0.57018226", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031", "0.5692031"...
0.5716143
8
Create sorting function for companies.
function compare(a,b) { if (a.name < b.name) return -1; if (a.name > b.name) return 1; return 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sortByFunc() {\n switch (sortBy.field) {\n case 'name':\n case 'ticker':\n if (sortBy.desc === 0) {\n return (a, b) => a[sortBy.field].localeCompare(b[sortBy.field])\n }\n return (a, b) => b[sortBy.field].localeCo...
[ "0.7149059", "0.6557632", "0.6550187", "0.6485365", "0.6314142", "0.6288456", "0.61877185", "0.6148073", "0.6117516", "0.6109166", "0.6103078", "0.6088733", "0.6086583", "0.6071376", "0.6071376", "0.6070496", "0.6063526", "0.6044142", "0.6018052", "0.59916425", "0.59916425", ...
0.0
-1
Returns the chosen companies on the form saved in the database
function chosenCompaniesDBFormat() { var dbFormatted = []; for(var i = 0; i < vm.chosenCompanies.length; i++) { dbFormatted.push({ name: vm.chosenCompanies[i].name, order: i + 1 }); } return dbFormatted; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadCompanies (companiesArray) {\n var companyForm = $(\"#company-selector\");\n \n for (company in companiesArray) {\n var currentCompany = companiesArray[company];\n companyForm.append(\"<g id=\\\"\" + currentCompany + \"-input\\\"><input type=\\\"checkbox\\\" ...
[ "0.66696525", "0.6437553", "0.6254415", "0.6245486", "0.619275", "0.6122468", "0.6101526", "0.5973255", "0.59573966", "0.5943225", "0.59382606", "0.5924111", "0.58607835", "0.5823227", "0.580402", "0.5785306", "0.576226", "0.5759443", "0.57576954", "0.57321566", "0.5704849", ...
0.6045522
7
Update user with saved applicationinformation
function updateUserProfile(){ if(vm.user){ // Update user data. vm.user.firstName = vm.firstname; vm.user.lastName = vm.lastname; vm.user.displayName = vm.firstname + ' ' + vm.lastname; vm.user.program = vm.taskapplication.program; vm.user.email = vm.taskapplication.email; vm.user.phone = vm.taskapplication.phone; vm.user.foodpref = vm.taskapplication.foodpref; var myUser = new Users(vm.user); myUser.$update(successCallbackUser, errorCallback); } else { successCallbackUser(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function pageUpdateAccount(){\n $(\"#update-name\").val(appUser.get('name'));\n $(\"#update-email\").val(appUser.get('email'));\n $(\"#update-username\").val(appUser.get('username'));\n }", "function setAppboyUser() {\n // get email and create user ids and such\n var emailAddress = document.getEl...
[ "0.69442725", "0.6867636", "0.6736739", "0.6719616", "0.66935664", "0.6674543", "0.6638821", "0.65680075", "0.6558019", "0.6550844", "0.65458006", "0.6530127", "0.6527179", "0.65117365", "0.65002155", "0.6477286", "0.64739716", "0.6472656", "0.6425882", "0.6357921", "0.635792...
0.6583185
7
a boolean and be case insensitive. The string can contains any char.
function XO(str) { const totalX = str.toLowerCase().split('').reduce((acc, value) => (value === 'x' ? acc + 1 : acc), 0); const totalO = str.toLowerCase().split('').reduce((acc, value) => (value === 'o' ? acc + 1 : acc), 0); return totalX === totalO; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "isCaseInsensitive() {\n return !!this._options['case-insensitive'];\n }", "function containsLowerCase(s) {\n return s != s.toUpperCase();\n}", "function isLowerCase(str) {\n return str == str.toLowerCase() && str != str.toUpperCase();\n}", "function stringToBoolean(s) {\n return [\"true\", \"yes...
[ "0.76494443", "0.6941879", "0.65839875", "0.6555828", "0.65389866", "0.64995146", "0.6443363", "0.6411372", "0.6316925", "0.6304686", "0.6303066", "0.6291031", "0.62662494", "0.6250397", "0.6243185", "0.62136304", "0.6212543", "0.6156964", "0.61505324", "0.61498666", "0.61406...
0.0
-1
validate entry, allow only numbers
function validate (current) { if (!(current.value < 48 || current.value > 57)) current.value = ""; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onlyNumbers(field) {\n if (/^\\d+$/.test(field.value)) {\n setValid(field);\n return true;\n } else {\n setInvalid(field, `${field.name} must contain only numbers`);\n return false;\n }\n}", "function allowNumbersOnly(e) {\n var code = (e.which) ? e.which : e.keyC...
[ "0.7542367", "0.748257", "0.7359254", "0.7359254", "0.732935", "0.73116314", "0.7302182", "0.7287616", "0.7269143", "0.7269143", "0.72665465", "0.7264134", "0.72529995", "0.72380006", "0.7234974", "0.7233162", "0.72225624", "0.7216284", "0.71797556", "0.71522415", "0.7141693"...
0.6794155
74
go to next input automatically
function autoTab (current, to) { if (current.getAttribute && current.value.length == current.getAttribute("maxlength")) to.focus(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function nextFormElement() {\n var fields = $('body').find('button,input,textarea,select'),\n index = fields.index($input);\n if (index > -1 && (index + 1) < fields.length) {\n fields.eq(index + 1).focus();\n }\n retu...
[ "0.7158232", "0.6924998", "0.6916781", "0.6840955", "0.67943424", "0.6739984", "0.6660193", "0.66356444", "0.6630864", "0.65571374", "0.6490272", "0.64664644", "0.6455121", "0.6360299", "0.6325571", "0.63036615", "0.6299922", "0.62558025", "0.6210101", "0.62033707", "0.619187...
0.0
-1
get CEP from input
function getCep() { let cep = ""; for (let i=1; i<=8; i++) cep += document.getElementById(`cep-input${i}`).value; return cep; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function CPF(CPF) {\n const result = formatCPF(CPF);\n if (result === '') {\n errors.invalidCPF(CPF);\n }\n\n return result;\n}", "function enq_get_pc(){\r\n\treturn enq_rc('enqp');\r\n}", "function Pc() {\n this.make = \"Dell\",\n this.model = \"Latitude 7640\"\n}", "Ec(){\r\n return 57*Math...
[ "0.5502982", "0.5222779", "0.511648", "0.5097086", "0.50962514", "0.50859517", "0.5083474", "0.5047004", "0.50427216", "0.5002002", "0.49791813", "0.49726874", "0.4941351", "0.49171612", "0.49171612", "0.48958528", "0.48808542", "0.48585698", "0.48398226", "0.48071763", "0.47...
0.61347467
0
End of document ready //////////// Helper functions Check to see if current url in tab is supported against list of supported sites. Then render status as accordingly. Each site will be treated individually until it has been shown otherwise.
function renderStatus(url, tabs) { var host = url.match(/^(.*?:\/{2,3})?(.+?)(\/|$)/)[2]; var result = $.grep(supported_sites, function (elem) { return elem.url === host; }); if (result.length == 0) { $("#siteStatus") .text("Current site not supported") .addClass("notSupported"); } else if (result.length == 1) { var siteObj = result[0]; // Get specific siteObject from supported_sites switch (siteObj.name) { case "Office Ally": case "Office Ally Demo": case "United Health Care Dev": case "United Health Care": enableForm(); showOAOptions(tabs[0].id); $("#siteStatus") .text(siteObj.name + " is supported!") .addClass("supported"); $("#fillForm").on("click", function () { fillFormHandler(siteObj, tabs[0].id); }); // Submit form after hitting enter $("#datesForm").keydown(function (event) { if (event.which == 13) { event.preventDefault(); fillFormHandler(siteObj, tabs[0].id); } }); $("#undoForm") .prop("disabled", false) .on("click", function () { chrome.tabs.sendMessage( tabs[0].id, { message: "undoForm", siteObj: JSON.stringify(siteObj), }, function (response) { ResponseHandler(response); } ); }); chrome.tabs.sendMessage( tabs[0].id, { message: "getDiagnoses", siteName: siteObj.name }, function (diagObj) { if (diagObj) { if (diagObj.length > 4) { $("#statusBarMsg") .text( "More than 4 diagnoses detected. Column 24.E will not be filled due to site limitations." ) .addClass("warning"); return; } $("#statusBarMsg") .text( diagObj.length + " diagnosis code(s) detected, Enter CPT Codes." ) .addClass("supported"); } else { $("#statusBarMsg").text( "No diagnosis detected in section 21. You will enter diagnosis pointers manually for each row." ); } } ); break; default: $("#siteStatus") .text(siteObj.name + " is not yet supported") .addClass("notSupported"); break; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function siteIsSupported() {\n // Check if the site is supported then set top bar\n return !!supportedSites.find(function (s) { return !!location.host.match(s.host); });\n}", "function checkCurrentUrlAdded(){\n\t\n\tgetCurrentUrl(function(currentUrl){\n\t\t\n\t\tif(domains.indexOf(currentUrl)==-1){\n\t\t\t...
[ "0.6739667", "0.6406322", "0.62774795", "0.6115601", "0.6068798", "0.6045893", "0.6015041", "0.5995952", "0.59887606", "0.596339", "0.5937359", "0.5906672", "0.58229846", "0.5817317", "0.58070564", "0.578137", "0.57801634", "0.5776091", "0.57722765", "0.57716405", "0.57697797...
0.77683234
0
Load selectors to match Quick Claim form input into site form. Pass in the detected site object then get the predefined selectors and make use of them. Get number of diagnosis codes entered in native site
function getObjLength(diagObjString) { var count = 0; diagObj = JSON.parse(diagObjString); for (p in diagObj) { count += 1; } return count; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parse_hpsm_fields() {\n var arr = document.querySelectorAll(\".x-tab-panel-body .x-panel.x-panel-noborder\");\n for (var i=0; i < arr.length; i++) {\n if(arr[i].id.substring(0, 3) == \"ext\") {\n if(arr[i].className.indexOf('x-hide-nosize') == -1){\n ...
[ "0.5382703", "0.5172645", "0.5065163", "0.49346924", "0.48996794", "0.48668793", "0.48654985", "0.4816717", "0.4798568", "0.4760419", "0.4757643", "0.4745863", "0.47445166", "0.47421628", "0.4725101", "0.47023365", "0.46835566", "0.46762025", "0.46661854", "0.46553585", "0.46...
0.0
-1
Retrieve input data from user Quick Claim form
function getUserInput(siteObj) { var cptValues = $("#cptForm").serializeArray(); var datesValues = $("#datesForm").serializeArray(); var cptObjects = {}; var datesArray = []; for (var i = 0; i < 6; i++) { var tempObj = {}; if (cptValues[i].value) { // Check if user input cpt is in profile saved cpt via store.js var cptObj = store.get("cpt" + cptValues[i].value); if (cptObj) { tempObj = objectTrimmer(cptObj); } cptObjects["cpt" + cptValues[i].value] = tempObj; } } for (var i = 0; i < 15; i++) { if (datesValues[i].value) { datesArray.push(datesValues[i].value); } } var rowsRequired = Object.keys(cptObjects).length * datesArray.length; if (rowsRequired > siteObj.maxRows) { $("#statusBarMsg") .text("Row limit exeeded. Further rows will not be added.") .addClass("warning"); } var claimObj = { cpts: cptObjects, dates: datesArray, rows: rowsRequired }; return claimObj; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function get_claims_info()\n{\n //fade_in_loader_and_fade_out_form(\"loader\", \"stats_info\"); \n var bearer = \"Bearer \" + localStorage.getItem(\"access_token\"); \n send_restapi_request_to_server_from_form(\"get\", api_get_claims_url, bearer, \"\", \"json\", get_claims_info_success_response_function...
[ "0.5989421", "0.5983287", "0.5950469", "0.5925524", "0.58773524", "0.5843522", "0.5782031", "0.5744509", "0.57331765", "0.56285876", "0.5588915", "0.5582396", "0.555861", "0.5549467", "0.5530008", "0.55252934", "0.5504572", "0.5491119", "0.54569095", "0.54476523", "0.5426303"...
0.0
-1
Pass the data required and let content.js handle how to input data and if rows need to be added or subtracted since it has access to the actual number of rows in the site DOM. Will also need to pass saved cpt info.
function fillFormHandler(siteObj, tabId) { var claimObj = getUserInput(siteObj); chrome.tabs.sendMessage( tabId, { message: "fillForm", siteObj: JSON.stringify(siteObj), claimObj: JSON.stringify(claimObj), }, function (response) { ResponseHandler(response); } ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadContent() {\r\n var contentsStored = localStorage.getItem('contents');\r\n if (contentsStored) {\r\n contents = JSON.parse(contentsStored);\r\n $.each(contents, function (index, content) {\r\n var row = $('<tr>');\r\n var html = '<td>' ...
[ "0.6060781", "0.59772605", "0.59444344", "0.5851095", "0.5725794", "0.5696893", "0.5666809", "0.5634667", "0.56222713", "0.5585665", "0.5485791", "0.5483372", "0.54724514", "0.5434234", "0.54341686", "0.5424243", "0.54157287", "0.5407757", "0.5403134", "0.537869", "0.5377995"...
0.0
-1
Removes empty properties from object and returns new object with occupied properties Disabling this for now, easier to work with objects with empty properties than to test for properties
function objectTrimmer(o) { j = {}; for (p in o) { if (o[p]) { j[p] = o[p]; } } return j; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cleanObject(obj) {\n const result = Object.assign(obj)\n for (const propName in result) {\n if (result[propName] === null || result[propName] === undefined) {\n delete result[propName];\n }\n }\n\n return result\n}", "function purgeEmptyFields(obj) {\n Object.keys(obj).forEach(key => {\n...
[ "0.67853415", "0.67459047", "0.6604225", "0.6583351", "0.6503944", "0.6476513", "0.6452959", "0.6398747", "0.63503855", "0.6339403", "0.63083804", "0.63070136", "0.6280458", "0.62798095", "0.62455827", "0.6212427", "0.6212427", "0.61969453", "0.61932194", "0.6159141", "0.6158...
0.0
-1
When the form is submitted, use the API.saveBook method to save the book data Then reload books from the database
function addBook(book) { setLoading(true); setVisible(true); API.saveBook(book) .then(res => { setLoading(false); }) .catch(err => { setLoading(false); setError(true); console.log(err); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function setupBookForm() {\n\n\t$('form').submit(event => {\n\t\t\n\t\tconsole.log(\"Form submitted\");\n\t\tevent.preventDefault(); // prevents default form behaviour (reloads the page)\n\n\t\tconst book = {\n\t\t\ttitle: $('#title').val(),\n\t\t\tauthor: $('#author').val(),\n\t\t\tnumPages: parseInt($('#pages')....
[ "0.77916396", "0.75272894", "0.7506747", "0.7442989", "0.73871773", "0.7373677", "0.73676205", "0.7308689", "0.7187482", "0.7170315", "0.7122147", "0.6948661", "0.6941686", "0.6914476", "0.688373", "0.68745273", "0.68709236", "0.6798974", "0.6782425", "0.67492574", "0.6721678...
0.6462441
40
Search bookwhen search button is clicked, the searchBook axios function is called
function searchBook(e) { e.preventDefault(); API.searchBook({searchRequest:searchTerm}) .then(res => { setBooks(res.data); }) .catch(err => { console.log(err); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleBookSearch () {\n // console.log(\"googleKey\", googleKey);\n axios.get(\"https://www.googleapis.com/books/v1/volumes?q=intitle:\" + book + \"&key=\" + googleKey + \"&maxResults=40\")\n .then(data => {\n const result = data.data.items[0];\n setResults(result);\n setLoad(true)...
[ "0.80293226", "0.78242433", "0.7710823", "0.7531888", "0.732654", "0.7155331", "0.7145036", "0.7118016", "0.71113783", "0.7004863", "0.69973826", "0.6993979", "0.6958667", "0.69534", "0.692687", "0.6922229", "0.6920562", "0.69113564", "0.6908385", "0.6897781", "0.68962806", ...
0.8781384
0
Returns a boolean if the list is empty or not
isEmpty() { return this.head == null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "isEmpty() {\n return this._list.length == 0 ? true : false;\n }", "isEmpty() {\n return this.list.length === 0;\n }", "isEmpty() {\n\t\treturn this.items.length === 0;\n\t}", "isEmpty() {\n\t\treturn this.items == 0;\n\t}", "isEmpty() {\n\t\treturn this.items.isEmpty();\n\t}", "function isEmpty(l...
[ "0.8775787", "0.84373957", "0.8101944", "0.80702233", "0.79909503", "0.7913101", "0.7898488", "0.78753054", "0.78437", "0.7834908", "0.78166986", "0.7798622", "0.7787578", "0.77678066", "0.7734837", "0.7734568", "0.7722334", "0.77094054", "0.7707432", "0.7706778", "0.77016026...
0.74802655
36
Returns the size of the list
size() { return this.length; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function length() {\n\treturn this.listSize;\n}", "sizeOfList() {\r\n\t\treturn this.size;\r\n\t}", "sizeOfList() {\n return this.size;\n }", "sizeOfList() {\n return this.size;\n }", "function listLength(){\n return list.length;\n}", "size_of_list() {\n console.log(_size);\n ...
[ "0.8625435", "0.8377767", "0.82152945", "0.82152945", "0.820825", "0.82018113", "0.81429094", "0.8127189", "0.80983436", "0.80377424", "0.8025926", "0.8000182", "0.7976032", "0.7887398", "0.7873033", "0.77376676", "0.77184117", "0.7716017", "0.77030385", "0.7669951", "0.76699...
0.0
-1
Adds an object to the end of the list Returns true if the object is added successfully
add(object) { let newLink = new Link(object); if(this.isEmpty()) this.head = newLink; else { this.tail.next = newLink; newLink.prev = this.tail; } this.tail = newLink; this.length++; return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "addLast(object) {\n let newLink = new Link(object);\n if(this.isEmpty()) \n this.head = newLink;\n else {\n this.tail.next = newLink;\n newLink.prev = this.tail;\n }\n this.tail = newLink;\n this.length++;\n return true;\n }", "...
[ "0.7072153", "0.6905208", "0.6696507", "0.6610833", "0.65806806", "0.65022784", "0.64733577", "0.6449853", "0.63729787", "0.63306546", "0.63013434", "0.6221054", "0.6204332", "0.61923397", "0.6178056", "0.61680704", "0.6109896", "0.6109336", "0.60723406", "0.60541624", "0.605...
0.70558774
1
Adds an object to the front of the list Returns true if the object is added successfully
addFirst(object) { let newLink = new Link(object); if(this.isEmpty()) this.tail = newLink; else this.head.prev = newLink; newLink.next = this.head; this.head = newLink; this.length++; return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addObjectInList(list, object) {\n if (object) {\n list.push(object);\n }\n }", "add(element) {\n if (!this.has(element)) {\n this.collection.push(element)\n return true\n }\n return false\n }", "add(object) {\n let newLink = new Link(object);\n if(...
[ "0.6551418", "0.6483231", "0.6383406", "0.63541275", "0.6135264", "0.6091673", "0.6063098", "0.60403967", "0.60127825", "0.5966089", "0.59324896", "0.592034", "0.5907519", "0.59066945", "0.5905003", "0.58957547", "0.58876604", "0.5881739", "0.5881193", "0.5865925", "0.5844874...
0.68832463
0
Adds an object to the end of the list Returns true if the object is added successfully
addLast(object) { let newLink = new Link(object); if(this.isEmpty()) this.head = newLink; else { this.tail.next = newLink; newLink.prev = this.tail; } this.tail = newLink; this.length++; return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "add(object) {\n let newLink = new Link(object);\n if(this.isEmpty()) \n this.head = newLink;\n else {\n this.tail.next = newLink;\n newLink.prev = this.tail;\n }\n this.tail = newLink;\n this.length++;\n return true;\n }", "add(...
[ "0.7055321", "0.6906338", "0.6696683", "0.66108924", "0.6579725", "0.6502238", "0.647387", "0.6449675", "0.63728106", "0.6330283", "0.6301664", "0.62215346", "0.62051207", "0.61926144", "0.6178815", "0.6167984", "0.6110496", "0.61093026", "0.607326", "0.60541385", "0.6051252"...
0.7070671
0