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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
tether/request-body | index.js | add | function add (obj, name, value) {
const previous = obj[name]
if (previous) {
const arr = [].concat(previous)
arr.push(value)
return arr
} else return value
} | javascript | function add (obj, name, value) {
const previous = obj[name]
if (previous) {
const arr = [].concat(previous)
arr.push(value)
return arr
} else return value
} | [
"function",
"add",
"(",
"obj",
",",
"name",
",",
"value",
")",
"{",
"const",
"previous",
"=",
"obj",
"[",
"name",
"]",
"if",
"(",
"previous",
")",
"{",
"const",
"arr",
"=",
"[",
"]",
".",
"concat",
"(",
"previous",
")",
"arr",
".",
"push",
"(",
... | Return value of array of values.
@param {Object} obj
@param {String} name
@param {Any} value
@return {Any|Array}
@api private | [
"Return",
"value",
"of",
"array",
"of",
"values",
"."
] | 825dfc130b728847dd1836b76383c17b3811ce93 | https://github.com/tether/request-body/blob/825dfc130b728847dd1836b76383c17b3811ce93/index.js#L89-L96 | train |
reelyactive/chickadee | lib/routes/contextat.js | retrieveContextAtReceiver | function retrieveContextAtReceiver(req, res) {
if(redirect(req.params.id, '', '', res)) {
return;
}
switch(req.accepts(['json', 'html'])) {
case 'html':
res.sendFile(path.resolve(__dirname + '/../../web/response.html'));
break;
default:
var options = {
query: 'receivedStrong... | javascript | function retrieveContextAtReceiver(req, res) {
if(redirect(req.params.id, '', '', res)) {
return;
}
switch(req.accepts(['json', 'html'])) {
case 'html':
res.sendFile(path.resolve(__dirname + '/../../web/response.html'));
break;
default:
var options = {
query: 'receivedStrong... | [
"function",
"retrieveContextAtReceiver",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"redirect",
"(",
"req",
".",
"params",
".",
"id",
",",
"''",
",",
"''",
",",
"res",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"req",
".",
"accepts",
"(",
... | Retrieve the context at a given receiver device id.
@param {Object} req The HTTP request.
@param {Object} res The HTTP result. | [
"Retrieve",
"the",
"context",
"at",
"a",
"given",
"receiver",
"device",
"id",
"."
] | 1f65c2d369694d93796aae63318fa76326275120 | https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/routes/contextat.js#L37-L59 | train |
fulmicoton/potato | doc/assets/CodeMirror-2.22/mode/xmlpure/xmlpure.js | popContext | function popContext(state) {
if (state.context) {
var oldContext = state.context;
state.context = oldContext.prev;
return oldContext;
}
// we shouldn't be here - it means we didn't have a context to pop
return null;
} | javascript | function popContext(state) {
if (state.context) {
var oldContext = state.context;
state.context = oldContext.prev;
return oldContext;
}
// we shouldn't be here - it means we didn't have a context to pop
return null;
} | [
"function",
"popContext",
"(",
"state",
")",
"{",
"if",
"(",
"state",
".",
"context",
")",
"{",
"var",
"oldContext",
"=",
"state",
".",
"context",
";",
"state",
".",
"context",
"=",
"oldContext",
".",
"prev",
";",
"return",
"oldContext",
";",
"}",
"// ... | go up a level in the document | [
"go",
"up",
"a",
"level",
"in",
"the",
"document"
] | 50f9506224b65f9f171ac52e5a9c8311f9f41c67 | https://github.com/fulmicoton/potato/blob/50f9506224b65f9f171ac52e5a9c8311f9f41c67/doc/assets/CodeMirror-2.22/mode/xmlpure/xmlpure.js#L75-L84 | train |
fulmicoton/potato | doc/assets/CodeMirror-2.22/mode/xmlpure/xmlpure.js | isTokenSeparated | function isTokenSeparated(stream) {
return stream.sol() ||
stream.string.charAt(stream.start - 1) == " " ||
stream.string.charAt(stream.start - 1) == "\t";
} | javascript | function isTokenSeparated(stream) {
return stream.sol() ||
stream.string.charAt(stream.start - 1) == " " ||
stream.string.charAt(stream.start - 1) == "\t";
} | [
"function",
"isTokenSeparated",
"(",
"stream",
")",
"{",
"return",
"stream",
".",
"sol",
"(",
")",
"||",
"stream",
".",
"string",
".",
"charAt",
"(",
"stream",
".",
"start",
"-",
"1",
")",
"==",
"\" \"",
"||",
"stream",
".",
"string",
".",
"charAt",
... | return true if the current token is seperated from the tokens before it which means either this is the start of the line, or there is at least one space or tab character behind the token otherwise returns false | [
"return",
"true",
"if",
"the",
"current",
"token",
"is",
"seperated",
"from",
"the",
"tokens",
"before",
"it",
"which",
"means",
"either",
"this",
"is",
"the",
"start",
"of",
"the",
"line",
"or",
"there",
"is",
"at",
"least",
"one",
"space",
"or",
"tab",... | 50f9506224b65f9f171ac52e5a9c8311f9f41c67 | https://github.com/fulmicoton/potato/blob/50f9506224b65f9f171ac52e5a9c8311f9f41c67/doc/assets/CodeMirror-2.22/mode/xmlpure/xmlpure.js#L90-L94 | train |
CodeOtter/bulkhead | lib/Plugin.js | loadPackage | function loadPackage(target, location, section, options, done) {
if(section == 'config') {
options.dirname = path.resolve(location + '/' + section);
} else {
options.dirname = path.resolve(location + '/api/' + section);
}
buildDictionary.optional(options, function(err, modules) {
if(err) return done(err);
... | javascript | function loadPackage(target, location, section, options, done) {
if(section == 'config') {
options.dirname = path.resolve(location + '/' + section);
} else {
options.dirname = path.resolve(location + '/api/' + section);
}
buildDictionary.optional(options, function(err, modules) {
if(err) return done(err);
... | [
"function",
"loadPackage",
"(",
"target",
",",
"location",
",",
"section",
",",
"options",
",",
"done",
")",
"{",
"if",
"(",
"section",
"==",
"'config'",
")",
"{",
"options",
".",
"dirname",
"=",
"path",
".",
"resolve",
"(",
"location",
"+",
"'/'",
"+"... | This function will merge Sails-like components into an NPM package, forming a Bulkhead package.
@private
@param Object The NPM module instance
@param String The location of the package
@param String The category name of Sails-like components
@param Object Sails-build-directory configuration override
@param Functio... | [
"This",
"function",
"will",
"merge",
"Sails",
"-",
"like",
"components",
"into",
"an",
"NPM",
"package",
"forming",
"a",
"Bulkhead",
"package",
"."
] | 7a247ef30a600c83dce0dd3e8921e306e2895324 | https://github.com/CodeOtter/bulkhead/blob/7a247ef30a600c83dce0dd3e8921e306e2895324/lib/Plugin.js#L23-L42 | train |
CodeOtter/bulkhead | lib/Plugin.js | function(sails, done) {
sails.log.silly('Initializing Bulkhead packages...');
// Detach models from the Sails instance
var bulkheads = Object.keys(Bulkhead),
i = 0,
detachedLoadModels = sails.modules.loadModels;
/**
* Reload event that loads each Bulkhead package's models
*/
var reloadedEvent = f... | javascript | function(sails, done) {
sails.log.silly('Initializing Bulkhead packages...');
// Detach models from the Sails instance
var bulkheads = Object.keys(Bulkhead),
i = 0,
detachedLoadModels = sails.modules.loadModels;
/**
* Reload event that loads each Bulkhead package's models
*/
var reloadedEvent = f... | [
"function",
"(",
"sails",
",",
"done",
")",
"{",
"sails",
".",
"log",
".",
"silly",
"(",
"'Initializing Bulkhead packages...'",
")",
";",
"// Detach models from the Sails instance",
"var",
"bulkheads",
"=",
"Object",
".",
"keys",
"(",
"Bulkhead",
")",
",",
"i",
... | Initializes all registered Bulkhead packages, grafts them to the Sails object, then moves them to their individual packages.
@param Object Sails instance
@param Function Callback to fire when initialization is finished | [
"Initializes",
"all",
"registered",
"Bulkhead",
"packages",
"grafts",
"them",
"to",
"the",
"Sails",
"object",
"then",
"moves",
"them",
"to",
"their",
"individual",
"packages",
"."
] | 7a247ef30a600c83dce0dd3e8921e306e2895324 | https://github.com/CodeOtter/bulkhead/blob/7a247ef30a600c83dce0dd3e8921e306e2895324/lib/Plugin.js#L70-L142 | train | |
CodeOtter/bulkhead | lib/Plugin.js | function() {
_.each(Bulkhead, function(bulkhead, bulkheadName) {
// A registered Bulkhead package needs to be initiated, bound to the Sails instance, detached, and merged back into the Bulkhead
_.each(bulkhead.models, function(model, index) {
bulkhead.models[model.originalIdentity] = sails.models[model.... | javascript | function() {
_.each(Bulkhead, function(bulkhead, bulkheadName) {
// A registered Bulkhead package needs to be initiated, bound to the Sails instance, detached, and merged back into the Bulkhead
_.each(bulkhead.models, function(model, index) {
bulkhead.models[model.originalIdentity] = sails.models[model.... | [
"function",
"(",
")",
"{",
"_",
".",
"each",
"(",
"Bulkhead",
",",
"function",
"(",
"bulkhead",
",",
"bulkheadName",
")",
"{",
"// A registered Bulkhead package needs to be initiated, bound to the Sails instance, detached, and merged back into the Bulkhead",
"_",
".",
"each",... | Reload event that loads each Bulkhead package's models | [
"Reload",
"event",
"that",
"loads",
"each",
"Bulkhead",
"package",
"s",
"models"
] | 7a247ef30a600c83dce0dd3e8921e306e2895324 | https://github.com/CodeOtter/bulkhead/blob/7a247ef30a600c83dce0dd3e8921e306e2895324/lib/Plugin.js#L80-L104 | train | |
rtm/upward | src/Upw.js | make | function make(x, options = {}) {
var {debug = DEBUG_ALL} = options;
var u;
debug = DEBUG && debug;
if (x === undefined) u = makeUndefined();
else if (x === null) u = makeNull();
else {
u = Object(x);
if (!is(u)) {
add(u, debug);
defineProperty(u, 'change', { value: change });
}
}... | javascript | function make(x, options = {}) {
var {debug = DEBUG_ALL} = options;
var u;
debug = DEBUG && debug;
if (x === undefined) u = makeUndefined();
else if (x === null) u = makeNull();
else {
u = Object(x);
if (!is(u)) {
add(u, debug);
defineProperty(u, 'change', { value: change });
}
}... | [
"function",
"make",
"(",
"x",
",",
"options",
"=",
"{",
"}",
")",
"{",
"var",
"{",
"debug",
"=",
"DEBUG_ALL",
"}",
"=",
"options",
";",
"var",
"u",
";",
"debug",
"=",
"DEBUG",
"&&",
"debug",
";",
"if",
"(",
"x",
"===",
"undefined",
")",
"u",
"=... | Make a new upwardable. Register it, and add a `change` method which notifies when it is to be replaced. | [
"Make",
"a",
"new",
"upwardable",
".",
"Register",
"it",
"and",
"add",
"a",
"change",
"method",
"which",
"notifies",
"when",
"it",
"is",
"to",
"be",
"replaced",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Upw.js#L47-L64 | train |
rtm/upward | src/Upw.js | change | function change(x) {
var u = this;
var debug = u._upwardableDebug;
if (x !== this.valueOf()) {
u = make(x, { debug });
getNotifier(this).notify({object: this, newValue: u, type: 'upward'});
if (debug) {
console.debug(...channel.debug("Replaced upwardable", this._upwardableId, "with", u._upward... | javascript | function change(x) {
var u = this;
var debug = u._upwardableDebug;
if (x !== this.valueOf()) {
u = make(x, { debug });
getNotifier(this).notify({object: this, newValue: u, type: 'upward'});
if (debug) {
console.debug(...channel.debug("Replaced upwardable", this._upwardableId, "with", u._upward... | [
"function",
"change",
"(",
"x",
")",
"{",
"var",
"u",
"=",
"this",
";",
"var",
"debug",
"=",
"u",
".",
"_upwardableDebug",
";",
"if",
"(",
"x",
"!==",
"this",
".",
"valueOf",
"(",
")",
")",
"{",
"u",
"=",
"make",
"(",
"x",
",",
"{",
"debug",
... | Change an upwardable. Issue notification that it has changed. | [
"Change",
"an",
"upwardable",
".",
"Issue",
"notification",
"that",
"it",
"has",
"changed",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Upw.js#L67-L80 | train |
hexoul/metasdk-react | src/components/util.js | setQRstyle | function setQRstyle (dst, src, caller) {
dst['qrpopup'] = src.qrpopup ? src.qrpopup : false
dst['qrsize'] = src.qrsize > 0 ? src.qrsize : 128
dst['qrvoffset'] = src.qrvoffset >= 0 ? src.qrvoffset : 20
dst['qrpadding'] = src.qrpadding ? src.qrpadding : '1em'
dst['qrposition'] = POSITIONS.includes(src.qrpositio... | javascript | function setQRstyle (dst, src, caller) {
dst['qrpopup'] = src.qrpopup ? src.qrpopup : false
dst['qrsize'] = src.qrsize > 0 ? src.qrsize : 128
dst['qrvoffset'] = src.qrvoffset >= 0 ? src.qrvoffset : 20
dst['qrpadding'] = src.qrpadding ? src.qrpadding : '1em'
dst['qrposition'] = POSITIONS.includes(src.qrpositio... | [
"function",
"setQRstyle",
"(",
"dst",
",",
"src",
",",
"caller",
")",
"{",
"dst",
"[",
"'qrpopup'",
"]",
"=",
"src",
".",
"qrpopup",
"?",
"src",
".",
"qrpopup",
":",
"false",
"dst",
"[",
"'qrsize'",
"]",
"=",
"src",
".",
"qrsize",
">",
"0",
"?",
... | Set QRCode style to dst from src
@param {map} dst
@param {map} src props
@param {string} caller name | [
"Set",
"QRCode",
"style",
"to",
"dst",
"from",
"src"
] | 5aa275bf2e19336edc1f5f0d3b43afc979cc2f42 | https://github.com/hexoul/metasdk-react/blob/5aa275bf2e19336edc1f5f0d3b43afc979cc2f42/src/components/util.js#L25-L32 | train |
hexoul/metasdk-react | src/components/util.js | convertData2Hexd | function convertData2Hexd (data) {
if (!isHexString(data)) {
var hex = ''
for (var i = 0; i < data.length; i++) {
hex += data.charCodeAt(i).toString(16)
}
return '0x' + hex
}
return data
} | javascript | function convertData2Hexd (data) {
if (!isHexString(data)) {
var hex = ''
for (var i = 0; i < data.length; i++) {
hex += data.charCodeAt(i).toString(16)
}
return '0x' + hex
}
return data
} | [
"function",
"convertData2Hexd",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"isHexString",
"(",
"data",
")",
")",
"{",
"var",
"hex",
"=",
"''",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"hex",
... | Convert to hexadecimal for data property of SendTransaction
@param {*} data | [
"Convert",
"to",
"hexadecimal",
"for",
"data",
"property",
"of",
"SendTransaction"
] | 5aa275bf2e19336edc1f5f0d3b43afc979cc2f42 | https://github.com/hexoul/metasdk-react/blob/5aa275bf2e19336edc1f5f0d3b43afc979cc2f42/src/components/util.js#L66-L75 | train |
alexindigo/batcher | lib/augmenter.js | augmenter | function augmenter(object, subject, hookCb)
{
var unaugment, originalCb = object[subject];
unaugment = function()
{
// return everything back to normal
object[subject] = originalCb;
};
object[subject] = function()
{
var args = Array.prototype.slice.call(arguments)
, result = originalCb... | javascript | function augmenter(object, subject, hookCb)
{
var unaugment, originalCb = object[subject];
unaugment = function()
{
// return everything back to normal
object[subject] = originalCb;
};
object[subject] = function()
{
var args = Array.prototype.slice.call(arguments)
, result = originalCb... | [
"function",
"augmenter",
"(",
"object",
",",
"subject",
",",
"hookCb",
")",
"{",
"var",
"unaugment",
",",
"originalCb",
"=",
"object",
"[",
"subject",
"]",
";",
"unaugment",
"=",
"function",
"(",
")",
"{",
"// return everything back to normal",
"object",
"[",
... | Augments provided callback to invoke custom hook after
original callback invocation but before passing control
@param {object} object - object to augment
@param {string} subject - name of the callback property
@param {function} hookCb - hook callback to add to the chain
@returns {function} - provide un-augment f... | [
"Augments",
"provided",
"callback",
"to",
"invoke",
"custom",
"hook",
"after",
"original",
"callback",
"invocation",
"but",
"before",
"passing",
"control"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/augmenter.js#L13-L38 | train |
richardschneider/table-master-parser | lib/parser.js | step | function step() {
var f = script.shift();
if(f) {
f(stack, step);
}
else {
return cb(null, stack.pop());
}
} | javascript | function step() {
var f = script.shift();
if(f) {
f(stack, step);
}
else {
return cb(null, stack.pop());
}
} | [
"function",
"step",
"(",
")",
"{",
"var",
"f",
"=",
"script",
".",
"shift",
"(",
")",
";",
"if",
"(",
"f",
")",
"{",
"f",
"(",
"stack",
",",
"step",
")",
";",
"}",
"else",
"{",
"return",
"cb",
"(",
"null",
",",
"stack",
".",
"pop",
"(",
")"... | Execute the functions asynchronously | [
"Execute",
"the",
"functions",
"asynchronously"
] | 4236d465ba209f1f00b3c09631d75a9ec607c9e8 | https://github.com/richardschneider/table-master-parser/blob/4236d465ba209f1f00b3c09631d75a9ec607c9e8/lib/parser.js#L23-L31 | train |
stayradiated/onepasswordjs | src/crypto_browser.js | function(ciphertext, key, iv, encoding) {
var binary, bytes, hex;
if (encoding == null) {
encoding = "buffer";
}
iv = this.toBuffer(iv);
key = this.toBuffer(key);
ciphertext = this.toBuffer(ciphertext);
binary = Gibberish.rawDecrypt(ciphertext, key, iv, true);
hex... | javascript | function(ciphertext, key, iv, encoding) {
var binary, bytes, hex;
if (encoding == null) {
encoding = "buffer";
}
iv = this.toBuffer(iv);
key = this.toBuffer(key);
ciphertext = this.toBuffer(ciphertext);
binary = Gibberish.rawDecrypt(ciphertext, key, iv, true);
hex... | [
"function",
"(",
"ciphertext",
",",
"key",
",",
"iv",
",",
"encoding",
")",
"{",
"var",
"binary",
",",
"bytes",
",",
"hex",
";",
"if",
"(",
"encoding",
"==",
"null",
")",
"{",
"encoding",
"=",
"\"buffer\"",
";",
"}",
"iv",
"=",
"this",
".",
"toBuff... | Decipher encrypted data.
@param {String|Buffer} ciphertext The data to decipher. Must be a multiple of the blocksize.
@param {String|Buffer} key The key to decipher the data with.
@param {String|Buffer} iv The initialization vector to use.
@param {String} [encoding=buffer] The format to return the decrypted contents as... | [
"Decipher",
"encrypted",
"data",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L59-L81 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(password, salt, iterations, keysize) {
var bits, hmac, self;
if (iterations == null) {
iterations = 10000;
}
if (keysize == null) {
keysize = 512;
}
self = this;
hmac = (function() {
function hmac(key) {
this.key = sjcl.codec.bytes.fro... | javascript | function(password, salt, iterations, keysize) {
var bits, hmac, self;
if (iterations == null) {
iterations = 10000;
}
if (keysize == null) {
keysize = 512;
}
self = this;
hmac = (function() {
function hmac(key) {
this.key = sjcl.codec.bytes.fro... | [
"function",
"(",
"password",
",",
"salt",
",",
"iterations",
",",
"keysize",
")",
"{",
"var",
"bits",
",",
"hmac",
",",
"self",
";",
"if",
"(",
"iterations",
"==",
"null",
")",
"{",
"iterations",
"=",
"10000",
";",
"}",
"if",
"(",
"keysize",
"==",
... | Generate keys from password using PKDF2-HMAC-SHA512.
@param {String} password The password.
@param {String|Buffer} salt The salt.
@param {Number} [iterations=10000] The numbers of iterations.
@param {Numbers} [keysize=512] The length of the derived key in bits.
@return {String} Returns the derived key encoded as hex. | [
"Generate",
"keys",
"from",
"password",
"using",
"PKDF2",
"-",
"HMAC",
"-",
"SHA512",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L91-L119 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(data, key, keysize) {
var input, mode;
if (keysize == null) {
keysize = 512;
}
data = this.toHex(data);
key = this.toHex(key);
mode = "SHA-" + keysize;
input = new jsSHA(data, "HEX");
return input.getHMAC(key, "HEX", mode, "HEX");
} | javascript | function(data, key, keysize) {
var input, mode;
if (keysize == null) {
keysize = 512;
}
data = this.toHex(data);
key = this.toHex(key);
mode = "SHA-" + keysize;
input = new jsSHA(data, "HEX");
return input.getHMAC(key, "HEX", mode, "HEX");
} | [
"function",
"(",
"data",
",",
"key",
",",
"keysize",
")",
"{",
"var",
"input",
",",
"mode",
";",
"if",
"(",
"keysize",
"==",
"null",
")",
"{",
"keysize",
"=",
"512",
";",
"}",
"data",
"=",
"this",
".",
"toHex",
"(",
"data",
")",
";",
"key",
"="... | Cryptographically hash data using HMAC.
@param {String|Buffer} data The data to be hashed.
@param {String|Buffer} key The key to use with HMAC.
@param {Number} [keysize=512] The keysize for the hash function.
@return {String} The hmac digest encoded as hex. | [
"Cryptographically",
"hash",
"data",
"using",
"HMAC",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L128-L138 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(data, keysize) {
var input, mode;
if (keysize == null) {
keysize = 512;
}
data = this.toHex(data);
mode = "SHA-" + keysize;
input = new jsSHA(data, "HEX");
return input.getHash(mode, "HEX");
} | javascript | function(data, keysize) {
var input, mode;
if (keysize == null) {
keysize = 512;
}
data = this.toHex(data);
mode = "SHA-" + keysize;
input = new jsSHA(data, "HEX");
return input.getHash(mode, "HEX");
} | [
"function",
"(",
"data",
",",
"keysize",
")",
"{",
"var",
"input",
",",
"mode",
";",
"if",
"(",
"keysize",
"==",
"null",
")",
"{",
"keysize",
"=",
"512",
";",
"}",
"data",
"=",
"this",
".",
"toHex",
"(",
"data",
")",
";",
"mode",
"=",
"\"SHA-\"",... | Create a hash digest of data.
@param {String|Buffer} data The data to hash.
@param {Number} [keysize=512] The keysize for the hash function.
@return {String} The hash digest encoded as hex. | [
"Create",
"a",
"hash",
"digest",
"of",
"data",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L146-L155 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(data) {
var bytesToPad, padding;
bytesToPad = BLOCKSIZE - (data.length % BLOCKSIZE);
padding = this.randomBytes(bytesToPad);
return this.concat([padding, data]);
} | javascript | function(data) {
var bytesToPad, padding;
bytesToPad = BLOCKSIZE - (data.length % BLOCKSIZE);
padding = this.randomBytes(bytesToPad);
return this.concat([padding, data]);
} | [
"function",
"(",
"data",
")",
"{",
"var",
"bytesToPad",
",",
"padding",
";",
"bytesToPad",
"=",
"BLOCKSIZE",
"-",
"(",
"data",
".",
"length",
"%",
"BLOCKSIZE",
")",
";",
"padding",
"=",
"this",
".",
"randomBytes",
"(",
"bytesToPad",
")",
";",
"return",
... | Prepend padding to data to make it fill the blocksize.
@param {Buffer} data The data to pad.
@return {Buffer} The data with padding added. | [
"Prepend",
"padding",
"to",
"data",
"to",
"make",
"it",
"fill",
"the",
"blocksize",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L162-L167 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(length) {
var array, byte, _i, _len, _results;
array = new Uint8Array(length);
window.crypto.getRandomValues(array);
_results = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
byte = array[_i];
_results.push(byte);
}
return _results;
} | javascript | function(length) {
var array, byte, _i, _len, _results;
array = new Uint8Array(length);
window.crypto.getRandomValues(array);
_results = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
byte = array[_i];
_results.push(byte);
}
return _results;
} | [
"function",
"(",
"length",
")",
"{",
"var",
"array",
",",
"byte",
",",
"_i",
",",
"_len",
",",
"_results",
";",
"array",
"=",
"new",
"Uint8Array",
"(",
"length",
")",
";",
"window",
".",
"crypto",
".",
"getRandomValues",
"(",
"array",
")",
";",
"_res... | Generates cryptographically strong pseudo-random data.
@param {Numbers} length How many bytes of data you want.
@return {Buffer} The random data as a Buffer. | [
"Generates",
"cryptographically",
"strong",
"pseudo",
"-",
"random",
"data",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L186-L196 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(data, encoding) {
if (encoding == null) {
encoding = 'hex';
}
if (Array.isArray(data)) {
return data;
}
switch (encoding) {
case 'base64':
return Gibberish.base64.decode(data);
case 'hex':
return Gibberish.h2a(data);
case... | javascript | function(data, encoding) {
if (encoding == null) {
encoding = 'hex';
}
if (Array.isArray(data)) {
return data;
}
switch (encoding) {
case 'base64':
return Gibberish.base64.decode(data);
case 'hex':
return Gibberish.h2a(data);
case... | [
"function",
"(",
"data",
",",
"encoding",
")",
"{",
"if",
"(",
"encoding",
"==",
"null",
")",
"{",
"encoding",
"=",
"'hex'",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"data",
")",
")",
"{",
"return",
"data",
";",
"}",
"switch",
"(",
"enc... | Convert data to a Buffer
@param {String|Buffer} data The data to be converted. If a string, must be encoded as hex.
@param {String} [encoding=hex] The format of the data to convert.
@return {Buffer} The data as a Buffer | [
"Convert",
"data",
"to",
"a",
"Buffer"
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L204-L221 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(hex) {
var pow, result;
result = 0;
pow = 0;
while (hex.length > 0) {
result += parseInt(hex.substring(0, 2), 16) * Math.pow(2, pow);
hex = hex.substring(2, hex.length);
pow += 8;
}
return result;
} | javascript | function(hex) {
var pow, result;
result = 0;
pow = 0;
while (hex.length > 0) {
result += parseInt(hex.substring(0, 2), 16) * Math.pow(2, pow);
hex = hex.substring(2, hex.length);
pow += 8;
}
return result;
} | [
"function",
"(",
"hex",
")",
"{",
"var",
"pow",
",",
"result",
";",
"result",
"=",
"0",
";",
"pow",
"=",
"0",
";",
"while",
"(",
"hex",
".",
"length",
">",
"0",
")",
"{",
"result",
"+=",
"parseInt",
"(",
"hex",
".",
"substring",
"(",
"0",
",",
... | Parse a litte endian number.
@author Jim Rogers {@link http://www.jimandkatrin.com/CodeBlog/post/Parse-a-little-endian.aspx}
@param {String} hex The little endian number.
@return {Number} The little endian converted to a number. | [
"Parse",
"a",
"litte",
"endian",
"number",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L259-L269 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(number, pad) {
var endian, i, multiplier, padding, power, remainder, value, _i;
if (pad == null) {
pad = true;
}
power = Math.floor((Math.log(number) / Math.LN2) / 8) * 8;
multiplier = Math.pow(2, power);
value = Math.floor(number / multiplier);
remainder = num... | javascript | function(number, pad) {
var endian, i, multiplier, padding, power, remainder, value, _i;
if (pad == null) {
pad = true;
}
power = Math.floor((Math.log(number) / Math.LN2) / 8) * 8;
multiplier = Math.pow(2, power);
value = Math.floor(number / multiplier);
remainder = num... | [
"function",
"(",
"number",
",",
"pad",
")",
"{",
"var",
"endian",
",",
"i",
",",
"multiplier",
",",
"padding",
",",
"power",
",",
"remainder",
",",
"value",
",",
"_i",
";",
"if",
"(",
"pad",
"==",
"null",
")",
"{",
"pad",
"=",
"true",
";",
"}",
... | Convert an integer into a little endian.
@param {Number} number The integer you want to convert.
@param {Boolean} [pad=true] Pad the little endian with zeroes.
@return {String} The little endian. | [
"Convert",
"an",
"integer",
"into",
"a",
"little",
"endian",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L277-L300 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(dec) {
var hex;
hex = dec.toString(16);
if (hex.length < 2) {
hex = "0" + hex;
}
return hex;
} | javascript | function(dec) {
var hex;
hex = dec.toString(16);
if (hex.length < 2) {
hex = "0" + hex;
}
return hex;
} | [
"function",
"(",
"dec",
")",
"{",
"var",
"hex",
";",
"hex",
"=",
"dec",
".",
"toString",
"(",
"16",
")",
";",
"if",
"(",
"hex",
".",
"length",
"<",
"2",
")",
"{",
"hex",
"=",
"\"0\"",
"+",
"hex",
";",
"}",
"return",
"hex",
";",
"}"
] | Turn a decimal into a hexadecimal.
@param {Number} dec The decimal.
@return {String} The hexadecimal. | [
"Turn",
"a",
"decimal",
"into",
"a",
"hexadecimal",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L307-L314 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(binary) {
var char, hex, _i, _len;
hex = "";
for (_i = 0, _len = binary.length; _i < _len; _i++) {
char = binary[_i];
hex += char.charCodeAt(0).toString(16).replace(/^([\dA-F])$/i, "0$1");
}
return hex;
} | javascript | function(binary) {
var char, hex, _i, _len;
hex = "";
for (_i = 0, _len = binary.length; _i < _len; _i++) {
char = binary[_i];
hex += char.charCodeAt(0).toString(16).replace(/^([\dA-F])$/i, "0$1");
}
return hex;
} | [
"function",
"(",
"binary",
")",
"{",
"var",
"char",
",",
"hex",
",",
"_i",
",",
"_len",
";",
"hex",
"=",
"\"\"",
";",
"for",
"(",
"_i",
"=",
"0",
",",
"_len",
"=",
"binary",
".",
"length",
";",
"_i",
"<",
"_len",
";",
"_i",
"++",
")",
"{",
... | Convert a binary string into a hex string.
@param {String} binary The binary encoded string.
@return {String} The hex encoded string. | [
"Convert",
"a",
"binary",
"string",
"into",
"a",
"hex",
"string",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L321-L329 | train | |
stayradiated/onepasswordjs | src/crypto_browser.js | function(length) {
var bytes, hex;
if (length == null) {
length = 32;
}
length /= 2;
bytes = this.randomBytes(length);
return hex = this.toHex(bytes).toUpperCase();
} | javascript | function(length) {
var bytes, hex;
if (length == null) {
length = 32;
}
length /= 2;
bytes = this.randomBytes(length);
return hex = this.toHex(bytes).toUpperCase();
} | [
"function",
"(",
"length",
")",
"{",
"var",
"bytes",
",",
"hex",
";",
"if",
"(",
"length",
"==",
"null",
")",
"{",
"length",
"=",
"32",
";",
"}",
"length",
"/=",
"2",
";",
"bytes",
"=",
"this",
".",
"randomBytes",
"(",
"length",
")",
";",
"return... | Generate a uuid.
@param {Number} [length=32] The length of the UUID.
@return {String} The UUID. | [
"Generate",
"a",
"uuid",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/src/crypto_browser.js#L336-L344 | train | |
ghinda/durruti | src/durruti.js | decorate | function decorate (Comp) {
var component
// instantiate classes
if (typeof Comp === 'function') {
component = new Comp()
} else {
// make sure we don't change the id on a cached component
component = Object.create(Comp)
}
// components get a new id on render,
// so we can clear the previous ... | javascript | function decorate (Comp) {
var component
// instantiate classes
if (typeof Comp === 'function') {
component = new Comp()
} else {
// make sure we don't change the id on a cached component
component = Object.create(Comp)
}
// components get a new id on render,
// so we can clear the previous ... | [
"function",
"decorate",
"(",
"Comp",
")",
"{",
"var",
"component",
"// instantiate classes",
"if",
"(",
"typeof",
"Comp",
"===",
"'function'",
")",
"{",
"component",
"=",
"new",
"Comp",
"(",
")",
"}",
"else",
"{",
"// make sure we don't change the id on a cached c... | decorate a basic class with durruti specific properties | [
"decorate",
"a",
"basic",
"class",
"with",
"durruti",
"specific",
"properties"
] | a67a95e9a636367b43afffdbede1ba083be00ebe | https://github.com/ghinda/durruti/blob/a67a95e9a636367b43afffdbede1ba083be00ebe/src/durruti.js#L14-L36 | train |
ghinda/durruti | src/durruti.js | cleanAttrNodes | function cleanAttrNodes ($container, includeParent) {
var nodes = [].slice.call($container.querySelectorAll(durrutiElemSelector))
if (includeParent) {
nodes.push($container)
}
nodes.forEach(($node) => {
// cache component in node
$node._durruti = getCachedComponent($node)
// clean-up data att... | javascript | function cleanAttrNodes ($container, includeParent) {
var nodes = [].slice.call($container.querySelectorAll(durrutiElemSelector))
if (includeParent) {
nodes.push($container)
}
nodes.forEach(($node) => {
// cache component in node
$node._durruti = getCachedComponent($node)
// clean-up data att... | [
"function",
"cleanAttrNodes",
"(",
"$container",
",",
"includeParent",
")",
"{",
"var",
"nodes",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"$container",
".",
"querySelectorAll",
"(",
"durrutiElemSelector",
")",
")",
"if",
"(",
"includeParent",
")",
"{",... | remove custom data attributes, and cache the component on the DOM node. | [
"remove",
"custom",
"data",
"attributes",
"and",
"cache",
"the",
"component",
"on",
"the",
"DOM",
"node",
"."
] | a67a95e9a636367b43afffdbede1ba083be00ebe | https://github.com/ghinda/durruti/blob/a67a95e9a636367b43afffdbede1ba083be00ebe/src/durruti.js#L55-L71 | train |
ghinda/durruti | src/durruti.js | getComponentNodes | function getComponentNodes ($container, traverse = true, arr = []) {
if ($container._durruti) {
arr.push($container)
}
if (traverse && $container.children) {
for (let i = 0; i < $container.children.length; i++) {
getComponentNodes($container.children[i], traverse, arr)
}
}
return arr
} | javascript | function getComponentNodes ($container, traverse = true, arr = []) {
if ($container._durruti) {
arr.push($container)
}
if (traverse && $container.children) {
for (let i = 0; i < $container.children.length; i++) {
getComponentNodes($container.children[i], traverse, arr)
}
}
return arr
} | [
"function",
"getComponentNodes",
"(",
"$container",
",",
"traverse",
"=",
"true",
",",
"arr",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$container",
".",
"_durruti",
")",
"{",
"arr",
".",
"push",
"(",
"$container",
")",
"}",
"if",
"(",
"traverse",
"&&",
"... | traverse and find durruti nodes | [
"traverse",
"and",
"find",
"durruti",
"nodes"
] | a67a95e9a636367b43afffdbede1ba083be00ebe | https://github.com/ghinda/durruti/blob/a67a95e9a636367b43afffdbede1ba083be00ebe/src/durruti.js#L149-L161 | train |
BladeRunnerJS/topiarist | src/topiarist.js | extend | function extend(classDefinition, superclass, extraProperties) {
var subclassName = className(classDefinition, 'Subclass');
// Find the right classDefinition - either the one provided, a new one or the one from extraProperties.
var extraPropertiesHasConstructor = typeof extraProperties !== 'undefined' &&
extraProp... | javascript | function extend(classDefinition, superclass, extraProperties) {
var subclassName = className(classDefinition, 'Subclass');
// Find the right classDefinition - either the one provided, a new one or the one from extraProperties.
var extraPropertiesHasConstructor = typeof extraProperties !== 'undefined' &&
extraProp... | [
"function",
"extend",
"(",
"classDefinition",
",",
"superclass",
",",
"extraProperties",
")",
"{",
"var",
"subclassName",
"=",
"className",
"(",
"classDefinition",
",",
"'Subclass'",
")",
";",
"// Find the right classDefinition - either the one provided, a new one or the one ... | Sets up the prototype chain for inheritance.
<p>As well as setting up the prototype chain, this also copies so called 'class' definitions from the superclass
to the subclass and makes sure that constructor will return the correct thing.</p>
@throws Error if the prototype has been modified before extend is called.
@m... | [
"Sets",
"up",
"the",
"prototype",
"chain",
"for",
"inheritance",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L25-L89 | train |
BladeRunnerJS/topiarist | src/topiarist.js | mixin | function mixin(target, Mix) {
assertArgumentOfType('function', target, ERROR_MESSAGES.NOT_CONSTRUCTOR, 'Target', 'mixin');
Mix = toFunction(
Mix,
new TypeError(
msg(
ERROR_MESSAGES.WRONG_TYPE,
'Mix',
'mixin',
'non-null object or function',
Mix === null ? 'null' : typeof Mix
)
)
);
... | javascript | function mixin(target, Mix) {
assertArgumentOfType('function', target, ERROR_MESSAGES.NOT_CONSTRUCTOR, 'Target', 'mixin');
Mix = toFunction(
Mix,
new TypeError(
msg(
ERROR_MESSAGES.WRONG_TYPE,
'Mix',
'mixin',
'non-null object or function',
Mix === null ? 'null' : typeof Mix
)
)
);
... | [
"function",
"mixin",
"(",
"target",
",",
"Mix",
")",
"{",
"assertArgumentOfType",
"(",
"'function'",
",",
"target",
",",
"ERROR_MESSAGES",
".",
"NOT_CONSTRUCTOR",
",",
"'Target'",
",",
"'mixin'",
")",
";",
"Mix",
"=",
"toFunction",
"(",
"Mix",
",",
"new",
... | Mixes functionality in to a class.
<p>Only functions are mixed in.</p>
<p>Code in the mixin is sandboxed and only has access to a 'mixin instance' rather than the real instance.</p>
@memberOf topiarist
@param {function} target
@param {function|Object} Mix | [
"Mixes",
"functionality",
"in",
"to",
"a",
"class",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L102-L146 | train |
BladeRunnerJS/topiarist | src/topiarist.js | inherit | function inherit(target, parent) {
assertArgumentOfType('function', target, ERROR_MESSAGES.NOT_CONSTRUCTOR, 'Target', 'inherit');
parent = toFunction(
parent,
new TypeError(
msg(
ERROR_MESSAGES.WRONG_TYPE,
'Parent',
'inherit',
'non-null object or function',
parent === null ? 'null' : typeof... | javascript | function inherit(target, parent) {
assertArgumentOfType('function', target, ERROR_MESSAGES.NOT_CONSTRUCTOR, 'Target', 'inherit');
parent = toFunction(
parent,
new TypeError(
msg(
ERROR_MESSAGES.WRONG_TYPE,
'Parent',
'inherit',
'non-null object or function',
parent === null ? 'null' : typeof... | [
"function",
"inherit",
"(",
"target",
",",
"parent",
")",
"{",
"assertArgumentOfType",
"(",
"'function'",
",",
"target",
",",
"ERROR_MESSAGES",
".",
"NOT_CONSTRUCTOR",
",",
"'Target'",
",",
"'inherit'",
")",
";",
"parent",
"=",
"toFunction",
"(",
"parent",
","... | Provides multiple inheritance through copying.
<p>This is discouraged; you should prefer to use aggregation first, single inheritance (extends) second, mixins
third and this as a last resort.</p>
@memberOf topiarist
@param {function} target the class that should receive the functionality.
@param {function|Object} par... | [
"Provides",
"multiple",
"inheritance",
"through",
"copying",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L158-L214 | train |
BladeRunnerJS/topiarist | src/topiarist.js | implement | function implement(classDefinition, protocol) {
doImplement(classDefinition, protocol);
setTimeout(function() {
assertHasImplemented(classDefinition, protocol);
}, 0);
return classDefinition;
} | javascript | function implement(classDefinition, protocol) {
doImplement(classDefinition, protocol);
setTimeout(function() {
assertHasImplemented(classDefinition, protocol);
}, 0);
return classDefinition;
} | [
"function",
"implement",
"(",
"classDefinition",
",",
"protocol",
")",
"{",
"doImplement",
"(",
"classDefinition",
",",
"protocol",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"assertHasImplemented",
"(",
"classDefinition",
",",
"protocol",
")",
";",... | Declares that the provided class will implement the provided protocol.
<p>This involves immediately updating an internal list of interfaces attached to the class definition,
and after a <code>setTimeout(0)</code> verifying that it does in fact implement the protocol.</p>
<p>It can be called before the implementations... | [
"Declares",
"that",
"the",
"provided",
"class",
"will",
"implement",
"the",
"provided",
"protocol",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L230-L238 | train |
BladeRunnerJS/topiarist | src/topiarist.js | hasImplemented | function hasImplemented(classDefinition, protocol) {
doImplement(classDefinition, protocol);
assertHasImplemented(classDefinition, protocol);
return classDefinition;
} | javascript | function hasImplemented(classDefinition, protocol) {
doImplement(classDefinition, protocol);
assertHasImplemented(classDefinition, protocol);
return classDefinition;
} | [
"function",
"hasImplemented",
"(",
"classDefinition",
",",
"protocol",
")",
"{",
"doImplement",
"(",
"classDefinition",
",",
"protocol",
")",
";",
"assertHasImplemented",
"(",
"classDefinition",
",",
"protocol",
")",
";",
"return",
"classDefinition",
";",
"}"
] | Declares that the provided class implements the provided protocol.
<p>This involves checking that it does in fact implement the protocol and updating an internal list of
interfaces attached to the class definition.</p>
<p>It should be called after implementations are provided, i.e. at the end of the class definition.... | [
"Declares",
"that",
"the",
"provided",
"class",
"implements",
"the",
"provided",
"protocol",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L254-L259 | train |
BladeRunnerJS/topiarist | src/topiarist.js | isA | function isA(instance, parent) {
if(instance == null) {
assertArgumentNotNullOrUndefined(instance, ERROR_MESSAGES.NULL, 'Object', 'isA');
}
// sneaky edge case where we're checking against an object literal we've mixed in or against a prototype of
// something.
if (typeof parent === 'object' && parent.hasOwnPr... | javascript | function isA(instance, parent) {
if(instance == null) {
assertArgumentNotNullOrUndefined(instance, ERROR_MESSAGES.NULL, 'Object', 'isA');
}
// sneaky edge case where we're checking against an object literal we've mixed in or against a prototype of
// something.
if (typeof parent === 'object' && parent.hasOwnPr... | [
"function",
"isA",
"(",
"instance",
",",
"parent",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"assertArgumentNotNullOrUndefined",
"(",
"instance",
",",
"ERROR_MESSAGES",
".",
"NULL",
",",
"'Object'",
",",
"'isA'",
")",
";",
"}",
"// sneaky edge... | Checks to see if an instance is defined to be a child of a parent.
@memberOf topiarist
@param {Object} instance An instance object to check.
@param {function} parent A potential parent (see classIsA).
@returns {boolean} true if this instance has been constructed from something that is assignable from the parent
or is ... | [
"Checks",
"to",
"see",
"if",
"an",
"instance",
"is",
"defined",
"to",
"be",
"a",
"child",
"of",
"a",
"parent",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L367-L383 | train |
BladeRunnerJS/topiarist | src/topiarist.js | classFulfills | function classFulfills(classDefinition, protocol) {
assertArgumentNotNullOrUndefined(classDefinition, ERROR_MESSAGES.NULL, 'Class', 'classFulfills');
assertArgumentNotNullOrUndefined(protocol, ERROR_MESSAGES.NULL, 'Protocol', 'classFulfills');
return fulfills(classDefinition.prototype, protocol);
} | javascript | function classFulfills(classDefinition, protocol) {
assertArgumentNotNullOrUndefined(classDefinition, ERROR_MESSAGES.NULL, 'Class', 'classFulfills');
assertArgumentNotNullOrUndefined(protocol, ERROR_MESSAGES.NULL, 'Protocol', 'classFulfills');
return fulfills(classDefinition.prototype, protocol);
} | [
"function",
"classFulfills",
"(",
"classDefinition",
",",
"protocol",
")",
"{",
"assertArgumentNotNullOrUndefined",
"(",
"classDefinition",
",",
"ERROR_MESSAGES",
".",
"NULL",
",",
"'Class'",
",",
"'classFulfills'",
")",
";",
"assertArgumentNotNullOrUndefined",
"(",
"pr... | Checks that a class provides a prototype that will fulfil a protocol.
@memberOf topiarist
@param {function} classDefinition
@param {function|Object} protocol
@returns {boolean} | [
"Checks",
"that",
"a",
"class",
"provides",
"a",
"prototype",
"that",
"will",
"fulfil",
"a",
"protocol",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L446-L451 | train |
BladeRunnerJS/topiarist | src/topiarist.js | nonenum | function nonenum(object, propertyName, defaultValue) {
var value = object[propertyName];
if (typeof value === 'undefined') {
value = defaultValue;
Object.defineProperty(object, propertyName, {
enumerable: false,
value: value
});
}
return value;
} | javascript | function nonenum(object, propertyName, defaultValue) {
var value = object[propertyName];
if (typeof value === 'undefined') {
value = defaultValue;
Object.defineProperty(object, propertyName, {
enumerable: false,
value: value
});
}
return value;
} | [
"function",
"nonenum",
"(",
"object",
",",
"propertyName",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"object",
"[",
"propertyName",
"]",
";",
"if",
"(",
"typeof",
"value",
"===",
"'undefined'",
")",
"{",
"value",
"=",
"defaultValue",
";",
"Object... | Returns a nonenumerable property if it exists, or creates one and returns that if it does not.
@private | [
"Returns",
"a",
"nonenumerable",
"property",
"if",
"it",
"exists",
"or",
"creates",
"one",
"and",
"returns",
"that",
"if",
"it",
"does",
"not",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L513-L525 | train |
BladeRunnerJS/topiarist | src/topiarist.js | toFunction | function toFunction(obj, couldNotCastError) {
if (obj == null) {
throw couldNotCastError;
}
var result;
if (typeof obj === 'object') {
if (obj.hasOwnProperty('constructor')) {
if (obj.constructor.prototype !== obj) {
throw couldNotCastError;
}
result = obj.constructor;
} else {
var EmptyIniti... | javascript | function toFunction(obj, couldNotCastError) {
if (obj == null) {
throw couldNotCastError;
}
var result;
if (typeof obj === 'object') {
if (obj.hasOwnProperty('constructor')) {
if (obj.constructor.prototype !== obj) {
throw couldNotCastError;
}
result = obj.constructor;
} else {
var EmptyIniti... | [
"function",
"toFunction",
"(",
"obj",
",",
"couldNotCastError",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"throw",
"couldNotCastError",
";",
"}",
"var",
"result",
";",
"if",
"(",
"typeof",
"obj",
"===",
"'object'",
")",
"{",
"if",
"(",
"obj",... | Easier for us if we treat everything as functions with prototypes. This function makes plain objects behave that
way.
@private | [
"Easier",
"for",
"us",
"if",
"we",
"treat",
"everything",
"as",
"functions",
"with",
"prototypes",
".",
"This",
"function",
"makes",
"plain",
"objects",
"behave",
"that",
"way",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L532-L558 | train |
BladeRunnerJS/topiarist | src/topiarist.js | missingAttributes | function missingAttributes(classdef, protocol) {
var result = [], obj = classdef.prototype, requirement = protocol.prototype;
var item;
for (item in requirement) {
if (typeof obj[item] !== typeof requirement[item]) {
result.push(item);
}
}
for (item in protocol) {
var protocolItemType = typeof protocol[i... | javascript | function missingAttributes(classdef, protocol) {
var result = [], obj = classdef.prototype, requirement = protocol.prototype;
var item;
for (item in requirement) {
if (typeof obj[item] !== typeof requirement[item]) {
result.push(item);
}
}
for (item in protocol) {
var protocolItemType = typeof protocol[i... | [
"function",
"missingAttributes",
"(",
"classdef",
",",
"protocol",
")",
"{",
"var",
"result",
"=",
"[",
"]",
",",
"obj",
"=",
"classdef",
".",
"prototype",
",",
"requirement",
"=",
"protocol",
".",
"prototype",
";",
"var",
"item",
";",
"for",
"(",
"item"... | Returns an array of all of the properties on a protocol that are not on classdef or are of a different type on
classdef.
@private | [
"Returns",
"an",
"array",
"of",
"all",
"of",
"the",
"properties",
"on",
"a",
"protocol",
"that",
"are",
"not",
"on",
"classdef",
"or",
"are",
"of",
"a",
"different",
"type",
"on",
"classdef",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L610-L630 | train |
BladeRunnerJS/topiarist | src/topiarist.js | makeMethod | function makeMethod(func) {
return function() {
var args = [this].concat(slice.call(arguments));
return func.apply(null, args);
};
} | javascript | function makeMethod(func) {
return function() {
var args = [this].concat(slice.call(arguments));
return func.apply(null, args);
};
} | [
"function",
"makeMethod",
"(",
"func",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"this",
"]",
".",
"concat",
"(",
"slice",
".",
"call",
"(",
"arguments",
")",
")",
";",
"return",
"func",
".",
"apply",
"(",
"null",
",",... | Turns a function into a method by using 'this' as the first argument.
@private | [
"Turns",
"a",
"function",
"into",
"a",
"method",
"by",
"using",
"this",
"as",
"the",
"first",
"argument",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L653-L658 | train |
BladeRunnerJS/topiarist | src/topiarist.js | getSandboxedFunction | function getSandboxedFunction(myMixId, Mix, func) {
var result = function() {
var mixInstances = nonenum(this, '__multiparentInstances__', []);
var mixInstance = mixInstances[myMixId];
if (mixInstance == null) {
if (typeof Mix === 'function') {
mixInstance = new Mix();
} else {
mixInstance = Object... | javascript | function getSandboxedFunction(myMixId, Mix, func) {
var result = function() {
var mixInstances = nonenum(this, '__multiparentInstances__', []);
var mixInstance = mixInstances[myMixId];
if (mixInstance == null) {
if (typeof Mix === 'function') {
mixInstance = new Mix();
} else {
mixInstance = Object... | [
"function",
"getSandboxedFunction",
"(",
"myMixId",
",",
"Mix",
",",
"func",
")",
"{",
"var",
"result",
"=",
"function",
"(",
")",
"{",
"var",
"mixInstances",
"=",
"nonenum",
"(",
"this",
",",
"'__multiparentInstances__'",
",",
"[",
"]",
")",
";",
"var",
... | Mixin functions are sandboxed into their own instance.
@private | [
"Mixin",
"functions",
"are",
"sandboxed",
"into",
"their",
"own",
"instance",
"."
] | b21636953c602f969adde2c3bd342c4b17e91968 | https://github.com/BladeRunnerJS/topiarist/blob/b21636953c602f969adde2c3bd342c4b17e91968/src/topiarist.js#L664-L684 | train |
jhermsmeier/node-json-web-key | lib/jwk.js | bnToBuffer | function bnToBuffer( bn ) {
var hex = bn.toString( 16 )
hex = hex.length % 2 === 1 ? '0' + hex : hex
return Buffer.from( hex, 'hex' )
} | javascript | function bnToBuffer( bn ) {
var hex = bn.toString( 16 )
hex = hex.length % 2 === 1 ? '0' + hex : hex
return Buffer.from( hex, 'hex' )
} | [
"function",
"bnToBuffer",
"(",
"bn",
")",
"{",
"var",
"hex",
"=",
"bn",
".",
"toString",
"(",
"16",
")",
"hex",
"=",
"hex",
".",
"length",
"%",
"2",
"===",
"1",
"?",
"'0'",
"+",
"hex",
":",
"hex",
"return",
"Buffer",
".",
"from",
"(",
"hex",
",... | Convert a BigNum into a Buffer
@internal
@param {BigNum} bn
@return {Buffer} | [
"Convert",
"a",
"BigNum",
"into",
"a",
"Buffer"
] | d2fec07c55baebea142b0c2098cf82a883a91be8 | https://github.com/jhermsmeier/node-json-web-key/blob/d2fec07c55baebea142b0c2098cf82a883a91be8/lib/jwk.js#L29-L33 | train |
jhermsmeier/node-satcat | lib/satellite.js | extract | function extract( line, from, to ) {
return line.substring( from, to )
.replace( /^\s+|\s+$/g, '' )
} | javascript | function extract( line, from, to ) {
return line.substring( from, to )
.replace( /^\s+|\s+$/g, '' )
} | [
"function",
"extract",
"(",
"line",
",",
"from",
",",
"to",
")",
"{",
"return",
"line",
".",
"substring",
"(",
"from",
",",
"to",
")",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
"}"
] | Extract a given range from a line
@internal
@param {String} line
@param {Number} from
@param {Number} to
@returns {String} | [
"Extract",
"a",
"given",
"range",
"from",
"a",
"line"
] | ba64b113ddf7a74f864baef414c22ea16a747034 | https://github.com/jhermsmeier/node-satcat/blob/ba64b113ddf7a74f864baef414c22ea16a747034/lib/satellite.js#L54-L57 | train |
kibertoad/objection-utils | repositories/lib/services/repository.factory.js | getCustomRepository | function getCustomRepository(RepositoryClass, knex, entityModel) {
validate.inheritsFrom(
RepositoryClass,
EntityRepository,
'Custom repository class must inherit from EntityRepository'
);
return memoizedGetCustomRepository(...arguments);
} | javascript | function getCustomRepository(RepositoryClass, knex, entityModel) {
validate.inheritsFrom(
RepositoryClass,
EntityRepository,
'Custom repository class must inherit from EntityRepository'
);
return memoizedGetCustomRepository(...arguments);
} | [
"function",
"getCustomRepository",
"(",
"RepositoryClass",
",",
"knex",
",",
"entityModel",
")",
"{",
"validate",
".",
"inheritsFrom",
"(",
"RepositoryClass",
",",
"EntityRepository",
",",
"'Custom repository class must inherit from EntityRepository'",
")",
";",
"return",
... | Get repository singleton for a given db and entity. Also passes any given arguments in addition to mandatory first
three to the constructor
@param {class<T>} RepositoryClass
@param {Knex} knex
@param {Model} entityModel
@returns {T} | [
"Get",
"repository",
"singleton",
"for",
"a",
"given",
"db",
"and",
"entity",
".",
"Also",
"passes",
"any",
"given",
"arguments",
"in",
"addition",
"to",
"mandatory",
"first",
"three",
"to",
"the",
"constructor"
] | 6da0bc3ef1185ae52d77fb0af5630a5433dbd917 | https://github.com/kibertoad/objection-utils/blob/6da0bc3ef1185ae52d77fb0af5630a5433dbd917/repositories/lib/services/repository.factory.js#L74-L81 | train |
cszatma/jest-supertest-cookie-fix | src/index.js | FixedAgent | function FixedAgent(app, options) {
if (!(this instanceof FixedAgent)) {
return new FixedAgent(app, options);
}
Agent.call(this, app, options);
} | javascript | function FixedAgent(app, options) {
if (!(this instanceof FixedAgent)) {
return new FixedAgent(app, options);
}
Agent.call(this, app, options);
} | [
"function",
"FixedAgent",
"(",
"app",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"FixedAgent",
")",
")",
"{",
"return",
"new",
"FixedAgent",
"(",
"app",
",",
"options",
")",
";",
"}",
"Agent",
".",
"call",
"(",
"this",
",",
... | Initializes a new supertest agent which its _saveCookies method
fixed to work with jest.
@param {Function|Server} app
@param {Object} options
@returns {FixedAgent}
@constructor
@api public | [
"Initializes",
"a",
"new",
"supertest",
"agent",
"which",
"its",
"_saveCookies",
"method",
"fixed",
"to",
"work",
"with",
"jest",
"."
] | 61f61015c2093c151fd03cab0dc87d93820cde1c | https://github.com/cszatma/jest-supertest-cookie-fix/blob/61f61015c2093c151fd03cab0dc87d93820cde1c/src/index.js#L12-L18 | train |
cszatma/jest-supertest-cookie-fix | src/index.js | fixedSaveCookies | function fixedSaveCookies(res) {
const cookies = res.headers['set-cookie'];
if (cookies) {
const fixedCookies = cookies.reduce(
(cookies, cookie) => cookies.concat(cookie.split(/,(?!\s)/)),
[]
);
this.jar.setCookies(fixedCookies);
}
} | javascript | function fixedSaveCookies(res) {
const cookies = res.headers['set-cookie'];
if (cookies) {
const fixedCookies = cookies.reduce(
(cookies, cookie) => cookies.concat(cookie.split(/,(?!\s)/)),
[]
);
this.jar.setCookies(fixedCookies);
}
} | [
"function",
"fixedSaveCookies",
"(",
"res",
")",
"{",
"const",
"cookies",
"=",
"res",
".",
"headers",
"[",
"'set-cookie'",
"]",
";",
"if",
"(",
"cookies",
")",
"{",
"const",
"fixedCookies",
"=",
"cookies",
".",
"reduce",
"(",
"(",
"cookies",
",",
"cookie... | Fixes jest's set-cookie behavior. Jest normally sets the cookie as a single string instead of an array.
This function splits the string and transforms it into an array the way it should be.
@param {Response} res
@api private | [
"Fixes",
"jest",
"s",
"set",
"-",
"cookie",
"behavior",
".",
"Jest",
"normally",
"sets",
"the",
"cookie",
"as",
"a",
"single",
"string",
"instead",
"of",
"an",
"array",
".",
"This",
"function",
"splits",
"the",
"string",
"and",
"transforms",
"it",
"into",
... | 61f61015c2093c151fd03cab0dc87d93820cde1c | https://github.com/cszatma/jest-supertest-cookie-fix/blob/61f61015c2093c151fd03cab0dc87d93820cde1c/src/index.js#L56-L66 | train |
anyfs/anyfs | lib/plugins/core/writeFile.js | writeFile | function writeFile(fs, p, content, method, cb) {
fs.metadata(p)
.then(function(metadata) {
if (metadata.is_dir) {
throw fs.error('EISDIR');
}
}, function(e) {
if (e.code === 'ENOENT') {
var parent = path.dirname(p);
return this.mkdir(parent);
... | javascript | function writeFile(fs, p, content, method, cb) {
fs.metadata(p)
.then(function(metadata) {
if (metadata.is_dir) {
throw fs.error('EISDIR');
}
}, function(e) {
if (e.code === 'ENOENT') {
var parent = path.dirname(p);
return this.mkdir(parent);
... | [
"function",
"writeFile",
"(",
"fs",
",",
"p",
",",
"content",
",",
"method",
",",
"cb",
")",
"{",
"fs",
".",
"metadata",
"(",
"p",
")",
".",
"then",
"(",
"function",
"(",
"metadata",
")",
"{",
"if",
"(",
"metadata",
".",
"is_dir",
")",
"{",
"thro... | write file - expensive way. | [
"write",
"file",
"-",
"expensive",
"way",
"."
] | bbaec164fd74cbc977245af45b0b1e3d0772b6ff | https://github.com/anyfs/anyfs/blob/bbaec164fd74cbc977245af45b0b1e3d0772b6ff/lib/plugins/core/writeFile.js#L6-L24 | train |
joneit/filter-tree | js/copy-input.js | copy | function copy(el, text) {
var result, lastText;
if (text) {
lastText = el.value;
el.value = text;
} else {
text = el.value;
}
el.value = multiLineTrim(text);
try {
el.select();
result = document.execCommand('copy');
} catch (err) {
result = ... | javascript | function copy(el, text) {
var result, lastText;
if (text) {
lastText = el.value;
el.value = text;
} else {
text = el.value;
}
el.value = multiLineTrim(text);
try {
el.select();
result = document.execCommand('copy');
} catch (err) {
result = ... | [
"function",
"copy",
"(",
"el",
",",
"text",
")",
"{",
"var",
"result",
",",
"lastText",
";",
"if",
"(",
"text",
")",
"{",
"lastText",
"=",
"el",
".",
"value",
";",
"el",
".",
"value",
"=",
"text",
";",
"}",
"else",
"{",
"text",
"=",
"el",
".",
... | 1. Trim the text in the given input element
2. select it
3. copy it to the clipboard
4. deselect it
5. return it
@param {HTMLElement|HTMLTextAreaElement} el
@param {string} [text=el.value] - Text to copy.
@returns {undefined|string} Trimmed text in element or undefined if unable to copy. | [
"1",
".",
"Trim",
"the",
"text",
"in",
"the",
"given",
"input",
"element",
"2",
".",
"select",
"it",
"3",
".",
"copy",
"it",
"to",
"the",
"clipboard",
"4",
".",
"deselect",
"it",
"5",
".",
"return",
"it"
] | c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e | https://github.com/joneit/filter-tree/blob/c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e/js/copy-input.js#L39-L63 | train |
rtm/upward | src/Ren.js | update | function update(v, i, params, {oldValue}) {
switch (i) {
case 'children': _unobserveChildren(oldValue); _observeChildren(v); break;
case 'attrs': _unobserveAttrs (oldValue); _observeAttrs (v); break;
}
} | javascript | function update(v, i, params, {oldValue}) {
switch (i) {
case 'children': _unobserveChildren(oldValue); _observeChildren(v); break;
case 'attrs': _unobserveAttrs (oldValue); _observeAttrs (v); break;
}
} | [
"function",
"update",
"(",
"v",
",",
"i",
",",
"params",
",",
"{",
"oldValue",
"}",
")",
"{",
"switch",
"(",
"i",
")",
"{",
"case",
"'children'",
":",
"_unobserveChildren",
"(",
"oldValue",
")",
";",
"_observeChildren",
"(",
"v",
")",
";",
"break",
"... | When parameters change, tear down and resetup observers. | [
"When",
"parameters",
"change",
"tear",
"down",
"and",
"resetup",
"observers",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Ren.js#L82-L87 | train |
alexindigo/batcher | lib/report.js | report | function report(type, state, params)
{
var reporter = defaultReporter;
// get rest of arguments
params = Array.prototype.slice.call(arguments, 1);
// `init` and `done` types don't have command associated with them
if (['init', 'done'].indexOf(type) == -1)
{
// second (1) position is for command
/... | javascript | function report(type, state, params)
{
var reporter = defaultReporter;
// get rest of arguments
params = Array.prototype.slice.call(arguments, 1);
// `init` and `done` types don't have command associated with them
if (['init', 'done'].indexOf(type) == -1)
{
// second (1) position is for command
/... | [
"function",
"report",
"(",
"type",
",",
"state",
",",
"params",
")",
"{",
"var",
"reporter",
"=",
"defaultReporter",
";",
"// get rest of arguments",
"params",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",... | Generates report via default or custom reporter
@private
@param {string} type - type of the report
@param {object} state - current state
@param {...mixed} [params] - extra parameters to report
@returns {void} | [
"Generates",
"report",
"via",
"default",
"or",
"custom",
"reporter"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/report.js#L17-L38 | train |
alexindigo/batcher | lib/report.js | stringifyCommand | function stringifyCommand(state, command)
{
var name;
if (typeof command == 'function')
{
name = typeof command.commandDescription == 'function'
? command.commandDescription(state)
: Function.prototype.toString.call(command)
;
// truncate long functions
name = name.split('\n');
... | javascript | function stringifyCommand(state, command)
{
var name;
if (typeof command == 'function')
{
name = typeof command.commandDescription == 'function'
? command.commandDescription(state)
: Function.prototype.toString.call(command)
;
// truncate long functions
name = name.split('\n');
... | [
"function",
"stringifyCommand",
"(",
"state",
",",
"command",
")",
"{",
"var",
"name",
";",
"if",
"(",
"typeof",
"command",
"==",
"'function'",
")",
"{",
"name",
"=",
"typeof",
"command",
".",
"commandDescription",
"==",
"'function'",
"?",
"command",
".",
... | Gets command description out of command object
@private
@param {object} state - current state
@param {mixed} command - command object
@returns {string} - description of the command | [
"Gets",
"command",
"description",
"out",
"of",
"command",
"object"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/report.js#L48-L96 | train |
joneit/filter-tree | js/FilterNode.js | function() {
if (this.parent) {
var newListItem = document.createElement(CHILD_TAG);
if (this.notesEl) {
newListItem.appendChild(this.notesEl);
}
if (!this.keep) {
var el = this.templates.get('removeButton');
el.ad... | javascript | function() {
if (this.parent) {
var newListItem = document.createElement(CHILD_TAG);
if (this.notesEl) {
newListItem.appendChild(this.notesEl);
}
if (!this.keep) {
var el = this.templates.get('removeButton');
el.ad... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"parent",
")",
"{",
"var",
"newListItem",
"=",
"document",
".",
"createElement",
"(",
"CHILD_TAG",
")",
";",
"if",
"(",
"this",
".",
"notesEl",
")",
"{",
"newListItem",
".",
"appendChild",
"(",
"this",... | Insert each subtree into its parent node along with a "delete" button.
NOTE: The root tree (which has no parent) must be inserted into the DOM by the instantiating code (without a delete button).
@memberOf FilterNode# | [
"Insert",
"each",
"subtree",
"into",
"its",
"parent",
"node",
"along",
"with",
"a",
"delete",
"button",
"."
] | c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e | https://github.com/joneit/filter-tree/blob/c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e/js/FilterNode.js#L187-L205 | train | |
YuhangGe/node-freetype | lib/parse/hmtx.js | parseHmtxTable | function parseHmtxTable(data, start, numMetrics, numGlyphs, glyphs) {
var p, i, glyph, advanceWidth, leftSideBearing;
p = new parse.Parser(data, start);
for (i = 0; i < numGlyphs; i += 1) {
// If the font is monospaced, only one entry is needed. This last entry applies to all subsequent glyphs.
... | javascript | function parseHmtxTable(data, start, numMetrics, numGlyphs, glyphs) {
var p, i, glyph, advanceWidth, leftSideBearing;
p = new parse.Parser(data, start);
for (i = 0; i < numGlyphs; i += 1) {
// If the font is monospaced, only one entry is needed. This last entry applies to all subsequent glyphs.
... | [
"function",
"parseHmtxTable",
"(",
"data",
",",
"start",
",",
"numMetrics",
",",
"numGlyphs",
",",
"glyphs",
")",
"{",
"var",
"p",
",",
"i",
",",
"glyph",
",",
"advanceWidth",
",",
"leftSideBearing",
";",
"p",
"=",
"new",
"parse",
".",
"Parser",
"(",
"... | Parse the `hmtx` table, which contains the horizontal metrics for all glyphs. This function augments the glyph array, adding the advanceWidth and leftSideBearing to each glyph. | [
"Parse",
"the",
"hmtx",
"table",
"which",
"contains",
"the",
"horizontal",
"metrics",
"for",
"all",
"glyphs",
".",
"This",
"function",
"augments",
"the",
"glyph",
"array",
"adding",
"the",
"advanceWidth",
"and",
"leftSideBearing",
"to",
"each",
"glyph",
"."
] | 4c8d2e2503f088ffbd61e613a23b9ff2e64d3489 | https://github.com/YuhangGe/node-freetype/blob/4c8d2e2503f088ffbd61e613a23b9ff2e64d3489/lib/parse/hmtx.js#L10-L23 | train |
alexindigo/batcher | index.js | iterator | function iterator(state, tasks, callback)
{
var keys
, tasksLeft = tasks.length
, task = tasks.shift()
;
if (tasksLeft === 0)
{
return callback(null, state);
}
// init current task reference
state._currentTask = {waiters: {}};
if (typeOf(task) == 'object')
{
// update state w... | javascript | function iterator(state, tasks, callback)
{
var keys
, tasksLeft = tasks.length
, task = tasks.shift()
;
if (tasksLeft === 0)
{
return callback(null, state);
}
// init current task reference
state._currentTask = {waiters: {}};
if (typeOf(task) == 'object')
{
// update state w... | [
"function",
"iterator",
"(",
"state",
",",
"tasks",
",",
"callback",
")",
"{",
"var",
"keys",
",",
"tasksLeft",
"=",
"tasks",
".",
"length",
",",
"task",
"=",
"tasks",
".",
"shift",
"(",
")",
";",
"if",
"(",
"tasksLeft",
"===",
"0",
")",
"{",
"retu... | Iterates over batch tasks with provided state object
@private
@param {object} state - current state
@param {array} tasks - list of tasks to execute
@param {function} callback - invoked after all tasks have been processed
@returns {void} | [
"Iterates",
"over",
"batch",
"tasks",
"with",
"provided",
"state",
"object"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/index.js#L97-L147 | train |
alexindigo/batcher | index.js | execute | function execute(state, task, keys, callback)
{
var key
, control
, assignment = 'ASSIGNMENT'
// get list of commands left for this iteration
, commandsLeft = (keys || task).length
, command = (keys || task).shift()
// job id within given task
, jobId = commandsLeft
... | javascript | function execute(state, task, keys, callback)
{
var key
, control
, assignment = 'ASSIGNMENT'
// get list of commands left for this iteration
, commandsLeft = (keys || task).length
, command = (keys || task).shift()
// job id within given task
, jobId = commandsLeft
... | [
"function",
"execute",
"(",
"state",
",",
"task",
",",
"keys",
",",
"callback",
")",
"{",
"var",
"key",
",",
"control",
",",
"assignment",
"=",
"'ASSIGNMENT'",
"// get list of commands left for this iteration",
",",
"commandsLeft",
"=",
"(",
"keys",
"||",
"task"... | Executes provided task with state object context
@private
@param {object} state - current state
@param {array} task - list of commands to execute
@param {array|undefined} keys - list of task names
@param {function} callback - invoked after all commands have been executed
@returns {void} | [
"Executes",
"provided",
"task",
"with",
"state",
"object",
"context"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/index.js#L159-L257 | train |
alexindigo/batcher | index.js | cleanWaiters | function cleanWaiters(state)
{
var list = state._currentTask.waiters;
Object.keys(list).forEach(function(job)
{
// prevent callback from execution
// by modifying up `once`'s `called` property
list[job].callback.called = true;
// if called it will return false
list[job].callback.value = fals... | javascript | function cleanWaiters(state)
{
var list = state._currentTask.waiters;
Object.keys(list).forEach(function(job)
{
// prevent callback from execution
// by modifying up `once`'s `called` property
list[job].callback.called = true;
// if called it will return false
list[job].callback.value = fals... | [
"function",
"cleanWaiters",
"(",
"state",
")",
"{",
"var",
"list",
"=",
"state",
".",
"_currentTask",
".",
"waiters",
";",
"Object",
".",
"keys",
"(",
"list",
")",
".",
"forEach",
"(",
"function",
"(",
"job",
")",
"{",
"// prevent callback from execution",
... | Cleans leftover jobs provided by the list
@param {object} state - current state
@returns {void} | [
"Cleans",
"leftover",
"jobs",
"provided",
"by",
"the",
"list"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/index.js#L320-L341 | train |
areslabs/babel-plugin-import-css | src/cssWatch.js | recallInMap | function recallInMap(resMap, absPath) {
if (resMap.has(absPath) && resMap.get(absPath).size > 0) {
for (let keyPath of resMap.get(absPath)) {
//update first
forceUpdate(keyPath)
recallInMap(resMap, keyPath)
}
}
} | javascript | function recallInMap(resMap, absPath) {
if (resMap.has(absPath) && resMap.get(absPath).size > 0) {
for (let keyPath of resMap.get(absPath)) {
//update first
forceUpdate(keyPath)
recallInMap(resMap, keyPath)
}
}
} | [
"function",
"recallInMap",
"(",
"resMap",
",",
"absPath",
")",
"{",
"if",
"(",
"resMap",
".",
"has",
"(",
"absPath",
")",
"&&",
"resMap",
".",
"get",
"(",
"absPath",
")",
".",
"size",
">",
"0",
")",
"{",
"for",
"(",
"let",
"keyPath",
"of",
"resMap"... | Modify related css files recursively
@param resMap
@param absPath | [
"Modify",
"related",
"css",
"files",
"recursively"
] | b90d3a4ec3a644edcaa1c803314e2c39de1d29c9 | https://github.com/areslabs/babel-plugin-import-css/blob/b90d3a4ec3a644edcaa1c803314e2c39de1d29c9/src/cssWatch.js#L138-L146 | train |
bookmansoft/gamecloud | facade/events/user/relogin.js | handle | function handle(event) {
if(event.data.type == 1 || event.data.type == 3 || event.data.type == 7){
facade.models.login().findCreateFind({
where:{
uid: event.user.id,
type: event.data.type,
},
defaults: {
uid: event.user.id, ... | javascript | function handle(event) {
if(event.data.type == 1 || event.data.type == 3 || event.data.type == 7){
facade.models.login().findCreateFind({
where:{
uid: event.user.id,
type: event.data.type,
},
defaults: {
uid: event.user.id, ... | [
"function",
"handle",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"data",
".",
"type",
"==",
"1",
"||",
"event",
".",
"data",
".",
"type",
"==",
"3",
"||",
"event",
".",
"data",
".",
"type",
"==",
"7",
")",
"{",
"facade",
".",
"models",
".... | Created by admin on 2017-05-26.
@param {EventData} event | [
"Created",
"by",
"admin",
"on",
"2017",
"-",
"05",
"-",
"26",
"."
] | cff1a3eeaab392756f4e7b188451f419755d679d | https://github.com/bookmansoft/gamecloud/blob/cff1a3eeaab392756f4e7b188451f419755d679d/facade/events/user/relogin.js#L7-L21 | train |
anywhichway/wsfetch | javascript/ractive.js | get | function get ( keypath ) {
if ( !keypath ) return this._element.parentFragment.findContext().get( true );
var model = resolveReference( this._element.parentFragment, keypath );
return model ? model.get( true ) : undefined;
} | javascript | function get ( keypath ) {
if ( !keypath ) return this._element.parentFragment.findContext().get( true );
var model = resolveReference( this._element.parentFragment, keypath );
return model ? model.get( true ) : undefined;
} | [
"function",
"get",
"(",
"keypath",
")",
"{",
"if",
"(",
"!",
"keypath",
")",
"return",
"this",
".",
"_element",
".",
"parentFragment",
".",
"findContext",
"(",
")",
".",
"get",
"(",
"true",
")",
";",
"var",
"model",
"=",
"resolveReference",
"(",
"this"... | get relative keypaths and values | [
"get",
"relative",
"keypaths",
"and",
"values"
] | 74d81a9537a748e9c6c04ffccf74f71b5eebddfa | https://github.com/anywhichway/wsfetch/blob/74d81a9537a748e9c6c04ffccf74f71b5eebddfa/javascript/ractive.js#L3653-L3659 | train |
anywhichway/wsfetch | javascript/ractive.js | add$1 | function add$1 ( keypath, value ) {
if ( value === undefined ) value = 1;
if ( !isNumeric( value ) ) throw new Error( 'Bad arguments' );
return set( this.ractive, build$1( this, keypath, value ).map( function ( pair ) {
var model = pair[0], val = pair[1], value = model.get();
if ( !isNumeric( val ) || ... | javascript | function add$1 ( keypath, value ) {
if ( value === undefined ) value = 1;
if ( !isNumeric( value ) ) throw new Error( 'Bad arguments' );
return set( this.ractive, build$1( this, keypath, value ).map( function ( pair ) {
var model = pair[0], val = pair[1], value = model.get();
if ( !isNumeric( val ) || ... | [
"function",
"add$1",
"(",
"keypath",
",",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"undefined",
")",
"value",
"=",
"1",
";",
"if",
"(",
"!",
"isNumeric",
"(",
"value",
")",
")",
"throw",
"new",
"Error",
"(",
"'Bad arguments'",
")",
";",
"return"... | the usual mutation suspects | [
"the",
"usual",
"mutation",
"suspects"
] | 74d81a9537a748e9c6c04ffccf74f71b5eebddfa | https://github.com/anywhichway/wsfetch/blob/74d81a9537a748e9c6c04ffccf74f71b5eebddfa/javascript/ractive.js#L3677-L3685 | train |
anywhichway/wsfetch | javascript/ractive.js | function ( Parent, proto, options ) {
if ( !options.css ) return;
var id = uuid();
var styles = options.noCssTransform ? options.css : transformCss( options.css, id );
proto.cssId = id;
addCSS( { id: id, styles: styles } );
} | javascript | function ( Parent, proto, options ) {
if ( !options.css ) return;
var id = uuid();
var styles = options.noCssTransform ? options.css : transformCss( options.css, id );
proto.cssId = id;
addCSS( { id: id, styles: styles } );
} | [
"function",
"(",
"Parent",
",",
"proto",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
".",
"css",
")",
"return",
";",
"var",
"id",
"=",
"uuid",
"(",
")",
";",
"var",
"styles",
"=",
"options",
".",
"noCssTransform",
"?",
"options",
".",
"css... | Called when creating a new component definition | [
"Called",
"when",
"creating",
"a",
"new",
"component",
"definition"
] | 74d81a9537a748e9c6c04ffccf74f71b5eebddfa | https://github.com/anywhichway/wsfetch/blob/74d81a9537a748e9c6c04ffccf74f71b5eebddfa/javascript/ractive.js#L4772-L4782 | train | |
anywhichway/wsfetch | javascript/ractive.js | makeQuotedStringMatcher | function makeQuotedStringMatcher ( okQuote ) {
return function ( parser ) {
var literal = '"';
var done = false;
var next;
while ( !done ) {
next = ( parser.matchPattern( stringMiddlePattern ) || parser.matchPattern( escapeSequencePattern ) ||
parser.matchString( okQuote ) );
if ( ne... | javascript | function makeQuotedStringMatcher ( okQuote ) {
return function ( parser ) {
var literal = '"';
var done = false;
var next;
while ( !done ) {
next = ( parser.matchPattern( stringMiddlePattern ) || parser.matchPattern( escapeSequencePattern ) ||
parser.matchString( okQuote ) );
if ( ne... | [
"function",
"makeQuotedStringMatcher",
"(",
"okQuote",
")",
"{",
"return",
"function",
"(",
"parser",
")",
"{",
"var",
"literal",
"=",
"'\"'",
";",
"var",
"done",
"=",
"false",
";",
"var",
"next",
";",
"while",
"(",
"!",
"done",
")",
"{",
"next",
"=",
... | Helper for defining getDoubleQuotedString and getSingleQuotedString. | [
"Helper",
"for",
"defining",
"getDoubleQuotedString",
"and",
"getSingleQuotedString",
"."
] | 74d81a9537a748e9c6c04ffccf74f71b5eebddfa | https://github.com/anywhichway/wsfetch/blob/74d81a9537a748e9c6c04ffccf74f71b5eebddfa/javascript/ractive.js#L5416-L5449 | train |
anywhichway/wsfetch | javascript/ractive.js | getConditional | function getConditional ( parser ) {
var start, expression, ifTrue, ifFalse;
expression = readLogicalOr$1( parser );
if ( !expression ) {
return null;
}
start = parser.pos;
parser.allowWhitespace();
if ( !parser.matchString( '?' ) ) {
parser.pos = start;
return expression;
}
... | javascript | function getConditional ( parser ) {
var start, expression, ifTrue, ifFalse;
expression = readLogicalOr$1( parser );
if ( !expression ) {
return null;
}
start = parser.pos;
parser.allowWhitespace();
if ( !parser.matchString( '?' ) ) {
parser.pos = start;
return expression;
}
... | [
"function",
"getConditional",
"(",
"parser",
")",
"{",
"var",
"start",
",",
"expression",
",",
"ifTrue",
",",
"ifFalse",
";",
"expression",
"=",
"readLogicalOr$1",
"(",
"parser",
")",
";",
"if",
"(",
"!",
"expression",
")",
"{",
"return",
"null",
";",
"}... | The conditional operator is the lowest precedence operator, so we start here | [
"The",
"conditional",
"operator",
"is",
"the",
"lowest",
"precedence",
"operator",
"so",
"we",
"start",
"here"
] | 74d81a9537a748e9c6c04ffccf74f71b5eebddfa | https://github.com/anywhichway/wsfetch/blob/74d81a9537a748e9c6c04ffccf74f71b5eebddfa/javascript/ractive.js#L6013-L6054 | train |
anywhichway/wsfetch | javascript/ractive.js | truncateStack | function truncateStack ( stack ) {
if ( !stack ) return '';
var lines = stack.split( '\n' );
var name = Computation.name + '.getValue';
var truncated = [];
var len = lines.length;
for ( var i = 1; i < len; i += 1 ) {
var line = lines[i];
if ( ~line.indexOf( name ) ) {
return truncated... | javascript | function truncateStack ( stack ) {
if ( !stack ) return '';
var lines = stack.split( '\n' );
var name = Computation.name + '.getValue';
var truncated = [];
var len = lines.length;
for ( var i = 1; i < len; i += 1 ) {
var line = lines[i];
if ( ~line.indexOf( name ) ) {
return truncated... | [
"function",
"truncateStack",
"(",
"stack",
")",
"{",
"if",
"(",
"!",
"stack",
")",
"return",
"''",
";",
"var",
"lines",
"=",
"stack",
".",
"split",
"(",
"'\\n'",
")",
";",
"var",
"name",
"=",
"Computation",
".",
"name",
"+",
"'.getValue'",
";",
"var"... | Ditto. This function truncates the stack to only include app code | [
"Ditto",
".",
"This",
"function",
"truncates",
"the",
"stack",
"to",
"only",
"include",
"app",
"code"
] | 74d81a9537a748e9c6c04ffccf74f71b5eebddfa | https://github.com/anywhichway/wsfetch/blob/74d81a9537a748e9c6c04ffccf74f71b5eebddfa/javascript/ractive.js#L10589-L10607 | train |
anywhichway/wsfetch | javascript/ractive.js | Ractive$teardown | function Ractive$teardown () {
if ( this.torndown ) {
warnIfDebug( 'ractive.teardown() was called on a Ractive instance that was already torn down' );
return Promise$1.resolve();
}
this.torndown = true;
this.fragment.unbind();
this.viewmodel.teardown();
this._observers.forEach( cancel );
... | javascript | function Ractive$teardown () {
if ( this.torndown ) {
warnIfDebug( 'ractive.teardown() was called on a Ractive instance that was already torn down' );
return Promise$1.resolve();
}
this.torndown = true;
this.fragment.unbind();
this.viewmodel.teardown();
this._observers.forEach( cancel );
... | [
"function",
"Ractive$teardown",
"(",
")",
"{",
"if",
"(",
"this",
".",
"torndown",
")",
"{",
"warnIfDebug",
"(",
"'ractive.teardown() was called on a Ractive instance that was already torn down'",
")",
";",
"return",
"Promise$1",
".",
"resolve",
"(",
")",
";",
"}",
... | Teardown. This goes through the root fragment and all its children, removing observers and generally cleaning up after itself | [
"Teardown",
".",
"This",
"goes",
"through",
"the",
"root",
"fragment",
"and",
"all",
"its",
"children",
"removing",
"observers",
"and",
"generally",
"cleaning",
"up",
"after",
"itself"
] | 74d81a9537a748e9c6c04ffccf74f71b5eebddfa | https://github.com/anywhichway/wsfetch/blob/74d81a9537a748e9c6c04ffccf74f71b5eebddfa/javascript/ractive.js#L16604-L16626 | train |
capaj/array-sugar | array-sugar.js | function(test, fromEnd) {
var i;
if (typeof test !== 'function') return undefined;
if (fromEnd) {
i = this.length;
while (i--) {
if (test(this[i], i, this)) {
return this[i];
}
}
} else {
i = 0;
while (i < this.length) {
... | javascript | function(test, fromEnd) {
var i;
if (typeof test !== 'function') return undefined;
if (fromEnd) {
i = this.length;
while (i--) {
if (test(this[i], i, this)) {
return this[i];
}
}
} else {
i = 0;
while (i < this.length) {
... | [
"function",
"(",
"test",
",",
"fromEnd",
")",
"{",
"var",
"i",
";",
"if",
"(",
"typeof",
"test",
"!==",
"'function'",
")",
"return",
"undefined",
";",
"if",
"(",
"fromEnd",
")",
"{",
"i",
"=",
"this",
".",
"length",
";",
"while",
"(",
"i",
"--",
... | traverses array and returns first element on which test function returns true
@param {Function<Boolean>} test
@param {Boolean} fromEnd pass true if you want to traverse array from end to beginning
@returns {*|null|undefined} an element of an array, or undefined when passed param is not a function | [
"traverses",
"array",
"and",
"returns",
"first",
"element",
"on",
"which",
"test",
"function",
"returns",
"true"
] | 43cee8e2dd166e46b88535dd7e149b8d71991f35 | https://github.com/capaj/array-sugar/blob/43cee8e2dd166e46b88535dd7e149b8d71991f35/array-sugar.js#L128-L148 | train | |
capaj/array-sugar | array-sugar.js | function(count, direction) {
return direction ? this.concat(this.splice(0, count)) : this.splice(this.length - count).concat(this);
} | javascript | function(count, direction) {
return direction ? this.concat(this.splice(0, count)) : this.splice(this.length - count).concat(this);
} | [
"function",
"(",
"count",
",",
"direction",
")",
"{",
"return",
"direction",
"?",
"this",
".",
"concat",
"(",
"this",
".",
"splice",
"(",
"0",
",",
"count",
")",
")",
":",
"this",
".",
"splice",
"(",
"this",
".",
"length",
"-",
"count",
")",
".",
... | Rotates an array by given number of fields in given direction
@param {Number} count
@param {boolean} direction true for shifting array to the left
@returns {Array} | [
"Rotates",
"an",
"array",
"by",
"given",
"number",
"of",
"fields",
"in",
"given",
"direction"
] | 43cee8e2dd166e46b88535dd7e149b8d71991f35 | https://github.com/capaj/array-sugar/blob/43cee8e2dd166e46b88535dd7e149b8d71991f35/array-sugar.js#L214-L216 | train | |
NikxDa/node-spotify-helper | src/spotifyAppleScriptApi.js | promiseWrapper | function promiseWrapper (resolve, reject) {
// Wait for the process to exit
process.on ("exit", (code) => {
// Did the process crash?
if (code !== 0) reject (process.stderr.textContent);
// Resolve
resolve (process.stdout.textConte... | javascript | function promiseWrapper (resolve, reject) {
// Wait for the process to exit
process.on ("exit", (code) => {
// Did the process crash?
if (code !== 0) reject (process.stderr.textContent);
// Resolve
resolve (process.stdout.textConte... | [
"function",
"promiseWrapper",
"(",
"resolve",
",",
"reject",
")",
"{",
"// Wait for the process to exit",
"process",
".",
"on",
"(",
"\"exit\"",
",",
"(",
"code",
")",
"=>",
"{",
"// Did the process crash?",
"if",
"(",
"code",
"!==",
"0",
")",
"reject",
"(",
... | Wrapper for the Promise | [
"Wrapper",
"for",
"the",
"Promise"
] | a60f4fca3c9e608981770960ef5417004d25a6a6 | https://github.com/NikxDa/node-spotify-helper/blob/a60f4fca3c9e608981770960ef5417004d25a6a6/src/spotifyAppleScriptApi.js#L452-L465 | train |
alexindigo/batcher | lib/run_command.js | run | function run(params, command, callback)
{
var job;
// decouple commands
command = clone(command);
// start command execution and get job reference
job = executioner(command, stringify(extend(this, params)), this.options || {}, callback);
// make ready to call task termination function
return partial(ex... | javascript | function run(params, command, callback)
{
var job;
// decouple commands
command = clone(command);
// start command execution and get job reference
job = executioner(command, stringify(extend(this, params)), this.options || {}, callback);
// make ready to call task termination function
return partial(ex... | [
"function",
"run",
"(",
"params",
",",
"command",
",",
"callback",
")",
"{",
"var",
"job",
";",
"// decouple commands",
"command",
"=",
"clone",
"(",
"command",
")",
";",
"// start command execution and get job reference",
"job",
"=",
"executioner",
"(",
"command"... | Runs provided command within state context
@param {object} params - extra execution-time parameters
@param {string|array} command - command to run
@param {function} callback - invoked after command finished executing
@returns {void} | [
"Runs",
"provided",
"command",
"within",
"state",
"context"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/run_command.js#L19-L31 | train |
alexindigo/batcher | lib/run_command.js | stringify | function stringify(origin)
{
var i, keys, prepared = {};
keys = Object.keys(origin);
i = keys.length;
while (i--)
{
// skip un-stringable things
if (typeOf(origin[keys[i]]) == 'function'
|| typeOf(origin[keys[i]]) == 'object')
{
continue;
}
// export it
prepared[keys[i]]... | javascript | function stringify(origin)
{
var i, keys, prepared = {};
keys = Object.keys(origin);
i = keys.length;
while (i--)
{
// skip un-stringable things
if (typeOf(origin[keys[i]]) == 'function'
|| typeOf(origin[keys[i]]) == 'object')
{
continue;
}
// export it
prepared[keys[i]]... | [
"function",
"stringify",
"(",
"origin",
")",
"{",
"var",
"i",
",",
"keys",
",",
"prepared",
"=",
"{",
"}",
";",
"keys",
"=",
"Object",
".",
"keys",
"(",
"origin",
")",
";",
"i",
"=",
"keys",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{"... | Decouples and "stringifies" provided object
to use with `executioner` shell runner
@param {object} origin - params object
@returns {object} - new object with stringified properties | [
"Decouples",
"and",
"stringifies",
"provided",
"object",
"to",
"use",
"with",
"executioner",
"shell",
"runner"
] | 73d9c8c994f915688db0627ea3b4854ead771138 | https://github.com/alexindigo/batcher/blob/73d9c8c994f915688db0627ea3b4854ead771138/lib/run_command.js#L40-L75 | train |
chrisJohn404/ljm-ffi | lib/ljm-ffi.js | allocateAndFillSyncFunctionArgs | function allocateAndFillSyncFunctionArgs(functionInfo, funcArgs, userArgs) {
functionInfo.requiredArgTypes.forEach(function(type, i) {
var buf = ljTypeOps[type].allocate(userArgs[i]);
buf = ljTypeOps[type].fill(buf, userArgs[i]);
funcArgs.push(buf);
});
} | javascript | function allocateAndFillSyncFunctionArgs(functionInfo, funcArgs, userArgs) {
functionInfo.requiredArgTypes.forEach(function(type, i) {
var buf = ljTypeOps[type].allocate(userArgs[i]);
buf = ljTypeOps[type].fill(buf, userArgs[i]);
funcArgs.push(buf);
});
} | [
"function",
"allocateAndFillSyncFunctionArgs",
"(",
"functionInfo",
",",
"funcArgs",
",",
"userArgs",
")",
"{",
"functionInfo",
".",
"requiredArgTypes",
".",
"forEach",
"(",
"function",
"(",
"type",
",",
"i",
")",
"{",
"var",
"buf",
"=",
"ljTypeOps",
"[",
"typ... | Define a function that is used to allocate and fill buffers to communicate with the LJM library through ffi. | [
"Define",
"a",
"function",
"that",
"is",
"used",
"to",
"allocate",
"and",
"fill",
"buffers",
"to",
"communicate",
"with",
"the",
"LJM",
"library",
"through",
"ffi",
"."
] | 5f2bb940988f1cedb4182180a891ac8973f07a3d | https://github.com/chrisJohn404/ljm-ffi/blob/5f2bb940988f1cedb4182180a891ac8973f07a3d/lib/ljm-ffi.js#L714-L720 | train |
chrisJohn404/ljm-ffi | lib/ljm-ffi.js | parseAndStoreSyncFunctionArgs | function parseAndStoreSyncFunctionArgs(functionInfo, funcArgs, saveObj) {
functionInfo.requiredArgTypes.forEach(function(type, i) {
var buf = funcArgs[i];
var parsedVal = ljTypeOps[type].parse(buf);
var argName = functionInfo.requiredArgNames[i];
saveObj[argName] = parsedVal;
});... | javascript | function parseAndStoreSyncFunctionArgs(functionInfo, funcArgs, saveObj) {
functionInfo.requiredArgTypes.forEach(function(type, i) {
var buf = funcArgs[i];
var parsedVal = ljTypeOps[type].parse(buf);
var argName = functionInfo.requiredArgNames[i];
saveObj[argName] = parsedVal;
});... | [
"function",
"parseAndStoreSyncFunctionArgs",
"(",
"functionInfo",
",",
"funcArgs",
",",
"saveObj",
")",
"{",
"functionInfo",
".",
"requiredArgTypes",
".",
"forEach",
"(",
"function",
"(",
"type",
",",
"i",
")",
"{",
"var",
"buf",
"=",
"funcArgs",
"[",
"i",
"... | Define a function that is used to parse the values altered by LJM through the ffi library & save them to a return-object. | [
"Define",
"a",
"function",
"that",
"is",
"used",
"to",
"parse",
"the",
"values",
"altered",
"by",
"LJM",
"through",
"the",
"ffi",
"library",
"&",
"save",
"them",
"to",
"a",
"return",
"-",
"object",
"."
] | 5f2bb940988f1cedb4182180a891ac8973f07a3d | https://github.com/chrisJohn404/ljm-ffi/blob/5f2bb940988f1cedb4182180a891ac8973f07a3d/lib/ljm-ffi.js#L724-L731 | train |
chrisJohn404/ljm-ffi | lib/ljm-ffi.js | createSyncFunction | function createSyncFunction(functionName, functionInfo) {
return function syncLJMFunction() {
if(arguments.length != functionInfo.args.length) {
var errStr = 'Invalid number of arguments. Should be: ';
errStr += functionInfo.args.length.toString() + '. ';
errStr += 'Giv... | javascript | function createSyncFunction(functionName, functionInfo) {
return function syncLJMFunction() {
if(arguments.length != functionInfo.args.length) {
var errStr = 'Invalid number of arguments. Should be: ';
errStr += functionInfo.args.length.toString() + '. ';
errStr += 'Giv... | [
"function",
"createSyncFunction",
"(",
"functionName",
",",
"functionInfo",
")",
"{",
"return",
"function",
"syncLJMFunction",
"(",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"!=",
"functionInfo",
".",
"args",
".",
"length",
")",
"{",
"var",
"errStr",
... | Define a function that creates functions that can call LJM synchronously. | [
"Define",
"a",
"function",
"that",
"creates",
"functions",
"that",
"can",
"call",
"LJM",
"synchronously",
"."
] | 5f2bb940988f1cedb4182180a891ac8973f07a3d | https://github.com/chrisJohn404/ljm-ffi/blob/5f2bb940988f1cedb4182180a891ac8973f07a3d/lib/ljm-ffi.js#L734-L769 | train |
chrisJohn404/ljm-ffi | lib/ljm-ffi.js | createAsyncFunction | function createAsyncFunction(functionName, functionInfo) {
return function asyncLJMFunction() {
var userCB;
function cb(err, res) {
if(err) {
console.error('Error Reported by Async Function', functionName);
}
// Create an object to be ... | javascript | function createAsyncFunction(functionName, functionInfo) {
return function asyncLJMFunction() {
var userCB;
function cb(err, res) {
if(err) {
console.error('Error Reported by Async Function', functionName);
}
// Create an object to be ... | [
"function",
"createAsyncFunction",
"(",
"functionName",
",",
"functionInfo",
")",
"{",
"return",
"function",
"asyncLJMFunction",
"(",
")",
"{",
"var",
"userCB",
";",
"function",
"cb",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",... | Define a function that creates functions that can call LJM asynchronously. | [
"Define",
"a",
"function",
"that",
"creates",
"functions",
"that",
"can",
"call",
"LJM",
"asynchronously",
"."
] | 5f2bb940988f1cedb4182180a891ac8973f07a3d | https://github.com/chrisJohn404/ljm-ffi/blob/5f2bb940988f1cedb4182180a891ac8973f07a3d/lib/ljm-ffi.js#L820-L880 | train |
chrisJohn404/ljm-ffi | lib/ljm-ffi.js | createSafeAsyncFunction | function createSafeAsyncFunction(functionName, functionInfo) {
return function safeAsyncFunction() {
// Define a variable to store the error string in.
var errStr;
// Check to make sure the arguments seem to be valid.
if(arguments.length != (functionInfo.args.length + 1)) {
... | javascript | function createSafeAsyncFunction(functionName, functionInfo) {
return function safeAsyncFunction() {
// Define a variable to store the error string in.
var errStr;
// Check to make sure the arguments seem to be valid.
if(arguments.length != (functionInfo.args.length + 1)) {
... | [
"function",
"createSafeAsyncFunction",
"(",
"functionName",
",",
"functionInfo",
")",
"{",
"return",
"function",
"safeAsyncFunction",
"(",
")",
"{",
"// Define a variable to store the error string in.",
"var",
"errStr",
";",
"// Check to make sure the arguments seem to be valid."... | Define a function that creates safe LJM ffi calls. | [
"Define",
"a",
"function",
"that",
"creates",
"safe",
"LJM",
"ffi",
"calls",
"."
] | 5f2bb940988f1cedb4182180a891ac8973f07a3d | https://github.com/chrisJohn404/ljm-ffi/blob/5f2bb940988f1cedb4182180a891ac8973f07a3d/lib/ljm-ffi.js#L883-L938 | train |
fczbkk/the-box | src/utilities/get-boxes-around.js | makeUnique | function makeUnique (boxes = []) {
// boxes converted to string, for easier comparison
const ref = [];
const result = [];
boxes.forEach((item) => {
const item_string = item.toString();
if (ref.indexOf(item_string) === -1) {
ref.push(item_string);
result.push(item);
}
});
return res... | javascript | function makeUnique (boxes = []) {
// boxes converted to string, for easier comparison
const ref = [];
const result = [];
boxes.forEach((item) => {
const item_string = item.toString();
if (ref.indexOf(item_string) === -1) {
ref.push(item_string);
result.push(item);
}
});
return res... | [
"function",
"makeUnique",
"(",
"boxes",
"=",
"[",
"]",
")",
"{",
"// boxes converted to string, for easier comparison",
"const",
"ref",
"=",
"[",
"]",
";",
"const",
"result",
"=",
"[",
"]",
";",
"boxes",
".",
"forEach",
"(",
"(",
"item",
")",
"=>",
"{",
... | Accepts list of Boxes, returns list of unique Boxes.
@param {Array.<Box>} [boxes=[]]
@returns {Array.<Box>}
@ignore | [
"Accepts",
"list",
"of",
"Boxes",
"returns",
"list",
"of",
"unique",
"Boxes",
"."
] | 337efc6bd00f92565dac8abffeb271b03caae2ba | https://github.com/fczbkk/the-box/blob/337efc6bd00f92565dac8abffeb271b03caae2ba/src/utilities/get-boxes-around.js#L69-L83 | train |
henrytseng/angular-state-loadable | src/services/loadable-manager.js | function(src) {
var _deferred = $q.defer();
// Instance
var _loadable = {
src: src,
// Loading completion flag
isComplete: false,
promise: _deferred.promise,
// TODO switch to $document
$element: document.createElement('script')
};
// Build DOM element
_... | javascript | function(src) {
var _deferred = $q.defer();
// Instance
var _loadable = {
src: src,
// Loading completion flag
isComplete: false,
promise: _deferred.promise,
// TODO switch to $document
$element: document.createElement('script')
};
// Build DOM element
_... | [
"function",
"(",
"src",
")",
"{",
"var",
"_deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"// Instance",
"var",
"_loadable",
"=",
"{",
"src",
":",
"src",
",",
"// Loading completion flag",
"isComplete",
":",
"false",
",",
"promise",
":",
"_deferred",
... | A loaded resource, adds self to DOM, self manage progress
@return {_Loadable} An instance | [
"A",
"loaded",
"resource",
"adds",
"self",
"to",
"DOM",
"self",
"manage",
"progress"
] | dd905296935ef62b468f1b151ade2652635e8f9f | https://github.com/henrytseng/angular-state-loadable/blob/dd905296935ef62b468f1b151ade2652635e8f9f/src/services/loadable-manager.js#L25-L75 | train | |
henrytseng/angular-state-loadable | src/services/loadable-manager.js | function(src) {
var loadable;
// Valid state name required
if(!src || src === '') {
var error;
error = new Error('Loadable requires a valid source.');
error.code = 'invalidname';
throw error;
}
// Already exists
if(_loadableHash[src]) {
loadable = _loadableHash[sr... | javascript | function(src) {
var loadable;
// Valid state name required
if(!src || src === '') {
var error;
error = new Error('Loadable requires a valid source.');
error.code = 'invalidname';
throw error;
}
// Already exists
if(_loadableHash[src]) {
loadable = _loadableHash[sr... | [
"function",
"(",
"src",
")",
"{",
"var",
"loadable",
";",
"// Valid state name required",
"if",
"(",
"!",
"src",
"||",
"src",
"===",
"''",
")",
"{",
"var",
"error",
";",
"error",
"=",
"new",
"Error",
"(",
"'Loadable requires a valid source.'",
")",
";",
"e... | Create a _Loadable. Does not replace previously created instances.
@param {String} src A source path for script asset
@return {_Loadable} A loadable instance | [
"Create",
"a",
"_Loadable",
".",
"Does",
"not",
"replace",
"previously",
"created",
"instances",
"."
] | dd905296935ef62b468f1b151ade2652635e8f9f | https://github.com/henrytseng/angular-state-loadable/blob/dd905296935ef62b468f1b151ade2652635e8f9f/src/services/loadable-manager.js#L94-L131 | train | |
henrytseng/angular-state-loadable | src/services/loadable-manager.js | function() {
var deferred = $q.defer();
var current = $state.current();
// Evaluate
if(current) {
var sources = (typeof current.load === 'string' ? [current.load] : current.load) || [];
// Get promises
$q.all(sources
.map(function(src) {
return _createLoadabl... | javascript | function() {
var deferred = $q.defer();
var current = $state.current();
// Evaluate
if(current) {
var sources = (typeof current.load === 'string' ? [current.load] : current.load) || [];
// Get promises
$q.all(sources
.map(function(src) {
return _createLoadabl... | [
"function",
"(",
")",
"{",
"var",
"deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"var",
"current",
"=",
"$state",
".",
"current",
"(",
")",
";",
"// Evaluate",
"if",
"(",
"current",
")",
"{",
"var",
"sources",
"=",
"(",
"typeof",
"current",
".... | Load all required items
@return {Promise} A promise fulfilled when the resources are loaded | [
"Load",
"all",
"required",
"items"
] | dd905296935ef62b468f1b151ade2652635e8f9f | https://github.com/henrytseng/angular-state-loadable/blob/dd905296935ef62b468f1b151ade2652635e8f9f/src/services/loadable-manager.js#L138-L173 | train | |
nicktindall/cyclon.p2p-rtc-client | lib/SocketIOSignallingService.js | postToFirstAvailableServer | function postToFirstAvailableServer (destinationNode, signallingServers, path, message) {
return new Promise(function (resolve, reject) {
if (signallingServers.length === 0) {
reject(new Utils.UnreachableError(createUnreachableErrorMessage(destinationNode)));
}
... | javascript | function postToFirstAvailableServer (destinationNode, signallingServers, path, message) {
return new Promise(function (resolve, reject) {
if (signallingServers.length === 0) {
reject(new Utils.UnreachableError(createUnreachableErrorMessage(destinationNode)));
}
... | [
"function",
"postToFirstAvailableServer",
"(",
"destinationNode",
",",
"signallingServers",
",",
"path",
",",
"message",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"if",
"(",
"signallingServers",
".",
"length"... | Post an object to the first available signalling server
@param destinationNode
@param signallingServers
@param path
@param message
@returns {Promise} | [
"Post",
"an",
"object",
"to",
"the",
"first",
"available",
"signalling",
"server"
] | eb586ce288a6ad7e1b221280825037e855b03904 | https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/SocketIOSignallingService.js#L184-L200 | train |
jhermsmeier/node-scuid | lib/scuid.js | pad | function pad( str, chr, n ) {
return (chr.repeat( Math.max( n - str.length, 0 ) ) + str).substr(-n)
} | javascript | function pad( str, chr, n ) {
return (chr.repeat( Math.max( n - str.length, 0 ) ) + str).substr(-n)
} | [
"function",
"pad",
"(",
"str",
",",
"chr",
",",
"n",
")",
"{",
"return",
"(",
"chr",
".",
"repeat",
"(",
"Math",
".",
"max",
"(",
"n",
"-",
"str",
".",
"length",
",",
"0",
")",
")",
"+",
"str",
")",
".",
"substr",
"(",
"-",
"n",
")",
"}"
] | Pad a string to length `n` with `chr`
@param {String} str
@param {String} chr
@param {Number} n
@return {String} | [
"Pad",
"a",
"string",
"to",
"length",
"n",
"with",
"chr"
] | 84e96962ff5eaae2ab2bcc2a9fae615e15204695 | https://github.com/jhermsmeier/node-scuid/blob/84e96962ff5eaae2ab2bcc2a9fae615e15204695/lib/scuid.js#L10-L12 | train |
jhermsmeier/node-scuid | lib/scuid.js | function() {
var block = this.rng.random() * this.discreteValues << 0
return pad( block.toString( this.base ), this.fill, this.blockSize )
} | javascript | function() {
var block = this.rng.random() * this.discreteValues << 0
return pad( block.toString( this.base ), this.fill, this.blockSize )
} | [
"function",
"(",
")",
"{",
"var",
"block",
"=",
"this",
".",
"rng",
".",
"random",
"(",
")",
"*",
"this",
".",
"discreteValues",
"<<",
"0",
"return",
"pad",
"(",
"block",
".",
"toString",
"(",
"this",
".",
"base",
")",
",",
"this",
".",
"fill",
"... | Generate a block of `blockSize` random characters
@return {String} | [
"Generate",
"a",
"block",
"of",
"blockSize",
"random",
"characters"
] | 84e96962ff5eaae2ab2bcc2a9fae615e15204695 | https://github.com/jhermsmeier/node-scuid/blob/84e96962ff5eaae2ab2bcc2a9fae615e15204695/lib/scuid.js#L127-L130 | train | |
jhermsmeier/node-scuid | lib/scuid.js | function() {
return this.timestamp().substr( -2 ) +
this.count().toString( this.base ).substr( -4 ) +
this._fingerprint[0] +
this._fingerprint[ this._fingerprint.length - 1 ] +
this.randomBlock().substr( -2 )
} | javascript | function() {
return this.timestamp().substr( -2 ) +
this.count().toString( this.base ).substr( -4 ) +
this._fingerprint[0] +
this._fingerprint[ this._fingerprint.length - 1 ] +
this.randomBlock().substr( -2 )
} | [
"function",
"(",
")",
"{",
"return",
"this",
".",
"timestamp",
"(",
")",
".",
"substr",
"(",
"-",
"2",
")",
"+",
"this",
".",
"count",
"(",
")",
".",
"toString",
"(",
"this",
".",
"base",
")",
".",
"substr",
"(",
"-",
"4",
")",
"+",
"this",
"... | Generate a slug
@return {String} slug | [
"Generate",
"a",
"slug"
] | 84e96962ff5eaae2ab2bcc2a9fae615e15204695 | https://github.com/jhermsmeier/node-scuid/blob/84e96962ff5eaae2ab2bcc2a9fae615e15204695/lib/scuid.js#L162-L168 | train | |
oliverwoodings/pkgify | lib/pkgify.js | findPackage | function findPackage(config, match) {
var map = getPackageMap(config.relativeTo, config.packages);
return _.reduce(map, function (prev, pkg) {
// Resolve using last priority. Priority:
// 1. package is a file
// 2. package granularity (done by file depth)
if (pkg.regexp.test(match) && (!prev || (p... | javascript | function findPackage(config, match) {
var map = getPackageMap(config.relativeTo, config.packages);
return _.reduce(map, function (prev, pkg) {
// Resolve using last priority. Priority:
// 1. package is a file
// 2. package granularity (done by file depth)
if (pkg.regexp.test(match) && (!prev || (p... | [
"function",
"findPackage",
"(",
"config",
",",
"match",
")",
"{",
"var",
"map",
"=",
"getPackageMap",
"(",
"config",
".",
"relativeTo",
",",
"config",
".",
"packages",
")",
";",
"return",
"_",
".",
"reduce",
"(",
"map",
",",
"function",
"(",
"prev",
",... | Try and find a package for the match | [
"Try",
"and",
"find",
"a",
"package",
"for",
"the",
"match"
] | 838d1858fc633f9cd99e91ec5902be50ec7089f0 | https://github.com/oliverwoodings/pkgify/blob/838d1858fc633f9cd99e91ec5902be50ec7089f0/lib/pkgify.js#L32-L47 | train |
neoziro/angular-match | angular-match.js | matchDirective | function matchDirective($parse) {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ctrl) {
scope.$watch(function () {
return [scope.$eval(attrs.match), ctrl.$viewValue];
}, function (values) {
ctrl.$setValidity('match', values[0] === values[1])... | javascript | function matchDirective($parse) {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ctrl) {
scope.$watch(function () {
return [scope.$eval(attrs.match), ctrl.$viewValue];
}, function (values) {
ctrl.$setValidity('match', values[0] === values[1])... | [
"function",
"matchDirective",
"(",
"$parse",
")",
"{",
"return",
"{",
"restrict",
":",
"'A'",
",",
"require",
":",
"'ngModel'",
",",
"link",
":",
"function",
"(",
"scope",
",",
"element",
",",
"attrs",
",",
"ctrl",
")",
"{",
"scope",
".",
"$watch",
"("... | Match directive.
@example
<input type="password" ng-match="password"> | [
"Match",
"directive",
"."
] | e77ca02b7ca8dcccec7a6d7e471e3dc11f15978c | https://github.com/neoziro/angular-match/blob/e77ca02b7ca8dcccec7a6d7e471e3dc11f15978c/angular-match.js#L14-L26 | train |
pauldenotter/nautical | lib/base.js | Base | function Base(client, endpoint) {
var base = this;
/**
* Get a list of all records for the current API
*
* @method list
* @param {Object} query - OPTIONAL querystring params
* @param {Function} callback
*/
base.list = function() {
return function(query, callback) {
var q = '';
if (query && 'fun... | javascript | function Base(client, endpoint) {
var base = this;
/**
* Get a list of all records for the current API
*
* @method list
* @param {Object} query - OPTIONAL querystring params
* @param {Function} callback
*/
base.list = function() {
return function(query, callback) {
var q = '';
if (query && 'fun... | [
"function",
"Base",
"(",
"client",
",",
"endpoint",
")",
"{",
"var",
"base",
"=",
"this",
";",
"/**\n\t * Get a list of all records for the current API\n\t *\n\t * @method list\n\t * @param {Object} query - OPTIONAL querystring params\n\t * @param {Function} callback\n\t */",
"base",
"... | Wrapper to provide basic functions for the API's
@class Base
@static | [
"Wrapper",
"to",
"provide",
"basic",
"functions",
"for",
"the",
"API",
"s"
] | 40707648c10073a356a424e6c9f75b642df7a7c7 | https://github.com/pauldenotter/nautical/blob/40707648c10073a356a424e6c9f75b642df7a7c7/lib/base.js#L9-L119 | train |
zackurben/event-chain | lib/Chain.js | function(config) {
this.events = new EventEmitter();
this.config = config || {};
// Allow someone to change the complete event label.
if (!this.config.complete) {
this.config.complete = '__complete';
}
debug('Chain created with the following configuration: ' + JSON.stringify(this.config));
} | javascript | function(config) {
this.events = new EventEmitter();
this.config = config || {};
// Allow someone to change the complete event label.
if (!this.config.complete) {
this.config.complete = '__complete';
}
debug('Chain created with the following configuration: ' + JSON.stringify(this.config));
} | [
"function",
"(",
"config",
")",
"{",
"this",
".",
"events",
"=",
"new",
"EventEmitter",
"(",
")",
";",
"this",
".",
"config",
"=",
"config",
"||",
"{",
"}",
";",
"// Allow someone to change the complete event label.",
"if",
"(",
"!",
"this",
".",
"config",
... | The primary container for chained events.
@param config
An optional configuration object.
@constructor | [
"The",
"primary",
"container",
"for",
"chained",
"events",
"."
] | d6b12f569afb58cb6b01e85dbb7dbf320583ed7b | https://github.com/zackurben/event-chain/blob/d6b12f569afb58cb6b01e85dbb7dbf320583ed7b/lib/Chain.js#L15-L25 | train | |
kibertoad/objection-utils | repositories/lib/services/entity.repository.js | _validateIsModel | function _validateIsModel(model) {
let parentClass = Object.getPrototypeOf(model);
while (parentClass.name !== 'Model' && parentClass.name !== '') {
parentClass = Object.getPrototypeOf(parentClass);
}
validationUtils.booleanTrue(
parentClass.name === 'Model',
'Parameter is not an Objection.js model'... | javascript | function _validateIsModel(model) {
let parentClass = Object.getPrototypeOf(model);
while (parentClass.name !== 'Model' && parentClass.name !== '') {
parentClass = Object.getPrototypeOf(parentClass);
}
validationUtils.booleanTrue(
parentClass.name === 'Model',
'Parameter is not an Objection.js model'... | [
"function",
"_validateIsModel",
"(",
"model",
")",
"{",
"let",
"parentClass",
"=",
"Object",
".",
"getPrototypeOf",
"(",
"model",
")",
";",
"while",
"(",
"parentClass",
".",
"name",
"!==",
"'Model'",
"&&",
"parentClass",
".",
"name",
"!==",
"''",
")",
"{",... | This is only invoked on the startup, so we can make this check non-trivial | [
"This",
"is",
"only",
"invoked",
"on",
"the",
"startup",
"so",
"we",
"can",
"make",
"this",
"check",
"non",
"-",
"trivial"
] | 6da0bc3ef1185ae52d77fb0af5630a5433dbd917 | https://github.com/kibertoad/objection-utils/blob/6da0bc3ef1185ae52d77fb0af5630a5433dbd917/repositories/lib/services/entity.repository.js#L202-L211 | train |
stormcolor/grel | dist/grel/nclgl.js | doNativeWasm | function doNativeWasm(global, env, providedBuffer) {
if (typeof WebAssembly !== 'object') {
err('no native wasm support detected');
return false;
}
// prepare memory import
if (!(Module['wasmMemory'] instanceof WebAssembly.Memory)) {
err('no native wasm Memory in use');
return fa... | javascript | function doNativeWasm(global, env, providedBuffer) {
if (typeof WebAssembly !== 'object') {
err('no native wasm support detected');
return false;
}
// prepare memory import
if (!(Module['wasmMemory'] instanceof WebAssembly.Memory)) {
err('no native wasm Memory in use');
return fa... | [
"function",
"doNativeWasm",
"(",
"global",
",",
"env",
",",
"providedBuffer",
")",
"{",
"if",
"(",
"typeof",
"WebAssembly",
"!==",
"'object'",
")",
"{",
"err",
"(",
"'no native wasm support detected'",
")",
";",
"return",
"false",
";",
"}",
"// prepare memory im... | do-method functions | [
"do",
"-",
"method",
"functions"
] | 37cd769a029cec5dcd75c43e1e0dba4737fa011a | https://github.com/stormcolor/grel/blob/37cd769a029cec5dcd75c43e1e0dba4737fa011a/dist/grel/nclgl.js#L1515-L1587 | train |
stormcolor/grel | dist/grel/nclgl.js | function(event) {
var e = event || window.event;
JSEvents.fillMouseEventData(JSEvents.wheelEvent, e, target);
HEAPF64[(((JSEvents.wheelEvent)+(72))>>3)]=e["deltaX"];
HEAPF64[(((JSEvents.wheelEvent)+(80))>>3)]=e["deltaY"];
HEAPF64[(((JSEvents.wheelEvent)+(88))>>3)]=e["de... | javascript | function(event) {
var e = event || window.event;
JSEvents.fillMouseEventData(JSEvents.wheelEvent, e, target);
HEAPF64[(((JSEvents.wheelEvent)+(72))>>3)]=e["deltaX"];
HEAPF64[(((JSEvents.wheelEvent)+(80))>>3)]=e["deltaY"];
HEAPF64[(((JSEvents.wheelEvent)+(88))>>3)]=e["de... | [
"function",
"(",
"event",
")",
"{",
"var",
"e",
"=",
"event",
"||",
"window",
".",
"event",
";",
"JSEvents",
".",
"fillMouseEventData",
"(",
"JSEvents",
".",
"wheelEvent",
",",
"e",
",",
"target",
")",
";",
"HEAPF64",
"[",
"(",
"(",
"(",
"JSEvents",
... | The DOM Level 3 events spec event 'wheel' | [
"The",
"DOM",
"Level",
"3",
"events",
"spec",
"event",
"wheel"
] | 37cd769a029cec5dcd75c43e1e0dba4737fa011a | https://github.com/stormcolor/grel/blob/37cd769a029cec5dcd75c43e1e0dba4737fa011a/dist/grel/nclgl.js#L5527-L5538 | train | |
ceoaliongroo/angular-weather | src/angular-weather.js | get | function get(city, _options) {
extend(options, _options, {city: city});
getWeather = $q.when(getWeather || angular.copy(getCache()) || getWeatherFromServer(city));
// Clear the promise cached, after resolve or reject the promise. Permit access to the cache data, when
// the promise excecution ... | javascript | function get(city, _options) {
extend(options, _options, {city: city});
getWeather = $q.when(getWeather || angular.copy(getCache()) || getWeatherFromServer(city));
// Clear the promise cached, after resolve or reject the promise. Permit access to the cache data, when
// the promise excecution ... | [
"function",
"get",
"(",
"city",
",",
"_options",
")",
"{",
"extend",
"(",
"options",
",",
"_options",
",",
"{",
"city",
":",
"city",
"}",
")",
";",
"getWeather",
"=",
"$q",
".",
"when",
"(",
"getWeather",
"||",
"angular",
".",
"copy",
"(",
"getCache"... | Return the promise with the category list, from cache or the server.
@param city - string
The city name. Ex: Houston
@param _options - object
The options to handle.
refresh: activate to get new weather information in interval
of delay time.
delay: interval of time in miliseconds.
@returns {Promise} | [
"Return",
"the",
"promise",
"with",
"the",
"category",
"list",
"from",
"cache",
"or",
"the",
"server",
"."
] | 4f8e4206c67c254549f5afdbeb10d6d694824144 | https://github.com/ceoaliongroo/angular-weather/blob/4f8e4206c67c254549f5afdbeb10d6d694824144/src/angular-weather.js#L62-L74 | train |
ceoaliongroo/angular-weather | src/angular-weather.js | getWeatherFromServer | function getWeatherFromServer(city) {
var deferred = $q.defer();
var url = openweatherEndpoint;
var params = {
q: city,
units: 'metric',
APPID: Config.openweather.apikey || ''
};
$http({
method: 'GET',
url: url,
params: params,
withou... | javascript | function getWeatherFromServer(city) {
var deferred = $q.defer();
var url = openweatherEndpoint;
var params = {
q: city,
units: 'metric',
APPID: Config.openweather.apikey || ''
};
$http({
method: 'GET',
url: url,
params: params,
withou... | [
"function",
"getWeatherFromServer",
"(",
"city",
")",
"{",
"var",
"deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"var",
"url",
"=",
"openweatherEndpoint",
";",
"var",
"params",
"=",
"{",
"q",
":",
"city",
",",
"units",
":",
"'metric'",
",",
"APPID... | Return Weather array from the server.
@returns {$q.promise} | [
"Return",
"Weather",
"array",
"from",
"the",
"server",
"."
] | 4f8e4206c67c254549f5afdbeb10d6d694824144 | https://github.com/ceoaliongroo/angular-weather/blob/4f8e4206c67c254549f5afdbeb10d6d694824144/src/angular-weather.js#L81-L107 | train |
ceoaliongroo/angular-weather | src/angular-weather.js | startRefreshWeather | function startRefreshWeather() {
interval = $interval(getWeatherFromServer(options.city), options.delay);
localforage.setItem('aw.refreshing', true);
} | javascript | function startRefreshWeather() {
interval = $interval(getWeatherFromServer(options.city), options.delay);
localforage.setItem('aw.refreshing', true);
} | [
"function",
"startRefreshWeather",
"(",
")",
"{",
"interval",
"=",
"$interval",
"(",
"getWeatherFromServer",
"(",
"options",
".",
"city",
")",
",",
"options",
".",
"delay",
")",
";",
"localforage",
".",
"setItem",
"(",
"'aw.refreshing'",
",",
"true",
")",
";... | Start an interval to refresh the weather cache data with new server data. | [
"Start",
"an",
"interval",
"to",
"refresh",
"the",
"weather",
"cache",
"data",
"with",
"new",
"server",
"data",
"."
] | 4f8e4206c67c254549f5afdbeb10d6d694824144 | https://github.com/ceoaliongroo/angular-weather/blob/4f8e4206c67c254549f5afdbeb10d6d694824144/src/angular-weather.js#L131-L134 | train |
ceoaliongroo/angular-weather | src/angular-weather.js | prepareWeather | function prepareWeather(weatherData) {
return {
temperature: weatherData.main.temp,
icon: (angular.isDefined(weatherIcons[weatherData.weather[0].icon])) ? weatherData.weather[0].icon : weatherData.weather[0].id,
description: weatherData.weather[0].description
}
} | javascript | function prepareWeather(weatherData) {
return {
temperature: weatherData.main.temp,
icon: (angular.isDefined(weatherIcons[weatherData.weather[0].icon])) ? weatherData.weather[0].icon : weatherData.weather[0].id,
description: weatherData.weather[0].description
}
} | [
"function",
"prepareWeather",
"(",
"weatherData",
")",
"{",
"return",
"{",
"temperature",
":",
"weatherData",
".",
"main",
".",
"temp",
",",
"icon",
":",
"(",
"angular",
".",
"isDefined",
"(",
"weatherIcons",
"[",
"weatherData",
".",
"weather",
"[",
"0",
"... | Prepare Weather object with order by list, tree and collection indexed by id.
Return the Weather object into a promises.
@param weatherData - {$q.promise)
Promise of list of Weather, comming from cache or the server. | [
"Prepare",
"Weather",
"object",
"with",
"order",
"by",
"list",
"tree",
"and",
"collection",
"indexed",
"by",
"id",
"."
] | 4f8e4206c67c254549f5afdbeb10d6d694824144 | https://github.com/ceoaliongroo/angular-weather/blob/4f8e4206c67c254549f5afdbeb10d6d694824144/src/angular-weather.js#L154-L160 | train |
BlackDice/lill | src/lill.js | func$withContext | function func$withContext(fn, item, i, ctx) { // eslint-disable-line max-params
return fn.call(ctx, item, i)
} | javascript | function func$withContext(fn, item, i, ctx) { // eslint-disable-line max-params
return fn.call(ctx, item, i)
} | [
"function",
"func$withContext",
"(",
"fn",
",",
"item",
",",
"i",
",",
"ctx",
")",
"{",
"// eslint-disable-line max-params",
"return",
"fn",
".",
"call",
"(",
"ctx",
",",
"item",
",",
"i",
")",
"}"
] | bit slower to use call when changing context | [
"bit",
"slower",
"to",
"use",
"call",
"when",
"changing",
"context"
] | 8bd52b904b9ecbc1d3eec262af8a4734e356188a | https://github.com/BlackDice/lill/blob/8bd52b904b9ecbc1d3eec262af8a4734e356188a/src/lill.js#L352-L354 | train |
BlackDice/lill | src/lill.js | getNeighbor | function getNeighbor(owner, item, dataPropertyName) {
const data = validateAttached(owner)
return obtainTrueValue(item[data[dataPropertyName]])
} | javascript | function getNeighbor(owner, item, dataPropertyName) {
const data = validateAttached(owner)
return obtainTrueValue(item[data[dataPropertyName]])
} | [
"function",
"getNeighbor",
"(",
"owner",
",",
"item",
",",
"dataPropertyName",
")",
"{",
"const",
"data",
"=",
"validateAttached",
"(",
"owner",
")",
"return",
"obtainTrueValue",
"(",
"item",
"[",
"data",
"[",
"dataPropertyName",
"]",
"]",
")",
"}"
] | just wrapper to minimize duplicate code | [
"just",
"wrapper",
"to",
"minimize",
"duplicate",
"code"
] | 8bd52b904b9ecbc1d3eec262af8a4734e356188a | https://github.com/BlackDice/lill/blob/8bd52b904b9ecbc1d3eec262af8a4734e356188a/src/lill.js#L365-L368 | train |
smartface/sf-component-calendar | scripts/components/__Calendar_List.js | CalendarList | function CalendarList(_super) {
_super(this, {
flexGrow: 1,
alignSelf: FlexLayout.AlignSelf.STRETCH,
backgroundColor: Color.GREEN,
});
this.init();
} | javascript | function CalendarList(_super) {
_super(this, {
flexGrow: 1,
alignSelf: FlexLayout.AlignSelf.STRETCH,
backgroundColor: Color.GREEN,
});
this.init();
} | [
"function",
"CalendarList",
"(",
"_super",
")",
"{",
"_super",
"(",
"this",
",",
"{",
"flexGrow",
":",
"1",
",",
"alignSelf",
":",
"FlexLayout",
".",
"AlignSelf",
".",
"STRETCH",
",",
"backgroundColor",
":",
"Color",
".",
"GREEN",
",",
"}",
")",
";",
"... | CalendarList Component constructor
@constructor | [
"CalendarList",
"Component",
"constructor"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/scripts/components/__Calendar_List.js#L10-L18 | train |
Ragnarokkr/chrome-i18n | lib/commons.js | validateMeta | function validateMeta( meta, errBuf ) {
var supportedLocales =
'ar,am,bg,bn,ca,cs,da,de,el,en,en_GB,en_US,es,es_419,et,' +
'fa,fi,fil,fr,gu,he,hi,hr,hu,id,it,ja,kn,ko,lt,lv,ml,mr,' +
'ms,nl,no,pl,pt_BR,pt_PT,ro,ru,sk,sl,sr,sv,sw,ta,te,th,' +
'tr,uk,vi,zh_CN,zh_TW'.split(','),
isFormatValid = true,
isIm... | javascript | function validateMeta( meta, errBuf ) {
var supportedLocales =
'ar,am,bg,bn,ca,cs,da,de,el,en,en_GB,en_US,es,es_419,et,' +
'fa,fi,fil,fr,gu,he,hi,hr,hu,id,it,ja,kn,ko,lt,lv,ml,mr,' +
'ms,nl,no,pl,pt_BR,pt_PT,ro,ru,sk,sl,sr,sv,sw,ta,te,th,' +
'tr,uk,vi,zh_CN,zh_TW'.split(','),
isFormatValid = true,
isIm... | [
"function",
"validateMeta",
"(",
"meta",
",",
"errBuf",
")",
"{",
"var",
"supportedLocales",
"=",
"'ar,am,bg,bn,ca,cs,da,de,el,en,en_GB,en_US,es,es_419,et,'",
"+",
"'fa,fi,fil,fr,gu,he,hi,hr,hu,id,it,ja,kn,ko,lt,lv,ml,mr,'",
"+",
"'ms,nl,no,pl,pt_BR,pt_PT,ro,ru,sk,sl,sr,sv,sw,ta,te,th,... | Checks the integrity of the META descriptor.
The locales codes are compared to those supported by the Chrome
Store (https://developers.google.com/chrome/web-store/docs/i18n?hl=it#localeTable),
so any unsupported locale code will invalidate the field.
@param {object} meta a valid JSON object
@param {array} errBuf buff... | [
"Checks",
"the",
"integrity",
"of",
"the",
"META",
"descriptor",
"."
] | e7660533fc6846f89bdf5cb6f3745a1b8930f4b9 | https://github.com/Ragnarokkr/chrome-i18n/blob/e7660533fc6846f89bdf5cb6f3745a1b8930f4b9/lib/commons.js#L26-L120 | train |
camme/zonar | lib/zonar.js | listen | function listen(next) {
listenSocket = dgram.createSocket({ type: 'udp4', reuseAddr: true });
listenSocket.on('message', function(payload, rinfo) {
var message = parseMessage(payload, rinfo);
if (message) {
if (message.id != id) {
if (message... | javascript | function listen(next) {
listenSocket = dgram.createSocket({ type: 'udp4', reuseAddr: true });
listenSocket.on('message', function(payload, rinfo) {
var message = parseMessage(payload, rinfo);
if (message) {
if (message.id != id) {
if (message... | [
"function",
"listen",
"(",
"next",
")",
"{",
"listenSocket",
"=",
"dgram",
".",
"createSocket",
"(",
"{",
"type",
":",
"'udp4'",
",",
"reuseAddr",
":",
"true",
"}",
")",
";",
"listenSocket",
".",
"on",
"(",
"'message'",
",",
"function",
"(",
"payload",
... | Listen for incoming single messages | [
"Listen",
"for",
"incoming",
"single",
"messages"
] | 9a2c9a355a885f68cbbf21cb170d3763abb0f458 | https://github.com/camme/zonar/blob/9a2c9a355a885f68cbbf21cb170d3763abb0f458/lib/zonar.js#L185-L215 | train |
camme/zonar | lib/zonar.js | createMessage | function createMessage(status) {
var message = [];
message.push(broadcastIdentifier);
message.push(compabilityVersion);
message.push(netId);
message.push(id);
message.push(name);
message.push(self.port);
message.push(status);
//message.push(mode)... | javascript | function createMessage(status) {
var message = [];
message.push(broadcastIdentifier);
message.push(compabilityVersion);
message.push(netId);
message.push(id);
message.push(name);
message.push(self.port);
message.push(status);
//message.push(mode)... | [
"function",
"createMessage",
"(",
"status",
")",
"{",
"var",
"message",
"=",
"[",
"]",
";",
"message",
".",
"push",
"(",
"broadcastIdentifier",
")",
";",
"message",
".",
"push",
"(",
"compabilityVersion",
")",
";",
"message",
".",
"push",
"(",
"netId",
"... | Creates the broadcast string, and returns a buffer | [
"Creates",
"the",
"broadcast",
"string",
"and",
"returns",
"a",
"buffer"
] | 9a2c9a355a885f68cbbf21cb170d3763abb0f458 | https://github.com/camme/zonar/blob/9a2c9a355a885f68cbbf21cb170d3763abb0f458/lib/zonar.js#L487-L506 | train |
eblanshey/safenet | src/request.js | Request | function Request(Safe, uri, method) {
if (!this)
return new Request(Safe, uri, method);
this.Safe = Safe;
this.uri = uri;
this.method = method;
this._needAuth = false;
this._returnMeta = false;
} | javascript | function Request(Safe, uri, method) {
if (!this)
return new Request(Safe, uri, method);
this.Safe = Safe;
this.uri = uri;
this.method = method;
this._needAuth = false;
this._returnMeta = false;
} | [
"function",
"Request",
"(",
"Safe",
",",
"uri",
",",
"method",
")",
"{",
"if",
"(",
"!",
"this",
")",
"return",
"new",
"Request",
"(",
"Safe",
",",
"uri",
",",
"method",
")",
";",
"this",
".",
"Safe",
"=",
"Safe",
";",
"this",
".",
"uri",
"=",
... | The main function for creating new Requests to SAFE
@param Safe
@param uri
@param method
@returns {Request}
@constructor | [
"The",
"main",
"function",
"for",
"creating",
"new",
"Requests",
"to",
"SAFE"
] | 8438251bf0999b43f39c231df299b05d01dd4618 | https://github.com/eblanshey/safenet/blob/8438251bf0999b43f39c231df299b05d01dd4618/src/request.js#L47-L56 | 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.