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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
odentools/denhub-device | models/helper.js | function (is_ignore_errors) {
var file_paths = [];
// root of dependence source directory
file_paths.push('./commands.json');
// root of denhub-device directory
file_paths.push(__dirname + '/../commands.json');
var file = null;
for (var i = 0, l = file_paths.length; i < l; i++) {
try {
file = re... | javascript | function (is_ignore_errors) {
var file_paths = [];
// root of dependence source directory
file_paths.push('./commands.json');
// root of denhub-device directory
file_paths.push(__dirname + '/../commands.json');
var file = null;
for (var i = 0, l = file_paths.length; i < l; i++) {
try {
file = re... | [
"function",
"(",
"is_ignore_errors",
")",
"{",
"var",
"file_paths",
"=",
"[",
"]",
";",
"// root of dependence source directory",
"file_paths",
".",
"push",
"(",
"'./commands.json'",
")",
";",
"// root of denhub-device directory",
"file_paths",
".",
"push",
"(",
"__di... | Read the user's commands definition
@return {Object} Commands definition | [
"Read",
"the",
"user",
"s",
"commands",
"definition"
] | 50d35aca96db3a07a3272f1765a660ea893735ce | https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/models/helper.js#L127-L166 | train | |
odentools/denhub-device | models/helper.js | function (str) {
var self = this;
if ('i' !== 'I'.toLowerCase()) {
// Thanks for http://qiita.com/niusounds/items/fff91f3f236c31ca910f
return str.replace(/[a-z]/g, function(ch) {
return String.fromCharCode(ch.charCodeAt(0) & ~32);
});
}
return str.toUpperCase();
} | javascript | function (str) {
var self = this;
if ('i' !== 'I'.toLowerCase()) {
// Thanks for http://qiita.com/niusounds/items/fff91f3f236c31ca910f
return str.replace(/[a-z]/g, function(ch) {
return String.fromCharCode(ch.charCodeAt(0) & ~32);
});
}
return str.toUpperCase();
} | [
"function",
"(",
"str",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"'i'",
"!==",
"'I'",
".",
"toLowerCase",
"(",
")",
")",
"{",
"// Thanks for http://qiita.com/niusounds/items/fff91f3f236c31ca910f",
"return",
"str",
".",
"replace",
"(",
"/",
"[a-z]"... | Conver the string to upper case
@return {String} Converted string | [
"Conver",
"the",
"string",
"to",
"upper",
"case"
] | 50d35aca96db3a07a3272f1765a660ea893735ce | https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/models/helper.js#L173-L186 | train | |
odentools/denhub-device | models/helper.js | function (obj, var_type) {
var text_class = Object.prototype.toString.call(obj).slice(8, -1);
return (text_class == var_type);
} | javascript | function (obj, var_type) {
var text_class = Object.prototype.toString.call(obj).slice(8, -1);
return (text_class == var_type);
} | [
"function",
"(",
"obj",
",",
"var_type",
")",
"{",
"var",
"text_class",
"=",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"obj",
")",
".",
"slice",
"(",
"8",
",",
"-",
"1",
")",
";",
"return",
"(",
"text_class",
"==",
"var_type",
... | Whether the variable type is matched with the specified variable type
@param {Object} obj Target variable
@param {String} var_type Expected variable type
@return {Boolean} Whether the type is matched | [
"Whether",
"the",
"variable",
"type",
"is",
"matched",
"with",
"the",
"specified",
"variable",
"type"
] | 50d35aca96db3a07a3272f1765a660ea893735ce | https://github.com/odentools/denhub-device/blob/50d35aca96db3a07a3272f1765a660ea893735ce/models/helper.js#L195-L200 | train | |
dpjanes/iotdb-phant-client | phant.js | function(paramd) {
var self = this
paramd = defaults(paramd, {
iri: "http://data.sparkfun.com"
})
self.iri = paramd.iri
} | javascript | function(paramd) {
var self = this
paramd = defaults(paramd, {
iri: "http://data.sparkfun.com"
})
self.iri = paramd.iri
} | [
"function",
"(",
"paramd",
")",
"{",
"var",
"self",
"=",
"this",
"paramd",
"=",
"defaults",
"(",
"paramd",
",",
"{",
"iri",
":",
"\"http://data.sparkfun.com\"",
"}",
")",
"self",
".",
"iri",
"=",
"paramd",
".",
"iri",
"}"
] | Connect to a Phant server
@param {object} paramd
@param {String|undefined} paramd.iri
The server to connect to, by default "http://data.sparkfun.com"
@constructor | [
"Connect",
"to",
"a",
"Phant",
"server"
] | 69958f6c532d7ea404d6c2bba8def1feaecddb1d | https://github.com/dpjanes/iotdb-phant-client/blob/69958f6c532d7ea404d6c2bba8def1feaecddb1d/phant.js#L40-L48 | train | |
dpjanes/iotdb-phant-client | phant.js | function(paramd, defaultd) {
if (paramd === undefined) {
return defaultd
}
for (var key in defaultd) {
var pvalue = paramd[key]
if (pvalue === undefined) {
paramd[key] = defaultd[key]
}
}
return paramd;
} | javascript | function(paramd, defaultd) {
if (paramd === undefined) {
return defaultd
}
for (var key in defaultd) {
var pvalue = paramd[key]
if (pvalue === undefined) {
paramd[key] = defaultd[key]
}
}
return paramd;
} | [
"function",
"(",
"paramd",
",",
"defaultd",
")",
"{",
"if",
"(",
"paramd",
"===",
"undefined",
")",
"{",
"return",
"defaultd",
"}",
"for",
"(",
"var",
"key",
"in",
"defaultd",
")",
"{",
"var",
"pvalue",
"=",
"paramd",
"[",
"key",
"]",
"if",
"(",
"p... | Make sure a 'paramd' is properly set up. That is,
that it's a dictionary and if any values in defaultd
are undefined in paramd, they're copied over | [
"Make",
"sure",
"a",
"paramd",
"is",
"properly",
"set",
"up",
".",
"That",
"is",
"that",
"it",
"s",
"a",
"dictionary",
"and",
"if",
"any",
"values",
"in",
"defaultd",
"are",
"undefined",
"in",
"paramd",
"they",
"re",
"copied",
"over"
] | 69958f6c532d7ea404d6c2bba8def1feaecddb1d | https://github.com/dpjanes/iotdb-phant-client/blob/69958f6c532d7ea404d6c2bba8def1feaecddb1d/phant.js#L524-L537 | train | |
itsa/itsa-event | event-listener.js | function (customEvent, callback, filter, prepend) {
return Event.after(customEvent, callback, this, filter, prepend);
} | javascript | function (customEvent, callback, filter, prepend) {
return Event.after(customEvent, callback, this, filter, prepend);
} | [
"function",
"(",
"customEvent",
",",
"callback",
",",
"filter",
",",
"prepend",
")",
"{",
"return",
"Event",
".",
"after",
"(",
"customEvent",
",",
"callback",
",",
"this",
",",
"filter",
",",
"prepend",
")",
";",
"}"
] | Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed `after` the defaultFn.
@method after
@param customEvent {String|Array} the custom-event (or Array of events) to subscribe to. CustomEvents should
have the syntax: `emitterName:eventName`. Wildcard `*` may be used f... | [
"Subscribes",
"to",
"a",
"customEvent",
"on",
"behalf",
"of",
"the",
"object",
"who",
"calls",
"this",
"method",
".",
"The",
"callback",
"will",
"be",
"executed",
"after",
"the",
"defaultFn",
"."
] | fd7b5ede1a5e8b6a237f60bd8373f570d014f5fa | https://github.com/itsa/itsa-event/blob/fd7b5ede1a5e8b6a237f60bd8373f570d014f5fa/event-listener.js#L49-L51 | train | |
itsa/itsa-event | event-listener.js | function (customEvent, callback, filter, prepend) {
return Event.before(customEvent, callback, this, filter, prepend);
} | javascript | function (customEvent, callback, filter, prepend) {
return Event.before(customEvent, callback, this, filter, prepend);
} | [
"function",
"(",
"customEvent",
",",
"callback",
",",
"filter",
",",
"prepend",
")",
"{",
"return",
"Event",
".",
"before",
"(",
"customEvent",
",",
"callback",
",",
"this",
",",
"filter",
",",
"prepend",
")",
";",
"}"
] | Subscribes to a customEvent on behalf of the object who calls this method.
The callback will be executed `before` the defaultFn.
@method before
@param customEvent {String|Array} the custom-event (or Array of events) to subscribe to. CustomEvents should
have the syntax: `emitterName:eventName`. Wildcard `*` may be used... | [
"Subscribes",
"to",
"a",
"customEvent",
"on",
"behalf",
"of",
"the",
"object",
"who",
"calls",
"this",
"method",
".",
"The",
"callback",
"will",
"be",
"executed",
"before",
"the",
"defaultFn",
"."
] | fd7b5ede1a5e8b6a237f60bd8373f570d014f5fa | https://github.com/itsa/itsa-event/blob/fd7b5ede1a5e8b6a237f60bd8373f570d014f5fa/event-listener.js#L72-L74 | train | |
chiasm-project/chiasm-layout | src/layout.js | setBox | function setBox(){
if(my.container){
my.box = {
x: 0,
y: 0,
width: my.container.clientWidth,
height: my.container.clientHeight
};
}
} | javascript | function setBox(){
if(my.container){
my.box = {
x: 0,
y: 0,
width: my.container.clientWidth,
height: my.container.clientHeight
};
}
} | [
"function",
"setBox",
"(",
")",
"{",
"if",
"(",
"my",
".",
"container",
")",
"{",
"my",
".",
"box",
"=",
"{",
"x",
":",
"0",
",",
"y",
":",
"0",
",",
"width",
":",
"my",
".",
"container",
".",
"clientWidth",
",",
"height",
":",
"my",
".",
"co... | Sets the `box` my property based on actual container size . | [
"Sets",
"the",
"box",
"my",
"property",
"based",
"on",
"actual",
"container",
"size",
"."
] | 245ddd2d8c1d19fa08b085cd6b8920be85453530 | https://github.com/chiasm-project/chiasm-layout/blob/245ddd2d8c1d19fa08b085cd6b8920be85453530/src/layout.js#L33-L42 | train |
chiasm-project/chiasm-layout | src/layout.js | aliasesInLayout | function aliasesInLayout(layout, sizes){
return Object.keys(computeLayout(layout, sizes, {
width: 100,
height: 100
}));
} | javascript | function aliasesInLayout(layout, sizes){
return Object.keys(computeLayout(layout, sizes, {
width: 100,
height: 100
}));
} | [
"function",
"aliasesInLayout",
"(",
"layout",
",",
"sizes",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"computeLayout",
"(",
"layout",
",",
"sizes",
",",
"{",
"width",
":",
"100",
",",
"height",
":",
"100",
"}",
")",
")",
";",
"}"
] | Computes which aliases are referenced in the given layout. | [
"Computes",
"which",
"aliases",
"are",
"referenced",
"in",
"the",
"given",
"layout",
"."
] | 245ddd2d8c1d19fa08b085cd6b8920be85453530 | https://github.com/chiasm-project/chiasm-layout/blob/245ddd2d8c1d19fa08b085cd6b8920be85453530/src/layout.js#L110-L115 | train |
camshaft/links-parser | index.js | parseParams | function parseParams(params, init) {
return reduce(params, function(obj, param) {
var parts = param.split(/ *= */);
var key = removeQuote(parts[0]);
obj[key] = removeQuote(parts[1]);
return obj;
}, init);
} | javascript | function parseParams(params, init) {
return reduce(params, function(obj, param) {
var parts = param.split(/ *= */);
var key = removeQuote(parts[0]);
obj[key] = removeQuote(parts[1]);
return obj;
}, init);
} | [
"function",
"parseParams",
"(",
"params",
",",
"init",
")",
"{",
"return",
"reduce",
"(",
"params",
",",
"function",
"(",
"obj",
",",
"param",
")",
"{",
"var",
"parts",
"=",
"param",
".",
"split",
"(",
"/",
" *= *",
"/",
")",
";",
"var",
"key",
"="... | Parse key=value parameters
@param {Object} params
@param {Object} init
@return {Object} | [
"Parse",
"key",
"=",
"value",
"parameters"
] | 358afb23cb28f9c8a24d0b3d795a07ec1ab87c18 | https://github.com/camshaft/links-parser/blob/358afb23cb28f9c8a24d0b3d795a07ec1ab87c18/index.js#L49-L56 | train |
eventualbuddha/broccoli-compile-modules | index.js | CompileModules | function CompileModules(inputTree, options) {
this.setInputTree(inputTree);
this.setInputFiles(options.inputFiles);
this.setResolvers(options.resolvers || []);
this.setOutput(options.output);
this.setFormatter(options.formatter);
if (options.output) {
this.description = 'CompileModules (' + options.o... | javascript | function CompileModules(inputTree, options) {
this.setInputTree(inputTree);
this.setInputFiles(options.inputFiles);
this.setResolvers(options.resolvers || []);
this.setOutput(options.output);
this.setFormatter(options.formatter);
if (options.output) {
this.description = 'CompileModules (' + options.o... | [
"function",
"CompileModules",
"(",
"inputTree",
",",
"options",
")",
"{",
"this",
".",
"setInputTree",
"(",
"inputTree",
")",
";",
"this",
".",
"setInputFiles",
"(",
"options",
".",
"inputFiles",
")",
";",
"this",
".",
"setResolvers",
"(",
"options",
".",
... | Creates a new compiled modules writer.
@param inputTree
@param {{inputFiles: ?string[], resolvers: ?object[], output: string, formatter: object}} options
@extends {Writer}
@constructor | [
"Creates",
"a",
"new",
"compiled",
"modules",
"writer",
"."
] | 9bab25bdc22399b0961fb44aa2aa5f012e020ea6 | https://github.com/eventualbuddha/broccoli-compile-modules/blob/9bab25bdc22399b0961fb44aa2aa5f012e020ea6/index.js#L35-L45 | train |
nicktindall/cyclon.p2p-common | lib/ObfuscatingStorageWrapper.js | ObfuscatingStorageWrapper | function ObfuscatingStorageWrapper(storage) {
var SECRET_KEY_KEY = "___XX";
var wellKnownKey = "ce56c9aa-d287-4e7c-b9d5-edca7a985487";
function getSecretKey() {
var secretKeyName = scrambleKey(SECRET_KEY_KEY, wellKnownKey);
var secretKey = storage.getItem(secretKeyName);
if (secret... | javascript | function ObfuscatingStorageWrapper(storage) {
var SECRET_KEY_KEY = "___XX";
var wellKnownKey = "ce56c9aa-d287-4e7c-b9d5-edca7a985487";
function getSecretKey() {
var secretKeyName = scrambleKey(SECRET_KEY_KEY, wellKnownKey);
var secretKey = storage.getItem(secretKeyName);
if (secret... | [
"function",
"ObfuscatingStorageWrapper",
"(",
"storage",
")",
"{",
"var",
"SECRET_KEY_KEY",
"=",
"\"___XX\"",
";",
"var",
"wellKnownKey",
"=",
"\"ce56c9aa-d287-4e7c-b9d5-edca7a985487\"",
";",
"function",
"getSecretKey",
"(",
")",
"{",
"var",
"secretKeyName",
"=",
"scr... | You don't need to be a genius to break this "security" but it should
slow tinkerers down a little
@param GuidService
@returns {{wrapStorage: Function}}
@constructor | [
"You",
"don",
"t",
"need",
"to",
"be",
"a",
"genius",
"to",
"break",
"this",
"security",
"but",
"it",
"should",
"slow",
"tinkerers",
"down",
"a",
"little"
] | 04ee34984c9d5145e265a886bf261cb64dc20e3c | https://github.com/nicktindall/cyclon.p2p-common/blob/04ee34984c9d5145e265a886bf261cb64dc20e3c/lib/ObfuscatingStorageWrapper.js#L14-L70 | train |
the-simian/phaser-shim-loader | phaser-debug.js | phaserShimDebug | function phaserShimDebug(source) {
this.cacheable && this.cacheable();
source = source.replace(/(var\s+ui\s*=\s*require\('\.\/util\/ui'\))/, 'var Phaser = _Phaser; $1');
source = '(function () { var _Phaser = require("phaser").Phaser;\n\n' + source + '\n\n}());';
return source;
} | javascript | function phaserShimDebug(source) {
this.cacheable && this.cacheable();
source = source.replace(/(var\s+ui\s*=\s*require\('\.\/util\/ui'\))/, 'var Phaser = _Phaser; $1');
source = '(function () { var _Phaser = require("phaser").Phaser;\n\n' + source + '\n\n}());';
return source;
} | [
"function",
"phaserShimDebug",
"(",
"source",
")",
"{",
"this",
".",
"cacheable",
"&&",
"this",
".",
"cacheable",
"(",
")",
";",
"source",
"=",
"source",
".",
"replace",
"(",
"/",
"(var\\s+ui\\s*=\\s*require\\('\\.\\/util\\/ui'\\))",
"/",
",",
"'var Phaser = _Phas... | phaser-debug-webpack-loader | [
"phaser",
"-",
"debug",
"-",
"webpack",
"-",
"loader"
] | ff22b8903de18d6d9eff1765722366892daf929a | https://github.com/the-simian/phaser-shim-loader/blob/ff22b8903de18d6d9eff1765722366892daf929a/phaser-debug.js#L4-L11 | train |
AndreasMadsen/steer-screenshot | steer-screenshot.js | retry | function retry(err) {
if (currentAttempt >= retryCount) {
return callback(err, null, currentAttempt);
}
currentAttempt += 1;
// Since the currentAttempt starts at 1 and it was just incremented
// currentAttempt - 2 will be the actual timeout index.
return setTimeout(attempt, timeouts[cur... | javascript | function retry(err) {
if (currentAttempt >= retryCount) {
return callback(err, null, currentAttempt);
}
currentAttempt += 1;
// Since the currentAttempt starts at 1 and it was just incremented
// currentAttempt - 2 will be the actual timeout index.
return setTimeout(attempt, timeouts[cur... | [
"function",
"retry",
"(",
"err",
")",
"{",
"if",
"(",
"currentAttempt",
">=",
"retryCount",
")",
"{",
"return",
"callback",
"(",
"err",
",",
"null",
",",
"currentAttempt",
")",
";",
"}",
"currentAttempt",
"+=",
"1",
";",
"// Since the currentAttempt starts at ... | The error is never null in this function call | [
"The",
"error",
"is",
"never",
"null",
"in",
"this",
"function",
"call"
] | 7059be89f14b35e1e3f8eaadc0fff2ef0f749fa0 | https://github.com/AndreasMadsen/steer-screenshot/blob/7059be89f14b35e1e3f8eaadc0fff2ef0f749fa0/steer-screenshot.js#L48-L58 | train |
cwebbdesign/component-maker | index.js | make | function make(component, config) {
var Constructor, Subclass,
conf = config || {};
// Config exists as a way to create pass a set of derived options. In the original use case a function was created
// to parse the DOM and pass information to the component at the time of creation.
// Allow the $el... | javascript | function make(component, config) {
var Constructor, Subclass,
conf = config || {};
// Config exists as a way to create pass a set of derived options. In the original use case a function was created
// to parse the DOM and pass information to the component at the time of creation.
// Allow the $el... | [
"function",
"make",
"(",
"component",
",",
"config",
")",
"{",
"var",
"Constructor",
",",
"Subclass",
",",
"conf",
"=",
"config",
"||",
"{",
"}",
";",
"// Config exists as a way to create pass a set of derived options. In the original use case a function was created",
"// t... | Important to note that the components which are initialized, inherit the same event emitter. this enables all components of the same type to listen to events. As the emitter is intended to listen to application level events, it makes sense to me that all instances would respond to the event | [
"Important",
"to",
"note",
"that",
"the",
"components",
"which",
"are",
"initialized",
"inherit",
"the",
"same",
"event",
"emitter",
".",
"this",
"enables",
"all",
"components",
"of",
"the",
"same",
"type",
"to",
"listen",
"to",
"events",
".",
"As",
"the",
... | 1b4edafd3090f2f6e42d61a8d612b9ef791fcab2 | https://github.com/cwebbdesign/component-maker/blob/1b4edafd3090f2f6e42d61a8d612b9ef791fcab2/index.js#L191-L216 | train |
fastest963/DelimiterStream | DelimiterStream.js | emitEvents | function emitEvents(stream) {
//if emitEvents gets called while in emitEvents we don't want to screw up the order
if (stream._emittingMatches) {
return;
}
var matches = stream.matches,
i = matches.length;
stream.matches = [];
stream._emittingMatch... | javascript | function emitEvents(stream) {
//if emitEvents gets called while in emitEvents we don't want to screw up the order
if (stream._emittingMatches) {
return;
}
var matches = stream.matches,
i = matches.length;
stream.matches = [];
stream._emittingMatch... | [
"function",
"emitEvents",
"(",
"stream",
")",
"{",
"//if emitEvents gets called while in emitEvents we don't want to screw up the order",
"if",
"(",
"stream",
".",
"_emittingMatches",
")",
"{",
"return",
";",
"}",
"var",
"matches",
"=",
"stream",
".",
"matches",
",",
... | Emit "data" events for each match | [
"Emit",
"data",
"events",
"for",
"each",
"match"
] | 1e31f16efca182d5e0d1eb04bce4740af8d2746e | https://github.com/fastest963/DelimiterStream/blob/1e31f16efca182d5e0d1eb04bce4740af8d2746e/DelimiterStream.js#L37-L55 | train |
fastest963/DelimiterStream | DelimiterStream.js | handleData | function handleData(stream, asString, data, dataLimit) {
var dataLen = data.length,
i = dataLen,
trailingDataIndex = -1, //index of data after the last delimiter match in data
lastMatchIndex = 0,
matchLimit = dataLimit || Infinity,
len = 0;
/... | javascript | function handleData(stream, asString, data, dataLimit) {
var dataLen = data.length,
i = dataLen,
trailingDataIndex = -1, //index of data after the last delimiter match in data
lastMatchIndex = 0,
matchLimit = dataLimit || Infinity,
len = 0;
/... | [
"function",
"handleData",
"(",
"stream",
",",
"asString",
",",
"data",
",",
"dataLimit",
")",
"{",
"var",
"dataLen",
"=",
"data",
".",
"length",
",",
"i",
"=",
"dataLen",
",",
"trailingDataIndex",
"=",
"-",
"1",
",",
"//index of data after the last delimiter m... | Handle data from a string stream | [
"Handle",
"data",
"from",
"a",
"string",
"stream"
] | 1e31f16efca182d5e0d1eb04bce4740af8d2746e | https://github.com/fastest963/DelimiterStream/blob/1e31f16efca182d5e0d1eb04bce4740af8d2746e/DelimiterStream.js#L60-L124 | train |
nachos/nachos-api | lib/api/settings/index.js | function (pkg, options) {
var settingsFile = new SettingsFile(pkg, options);
var save = settingsFile.save;
settingsFile.save = _.bind(function (config) {
return save.call(settingsFile, config)
.then(function () {
client.emit('config.global-changed', {
app: pkg,
... | javascript | function (pkg, options) {
var settingsFile = new SettingsFile(pkg, options);
var save = settingsFile.save;
settingsFile.save = _.bind(function (config) {
return save.call(settingsFile, config)
.then(function () {
client.emit('config.global-changed', {
app: pkg,
... | [
"function",
"(",
"pkg",
",",
"options",
")",
"{",
"var",
"settingsFile",
"=",
"new",
"SettingsFile",
"(",
"pkg",
",",
"options",
")",
";",
"var",
"save",
"=",
"settingsFile",
".",
"save",
";",
"settingsFile",
".",
"save",
"=",
"_",
".",
"bind",
"(",
... | Build a wrapped instance of settings file
@param {string} pkg Package name
@param {object} options Default settings of the package
@returns {SettingsFile} Wrapped settings file | [
"Build",
"a",
"wrapped",
"instance",
"of",
"settings",
"file"
] | a0f4633967fab37a1ab1066a053f31563b303c4e | https://github.com/nachos/nachos-api/blob/a0f4633967fab37a1ab1066a053f31563b303c4e/lib/api/settings/index.js#L15-L93 | train | |
patgrasso/parsey | lib/rules.js | Rule | function Rule(lhs, rhs, valuator) {
let arr = [];
if (!rhs || rhs.length === 0) {
throw new Error('Rule does not produce anything');
}
arr.push.apply(arr, rhs);
arr.lhs = lhs;
Object.defineProperty(arr, 'lhs', { value: lhs });
Object.defineProperty(arr, 'evaluate', {
value: (values) => (valuator... | javascript | function Rule(lhs, rhs, valuator) {
let arr = [];
if (!rhs || rhs.length === 0) {
throw new Error('Rule does not produce anything');
}
arr.push.apply(arr, rhs);
arr.lhs = lhs;
Object.defineProperty(arr, 'lhs', { value: lhs });
Object.defineProperty(arr, 'evaluate', {
value: (values) => (valuator... | [
"function",
"Rule",
"(",
"lhs",
",",
"rhs",
",",
"valuator",
")",
"{",
"let",
"arr",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"rhs",
"||",
"rhs",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Rule does not produce anything'",
")",
... | Defines a production rule, with a sole symbol on the left-hand side and a
list of symbols on the right-hand side. The constructor also accepts a third
argument, a valuator function, which can be used to evaluate values that are
obtained by matching this production
@class Rule
@extends Array
@constructor
@memberof modu... | [
"Defines",
"a",
"production",
"rule",
"with",
"a",
"sole",
"symbol",
"on",
"the",
"left",
"-",
"hand",
"side",
"and",
"a",
"list",
"of",
"symbols",
"on",
"the",
"right",
"-",
"hand",
"side",
".",
"The",
"constructor",
"also",
"accepts",
"a",
"third",
"... | d28b3f330ee03b5c273f1ce5871a5b86dac79fb0 | https://github.com/patgrasso/parsey/blob/d28b3f330ee03b5c273f1ce5871a5b86dac79fb0/lib/rules.js#L26-L43 | train |
patgrasso/parsey | lib/rules.js | Sym | function Sym(name) {
let symbol = {};
symbol.__proto__ = Sym.prototype;
symbol.name = name;
return symbol;
} | javascript | function Sym(name) {
let symbol = {};
symbol.__proto__ = Sym.prototype;
symbol.name = name;
return symbol;
} | [
"function",
"Sym",
"(",
"name",
")",
"{",
"let",
"symbol",
"=",
"{",
"}",
";",
"symbol",
".",
"__proto__",
"=",
"Sym",
".",
"prototype",
";",
"symbol",
".",
"name",
"=",
"name",
";",
"return",
"symbol",
";",
"}"
] | Constructor for the Sym class, which simply represents a non-terminal symbol
in a grammar. While parsing, Syms are compared by reference, not by name. So,
the name argument is optional as it serves no purpose for parsing. For
debugging and evaluation of a parse tree, however, the name could be quite
useful
@class Sym
... | [
"Constructor",
"for",
"the",
"Sym",
"class",
"which",
"simply",
"represents",
"a",
"non",
"-",
"terminal",
"symbol",
"in",
"a",
"grammar",
".",
"While",
"parsing",
"Syms",
"are",
"compared",
"by",
"reference",
"not",
"by",
"name",
".",
"So",
"the",
"name",... | d28b3f330ee03b5c273f1ce5871a5b86dac79fb0 | https://github.com/patgrasso/parsey/blob/d28b3f330ee03b5c273f1ce5871a5b86dac79fb0/lib/rules.js#L61-L66 | train |
substance/commander | src/keyboard.js | _getMatches | function _getMatches(character, modifiers, e, sequenceName, combination, level) {
var i,
callback,
matches = [],
action = e.type;
// if there are no events related to this keycode
if (!this._callbacks[character]) {
return [];
}
// if a modifier key... | javascript | function _getMatches(character, modifiers, e, sequenceName, combination, level) {
var i,
callback,
matches = [],
action = e.type;
// if there are no events related to this keycode
if (!this._callbacks[character]) {
return [];
}
// if a modifier key... | [
"function",
"_getMatches",
"(",
"character",
",",
"modifiers",
",",
"e",
",",
"sequenceName",
",",
"combination",
",",
"level",
")",
"{",
"var",
"i",
",",
"callback",
",",
"matches",
"=",
"[",
"]",
",",
"action",
"=",
"e",
".",
"type",
";",
"// if ther... | finds all callbacks that match based on the keycode, modifiers,
and action
@param {string} character
@param {Array} modifiers
@param {Event|Object} e
@param {string=} sequenceName - name of the sequence we are looking for
@param {string=} combination
@param {number=} level
@returns {Array} | [
"finds",
"all",
"callbacks",
"that",
"match",
"based",
"on",
"the",
"keycode",
"modifiers",
"and",
"action"
] | c16d22056d1cc4e1f190bd2084af6bd241c76197 | https://github.com/substance/commander/blob/c16d22056d1cc4e1f190bd2084af6bd241c76197/src/keyboard.js#L369-L427 | train |
substance/commander | src/keyboard.js | _getReverseMap | function _getReverseMap() {
if (!this._REVERSE_MAP) {
this._REVERSE_MAP = {};
for (var key in _MAP) {
// pull out the numeric keypad from here cause keypress should
// be able to detect the keys from the character
if (key > 95 && key < 112) {
continue;
}
... | javascript | function _getReverseMap() {
if (!this._REVERSE_MAP) {
this._REVERSE_MAP = {};
for (var key in _MAP) {
// pull out the numeric keypad from here cause keypress should
// be able to detect the keys from the character
if (key > 95 && key < 112) {
continue;
}
... | [
"function",
"_getReverseMap",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_REVERSE_MAP",
")",
"{",
"this",
".",
"_REVERSE_MAP",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"_MAP",
")",
"{",
"// pull out the numeric keypad from here cause keypress shou... | reverses the map lookup so that we can look for specific keys
to see what can and can't use keypress
@return {Object} | [
"reverses",
"the",
"map",
"lookup",
"so",
"that",
"we",
"can",
"look",
"for",
"specific",
"keys",
"to",
"see",
"what",
"can",
"and",
"can",
"t",
"use",
"keypress"
] | c16d22056d1cc4e1f190bd2084af6bd241c76197 | https://github.com/substance/commander/blob/c16d22056d1cc4e1f190bd2084af6bd241c76197/src/keyboard.js#L723-L740 | train |
substance/commander | src/keyboard.js | _bindSequence | function _bindSequence(combo, keys, callback, action) {
var that = this;
// start off by adding a sequence level record for this combination
// and setting the level to 0
this._sequenceLevels[combo] = 0;
/**
* callback to increase the sequence level for this sequence and reset
* all oth... | javascript | function _bindSequence(combo, keys, callback, action) {
var that = this;
// start off by adding a sequence level record for this combination
// and setting the level to 0
this._sequenceLevels[combo] = 0;
/**
* callback to increase the sequence level for this sequence and reset
* all oth... | [
"function",
"_bindSequence",
"(",
"combo",
",",
"keys",
",",
"callback",
",",
"action",
")",
"{",
"var",
"that",
"=",
"this",
";",
"// start off by adding a sequence level record for this combination",
"// and setting the level to 0",
"this",
".",
"_sequenceLevels",
"[",
... | binds a key sequence to an event
@param {string} combo - combo specified in bind call
@param {Array} keys
@param {Function} callback
@param {string=} action
@returns void | [
"binds",
"a",
"key",
"sequence",
"to",
"an",
"event"
] | c16d22056d1cc4e1f190bd2084af6bd241c76197 | https://github.com/substance/commander/blob/c16d22056d1cc4e1f190bd2084af6bd241c76197/src/keyboard.js#L775-L834 | train |
substance/commander | src/keyboard.js | _increaseSequence | function _increaseSequence(nextAction) {
return function() {
that._nextExpectedAction = nextAction;
++that._sequenceLevels[combo];
_resetSequenceTimer.call(that);
};
} | javascript | function _increaseSequence(nextAction) {
return function() {
that._nextExpectedAction = nextAction;
++that._sequenceLevels[combo];
_resetSequenceTimer.call(that);
};
} | [
"function",
"_increaseSequence",
"(",
"nextAction",
")",
"{",
"return",
"function",
"(",
")",
"{",
"that",
".",
"_nextExpectedAction",
"=",
"nextAction",
";",
"++",
"that",
".",
"_sequenceLevels",
"[",
"combo",
"]",
";",
"_resetSequenceTimer",
".",
"call",
"("... | callback to increase the sequence level for this sequence and reset
all other sequences that were active
@param {string} nextAction
@returns {Function} | [
"callback",
"to",
"increase",
"the",
"sequence",
"level",
"for",
"this",
"sequence",
"and",
"reset",
"all",
"other",
"sequences",
"that",
"were",
"active"
] | c16d22056d1cc4e1f190bd2084af6bd241c76197 | https://github.com/substance/commander/blob/c16d22056d1cc4e1f190bd2084af6bd241c76197/src/keyboard.js#L790-L796 | train |
substance/commander | src/keyboard.js | _callbackAndReset | function _callbackAndReset(e) {
_fireCallback.call(this, callback, e, combo);
// we should ignore the next key up if the action is key down
// or keypress. this is so if you finish a sequence and
// release the key the final key will not trigger a keyup
if (action !== 'keyup') {
... | javascript | function _callbackAndReset(e) {
_fireCallback.call(this, callback, e, combo);
// we should ignore the next key up if the action is key down
// or keypress. this is so if you finish a sequence and
// release the key the final key will not trigger a keyup
if (action !== 'keyup') {
... | [
"function",
"_callbackAndReset",
"(",
"e",
")",
"{",
"_fireCallback",
".",
"call",
"(",
"this",
",",
"callback",
",",
"e",
",",
"combo",
")",
";",
"// we should ignore the next key up if the action is key down",
"// or keypress. this is so if you finish a sequence and",
"/... | wraps the specified callback inside of another function in order
to reset all sequence counters as soon as this sequence is done
@param {Event} e
@returns void | [
"wraps",
"the",
"specified",
"callback",
"inside",
"of",
"another",
"function",
"in",
"order",
"to",
"reset",
"all",
"sequence",
"counters",
"as",
"soon",
"as",
"this",
"sequence",
"is",
"done"
] | c16d22056d1cc4e1f190bd2084af6bd241c76197 | https://github.com/substance/commander/blob/c16d22056d1cc4e1f190bd2084af6bd241c76197/src/keyboard.js#L805-L818 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/lang.js | function( languageCode, defaultLanguage, callback ) {
// If no languageCode - fallback to browser or default.
// If languageCode - fallback to no-localized version or default.
if ( !languageCode || !CKEDITOR.lang.languages[ languageCode ] )
languageCode = this.detect( defaultLanguage, languageCode );
v... | javascript | function( languageCode, defaultLanguage, callback ) {
// If no languageCode - fallback to browser or default.
// If languageCode - fallback to no-localized version or default.
if ( !languageCode || !CKEDITOR.lang.languages[ languageCode ] )
languageCode = this.detect( defaultLanguage, languageCode );
v... | [
"function",
"(",
"languageCode",
",",
"defaultLanguage",
",",
"callback",
")",
"{",
"// If no languageCode - fallback to browser or default.",
"// If languageCode - fallback to no-localized version or default.",
"if",
"(",
"!",
"languageCode",
"||",
"!",
"CKEDITOR",
".",
"lang"... | Loads a specific language file, or auto detects it. A callback is
then called when the file gets loaded.
@param {String} languageCode The code of the language file to be
loaded. If null or empty, autodetection will be performed. The
same happens if the language is not supported.
@param {String} defaultLanguage The lan... | [
"Loads",
"a",
"specific",
"language",
"file",
"or",
"auto",
"detects",
"it",
".",
"A",
"callback",
"is",
"then",
"called",
"when",
"the",
"file",
"gets",
"loaded",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/lang.js#L46-L62 | train | |
georgenorman/tessel-kit | lib/log-helper.js | function(title, obj) {
if (arguments.length == 2) {
this.msg(title);
} else {
obj = title;
}
doLog(generalUtils.getProperties(obj));
} | javascript | function(title, obj) {
if (arguments.length == 2) {
this.msg(title);
} else {
obj = title;
}
doLog(generalUtils.getProperties(obj));
} | [
"function",
"(",
"title",
",",
"obj",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"==",
"2",
")",
"{",
"this",
".",
"msg",
"(",
"title",
")",
";",
"}",
"else",
"{",
"obj",
"=",
"title",
";",
"}",
"doLog",
"(",
"generalUtils",
".",
"getProper... | Logs a String, of the form "propertyName=propertyValue\n", for every property of the given obj.
@param title optional title to log above the property listing.
@param obj object to retrieve the properties from. | [
"Logs",
"a",
"String",
"of",
"the",
"form",
"propertyName",
"=",
"propertyValue",
"\\",
"n",
"for",
"every",
"property",
"of",
"the",
"given",
"obj",
"."
] | 487e91360f0ecf8500d24297228842e2c01ac762 | https://github.com/georgenorman/tessel-kit/blob/487e91360f0ecf8500d24297228842e2c01ac762/lib/log-helper.js#L111-L118 | train | |
yoshuawuyts/url-querystring | index.js | split | function split(url) {
assert.equal(typeof url, 'string', 'url-querystring: url should be a string');
var res = {};
var nw = url.split('?');
res.url = nw[0];
res.qs = nw.length == 2
? qs.parse(nw[1])
: {};
return res;
} | javascript | function split(url) {
assert.equal(typeof url, 'string', 'url-querystring: url should be a string');
var res = {};
var nw = url.split('?');
res.url = nw[0];
res.qs = nw.length == 2
? qs.parse(nw[1])
: {};
return res;
} | [
"function",
"split",
"(",
"url",
")",
"{",
"assert",
".",
"equal",
"(",
"typeof",
"url",
",",
"'string'",
",",
"'url-querystring: url should be a string'",
")",
";",
"var",
"res",
"=",
"{",
"}",
";",
"var",
"nw",
"=",
"url",
".",
"split",
"(",
"'?'",
"... | Splice a `querystring` from an `url`;
@param {String} url
@return {String}
@api public | [
"Splice",
"a",
"querystring",
"from",
"an",
"url",
";"
] | 726bbb5a2cde3e08cd0d4b0b1601d6edf5b253cf | https://github.com/yoshuawuyts/url-querystring/blob/726bbb5a2cde3e08cd0d4b0b1601d6edf5b253cf/index.js#L22-L34 | train |
intervolga/bem-utils | lib/dir-exist.js | dirExist | function dirExist(dirName) {
return new Promise((resolve, reject) => {
fs.stat(dirName, (err, stats) => {
if (err === null && stats.isDirectory()) {
resolve(dirName);
} else {
resolve(false);
}
});
});
} | javascript | function dirExist(dirName) {
return new Promise((resolve, reject) => {
fs.stat(dirName, (err, stats) => {
if (err === null && stats.isDirectory()) {
resolve(dirName);
} else {
resolve(false);
}
});
});
} | [
"function",
"dirExist",
"(",
"dirName",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"stat",
"(",
"dirName",
",",
"(",
"err",
",",
"stats",
")",
"=>",
"{",
"if",
"(",
"err",
"===",
"null",
"... | Promisified "directory exist" check
@param {String} dirName
@return {Promise} resolves to dirName if exist, false otherwise | [
"Promisified",
"directory",
"exist",
"check"
] | 3b81bb9bc408275486175326dc7f35c563a46563 | https://github.com/intervolga/bem-utils/blob/3b81bb9bc408275486175326dc7f35c563a46563/lib/dir-exist.js#L9-L19 | train |
muttr/libmuttr | lib/identity.js | Identity | function Identity(userID, passphrase, keyPair) {
if (!(this instanceof Identity)) {
return new Identity(userID, passphrase, keyPair);
}
assert(typeof userID === 'string', 'Invalid userID supplied');
assert(typeof passphrase === 'string', 'Invalid passphrase supplied');
this._publicKeyArmored = keyPair.p... | javascript | function Identity(userID, passphrase, keyPair) {
if (!(this instanceof Identity)) {
return new Identity(userID, passphrase, keyPair);
}
assert(typeof userID === 'string', 'Invalid userID supplied');
assert(typeof passphrase === 'string', 'Invalid passphrase supplied');
this._publicKeyArmored = keyPair.p... | [
"function",
"Identity",
"(",
"userID",
",",
"passphrase",
",",
"keyPair",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Identity",
")",
")",
"{",
"return",
"new",
"Identity",
"(",
"userID",
",",
"passphrase",
",",
"keyPair",
")",
";",
"}",
"ass... | An identity is represented by a PGP key pair and user ID
@constructor
@param {string} userID
@param {string} passphrase
@param {object} keyPair
@param {string} keyPair.publicKey
@param {string} keyPair.privateKey | [
"An",
"identity",
"is",
"represented",
"by",
"a",
"PGP",
"key",
"pair",
"and",
"user",
"ID"
] | 2e4fda9cb2b47b8febe30585f54196d39d79e2e5 | https://github.com/muttr/libmuttr/blob/2e4fda9cb2b47b8febe30585f54196d39d79e2e5/lib/identity.js#L22-L38 | train |
nutella-framework/nutella_lib.js | src/persist/mongo_persisted_collection.js | extend | function extend(x, y){
for(var key in y) {
if (y.hasOwnProperty(key)) {
x[key] = y[key];
}
}
return x;
} | javascript | function extend(x, y){
for(var key in y) {
if (y.hasOwnProperty(key)) {
x[key] = y[key];
}
}
return x;
} | [
"function",
"extend",
"(",
"x",
",",
"y",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"y",
")",
"{",
"if",
"(",
"y",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"x",
"[",
"key",
"]",
"=",
"y",
"[",
"key",
"]",
";",
"}",
"}",
"return",
... | Helper function used in order to extend the array | [
"Helper",
"function",
"used",
"in",
"order",
"to",
"extend",
"the",
"array"
] | b3a3406a407e2a1ada6edcc503b70991f9cb249b | https://github.com/nutella-framework/nutella_lib.js/blob/b3a3406a407e2a1ada6edcc503b70991f9cb249b/src/persist/mongo_persisted_collection.js#L10-L17 | train |
nutella-framework/nutella_lib.js | src/persist/mongo_persisted_collection.js | function(mongo_host, db, collection) {
var arrayMongo = function() {
};
arrayMongo.prototype = Array.prototype;
extend(arrayMongo.prototype, {
/**
* Store the parameters
*/
host: function() {
return mongo_host;
},
db: function() {
... | javascript | function(mongo_host, db, collection) {
var arrayMongo = function() {
};
arrayMongo.prototype = Array.prototype;
extend(arrayMongo.prototype, {
/**
* Store the parameters
*/
host: function() {
return mongo_host;
},
db: function() {
... | [
"function",
"(",
"mongo_host",
",",
"db",
",",
"collection",
")",
"{",
"var",
"arrayMongo",
"=",
"function",
"(",
")",
"{",
"}",
";",
"arrayMongo",
".",
"prototype",
"=",
"Array",
".",
"prototype",
";",
"extend",
"(",
"arrayMongo",
".",
"prototype",
",",... | Creates a new persisted array
@param mongo_host
@param db
@param collection
@return {Array} | [
"Creates",
"a",
"new",
"persisted",
"array"
] | b3a3406a407e2a1ada6edcc503b70991f9cb249b | https://github.com/nutella-framework/nutella_lib.js/blob/b3a3406a407e2a1ada6edcc503b70991f9cb249b/src/persist/mongo_persisted_collection.js#L27-L90 | train | |
sittingbool/sbool-node-utils | util/cipherUtil.js | pwCipher | function pwCipher(string) {
if(string) {
if ( typeof pw !== 'string' || pw.length < 8 ) {
throw new Error('Please set a password with 8 or ' +
'more chars on process.env.CIPHER_UTIL_PW!');
}
if ( typeof algo !== 'string' || algo.length <... | javascript | function pwCipher(string) {
if(string) {
if ( typeof pw !== 'string' || pw.length < 8 ) {
throw new Error('Please set a password with 8 or ' +
'more chars on process.env.CIPHER_UTIL_PW!');
}
if ( typeof algo !== 'string' || algo.length <... | [
"function",
"pwCipher",
"(",
"string",
")",
"{",
"if",
"(",
"string",
")",
"{",
"if",
"(",
"typeof",
"pw",
"!==",
"'string'",
"||",
"pw",
".",
"length",
"<",
"8",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please set a password with 8 or '",
"+",
"'more c... | Encrypt string with password and specified algorithm.
@param string {String} String to encrypt.
@return {String | Null} | [
"Encrypt",
"string",
"with",
"password",
"and",
"specified",
"algorithm",
"."
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/cipherUtil.js#L63-L92 | train |
sittingbool/sbool-node-utils | util/cipherUtil.js | pwDecipher | function pwDecipher(string) {
if(string) {
if ( typeof pw !== 'string' || pw.length < 8 ) {
throw new Error('Please set a password with 8 or ' +
'more chars on process.env.CIPHER_UTIL_PW!');
}
if ( typeof algo !== 'string' || algo.length... | javascript | function pwDecipher(string) {
if(string) {
if ( typeof pw !== 'string' || pw.length < 8 ) {
throw new Error('Please set a password with 8 or ' +
'more chars on process.env.CIPHER_UTIL_PW!');
}
if ( typeof algo !== 'string' || algo.length... | [
"function",
"pwDecipher",
"(",
"string",
")",
"{",
"if",
"(",
"string",
")",
"{",
"if",
"(",
"typeof",
"pw",
"!==",
"'string'",
"||",
"pw",
".",
"length",
"<",
"8",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please set a password with 8 or '",
"+",
"'more... | Decrypt string with password and specified algorithm.
@param string {String} String to decrypt.
@return {String | Null} | [
"Decrypt",
"string",
"with",
"password",
"and",
"specified",
"algorithm",
"."
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/cipherUtil.js#L190-L218 | train |
lucified/lucify-build-tools | src/bundle.js | bundle | function bundle(entryPoint, buildContext, opts) {
if (!opts) {
opts = {};
}
if (!opts.outputFileName) {
opts.outputFileName = 'index.js';
}
if (!opts.destPath) {
opts.destPath = buildContext.destPath;
}
if (opts.rev !== false) {
opts.rev = true;
}
var shouldUglify = false;
var con... | javascript | function bundle(entryPoint, buildContext, opts) {
if (!opts) {
opts = {};
}
if (!opts.outputFileName) {
opts.outputFileName = 'index.js';
}
if (!opts.destPath) {
opts.destPath = buildContext.destPath;
}
if (opts.rev !== false) {
opts.rev = true;
}
var shouldUglify = false;
var con... | [
"function",
"bundle",
"(",
"entryPoint",
",",
"buildContext",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"opts",
")",
"{",
"opts",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"opts",
".",
"outputFileName",
")",
"{",
"opts",
".",
"outputFileName",
"=",
"'i... | Create a browserify bundle according
to the given configuration
entryPoint - the entry point for the bundle
buildContext - lucify build context
opts.outputFileName - file name for produced bundle
opts.destPath - destinatino path for produced bundle | [
"Create",
"a",
"browserify",
"bundle",
"according",
"to",
"the",
"given",
"configuration"
] | 1169821ebcc4a8abaa754d060f2424fa9db0b75f | https://github.com/lucified/lucify-build-tools/blob/1169821ebcc4a8abaa754d060f2424fa9db0b75f/src/bundle.js#L30-L69 | train |
doowb/vinyl-group | index.js | is | function is(obj, name) {
if (typeof name !== 'string') {
throw new TypeError('expected name to be a string');
}
utils.define(obj, 'is' + utils.pascal(name), true);
utils.define(obj, '_name', name);
} | javascript | function is(obj, name) {
if (typeof name !== 'string') {
throw new TypeError('expected name to be a string');
}
utils.define(obj, 'is' + utils.pascal(name), true);
utils.define(obj, '_name', name);
} | [
"function",
"is",
"(",
"obj",
",",
"name",
")",
"{",
"if",
"(",
"typeof",
"name",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'expected name to be a string'",
")",
";",
"}",
"utils",
".",
"define",
"(",
"obj",
",",
"'is'",
"+",
"uti... | Set the name and type of object. | [
"Set",
"the",
"name",
"and",
"type",
"of",
"object",
"."
] | 68acd2a45e5b5dcc7a23789f7a92ce1c5551da41 | https://github.com/doowb/vinyl-group/blob/68acd2a45e5b5dcc7a23789f7a92ce1c5551da41/index.js#L75-L81 | train |
davidfig/jsdoc-template | plugins/es6-fix.js | beforeParse | function beforeParse(e)
{
var namespace = e.source.match(rgxNamespace);
var className = e.source.match(rgxClassName);
// Fix members not showing up attached to class
if (namespace && className)
{
// console.log(`${namespace[1]}.${className[2]}`);
// R... | javascript | function beforeParse(e)
{
var namespace = e.source.match(rgxNamespace);
var className = e.source.match(rgxClassName);
// Fix members not showing up attached to class
if (namespace && className)
{
// console.log(`${namespace[1]}.${className[2]}`);
// R... | [
"function",
"beforeParse",
"(",
"e",
")",
"{",
"var",
"namespace",
"=",
"e",
".",
"source",
".",
"match",
"(",
"rgxNamespace",
")",
";",
"var",
"className",
"=",
"e",
".",
"source",
".",
"match",
"(",
"rgxClassName",
")",
";",
"// Fix members not showing u... | Called before parsing a file, giving us a change to replace the source.
@param {*} e - The `beforeParse` event data.
@param {string} e.filename - The name of the file being parsed.
@param {string} e.source - The source of the file being parsed. | [
"Called",
"before",
"parsing",
"a",
"file",
"giving",
"us",
"a",
"change",
"to",
"replace",
"the",
"source",
"."
] | b54ea3af8b3368b8604f2f9a493bb169b7e24e27 | https://github.com/davidfig/jsdoc-template/blob/b54ea3af8b3368b8604f2f9a493bb169b7e24e27/plugins/es6-fix.js#L24-L38 | train |
peteromano/jetrunner | example/vendor/mocha/lib/suite.js | Suite | function Suite(title, ctx) {
this.title = title;
this.ctx = ctx;
this.suites = [];
this.tests = [];
this.pending = false;
this._beforeEach = [];
this._beforeAll = [];
this._afterEach = [];
this._afterAll = [];
this.root = !title;
this._timeout = 2000;
this._slow = 75;
this._bail = false;
} | javascript | function Suite(title, ctx) {
this.title = title;
this.ctx = ctx;
this.suites = [];
this.tests = [];
this.pending = false;
this._beforeEach = [];
this._beforeAll = [];
this._afterEach = [];
this._afterAll = [];
this.root = !title;
this._timeout = 2000;
this._slow = 75;
this._bail = false;
} | [
"function",
"Suite",
"(",
"title",
",",
"ctx",
")",
"{",
"this",
".",
"title",
"=",
"title",
";",
"this",
".",
"ctx",
"=",
"ctx",
";",
"this",
".",
"suites",
"=",
"[",
"]",
";",
"this",
".",
"tests",
"=",
"[",
"]",
";",
"this",
".",
"pending",
... | Initialize a new `Suite` with the given
`title` and `ctx`.
@param {String} title
@param {Context} ctx
@api private | [
"Initialize",
"a",
"new",
"Suite",
"with",
"the",
"given",
"title",
"and",
"ctx",
"."
] | 1882e0ee83d31fe1c799b42848c8c1357a62c995 | https://github.com/peteromano/jetrunner/blob/1882e0ee83d31fe1c799b42848c8c1357a62c995/example/vendor/mocha/lib/suite.js#L49-L63 | train |
jkroso/when-all | deep.js | unbox | function unbox(value){
if (value instanceof ResType) return when(value, unbox)
if (value && typeof value == 'object') return unboxAll(value)
return value
} | javascript | function unbox(value){
if (value instanceof ResType) return when(value, unbox)
if (value && typeof value == 'object') return unboxAll(value)
return value
} | [
"function",
"unbox",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"ResType",
")",
"return",
"when",
"(",
"value",
",",
"unbox",
")",
"if",
"(",
"value",
"&&",
"typeof",
"value",
"==",
"'object'",
")",
"return",
"unboxAll",
"(",
"value",
")... | unbox all values in `obj` recursively
@param {Object|Array} obj
@return {Result} for a new `obj` | [
"unbox",
"all",
"values",
"in",
"obj",
"recursively"
] | cbd30c361c1b8ececf7369339ce6589f03d9fdb0 | https://github.com/jkroso/when-all/blob/cbd30c361c1b8ececf7369339ce6589f03d9fdb0/deep.js#L19-L23 | train |
hoyce/passport-cas-kth | index.js | useGatewayAuthentication | function useGatewayAuthentication(req) {
// can be set on request if via application supplied callback
if (req.useGateway == true) { return true; }
// otherwise via query parameter
var origUrl = req.originalUrl;
var useGateway = false;
var idx = origUrl.indexOf(gatewayParameter);
if (idx >= 0) {
useG... | javascript | function useGatewayAuthentication(req) {
// can be set on request if via application supplied callback
if (req.useGateway == true) { return true; }
// otherwise via query parameter
var origUrl = req.originalUrl;
var useGateway = false;
var idx = origUrl.indexOf(gatewayParameter);
if (idx >= 0) {
useG... | [
"function",
"useGatewayAuthentication",
"(",
"req",
")",
"{",
"// can be set on request if via application supplied callback",
"if",
"(",
"req",
".",
"useGateway",
"==",
"true",
")",
"{",
"return",
"true",
";",
"}",
"// otherwise via query parameter",
"var",
"origUrl",
... | Check if we are requested to perform a gateway signon, i.e. a check | [
"Check",
"if",
"we",
"are",
"requested",
"to",
"perform",
"a",
"gateway",
"signon",
"i",
".",
"e",
".",
"a",
"check"
] | 56bcc5324c0332008cfde37023ed05a22bdf1eb3 | https://github.com/hoyce/passport-cas-kth/blob/56bcc5324c0332008cfde37023ed05a22bdf1eb3/index.js#L149-L162 | train |
hoyce/passport-cas-kth | index.js | stripGatewayAuthenticationParameter | function stripGatewayAuthenticationParameter(aUrl) {
if (aUrl.query && aUrl.query.useGateway) {
delete aUrl.query.useGateway;
}
if (aUrl.query.nextUrl) {
var theNextUrl = decodeURIComponent(aUrl.query.nextUrl);
aUrl.query.nextUrl = decodeURIComponent(theNextUrl);
}
var theUrl = url.format(aUrl);
... | javascript | function stripGatewayAuthenticationParameter(aUrl) {
if (aUrl.query && aUrl.query.useGateway) {
delete aUrl.query.useGateway;
}
if (aUrl.query.nextUrl) {
var theNextUrl = decodeURIComponent(aUrl.query.nextUrl);
aUrl.query.nextUrl = decodeURIComponent(theNextUrl);
}
var theUrl = url.format(aUrl);
... | [
"function",
"stripGatewayAuthenticationParameter",
"(",
"aUrl",
")",
"{",
"if",
"(",
"aUrl",
".",
"query",
"&&",
"aUrl",
".",
"query",
".",
"useGateway",
")",
"{",
"delete",
"aUrl",
".",
"query",
".",
"useGateway",
";",
"}",
"if",
"(",
"aUrl",
".",
"quer... | If a gateway query parameter is added, remove it. | [
"If",
"a",
"gateway",
"query",
"parameter",
"is",
"added",
"remove",
"it",
"."
] | 56bcc5324c0332008cfde37023ed05a22bdf1eb3 | https://github.com/hoyce/passport-cas-kth/blob/56bcc5324c0332008cfde37023ed05a22bdf1eb3/index.js#L167-L178 | train |
lucidogen/lucy-live | index.js | function ( h )
{ getData ( h, true )
.then
( function ( data )
{ if ( h.readValue == data )
{ // same. ignore
}
else
{ // console.log ( `onChangedPath ( "${h.path}" ) ` )
h.evalValue = null
h.readValue = data
// reload
let callbacks = h.callbacks
f... | javascript | function ( h )
{ getData ( h, true )
.then
( function ( data )
{ if ( h.readValue == data )
{ // same. ignore
}
else
{ // console.log ( `onChangedPath ( "${h.path}" ) ` )
h.evalValue = null
h.readValue = data
// reload
let callbacks = h.callbacks
f... | [
"function",
"(",
"h",
")",
"{",
"getData",
"(",
"h",
",",
"true",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"h",
".",
"readValue",
"==",
"data",
")",
"{",
"// same. ignore",
"}",
"else",
"{",
"// console.log ( `onChangedPath ... | If we change 'onChangedPath' to not read file content to detect file changes, we need to change the HANDLERS to use getData and adapt cache code accordingly. | [
"If",
"we",
"change",
"onChangedPath",
"to",
"not",
"read",
"file",
"content",
"to",
"detect",
"file",
"changes",
"we",
"need",
"to",
"change",
"the",
"HANDLERS",
"to",
"use",
"getData",
"and",
"adapt",
"cache",
"code",
"accordingly",
"."
] | 86924af74b23190e5753f5e1447719bb1def8151 | https://github.com/lucidogen/lucy-live/blob/86924af74b23190e5753f5e1447719bb1def8151/index.js#L89-L109 | train | |
lucidogen/lucy-live | index.js | function ( path, base )
{ let filename
let start = path.substr ( 0, 2 )
if ( path.charAt ( 0 ) === '/' )
{ // absolute path
filename = path
}
else if ( start == './' || start == '..' || path == '.' )
{ filename = lpath.resolve ( base, path )
}
else
{ // funky node_modules path not supported
t... | javascript | function ( path, base )
{ let filename
let start = path.substr ( 0, 2 )
if ( path.charAt ( 0 ) === '/' )
{ // absolute path
filename = path
}
else if ( start == './' || start == '..' || path == '.' )
{ filename = lpath.resolve ( base, path )
}
else
{ // funky node_modules path not supported
t... | [
"function",
"(",
"path",
",",
"base",
")",
"{",
"let",
"filename",
"let",
"start",
"=",
"path",
".",
"substr",
"(",
"0",
",",
"2",
")",
"if",
"(",
"path",
".",
"charAt",
"(",
"0",
")",
"===",
"'/'",
")",
"{",
"// absolute path",
"filename",
"=",
... | Used by watch. Not full resolution. | [
"Used",
"by",
"watch",
".",
"Not",
"full",
"resolution",
"."
] | 86924af74b23190e5753f5e1447719bb1def8151 | https://github.com/lucidogen/lucy-live/blob/86924af74b23190e5753f5e1447719bb1def8151/index.js#L423-L439 | train | |
lucidogen/lucy-live | index.js | function ( path, base )
{ let start = path.substr ( 0, 2 )
let paths
if ( start != './' && start != '..' )
{ // absolute or funky node_modules require
paths = module.paths
}
else
{ paths = [ base ]
}
let filename = findPath ( path, paths )
if ( !filename )
{ throw new Error ( `Cannot find path ... | javascript | function ( path, base )
{ let start = path.substr ( 0, 2 )
let paths
if ( start != './' && start != '..' )
{ // absolute or funky node_modules require
paths = module.paths
}
else
{ paths = [ base ]
}
let filename = findPath ( path, paths )
if ( !filename )
{ throw new Error ( `Cannot find path ... | [
"function",
"(",
"path",
",",
"base",
")",
"{",
"let",
"start",
"=",
"path",
".",
"substr",
"(",
"0",
",",
"2",
")",
"let",
"paths",
"if",
"(",
"start",
"!=",
"'./'",
"&&",
"start",
"!=",
"'..'",
")",
"{",
"// absolute or funky node_modules require",
"... | Used by require | [
"Used",
"by",
"require"
] | 86924af74b23190e5753f5e1447719bb1def8151 | https://github.com/lucidogen/lucy-live/blob/86924af74b23190e5753f5e1447719bb1def8151/index.js#L442-L457 | train | |
mgesmundo/authorify-client | lib/mixin/WithContent.js | function(date) {
if (_.isDate(date)) {
this._date = date.toSerialNumber();
} else if (_.isNumber(date)) {
this._date = date;
} else {
throw new CError('wrong date type').log();
}
} | javascript | function(date) {
if (_.isDate(date)) {
this._date = date.toSerialNumber();
} else if (_.isNumber(date)) {
this._date = date;
} else {
throw new CError('wrong date type').log();
}
} | [
"function",
"(",
"date",
")",
"{",
"if",
"(",
"_",
".",
"isDate",
"(",
"date",
")",
")",
"{",
"this",
".",
"_date",
"=",
"date",
".",
"toSerialNumber",
"(",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isNumber",
"(",
"date",
")",
")",
"{",
"... | Set the date
@param {Date/Integer} date The date as date or number of milliseconds. The date is anyhow saved as integer. | [
"Set",
"the",
"date"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/mixin/WithContent.js#L39-L47 | train | |
mgesmundo/authorify-client | lib/mixin/WithContent.js | function(password) {
// empty password not allowed
if (password) {
var hmac = forge.hmac.create();
hmac.start('sha256', SECRET);
hmac.update(password);
this._password = password;
this._passwordHash = hmac.digest().toHex();
}
} | javascript | function(password) {
// empty password not allowed
if (password) {
var hmac = forge.hmac.create();
hmac.start('sha256', SECRET);
hmac.update(password);
this._password = password;
this._passwordHash = hmac.digest().toHex();
}
} | [
"function",
"(",
"password",
")",
"{",
"// empty password not allowed",
"if",
"(",
"password",
")",
"{",
"var",
"hmac",
"=",
"forge",
".",
"hmac",
".",
"create",
"(",
")",
";",
"hmac",
".",
"start",
"(",
"'sha256'",
",",
"SECRET",
")",
";",
"hmac",
"."... | Set the password for interactive login
@param {String} password The password for the login | [
"Set",
"the",
"password",
"for",
"interactive",
"login"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/mixin/WithContent.js#L135-L144 | train | |
cli-kit/cli-property | lib/find.js | find | function find(key, target, opts) {
opts = opts || {};
var path = []
, o = target, i, k, p
, re = opts.re = opts.re || /\./
, parts = key.split(re);
for(i =0;i < parts.length;i++) {
k = parts[i];
p = o;
if(opts.create && o[k] === undefined) o[k] = {};
o = o[k];
path.push(k);
if(... | javascript | function find(key, target, opts) {
opts = opts || {};
var path = []
, o = target, i, k, p
, re = opts.re = opts.re || /\./
, parts = key.split(re);
for(i =0;i < parts.length;i++) {
k = parts[i];
p = o;
if(opts.create && o[k] === undefined) o[k] = {};
o = o[k];
path.push(k);
if(... | [
"function",
"find",
"(",
"key",
",",
"target",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"path",
"=",
"[",
"]",
",",
"o",
"=",
"target",
",",
"i",
",",
"k",
",",
"p",
",",
"re",
"=",
"opts",
".",
"re",
"=",
"... | Accept a string dot delimited key and attempt to lookup the
property on a target object.
Returns an object containing the fields:
1. key - The name of the property on the parent.
2. value - The property value.
3. parent - The parent object.
4. path - A string dot delimited path to the object.
@param key String dot d... | [
"Accept",
"a",
"string",
"dot",
"delimited",
"key",
"and",
"attempt",
"to",
"lookup",
"the",
"property",
"on",
"a",
"target",
"object",
"."
] | de6f727af1f8fc1f613fe42200c5e070aa6b0b21 | https://github.com/cli-kit/cli-property/blob/de6f727af1f8fc1f613fe42200c5e070aa6b0b21/lib/find.js#L20-L35 | train |
hitchyjs/odem | lib/utility/string.js | camelToSnake | function camelToSnake( string ) {
return string.replace( ptnCamel, ( all, predecessor, match ) => predecessor + "_" + match.toLocaleLowerCase() );
} | javascript | function camelToSnake( string ) {
return string.replace( ptnCamel, ( all, predecessor, match ) => predecessor + "_" + match.toLocaleLowerCase() );
} | [
"function",
"camelToSnake",
"(",
"string",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"ptnCamel",
",",
"(",
"all",
",",
"predecessor",
",",
"match",
")",
"=>",
"predecessor",
"+",
"\"_\"",
"+",
"match",
".",
"toLocaleLowerCase",
"(",
")",
")",
";... | Converts string from camelCase to snake_case.
@param {string} string string to convert
@returns {string} converted string | [
"Converts",
"string",
"from",
"camelCase",
"to",
"snake_case",
"."
] | 28f3dc31cc3314f9109d2cac1f5f7e20dad6521b | https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/lib/utility/string.js#L40-L42 | train |
hitchyjs/odem | lib/utility/string.js | camelToKebab | function camelToKebab( string ) {
return string.replace( ptnCamel, ( all, predecessor, match ) => predecessor + "-" + match.toLocaleLowerCase() );
} | javascript | function camelToKebab( string ) {
return string.replace( ptnCamel, ( all, predecessor, match ) => predecessor + "-" + match.toLocaleLowerCase() );
} | [
"function",
"camelToKebab",
"(",
"string",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"ptnCamel",
",",
"(",
"all",
",",
"predecessor",
",",
"match",
")",
"=>",
"predecessor",
"+",
"\"-\"",
"+",
"match",
".",
"toLocaleLowerCase",
"(",
")",
")",
";... | Converts string from camelCase to kebab-case.
@param {string} string string to convert
@returns {string} converted string | [
"Converts",
"string",
"from",
"camelCase",
"to",
"kebab",
"-",
"case",
"."
] | 28f3dc31cc3314f9109d2cac1f5f7e20dad6521b | https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/lib/utility/string.js#L50-L52 | train |
hitchyjs/odem | lib/utility/string.js | snakeToCamel | function snakeToCamel( string ) {
return string.replace( ptnSnake, ( all, predecessor, match ) => predecessor + match.toLocaleUpperCase() );
} | javascript | function snakeToCamel( string ) {
return string.replace( ptnSnake, ( all, predecessor, match ) => predecessor + match.toLocaleUpperCase() );
} | [
"function",
"snakeToCamel",
"(",
"string",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"ptnSnake",
",",
"(",
"all",
",",
"predecessor",
",",
"match",
")",
"=>",
"predecessor",
"+",
"match",
".",
"toLocaleUpperCase",
"(",
")",
")",
";",
"}"
] | Converts string from snake_case to camelCase.
@param {string} string string to convert
@returns {string} converted string | [
"Converts",
"string",
"from",
"snake_case",
"to",
"camelCase",
"."
] | 28f3dc31cc3314f9109d2cac1f5f7e20dad6521b | https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/lib/utility/string.js#L60-L62 | train |
hitchyjs/odem | lib/utility/string.js | snakeToKebab | function snakeToKebab( string ) {
return string.replace( ptnSnake, ( all, predecessor, match ) => predecessor + "-" + match );
} | javascript | function snakeToKebab( string ) {
return string.replace( ptnSnake, ( all, predecessor, match ) => predecessor + "-" + match );
} | [
"function",
"snakeToKebab",
"(",
"string",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"ptnSnake",
",",
"(",
"all",
",",
"predecessor",
",",
"match",
")",
"=>",
"predecessor",
"+",
"\"-\"",
"+",
"match",
")",
";",
"}"
] | Converts string from snake_case to kebab-case.
@param {string} string string to convert
@returns {string} converted string | [
"Converts",
"string",
"from",
"snake_case",
"to",
"kebab",
"-",
"case",
"."
] | 28f3dc31cc3314f9109d2cac1f5f7e20dad6521b | https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/lib/utility/string.js#L70-L72 | train |
hitchyjs/odem | lib/utility/string.js | kebabToCamel | function kebabToCamel( string ) {
return string.replace( ptnKebab, ( all, predecessor, match ) => predecessor + match.toLocaleUpperCase() );
} | javascript | function kebabToCamel( string ) {
return string.replace( ptnKebab, ( all, predecessor, match ) => predecessor + match.toLocaleUpperCase() );
} | [
"function",
"kebabToCamel",
"(",
"string",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"ptnKebab",
",",
"(",
"all",
",",
"predecessor",
",",
"match",
")",
"=>",
"predecessor",
"+",
"match",
".",
"toLocaleUpperCase",
"(",
")",
")",
";",
"}"
] | Converts string from kebab-case to camelCase.
@param {string} string string to convert
@returns {string} converted string | [
"Converts",
"string",
"from",
"kebab",
"-",
"case",
"to",
"camelCase",
"."
] | 28f3dc31cc3314f9109d2cac1f5f7e20dad6521b | https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/lib/utility/string.js#L80-L82 | train |
hitchyjs/odem | lib/utility/string.js | kebabToPascal | function kebabToPascal( string ) {
const camel = kebabToCamel( string );
return camel.slice( 0, 1 ).toUpperCase() + camel.slice( 1 );
} | javascript | function kebabToPascal( string ) {
const camel = kebabToCamel( string );
return camel.slice( 0, 1 ).toUpperCase() + camel.slice( 1 );
} | [
"function",
"kebabToPascal",
"(",
"string",
")",
"{",
"const",
"camel",
"=",
"kebabToCamel",
"(",
"string",
")",
";",
"return",
"camel",
".",
"slice",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"camel",
".",
"slice",
"(",
"1",
")",
... | Converts string from kebab-case to PascalCase.
@param {string} string string to convert
@returns {string} converted string | [
"Converts",
"string",
"from",
"kebab",
"-",
"case",
"to",
"PascalCase",
"."
] | 28f3dc31cc3314f9109d2cac1f5f7e20dad6521b | https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/lib/utility/string.js#L90-L94 | train |
hitchyjs/odem | lib/utility/string.js | kebabToSnake | function kebabToSnake( string ) {
return string.replace( ptnKebab, ( all, predecessor, match ) => predecessor + "_" + match );
} | javascript | function kebabToSnake( string ) {
return string.replace( ptnKebab, ( all, predecessor, match ) => predecessor + "_" + match );
} | [
"function",
"kebabToSnake",
"(",
"string",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"ptnKebab",
",",
"(",
"all",
",",
"predecessor",
",",
"match",
")",
"=>",
"predecessor",
"+",
"\"_\"",
"+",
"match",
")",
";",
"}"
] | Converts string from kebab-case to snake_case.
@param {string} string string to convert
@returns {string} converted string | [
"Converts",
"string",
"from",
"kebab",
"-",
"case",
"to",
"snake_case",
"."
] | 28f3dc31cc3314f9109d2cac1f5f7e20dad6521b | https://github.com/hitchyjs/odem/blob/28f3dc31cc3314f9109d2cac1f5f7e20dad6521b/lib/utility/string.js#L102-L104 | train |
TribeMedia/tribemedia-kurento-client-core | lib/complexTypes/CodecConfiguration.js | CodecConfiguration | function CodecConfiguration(codecConfigurationDict){
if(!(this instanceof CodecConfiguration))
return new CodecConfiguration(codecConfigurationDict)
// Check codecConfigurationDict has the required fields
checkType('String', 'codecConfigurationDict.name', codecConfigurationDict.name, {required: true});
che... | javascript | function CodecConfiguration(codecConfigurationDict){
if(!(this instanceof CodecConfiguration))
return new CodecConfiguration(codecConfigurationDict)
// Check codecConfigurationDict has the required fields
checkType('String', 'codecConfigurationDict.name', codecConfigurationDict.name, {required: true});
che... | [
"function",
"CodecConfiguration",
"(",
"codecConfigurationDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"CodecConfiguration",
")",
")",
"return",
"new",
"CodecConfiguration",
"(",
"codecConfigurationDict",
")",
"// Check codecConfigurationDict has the required... | Defines specific configuration for codecs
@constructor module:core/complexTypes.CodecConfiguration
@property {external:String} name
Name of the codec defined as <encoding name>/<clock rate>[/<encoding
parameters>]
@property {external:String} properties
String used for tuning codec properties | [
"Defines",
"specific",
"configuration",
"for",
"codecs"
] | de4c0094644aae91320e330f9cea418a3ac55468 | https://github.com/TribeMedia/tribemedia-kurento-client-core/blob/de4c0094644aae91320e330f9cea418a3ac55468/lib/complexTypes/CodecConfiguration.js#L38-L62 | train |
AndreasMadsen/drugged | handlers/default.js | DefaultHandle | function DefaultHandle(done, req, res, parsedUrl) {
this.res = res;
this.res.once('error', this.error.bind(this));
this.req = req;
this.req.once('error', this.error.bind(this));
this.url = parsedUrl;
// If this is the actual constructor call done now
if (this.constructor === DefaultHandle) done(null);
} | javascript | function DefaultHandle(done, req, res, parsedUrl) {
this.res = res;
this.res.once('error', this.error.bind(this));
this.req = req;
this.req.once('error', this.error.bind(this));
this.url = parsedUrl;
// If this is the actual constructor call done now
if (this.constructor === DefaultHandle) done(null);
} | [
"function",
"DefaultHandle",
"(",
"done",
",",
"req",
",",
"res",
",",
"parsedUrl",
")",
"{",
"this",
".",
"res",
"=",
"res",
";",
"this",
".",
"res",
".",
"once",
"(",
"'error'",
",",
"this",
".",
"error",
".",
"bind",
"(",
"this",
")",
")",
";"... | Supper simple request container | [
"Supper",
"simple",
"request",
"container"
] | 2ba5e9a9e87dd43a6754f711a125da13c58da68b | https://github.com/AndreasMadsen/drugged/blob/2ba5e9a9e87dd43a6754f711a125da13c58da68b/handlers/default.js#L4-L13 | train |
tmpvar/varargs | varargs.js | varargs | function varargs(args) {
var argl = args.length;
var arga;
if (!Array.isArray(args)) {
arga = new Array(argl);
for (var i = 0; i < argl; i++) {
arga[i] = args[i];
}
}
return arga;
} | javascript | function varargs(args) {
var argl = args.length;
var arga;
if (!Array.isArray(args)) {
arga = new Array(argl);
for (var i = 0; i < argl; i++) {
arga[i] = args[i];
}
}
return arga;
} | [
"function",
"varargs",
"(",
"args",
")",
"{",
"var",
"argl",
"=",
"args",
".",
"length",
";",
"var",
"arga",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"args",
")",
")",
"{",
"arga",
"=",
"new",
"Array",
"(",
"argl",
")",
";",
"for",
"(... | args is an 'arguments' object | [
"args",
"is",
"an",
"arguments",
"object"
] | 27ff831850302bb41bde6b34eba940094eca6730 | https://github.com/tmpvar/varargs/blob/27ff831850302bb41bde6b34eba940094eca6730/varargs.js#L4-L17 | train |
MrRaindrop/cubicbezier | build/cubicbezier.debug.js | solveCurveX | function solveCurveX(x) {
var t2 = x,
derivative,
x2;
// https://trac.webkit.org/browser/trunk/Source/WebCore/platform/animation
// First try a few iterations of Newton's method -- normally very fast.
// http://en.wikipedia.org/wiki/Newton's_method
for (v... | javascript | function solveCurveX(x) {
var t2 = x,
derivative,
x2;
// https://trac.webkit.org/browser/trunk/Source/WebCore/platform/animation
// First try a few iterations of Newton's method -- normally very fast.
// http://en.wikipedia.org/wiki/Newton's_method
for (v... | [
"function",
"solveCurveX",
"(",
"x",
")",
"{",
"var",
"t2",
"=",
"x",
",",
"derivative",
",",
"x2",
";",
"// https://trac.webkit.org/browser/trunk/Source/WebCore/platform/animation",
"// First try a few iterations of Newton's method -- normally very fast.",
"// http://en.wikipedia.... | Given an x value, find a parametric value it came from. | [
"Given",
"an",
"x",
"value",
"find",
"a",
"parametric",
"value",
"it",
"came",
"from",
"."
] | 4d70f21a8890799aef1bcd7165f2dce50efe3221 | https://github.com/MrRaindrop/cubicbezier/blob/4d70f21a8890799aef1bcd7165f2dce50efe3221/build/cubicbezier.debug.js#L29-L72 | train |
AndreasMadsen/immortal | lib/monitor.js | function (name) {
return function (state) {
// Write to output stream
var time = new Date();
self.write(messages[name][state].replace('{pid}', self.pid[name]));
self.write('=== Time: ' + time.toString());
};
} | javascript | function (name) {
return function (state) {
// Write to output stream
var time = new Date();
self.write(messages[name][state].replace('{pid}', self.pid[name]));
self.write('=== Time: ' + time.toString());
};
} | [
"function",
"(",
"name",
")",
"{",
"return",
"function",
"(",
"state",
")",
"{",
"// Write to output stream",
"var",
"time",
"=",
"new",
"Date",
"(",
")",
";",
"self",
".",
"write",
"(",
"messages",
"[",
"name",
"]",
"[",
"state",
"]",
".",
"replace",
... | will write the message given in the message object and write the current time and date. | [
"will",
"write",
"the",
"message",
"given",
"in",
"the",
"message",
"object",
"and",
"write",
"the",
"current",
"time",
"and",
"date",
"."
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/monitor.js#L84-L91 | train | |
ltoussaint/node-bootstrap-core | routers/exactPath.js | ExactPath | function ExactPath() {
/**
* Uri to action::method mapping
* @type {Object}
*/
var mapping = {};
/**
* Resolve uri
* @param request
* @returns {*}
*/
this.resolve = function (request) {
var uri = request.url.split('?')[0];
if (mapping[request.method] && mapping[request.method][ur... | javascript | function ExactPath() {
/**
* Uri to action::method mapping
* @type {Object}
*/
var mapping = {};
/**
* Resolve uri
* @param request
* @returns {*}
*/
this.resolve = function (request) {
var uri = request.url.split('?')[0];
if (mapping[request.method] && mapping[request.method][ur... | [
"function",
"ExactPath",
"(",
")",
"{",
"/**\n * Uri to action::method mapping\n * @type {Object}\n */",
"var",
"mapping",
"=",
"{",
"}",
";",
"/**\n * Resolve uri\n * @param request\n * @returns {*}\n */",
"this",
".",
"resolve",
"=",
"function",
"(",
"request",
... | Simple router which will map exact url pathname to a callback
@returns {ExactPath}
@constructor | [
"Simple",
"router",
"which",
"will",
"map",
"exact",
"url",
"pathname",
"to",
"a",
"callback"
] | b083b320900ed068007e58af2249825b8da24c79 | https://github.com/ltoussaint/node-bootstrap-core/blob/b083b320900ed068007e58af2249825b8da24c79/routers/exactPath.js#L8-L107 | train |
MoNoApps/uf | utils/zugmaschine.js | function(config){
this.options = {
hostname : config.url,
port : 443,
path : '', //override
method : '', //override
auth : config.user + ':' + config.passwd,
headers : config.headers
};
} | javascript | function(config){
this.options = {
hostname : config.url,
port : 443,
path : '', //override
method : '', //override
auth : config.user + ':' + config.passwd,
headers : config.headers
};
} | [
"function",
"(",
"config",
")",
"{",
"this",
".",
"options",
"=",
"{",
"hostname",
":",
"config",
".",
"url",
",",
"port",
":",
"443",
",",
"path",
":",
"''",
",",
"//override",
"method",
":",
"''",
",",
"//override",
"auth",
":",
"config",
".",
"u... | The Tracktor object.
This object uses https and send the request to unfuddle API. | [
"The",
"Tracktor",
"object",
".",
"This",
"object",
"uses",
"https",
"and",
"send",
"the",
"request",
"to",
"unfuddle",
"API",
"."
] | cc65386de47acce4aa6fc44ef18219d03944f6c3 | https://github.com/MoNoApps/uf/blob/cc65386de47acce4aa6fc44ef18219d03944f6c3/utils/zugmaschine.js#L7-L16 | train | |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/wireprotocol/3_2_support.js | decorateWithSessionsData | function decorateWithSessionsData(command, session, options) {
if (!session) {
return;
}
// first apply non-transaction-specific sessions data
const serverSession = session.serverSession;
const inTransaction = session.inTransaction() || isTransactionCommand(command);
const isRetryableWrite = options.wi... | javascript | function decorateWithSessionsData(command, session, options) {
if (!session) {
return;
}
// first apply non-transaction-specific sessions data
const serverSession = session.serverSession;
const inTransaction = session.inTransaction() || isTransactionCommand(command);
const isRetryableWrite = options.wi... | [
"function",
"decorateWithSessionsData",
"(",
"command",
",",
"session",
",",
"options",
")",
"{",
"if",
"(",
"!",
"session",
")",
"{",
"return",
";",
"}",
"// first apply non-transaction-specific sessions data",
"const",
"serverSession",
"=",
"session",
".",
"server... | Optionally decorate a command with sessions specific keys
@param {Object} command the command to decorate
@param {ClientSession} session the session tracking transaction state
@param {Object} [options] Optional settings passed to calling operation
@param {Function} [callback] Optional callback passed from calling oper... | [
"Optionally",
"decorate",
"a",
"command",
"with",
"sessions",
"specific",
"keys"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/wireprotocol/3_2_support.js#L28-L81 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/wireprotocol/3_2_support.js | executeWrite | function executeWrite(pool, bson, type, opsField, ns, ops, options, callback) {
if (ops.length === 0) throw new MongoError('insert must contain at least one document');
if (typeof options === 'function') {
callback = options;
options = {};
options = options || {};
}
// Split the ns up to get db and... | javascript | function executeWrite(pool, bson, type, opsField, ns, ops, options, callback) {
if (ops.length === 0) throw new MongoError('insert must contain at least one document');
if (typeof options === 'function') {
callback = options;
options = {};
options = options || {};
}
// Split the ns up to get db and... | [
"function",
"executeWrite",
"(",
"pool",
",",
"bson",
",",
"type",
",",
"opsField",
",",
"ns",
",",
"ops",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"ops",
".",
"length",
"===",
"0",
")",
"throw",
"new",
"MongoError",
"(",
"'insert must con... | Execute a write operation | [
"Execute",
"a",
"write",
"operation"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/wireprotocol/3_2_support.js#L85-L151 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/wireprotocol/3_2_support.js | killCursorCallback | function killCursorCallback(err, result) {
if (err) {
if (typeof callback !== 'function') return;
return callback(err);
}
// Result
const r = result.message;
// If we have a timed out query or a cursor that was killed
if ((r.responseFlags & (1 << 0)) !== 0) {
if (typeof callba... | javascript | function killCursorCallback(err, result) {
if (err) {
if (typeof callback !== 'function') return;
return callback(err);
}
// Result
const r = result.message;
// If we have a timed out query or a cursor that was killed
if ((r.responseFlags & (1 << 0)) !== 0) {
if (typeof callba... | [
"function",
"killCursorCallback",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"typeof",
"callback",
"!==",
"'function'",
")",
"return",
";",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"// Result",
"const",
"r",
"="... | Kill cursor callback | [
"Kill",
"cursor",
"callback"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/wireprotocol/3_2_support.js#L190-L215 | train |
tdeekens/grunt-voguesy | tasks/voguesy.js | function(dependencies) {
var _dependencies = dependencies || {};
var _numberOfOudatedPackages = Object.keys(_dependencies).length;
var _minor = semver.allMinor(dependencies, 'latest');
var _major = semver.allMajor(dependencies, 'latest');
var _patch = semver.allPatch(dependencies... | javascript | function(dependencies) {
var _dependencies = dependencies || {};
var _numberOfOudatedPackages = Object.keys(_dependencies).length;
var _minor = semver.allMinor(dependencies, 'latest');
var _major = semver.allMajor(dependencies, 'latest');
var _patch = semver.allPatch(dependencies... | [
"function",
"(",
"dependencies",
")",
"{",
"var",
"_dependencies",
"=",
"dependencies",
"||",
"{",
"}",
";",
"var",
"_numberOfOudatedPackages",
"=",
"Object",
".",
"keys",
"(",
"_dependencies",
")",
".",
"length",
";",
"var",
"_minor",
"=",
"semver",
".",
... | Helper function to avoid code repetition | [
"Helper",
"function",
"to",
"avoid",
"code",
"repetition"
] | 914eb487385bf76c1fa5105a3ef8c98d9cce2263 | https://github.com/tdeekens/grunt-voguesy/blob/914eb487385bf76c1fa5105a3ef8c98d9cce2263/tasks/voguesy.js#L45-L62 | train | |
m3co/router3 | src/router3.js | resolve_ | function resolve_(element, resolve) {
// if element is a fragment, it will load everything
// up to child element
if (element.MaterialFragment) {
element.MaterialFragment.loaded.then(() => {
slice.call(element.querySelectorAll(selClass))
.forEach(element => componentHandler.upgradeEl... | javascript | function resolve_(element, resolve) {
// if element is a fragment, it will load everything
// up to child element
if (element.MaterialFragment) {
element.MaterialFragment.loaded.then(() => {
slice.call(element.querySelectorAll(selClass))
.forEach(element => componentHandler.upgradeEl... | [
"function",
"resolve_",
"(",
"element",
",",
"resolve",
")",
"{",
"// if element is a fragment, it will load everything",
"// up to child element",
"if",
"(",
"element",
".",
"MaterialFragment",
")",
"{",
"element",
".",
"MaterialFragment",
".",
"loaded",
".",
"then",
... | Resolve and upgrade any router element present in element
@param {HTMLElement} element - The element to upgrade/resolve.
@param {Function} resolve - The function to resolve the Promise.
@private | [
"Resolve",
"and",
"upgrade",
"any",
"router",
"element",
"present",
"in",
"element"
] | 8d148bfce50fe7aff4a0952298e0ade50184c1f7 | https://github.com/m3co/router3/blob/8d148bfce50fe7aff4a0952298e0ade50184c1f7/src/router3.js#L54-L66 | train |
m3co/router3 | src/router3.js | hashchange_ | function hashchange_(e) {
if (counterLastMatch > 1) {
counterLastMatch = 0;
throw new Error(`Cannot go back to last matched hash ${e.oldURL}`);
}
// Look for all router3 elements in order
Promise.all(slice
.call(document.querySelectorAll(selClass))
.map(element => {
/**
... | javascript | function hashchange_(e) {
if (counterLastMatch > 1) {
counterLastMatch = 0;
throw new Error(`Cannot go back to last matched hash ${e.oldURL}`);
}
// Look for all router3 elements in order
Promise.all(slice
.call(document.querySelectorAll(selClass))
.map(element => {
/**
... | [
"function",
"hashchange_",
"(",
"e",
")",
"{",
"if",
"(",
"counterLastMatch",
">",
"1",
")",
"{",
"counterLastMatch",
"=",
"0",
";",
"throw",
"new",
"Error",
"(",
"`",
"${",
"e",
".",
"oldURL",
"}",
"`",
")",
";",
"}",
"// Look for all router3 elements i... | Hash Change handler that also is executed when
load event has been dispatched
@private | [
"Hash",
"Change",
"handler",
"that",
"also",
"is",
"executed",
"when",
"load",
"event",
"has",
"been",
"dispatched"
] | 8d148bfce50fe7aff4a0952298e0ade50184c1f7 | https://github.com/m3co/router3/blob/8d148bfce50fe7aff4a0952298e0ade50184c1f7/src/router3.js#L74-L123 | train |
m3co/router3 | src/router3.js | hide_ | function hide_(element) {
if (!element.hidden) {
element.hidden = true;
element.style.visibility = 'hidden';
element.style.height = '0px';
element.style.width = '0px';
/**
* Dispatch hide event if URL's fragment matches with a route
* and router.hidden = true
*
... | javascript | function hide_(element) {
if (!element.hidden) {
element.hidden = true;
element.style.visibility = 'hidden';
element.style.height = '0px';
element.style.width = '0px';
/**
* Dispatch hide event if URL's fragment matches with a route
* and router.hidden = true
*
... | [
"function",
"hide_",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
".",
"hidden",
")",
"{",
"element",
".",
"hidden",
"=",
"true",
";",
"element",
".",
"style",
".",
"visibility",
"=",
"'hidden'",
";",
"element",
".",
"style",
".",
"height",
"... | Hide element and dispatch hide event
@param {HTMLElement} element - The element
@private | [
"Hide",
"element",
"and",
"dispatch",
"hide",
"event"
] | 8d148bfce50fe7aff4a0952298e0ade50184c1f7 | https://github.com/m3co/router3/blob/8d148bfce50fe7aff4a0952298e0ade50184c1f7/src/router3.js#L196-L219 | train |
m3co/router3 | src/router3.js | dispatchShow_ | function dispatchShow_(element, detail) {
/**
* Dispatch show event if URL's fragment matches with a route
*
* @event MaterialRouter3#show
* @type {CustomEvent}
* @property {HTMLElement} router - The router that dispatches
* this event
* @property {String} param1
* @proper... | javascript | function dispatchShow_(element, detail) {
/**
* Dispatch show event if URL's fragment matches with a route
*
* @event MaterialRouter3#show
* @type {CustomEvent}
* @property {HTMLElement} router - The router that dispatches
* this event
* @property {String} param1
* @proper... | [
"function",
"dispatchShow_",
"(",
"element",
",",
"detail",
")",
"{",
"/**\n * Dispatch show event if URL's fragment matches with a route\n *\n * @event MaterialRouter3#show\n * @type {CustomEvent}\n * @property {HTMLElement} router - The router that dispatches\n * this eve... | Dispatch show event
@param {HTMLElement} element - The element
@param {Object} detail - The extracted params
@private | [
"Dispatch",
"show",
"event"
] | 8d148bfce50fe7aff4a0952298e0ade50184c1f7 | https://github.com/m3co/router3/blob/8d148bfce50fe7aff4a0952298e0ade50184c1f7/src/router3.js#L228-L248 | train |
m3co/router3 | src/router3.js | unhide_ | function unhide_(element) {
if (element.hidden) {
element.hidden = false;
element.style.visibility = 'visible';
element.style.height = null;
element.style.width = null;
/**
* Dispatch unhide even if URL's fragment matches with a route
* and router.hidden = false
*... | javascript | function unhide_(element) {
if (element.hidden) {
element.hidden = false;
element.style.visibility = 'visible';
element.style.height = null;
element.style.width = null;
/**
* Dispatch unhide even if URL's fragment matches with a route
* and router.hidden = false
*... | [
"function",
"unhide_",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"hidden",
")",
"{",
"element",
".",
"hidden",
"=",
"false",
";",
"element",
".",
"style",
".",
"visibility",
"=",
"'visible'",
";",
"element",
".",
"style",
".",
"height",
"=",... | Unhide element and dispatch unhide event
@param {HTMLElement} element - The element
@private | [
"Unhide",
"element",
"and",
"dispatch",
"unhide",
"event"
] | 8d148bfce50fe7aff4a0952298e0ade50184c1f7 | https://github.com/m3co/router3/blob/8d148bfce50fe7aff4a0952298e0ade50184c1f7/src/router3.js#L256-L279 | train |
m3co/router3 | src/router3.js | match_ | function match_(newHash, parents, hashes) {
parents.push(parents[hashes.length].parentElement.closest(selClass));
hashes.push(parents[hashes.length].getAttribute('hash'));
if (parents[hashes.length]) {
return match_(newHash, parents, hashes);
} else {
return hashes.slice(0, hashes.length).r... | javascript | function match_(newHash, parents, hashes) {
parents.push(parents[hashes.length].parentElement.closest(selClass));
hashes.push(parents[hashes.length].getAttribute('hash'));
if (parents[hashes.length]) {
return match_(newHash, parents, hashes);
} else {
return hashes.slice(0, hashes.length).r... | [
"function",
"match_",
"(",
"newHash",
",",
"parents",
",",
"hashes",
")",
"{",
"parents",
".",
"push",
"(",
"parents",
"[",
"hashes",
".",
"length",
"]",
".",
"parentElement",
".",
"closest",
"(",
"selClass",
")",
")",
";",
"hashes",
".",
"push",
"(",
... | Match to chain-hash
@param {String} newHash - The new hash to navigate
@param {Array} parents - The array of pushed parents
@param {Array} hashes - The array of pushed hashes
@private | [
"Match",
"to",
"chain",
"-",
"hash"
] | 8d148bfce50fe7aff4a0952298e0ade50184c1f7 | https://github.com/m3co/router3/blob/8d148bfce50fe7aff4a0952298e0ade50184c1f7/src/router3.js#L289-L298 | train |
muttr/libmuttr | lib/client.js | Client | function Client(identity) {
if (!(this instanceof Client)) {
return new Client(identity);
}
assert(identity instanceof Identity, 'Invalid identity supplied');
this._identity = identity;
this._podhost = utils.getPodHostFromUserID(this._identity.userID);
this._baseUrl = 'https://' + this._podhost;
thi... | javascript | function Client(identity) {
if (!(this instanceof Client)) {
return new Client(identity);
}
assert(identity instanceof Identity, 'Invalid identity supplied');
this._identity = identity;
this._podhost = utils.getPodHostFromUserID(this._identity.userID);
this._baseUrl = 'https://' + this._podhost;
thi... | [
"function",
"Client",
"(",
"identity",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Client",
")",
")",
"{",
"return",
"new",
"Client",
"(",
"identity",
")",
";",
"}",
"assert",
"(",
"identity",
"instanceof",
"Identity",
",",
"'Invalid identity sup... | HTTPS API Client for MuttrPods
@constructor
@param {object} identity | [
"HTTPS",
"API",
"Client",
"for",
"MuttrPods"
] | 2e4fda9cb2b47b8febe30585f54196d39d79e2e5 | https://github.com/muttr/libmuttr/blob/2e4fda9cb2b47b8febe30585f54196d39d79e2e5/lib/client.js#L25-L36 | train |
Gozala/signalize | core.js | ender | function ender(input) {
return signal(function(next) {
var pending = 0
var state = null
return spawn(input, function(item) {
state = item === START ? (pending = pending + 1,
state) :
item === END ? (pending = pending - 1,
pe... | javascript | function ender(input) {
return signal(function(next) {
var pending = 0
var state = null
return spawn(input, function(item) {
state = item === START ? (pending = pending + 1,
state) :
item === END ? (pending = pending - 1,
pe... | [
"function",
"ender",
"(",
"input",
")",
"{",
"return",
"signal",
"(",
"function",
"(",
"next",
")",
"{",
"var",
"pending",
"=",
"0",
"var",
"state",
"=",
"null",
"return",
"spawn",
"(",
"input",
",",
"function",
"(",
"item",
")",
"{",
"state",
"=",
... | Takes input that represents groups wrapped in `START` and `END` items and returns input that contains all items, but `START` & `END` except the last `END`. | [
"Takes",
"input",
"that",
"represents",
"groups",
"wrapped",
"in",
"START",
"and",
"END",
"items",
"and",
"returns",
"input",
"that",
"contains",
"all",
"items",
"but",
"START",
"&",
"END",
"except",
"the",
"last",
"END",
"."
] | 4fcde5d5580b157425045fe32ab09c62f213522b | https://github.com/Gozala/signalize/blob/4fcde5d5580b157425045fe32ab09c62f213522b/core.js#L330-L343 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/collection_ops.js | bulkWrite | function bulkWrite(coll, operations, options, callback) {
// Add ignoreUndfined
if (coll.s.options.ignoreUndefined) {
options = Object.assign({}, options);
options.ignoreUndefined = coll.s.options.ignoreUndefined;
}
// Create the bulk operation
const bulk =
options.ordered === true || options.ord... | javascript | function bulkWrite(coll, operations, options, callback) {
// Add ignoreUndfined
if (coll.s.options.ignoreUndefined) {
options = Object.assign({}, options);
options.ignoreUndefined = coll.s.options.ignoreUndefined;
}
// Create the bulk operation
const bulk =
options.ordered === true || options.ord... | [
"function",
"bulkWrite",
"(",
"coll",
",",
"operations",
",",
"options",
",",
"callback",
")",
"{",
"// Add ignoreUndfined",
"if",
"(",
"coll",
".",
"s",
".",
"options",
".",
"ignoreUndefined",
")",
"{",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
... | Perform a bulkWrite operation. See Collection.prototype.bulkWrite for more information.
@method
@param {Collection} a Collection instance.
@param {object[]} operations Bulk operations to perform.
@param {object} [options] Optional settings. See Collection.prototype.bulkWrite for a list of options.
@param {Collection~b... | [
"Perform",
"a",
"bulkWrite",
"operation",
".",
"See",
"Collection",
".",
"prototype",
".",
"bulkWrite",
"for",
"more",
"information",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/collection_ops.js#L68-L149 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/operations/collection_ops.js | rename | function rename(coll, newName, options, callback) {
const Collection = require('../collection');
// Check the collection name
checkCollectionName(newName);
// Build the command
const renameCollection = `${coll.s.dbName}.${coll.s.name}`;
const toCollection = `${coll.s.dbName}.${newName}`;
const dropTarget ... | javascript | function rename(coll, newName, options, callback) {
const Collection = require('../collection');
// Check the collection name
checkCollectionName(newName);
// Build the command
const renameCollection = `${coll.s.dbName}.${coll.s.name}`;
const toCollection = `${coll.s.dbName}.${newName}`;
const dropTarget ... | [
"function",
"rename",
"(",
"coll",
",",
"newName",
",",
"options",
",",
"callback",
")",
"{",
"const",
"Collection",
"=",
"require",
"(",
"'../collection'",
")",
";",
"// Check the collection name",
"checkCollectionName",
"(",
"newName",
")",
";",
"// Build the co... | Rename the collection.
@method
@param {Collection} a Collection instance.
@param {string} newName New name of of the collection.
@param {object} [options] Optional settings. See Collection.prototype.rename for a list of options.
@param {Collection~collectionResultCallback} [callback] The results callback | [
"Rename",
"the",
"collection",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/operations/collection_ops.js#L1206-L1241 | train |
smbape/node-sem-lib | lib/sem-lib.js | toPositiveInt | function toPositiveInt(num, _default) {
if (isNumeric(num)) {
num = parseInt(num, 10);
} else {
return _default;
}
if (num < 0) {
return _default;
}
return num;
} | javascript | function toPositiveInt(num, _default) {
if (isNumeric(num)) {
num = parseInt(num, 10);
} else {
return _default;
}
if (num < 0) {
return _default;
}
return num;
} | [
"function",
"toPositiveInt",
"(",
"num",
",",
"_default",
")",
"{",
"if",
"(",
"isNumeric",
"(",
"num",
")",
")",
"{",
"num",
"=",
"parseInt",
"(",
"num",
",",
"10",
")",
";",
"}",
"else",
"{",
"return",
"_default",
";",
"}",
"if",
"(",
"num",
"<... | Value of parsed interger or default value if not a number or < 0
@param {Any} num value to parse
@param {Interger} _default default value
@return {Interger} parsing result | [
"Value",
"of",
"parsed",
"interger",
"or",
"default",
"value",
"if",
"not",
"a",
"number",
"or",
"<",
"0"
] | 81651c9c1b998ccf219dfd92d93d6a0f8f0c684b | https://github.com/smbape/node-sem-lib/blob/81651c9c1b998ccf219dfd92d93d6a0f8f0c684b/lib/sem-lib.js#L78-L89 | train |
benzhou1/iod | lib/schema.js | validateIODActions | function validateIODActions(IOD, IODOpts) {
// Validate IOD action schema
var actionErr = validateAction(IOD, IODOpts.action, IODOpts.params)
if (actionErr) return actionErr
// Validate IOD action required inputs
var inputErr = validateActionInputs(IOD, IODOpts)
if (inputErr) return inputErr
// Validate... | javascript | function validateIODActions(IOD, IODOpts) {
// Validate IOD action schema
var actionErr = validateAction(IOD, IODOpts.action, IODOpts.params)
if (actionErr) return actionErr
// Validate IOD action required inputs
var inputErr = validateActionInputs(IOD, IODOpts)
if (inputErr) return inputErr
// Validate... | [
"function",
"validateIODActions",
"(",
"IOD",
",",
"IODOpts",
")",
"{",
"// Validate IOD action schema",
"var",
"actionErr",
"=",
"validateAction",
"(",
"IOD",
",",
"IODOpts",
".",
"action",
",",
"IODOpts",
".",
"params",
")",
"if",
"(",
"actionErr",
")",
"ret... | Validates IOD action schema along with their required inputs.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options object
@returns {Object | null} - Schema errors | [
"Validates",
"IOD",
"action",
"schema",
"along",
"with",
"their",
"required",
"inputs",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/schema.js#L255-L267 | train |
benzhou1/iod | lib/schema.js | validateIODJob | function validateIODJob(IOD, IODOpts) {
var job = IODOpts.job
var errors = []
_.each(job.actions, function(action) {
// Validate every IOD action in job
var err = validateAction(IOD, action.name, action.params)
if (err) return errors.push({
action: action.name,
error: err
})
// Validate e... | javascript | function validateIODJob(IOD, IODOpts) {
var job = IODOpts.job
var errors = []
_.each(job.actions, function(action) {
// Validate every IOD action in job
var err = validateAction(IOD, action.name, action.params)
if (err) return errors.push({
action: action.name,
error: err
})
// Validate e... | [
"function",
"validateIODJob",
"(",
"IOD",
",",
"IODOpts",
")",
"{",
"var",
"job",
"=",
"IODOpts",
".",
"job",
"var",
"errors",
"=",
"[",
"]",
"_",
".",
"each",
"(",
"job",
".",
"actions",
",",
"function",
"(",
"action",
")",
"{",
"// Validate every IOD... | Validates IOD action schema for every action in job, along with their required inputs.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options object
@returns {Object | null} - Schema errors | [
"Validates",
"IOD",
"action",
"schema",
"for",
"every",
"action",
"in",
"job",
"along",
"with",
"their",
"required",
"inputs",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/schema.js#L276-L310 | train |
Miramac/dir-util | lib/creator.js | create | function create(options, cb) {
options.force = (options.force) ? options.force : false;
options.preserve = (options.preserve) ? options.preserve : true;
options.password = getPwHash(options.password);
console.log('Gernerating directories with folling options:\n', options, '\n');
if(options.test) {return;}
//cr... | javascript | function create(options, cb) {
options.force = (options.force) ? options.force : false;
options.preserve = (options.preserve) ? options.preserve : true;
options.password = getPwHash(options.password);
console.log('Gernerating directories with folling options:\n', options, '\n');
if(options.test) {return;}
//cr... | [
"function",
"create",
"(",
"options",
",",
"cb",
")",
"{",
"options",
".",
"force",
"=",
"(",
"options",
".",
"force",
")",
"?",
"options",
".",
"force",
":",
"false",
";",
"options",
".",
"preserve",
"=",
"(",
"options",
".",
"preserve",
")",
"?",
... | Used to create user directory with htacces password-file from a template folder. Will need a rework for more generic functionality...
Deep copy src to the dest
Search and replace in dest | [
"Used",
"to",
"create",
"user",
"directory",
"with",
"htacces",
"password",
"-",
"file",
"from",
"a",
"template",
"folder",
".",
"Will",
"need",
"a",
"rework",
"for",
"more",
"generic",
"functionality",
"..."
] | 2ffb6fce91e1540b29d924b38225c161a8e646ef | https://github.com/Miramac/dir-util/blob/2ffb6fce91e1540b29d924b38225c161a8e646ef/lib/creator.js#L19-L59 | train |
Miramac/dir-util | lib/creator.js | replace | function replace(root, options, callback) {
analyser.readDir(root, options, function(err, files) {
files = _.flatten(files);
_.each(files, function(file){
fs.readFile(file, 'UTF-8', function(err, data) {
if(err) {throw err;}
var i, value;
for(i=0; i<options.values.length; i++) {
value = option... | javascript | function replace(root, options, callback) {
analyser.readDir(root, options, function(err, files) {
files = _.flatten(files);
_.each(files, function(file){
fs.readFile(file, 'UTF-8', function(err, data) {
if(err) {throw err;}
var i, value;
for(i=0; i<options.values.length; i++) {
value = option... | [
"function",
"replace",
"(",
"root",
",",
"options",
",",
"callback",
")",
"{",
"analyser",
".",
"readDir",
"(",
"root",
",",
"options",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"files",
"=",
"_",
".",
"flatten",
"(",
"files",
")",
";",
... | search and replace in files file | [
"search",
"and",
"replace",
"in",
"files",
"file"
] | 2ffb6fce91e1540b29d924b38225c161a8e646ef | https://github.com/Miramac/dir-util/blob/2ffb6fce91e1540b29d924b38225c161a8e646ef/lib/creator.js#L75-L99 | train |
calaverastech/grunt-pkgbuild | tasks/pkgbuild.js | abs_path | function abs_path(file, cwd) {
if(!file || file.length === 0) {
return null;
}
function get_path(p) {
var dir = grunt.file.isPathAbsolute(p) ? "" : (cwd || ".");
return path.join(dir, p);
}
... | javascript | function abs_path(file, cwd) {
if(!file || file.length === 0) {
return null;
}
function get_path(p) {
var dir = grunt.file.isPathAbsolute(p) ? "" : (cwd || ".");
return path.join(dir, p);
}
... | [
"function",
"abs_path",
"(",
"file",
",",
"cwd",
")",
"{",
"if",
"(",
"!",
"file",
"||",
"file",
".",
"length",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"function",
"get_path",
"(",
"p",
")",
"{",
"var",
"dir",
"=",
"grunt",
".",
"file",... | get absolute path | [
"get",
"absolute",
"path"
] | f1414516a0cffc1d7d7c0fa63861d3acbef054bd | https://github.com/calaverastech/grunt-pkgbuild/blob/f1414516a0cffc1d7d7c0fa63861d3acbef054bd/tasks/pkgbuild.js#L147-L164 | train |
peteromano/jetrunner | example/vendor/mocha/lib/ms.js | format | function format(ms) {
if (ms == d) return Math.round(ms / d) + ' day';
if (ms > d) return Math.round(ms / d) + ' days';
if (ms == h) return Math.round(ms / h) + ' hour';
if (ms > h) return Math.round(ms / h) + ' hours';
if (ms == m) return Math.round(ms / m) + ' minute';
if (ms > m) return Math.round(ms / m... | javascript | function format(ms) {
if (ms == d) return Math.round(ms / d) + ' day';
if (ms > d) return Math.round(ms / d) + ' days';
if (ms == h) return Math.round(ms / h) + ' hour';
if (ms > h) return Math.round(ms / h) + ' hours';
if (ms == m) return Math.round(ms / m) + ' minute';
if (ms > m) return Math.round(ms / m... | [
"function",
"format",
"(",
"ms",
")",
"{",
"if",
"(",
"ms",
"==",
"d",
")",
"return",
"Math",
".",
"round",
"(",
"ms",
"/",
"d",
")",
"+",
"' day'",
";",
"if",
"(",
"ms",
">",
"d",
")",
"return",
"Math",
".",
"round",
"(",
"ms",
"/",
"d",
"... | Format the given `ms`.
@param {Number} ms
@return {String}
@api public | [
"Format",
"the",
"given",
"ms",
"."
] | 1882e0ee83d31fe1c799b42848c8c1357a62c995 | https://github.com/peteromano/jetrunner/blob/1882e0ee83d31fe1c799b42848c8c1357a62c995/example/vendor/mocha/lib/ms.js#L71-L81 | train |
christophercrouzet/pillr | lib/components/render_page.js | getPartials | function getPartials(file, sourcePath, templates, customPartialName, callback) {
const { partials } = templates;
if (file.meta.customLayout === undefined) {
async.nextTick(callback, null, partials);
return;
}
const customLayoutPath = path.join(
sourcePath,
path.resolve(path.sep, file.meta.fileP... | javascript | function getPartials(file, sourcePath, templates, customPartialName, callback) {
const { partials } = templates;
if (file.meta.customLayout === undefined) {
async.nextTick(callback, null, partials);
return;
}
const customLayoutPath = path.join(
sourcePath,
path.resolve(path.sep, file.meta.fileP... | [
"function",
"getPartials",
"(",
"file",
",",
"sourcePath",
",",
"templates",
",",
"customPartialName",
",",
"callback",
")",
"{",
"const",
"{",
"partials",
"}",
"=",
"templates",
";",
"if",
"(",
"file",
".",
"meta",
".",
"customLayout",
"===",
"undefined",
... | Retrieve the template partials. | [
"Retrieve",
"the",
"template",
"partials",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/components/render_page.js#L12-L33 | train |
christophercrouzet/pillr | lib/components/render_page.js | render | function render(file, layout, context, partials, callback) {
try {
const data = mustache.render(layout, context, partials);
async.nextTick(callback, null, data);
} catch (error) {
console.error(`${file.path}: Could not render the layout`);
async.nextTick(callback, error);
}
} | javascript | function render(file, layout, context, partials, callback) {
try {
const data = mustache.render(layout, context, partials);
async.nextTick(callback, null, data);
} catch (error) {
console.error(`${file.path}: Could not render the layout`);
async.nextTick(callback, error);
}
} | [
"function",
"render",
"(",
"file",
",",
"layout",
",",
"context",
",",
"partials",
",",
"callback",
")",
"{",
"try",
"{",
"const",
"data",
"=",
"mustache",
".",
"render",
"(",
"layout",
",",
"context",
",",
"partials",
")",
";",
"async",
".",
"nextTick... | Render the page. | [
"Render",
"the",
"page",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/components/render_page.js#L36-L44 | train |
christophercrouzet/pillr | lib/components/render_page.js | wrapFunctions | function wrapFunctions(fns, file, files) {
return Object.entries(fns)
.reduce((obj1, [groupName, group]) => {
return Object.assign(obj1, {
[groupName]: Object.entries(group)
.reduce((obj2, [fnName, fn]) => {
return Object.assign(obj2, { [fnName]: fn(file, files) });
}... | javascript | function wrapFunctions(fns, file, files) {
return Object.entries(fns)
.reduce((obj1, [groupName, group]) => {
return Object.assign(obj1, {
[groupName]: Object.entries(group)
.reduce((obj2, [fnName, fn]) => {
return Object.assign(obj2, { [fnName]: fn(file, files) });
}... | [
"function",
"wrapFunctions",
"(",
"fns",
",",
"file",
",",
"files",
")",
"{",
"return",
"Object",
".",
"entries",
"(",
"fns",
")",
".",
"reduce",
"(",
"(",
"obj1",
",",
"[",
"groupName",
",",
"group",
"]",
")",
"=>",
"{",
"return",
"Object",
".",
"... | Wrap the template functions to pass them the current file. | [
"Wrap",
"the",
"template",
"functions",
"to",
"pass",
"them",
"the",
"current",
"file",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/components/render_page.js#L48-L58 | train |
huafu/ember-dev-fixtures | private/utils/dev-fixtures/module.js | function (fullPath, autoDefine) {
if (!this.instances[fullPath]) {
this.instances[fullPath] = DevFixturesModule.create({
fullPath: fullPath,
autoDefine: Boolean(autoDefine)
});
}
return this.instances[fullPath];
} | javascript | function (fullPath, autoDefine) {
if (!this.instances[fullPath]) {
this.instances[fullPath] = DevFixturesModule.create({
fullPath: fullPath,
autoDefine: Boolean(autoDefine)
});
}
return this.instances[fullPath];
} | [
"function",
"(",
"fullPath",
",",
"autoDefine",
")",
"{",
"if",
"(",
"!",
"this",
".",
"instances",
"[",
"fullPath",
"]",
")",
"{",
"this",
".",
"instances",
"[",
"fullPath",
"]",
"=",
"DevFixturesModule",
".",
"create",
"(",
"{",
"fullPath",
":",
"ful... | Get the instance of the module for the given full path
@method for
@param {string} fullPath
@param {boolean} autoDefine
@return {DevFixturesModule} | [
"Get",
"the",
"instance",
"of",
"the",
"module",
"for",
"the",
"given",
"full",
"path"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/utils/dev-fixtures/module.js#L143-L151 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( obj ) {
var clone;
// Array.
if ( obj && ( obj instanceof Array ) ) {
clone = [];
for ( var i = 0; i < obj.length; i++ )
clone[ i ] = CKEDITOR.tools.clone( obj[ i ] );
return clone;
}
// "Static" types.
if ( obj === null || ( typeof( obj ) != 'object' ) || ( obj instance... | javascript | function( obj ) {
var clone;
// Array.
if ( obj && ( obj instanceof Array ) ) {
clone = [];
for ( var i = 0; i < obj.length; i++ )
clone[ i ] = CKEDITOR.tools.clone( obj[ i ] );
return clone;
}
// "Static" types.
if ( obj === null || ( typeof( obj ) != 'object' ) || ( obj instance... | [
"function",
"(",
"obj",
")",
"{",
"var",
"clone",
";",
"// Array.",
"if",
"(",
"obj",
"&&",
"(",
"obj",
"instanceof",
"Array",
")",
")",
"{",
"clone",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"obj",
".",
"length",
... | Creates a deep copy of an object.
**Note**: Recursive references are not supported.
var obj = {
name: 'John',
cars: {
Mercedes: { color: 'blue' },
Porsche: { color: 'red' }
}
};
var clone = CKEDITOR.tools.clone( obj );
clone.name = 'Paul';
clone.cars.Porsche.color = 'silver';
alert( obj.name ); // 'John'
alert( ... | [
"Creates",
"a",
"deep",
"copy",
"of",
"an",
"object",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L95-L125 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( str, keepCase ) {
return str.charAt( 0 ).toUpperCase() + ( keepCase ? str.slice( 1 ) : str.slice( 1 ).toLowerCase() );
} | javascript | function( str, keepCase ) {
return str.charAt( 0 ).toUpperCase() + ( keepCase ? str.slice( 1 ) : str.slice( 1 ).toLowerCase() );
} | [
"function",
"(",
"str",
",",
"keepCase",
")",
"{",
"return",
"str",
".",
"charAt",
"(",
"0",
")",
".",
"toUpperCase",
"(",
")",
"+",
"(",
"keepCase",
"?",
"str",
".",
"slice",
"(",
"1",
")",
":",
"str",
".",
"slice",
"(",
"1",
")",
".",
"toLowe... | Turns the first letter of a string to upper-case.
@param {String} str
@param {Boolean} [keepCase] Keep the case of 2nd to last letter.
@returns {String} | [
"Turns",
"the",
"first",
"letter",
"of",
"a",
"string",
"to",
"upper",
"-",
"case",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L134-L136 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( property, value, asString ) {
if ( asString )
return cssVendorPrefix + property + ':' + value + ';' + property + ':' + value;
var ret = {};
ret[ property ] = value;
ret[ cssVendorPrefix + property ] = value;
return ret;
} | javascript | function( property, value, asString ) {
if ( asString )
return cssVendorPrefix + property + ':' + value + ';' + property + ':' + value;
var ret = {};
ret[ property ] = value;
ret[ cssVendorPrefix + property ] = value;
return ret;
} | [
"function",
"(",
"property",
",",
"value",
",",
"asString",
")",
"{",
"if",
"(",
"asString",
")",
"return",
"cssVendorPrefix",
"+",
"property",
"+",
"':'",
"+",
"value",
"+",
"';'",
"+",
"property",
"+",
"':'",
"+",
"value",
";",
"var",
"ret",
"=",
"... | Generates an object or a string containing vendor-specific and vendor-free CSS properties.
CKEDITOR.tools.cssVendorPrefix( 'border-radius', '0', true );
// On Firefox: '-moz-border-radius:0;border-radius:0'
// On Chrome: '-webkit-border-radius:0;border-radius:0'
@param {String} property The CSS property name.
@param ... | [
"Generates",
"an",
"object",
"or",
"a",
"string",
"containing",
"vendor",
"-",
"specific",
"and",
"vendor",
"-",
"free",
"CSS",
"properties",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L267-L276 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( originalFunction, functionBuilder ) {
var newFn = functionBuilder( originalFunction );
newFn.prototype = originalFunction.prototype;
return newFn;
} | javascript | function( originalFunction, functionBuilder ) {
var newFn = functionBuilder( originalFunction );
newFn.prototype = originalFunction.prototype;
return newFn;
} | [
"function",
"(",
"originalFunction",
",",
"functionBuilder",
")",
"{",
"var",
"newFn",
"=",
"functionBuilder",
"(",
"originalFunction",
")",
";",
"newFn",
".",
"prototype",
"=",
"originalFunction",
".",
"prototype",
";",
"return",
"newFn",
";",
"}"
] | Creates a function override.
var obj = {
myFunction: function( name ) {
alert( 'Name: ' + name );
}
};
obj.myFunction = CKEDITOR.tools.override( obj.myFunction, function( myFunctionOriginal ) {
return function( name ) {
alert( 'Overriden name: ' + name );
myFunctionOriginal.call( this, name );
};
} );
@param {Functi... | [
"Creates",
"a",
"function",
"override",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L429-L433 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( styleText, nativeNormalize ) {
var props = [],
name,
parsedProps = CKEDITOR.tools.parseCssText( styleText, true, nativeNormalize );
for ( name in parsedProps )
props.push( name + ':' + parsedProps[ name ] );
props.sort();
return props.length ? ( props.join( ';' ) + ';' ) : '';
} | javascript | function( styleText, nativeNormalize ) {
var props = [],
name,
parsedProps = CKEDITOR.tools.parseCssText( styleText, true, nativeNormalize );
for ( name in parsedProps )
props.push( name + ':' + parsedProps[ name ] );
props.sort();
return props.length ? ( props.join( ';' ) + ';' ) : '';
} | [
"function",
"(",
"styleText",
",",
"nativeNormalize",
")",
"{",
"var",
"props",
"=",
"[",
"]",
",",
"name",
",",
"parsedProps",
"=",
"CKEDITOR",
".",
"tools",
".",
"parseCssText",
"(",
"styleText",
",",
"true",
",",
"nativeNormalize",
")",
";",
"for",
"(... | Normalizes CSS data in order to avoid differences in the style attribute.
@param {String} styleText The style data to be normalized.
@param {Boolean} [nativeNormalize=false] Parse the data using the browser.
@returns {String} The normalized value. | [
"Normalizes",
"CSS",
"data",
"in",
"order",
"to",
"avoid",
"differences",
"in",
"the",
"style",
"attribute",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L840-L851 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( styleText, normalize, nativeNormalize ) {
var retval = {};
if ( nativeNormalize ) {
// Injects the style in a temporary span object, so the browser parses it,
// retrieving its final format.
var temp = new CKEDITOR.dom.element( 'span' );
temp.setAttribute( 'style', styleText );
styl... | javascript | function( styleText, normalize, nativeNormalize ) {
var retval = {};
if ( nativeNormalize ) {
// Injects the style in a temporary span object, so the browser parses it,
// retrieving its final format.
var temp = new CKEDITOR.dom.element( 'span' );
temp.setAttribute( 'style', styleText );
styl... | [
"function",
"(",
"styleText",
",",
"normalize",
",",
"nativeNormalize",
")",
"{",
"var",
"retval",
"=",
"{",
"}",
";",
"if",
"(",
"nativeNormalize",
")",
"{",
"// Injects the style in a temporary span object, so the browser parses it,",
"// retrieving its final format.",
... | Turns inline style text properties into one hash.
@param {String} styleText The style data to be parsed.
@param {Boolean} [normalize=false] Normalize properties and values
(e.g. trim spaces, convert to lower case).
@param {Boolean} [nativeNormalize=false] Parse the data using the browser.
@returns {Object} The object ... | [
"Turns",
"inline",
"style",
"text",
"properties",
"into",
"one",
"hash",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L878-L906 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( styles, sort ) {
var name,
stylesArr = [];
for ( name in styles )
stylesArr.push( name + ':' + styles[ name ] );
if ( sort )
stylesArr.sort();
return stylesArr.join( '; ' );
} | javascript | function( styles, sort ) {
var name,
stylesArr = [];
for ( name in styles )
stylesArr.push( name + ':' + styles[ name ] );
if ( sort )
stylesArr.sort();
return stylesArr.join( '; ' );
} | [
"function",
"(",
"styles",
",",
"sort",
")",
"{",
"var",
"name",
",",
"stylesArr",
"=",
"[",
"]",
";",
"for",
"(",
"name",
"in",
"styles",
")",
"stylesArr",
".",
"push",
"(",
"name",
"+",
"':'",
"+",
"styles",
"[",
"name",
"]",
")",
";",
"if",
... | Serializes the `style name => value` hash to a style text.
var styleObj = CKEDITOR.tools.parseCssText( 'color: red; border: none' );
console.log( styleObj.color ); // -> 'red'
CKEDITOR.tools.writeCssText( styleObj ); // -> 'color:red; border:none'
CKEDITOR.tools.writeCssText( styleObj, true ); // -> 'border:none; colo... | [
"Serializes",
"the",
"style",
"name",
"=",
">",
"value",
"hash",
"to",
"a",
"style",
"text",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L921-L932 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( left, right, onlyLeft ) {
var name;
if ( !left && !right )
return true;
if ( !left || !right )
return false;
for ( name in left ) {
if ( left[ name ] != right[ name ] )
return false;
}
if ( !onlyLeft ) {
for ( name in right ) {
if ( left[ name ] != right[ name ]... | javascript | function( left, right, onlyLeft ) {
var name;
if ( !left && !right )
return true;
if ( !left || !right )
return false;
for ( name in left ) {
if ( left[ name ] != right[ name ] )
return false;
}
if ( !onlyLeft ) {
for ( name in right ) {
if ( left[ name ] != right[ name ]... | [
"function",
"(",
"left",
",",
"right",
",",
"onlyLeft",
")",
"{",
"var",
"name",
";",
"if",
"(",
"!",
"left",
"&&",
"!",
"right",
")",
"return",
"true",
";",
"if",
"(",
"!",
"left",
"||",
"!",
"right",
")",
"return",
"false",
";",
"for",
"(",
"... | Compares two objects.
**Note:** This method performs shallow, non-strict comparison.
@since 4.1
@param {Object} left
@param {Object} right
@param {Boolean} [onlyLeft] Check only the properties that are present in the `left` object.
@returns {Boolean} Whether objects are identical. | [
"Compares",
"two",
"objects",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L945-L967 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( arr, fillWith ) {
var obj = {};
if ( arguments.length == 1 )
fillWith = true;
for ( var i = 0, l = arr.length; i < l; ++i )
obj[ arr[ i ] ] = fillWith;
return obj;
} | javascript | function( arr, fillWith ) {
var obj = {};
if ( arguments.length == 1 )
fillWith = true;
for ( var i = 0, l = arr.length; i < l; ++i )
obj[ arr[ i ] ] = fillWith;
return obj;
} | [
"function",
"(",
"arr",
",",
"fillWith",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"if",
"(",
"arguments",
".",
"length",
"==",
"1",
")",
"fillWith",
"=",
"true",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"arr",
".",
"length",
"... | Converts an array to an object by rewriting array items
to object properties.
var arr = [ 'foo', 'bar', 'foo' ];
console.log( CKEDITOR.tools.convertArrayToObject( arr ) );
// -> { foo: true, bar: true }
console.log( CKEDITOR.tools.convertArrayToObject( arr, 1 ) );
// -> { foo: 1, bar: 1 }
@since 4.1
@param {Array} ar... | [
"Converts",
"an",
"array",
"to",
"an",
"object",
"by",
"rewriting",
"array",
"items",
"to",
"object",
"properties",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L1001-L1011 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function() {
var domain;
while ( 1 ) {
try {
// Try to access the parent document. It throws
// "access denied" if restricted by the "Same Origin" policy.
domain = window.parent.document.domain;
break;
} catch ( e ) {
// Calculate the value to set to document.domain.
domain ... | javascript | function() {
var domain;
while ( 1 ) {
try {
// Try to access the parent document. It throws
// "access denied" if restricted by the "Same Origin" policy.
domain = window.parent.document.domain;
break;
} catch ( e ) {
// Calculate the value to set to document.domain.
domain ... | [
"function",
"(",
")",
"{",
"var",
"domain",
";",
"while",
"(",
"1",
")",
"{",
"try",
"{",
"// Try to access the parent document. It throws",
"// \"access denied\" if restricted by the \"Same Origin\" policy.",
"domain",
"=",
"window",
".",
"parent",
".",
"document",
"."... | Tries to fix the `document.domain` of the current document to match the
parent window domain, avoiding "Same Origin" policy issues.
This is an Internet Explorer only requirement.
@since 4.1.2
@returns {Boolean} `true` if the current domain is already good or if
it has been fixed successfully. | [
"Tries",
"to",
"fix",
"the",
"document",
".",
"domain",
"of",
"the",
"current",
"document",
"to",
"match",
"the",
"parent",
"window",
"domain",
"avoiding",
"Same",
"Origin",
"policy",
"issues",
".",
"This",
"is",
"an",
"Internet",
"Explorer",
"only",
"requir... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L1022-L1052 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/tools.js | function( arr, regexp ) {
for ( var i = 0, l = arr.length; i < l; ++i ) {
if ( arr[ i ].match( regexp ) )
return true;
}
return false;
} | javascript | function( arr, regexp ) {
for ( var i = 0, l = arr.length; i < l; ++i ) {
if ( arr[ i ].match( regexp ) )
return true;
}
return false;
} | [
"function",
"(",
"arr",
",",
"regexp",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"arr",
".",
"length",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"{",
"if",
"(",
"arr",
"[",
"i",
"]",
".",
"match",
"(",
"regexp",
")",
")",
... | Checks if any of the `arr` items match the provided regular expression.
@param {Array} arr The array whose items will be checked.
@param {RegExp} regexp The regular expression.
@returns {Boolean} Returns `true` for the first occurrence of the search pattern.
@since 4.4 | [
"Checks",
"if",
"any",
"of",
"the",
"arr",
"items",
"match",
"the",
"provided",
"regular",
"expression",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/tools.js#L1152-L1158 | train | |
nick-thompson/capp | index.js | loadDocument | function loadDocument (directory, callback) {
var docPath = path.resolve(directory, '_design.js')
fs.stat(docPath, function (err, stat) {
if (err) return callback.call(null, err);
if (stat.isFile()) {
var document = require(docPath);
return callback.call(null, null, document);
}
return c... | javascript | function loadDocument (directory, callback) {
var docPath = path.resolve(directory, '_design.js')
fs.stat(docPath, function (err, stat) {
if (err) return callback.call(null, err);
if (stat.isFile()) {
var document = require(docPath);
return callback.call(null, null, document);
}
return c... | [
"function",
"loadDocument",
"(",
"directory",
",",
"callback",
")",
"{",
"var",
"docPath",
"=",
"path",
".",
"resolve",
"(",
"directory",
",",
"'_design.js'",
")",
"fs",
".",
"stat",
"(",
"docPath",
",",
"function",
"(",
"err",
",",
"stat",
")",
"{",
"... | Load a design document from the _design.js directive
within a specified directory.
@param {string} directory
@param {function} callback (err, document) | [
"Load",
"a",
"design",
"document",
"from",
"the",
"_design",
".",
"js",
"directive",
"within",
"a",
"specified",
"directory",
"."
] | 3df2193d7b464b0440224f658128fded8bff8c88 | https://github.com/nick-thompson/capp/blob/3df2193d7b464b0440224f658128fded8bff8c88/index.js#L25-L35 | train |
nick-thompson/capp | index.js | loadAttachments | function loadAttachments (doc, directory, callback) {
doc._attachments = doc._attachments || {};
glob('**/*', { cwd: directory }, function (err, files) {
async.each(files, function (file, done) {
if (file.indexOf('_') === 0) return done();
fs.stat(path.join(directory, file), function (err, stat) {
... | javascript | function loadAttachments (doc, directory, callback) {
doc._attachments = doc._attachments || {};
glob('**/*', { cwd: directory }, function (err, files) {
async.each(files, function (file, done) {
if (file.indexOf('_') === 0) return done();
fs.stat(path.join(directory, file), function (err, stat) {
... | [
"function",
"loadAttachments",
"(",
"doc",
",",
"directory",
",",
"callback",
")",
"{",
"doc",
".",
"_attachments",
"=",
"doc",
".",
"_attachments",
"||",
"{",
"}",
";",
"glob",
"(",
"'**/*'",
",",
"{",
"cwd",
":",
"directory",
"}",
",",
"function",
"(... | Recursively load attachments from a directory onto
a design document.
@param {object} doc design document
@param {string} directory path to the attachments directory
@param {function} callback (err, document) | [
"Recursively",
"load",
"attachments",
"from",
"a",
"directory",
"onto",
"a",
"design",
"document",
"."
] | 3df2193d7b464b0440224f658128fded8bff8c88 | https://github.com/nick-thompson/capp/blob/3df2193d7b464b0440224f658128fded8bff8c88/index.js#L47-L71 | train |
nick-thompson/capp | index.js | push | function push (directory, uri, callback) {
var db = nano(uri);
loadDocument(directory, function (err, doc) {
if (err) return callback.call(null, err);
loadAttachments(doc, directory, function (err, doc) {
if (err) return callback.call(null, err);
db.get(doc._id, function (err, body) {
if... | javascript | function push (directory, uri, callback) {
var db = nano(uri);
loadDocument(directory, function (err, doc) {
if (err) return callback.call(null, err);
loadAttachments(doc, directory, function (err, doc) {
if (err) return callback.call(null, err);
db.get(doc._id, function (err, body) {
if... | [
"function",
"push",
"(",
"directory",
",",
"uri",
",",
"callback",
")",
"{",
"var",
"db",
"=",
"nano",
"(",
"uri",
")",
";",
"loadDocument",
"(",
"directory",
",",
"function",
"(",
"err",
",",
"doc",
")",
"{",
"if",
"(",
"err",
")",
"return",
"call... | Build a design document from the specified directory
and push it to a Couch at the specified uri.
@param {string} directory
@param {string} uri
@param {function} callback (err, responseBody) | [
"Build",
"a",
"design",
"document",
"from",
"the",
"specified",
"directory",
"and",
"push",
"it",
"to",
"a",
"Couch",
"at",
"the",
"specified",
"uri",
"."
] | 3df2193d7b464b0440224f658128fded8bff8c88 | https://github.com/nick-thompson/capp/blob/3df2193d7b464b0440224f658128fded8bff8c88/index.js#L82-L97 | 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.