repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
OpenF2/F2 | sdk/src/third-party/easyXDM/easyXDM.js | _send | function _send(data){
data.jsonrpc = "2.0";
pub.down.outgoing(serializer.stringify(data));
} | javascript | function _send(data){
data.jsonrpc = "2.0";
pub.down.outgoing(serializer.stringify(data));
} | [
"function",
"_send",
"(",
"data",
")",
"{",
"data",
".",
"jsonrpc",
"=",
"\"2.0\"",
";",
"pub",
".",
"down",
".",
"outgoing",
"(",
"serializer",
".",
"stringify",
"(",
"data",
")",
")",
";",
"}"
] | Serializes and sends the message
@private
@param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added. | [
"Serializes",
"and",
"sends",
"the",
"message"
] | 6e1e554e29b622f7007292a3e2a35feeb22f2b27 | https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L2420-L2423 | train |
OpenF2/F2 | sdk/src/third-party/easyXDM/easyXDM.js | _createMethod | function _createMethod(definition, method){
var slice = Array.prototype.slice;
return function(){
var l = arguments.length, callback, message = {
method: method
};
if (l > 0 && typeof arguments[l - 1] === "function") {
... | javascript | function _createMethod(definition, method){
var slice = Array.prototype.slice;
return function(){
var l = arguments.length, callback, message = {
method: method
};
if (l > 0 && typeof arguments[l - 1] === "function") {
... | [
"function",
"_createMethod",
"(",
"definition",
",",
"method",
")",
"{",
"var",
"slice",
"=",
"Array",
".",
"prototype",
".",
"slice",
";",
"return",
"function",
"(",
")",
"{",
"var",
"l",
"=",
"arguments",
".",
"length",
",",
"callback",
",",
"message",... | Creates a method that implements the given definition
@private
@param {Object} The method configuration
@param {String} method The name of the method
@return {Function} A stub capable of proxying the requested method call | [
"Creates",
"a",
"method",
"that",
"implements",
"the",
"given",
"definition"
] | 6e1e554e29b622f7007292a3e2a35feeb22f2b27 | https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L2432-L2470 | train |
OpenF2/F2 | sdk/src/third-party/easyXDM/easyXDM.js | _executeMethod | function _executeMethod(method, id, fn, params){
if (!fn) {
if (id) {
_send({
id: id,
error: {
code: -32601,
message: "Procedure not found."
}
});
}... | javascript | function _executeMethod(method, id, fn, params){
if (!fn) {
if (id) {
_send({
id: id,
error: {
code: -32601,
message: "Procedure not found."
}
});
}... | [
"function",
"_executeMethod",
"(",
"method",
",",
"id",
",",
"fn",
",",
"params",
")",
"{",
"if",
"(",
"!",
"fn",
")",
"{",
"if",
"(",
"id",
")",
"{",
"_send",
"(",
"{",
"id",
":",
"id",
",",
"error",
":",
"{",
"code",
":",
"-",
"32601",
",",... | Executes the exposed method
@private
@param {String} method The name of the method
@param {Number} id The callback id to use
@param {Function} method The exposed implementation
@param {Array} params The parameters supplied by the remote end | [
"Executes",
"the",
"exposed",
"method"
] | 6e1e554e29b622f7007292a3e2a35feeb22f2b27 | https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L2480-L2534 | train |
OpenF2/F2 | dist/f2.debug.js | function(instanceId) {
if (_apps[instanceId] && _apps[instanceId].socket) {
_apps[instanceId].socket.destroy();
}
delete _apps[instanceId];
} | javascript | function(instanceId) {
if (_apps[instanceId] && _apps[instanceId].socket) {
_apps[instanceId].socket.destroy();
}
delete _apps[instanceId];
} | [
"function",
"(",
"instanceId",
")",
"{",
"if",
"(",
"_apps",
"[",
"instanceId",
"]",
"&&",
"_apps",
"[",
"instanceId",
"]",
".",
"socket",
")",
"{",
"_apps",
"[",
"instanceId",
"]",
".",
"socket",
".",
"destroy",
"(",
")",
";",
"}",
"delete",
"_apps"... | Cleans up a given app instance
@method destroy
@param {string} instanceId The Instance ID | [
"Cleans",
"up",
"a",
"given",
"app",
"instance"
] | 6e1e554e29b622f7007292a3e2a35feeb22f2b27 | https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.debug.js#L17070-L17075 | train | |
OpenF2/F2 | dist/f2.debug.js | function(instanceId) {
if (!_isInit()) {
F2.log('F2.init() must be called before F2.removeApp()');
return;
}
if (_apps[instanceId]) {
F2.AppHandlers.__trigger(
_sAppHandlerToken,
F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
_apps[instanceId] // the app instance
);
F2.AppHa... | javascript | function(instanceId) {
if (!_isInit()) {
F2.log('F2.init() must be called before F2.removeApp()');
return;
}
if (_apps[instanceId]) {
F2.AppHandlers.__trigger(
_sAppHandlerToken,
F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
_apps[instanceId] // the app instance
);
F2.AppHa... | [
"function",
"(",
"instanceId",
")",
"{",
"if",
"(",
"!",
"_isInit",
"(",
")",
")",
"{",
"F2",
".",
"log",
"(",
"'F2.init() must be called before F2.removeApp()'",
")",
";",
"return",
";",
"}",
"if",
"(",
"_apps",
"[",
"instanceId",
"]",
")",
"{",
"F2",
... | Removes an app from the container
@method removeApp
@param {string} instanceId The app's instanceId | [
"Removes",
"an",
"app",
"from",
"the",
"container"
] | 6e1e554e29b622f7007292a3e2a35feeb22f2b27 | https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.debug.js#L18725-L18757 | train | |
dasmoth/dalliance | js/bam.js | parseBamHeader | function parseBamHeader(r) {
if (!r) {
return callback(null, "Couldn't access BAM");
}
var unc = unbgzf(r, r.byteLength);
var uncba = new Uint8Array(unc);
var magic = readInt(uncba, 0);
if (magic != BAM_MAGIC) {
return callback(null, "Not a BAM f... | javascript | function parseBamHeader(r) {
if (!r) {
return callback(null, "Couldn't access BAM");
}
var unc = unbgzf(r, r.byteLength);
var uncba = new Uint8Array(unc);
var magic = readInt(uncba, 0);
if (magic != BAM_MAGIC) {
return callback(null, "Not a BAM f... | [
"function",
"parseBamHeader",
"(",
"r",
")",
"{",
"if",
"(",
"!",
"r",
")",
"{",
"return",
"callback",
"(",
"null",
",",
"\"Couldn't access BAM\"",
")",
";",
"}",
"var",
"unc",
"=",
"unbgzf",
"(",
"r",
",",
"r",
".",
"byteLength",
")",
";",
"var",
... | Fills out bam.chrToIndex and bam.indexToChr based on the first few bytes of the BAM. | [
"Fills",
"out",
"bam",
".",
"chrToIndex",
"and",
"bam",
".",
"indexToChr",
"based",
"on",
"the",
"first",
"few",
"bytes",
"of",
"the",
"BAM",
"."
] | 64565abc974433a5dcd5406d17fa0a202e1e55fc | https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/bam.js#L111-L155 | train |
dasmoth/dalliance | js/twoBit.js | function() {
while (i < tb.seqCount) {
var ns = ba[p];
if (p + ns + 2 + (tb.version == 0 ? 4 : 8) >= ba.length) {
headerBlocksFetched += headerBlockSize;
headerBlockSize = Math.max(HEADER_BLOCK_SIZE,Math.floor(headerBlocksFetched*tb.seq... | javascript | function() {
while (i < tb.seqCount) {
var ns = ba[p];
if (p + ns + 2 + (tb.version == 0 ? 4 : 8) >= ba.length) {
headerBlocksFetched += headerBlockSize;
headerBlockSize = Math.max(HEADER_BLOCK_SIZE,Math.floor(headerBlocksFetched*tb.seq... | [
"function",
"(",
")",
"{",
"while",
"(",
"i",
"<",
"tb",
".",
"seqCount",
")",
"{",
"var",
"ns",
"=",
"ba",
"[",
"p",
"]",
";",
"if",
"(",
"p",
"+",
"ns",
"+",
"2",
"+",
"(",
"tb",
".",
"version",
"==",
"0",
"?",
"4",
":",
"8",
")",
">=... | Offset of the current block if we need to fetch multiple header blocks. | [
"Offset",
"of",
"the",
"current",
"block",
"if",
"we",
"need",
"to",
"fetch",
"multiple",
"header",
"blocks",
"."
] | 64565abc974433a5dcd5406d17fa0a202e1e55fc | https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/twoBit.js#L65-L95 | train | |
dasmoth/dalliance | js/sample.js | alignSeqUsingCigar | function alignSeqUsingCigar(rawseq, rawquals, cigar) {
var ops = parseCigar(cigar);
var seq = [];
var quals = [];
var cursor = 0;
for (var ci = 0; ci < ops.length; ++ci) {
var co = ops[ci];
if (co.op == 'M') {
seq.push(rawseq.substr(cursor, co.cnt));
quals.pus... | javascript | function alignSeqUsingCigar(rawseq, rawquals, cigar) {
var ops = parseCigar(cigar);
var seq = [];
var quals = [];
var cursor = 0;
for (var ci = 0; ci < ops.length; ++ci) {
var co = ops[ci];
if (co.op == 'M') {
seq.push(rawseq.substr(cursor, co.cnt));
quals.pus... | [
"function",
"alignSeqUsingCigar",
"(",
"rawseq",
",",
"rawquals",
",",
"cigar",
")",
"{",
"var",
"ops",
"=",
"parseCigar",
"(",
"cigar",
")",
";",
"var",
"seq",
"=",
"[",
"]",
";",
"var",
"quals",
"=",
"[",
"]",
";",
"var",
"cursor",
"=",
"0",
";",... | Generates an aligned read from the raw sequence of a BAM record
using given cigar string.
Params:
rawseq: unaligned read sequence from Bam record
rawquals: unaligned read quals from Bam record
cigar: Bam cigar string from Bam record
Returns an object with 2 properties:
seq: string containing aligned read
quals: strin... | [
"Generates",
"an",
"aligned",
"read",
"from",
"the",
"raw",
"sequence",
"of",
"a",
"BAM",
"record",
"using",
"given",
"cigar",
"string",
"."
] | 64565abc974433a5dcd5406d17fa0a202e1e55fc | https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/sample.js#L279-L305 | train |
dasmoth/dalliance | js/sample.js | getRefSeq | function getRefSeq(currentSequence, min, max) {
var refSeq = [];
if (currentSequence) {
var csStart = currentSequence.start|0;
var csEnd = currentSequence.end|0;
if (csStart <= max && csEnd >= min) {
var sfMin = Math.max(min, csStart);
var sfMax = Math.min(max, cs... | javascript | function getRefSeq(currentSequence, min, max) {
var refSeq = [];
if (currentSequence) {
var csStart = currentSequence.start|0;
var csEnd = currentSequence.end|0;
if (csStart <= max && csEnd >= min) {
var sfMin = Math.max(min, csStart);
var sfMax = Math.min(max, cs... | [
"function",
"getRefSeq",
"(",
"currentSequence",
",",
"min",
",",
"max",
")",
"{",
"var",
"refSeq",
"=",
"[",
"]",
";",
"if",
"(",
"currentSequence",
")",
"{",
"var",
"csStart",
"=",
"currentSequence",
".",
"start",
"|",
"0",
";",
"var",
"csEnd",
"=",
... | Constructs the reference sequence for a given window.
Params
currentSequence: DasSequence object containing ref sequence
in current browser view.
min, max: min and max position for window.
Returns a string containing the refseq, padded with 'N' where sequence is not
available. | [
"Constructs",
"the",
"reference",
"sequence",
"for",
"a",
"given",
"window",
"."
] | 64565abc974433a5dcd5406d17fa0a202e1e55fc | https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/sample.js#L317-L334 | train |
ArnaudValensi/node-jsencrypt | index.js | function () {
if ((i = x.getLowestSetBit()) > 0) {
x.rShiftTo(i, x);
}
if ((i = y.getLowestSetBit()) > 0) {
y.rShiftTo(i, y);
}
if (x.compareTo(y) >= 0) {
x.subTo(y, x);
... | javascript | function () {
if ((i = x.getLowestSetBit()) > 0) {
x.rShiftTo(i, x);
}
if ((i = y.getLowestSetBit()) > 0) {
y.rShiftTo(i, y);
}
if (x.compareTo(y) >= 0) {
x.subTo(y, x);
... | [
"function",
"(",
")",
"{",
"if",
"(",
"(",
"i",
"=",
"x",
".",
"getLowestSetBit",
"(",
")",
")",
">",
"0",
")",
"{",
"x",
".",
"rShiftTo",
"(",
"i",
",",
"x",
")",
";",
"}",
"if",
"(",
"(",
"i",
"=",
"y",
".",
"getLowestSetBit",
"(",
")",
... | Workhorse of the algorithm, gets called 200 - 800 times per 512 bit keygen. | [
"Workhorse",
"of",
"the",
"algorithm",
"gets",
"called",
"200",
"-",
"800",
"times",
"per",
"512",
"bit",
"keygen",
"."
] | ddea7f3a5ac4635bd462327f0005caba10cc0870 | https://github.com/ArnaudValensi/node-jsencrypt/blob/ddea7f3a5ac4635bd462327f0005caba10cc0870/index.js#L2514-L2536 | train | |
ArnaudValensi/node-jsencrypt | index.js | b64tohex | function b64tohex(s) {
var ret = ""
var i;
var k = 0; // b64 state, 0-3
var slop;
for (i = 0; i < s.length; ++i) {
if (s.charAt(i) == b64pad) break;
v = b64map.indexOf(s.charAt(i));
if (v < 0) continue;
if (k == 0) {
... | javascript | function b64tohex(s) {
var ret = ""
var i;
var k = 0; // b64 state, 0-3
var slop;
for (i = 0; i < s.length; ++i) {
if (s.charAt(i) == b64pad) break;
v = b64map.indexOf(s.charAt(i));
if (v < 0) continue;
if (k == 0) {
... | [
"function",
"b64tohex",
"(",
"s",
")",
"{",
"var",
"ret",
"=",
"\"\"",
"var",
"i",
";",
"var",
"k",
"=",
"0",
";",
"// b64 state, 0-3",
"var",
"slop",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"s",
".",
"length",
";",
"++",
"i",
")",
"{"... | convert a base64 string to hex | [
"convert",
"a",
"base64",
"string",
"to",
"hex"
] | ddea7f3a5ac4635bd462327f0005caba10cc0870 | https://github.com/ArnaudValensi/node-jsencrypt/blob/ddea7f3a5ac4635bd462327f0005caba10cc0870/index.js#L2603-L2637 | train |
ArnaudValensi/node-jsencrypt | index.js | function (key) {
// Call the super constructor.
RSAKey.call(this);
// If a key key was provided.
if (key) {
// If this is a string...
if (typeof key === 'string') {
this.parseKey(key);
}
else if (
this.hasPri... | javascript | function (key) {
// Call the super constructor.
RSAKey.call(this);
// If a key key was provided.
if (key) {
// If this is a string...
if (typeof key === 'string') {
this.parseKey(key);
}
else if (
this.hasPri... | [
"function",
"(",
"key",
")",
"{",
"// Call the super constructor.",
"RSAKey",
".",
"call",
"(",
"this",
")",
";",
"// If a key key was provided.",
"if",
"(",
"key",
")",
"{",
"// If this is a string...",
"if",
"(",
"typeof",
"key",
"===",
"'string'",
")",
"{",
... | Create a new JSEncryptRSAKey that extends Tom Wu's RSA key object.
This object is just a decorator for parsing the key parameter
@param {string|Object} key - The key in string format, or an object containing
the parameters needed to build a RSAKey object.
@constructor | [
"Create",
"a",
"new",
"JSEncryptRSAKey",
"that",
"extends",
"Tom",
"Wu",
"s",
"RSA",
"key",
"object",
".",
"This",
"object",
"is",
"just",
"a",
"decorator",
"for",
"parsing",
"the",
"key",
"parameter"
] | ddea7f3a5ac4635bd462327f0005caba10cc0870 | https://github.com/ArnaudValensi/node-jsencrypt/blob/ddea7f3a5ac4635bd462327f0005caba10cc0870/index.js#L4386-L4403 | train | |
dasmoth/dalliance | js/das.js | DASSequence | function DASSequence(name, start, end, alpha, seq) {
this.name = name;
this.start = start;
this.end = end;
this.alphabet = alpha;
this.seq = seq;
} | javascript | function DASSequence(name, start, end, alpha, seq) {
this.name = name;
this.start = start;
this.end = end;
this.alphabet = alpha;
this.seq = seq;
} | [
"function",
"DASSequence",
"(",
"name",
",",
"start",
",",
"end",
",",
"alpha",
",",
"seq",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"start",
"=",
"start",
";",
"this",
".",
"end",
"=",
"end",
";",
"this",
".",
"alphabet",
"=... | DAS 1.6 sequence command Do we need an option to fall back to the dna command? | [
"DAS",
"1",
".",
"6",
"sequence",
"command",
"Do",
"we",
"need",
"an",
"option",
"to",
"fall",
"back",
"to",
"the",
"dna",
"command?"
] | 64565abc974433a5dcd5406d17fa0a202e1e55fc | https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/das.js#L140-L146 | train |
thlorenz/flamegraph | index.js | flamegraph | function flamegraph(arr, opts) {
var profile
if (!Array.isArray(arr)) throw new TypeError('First arg needs to be an array of lines.')
opts = opts || {}
try {
profile = cpuprofilify().convert(arr, opts.profile)
} catch (err) {
// not a valid input to cpuprofilify -- maybe it's an actual cpuprofile alr... | javascript | function flamegraph(arr, opts) {
var profile
if (!Array.isArray(arr)) throw new TypeError('First arg needs to be an array of lines.')
opts = opts || {}
try {
profile = cpuprofilify().convert(arr, opts.profile)
} catch (err) {
// not a valid input to cpuprofilify -- maybe it's an actual cpuprofile alr... | [
"function",
"flamegraph",
"(",
"arr",
",",
"opts",
")",
"{",
"var",
"profile",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"arr",
")",
")",
"throw",
"new",
"TypeError",
"(",
"'First arg needs to be an array of lines.'",
")",
"opts",
"=",
"opts",
"||",
"{... | Converts an array of call graph lines into an svg document.
@name flamegraph
@function
@param {Array.<string>} arr input lines to render svg for
@param {Object} opts objects that affect the visualization
@param {Object} opts.profile options passed to cpuprofilify @see [cpuprofilify.con... | [
"Converts",
"an",
"array",
"of",
"call",
"graph",
"lines",
"into",
"an",
"svg",
"document",
"."
] | 2871eabaef5e8de1941a09077d83d41e24baca85 | https://github.com/thlorenz/flamegraph/blob/2871eabaef5e8de1941a09077d83d41e24baca85/index.js#L43-L62 | train |
thlorenz/flamegraph | from-stream.js | fromStream | function fromStream(stream, opts) {
opts = opts || {}
var out = through()
function ondata(res) {
try {
var svg = flamegraph(res.toString().split('\n'), opts)
out.write(svg)
} catch (err) {
out.emit('error', err)
}
}
// Once memory becomes an issue we need to make this truly str... | javascript | function fromStream(stream, opts) {
opts = opts || {}
var out = through()
function ondata(res) {
try {
var svg = flamegraph(res.toString().split('\n'), opts)
out.write(svg)
} catch (err) {
out.emit('error', err)
}
}
// Once memory becomes an issue we need to make this truly str... | [
"function",
"fromStream",
"(",
"stream",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
"var",
"out",
"=",
"through",
"(",
")",
"function",
"ondata",
"(",
"res",
")",
"{",
"try",
"{",
"var",
"svg",
"=",
"flamegraph",
"(",
"res",
".",
... | Converts a stream of call graph lines into an svg document.
Not truly streaming, concats all lines before processing.
**Example**:
```js
var fromStream = require('flamegraph/from-stream')
fromStream(process.stdin, opts).pipe(process.stdout)
```
@name flamegraph::fromStream
@function
@param {ReadableStream} stream th... | [
"Converts",
"a",
"stream",
"of",
"call",
"graph",
"lines",
"into",
"an",
"svg",
"document",
".",
"Not",
"truly",
"streaming",
"concats",
"all",
"lines",
"before",
"processing",
"."
] | 2871eabaef5e8de1941a09077d83d41e24baca85 | https://github.com/thlorenz/flamegraph/blob/2871eabaef5e8de1941a09077d83d41e24baca85/from-stream.js#L29-L45 | train |
ralucas/node-zillow | lib/helpers.js | httpRequest | function httpRequest(url) {
var deferred = Q.defer();
request(url, function(err, response, body) {
if (err) {
deferred.reject(new Error(err));
} else if (!err && response.statusCode !== 200) {
deferred.reject(new Error(response.statusCode));
} else {
deferred.resolve(bo... | javascript | function httpRequest(url) {
var deferred = Q.defer();
request(url, function(err, response, body) {
if (err) {
deferred.reject(new Error(err));
} else if (!err && response.statusCode !== 200) {
deferred.reject(new Error(response.statusCode));
} else {
deferred.resolve(bo... | [
"function",
"httpRequest",
"(",
"url",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"request",
"(",
"url",
",",
"function",
"(",
"err",
",",
"response",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"deferred",
".",
"r... | Helper function that handles the http request
@param {string} url | [
"Helper",
"function",
"that",
"handles",
"the",
"http",
"request"
] | 236aa710b60fd3713bf1245be163cd64c2045985 | https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L17-L29 | train |
ralucas/node-zillow | lib/helpers.js | toJson | function toJson(xml) {
var deferred = Q.defer();
xml2js.parseString(xml, function(err, result) {
if (err) {
deferred.reject(new Error(err));
} else {
deferred.resolve(result);
}
});
return deferred.promise;
} | javascript | function toJson(xml) {
var deferred = Q.defer();
xml2js.parseString(xml, function(err, result) {
if (err) {
deferred.reject(new Error(err));
} else {
deferred.resolve(result);
}
});
return deferred.promise;
} | [
"function",
"toJson",
"(",
"xml",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"xml2js",
".",
"parseString",
"(",
"xml",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"{",
"deferred",
".",
"re... | Helper function that converts xml to json
@param {xml} xml | [
"Helper",
"function",
"that",
"converts",
"xml",
"to",
"json"
] | 236aa710b60fd3713bf1245be163cd64c2045985 | https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L36-L46 | train |
ralucas/node-zillow | lib/helpers.js | toQueryString | function toQueryString(params, id) {
var paramsString = '';
for (var key in params) {
if (params.hasOwnProperty(key)) {
paramsString += '&' + key + '=' + encodeURIComponent(params[key]);
}
}
return 'zws-id=' + id + paramsString;
} | javascript | function toQueryString(params, id) {
var paramsString = '';
for (var key in params) {
if (params.hasOwnProperty(key)) {
paramsString += '&' + key + '=' + encodeURIComponent(params[key]);
}
}
return 'zws-id=' + id + paramsString;
} | [
"function",
"toQueryString",
"(",
"params",
",",
"id",
")",
"{",
"var",
"paramsString",
"=",
"''",
";",
"for",
"(",
"var",
"key",
"in",
"params",
")",
"{",
"if",
"(",
"params",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"paramsString",
"+=",
"... | Helper function that takes params hash and converts it into query string
@param {object} params
@param {Number} id | [
"Helper",
"function",
"that",
"takes",
"params",
"hash",
"and",
"converts",
"it",
"into",
"query",
"string"
] | 236aa710b60fd3713bf1245be163cd64c2045985 | https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L54-L62 | train |
ralucas/node-zillow | lib/helpers.js | checkParams | function checkParams(params, reqParams) {
if ( reqParams.length < 1 ) {
return;
}
if ( (_.isEmpty(params) || !params) && (reqParams.length > 0) ) {
throw new Error('Missing parameters: ' + reqParams.join(', '));
}
var paramsKeys = _.keys(params);
_.each(reqParams, function(reqPa... | javascript | function checkParams(params, reqParams) {
if ( reqParams.length < 1 ) {
return;
}
if ( (_.isEmpty(params) || !params) && (reqParams.length > 0) ) {
throw new Error('Missing parameters: ' + reqParams.join(', '));
}
var paramsKeys = _.keys(params);
_.each(reqParams, function(reqPa... | [
"function",
"checkParams",
"(",
"params",
",",
"reqParams",
")",
"{",
"if",
"(",
"reqParams",
".",
"length",
"<",
"1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"(",
"_",
".",
"isEmpty",
"(",
"params",
")",
"||",
"!",
"params",
")",
"&&",
"(",
"re... | Helper function that checks for the required params
@param {object} params
@param {array} reqParams -- required parameters | [
"Helper",
"function",
"that",
"checks",
"for",
"the",
"required",
"params"
] | 236aa710b60fd3713bf1245be163cd64c2045985 | https://github.com/ralucas/node-zillow/blob/236aa710b60fd3713bf1245be163cd64c2045985/lib/helpers.js#L70-L86 | train |
gosquared/mmdb-reader | src/Reader.js | Reader | function Reader(buf, filePath) {
// Allow instantiating without `new`
if (!(this instanceof Reader)) {
return new Reader(buf);
}
// Allow passing either a path to a file or a raw buffer
if (typeof buf === 'string') {
filePath = buf;
buf = fs.readFileSync(buf);
}
// LRU cache that'll hold obj... | javascript | function Reader(buf, filePath) {
// Allow instantiating without `new`
if (!(this instanceof Reader)) {
return new Reader(buf);
}
// Allow passing either a path to a file or a raw buffer
if (typeof buf === 'string') {
filePath = buf;
buf = fs.readFileSync(buf);
}
// LRU cache that'll hold obj... | [
"function",
"Reader",
"(",
"buf",
",",
"filePath",
")",
"{",
"// Allow instantiating without `new`",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Reader",
")",
")",
"{",
"return",
"new",
"Reader",
"(",
"buf",
")",
";",
"}",
"// Allow passing either a path to a fi... | Main reader constructor | [
"Main",
"reader",
"constructor"
] | 65adbb40709020a3b13ec5619b83efae75b77a5e | https://github.com/gosquared/mmdb-reader/blob/65adbb40709020a3b13ec5619b83efae75b77a5e/src/Reader.js#L26-L48 | train |
vacuumlabs/data-provider | src/config.js | changeCfgOption | function changeCfgOption(options, key) {
if (expectKey(options, key, typeof cfg[key])) {
cfg[key] = options[key]
}
} | javascript | function changeCfgOption(options, key) {
if (expectKey(options, key, typeof cfg[key])) {
cfg[key] = options[key]
}
} | [
"function",
"changeCfgOption",
"(",
"options",
",",
"key",
")",
"{",
"if",
"(",
"expectKey",
"(",
"options",
",",
"key",
",",
"typeof",
"cfg",
"[",
"key",
"]",
")",
")",
"{",
"cfg",
"[",
"key",
"]",
"=",
"options",
"[",
"key",
"]",
"}",
"}"
] | if supplied options contain given field, override its value in global cfg | [
"if",
"supplied",
"options",
"contain",
"given",
"field",
"override",
"its",
"value",
"in",
"global",
"cfg"
] | 2acbd4698a3d5050dd15d25d023409dee126cc41 | https://github.com/vacuumlabs/data-provider/blob/2acbd4698a3d5050dd15d25d023409dee126cc41/src/config.js#L38-L42 | train |
vacuumlabs/data-provider | src/config.js | expectKey | function expectKey(options, key, type) {
if (key in options) {
if (typeof options[key] === type) {
return true
}
// eslint-disable-next-line no-console
console.warn(`Ignoring options key '${key}' - ` +
`expected type '${type}', received '${typeof options[key]}'`)
}
return false
} | javascript | function expectKey(options, key, type) {
if (key in options) {
if (typeof options[key] === type) {
return true
}
// eslint-disable-next-line no-console
console.warn(`Ignoring options key '${key}' - ` +
`expected type '${type}', received '${typeof options[key]}'`)
}
return false
} | [
"function",
"expectKey",
"(",
"options",
",",
"key",
",",
"type",
")",
"{",
"if",
"(",
"key",
"in",
"options",
")",
"{",
"if",
"(",
"typeof",
"options",
"[",
"key",
"]",
"===",
"type",
")",
"{",
"return",
"true",
"}",
"// eslint-disable-next-line no-cons... | check whether options contain given key and that it is the same type as in cfg | [
"check",
"whether",
"options",
"contain",
"given",
"key",
"and",
"that",
"it",
"is",
"the",
"same",
"type",
"as",
"in",
"cfg"
] | 2acbd4698a3d5050dd15d25d023409dee126cc41 | https://github.com/vacuumlabs/data-provider/blob/2acbd4698a3d5050dd15d25d023409dee126cc41/src/config.js#L45-L55 | train |
kmi/node-red-contrib-noble | noble/node-red-contrib-noble.js | startScan | function startScan(stateChange, error) {
if (!node.scanning) {
// send status message
var msg = {
statusUpdate: true,
error: error,
stateChange: stateChange,
state: noble.state
};
... | javascript | function startScan(stateChange, error) {
if (!node.scanning) {
// send status message
var msg = {
statusUpdate: true,
error: error,
stateChange: stateChange,
state: noble.state
};
... | [
"function",
"startScan",
"(",
"stateChange",
",",
"error",
")",
"{",
"if",
"(",
"!",
"node",
".",
"scanning",
")",
"{",
"// send status message",
"var",
"msg",
"=",
"{",
"statusUpdate",
":",
"true",
",",
"error",
":",
"error",
",",
"stateChange",
":",
"s... | Take care of starting the scan and sending the status message | [
"Take",
"care",
"of",
"starting",
"the",
"scan",
"and",
"sending",
"the",
"status",
"message"
] | 9f30d0928df8e4b432891820c6ff97d4c18f49f4 | https://github.com/kmi/node-red-contrib-noble/blob/9f30d0928df8e4b432891820c6ff97d4c18f49f4/noble/node-red-contrib-noble.js#L90-L107 | train |
kmi/node-red-contrib-noble | noble/node-red-contrib-noble.js | stopScan | function stopScan(stateChange, error) {
if (node.scanning) {
// send status message
var msg = {
statusUpdate: true,
error: error,
stateChange: stateChange,
state: noble.state
};
... | javascript | function stopScan(stateChange, error) {
if (node.scanning) {
// send status message
var msg = {
statusUpdate: true,
error: error,
stateChange: stateChange,
state: noble.state
};
... | [
"function",
"stopScan",
"(",
"stateChange",
",",
"error",
")",
"{",
"if",
"(",
"node",
".",
"scanning",
")",
"{",
"// send status message",
"var",
"msg",
"=",
"{",
"statusUpdate",
":",
"true",
",",
"error",
":",
"error",
",",
"stateChange",
":",
"stateChan... | Take care of stopping the scan and sending the status message | [
"Take",
"care",
"of",
"stopping",
"the",
"scan",
"and",
"sending",
"the",
"status",
"message"
] | 9f30d0928df8e4b432891820c6ff97d4c18f49f4 | https://github.com/kmi/node-red-contrib-noble/blob/9f30d0928df8e4b432891820c6ff97d4c18f49f4/noble/node-red-contrib-noble.js#L110-L130 | train |
maxogden/bytewiser | exercises/modifying_buffers/exercise.js | query | function query (mode) {
var exercise = this
function send (stream) {
var input = through2()
input
.pipe(stream)
.on('error', function(err) {
exercise.emit(
'fail',
exercise.__('fail.never_read_stdin')
)
})
input.write('wow. such wow.');
input.en... | javascript | function query (mode) {
var exercise = this
function send (stream) {
var input = through2()
input
.pipe(stream)
.on('error', function(err) {
exercise.emit(
'fail',
exercise.__('fail.never_read_stdin')
)
})
input.write('wow. such wow.');
input.en... | [
"function",
"query",
"(",
"mode",
")",
"{",
"var",
"exercise",
"=",
"this",
"function",
"send",
"(",
"stream",
")",
"{",
"var",
"input",
"=",
"through2",
"(",
")",
"input",
".",
"pipe",
"(",
"stream",
")",
".",
"on",
"(",
"'error'",
",",
"function",
... | delayed for 500ms to wait for servers to start so we can start playing with them | [
"delayed",
"for",
"500ms",
"to",
"wait",
"for",
"servers",
"to",
"start",
"so",
"we",
"can",
"start",
"playing",
"with",
"them"
] | b111cda74ba0021b0ed69a51fb2c5f40e74284a1 | https://github.com/maxogden/bytewiser/blob/b111cda74ba0021b0ed69a51fb2c5f40e74284a1/exercises/modifying_buffers/exercise.js#L29-L50 | train |
DamienP33/express-mongoose-generator | lib/formatTools.js | getFieldsForModelTemplate | function getFieldsForModelTemplate(fields) {
var lg = fields.length - 1;
var modelFields = '{' + os.EOL;
fields.forEach(function(field, index, array) {
modelFields += '\t\'' + field.name + '\' : '+ (field.isArray ? '[' : '') + (allowedFieldsTypes[field.type]).name + (field.isArray ? ']' : '');
... | javascript | function getFieldsForModelTemplate(fields) {
var lg = fields.length - 1;
var modelFields = '{' + os.EOL;
fields.forEach(function(field, index, array) {
modelFields += '\t\'' + field.name + '\' : '+ (field.isArray ? '[' : '') + (allowedFieldsTypes[field.type]).name + (field.isArray ? ']' : '');
... | [
"function",
"getFieldsForModelTemplate",
"(",
"fields",
")",
"{",
"var",
"lg",
"=",
"fields",
".",
"length",
"-",
"1",
";",
"var",
"modelFields",
"=",
"'{'",
"+",
"os",
".",
"EOL",
";",
"fields",
".",
"forEach",
"(",
"function",
"(",
"field",
",",
"ind... | Format the fields for the model template
@param {array} fields fields input
@returns {string} formatted fields | [
"Format",
"the",
"fields",
"for",
"the",
"model",
"template"
] | ce1439c4c9c291e539fc6190907364d70e75d4d6 | https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/formatTools.js#L18-L33 | train |
DamienP33/express-mongoose-generator | lib/generators.js | generateModel | function generateModel(path, modelName, modelFields, generateMethod, ts, cb) {
var fields = formatTools.getFieldsForModelTemplate(modelFields);
var schemaName = modelName + 'Schema';
var extension = (ts) ? 'ts' : 'js';
var model = ft.loadTemplateSync('model.' + extension);
model = model.replace(/{m... | javascript | function generateModel(path, modelName, modelFields, generateMethod, ts, cb) {
var fields = formatTools.getFieldsForModelTemplate(modelFields);
var schemaName = modelName + 'Schema';
var extension = (ts) ? 'ts' : 'js';
var model = ft.loadTemplateSync('model.' + extension);
model = model.replace(/{m... | [
"function",
"generateModel",
"(",
"path",
",",
"modelName",
",",
"modelFields",
",",
"generateMethod",
",",
"ts",
",",
"cb",
")",
"{",
"var",
"fields",
"=",
"formatTools",
".",
"getFieldsForModelTemplate",
"(",
"modelFields",
")",
";",
"var",
"schemaName",
"="... | Generate a Mongoose model
@param {string} path
@param {string} modelName
@param {array} modelFields
@param {string} generateMethod
@param {boolean} ts generating code in TS
@param {function} cb | [
"Generate",
"a",
"Mongoose",
"model"
] | ce1439c4c9c291e539fc6190907364d70e75d4d6 | https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/generators.js#L17-L36 | train |
DamienP33/express-mongoose-generator | lib/generators.js | generateRouter | function generateRouter(path, modelName, generateMethod, ts, cb) {
var extension = (ts) ? 'ts' : 'js';
var router = ft.loadTemplateSync('router.' + extension);
router = router.replace(/{controllerName}/g, modelName + 'Controller');
if (generateMethod === 't') {
ft.createDirIfIsNotDefined(path, ... | javascript | function generateRouter(path, modelName, generateMethod, ts, cb) {
var extension = (ts) ? 'ts' : 'js';
var router = ft.loadTemplateSync('router.' + extension);
router = router.replace(/{controllerName}/g, modelName + 'Controller');
if (generateMethod === 't') {
ft.createDirIfIsNotDefined(path, ... | [
"function",
"generateRouter",
"(",
"path",
",",
"modelName",
",",
"generateMethod",
",",
"ts",
",",
"cb",
")",
"{",
"var",
"extension",
"=",
"(",
"ts",
")",
"?",
"'ts'",
":",
"'js'",
";",
"var",
"router",
"=",
"ft",
".",
"loadTemplateSync",
"(",
"'rout... | Generate a Express router
@param {string} path
@param {string} modelName
@param {string} generateMethod
@param {boolean} ts generating code in TS
@param {function} cb | [
"Generate",
"a",
"Express",
"router"
] | ce1439c4c9c291e539fc6190907364d70e75d4d6 | https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/generators.js#L46-L62 | train |
DamienP33/express-mongoose-generator | lib/fileTools.js | createDirIfIsNotDefined | function createDirIfIsNotDefined(dirPath, dirName, cb) {
if (!fs.existsSync(dirPath + '/' + dirName)){
fs.mkdirSync(dirPath + '/' + dirName);
console.info(cliStyles.cyan + '\tcreate' + cliStyles.reset + ': ' + dirPath + '/' + dirName);
}
cb();
} | javascript | function createDirIfIsNotDefined(dirPath, dirName, cb) {
if (!fs.existsSync(dirPath + '/' + dirName)){
fs.mkdirSync(dirPath + '/' + dirName);
console.info(cliStyles.cyan + '\tcreate' + cliStyles.reset + ': ' + dirPath + '/' + dirName);
}
cb();
} | [
"function",
"createDirIfIsNotDefined",
"(",
"dirPath",
",",
"dirName",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"dirPath",
"+",
"'/'",
"+",
"dirName",
")",
")",
"{",
"fs",
".",
"mkdirSync",
"(",
"dirPath",
"+",
"'/'",
"+",
"... | Create a directory if not defined
@param {string} dirPath directory path parent
@param {string} dirName directory name to find
@param {function} cb callback | [
"Create",
"a",
"directory",
"if",
"not",
"defined"
] | ce1439c4c9c291e539fc6190907364d70e75d4d6 | https://github.com/DamienP33/express-mongoose-generator/blob/ce1439c4c9c291e539fc6190907364d70e75d4d6/lib/fileTools.js#L14-L21 | train |
enricostara/telegram-mt-node | lib/auth/index.js | createAuthKey | function createAuthKey(callback, channel) {
flow.retryUntilIsDone(callback, null,
function (callback) {
flow.runSeries([
require('./request-pq'),
require('./request-dh-params'),
require('./set-client-dh-params')
], callback, channel);
... | javascript | function createAuthKey(callback, channel) {
flow.retryUntilIsDone(callback, null,
function (callback) {
flow.runSeries([
require('./request-pq'),
require('./request-dh-params'),
require('./set-client-dh-params')
], callback, channel);
... | [
"function",
"createAuthKey",
"(",
"callback",
",",
"channel",
")",
"{",
"flow",
".",
"retryUntilIsDone",
"(",
"callback",
",",
"null",
",",
"function",
"(",
"callback",
")",
"{",
"flow",
".",
"runSeries",
"(",
"[",
"require",
"(",
"'./request-pq'",
")",
",... | Create the authorization key | [
"Create",
"the",
"authorization",
"key"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/index.js#L18-L28 | train |
enricostara/telegram-mt-node | lib/auth/request-pq.js | requestPQ | function requestPQ(callback, channel) {
// Create a nonce for the client
var clientNonce = utility.createNonce(16);
mtproto.service.req_pq({
props: {
nonce: clientNonce
},
channel: channel,
callback: function (ex, resPQ) {
if (clientNonce === resPQ.non... | javascript | function requestPQ(callback, channel) {
// Create a nonce for the client
var clientNonce = utility.createNonce(16);
mtproto.service.req_pq({
props: {
nonce: clientNonce
},
channel: channel,
callback: function (ex, resPQ) {
if (clientNonce === resPQ.non... | [
"function",
"requestPQ",
"(",
"callback",
",",
"channel",
")",
"{",
"// Create a nonce for the client",
"var",
"clientNonce",
"=",
"utility",
".",
"createNonce",
"(",
"16",
")",
";",
"mtproto",
".",
"service",
".",
"req_pq",
"(",
"{",
"props",
":",
"{",
"non... | Request a PQ pair number | [
"Request",
"a",
"PQ",
"pair",
"number"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-pq.js#L27-L47 | train |
enricostara/telegram-mt-node | lib/auth/request-pq.js | findPAndQ | function findPAndQ(context) {
var pqFinder = new security.PQFinder(context.resPQ.pq);
if (logger.isDebugEnabled()) {
logger.debug('Start finding P and Q, with PQ = %s', pqFinder.getPQPairNumber());
}
var pq = pqFinder.findPQ();
if (logger.isDebugEnabled()) {
logger.debug('Found P = %... | javascript | function findPAndQ(context) {
var pqFinder = new security.PQFinder(context.resPQ.pq);
if (logger.isDebugEnabled()) {
logger.debug('Start finding P and Q, with PQ = %s', pqFinder.getPQPairNumber());
}
var pq = pqFinder.findPQ();
if (logger.isDebugEnabled()) {
logger.debug('Found P = %... | [
"function",
"findPAndQ",
"(",
"context",
")",
"{",
"var",
"pqFinder",
"=",
"new",
"security",
".",
"PQFinder",
"(",
"context",
".",
"resPQ",
".",
"pq",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
... | Find the P and Q prime numbers | [
"Find",
"the",
"P",
"and",
"Q",
"prime",
"numbers"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-pq.js#L50-L62 | train |
enricostara/telegram-mt-node | lib/auth/request-pq.js | findPublicKey | function findPublicKey(context) {
var fingerprints = context.resPQ.server_public_key_fingerprints.getList();
if (logger.isDebugEnabled()) {
logger.debug('Public keys fingerprints from server: %s', fingerprints);
}
for (var i = 0; i < fingerprints.length; i++) {
var fingerprint = fingerpr... | javascript | function findPublicKey(context) {
var fingerprints = context.resPQ.server_public_key_fingerprints.getList();
if (logger.isDebugEnabled()) {
logger.debug('Public keys fingerprints from server: %s', fingerprints);
}
for (var i = 0; i < fingerprints.length; i++) {
var fingerprint = fingerpr... | [
"function",
"findPublicKey",
"(",
"context",
")",
"{",
"var",
"fingerprints",
"=",
"context",
".",
"resPQ",
".",
"server_public_key_fingerprints",
".",
"getList",
"(",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
... | Find the correct Public Key using fingerprint from server response | [
"Find",
"the",
"correct",
"Public",
"Key",
"using",
"fingerprint",
"from",
"server",
"response"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-pq.js#L65-L86 | train |
enricostara/telegram-mt-node | lib/utility.js | createMessageId | function createMessageId() {
var logger = getLogger('utility.createMessageId');
// Constants
// Take the time and sum the time-offset with the server clock
var time = new BigInteger((require('./time').getLocalTime()).toString());
// Divide the time by 1000 `result[0]` and take the fractional part `r... | javascript | function createMessageId() {
var logger = getLogger('utility.createMessageId');
// Constants
// Take the time and sum the time-offset with the server clock
var time = new BigInteger((require('./time').getLocalTime()).toString());
// Divide the time by 1000 `result[0]` and take the fractional part `r... | [
"function",
"createMessageId",
"(",
")",
"{",
"var",
"logger",
"=",
"getLogger",
"(",
"'utility.createMessageId'",
")",
";",
"// Constants",
"// Take the time and sum the time-offset with the server clock",
"var",
"time",
"=",
"new",
"BigInteger",
"(",
"(",
"require",
"... | Create a message ID starting from the local time | [
"Create",
"a",
"message",
"ID",
"starting",
"from",
"the",
"local",
"time"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/utility.js#L27-L43 | train |
enricostara/telegram-mt-node | lib/utility.js | createSHAHash | function createSHAHash(buffer, algorithm) {
var logger = getLogger('utility.createSHA1Hash');
var sha1sum = crypto.createHash(algorithm || 'sha1');
if (require('util').isArray(buffer)) {
if (logger.isDebugEnabled()) {
logger.debug('It\'s an Array of buffers');
}
for (var ... | javascript | function createSHAHash(buffer, algorithm) {
var logger = getLogger('utility.createSHA1Hash');
var sha1sum = crypto.createHash(algorithm || 'sha1');
if (require('util').isArray(buffer)) {
if (logger.isDebugEnabled()) {
logger.debug('It\'s an Array of buffers');
}
for (var ... | [
"function",
"createSHAHash",
"(",
"buffer",
",",
"algorithm",
")",
"{",
"var",
"logger",
"=",
"getLogger",
"(",
"'utility.createSHA1Hash'",
")",
";",
"var",
"sha1sum",
"=",
"crypto",
".",
"createHash",
"(",
"algorithm",
"||",
"'sha1'",
")",
";",
"if",
"(",
... | Create SHA1 hash starting from a buffer or an array of buffers | [
"Create",
"SHA1",
"hash",
"starting",
"from",
"a",
"buffer",
"or",
"an",
"array",
"of",
"buffers"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/utility.js#L46-L63 | train |
enricostara/telegram-mt-node | lib/utility.js | xor | function xor(buffer1, buffer2) {
var length = Math.min(buffer1.length, buffer2.length);
var retBuffer = new Buffer(length);
for (var i = 0; i < length; i++) {
retBuffer[i] = buffer1[i] ^ buffer2[i];
}
return retBuffer;
} | javascript | function xor(buffer1, buffer2) {
var length = Math.min(buffer1.length, buffer2.length);
var retBuffer = new Buffer(length);
for (var i = 0; i < length; i++) {
retBuffer[i] = buffer1[i] ^ buffer2[i];
}
return retBuffer;
} | [
"function",
"xor",
"(",
"buffer1",
",",
"buffer2",
")",
"{",
"var",
"length",
"=",
"Math",
".",
"min",
"(",
"buffer1",
".",
"length",
",",
"buffer2",
".",
"length",
")",
";",
"var",
"retBuffer",
"=",
"new",
"Buffer",
"(",
"length",
")",
";",
"for",
... | Xor op on buffers | [
"Xor",
"op",
"on",
"buffers"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/utility.js#L93-L100 | train |
enricostara/telegram-mt-node | lib/auth/request-dh-params.js | createPQInnerData | function createPQInnerData(context) {
var resPQ = context.resPQ;
var newNonce = utility.createNonce(32);
var pqInnerData = new mtproto.type.P_q_inner_data({
props: {
pq: resPQ.pq,
p: context.pBuffer,
q: context.qBuffer,
nonce: resPQ.nonce,
... | javascript | function createPQInnerData(context) {
var resPQ = context.resPQ;
var newNonce = utility.createNonce(32);
var pqInnerData = new mtproto.type.P_q_inner_data({
props: {
pq: resPQ.pq,
p: context.pBuffer,
q: context.qBuffer,
nonce: resPQ.nonce,
... | [
"function",
"createPQInnerData",
"(",
"context",
")",
"{",
"var",
"resPQ",
"=",
"context",
".",
"resPQ",
";",
"var",
"newNonce",
"=",
"utility",
".",
"createNonce",
"(",
"32",
")",
";",
"var",
"pqInnerData",
"=",
"new",
"mtproto",
".",
"type",
".",
"P_q_... | Create the pq_inner_data buffer | [
"Create",
"the",
"pq_inner_data",
"buffer"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L32-L48 | train |
enricostara/telegram-mt-node | lib/auth/request-dh-params.js | encryptPQInnerDataWithRSA | function encryptPQInnerDataWithRSA(context) {
// Create the data with hash to be encrypt
var hash = utility.createSHAHash(context.pqInnerData);
var dataWithHash = Buffer.concat([hash, context.pqInnerData]);
if (logger.isDebugEnabled()) {
logger.debug('Data to be encrypted contains: hash(%s), pqI... | javascript | function encryptPQInnerDataWithRSA(context) {
// Create the data with hash to be encrypt
var hash = utility.createSHAHash(context.pqInnerData);
var dataWithHash = Buffer.concat([hash, context.pqInnerData]);
if (logger.isDebugEnabled()) {
logger.debug('Data to be encrypted contains: hash(%s), pqI... | [
"function",
"encryptPQInnerDataWithRSA",
"(",
"context",
")",
"{",
"// Create the data with hash to be encrypt",
"var",
"hash",
"=",
"utility",
".",
"createSHAHash",
"(",
"context",
".",
"pqInnerData",
")",
";",
"var",
"dataWithHash",
"=",
"Buffer",
".",
"concat",
"... | Encrypt the pq_inner_data with RSA | [
"Encrypt",
"the",
"pq_inner_data",
"with",
"RSA"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L51-L62 | train |
enricostara/telegram-mt-node | lib/auth/request-dh-params.js | requestDHParams | function requestDHParams(callback, context) {
var resPQ = context.resPQ;
mtproto.service.req_DH_params({
props: {
nonce: resPQ.nonce,
server_nonce: resPQ.server_nonce,
p: context.pBuffer,
q: context.qBuffer,
public_key_fingerprint: context.fing... | javascript | function requestDHParams(callback, context) {
var resPQ = context.resPQ;
mtproto.service.req_DH_params({
props: {
nonce: resPQ.nonce,
server_nonce: resPQ.server_nonce,
p: context.pBuffer,
q: context.qBuffer,
public_key_fingerprint: context.fing... | [
"function",
"requestDHParams",
"(",
"callback",
",",
"context",
")",
"{",
"var",
"resPQ",
"=",
"context",
".",
"resPQ",
";",
"mtproto",
".",
"service",
".",
"req_DH_params",
"(",
"{",
"props",
":",
"{",
"nonce",
":",
"resPQ",
".",
"nonce",
",",
"server_n... | Request server DH parameters | [
"Request",
"server",
"DH",
"parameters"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L65-L102 | train |
enricostara/telegram-mt-node | lib/auth/request-dh-params.js | decryptDHParams | function decryptDHParams(context) {
var newNonce = utility.string2Buffer(context.newNonce, 32);
var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16);
if (logger.isDebugEnabled()) {
logger.debug('newNonce = %s, serverNonce = %s', newNonce.toString('hex'), serverNonce.toString('hex'... | javascript | function decryptDHParams(context) {
var newNonce = utility.string2Buffer(context.newNonce, 32);
var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16);
if (logger.isDebugEnabled()) {
logger.debug('newNonce = %s, serverNonce = %s', newNonce.toString('hex'), serverNonce.toString('hex'... | [
"function",
"decryptDHParams",
"(",
"context",
")",
"{",
"var",
"newNonce",
"=",
"utility",
".",
"string2Buffer",
"(",
"context",
".",
"newNonce",
",",
"32",
")",
";",
"var",
"serverNonce",
"=",
"utility",
".",
"string2Buffer",
"(",
"context",
".",
"resPQ",
... | Decrypt DH parameters and synch the local time with the server time | [
"Decrypt",
"DH",
"parameters",
"and",
"synch",
"the",
"local",
"time",
"with",
"the",
"server",
"time"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L105-L136 | train |
enricostara/telegram-mt-node | lib/auth/request-dh-params.js | deserializeDHInnerData | function deserializeDHInnerData(context) {
var decryptedDHParamsWithHash = context.decryptedDHParams;
if (logger.isDebugEnabled()) {
logger.debug('decryptedDHParamsWithHash(%s) = %s', decryptedDHParamsWithHash.length, decryptedDHParamsWithHash.toString('hex'));
}
var decryptedDHParams = decrypte... | javascript | function deserializeDHInnerData(context) {
var decryptedDHParamsWithHash = context.decryptedDHParams;
if (logger.isDebugEnabled()) {
logger.debug('decryptedDHParamsWithHash(%s) = %s', decryptedDHParamsWithHash.length, decryptedDHParamsWithHash.toString('hex'));
}
var decryptedDHParams = decrypte... | [
"function",
"deserializeDHInnerData",
"(",
"context",
")",
"{",
"var",
"decryptedDHParamsWithHash",
"=",
"context",
".",
"decryptedDHParams",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"'decryptedDHParamsWithH... | De-serialize the server DH inner data | [
"De",
"-",
"serialize",
"the",
"server",
"DH",
"inner",
"data"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/request-dh-params.js#L139-L165 | train |
enricostara/telegram-mt-node | lib/security/cipher.js | aesDecrypt | function aesDecrypt(msg, key, iv) {
var logger = getLogger('security.cipher.aesDecrypt');
var encryptedMsg = buffer2WordArray(msg);
var keyWordArray = buffer2WordArray(key);
var ivWordArray = buffer2WordArray(iv);
if (logger.isDebugEnabled()) {
logger.debug('encryptedMsg = %s\nkeyWordArray =... | javascript | function aesDecrypt(msg, key, iv) {
var logger = getLogger('security.cipher.aesDecrypt');
var encryptedMsg = buffer2WordArray(msg);
var keyWordArray = buffer2WordArray(key);
var ivWordArray = buffer2WordArray(iv);
if (logger.isDebugEnabled()) {
logger.debug('encryptedMsg = %s\nkeyWordArray =... | [
"function",
"aesDecrypt",
"(",
"msg",
",",
"key",
",",
"iv",
")",
"{",
"var",
"logger",
"=",
"getLogger",
"(",
"'security.cipher.aesDecrypt'",
")",
";",
"var",
"encryptedMsg",
"=",
"buffer2WordArray",
"(",
"msg",
")",
";",
"var",
"keyWordArray",
"=",
"buffer... | AES decrypt function | [
"AES",
"decrypt",
"function"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/security/cipher.js#L50-L68 | train |
enricostara/telegram-mt-node | lib/security/cipher.js | aesEncrypt | function aesEncrypt(msg, key, iv) {
var logger = getLogger('security.cipher.aesEncrypt');
// Check if padding is needed
var padding = msg.length % 16;
if (padding > 0) {
var paddingBuffer = utility.createRandomBuffer(16 - padding);
msg = Buffer.concat([msg, paddingBuffer]);
}
// ... | javascript | function aesEncrypt(msg, key, iv) {
var logger = getLogger('security.cipher.aesEncrypt');
// Check if padding is needed
var padding = msg.length % 16;
if (padding > 0) {
var paddingBuffer = utility.createRandomBuffer(16 - padding);
msg = Buffer.concat([msg, paddingBuffer]);
}
// ... | [
"function",
"aesEncrypt",
"(",
"msg",
",",
"key",
",",
"iv",
")",
"{",
"var",
"logger",
"=",
"getLogger",
"(",
"'security.cipher.aesEncrypt'",
")",
";",
"// Check if padding is needed",
"var",
"padding",
"=",
"msg",
".",
"length",
"%",
"16",
";",
"if",
"(",
... | AES encrypt function | [
"AES",
"encrypt",
"function"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/security/cipher.js#L71-L98 | train |
enricostara/telegram-mt-node | lib/time.js | timeSynchronization | function timeSynchronization(serverTime, requestDuration) {
var logger = getLogger('time.timeSynchronization');
var localTime = Math.floor(new Date().getTime() / 1000);
var response = requestDuration / 2;
if (logger.isDebugEnabled()) {
logger.debug('ServerTime %ss - LocalTime %ss - Response in %... | javascript | function timeSynchronization(serverTime, requestDuration) {
var logger = getLogger('time.timeSynchronization');
var localTime = Math.floor(new Date().getTime() / 1000);
var response = requestDuration / 2;
if (logger.isDebugEnabled()) {
logger.debug('ServerTime %ss - LocalTime %ss - Response in %... | [
"function",
"timeSynchronization",
"(",
"serverTime",
",",
"requestDuration",
")",
"{",
"var",
"logger",
"=",
"getLogger",
"(",
"'time.timeSynchronization'",
")",
";",
"var",
"localTime",
"=",
"Math",
".",
"floor",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",... | Synchronize the local time with the server time | [
"Synchronize",
"the",
"local",
"time",
"with",
"the",
"server",
"time"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/time.js#L28-L50 | train |
enricostara/telegram-mt-node | lib/auth/set-client-dh-params.js | encryptClientDHInnerDataWithAES | function encryptClientDHInnerDataWithAES(context) {
var hash = utility.createSHAHash(context.clientDHInnerData);
var dataWithHash = Buffer.concat([hash, context.clientDHInnerData]);
if (logger.isDebugEnabled()) {
logger.debug('Data to be encrypted contains: hash(%s), clientDHInnerData(%s), total len... | javascript | function encryptClientDHInnerDataWithAES(context) {
var hash = utility.createSHAHash(context.clientDHInnerData);
var dataWithHash = Buffer.concat([hash, context.clientDHInnerData]);
if (logger.isDebugEnabled()) {
logger.debug('Data to be encrypted contains: hash(%s), clientDHInnerData(%s), total len... | [
"function",
"encryptClientDHInnerDataWithAES",
"(",
"context",
")",
"{",
"var",
"hash",
"=",
"utility",
".",
"createSHAHash",
"(",
"context",
".",
"clientDHInnerData",
")",
";",
"var",
"dataWithHash",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"hash",
",",
"conte... | Encrypt Client DH inner data | [
"Encrypt",
"Client",
"DH",
"inner",
"data"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L57-L74 | train |
enricostara/telegram-mt-node | lib/auth/set-client-dh-params.js | setClientDHParams | function setClientDHParams(callback, context) {
mtproto.service.set_client_DH_params({
props: {
nonce: context.resPQ.nonce,
server_nonce: context.resPQ.server_nonce,
encrypted_data: context.encryptClientDHInnerData
},
channel: context.channel,
call... | javascript | function setClientDHParams(callback, context) {
mtproto.service.set_client_DH_params({
props: {
nonce: context.resPQ.nonce,
server_nonce: context.resPQ.server_nonce,
encrypted_data: context.encryptClientDHInnerData
},
channel: context.channel,
call... | [
"function",
"setClientDHParams",
"(",
"callback",
",",
"context",
")",
"{",
"mtproto",
".",
"service",
".",
"set_client_DH_params",
"(",
"{",
"props",
":",
"{",
"nonce",
":",
"context",
".",
"resPQ",
".",
"nonce",
",",
"server_nonce",
":",
"context",
".",
... | Set client DH parameters | [
"Set",
"client",
"DH",
"parameters"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L77-L117 | train |
enricostara/telegram-mt-node | lib/auth/set-client-dh-params.js | calculateAuthKeyValue | function calculateAuthKeyValue(context) {
var ga = context.serverDHInnerData.g_a;
var b = context.b;
var dhPrime = context.serverDHInnerData.dh_prime;
var authKeyValue = utility.modPow(ga, b, dhPrime);
if (logger.isDebugEnabled()) {
logger.debug('authKeyValue(%s) = %s', authKeyValue.length, ... | javascript | function calculateAuthKeyValue(context) {
var ga = context.serverDHInnerData.g_a;
var b = context.b;
var dhPrime = context.serverDHInnerData.dh_prime;
var authKeyValue = utility.modPow(ga, b, dhPrime);
if (logger.isDebugEnabled()) {
logger.debug('authKeyValue(%s) = %s', authKeyValue.length, ... | [
"function",
"calculateAuthKeyValue",
"(",
"context",
")",
"{",
"var",
"ga",
"=",
"context",
".",
"serverDHInnerData",
".",
"g_a",
";",
"var",
"b",
"=",
"context",
".",
"b",
";",
"var",
"dhPrime",
"=",
"context",
".",
"serverDHInnerData",
".",
"dh_prime",
"... | Calculate the authentication key value | [
"Calculate",
"the",
"authentication",
"key",
"value"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L120-L130 | train |
enricostara/telegram-mt-node | lib/auth/set-client-dh-params.js | createAuthKeyID | function createAuthKeyID(context) {
var authKeyHash = utility.createSHAHash(context.authKeyValue);
var authKeyAuxHash = authKeyHash.slice(0, 8);
var authKeyID = authKeyHash.slice(-8);
if (logger.isDebugEnabled()) {
logger.debug('authKeyID(%s) = %s', authKeyID.length, authKeyID.toString('hex'));
... | javascript | function createAuthKeyID(context) {
var authKeyHash = utility.createSHAHash(context.authKeyValue);
var authKeyAuxHash = authKeyHash.slice(0, 8);
var authKeyID = authKeyHash.slice(-8);
if (logger.isDebugEnabled()) {
logger.debug('authKeyID(%s) = %s', authKeyID.length, authKeyID.toString('hex'));
... | [
"function",
"createAuthKeyID",
"(",
"context",
")",
"{",
"var",
"authKeyHash",
"=",
"utility",
".",
"createSHAHash",
"(",
"context",
".",
"authKeyValue",
")",
";",
"var",
"authKeyAuxHash",
"=",
"authKeyHash",
".",
"slice",
"(",
"0",
",",
"8",
")",
";",
"va... | Calculate AuthKey hash and ID | [
"Calculate",
"AuthKey",
"hash",
"and",
"ID"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L133-L143 | train |
enricostara/telegram-mt-node | lib/auth/set-client-dh-params.js | checkNonceMatch | function checkNonceMatch(context) {
var newNonce1 = Buffer.concat([utility.string2Buffer(context.newNonce, 32), new Buffer([1]), context.authKeyAuxHash]);
var newNonceHash = utility.buffer2String(utility.createSHAHash(newNonce1).slice(-16));
var serverNewNonceHash = context.setClientDHParamsAnswer.new_nonce... | javascript | function checkNonceMatch(context) {
var newNonce1 = Buffer.concat([utility.string2Buffer(context.newNonce, 32), new Buffer([1]), context.authKeyAuxHash]);
var newNonceHash = utility.buffer2String(utility.createSHAHash(newNonce1).slice(-16));
var serverNewNonceHash = context.setClientDHParamsAnswer.new_nonce... | [
"function",
"checkNonceMatch",
"(",
"context",
")",
"{",
"var",
"newNonce1",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"utility",
".",
"string2Buffer",
"(",
"context",
".",
"newNonce",
",",
"32",
")",
",",
"new",
"Buffer",
"(",
"[",
"1",
"]",
")",
",",
... | Withstand replay-attacks | [
"Withstand",
"replay",
"-",
"attacks"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L146-L158 | train |
enricostara/telegram-mt-node | lib/auth/set-client-dh-params.js | createAuthKey | function createAuthKey(context) {
// Extract the nonces
var newNonce = utility.string2Buffer(context.newNonce, 32);
var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16);
// Create the serverSalt
var serverSalt = utility.xor(newNonce.slice(0, 8), serverNonce.slice(0, 8));
if (l... | javascript | function createAuthKey(context) {
// Extract the nonces
var newNonce = utility.string2Buffer(context.newNonce, 32);
var serverNonce = utility.string2Buffer(context.resPQ.server_nonce, 16);
// Create the serverSalt
var serverSalt = utility.xor(newNonce.slice(0, 8), serverNonce.slice(0, 8));
if (l... | [
"function",
"createAuthKey",
"(",
"context",
")",
"{",
"// Extract the nonces",
"var",
"newNonce",
"=",
"utility",
".",
"string2Buffer",
"(",
"context",
".",
"newNonce",
",",
"32",
")",
";",
"var",
"serverNonce",
"=",
"utility",
".",
"string2Buffer",
"(",
"con... | Create the AuthKey | [
"Create",
"the",
"AuthKey"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/auth/set-client-dh-params.js#L161-L180 | train |
enricostara/telegram-mt-node | lib/security/public-key.js | PublicKey | function PublicKey(params) {
this._fingerprint = params.fingerprint;
this._modulus = params.modulus;
this._exponent = params.exponent;
} | javascript | function PublicKey(params) {
this._fingerprint = params.fingerprint;
this._modulus = params.modulus;
this._exponent = params.exponent;
} | [
"function",
"PublicKey",
"(",
"params",
")",
"{",
"this",
".",
"_fingerprint",
"=",
"params",
".",
"fingerprint",
";",
"this",
".",
"_modulus",
"=",
"params",
".",
"modulus",
";",
"this",
".",
"_exponent",
"=",
"params",
".",
"exponent",
";",
"}"
] | PublicKey class This class represents a Public Key The constructor requires the fingerprint, the modulus and the exponent | [
"PublicKey",
"class",
"This",
"class",
"represents",
"a",
"Public",
"Key",
"The",
"constructor",
"requires",
"the",
"fingerprint",
"the",
"modulus",
"and",
"the",
"exponent"
] | f069dfcea2d023fc1ca837c5673d3abe26d44d28 | https://github.com/enricostara/telegram-mt-node/blob/f069dfcea2d023fc1ca837c5673d3abe26d44d28/lib/security/public-key.js#L11-L15 | train |
jschyma/open_fints_js_client | lib/Classes.js | function (error, order, recvMsg) {
if (error) {
me_order.client.MsgEndDialog(function (error2, recvMsg2) {
if (error2) {
me_order.client.log.con.error({
error: error2
}, 'Connection close failed after error.')
} else {
me_order.client.l... | javascript | function (error, order, recvMsg) {
if (error) {
me_order.client.MsgEndDialog(function (error2, recvMsg2) {
if (error2) {
me_order.client.log.con.error({
error: error2
}, 'Connection close failed after error.')
} else {
me_order.client.l... | [
"function",
"(",
"error",
",",
"order",
",",
"recvMsg",
")",
"{",
"if",
"(",
"error",
")",
"{",
"me_order",
".",
"client",
".",
"MsgEndDialog",
"(",
"function",
"(",
"error2",
",",
"recvMsg2",
")",
"{",
"if",
"(",
"error2",
")",
"{",
"me_order",
".",... | Exit CB is called when the function returns here it is checked if an error occures and then disconnects | [
"Exit",
"CB",
"is",
"called",
"when",
"the",
"function",
"returns",
"here",
"it",
"is",
"checked",
"if",
"an",
"error",
"occures",
"and",
"then",
"disconnects"
] | 1d3a36bebeb40511e99def61b2e3f25c4248d288 | https://github.com/jschyma/open_fints_js_client/blob/1d3a36bebeb40511e99def61b2e3f25c4248d288/lib/Classes.js#L896-L909 | train | |
modofunjs/modofun | index.js | createServiceHandler | function createServiceHandler(handlers = {}, options = {}, shortcutType) {
const errorHandler = options.errorHandler || defaultErrorHandler;
const middleware = options.middleware || Array.isArray(options) && options || [];
const mode = options.mode || FUNCTION_MODE;
const checkArity = options.checkArity === und... | javascript | function createServiceHandler(handlers = {}, options = {}, shortcutType) {
const errorHandler = options.errorHandler || defaultErrorHandler;
const middleware = options.middleware || Array.isArray(options) && options || [];
const mode = options.mode || FUNCTION_MODE;
const checkArity = options.checkArity === und... | [
"function",
"createServiceHandler",
"(",
"handlers",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
",",
"shortcutType",
")",
"{",
"const",
"errorHandler",
"=",
"options",
".",
"errorHandler",
"||",
"defaultErrorHandler",
";",
"const",
"middleware",
"=",
"optio... | The exported function that creates the request handler
using the supplied handlers and configuration.
Returns a handler with either function(req, res) signature
or function(event, context, callback) signature.
Example:
var app = modofun(
{
authenticate: authenticate,
user: [authorize, getUser]
},
{
middleware: [logg... | [
"The",
"exported",
"function",
"that",
"creates",
"the",
"request",
"handler",
"using",
"the",
"supplied",
"handlers",
"and",
"configuration",
"."
] | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L171-L206 | train |
modofunjs/modofun | index.js | handleRequest | function handleRequest(middleware, handlers, mode, checkArity, req, res, errorHandler) {
const done = err => err && setImmediate(errorHandler, err, req, res);
// run global middleware first, then start handling request
// this is important to allow loggers for example to kick-in regardless
runMiddlewareStack(mi... | javascript | function handleRequest(middleware, handlers, mode, checkArity, req, res, errorHandler) {
const done = err => err && setImmediate(errorHandler, err, req, res);
// run global middleware first, then start handling request
// this is important to allow loggers for example to kick-in regardless
runMiddlewareStack(mi... | [
"function",
"handleRequest",
"(",
"middleware",
",",
"handlers",
",",
"mode",
",",
"checkArity",
",",
"req",
",",
"res",
",",
"errorHandler",
")",
"{",
"const",
"done",
"=",
"err",
"=>",
"err",
"&&",
"setImmediate",
"(",
"errorHandler",
",",
"err",
",",
... | Execute middleware stack and handle request.
@private | [
"Execute",
"middleware",
"stack",
"and",
"handle",
"request",
"."
] | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L212-L224 | train |
modofunjs/modofun | index.js | handleOperation | function handleOperation(handlers, mode, checkArity, req, res, done) {
// parse path:
// - first part is the operation name
// - the following components of the path are used as arguments
const parsedParts = parsePath(req);
if (parsedParts[0].length === 0) {
done(new ModofunError(403, 'NoOperation', 'Oper... | javascript | function handleOperation(handlers, mode, checkArity, req, res, done) {
// parse path:
// - first part is the operation name
// - the following components of the path are used as arguments
const parsedParts = parsePath(req);
if (parsedParts[0].length === 0) {
done(new ModofunError(403, 'NoOperation', 'Oper... | [
"function",
"handleOperation",
"(",
"handlers",
",",
"mode",
",",
"checkArity",
",",
"req",
",",
"res",
",",
"done",
")",
"{",
"// parse path:",
"// - first part is the operation name",
"// - the following components of the path are used as arguments",
"const",
"parsedParts",... | Try to apply supplied handlers to the requested operation.
@private | [
"Try",
"to",
"apply",
"supplied",
"handlers",
"to",
"the",
"requested",
"operation",
"."
] | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L230-L282 | train |
modofunjs/modofun | index.js | invokeHTTPHandler | function invokeHTTPHandler(handler, args, req, res, done) {
// inject parsed parameters into request
req.params = args;
// call handler with typical HTTP request/response parameters
let result = handler(req, res);
// handle results that are not a trusted Promise with Promise.resolve()
// which also supports... | javascript | function invokeHTTPHandler(handler, args, req, res, done) {
// inject parsed parameters into request
req.params = args;
// call handler with typical HTTP request/response parameters
let result = handler(req, res);
// handle results that are not a trusted Promise with Promise.resolve()
// which also supports... | [
"function",
"invokeHTTPHandler",
"(",
"handler",
",",
"args",
",",
"req",
",",
"res",
",",
"done",
")",
"{",
"// inject parsed parameters into request",
"req",
".",
"params",
"=",
"args",
";",
"// call handler with typical HTTP request/response parameters",
"let",
"resu... | Invoke the provided request handler function.
This handler function must send a response.
If the handler returns a Promise,
it will handle the error if the Promise is rejected.
@private | [
"Invoke",
"the",
"provided",
"request",
"handler",
"function",
".",
"This",
"handler",
"function",
"must",
"send",
"a",
"response",
".",
"If",
"the",
"handler",
"returns",
"a",
"Promise",
"it",
"will",
"handle",
"the",
"error",
"if",
"the",
"Promise",
"is",
... | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L330-L341 | train |
modofunjs/modofun | index.js | invokeFunctionHandler | function invokeFunctionHandler(handler, args, checkArity, req, res, done) {
// check if number of arguments provided matches the handler function arity
if (checkArity && args.length < handler.length) { // < due to possible optionals
done(new ModofunError(400, 'InvalidInput',
`This operation requires ${han... | javascript | function invokeFunctionHandler(handler, args, checkArity, req, res, done) {
// check if number of arguments provided matches the handler function arity
if (checkArity && args.length < handler.length) { // < due to possible optionals
done(new ModofunError(400, 'InvalidInput',
`This operation requires ${han... | [
"function",
"invokeFunctionHandler",
"(",
"handler",
",",
"args",
",",
"checkArity",
",",
"req",
",",
"res",
",",
"done",
")",
"{",
"// check if number of arguments provided matches the handler function arity",
"if",
"(",
"checkArity",
"&&",
"args",
".",
"length",
"<"... | Invoke the provided request handler function.
The handler should return a value or a Promised value
which will be added to the reponse automatically.
@private | [
"Invoke",
"the",
"provided",
"request",
"handler",
"function",
".",
"The",
"handler",
"should",
"return",
"a",
"value",
"or",
"a",
"Promised",
"value",
"which",
"will",
"be",
"added",
"to",
"the",
"reponse",
"automatically",
"."
] | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L349-L387 | train |
modofunjs/modofun | index.js | defaultErrorHandler | function defaultErrorHandler(err, req, res) {
if (err.name === 'UnauthorizedError') { // authentication is expected to be a common use-case
res.status(401).end();
} else {
if (!err.status || err.status >= 500) {
console.error(err.stack || err.toString());
}
res.status(err.status || 500).json({... | javascript | function defaultErrorHandler(err, req, res) {
if (err.name === 'UnauthorizedError') { // authentication is expected to be a common use-case
res.status(401).end();
} else {
if (!err.status || err.status >= 500) {
console.error(err.stack || err.toString());
}
res.status(err.status || 500).json({... | [
"function",
"defaultErrorHandler",
"(",
"err",
",",
"req",
",",
"res",
")",
"{",
"if",
"(",
"err",
".",
"name",
"===",
"'UnauthorizedError'",
")",
"{",
"// authentication is expected to be a common use-case",
"res",
".",
"status",
"(",
"401",
")",
".",
"end",
... | The default error handler, in case none is provided by the application.
@private | [
"The",
"default",
"error",
"handler",
"in",
"case",
"none",
"is",
"provided",
"by",
"the",
"application",
"."
] | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L393-L402 | train |
modofunjs/modofun | index.js | parsePath | function parsePath(req) {
// get path if preprocessed or otherwise separate path from query string
const path = req.path || (req.url && req.url.split('?')[0]) || '';
// ignore start and end slashes, and split the path
return path.replace(/^\/|\/$/g, '').split('/');
} | javascript | function parsePath(req) {
// get path if preprocessed or otherwise separate path from query string
const path = req.path || (req.url && req.url.split('?')[0]) || '';
// ignore start and end slashes, and split the path
return path.replace(/^\/|\/$/g, '').split('/');
} | [
"function",
"parsePath",
"(",
"req",
")",
"{",
"// get path if preprocessed or otherwise separate path from query string",
"const",
"path",
"=",
"req",
".",
"path",
"||",
"(",
"req",
".",
"url",
"&&",
"req",
".",
"url",
".",
"split",
"(",
"'?'",
")",
"[",
"0",... | Parse URL path to an array of its components.
@private | [
"Parse",
"URL",
"path",
"to",
"an",
"array",
"of",
"its",
"components",
"."
] | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L408-L413 | train |
modofunjs/modofun | index.js | arity | function arity(min, max = Number.MAX_SAFE_INTEGER) {
return (req, res, next) => {
const foundArity = parsePath(req).length-1;
if (foundArity < min ) {
next(new ModofunError(400, 'InvalidInput',
`This operation requires ${min} parameters. Received ${foundArity}.`));
} else if (foundArity > ma... | javascript | function arity(min, max = Number.MAX_SAFE_INTEGER) {
return (req, res, next) => {
const foundArity = parsePath(req).length-1;
if (foundArity < min ) {
next(new ModofunError(400, 'InvalidInput',
`This operation requires ${min} parameters. Received ${foundArity}.`));
} else if (foundArity > ma... | [
"function",
"arity",
"(",
"min",
",",
"max",
"=",
"Number",
".",
"MAX_SAFE_INTEGER",
")",
"{",
"return",
"(",
"req",
",",
"res",
",",
"next",
")",
"=>",
"{",
"const",
"foundArity",
"=",
"parsePath",
"(",
"req",
")",
".",
"length",
"-",
"1",
";",
"i... | Utility middleware to enforce a minimum number of parameters.
Accepts an extra argument for an optional maximum number.
@public | [
"Utility",
"middleware",
"to",
"enforce",
"a",
"minimum",
"number",
"of",
"parameters",
".",
"Accepts",
"an",
"extra",
"argument",
"for",
"an",
"optional",
"maximum",
"number",
"."
] | df5ea1b4d930a0bf1884e6926493b4eb246f5ae2 | https://github.com/modofunjs/modofun/blob/df5ea1b4d930a0bf1884e6926493b4eb246f5ae2/index.js#L420-L433 | train |
dominictarr/hashlru | bench.js | run | function run (N, op, init) {
var stats = null, value
for(var j = 0; j < 100; j++) {
if(init) value = init(j)
var start = Date.now()
for(var i = 0; i < N; i++) op(value, i)
stats = Stats(stats, N/((Date.now() - start)))
}
return stats
} | javascript | function run (N, op, init) {
var stats = null, value
for(var j = 0; j < 100; j++) {
if(init) value = init(j)
var start = Date.now()
for(var i = 0; i < N; i++) op(value, i)
stats = Stats(stats, N/((Date.now() - start)))
}
return stats
} | [
"function",
"run",
"(",
"N",
",",
"op",
",",
"init",
")",
"{",
"var",
"stats",
"=",
"null",
",",
"value",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"100",
";",
"j",
"++",
")",
"{",
"if",
"(",
"init",
")",
"value",
"=",
"init",
"(",
... | simple benchmarks, and measure standard deviation | [
"simple",
"benchmarks",
"and",
"measure",
"standard",
"deviation"
] | 522050a6ce00af236e17c709d38621261b87d590 | https://github.com/dominictarr/hashlru/blob/522050a6ce00af236e17c709d38621261b87d590/bench.js#L6-L15 | train |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
if (config) {
if (config.element) {
this.expect.element(config.element).to.not.be.visible;
} else {
throw new Error('adminUIApp:must specify an element!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
return this;
} | javascript | function (config) {
if (config) {
if (config.element) {
this.expect.element(config.element).to.not.be.visible;
} else {
throw new Error('adminUIApp:must specify an element!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
return this;
} | [
"function",
"(",
"config",
")",
"{",
"if",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"element",
")",
"{",
"this",
".",
"expect",
".",
"element",
"(",
"config",
".",
"element",
")",
".",
"to",
".",
"not",
".",
"be",
".",
"visible",
";",
... | Asserts that the specified home screen element UI is not visible.
@param {Object} config The config spec.
@param {string} config.element The element whose UI should not be visible. | [
"Asserts",
"that",
"the",
"specified",
"home",
"screen",
"element",
"UI",
"is",
"not",
"visible",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L48-L59 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
if (config) {
if (config.element) {
this.expect.element(config.element).to.be.present;
} else {
throw new Error('adminUIApp:must specify an element!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
return this;
} | javascript | function (config) {
if (config) {
if (config.element) {
this.expect.element(config.element).to.be.present;
} else {
throw new Error('adminUIApp:must specify an element!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
return this;
} | [
"function",
"(",
"config",
")",
"{",
"if",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"element",
")",
"{",
"this",
".",
"expect",
".",
"element",
"(",
"config",
".",
"element",
")",
".",
"to",
".",
"be",
".",
"present",
";",
"}",
"else",
... | Asserts that the specified home screen element DOM is present.
@param {Object} config The config spec.
@param {string} config.element The element whose DOM should be present. | [
"Asserts",
"that",
"the",
"specified",
"home",
"screen",
"element",
"DOM",
"is",
"present",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L67-L78 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
if (config) {
if (config.element && config.text) {
this.expect.element(config.element).text.to.equal(config.text);
} else {
throw new Error('adminUIApp:must specify an element and text!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
... | javascript | function (config) {
if (config) {
if (config.element && config.text) {
this.expect.element(config.element).text.to.equal(config.text);
} else {
throw new Error('adminUIApp:must specify an element and text!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
... | [
"function",
"(",
"config",
")",
"{",
"if",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"element",
"&&",
"config",
".",
"text",
")",
"{",
"this",
".",
"expect",
".",
"element",
"(",
"config",
".",
"element",
")",
".",
"text",
".",
"to",
"."... | Asserts that the specified home screen element text equals the specified value.
@param {Object} config The config spec.
@param {string} config.element The element whose text should be compared to the input text.
@param {String} config.text The text to compare against. | [
"Asserts",
"that",
"the",
"specified",
"home",
"screen",
"element",
"text",
"equals",
"the",
"specified",
"value",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L106-L117 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
if (config) {
if (config.element && config.text) {
this.expect.element(config.element).text.to.contain(config.text);
} else {
throw new Error('adminUIApp:must specify an element and text!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
... | javascript | function (config) {
if (config) {
if (config.element && config.text) {
this.expect.element(config.element).text.to.contain(config.text);
} else {
throw new Error('adminUIApp:must specify an element and text!');
}
} else {
throw new Error('adminUIApp:invalid config specification!');
}
... | [
"function",
"(",
"config",
")",
"{",
"if",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"element",
"&&",
"config",
".",
"text",
")",
"{",
"this",
".",
"expect",
".",
"element",
"(",
"config",
".",
"element",
")",
".",
"text",
".",
"to",
"."... | Asserts that the specified home screen element text contains the specified value.
@param {Object} config The config spec.
@param {string} config.element The element whose text should contain the input text.
@param {String} config.text The text to compare against. | [
"Asserts",
"that",
"the",
"specified",
"home",
"screen",
"element",
"text",
"contains",
"the",
"specified",
"value",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L146-L157 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
if (config) {
if (config.element && config.attribute && config.value) {
this.expect.element(config.element).to.have.attribute(config.attribute).which.contains(config.value);
} else {
throw new Error('adminUIApp:must specify a config element, attribute, and value!');
}
} e... | javascript | function (config) {
if (config) {
if (config.element && config.attribute && config.value) {
this.expect.element(config.element).to.have.attribute(config.attribute).which.contains(config.value);
} else {
throw new Error('adminUIApp:must specify a config element, attribute, and value!');
}
} e... | [
"function",
"(",
"config",
")",
"{",
"if",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"element",
"&&",
"config",
".",
"attribute",
"&&",
"config",
".",
"value",
")",
"{",
"this",
".",
"expect",
".",
"element",
"(",
"config",
".",
"element",
... | Asserts that the specified home screen element has the specified attribute.
@param {Object} config The config spec.
@param {string} config.element The element whose UI should be visible.
@param {string} config.attribute The attribute that should be present in the element.
@param {string} config.value The value that th... | [
"Asserts",
"that",
"the",
"specified",
"home",
"screen",
"element",
"has",
"the",
"specified",
"attribute",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L167-L178 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
var _config = objectAssign({}, { wait: true }, config);
this.navigate();
if (_config.wait) this.waitForSigninScreen();
return this;
} | javascript | function (config) {
var _config = objectAssign({}, { wait: true }, config);
this.navigate();
if (_config.wait) this.waitForSigninScreen();
return this;
} | [
"function",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"objectAssign",
"(",
"{",
"}",
",",
"{",
"wait",
":",
"true",
"}",
",",
"config",
")",
";",
"this",
".",
"navigate",
"(",
")",
";",
"if",
"(",
"_config",
".",
"wait",
")",
"this",
".",
... | Navigates to the signin screen.
@param {Object} config The config spec.
@param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true. | [
"Navigates",
"to",
"the",
"signin",
"screen",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L186-L191 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
var _config = objectAssign({}, { wait: true }, config);
this.navigate();
if (_config.wait) this.waitForHomeScreen();
return this;
} | javascript | function (config) {
var _config = objectAssign({}, { wait: true }, config);
this.navigate();
if (_config.wait) this.waitForHomeScreen();
return this;
} | [
"function",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"objectAssign",
"(",
"{",
"}",
",",
"{",
"wait",
":",
"true",
"}",
",",
"config",
")",
";",
"this",
".",
"navigate",
"(",
")",
";",
"if",
"(",
"_config",
".",
"wait",
")",
"this",
".",
... | Navigates to the home screen.
@param {Object} config The config spec.
@param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true. | [
"Navigates",
"to",
"the",
"home",
"screen",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L199-L204 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
var _config = objectAssign({}, { wait: true }, config);
if (_config.section && _config.list) {
this.clickPrimaryNavbar({ section: _config.section })
.waitForForSecondaryNavbar()
.clickSecondaryNavbar({ list: _config.list });
} else {
throw new Error('adminUIApp:must specif... | javascript | function (config) {
var _config = objectAssign({}, { wait: true }, config);
if (_config.section && _config.list) {
this.clickPrimaryNavbar({ section: _config.section })
.waitForForSecondaryNavbar()
.clickSecondaryNavbar({ list: _config.list });
} else {
throw new Error('adminUIApp:must specif... | [
"function",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"objectAssign",
"(",
"{",
"}",
",",
"{",
"wait",
":",
"true",
"}",
",",
"config",
")",
";",
"if",
"(",
"_config",
".",
"section",
"&&",
"_config",
".",
"list",
")",
"{",
"this",
".",
"cl... | Opens the list of items given the specified list config spec.
@param {Object} config The config spec.
@param {string} config.section The section in the primary navbar to click on.
@param {string} config.list The list in the secondary navbar to click on.
@param {boolean} config.wait Whether to wait for the target UI. ... | [
"Opens",
"the",
"list",
"of",
"items",
"given",
"the",
"specified",
"list",
"config",
"spec",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L214-L225 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
var _config = objectAssign({}, { wait: true }, config);
if (_config.section) {
this.click(this.getPrimaryNavbarSectionElement({ section: _config.section }));
} else {
throw new Error('adminUIApp:must specify a navbar section!');
}
if (_config.wait) this.waitForForSecondaryNavb... | javascript | function (config) {
var _config = objectAssign({}, { wait: true }, config);
if (_config.section) {
this.click(this.getPrimaryNavbarSectionElement({ section: _config.section }));
} else {
throw new Error('adminUIApp:must specify a navbar section!');
}
if (_config.wait) this.waitForForSecondaryNavb... | [
"function",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"objectAssign",
"(",
"{",
"}",
",",
"{",
"wait",
":",
"true",
"}",
",",
"config",
")",
";",
"if",
"(",
"_config",
".",
"section",
")",
"{",
"this",
".",
"click",
"(",
"this",
".",
"getPr... | Clicks the specified section in the primary navbar.
@param {Object} config The config spec.
@param {string} config.section The section in the primary navbar to click on.
@param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true. | [
"Clicks",
"the",
"specified",
"section",
"in",
"the",
"primary",
"navbar",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L234-L243 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
var _config = objectAssign({}, { wait: true }, config);
if (_config.list) {
this.click(this.getSecondaryNavbarListElement({ list: _config.list }));
} else {
throw new Error('adminUIApp:must specify a navbar list!');
}
if (_config.wait) this.waitForListScreen();
return this;... | javascript | function (config) {
var _config = objectAssign({}, { wait: true }, config);
if (_config.list) {
this.click(this.getSecondaryNavbarListElement({ list: _config.list }));
} else {
throw new Error('adminUIApp:must specify a navbar list!');
}
if (_config.wait) this.waitForListScreen();
return this;... | [
"function",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"objectAssign",
"(",
"{",
"}",
",",
"{",
"wait",
":",
"true",
"}",
",",
"config",
")",
";",
"if",
"(",
"_config",
".",
"list",
")",
"{",
"this",
".",
"click",
"(",
"this",
".",
"getSecon... | Clicks the specified list in the secondary navbar.
@param {Object} config The config spec.
@param {string} list The list in the secondary navbar to click on.
@param {boolean} config.wait Whether to wait for the target UI. Optional, defaults to true. | [
"Clicks",
"the",
"specified",
"list",
"in",
"the",
"secondary",
"navbar",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L252-L261 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
var _config = objectAssign({}, { timeout: this.api.globals.waitForConditionTimeout }, config);
this.waitForElementVisible('@signinScreen', _config.timeout);
this.api.pause(self.screenTransitionTimeout);
return this;
} | javascript | function (config) {
var _config = objectAssign({}, { timeout: this.api.globals.waitForConditionTimeout }, config);
this.waitForElementVisible('@signinScreen', _config.timeout);
this.api.pause(self.screenTransitionTimeout);
return this;
} | [
"function",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"objectAssign",
"(",
"{",
"}",
",",
"{",
"timeout",
":",
"this",
".",
"api",
".",
"globals",
".",
"waitForConditionTimeout",
"}",
",",
"config",
")",
";",
"this",
".",
"waitForElementVisible",
"... | Waits for the signin screen UI to be visible.
@param {Object} config The config spec.
@param {number} config.timeout Optional timeout to wait for. | [
"Waits",
"for",
"the",
"signin",
"screen",
"UI",
"to",
"be",
"visible",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L284-L289 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
return this.expect.element(this.getPrimaryNavbarSectionElement({ section: config.section })).to.be.visible;
} | javascript | function (config) {
return this.expect.element(this.getPrimaryNavbarSectionElement({ section: config.section })).to.be.visible;
} | [
"function",
"(",
"config",
")",
"{",
"return",
"this",
".",
"expect",
".",
"element",
"(",
"this",
".",
"getPrimaryNavbarSectionElement",
"(",
"{",
"section",
":",
"config",
".",
"section",
"}",
")",
")",
".",
"to",
".",
"be",
".",
"visible",
";",
"}"
... | Asserts that the specified primary navbar section is visible.
@param {Object} config The config spec.
@param {string} config.section The section that should be visible in the primary navbar. | [
"Asserts",
"that",
"the",
"specified",
"primary",
"navbar",
"section",
"is",
"visible",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L389-L391 | train | |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUIApp.js | function (config) {
return this.expect.element(this.getSecondaryNavbarListElement({ list: config.list })).to.be.visible;
} | javascript | function (config) {
return this.expect.element(this.getSecondaryNavbarListElement({ list: config.list })).to.be.visible;
} | [
"function",
"(",
"config",
")",
"{",
"return",
"this",
".",
"expect",
".",
"element",
"(",
"this",
".",
"getSecondaryNavbarListElement",
"(",
"{",
"list",
":",
"config",
".",
"list",
"}",
")",
")",
".",
"to",
".",
"be",
".",
"visible",
";",
"}"
] | Asserts that the specified secondary navbar list is visible. Make sure that the parent
primary navbar section is clicked on first.
@param {Object} config The config spec.
@param {string} config.list The list that should be visible in the secondary navbar. | [
"Asserts",
"that",
"the",
"specified",
"secondary",
"navbar",
"list",
"is",
"visible",
".",
"Make",
"sure",
"that",
"the",
"parent",
"primary",
"navbar",
"section",
"is",
"clicked",
"on",
"first",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUIApp.js#L400-L402 | train | |
keystonejs/keystone-nightwatch-e2e | index.js | function (cb) {
if (argv.env === 'default' && argv['selenium-in-background']) {
process.env.KNE_SELENIUM_START_PROCESS = false;
runSeleniumInBackground(cb);
} else if (argv.env === 'default') {
process.env.KNE_SELENIUM_START_PROCESS = true;
cb();
} else {
process.env.KNE_SEL... | javascript | function (cb) {
if (argv.env === 'default' && argv['selenium-in-background']) {
process.env.KNE_SELENIUM_START_PROCESS = false;
runSeleniumInBackground(cb);
} else if (argv.env === 'default') {
process.env.KNE_SELENIUM_START_PROCESS = true;
cb();
} else {
process.env.KNE_SEL... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"argv",
".",
"env",
"===",
"'default'",
"&&",
"argv",
"[",
"'selenium-in-background'",
"]",
")",
"{",
"process",
".",
"env",
".",
"KNE_SELENIUM_START_PROCESS",
"=",
"false",
";",
"runSeleniumInBackground",
"(",
"cb... | If the user wants us to start selenium manually then do so | [
"If",
"the",
"user",
"wants",
"us",
"to",
"start",
"selenium",
"manually",
"then",
"do",
"so"
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L102-L113 | train | |
keystonejs/keystone-nightwatch-e2e | index.js | function (cb) {
if (argv.env === 'saucelabs-travis' || (argv.env === 'saucelabs-local' && argv['sauce-username'] && argv['sauce-access-key'])) {
startSauceConnect(cb);
} else {
if (argv.env === 'saucelabs-local') {
console.error([moment().format('HH:mm:ss:SSS')] + ' kne: You must specify --... | javascript | function (cb) {
if (argv.env === 'saucelabs-travis' || (argv.env === 'saucelabs-local' && argv['sauce-username'] && argv['sauce-access-key'])) {
startSauceConnect(cb);
} else {
if (argv.env === 'saucelabs-local') {
console.error([moment().format('HH:mm:ss:SSS')] + ' kne: You must specify --... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"argv",
".",
"env",
"===",
"'saucelabs-travis'",
"||",
"(",
"argv",
".",
"env",
"===",
"'saucelabs-local'",
"&&",
"argv",
"[",
"'sauce-username'",
"]",
"&&",
"argv",
"[",
"'sauce-access-key'",
"]",
")",
")",
"{... | The only environment that currently requires starting sauce connect is travis. | [
"The",
"only",
"environment",
"that",
"currently",
"requires",
"starting",
"sauce",
"connect",
"is",
"travis",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L118-L129 | train | |
keystonejs/keystone-nightwatch-e2e | index.js | function (cb) {
Nightwatch.runner(argv, function (status) {
var err = null;
if (status) {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests passed');
} else {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests failed');
err = new Error('kne: nightwatch ru... | javascript | function (cb) {
Nightwatch.runner(argv, function (status) {
var err = null;
if (status) {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests passed');
} else {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: tests failed');
err = new Error('kne: nightwatch ru... | [
"function",
"(",
"cb",
")",
"{",
"Nightwatch",
".",
"runner",
"(",
"argv",
",",
"function",
"(",
"status",
")",
"{",
"var",
"err",
"=",
"null",
";",
"if",
"(",
"status",
")",
"{",
"console",
".",
"log",
"(",
"[",
"moment",
"(",
")",
".",
"format"... | Run nightwatch to start executing the tests | [
"Run",
"nightwatch",
"to",
"start",
"executing",
"the",
"tests"
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L134-L145 | train | |
keystonejs/keystone-nightwatch-e2e | index.js | startSauceConnect | function startSauceConnect (done) {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: Starting Sauce Connect');
var default_options = {
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
connectRetries: 5,
connectRetryTimeout: 60000,
logger: sauceConnectLog,
readyFileId: ... | javascript | function startSauceConnect (done) {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: Starting Sauce Connect');
var default_options = {
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
connectRetries: 5,
connectRetryTimeout: 60000,
logger: sauceConnectLog,
readyFileId: ... | [
"function",
"startSauceConnect",
"(",
"done",
")",
"{",
"console",
".",
"log",
"(",
"[",
"moment",
"(",
")",
".",
"format",
"(",
"'HH:mm:ss:SSS'",
")",
"]",
"+",
"' kne: Starting Sauce Connect'",
")",
";",
"var",
"default_options",
"=",
"{",
"username",
":",... | Function that starts the sauce connect servers if SAUCE_ACCESS_KEY is set. | [
"Function",
"that",
"starts",
"the",
"sauce",
"connect",
"servers",
"if",
"SAUCE_ACCESS_KEY",
"is",
"set",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L168-L197 | train |
keystonejs/keystone-nightwatch-e2e | index.js | checkKeystoneReady | function checkKeystoneReady (keystone, done) {
async.retry({
times: 10,
interval: 3000,
}, function (done, result) {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: checking if KeystoneJS ready for request');
request
.get('http://' + keystone.get('host') + ':' + keystone.get('port') + '/keystone')
... | javascript | function checkKeystoneReady (keystone, done) {
async.retry({
times: 10,
interval: 3000,
}, function (done, result) {
console.log([moment().format('HH:mm:ss:SSS')] + ' kne: checking if KeystoneJS ready for request');
request
.get('http://' + keystone.get('host') + ':' + keystone.get('port') + '/keystone')
... | [
"function",
"checkKeystoneReady",
"(",
"keystone",
",",
"done",
")",
"{",
"async",
".",
"retry",
"(",
"{",
"times",
":",
"10",
",",
"interval",
":",
"3000",
",",
"}",
",",
"function",
"(",
"done",
",",
"result",
")",
"{",
"console",
".",
"log",
"(",
... | Function that checks if keystone is ready before starting testing | [
"Function",
"that",
"checks",
"if",
"keystone",
"is",
"ready",
"before",
"starting",
"testing"
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/index.js#L213-L231 | train |
keystonejs/keystone-nightwatch-e2e | lib/src/pageObjects/adminUISignin.js | function (config) {
var _config = objectAssign({}, { user: 'user@test.e2e', password: 'test', wait: true }, config);
this
.setValue('@email', _config.user)
.setValue('@password', _config.password)
.click('@submitButton');
if (_config.wait) this.api.page.adminUIApp().waitForHomeScreen();
return t... | javascript | function (config) {
var _config = objectAssign({}, { user: 'user@test.e2e', password: 'test', wait: true }, config);
this
.setValue('@email', _config.user)
.setValue('@password', _config.password)
.click('@submitButton');
if (_config.wait) this.api.page.adminUIApp().waitForHomeScreen();
return t... | [
"function",
"(",
"config",
")",
"{",
"var",
"_config",
"=",
"objectAssign",
"(",
"{",
"}",
",",
"{",
"user",
":",
"'user@test.e2e'",
",",
"password",
":",
"'test'",
",",
"wait",
":",
"true",
"}",
",",
"config",
")",
";",
"this",
".",
"setValue",
"(",... | Signs in to the Admin UI.
@param {Object} config The login info.
@param {string} config.user The login username/email.
@param {string} config.password The login password.
@param {boolean} config.wait Whether to wait for the home screen by default. Optional, defaults to true. | [
"Signs",
"in",
"to",
"the",
"Admin",
"UI",
"."
] | 4329b4b296ade1339363837f9f11ba4ea42e1858 | https://github.com/keystonejs/keystone-nightwatch-e2e/blob/4329b4b296ade1339363837f9f11ba4ea42e1858/lib/src/pageObjects/adminUISignin.js#L29-L37 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(model, options) {
Backbone.Model.apply(this, arguments);
var defaults = _.result(this, 'defaults');
// Apply defaults only after first sync.
this.once('sync', function() {
this.set(_.defaults(this.toJSON(), defaults));
});
this.autoSync = Backbone.Fir... | javascript | function(model, options) {
Backbone.Model.apply(this, arguments);
var defaults = _.result(this, 'defaults');
// Apply defaults only after first sync.
this.once('sync', function() {
this.set(_.defaults(this.toJSON(), defaults));
});
this.autoSync = Backbone.Fir... | [
"function",
"(",
"model",
",",
"options",
")",
"{",
"Backbone",
".",
"Model",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"defaults",
"=",
"_",
".",
"result",
"(",
"this",
",",
"'defaults'",
")",
";",
"// Apply defaults only after first s... | Determine whether the realtime or once methods apply | [
"Determine",
"whether",
"the",
"realtime",
"or",
"once",
"methods",
"apply"
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L276-L309 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(snap) {
var newModel = Backbone.Firebase._checkId(snap);
if (typeof newModel === 'object' && newModel !== null) {
var diff = _.difference(_.keys(this.attributes), _.keys(newModel));
_.each(diff, _.bind(function(key) {
this.unset(key);
}, this));
... | javascript | function(snap) {
var newModel = Backbone.Firebase._checkId(snap);
if (typeof newModel === 'object' && newModel !== null) {
var diff = _.difference(_.keys(this.attributes), _.keys(newModel));
_.each(diff, _.bind(function(key) {
this.unset(key);
}, this));
... | [
"function",
"(",
"snap",
")",
"{",
"var",
"newModel",
"=",
"Backbone",
".",
"Firebase",
".",
"_checkId",
"(",
"snap",
")",
";",
"if",
"(",
"typeof",
"newModel",
"===",
"'object'",
"&&",
"newModel",
"!==",
"null",
")",
"{",
"var",
"diff",
"=",
"_",
".... | Unset attributes that have been deleted from the server
by comparing the keys that have been removed. | [
"Unset",
"attributes",
"that",
"have",
"been",
"deleted",
"from",
"the",
"server",
"by",
"comparing",
"the",
"keys",
"that",
"have",
"been",
"removed",
"."
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L334-L348 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(model) {
var modelObj = model.changedAttributes();
_.each(model.changed, function(value, key) {
if (typeof value === 'undefined' || value === null) {
if (key == 'id') {
delete modelObj[key];
} else {
modelObj[key] = null;
... | javascript | function(model) {
var modelObj = model.changedAttributes();
_.each(model.changed, function(value, key) {
if (typeof value === 'undefined' || value === null) {
if (key == 'id') {
delete modelObj[key];
} else {
modelObj[key] = null;
... | [
"function",
"(",
"model",
")",
"{",
"var",
"modelObj",
"=",
"model",
".",
"changedAttributes",
"(",
")",
";",
"_",
".",
"each",
"(",
"model",
".",
"changed",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
... | Find the deleted keys and set their values to null
so Firebase properly deletes them. | [
"Find",
"the",
"deleted",
"keys",
"and",
"set",
"their",
"values",
"to",
"null",
"so",
"Firebase",
"properly",
"deletes",
"them",
"."
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L354-L367 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(cb) {
var method = cb ? 'on' : 'off';
this[method]('change', function(model) {
var newModel = this._updateModel(model);
if(_.isFunction(cb)){
cb.call(this, newModel);
}
}, this);
} | javascript | function(cb) {
var method = cb ? 'on' : 'off';
this[method]('change', function(model) {
var newModel = this._updateModel(model);
if(_.isFunction(cb)){
cb.call(this, newModel);
}
}, this);
} | [
"function",
"(",
"cb",
")",
"{",
"var",
"method",
"=",
"cb",
"?",
"'on'",
":",
"'off'",
";",
"this",
"[",
"method",
"]",
"(",
"'change'",
",",
"function",
"(",
"model",
")",
"{",
"var",
"newModel",
"=",
"this",
".",
"_updateModel",
"(",
"model",
")... | Determine if the model will update for every local change.
Provide a callback function to call events after the update. | [
"Determine",
"if",
"the",
"model",
"will",
"update",
"for",
"every",
"local",
"change",
".",
"Provide",
"a",
"callback",
"function",
"to",
"call",
"events",
"after",
"the",
"update",
"."
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L374-L382 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(model, options) {
model.id = Backbone.Firebase._getKey(this.firebase.push());
options = _.extend({ autoSync: false }, options);
return Backbone.Collection.prototype.create.apply(this, [model, options]);
} | javascript | function(model, options) {
model.id = Backbone.Firebase._getKey(this.firebase.push());
options = _.extend({ autoSync: false }, options);
return Backbone.Collection.prototype.create.apply(this, [model, options]);
} | [
"function",
"(",
"model",
",",
"options",
")",
"{",
"model",
".",
"id",
"=",
"Backbone",
".",
"Firebase",
".",
"_getKey",
"(",
"this",
".",
"firebase",
".",
"push",
"(",
")",
")",
";",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"autoSync",
":",
... | Create an id from a Firebase push-id and call Backbone.create, which
will do prepare the models and trigger the proper events and then call
Backbone.Firebase.sync with the correct method. | [
"Create",
"an",
"id",
"from",
"a",
"Firebase",
"push",
"-",
"id",
"and",
"call",
"Backbone",
".",
"create",
"which",
"will",
"do",
"prepare",
"the",
"models",
"and",
"trigger",
"the",
"proper",
"events",
"and",
"then",
"call",
"Backbone",
".",
"Firebase",
... | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L396-L400 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(options) {
options = options ? _.clone(options) : {};
if (options.parse === void 0) { options.parse = true; }
var success = options.success;
var collection = this;
options.success = function(resp) {
var arr = [];
var keys = _.keys(resp);... | javascript | function(options) {
options = options ? _.clone(options) : {};
if (options.parse === void 0) { options.parse = true; }
var success = options.success;
var collection = this;
options.success = function(resp) {
var arr = [];
var keys = _.keys(resp);... | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"?",
"_",
".",
"clone",
"(",
"options",
")",
":",
"{",
"}",
";",
"if",
"(",
"options",
".",
"parse",
"===",
"void",
"0",
")",
"{",
"options",
".",
"parse",
"=",
"true",
";",
"}",
... | Firebase returns lists as an object with keys, where Backbone
collections require an array. This function modifies the existing
Backbone.Collection.fetch method by mapping the returned object from
Firebase to an array that Backbone can use. | [
"Firebase",
"returns",
"lists",
"as",
"an",
"object",
"with",
"keys",
"where",
"Backbone",
"collections",
"require",
"an",
"array",
".",
"This",
"function",
"modifies",
"the",
"existing",
"Backbone",
".",
"Collection",
".",
"fetch",
"method",
"by",
"mapping",
... | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L423-L442 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(snap) {
var model = Backbone.Firebase._checkId(snap);
var item = _.find(this.models, function(child) {
return child.id == model.id;
});
if (!item) {
// TODO: Investigate: what is the right way to handle this case?
//throw new Error('... | javascript | function(snap) {
var model = Backbone.Firebase._checkId(snap);
var item = _.find(this.models, function(child) {
return child.id == model.id;
});
if (!item) {
// TODO: Investigate: what is the right way to handle this case?
//throw new Error('... | [
"function",
"(",
"snap",
")",
"{",
"var",
"model",
"=",
"Backbone",
".",
"Firebase",
".",
"_checkId",
"(",
"snap",
")",
";",
"var",
"item",
"=",
"_",
".",
"find",
"(",
"this",
".",
"models",
",",
"function",
"(",
"child",
")",
"{",
"return",
"child... | when a model has changed remotely find differences between the local and remote data and apply them to the local model | [
"when",
"a",
"model",
"has",
"changed",
"remotely",
"find",
"differences",
"between",
"the",
"local",
"and",
"remote",
"data",
"and",
"apply",
"them",
"to",
"the",
"local",
"model"
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L592-L620 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(snap) {
var model = Backbone.Firebase._checkId(snap);
if (this._suppressEvent === true) {
this._suppressEvent = false;
Backbone.Collection.prototype.remove.apply(
this, [model], {silent: true}
);
} else {
// trigger sy... | javascript | function(snap) {
var model = Backbone.Firebase._checkId(snap);
if (this._suppressEvent === true) {
this._suppressEvent = false;
Backbone.Collection.prototype.remove.apply(
this, [model], {silent: true}
);
} else {
// trigger sy... | [
"function",
"(",
"snap",
")",
"{",
"var",
"model",
"=",
"Backbone",
".",
"Firebase",
".",
"_checkId",
"(",
"snap",
")",
";",
"if",
"(",
"this",
".",
"_suppressEvent",
"===",
"true",
")",
"{",
"this",
".",
"_suppressEvent",
"=",
"false",
";",
"Backbone"... | remove an item from the collection when removed remotely provides the ability to remove siliently | [
"remove",
"an",
"item",
"from",
"the",
"collection",
"when",
"removed",
"remotely",
"provides",
"the",
"ability",
"to",
"remove",
"siliently"
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L624-L637 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(model) {
var remoteAttributes;
var localAttributes;
var updateAttributes;
var ref;
// if the model is already being handled by listeners then return
if (model._remoteChanging) {
return;
}
remoteAttributes = model._rem... | javascript | function(model) {
var remoteAttributes;
var localAttributes;
var updateAttributes;
var ref;
// if the model is already being handled by listeners then return
if (model._remoteChanging) {
return;
}
remoteAttributes = model._rem... | [
"function",
"(",
"model",
")",
"{",
"var",
"remoteAttributes",
";",
"var",
"localAttributes",
";",
"var",
"updateAttributes",
";",
"var",
"ref",
";",
"// if the model is already being handled by listeners then return",
"if",
"(",
"model",
".",
"_remoteChanging",
")",
... | Add handlers for all models in this collection, and any future ones that may be added. | [
"Add",
"handlers",
"for",
"all",
"models",
"in",
"this",
"collection",
"and",
"any",
"future",
"ones",
"that",
"may",
"be",
"added",
"."
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L641-L668 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(remoteAttributes, localAttributes) {
var updateAttributes = {};
var union = _.union(_.keys(remoteAttributes), _.keys(localAttributes));
_.each(union, function(key) {
if (!_.has(localAttributes, key)) {
updateAttributes[key] = null;
} else if... | javascript | function(remoteAttributes, localAttributes) {
var updateAttributes = {};
var union = _.union(_.keys(remoteAttributes), _.keys(localAttributes));
_.each(union, function(key) {
if (!_.has(localAttributes, key)) {
updateAttributes[key] = null;
} else if... | [
"function",
"(",
"remoteAttributes",
",",
"localAttributes",
")",
"{",
"var",
"updateAttributes",
"=",
"{",
"}",
";",
"var",
"union",
"=",
"_",
".",
"union",
"(",
"_",
".",
"keys",
"(",
"remoteAttributes",
")",
",",
"_",
".",
"keys",
"(",
"localAttribute... | set the attributes to be updated to Firebase set any removed attributes to null so that Firebase removes them | [
"set",
"the",
"attributes",
"to",
"be",
"updated",
"to",
"Firebase",
"set",
"any",
"removed",
"attributes",
"to",
"null",
"so",
"that",
"Firebase",
"removes",
"them"
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L672-L686 | train | |
googlearchive/backbonefire | examples/todos/js/backbonefire.js | function(ref, item) {
var priority = item['.priority'];
delete item['.priority'];
ref.setWithPriority(item, priority);
return item;
} | javascript | function(ref, item) {
var priority = item['.priority'];
delete item['.priority'];
ref.setWithPriority(item, priority);
return item;
} | [
"function",
"(",
"ref",
",",
"item",
")",
"{",
"var",
"priority",
"=",
"item",
"[",
"'.priority'",
"]",
";",
"delete",
"item",
"[",
"'.priority'",
"]",
";",
"ref",
".",
"setWithPriority",
"(",
"item",
",",
"priority",
")",
";",
"return",
"item",
";",
... | Special case if '.priority' was updated - a merge is not allowed so we'll have to do a full setWithPriority. | [
"Special",
"case",
"if",
".",
"priority",
"was",
"updated",
"-",
"a",
"merge",
"is",
"not",
"allowed",
"so",
"we",
"ll",
"have",
"to",
"do",
"a",
"full",
"setWithPriority",
"."
] | d6278d4aeb0743bdd7e9de96cc56d4e64476778b | https://github.com/googlearchive/backbonefire/blob/d6278d4aeb0743bdd7e9de96cc56d4e64476778b/examples/todos/js/backbonefire.js#L690-L695 | train | |
repetere/modelscript | build/modelscript.umd.js | function(data, param) {
var eol = getEol(data,param);
var lines = data.split(eol);
var partial = lines.pop();
return {lines: lines, partial: partial};
} | javascript | function(data, param) {
var eol = getEol(data,param);
var lines = data.split(eol);
var partial = lines.pop();
return {lines: lines, partial: partial};
} | [
"function",
"(",
"data",
",",
"param",
")",
"{",
"var",
"eol",
"=",
"getEol",
"(",
"data",
",",
"param",
")",
";",
"var",
"lines",
"=",
"data",
".",
"split",
"(",
"eol",
")",
";",
"var",
"partial",
"=",
"lines",
".",
"pop",
"(",
")",
";",
"retu... | convert data chunk to file lines array
@param {string} data data chunk as utf8 string
@param {object} param Converter param object
@return {Object} {lines:[line1,line2...],partial:String} | [
"convert",
"data",
"chunk",
"to",
"file",
"lines",
"array"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7560-L7565 | train | |
repetere/modelscript | build/modelscript.umd.js | rowSplit | function rowSplit(rowStr, param) {
if (rowStr === "") {
return { cols: [], closed: true };
}
var quote = param.quote;
var trim = param.trim;
var escape = param.escape;
if (param.delimiter instanceof Array || param.delimi... | javascript | function rowSplit(rowStr, param) {
if (rowStr === "") {
return { cols: [], closed: true };
}
var quote = param.quote;
var trim = param.trim;
var escape = param.escape;
if (param.delimiter instanceof Array || param.delimi... | [
"function",
"rowSplit",
"(",
"rowStr",
",",
"param",
")",
"{",
"if",
"(",
"rowStr",
"===",
"\"\"",
")",
"{",
"return",
"{",
"cols",
":",
"[",
"]",
",",
"closed",
":",
"true",
"}",
";",
"}",
"var",
"quote",
"=",
"param",
".",
"quote",
";",
"var",
... | Convert a line of string to csv columns according to its delimiter
the param._header may not be ready when this is called.
@param {[type]} rowStr [description]
@param {[type]} param [Converter param]
@return {[type]} {cols:["a","b","c"],closed:boolean} the closed field indicate if the row is a complete row | [
"Convert",
"a",
"line",
"of",
"string",
"to",
"csv",
"columns",
"according",
"to",
"its",
"delimiter",
"the",
"param",
".",
"_header",
"may",
"not",
"be",
"ready",
"when",
"this",
"is",
"called",
"."
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7617-L7692 | train |
repetere/modelscript | build/modelscript.umd.js | function(lines, param) {
var csvLines = [];
var left = "";
while (lines.length) {
var line = left + lines.shift();
var row = rowSplit(line, param);
if (row.closed) {
csvLines.push(row.cols);
lef... | javascript | function(lines, param) {
var csvLines = [];
var left = "";
while (lines.length) {
var line = left + lines.shift();
var row = rowSplit(line, param);
if (row.closed) {
csvLines.push(row.cols);
lef... | [
"function",
"(",
"lines",
",",
"param",
")",
"{",
"var",
"csvLines",
"=",
"[",
"]",
";",
"var",
"left",
"=",
"\"\"",
";",
"while",
"(",
"lines",
".",
"length",
")",
"{",
"var",
"line",
"=",
"left",
"+",
"lines",
".",
"shift",
"(",
")",
";",
"va... | Convert lines to csv columns
@param {[type]} lines [file lines]
@param {[type]} param [Converter param]
@return {[type]} {lines:[[col1,col2,col3...]],partial:String} | [
"Convert",
"lines",
"to",
"csv",
"columns"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7737-L7751 | train | |
repetere/modelscript | build/modelscript.umd.js | function(fileLine, params) {
var lines = fileLine.lines;
var csvLines = csvline(lines,params);
return {
lines: csvLines.lines,
partial: csvLines.partial + fileLine.partial
};
} | javascript | function(fileLine, params) {
var lines = fileLine.lines;
var csvLines = csvline(lines,params);
return {
lines: csvLines.lines,
partial: csvLines.partial + fileLine.partial
};
} | [
"function",
"(",
"fileLine",
",",
"params",
")",
"{",
"var",
"lines",
"=",
"fileLine",
".",
"lines",
";",
"var",
"csvLines",
"=",
"csvline",
"(",
"lines",
",",
"params",
")",
";",
"return",
"{",
"lines",
":",
"csvLines",
".",
"lines",
",",
"partial",
... | Convert data chunk to csv lines with cols
@param {[type]} data [description]
@param {[type]} params [description]
@return {[type]} {lines:[[col1,col2,col3]],partial:String} | [
"Convert",
"data",
"chunk",
"to",
"csv",
"lines",
"with",
"cols"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L7759-L7766 | train | |
repetere/modelscript | build/modelscript.umd.js | function (lines, params, idx) {
if (params._needParseJson) {
if (!params._headers) {
params._headers = [];
}
if (!params.parseRules) {
var row = params._headers;
params.parseRules = parserMgr.initParsers(... | javascript | function (lines, params, idx) {
if (params._needParseJson) {
if (!params._headers) {
params._headers = [];
}
if (!params.parseRules) {
var row = params._headers;
params.parseRules = parserMgr.initParsers(... | [
"function",
"(",
"lines",
",",
"params",
",",
"idx",
")",
"{",
"if",
"(",
"params",
".",
"_needParseJson",
")",
"{",
"if",
"(",
"!",
"params",
".",
"_headers",
")",
"{",
"params",
".",
"_headers",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"params"... | Convert lines of csv array into json
@param {[type]} lines [[col1,col2,col3]]
@param {[type]} params Converter params with _headers field populated
@param {[type]} idx start pos of the lines
@return {[type]} [{err:null,json:obj,index:line,row:[csv row]}] | [
"Convert",
"lines",
"of",
"csv",
"array",
"into",
"json"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L9419-L9432 | train | |
repetere/modelscript | build/modelscript.umd.js | _initConverter | function _initConverter(){
var csvConverter = new Converter_1();
var started = false;
var writeStream = process.stdout;
csvConverter.on("record_parsed",function(rowJSON){
if (started){
writeStream.write(",\n");
... | javascript | function _initConverter(){
var csvConverter = new Converter_1();
var started = false;
var writeStream = process.stdout;
csvConverter.on("record_parsed",function(rowJSON){
if (started){
writeStream.write(",\n");
... | [
"function",
"_initConverter",
"(",
")",
"{",
"var",
"csvConverter",
"=",
"new",
"Converter_1",
"(",
")",
";",
"var",
"started",
"=",
"false",
";",
"var",
"writeStream",
"=",
"process",
".",
"stdout",
";",
"csvConverter",
".",
"on",
"(",
"\"record_parsed\"",
... | Convert input to process stdout
implementation | [
"Convert",
"input",
"to",
"process",
"stdout",
"implementation"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27505-L27528 | train |
repetere/modelscript | build/modelscript.umd.js | loadCSVURI | async function loadCSVURI(filepath, options) {
const reqMethod = (filepath.search('https', 'gi') > -1) ? get : get;
return new Promise((resolve, reject) => {
const csvData = [];
const config = Object.assign({ checkType: true, }, options);
... | javascript | async function loadCSVURI(filepath, options) {
const reqMethod = (filepath.search('https', 'gi') > -1) ? get : get;
return new Promise((resolve, reject) => {
const csvData = [];
const config = Object.assign({ checkType: true, }, options);
... | [
"async",
"function",
"loadCSVURI",
"(",
"filepath",
",",
"options",
")",
"{",
"const",
"reqMethod",
"=",
"(",
"filepath",
".",
"search",
"(",
"'https'",
",",
"'gi'",
")",
">",
"-",
"1",
")",
"?",
"get",
":",
"get",
";",
"return",
"new",
"Promise",
"(... | Asynchronously loads a CSV from a remote URL and returns an array of objects
@example
// returns [{header:value,header2:value2}]
loadCSVURI('https://raw.githubusercontent.com/repetere/modelscript/master/test/mock/data.csv').then(csvData).catch(console.error)
@memberOf csv
@param {string} filepath - URL to CSV path
@par... | [
"Asynchronously",
"loads",
"a",
"CSV",
"from",
"a",
"remote",
"URL",
"and",
"returns",
"an",
"array",
"of",
"objects"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27578-L27601 | train |
repetere/modelscript | build/modelscript.umd.js | loadCSV | async function loadCSV(filepath, options) {
if (validUrl.isUri(filepath)) {
return loadCSVURI(filepath, options);
} else {
return new Promise((resolve, reject) => {
const csvData = [];
const config = Object.assign({ ch... | javascript | async function loadCSV(filepath, options) {
if (validUrl.isUri(filepath)) {
return loadCSVURI(filepath, options);
} else {
return new Promise((resolve, reject) => {
const csvData = [];
const config = Object.assign({ ch... | [
"async",
"function",
"loadCSV",
"(",
"filepath",
",",
"options",
")",
"{",
"if",
"(",
"validUrl",
".",
"isUri",
"(",
"filepath",
")",
")",
"{",
"return",
"loadCSVURI",
"(",
"filepath",
",",
"options",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Promi... | Asynchronously loads a CSV from either a filepath or remote URL and returns an array of objects
@example
// returns [{header:value,header2:value2}]
loadCSV('../mock/invalid-file.csv').then(csvData).catch(console.error)
@memberOf csv
@param {string} filepath - URL to CSV path
@param {Object} [options] - options passed t... | [
"Asynchronously",
"loads",
"a",
"CSV",
"from",
"either",
"a",
"filepath",
"or",
"remote",
"URL",
"and",
"returns",
"an",
"array",
"of",
"objects"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27614-L27637 | train |
repetere/modelscript | build/modelscript.umd.js | loadTSV | async function loadTSV(filepath, options) {
const tsvOptions = Object.assign({
checkType: true,
}, options, {
delimiter: '\t',
});
return loadCSV(filepath, tsvOptions);
} | javascript | async function loadTSV(filepath, options) {
const tsvOptions = Object.assign({
checkType: true,
}, options, {
delimiter: '\t',
});
return loadCSV(filepath, tsvOptions);
} | [
"async",
"function",
"loadTSV",
"(",
"filepath",
",",
"options",
")",
"{",
"const",
"tsvOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"checkType",
":",
"true",
",",
"}",
",",
"options",
",",
"{",
"delimiter",
":",
"'\\t'",
",",
"}",
")",
";",
"re... | Asynchronously loads a TSV from either a filepath or remote URL and returns an array of objects
@example
// returns [{header:value,header2:value2}]
loadCSV('../mock/invalid-file.tsv').then(csvData).catch(console.error)
@memberOf csv
@param {string} filepath - URL to CSV path
@param {Object} [options] - options passed t... | [
"Asynchronously",
"loads",
"a",
"TSV",
"from",
"either",
"a",
"filepath",
"or",
"remote",
"URL",
"and",
"returns",
"an",
"array",
"of",
"objects"
] | b507fad9b3ecfb4a9ec4d44d41052a8082dac763 | https://github.com/repetere/modelscript/blob/b507fad9b3ecfb4a9ec4d44d41052a8082dac763/build/modelscript.umd.js#L27649-L27656 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.