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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
pkoretic/pdf417-generator | lib/bcmath.js | bcscale | function bcscale(scale) {
scale = parseInt(scale, 10);
if (isNaN(scale)) {
return false;
}
if (scale < 0) {
return false;
}
libbcmath.scale = scale;
return true;
} | javascript | function bcscale(scale) {
scale = parseInt(scale, 10);
if (isNaN(scale)) {
return false;
}
if (scale < 0) {
return false;
}
libbcmath.scale = scale;
return true;
} | [
"function",
"bcscale",
"(",
"scale",
")",
"{",
"scale",
"=",
"parseInt",
"(",
"scale",
",",
"10",
")",
";",
"if",
"(",
"isNaN",
"(",
"scale",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"scale",
"<",
"0",
")",
"{",
"return",
"false",
... | bcscale - Set default scale parameter for all bc math functions
@param int scale The scale factor (0 to infinate)
@return bool | [
"bcscale",
"-",
"Set",
"default",
"scale",
"parameter",
"for",
"all",
"bc",
"math",
"functions"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L119-L129 | train |
pkoretic/pdf417-generator | lib/bcmath.js | bcdiv | function bcdiv(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = ... | javascript | function bcdiv(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = ... | [
"function",
"bcdiv",
"(",
"left_operand",
",",
"right_operand",
",",
"scale",
")",
"{",
"var",
"first",
",",
"second",
",",
"result",
";",
"if",
"(",
"typeof",
"(",
"scale",
")",
"==",
"'undefined'",
")",
"{",
"scale",
"=",
"libbcmath",
".",
"scale",
"... | bcdiv - Divide two arbitrary precision numbers
@param string left_operand The left operand, as a string
@param string right_operand The right operand, as a string.
@param int [scale] The optional parameter is used to set the number of digits after the decimal place in the result. You can also ... | [
"bcdiv",
"-",
"Divide",
"two",
"arbitrary",
"precision",
"numbers"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L140-L170 | train |
pkoretic/pdf417-generator | lib/bcmath.js | bcmul | function bcmul(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = ... | javascript | function bcmul(left_operand, right_operand, scale) {
var first, second, result;
if (typeof(scale) == 'undefined') {
scale = libbcmath.scale;
}
scale = ((scale < 0) ? 0 : scale);
// create objects
first = libbcmath.bc_init_num();
second = libbcmath.bc_init_num();
result = ... | [
"function",
"bcmul",
"(",
"left_operand",
",",
"right_operand",
",",
"scale",
")",
"{",
"var",
"first",
",",
"second",
",",
"result",
";",
"if",
"(",
"typeof",
"(",
"scale",
")",
"==",
"'undefined'",
")",
"{",
"scale",
"=",
"libbcmath",
".",
"scale",
"... | bcdiv - Multiply two arbitrary precision number
@param string left_operand The left operand, as a string
@param string right_operand The right operand, as a string.
@param int [scale] The optional parameter is used to set the number of digits after the decimal place in the result. You can also... | [
"bcdiv",
"-",
"Multiply",
"two",
"arbitrary",
"precision",
"number"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/bcmath.js#L180-L207 | train |
hammerjs/simulator | index.js | ensureAnArray | function ensureAnArray (arr) {
if (Object.prototype.toString.call(arr) === '[object Array]') {
return arr;
} else if (arr === null || arr === void 0) {
return [];
} else {
return [arr];
}
} | javascript | function ensureAnArray (arr) {
if (Object.prototype.toString.call(arr) === '[object Array]') {
return arr;
} else if (arr === null || arr === void 0) {
return [];
} else {
return [arr];
}
} | [
"function",
"ensureAnArray",
"(",
"arr",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"arr",
")",
"===",
"'[object Array]'",
")",
"{",
"return",
"arr",
";",
"}",
"else",
"if",
"(",
"arr",
"===",
"null",
"||",
"a... | return unchanged if array passed, otherwise wrap in an array
@param {Object|Array|Null} arr any object
@return {Array} | [
"return",
"unchanged",
"if",
"array",
"passed",
"otherwise",
"wrap",
"in",
"an",
"array"
] | 31a05ccd9314247d4e404e18e310b9e3b4642056 | https://github.com/hammerjs/simulator/blob/31a05ccd9314247d4e404e18e310b9e3b4642056/index.js#L7-L15 | train |
hammerjs/simulator | index.js | renderTouches | function renderTouches(touches, element) {
touches.forEach(function(touch) {
var el = document.createElement('div');
el.style.width = '20px';
el.style.height = '20px';
el.style.background = 'red';
el.style.position = 'fixed';
el.style.top =... | javascript | function renderTouches(touches, element) {
touches.forEach(function(touch) {
var el = document.createElement('div');
el.style.width = '20px';
el.style.height = '20px';
el.style.background = 'red';
el.style.position = 'fixed';
el.style.top =... | [
"function",
"renderTouches",
"(",
"touches",
",",
"element",
")",
"{",
"touches",
".",
"forEach",
"(",
"function",
"(",
"touch",
")",
"{",
"var",
"el",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"el",
".",
"style",
".",
"width",
"="... | render the touches
@param touches
@param element
@param type | [
"render",
"the",
"touches"
] | 31a05ccd9314247d4e404e18e310b9e3b4642056 | https://github.com/hammerjs/simulator/blob/31a05ccd9314247d4e404e18e310b9e3b4642056/index.js#L226-L245 | train |
hammerjs/simulator | index.js | trigger | function trigger(touches, element, type) {
return Simulator.events[Simulator.type].trigger(touches, element, type);
} | javascript | function trigger(touches, element, type) {
return Simulator.events[Simulator.type].trigger(touches, element, type);
} | [
"function",
"trigger",
"(",
"touches",
",",
"element",
",",
"type",
")",
"{",
"return",
"Simulator",
".",
"events",
"[",
"Simulator",
".",
"type",
"]",
".",
"trigger",
"(",
"touches",
",",
"element",
",",
"type",
")",
";",
"}"
] | trigger the touch events
@param touches
@param element
@param type
@returns {*} | [
"trigger",
"the",
"touch",
"events"
] | 31a05ccd9314247d4e404e18e310b9e3b4642056 | https://github.com/hammerjs/simulator/blob/31a05ccd9314247d4e404e18e310b9e3b4642056/index.js#L254-L256 | train |
nathanboktae/mocha-phantomjs-core | mocha-phantomjs-core.js | function(msg, errno) {
if (output && config.file) {
output.close()
}
if (msg) {
stderr.writeLine(msg)
}
return phantom.exit(errno || 1)
} | javascript | function(msg, errno) {
if (output && config.file) {
output.close()
}
if (msg) {
stderr.writeLine(msg)
}
return phantom.exit(errno || 1)
} | [
"function",
"(",
"msg",
",",
"errno",
")",
"{",
"if",
"(",
"output",
"&&",
"config",
".",
"file",
")",
"{",
"output",
".",
"close",
"(",
")",
"}",
"if",
"(",
"msg",
")",
"{",
"stderr",
".",
"writeLine",
"(",
"msg",
")",
"}",
"return",
"phantom",
... | Create and configure the client page | [
"Create",
"and",
"configure",
"the",
"client",
"page"
] | 562125f41e4248a9ae19b91ed2e23a95f92262e9 | https://github.com/nathanboktae/mocha-phantomjs-core/blob/562125f41e4248a9ae19b91ed2e23a95f92262e9/mocha-phantomjs-core.js#L39-L47 | train | |
pkoretic/pdf417-generator | lib/libbcmath.js | function() {
this.n_sign = null; // sign
this.n_len = null; /* (int) The number of digits before the decimal point. */
this.n_scale = null; /* (int) The number of digits after the decimal point. */
//this.n_refs = null; /* (int) The number of pointers to this number. */
//this.n... | javascript | function() {
this.n_sign = null; // sign
this.n_len = null; /* (int) The number of digits before the decimal point. */
this.n_scale = null; /* (int) The number of digits after the decimal point. */
//this.n_refs = null; /* (int) The number of pointers to this number. */
//this.n... | [
"function",
"(",
")",
"{",
"this",
".",
"n_sign",
"=",
"null",
";",
"// sign",
"this",
".",
"n_len",
"=",
"null",
";",
"/* (int) The number of digits before the decimal point. */",
"this",
".",
"n_scale",
"=",
"null",
";",
"/* (int) The number of digits after the deci... | default scale
Basic number structure | [
"default",
"scale",
"Basic",
"number",
"structure"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L31-L64 | train | |
pkoretic/pdf417-generator | lib/libbcmath.js | function(str) {
var p;
p = str.indexOf('.');
if (p==-1) {
return libbcmath.bc_str2num(str, 0);
} else {
return libbcmath.bc_str2num(str, (str.length-p));
}
} | javascript | function(str) {
var p;
p = str.indexOf('.');
if (p==-1) {
return libbcmath.bc_str2num(str, 0);
} else {
return libbcmath.bc_str2num(str, (str.length-p));
}
} | [
"function",
"(",
"str",
")",
"{",
"var",
"p",
";",
"p",
"=",
"str",
".",
"indexOf",
"(",
"'.'",
")",
";",
"if",
"(",
"p",
"==",
"-",
"1",
")",
"{",
"return",
"libbcmath",
".",
"bc_str2num",
"(",
"str",
",",
"0",
")",
";",
"}",
"else",
"{",
... | Convert to bc_num detecting scale | [
"Convert",
"to",
"bc_num",
"detecting",
"scale"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L105-L114 | train | |
pkoretic/pdf417-generator | lib/libbcmath.js | function(r, ptr, chr, len) {
var i;
for (i=0;i<len;i++) {
r[ptr+i] = chr;
}
} | javascript | function(r, ptr, chr, len) {
var i;
for (i=0;i<len;i++) {
r[ptr+i] = chr;
}
} | [
"function",
"(",
"r",
",",
"ptr",
",",
"chr",
",",
"len",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"r",
"[",
"ptr",
"+",
"i",
"]",
"=",
"chr",
";",
"}",
"}"
] | replicate c function
@param array return (by reference)
@param string char to fill
@param int length to fill | [
"replicate",
"c",
"function"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L256-L261 | train | |
pkoretic/pdf417-generator | lib/libbcmath.js | function(num) {
var count; // int
var nptr; // int
/* Quick check. */
//if (num == BCG(_zero_)) return TRUE;
/* Initialize */
count = num.n_len + num.n_scale;
nptr = 0; //num->n_value;
/* The check */
while ((count > 0) && (num.n_value[nptr++] =... | javascript | function(num) {
var count; // int
var nptr; // int
/* Quick check. */
//if (num == BCG(_zero_)) return TRUE;
/* Initialize */
count = num.n_len + num.n_scale;
nptr = 0; //num->n_value;
/* The check */
while ((count > 0) && (num.n_value[nptr++] =... | [
"function",
"(",
"num",
")",
"{",
"var",
"count",
";",
"// int",
"var",
"nptr",
";",
"// int",
"/* Quick check. */",
"//if (num == BCG(_zero_)) return TRUE;",
"/* Initialize */",
"count",
"=",
"num",
".",
"n_len",
"+",
"num",
".",
"n_scale",
";",
"nptr",
"=",
... | Determine if the number specified is zero or not
@param bc_num num number to check
@return boolean true when zero, false when not zero. | [
"Determine",
"if",
"the",
"number",
"specified",
"is",
"zero",
"or",
"not"
] | bcb0af69d822446aa4e195019a35d0967626a13b | https://github.com/pkoretic/pdf417-generator/blob/bcb0af69d822446aa4e195019a35d0967626a13b/lib/libbcmath.js#L282-L303 | train | |
Suor/pg-bricks | index.js | Conf | function Conf(config, _pg) {
if (typeof config === 'string') config = {connectionString: config};
this._config = config;
this._pg = _pg || pg;
this._pool = this._pg.Pool(config);
} | javascript | function Conf(config, _pg) {
if (typeof config === 'string') config = {connectionString: config};
this._config = config;
this._pg = _pg || pg;
this._pool = this._pg.Pool(config);
} | [
"function",
"Conf",
"(",
"config",
",",
"_pg",
")",
"{",
"if",
"(",
"typeof",
"config",
"===",
"'string'",
")",
"config",
"=",
"{",
"connectionString",
":",
"config",
"}",
";",
"this",
".",
"_config",
"=",
"config",
";",
"this",
".",
"_pg",
"=",
"_pg... | A Conf object | [
"A",
"Conf",
"object"
] | 023538ab7ece9c0abba1102db9a437820d1173df | https://github.com/Suor/pg-bricks/blob/023538ab7ece9c0abba1102db9a437820d1173df/index.js#L154-L159 | train |
remy/twitterlib | twitterlib.js | function (tweets, search, includeHighlighted) {
var updated = [], tmp, i = 0;
if (typeof search == 'string') {
search = this.format(search);
}
for (i = 0; i < tweets.length; i++) {
if (this.match(tweets[i], search, includeHighlighted)) {
updated.push(twe... | javascript | function (tweets, search, includeHighlighted) {
var updated = [], tmp, i = 0;
if (typeof search == 'string') {
search = this.format(search);
}
for (i = 0; i < tweets.length; i++) {
if (this.match(tweets[i], search, includeHighlighted)) {
updated.push(twe... | [
"function",
"(",
"tweets",
",",
"search",
",",
"includeHighlighted",
")",
"{",
"var",
"updated",
"=",
"[",
"]",
",",
"tmp",
",",
"i",
"=",
"0",
";",
"if",
"(",
"typeof",
"search",
"==",
"'string'",
")",
"{",
"search",
"=",
"this",
".",
"format",
"(... | tweets typeof Array | [
"tweets",
"typeof",
"Array"
] | ccfa3c43a44e175d258f9773a7f76196a107e527 | https://github.com/remy/twitterlib/blob/ccfa3c43a44e175d258f9773a7f76196a107e527/twitterlib.js#L350-L364 | train | |
ahmed-wagdi/angular-joyride | js/joyride.js | function(){
angular.element(document.querySelector('body')).removeClass('jr_active jr_overlay_show');
removeJoyride();
scope.joyride.current = 0;
scope.joyride.transitionStep = true;
if (typeof scope.joyride.config.onFinish === "function") {
scope.joyride.co... | javascript | function(){
angular.element(document.querySelector('body')).removeClass('jr_active jr_overlay_show');
removeJoyride();
scope.joyride.current = 0;
scope.joyride.transitionStep = true;
if (typeof scope.joyride.config.onFinish === "function") {
scope.joyride.co... | [
"function",
"(",
")",
"{",
"angular",
".",
"element",
"(",
"document",
".",
"querySelector",
"(",
"'body'",
")",
")",
".",
"removeClass",
"(",
"'jr_active jr_overlay_show'",
")",
";",
"removeJoyride",
"(",
")",
";",
"scope",
".",
"joyride",
".",
"current",
... | Reset variables after joyride ends | [
"Reset",
"variables",
"after",
"joyride",
"ends"
] | e2b48d7ceea9d3480ba7c619c7ac71fb5c1fc6f7 | https://github.com/ahmed-wagdi/angular-joyride/blob/e2b48d7ceea9d3480ba7c619c7ac71fb5c1fc6f7/js/joyride.js#L243-L254 | train | |
dtoubelis/sails-cassandra | lib/adapter.js | function (connection, collections, cb) {
if (!connection.identity) return cb(Errors.IdentityMissing);
if (connections[connection.identity]) return cb(Errors.IdentityDuplicate);
// Store the connection
connections[connection.identity] = {
config: connection,
collections: collect... | javascript | function (connection, collections, cb) {
if (!connection.identity) return cb(Errors.IdentityMissing);
if (connections[connection.identity]) return cb(Errors.IdentityDuplicate);
// Store the connection
connections[connection.identity] = {
config: connection,
collections: collect... | [
"function",
"(",
"connection",
",",
"collections",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"connection",
".",
"identity",
")",
"return",
"cb",
"(",
"Errors",
".",
"IdentityMissing",
")",
";",
"if",
"(",
"connections",
"[",
"connection",
".",
"identity",
"]"... | Register a connection and the collections assigned to it.
@param {Connection} connection
@param {Object} collections
@param {Function} cb | [
"Register",
"a",
"connection",
"and",
"the",
"collections",
"assigned",
"to",
"it",
"."
] | 78c3f5437f92cf0fdc20b7dac819e6c51b56331d | https://github.com/dtoubelis/sails-cassandra/blob/78c3f5437f92cf0fdc20b7dac819e6c51b56331d/lib/adapter.js#L57-L86 | train | |
dtoubelis/sails-cassandra | lib/adapter.js | function(cb) {
var collection = connectionObject.collections[collectionName];
if (!collection) return cb(Errors.CollectionNotRegistered);
collection.dropTable(function(err) {
// ignore "table does not exist" error
if (err && err.code === 8704) return cb(... | javascript | function(cb) {
var collection = connectionObject.collections[collectionName];
if (!collection) return cb(Errors.CollectionNotRegistered);
collection.dropTable(function(err) {
// ignore "table does not exist" error
if (err && err.code === 8704) return cb(... | [
"function",
"(",
"cb",
")",
"{",
"var",
"collection",
"=",
"connectionObject",
".",
"collections",
"[",
"collectionName",
"]",
";",
"if",
"(",
"!",
"collection",
")",
"return",
"cb",
"(",
"Errors",
".",
"CollectionNotRegistered",
")",
";",
"collection",
".",... | drop the main table | [
"drop",
"the",
"main",
"table"
] | 78c3f5437f92cf0fdc20b7dac819e6c51b56331d | https://github.com/dtoubelis/sails-cassandra/blob/78c3f5437f92cf0fdc20b7dac819e6c51b56331d/lib/adapter.js#L197-L208 | train | |
Magillem/generator-jhipster-pages | generators/app/files.js | addDropdownToMenu | function addDropdownToMenu(dropdownName, routerName, glyphiconName, enableTranslation, clientFramework) {
let navbarPath;
try {
if (clientFramework === 'angular1') {
navbarPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.html`;
jhipsterUtils.rewriteFile({
f... | javascript | function addDropdownToMenu(dropdownName, routerName, glyphiconName, enableTranslation, clientFramework) {
let navbarPath;
try {
if (clientFramework === 'angular1') {
navbarPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.html`;
jhipsterUtils.rewriteFile({
f... | [
"function",
"addDropdownToMenu",
"(",
"dropdownName",
",",
"routerName",
",",
"glyphiconName",
",",
"enableTranslation",
",",
"clientFramework",
")",
"{",
"let",
"navbarPath",
";",
"try",
"{",
"if",
"(",
"clientFramework",
"===",
"'angular1'",
")",
"{",
"navbarPat... | Add a new dropdown element, at the root of the menu.
@param {string} dropdownName - The name of the AngularJS router that is added to the menu.
@param {string} glyphiconName - The name of the Glyphicon (from Bootstrap) that will be displayed.
@param {boolean} enableTranslation - If translations are enabled or not
@par... | [
"Add",
"a",
"new",
"dropdown",
"element",
"at",
"the",
"root",
"of",
"the",
"menu",
"."
] | 276dc08adc28626705fa251709def03de61a10ac | https://github.com/Magillem/generator-jhipster-pages/blob/276dc08adc28626705fa251709def03de61a10ac/generators/app/files.js#L463-L523 | train |
Magillem/generator-jhipster-pages | generators/app/files.js | addPageSetsModule | function addPageSetsModule(clientFramework) {
let appModulePath;
try {
if (clientFramework !== 'angular1') {
appModulePath = `${CLIENT_MAIN_SRC_DIR}app/app.module.ts`;
const fullPath = path.join(process.cwd(), appModulePath);
let args = {
file: appMod... | javascript | function addPageSetsModule(clientFramework) {
let appModulePath;
try {
if (clientFramework !== 'angular1') {
appModulePath = `${CLIENT_MAIN_SRC_DIR}app/app.module.ts`;
const fullPath = path.join(process.cwd(), appModulePath);
let args = {
file: appMod... | [
"function",
"addPageSetsModule",
"(",
"clientFramework",
")",
"{",
"let",
"appModulePath",
";",
"try",
"{",
"if",
"(",
"clientFramework",
"!==",
"'angular1'",
")",
"{",
"appModulePath",
"=",
"`",
"${",
"CLIENT_MAIN_SRC_DIR",
"}",
"`",
";",
"const",
"fullPath",
... | Add pageSets module to app module.
@param {string} clientFramework - The name of the client framework | [
"Add",
"pageSets",
"module",
"to",
"app",
"module",
"."
] | 276dc08adc28626705fa251709def03de61a10ac | https://github.com/Magillem/generator-jhipster-pages/blob/276dc08adc28626705fa251709def03de61a10ac/generators/app/files.js#L575-L603 | train |
senecajs/seneca-auth | lib/express-auth.js | trigger_service_login | function trigger_service_login (msg, respond) {
var seneca = this
if (!msg.user) {
return respond(null, {ok: false, why: 'no-user'})
}
var user_data = msg.user
var q = {}
if (user_data.identifier) {
q[msg.service + '_id'] = user_data.identifier
user_data[msg.service + '_id'] ... | javascript | function trigger_service_login (msg, respond) {
var seneca = this
if (!msg.user) {
return respond(null, {ok: false, why: 'no-user'})
}
var user_data = msg.user
var q = {}
if (user_data.identifier) {
q[msg.service + '_id'] = user_data.identifier
user_data[msg.service + '_id'] ... | [
"function",
"trigger_service_login",
"(",
"msg",
",",
"respond",
")",
"{",
"var",
"seneca",
"=",
"this",
"if",
"(",
"!",
"msg",
".",
"user",
")",
"{",
"return",
"respond",
"(",
"null",
",",
"{",
"ok",
":",
"false",
",",
"why",
":",
"'no-user'",
"}",
... | LOGOUT END default service login trigger | [
"LOGOUT",
"END",
"default",
"service",
"login",
"trigger"
] | 537716d2a07c9be6e3aa5ae6529929704c97338b | https://github.com/senecajs/seneca-auth/blob/537716d2a07c9be6e3aa5ae6529929704c97338b/lib/express-auth.js#L278-L320 | train |
JedWatson/react-component-gulp-tasks | index.js | readPackageJSON | function readPackageJSON () {
var pkg = JSON.parse(require('fs').readFileSync('./package.json'));
var dependencies = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
var peerDependencies = pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [];
return {
name: pkg.name,
deps: dependencies.concat(pe... | javascript | function readPackageJSON () {
var pkg = JSON.parse(require('fs').readFileSync('./package.json'));
var dependencies = pkg.dependencies ? Object.keys(pkg.dependencies) : [];
var peerDependencies = pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [];
return {
name: pkg.name,
deps: dependencies.concat(pe... | [
"function",
"readPackageJSON",
"(",
")",
"{",
"var",
"pkg",
"=",
"JSON",
".",
"parse",
"(",
"require",
"(",
"'fs'",
")",
".",
"readFileSync",
"(",
"'./package.json'",
")",
")",
";",
"var",
"dependencies",
"=",
"pkg",
".",
"dependencies",
"?",
"Object",
"... | Extract package.json metadata | [
"Extract",
"package",
".",
"json",
"metadata"
] | 8a6d636b72fcb10ecd9d633343193923d7447d8d | https://github.com/JedWatson/react-component-gulp-tasks/blob/8a6d636b72fcb10ecd9d633343193923d7447d8d/index.js#L6-L16 | train |
JedWatson/react-component-gulp-tasks | index.js | initTasks | function initTasks (gulp, config) {
var pkg = readPackageJSON();
var name = capitalize(camelCase(config.component.pkgName || pkg.name));
config = defaults(config, { aliasify: pkg.aliasify });
config.component = defaults(config.component, {
pkgName: pkg.name,
dependencies: pkg.deps,
name: name,
src: 'src',
... | javascript | function initTasks (gulp, config) {
var pkg = readPackageJSON();
var name = capitalize(camelCase(config.component.pkgName || pkg.name));
config = defaults(config, { aliasify: pkg.aliasify });
config.component = defaults(config.component, {
pkgName: pkg.name,
dependencies: pkg.deps,
name: name,
src: 'src',
... | [
"function",
"initTasks",
"(",
"gulp",
",",
"config",
")",
"{",
"var",
"pkg",
"=",
"readPackageJSON",
"(",
")",
";",
"var",
"name",
"=",
"capitalize",
"(",
"camelCase",
"(",
"config",
".",
"component",
".",
"pkgName",
"||",
"pkg",
".",
"name",
")",
")",... | This package exports a function that binds tasks to a gulp instance
based on the provided config. | [
"This",
"package",
"exports",
"a",
"function",
"that",
"binds",
"tasks",
"to",
"a",
"gulp",
"instance",
"based",
"on",
"the",
"provided",
"config",
"."
] | 8a6d636b72fcb10ecd9d633343193923d7447d8d | https://github.com/JedWatson/react-component-gulp-tasks/blob/8a6d636b72fcb10ecd9d633343193923d7447d8d/index.js#L22-L71 | train |
stdarg/tcp-port-used | index.js | makeOptionsObj | function makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs) {
var opts = {};
opts.port = port;
opts.host = host;
opts.inUse = inUse;
opts.retryTimeMs = retryTimeMs;
opts.timeOutMs = timeOutMs;
return opts;
} | javascript | function makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs) {
var opts = {};
opts.port = port;
opts.host = host;
opts.inUse = inUse;
opts.retryTimeMs = retryTimeMs;
opts.timeOutMs = timeOutMs;
return opts;
} | [
"function",
"makeOptionsObj",
"(",
"port",
",",
"host",
",",
"inUse",
",",
"retryTimeMs",
",",
"timeOutMs",
")",
"{",
"var",
"opts",
"=",
"{",
"}",
";",
"opts",
".",
"port",
"=",
"port",
";",
"opts",
".",
"host",
"=",
"host",
";",
"opts",
".",
"inU... | Creates an options object from all the possible arguments
@private
@param {Number} port a valid TCP port number
@param {String} host The DNS name or IP address.
@param {Boolean} status The desired in use status to wait for: false === not in use, true === in use
@param {Number} retryTimeMs the retry interval in millisec... | [
"Creates",
"an",
"options",
"object",
"from",
"all",
"the",
"possible",
"arguments"
] | 23356dede7d2bb198cc07f47215d763c225a96c8 | https://github.com/stdarg/tcp-port-used/blob/23356dede7d2bb198cc07f47215d763c225a96c8/index.js#L47-L55 | train |
senecajs/seneca-auth | lib/hapi-auth.js | cmd_logout | function cmd_logout (msg, respond) {
var req = msg.req$
// get token from request
req.seneca.act("role: 'auth', get: 'token'", {tokenkey: options.tokenkey}, function (err, clienttoken) {
if (err) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respon... | javascript | function cmd_logout (msg, respond) {
var req = msg.req$
// get token from request
req.seneca.act("role: 'auth', get: 'token'", {tokenkey: options.tokenkey}, function (err, clienttoken) {
if (err) {
return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respon... | [
"function",
"cmd_logout",
"(",
"msg",
",",
"respond",
")",
"{",
"var",
"req",
"=",
"msg",
".",
"req$",
"// get token from request",
"req",
".",
"seneca",
".",
"act",
"(",
"\"role: 'auth', get: 'token'\"",
",",
"{",
"tokenkey",
":",
"options",
".",
"tokenkey",
... | LOGIN END LOGOUT START | [
"LOGIN",
"END",
"LOGOUT",
"START"
] | 537716d2a07c9be6e3aa5ae6529929704c97338b | https://github.com/senecajs/seneca-auth/blob/537716d2a07c9be6e3aa5ae6529929704c97338b/lib/hapi-auth.js#L146-L177 | train |
jonschlinkert/extract-comments | index.js | extract | function extract(str, options, tranformFn) {
let extractor = new Extractor(options, tranformFn);
return extractor.extract(str);
} | javascript | function extract(str, options, tranformFn) {
let extractor = new Extractor(options, tranformFn);
return extractor.extract(str);
} | [
"function",
"extract",
"(",
"str",
",",
"options",
",",
"tranformFn",
")",
"{",
"let",
"extractor",
"=",
"new",
"Extractor",
"(",
"options",
",",
"tranformFn",
")",
";",
"return",
"extractor",
".",
"extract",
"(",
"str",
")",
";",
"}"
] | Extract comments from the given `string`.
```js
const extract = require('extract-comments');
console.log(extract(string, options));
```
@param {String} `string`
@param {Object} `options` Pass `first: true` to return after the first comment is found.
@param {Function} `tranformFn` (optional) Tranform function to modify... | [
"Extract",
"comments",
"from",
"the",
"given",
"string",
"."
] | cc42e9f52a2502c6654d435e91e41ebebfbef4b2 | https://github.com/jonschlinkert/extract-comments/blob/cc42e9f52a2502c6654d435e91e41ebebfbef4b2/index.js#L26-L29 | train |
stefanjudis/grunt-photobox | tasks/lib/photobox.js | function( grunt, options, callback ) {
this.callback = callback;
this.diffCount = 0;
this.grunt = grunt;
this.options = options;
this.options.indexPath = this.getIndexPath();
this.pictureCount = 0;
if ( typeof options.template === 'string' ) {
this.template... | javascript | function( grunt, options, callback ) {
this.callback = callback;
this.diffCount = 0;
this.grunt = grunt;
this.options = options;
this.options.indexPath = this.getIndexPath();
this.pictureCount = 0;
if ( typeof options.template === 'string' ) {
this.template... | [
"function",
"(",
"grunt",
",",
"options",
",",
"callback",
")",
"{",
"this",
".",
"callback",
"=",
"callback",
";",
"this",
".",
"diffCount",
"=",
"0",
";",
"this",
".",
"grunt",
"=",
"grunt",
";",
"this",
".",
"options",
"=",
"options",
";",
"this",... | Constructor for PhotoBox
@param {Object} grunt grunt
@param {Object} options plugin options
@param {Function} callback callback
@tested | [
"Constructor",
"for",
"PhotoBox"
] | 9d91025d554a997953deb655de808b40399bc805 | https://github.com/stefanjudis/grunt-photobox/blob/9d91025d554a997953deb655de808b40399bc805/tasks/lib/photobox.js#L26-L42 | train | |
asakusuma/ember-spaniel | index.js | function(treeType) {
if (treeType === 'vendor') {
// The treeForVendor returns a different value based on whether or not
// this addon is a nested dependency
return caclculateCacheKeyForTree(treeType, this, [!this.parent.parent]);
} else {
return this._super.cacheKeyForTree.call(this, tr... | javascript | function(treeType) {
if (treeType === 'vendor') {
// The treeForVendor returns a different value based on whether or not
// this addon is a nested dependency
return caclculateCacheKeyForTree(treeType, this, [!this.parent.parent]);
} else {
return this._super.cacheKeyForTree.call(this, tr... | [
"function",
"(",
"treeType",
")",
"{",
"if",
"(",
"treeType",
"===",
"'vendor'",
")",
"{",
"// The treeForVendor returns a different value based on whether or not",
"// this addon is a nested dependency",
"return",
"caclculateCacheKeyForTree",
"(",
"treeType",
",",
"this",
",... | ember-rollup implements a custom treeForVendor hook, we restore the caching for that hook here | [
"ember",
"-",
"rollup",
"implements",
"a",
"custom",
"treeForVendor",
"hook",
"we",
"restore",
"the",
"caching",
"for",
"that",
"hook",
"here"
] | 26bb0917eebf710e662199cc1c2cc5c4eb37c42e | https://github.com/asakusuma/ember-spaniel/blob/26bb0917eebf710e662199cc1c2cc5c4eb37c42e/index.js#L15-L23 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(elem) {
this.getOffset._offset = $(elem).offset();
if (Garnish.$scrollContainer[0] !== Garnish.$win[0]) {
this.getOffset._offset.top += Garnish.$scrollContainer.scrollTop();
this.getOffset._offset.left += Garnish.$scrollContainer.scrollLeft();
}
return ... | javascript | function(elem) {
this.getOffset._offset = $(elem).offset();
if (Garnish.$scrollContainer[0] !== Garnish.$win[0]) {
this.getOffset._offset.top += Garnish.$scrollContainer.scrollTop();
this.getOffset._offset.left += Garnish.$scrollContainer.scrollLeft();
}
return ... | [
"function",
"(",
"elem",
")",
"{",
"this",
".",
"getOffset",
".",
"_offset",
"=",
"$",
"(",
"elem",
")",
".",
"offset",
"(",
")",
";",
"if",
"(",
"Garnish",
".",
"$scrollContainer",
"[",
"0",
"]",
"!==",
"Garnish",
".",
"$win",
"[",
"0",
"]",
")"... | Returns the offset of an element within the scroll container, whether that's the window or something else | [
"Returns",
"the",
"offset",
"of",
"an",
"element",
"within",
"the",
"scroll",
"container",
"whether",
"that",
"s",
"the",
"window",
"or",
"something",
"else"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L300-L309 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(source, target) {
var $source = $(source),
$target = $(target);
$target.css({
fontFamily: $source.css('fontFamily'),
fontSize: $source.css('fontSize'),
fontWeight: $source.css('fontWeight'),
letterSpacing: $source.css('letterSpacing')... | javascript | function(source, target) {
var $source = $(source),
$target = $(target);
$target.css({
fontFamily: $source.css('fontFamily'),
fontSize: $source.css('fontSize'),
fontWeight: $source.css('fontWeight'),
letterSpacing: $source.css('letterSpacing')... | [
"function",
"(",
"source",
",",
"target",
")",
"{",
"var",
"$source",
"=",
"$",
"(",
"source",
")",
",",
"$target",
"=",
"$",
"(",
"target",
")",
";",
"$target",
".",
"css",
"(",
"{",
"fontFamily",
":",
"$source",
".",
"css",
"(",
"'fontFamily'",
"... | Copies text styles from one element to another.
@param {object} source The source element. Can be either an actual element or a jQuery collection.
@param {object} target The target element. Can be either an actual element or a jQuery collection. | [
"Copies",
"text",
"styles",
"from",
"one",
"element",
"to",
"another",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L360-L376 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function() {
Garnish.getBodyScrollTop._scrollTop = document.body.scrollTop;
if (Garnish.getBodyScrollTop._scrollTop < 0) {
Garnish.getBodyScrollTop._scrollTop = 0;
}
else {
Garnish.getBodyScrollTop._maxScrollTop = Garnish.$bod.outerHeight() - Garnish.$win.height(... | javascript | function() {
Garnish.getBodyScrollTop._scrollTop = document.body.scrollTop;
if (Garnish.getBodyScrollTop._scrollTop < 0) {
Garnish.getBodyScrollTop._scrollTop = 0;
}
else {
Garnish.getBodyScrollTop._maxScrollTop = Garnish.$bod.outerHeight() - Garnish.$win.height(... | [
"function",
"(",
")",
"{",
"Garnish",
".",
"getBodyScrollTop",
".",
"_scrollTop",
"=",
"document",
".",
"body",
".",
"scrollTop",
";",
"if",
"(",
"Garnish",
".",
"getBodyScrollTop",
".",
"_scrollTop",
"<",
"0",
")",
"{",
"Garnish",
".",
"getBodyScrollTop",
... | Returns the body's real scrollTop, discarding any window banding in Safari.
@return {number} | [
"Returns",
"the",
"body",
"s",
"real",
"scrollTop",
"discarding",
"any",
"window",
"banding",
"in",
"Safari",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L383-L398 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(container, elem) {
var $elem;
if (typeof elem === 'undefined') {
$elem = $(container);
$container = $elem.scrollParent();
}
else {
var $container = $(container);
$elem = $(elem);
}
if ($container.prop('nodeName') ... | javascript | function(container, elem) {
var $elem;
if (typeof elem === 'undefined') {
$elem = $(container);
$container = $elem.scrollParent();
}
else {
var $container = $(container);
$elem = $(elem);
}
if ($container.prop('nodeName') ... | [
"function",
"(",
"container",
",",
"elem",
")",
"{",
"var",
"$elem",
";",
"if",
"(",
"typeof",
"elem",
"===",
"'undefined'",
")",
"{",
"$elem",
"=",
"$",
"(",
"container",
")",
";",
"$container",
"=",
"$elem",
".",
"scrollParent",
"(",
")",
";",
"}",... | Scrolls a container element to an element within it.
@param {object} container Either an actual element or a jQuery collection.
@param {object} elem Either an actual element or a jQuery collection. | [
"Scrolls",
"a",
"container",
"element",
"to",
"an",
"element",
"within",
"it",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L434-L490 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(elem, prop) {
var $elem = $(elem);
if (!prop) {
prop = 'margin-left';
}
var startingPoint = parseInt($elem.css(prop));
if (isNaN(startingPoint)) {
startingPoint = 0;
}
for (var i = 0; i <= Garnish.SHAKE_STEPS; i++) {
... | javascript | function(elem, prop) {
var $elem = $(elem);
if (!prop) {
prop = 'margin-left';
}
var startingPoint = parseInt($elem.css(prop));
if (isNaN(startingPoint)) {
startingPoint = 0;
}
for (var i = 0; i <= Garnish.SHAKE_STEPS; i++) {
... | [
"function",
"(",
"elem",
",",
"prop",
")",
"{",
"var",
"$elem",
"=",
"$",
"(",
"elem",
")",
";",
"if",
"(",
"!",
"prop",
")",
"{",
"prop",
"=",
"'margin-left'",
";",
"}",
"var",
"startingPoint",
"=",
"parseInt",
"(",
"$elem",
".",
"css",
"(",
"pr... | Shakes an element.
@param {object} elem Either an actual element or a jQuery collection.
@param {string} prop The property that should be adjusted (default is 'margin-left'). | [
"Shakes",
"an",
"element",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L501-L522 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(container) {
var postData = {},
arrayInputCounters = {},
$inputs = Garnish.findInputs(container);
var inputName;
for (var i = 0; i < $inputs.length; i++) {
var $input = $inputs.eq(i);
if ($input.prop('disabled')) {
conti... | javascript | function(container) {
var postData = {},
arrayInputCounters = {},
$inputs = Garnish.findInputs(container);
var inputName;
for (var i = 0; i < $inputs.length; i++) {
var $input = $inputs.eq(i);
if ($input.prop('disabled')) {
conti... | [
"function",
"(",
"container",
")",
"{",
"var",
"postData",
"=",
"{",
"}",
",",
"arrayInputCounters",
"=",
"{",
"}",
",",
"$inputs",
"=",
"Garnish",
".",
"findInputs",
"(",
"container",
")",
";",
"var",
"inputName",
";",
"for",
"(",
"var",
"i",
"=",
"... | Returns the post data within a container.
@param {object} container
@return {array} | [
"Returns",
"the",
"post",
"data",
"within",
"a",
"container",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L606-L657 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(ev) {
ev.preventDefault();
this.realMouseX = ev.pageX;
this.realMouseY = ev.pageY;
if (this.settings.axis !== Garnish.Y_AXIS) {
this.mouseX = ev.pageX;
}
if (this.settings.axis !== Garnish.X_AXIS) {
this.... | javascript | function(ev) {
ev.preventDefault();
this.realMouseX = ev.pageX;
this.realMouseY = ev.pageY;
if (this.settings.axis !== Garnish.Y_AXIS) {
this.mouseX = ev.pageX;
}
if (this.settings.axis !== Garnish.X_AXIS) {
this.... | [
"function",
"(",
"ev",
")",
"{",
"ev",
".",
"preventDefault",
"(",
")",
";",
"this",
".",
"realMouseX",
"=",
"ev",
".",
"pageX",
";",
"this",
".",
"realMouseY",
"=",
"ev",
".",
"pageY",
";",
"if",
"(",
"this",
".",
"settings",
".",
"axis",
"!==",
... | Handle Mouse Move | [
"Handle",
"Mouse",
"Move"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L1407-L1436 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function($newDraggee) {
if (!$newDraggee.length) {
return;
}
if (!this.settings.collapseDraggees) {
var oldLength = this.$draggee.length;
}
this.$draggee = $(this.$draggee.toArray().concat($newDraggee.toArray()));
... | javascript | function($newDraggee) {
if (!$newDraggee.length) {
return;
}
if (!this.settings.collapseDraggees) {
var oldLength = this.$draggee.length;
}
this.$draggee = $(this.$draggee.toArray().concat($newDraggee.toArray()));
... | [
"function",
"(",
"$newDraggee",
")",
"{",
"if",
"(",
"!",
"$newDraggee",
".",
"length",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"settings",
".",
"collapseDraggees",
")",
"{",
"var",
"oldLength",
"=",
"this",
".",
"$draggee",
".",
"... | Appends additional items to the draggee. | [
"Appends",
"additional",
"items",
"to",
"the",
"draggee",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L1836-L1862 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function() {
this._returningHelpersToDraggees = true;
for (var i = 0; i < this.helpers.length; i++) {
var $draggee = this.$draggee.eq(i),
$helper = this.helpers[i];
$draggee.css({
display: this.draggeeDisplay,
... | javascript | function() {
this._returningHelpersToDraggees = true;
for (var i = 0; i < this.helpers.length; i++) {
var $draggee = this.$draggee.eq(i),
$helper = this.helpers[i];
$draggee.css({
display: this.draggeeDisplay,
... | [
"function",
"(",
")",
"{",
"this",
".",
"_returningHelpersToDraggees",
"=",
"true",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"helpers",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"$draggee",
"=",
"this",
".",
"$dragge... | Return Helpers to Draggees | [
"Return",
"Helpers",
"to",
"Draggees"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L1921-L1945 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function() {
// Has the mouse moved?
if (this.mouseX !== this.lastMouseX || this.mouseY !== this.lastMouseY) {
// Get the new target helper positions
for (this._updateHelperPos._i = 0; this._updateHelperPos._i < this.helpers.length; this._updateHelperPos._i++) {
... | javascript | function() {
// Has the mouse moved?
if (this.mouseX !== this.lastMouseX || this.mouseY !== this.lastMouseY) {
// Get the new target helper positions
for (this._updateHelperPos._i = 0; this._updateHelperPos._i < this.helpers.length; this._updateHelperPos._i++) {
... | [
"function",
"(",
")",
"{",
"// Has the mouse moved?",
"if",
"(",
"this",
".",
"mouseX",
"!==",
"this",
".",
"lastMouseX",
"||",
"this",
".",
"mouseY",
"!==",
"this",
".",
"lastMouseY",
")",
"{",
"// Get the new target helper positions",
"for",
"(",
"this",
"."... | Update Helper Position | [
"Update",
"Helper",
"Position"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2012-L2038 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(i) {
return {
left: this.getHelperTargetX() + (this.settings.helperSpacingX * i),
top: this.getHelperTargetY() + (this.settings.helperSpacingY * i)
};
} | javascript | function(i) {
return {
left: this.getHelperTargetX() + (this.settings.helperSpacingX * i),
top: this.getHelperTargetY() + (this.settings.helperSpacingY * i)
};
} | [
"function",
"(",
"i",
")",
"{",
"return",
"{",
"left",
":",
"this",
".",
"getHelperTargetX",
"(",
")",
"+",
"(",
"this",
".",
"settings",
".",
"helperSpacingX",
"*",
"i",
")",
",",
"top",
":",
"this",
".",
"getHelperTargetY",
"(",
")",
"+",
"(",
"t... | Get the helper position for a draggee helper | [
"Get",
"the",
"helper",
"position",
"for",
"a",
"draggee",
"helper"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2043-L2048 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function() {
for (var i = 0; i < this.helpers.length; i++) {
(function($draggeeHelper) {
$draggeeHelper.velocity('fadeOut', {
duration: Garnish.FX_DURATION,
complete: function() {
$draggeeHelper.r... | javascript | function() {
for (var i = 0; i < this.helpers.length; i++) {
(function($draggeeHelper) {
$draggeeHelper.velocity('fadeOut', {
duration: Garnish.FX_DURATION,
complete: function() {
$draggeeHelper.r... | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"helpers",
".",
"length",
";",
"i",
"++",
")",
"{",
"(",
"function",
"(",
"$draggeeHelper",
")",
"{",
"$draggeeHelper",
".",
"velocity",
"(",
"'fadeOut'",
",",... | Fade Out Helpers | [
"Fade",
"Out",
"Helpers"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2185-L2196 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(bodyContents) {
// Cleanup
this.$main.html('');
if (this.$header) {
this.$hud.removeClass('has-header');
this.$header.remove();
this.$header = null;
}
if (this.$footer) {
this.$hud.remo... | javascript | function(bodyContents) {
// Cleanup
this.$main.html('');
if (this.$header) {
this.$hud.removeClass('has-header');
this.$header.remove();
this.$header = null;
}
if (this.$footer) {
this.$hud.remo... | [
"function",
"(",
"bodyContents",
")",
"{",
"// Cleanup",
"this",
".",
"$main",
".",
"html",
"(",
"''",
")",
";",
"if",
"(",
"this",
".",
"$header",
")",
"{",
"this",
".",
"$hud",
".",
"removeClass",
"(",
"'has-header'",
")",
";",
"this",
".",
"$heade... | Update the body contents | [
"Update",
"the",
"body",
"contents"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L2850-L2882 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function($item, preventScroll) {
if (preventScroll) {
var scrollLeft = Garnish.$doc.scrollLeft(),
scrollTop = Garnish.$doc.scrollTop();
$item.focus();
window.scrollTo(scrollLeft, scrollTop);
}
else {
... | javascript | function($item, preventScroll) {
if (preventScroll) {
var scrollLeft = Garnish.$doc.scrollLeft(),
scrollTop = Garnish.$doc.scrollTop();
$item.focus();
window.scrollTo(scrollLeft, scrollTop);
}
else {
... | [
"function",
"(",
"$item",
",",
"preventScroll",
")",
"{",
"if",
"(",
"preventScroll",
")",
"{",
"var",
"scrollLeft",
"=",
"Garnish",
".",
"$doc",
".",
"scrollLeft",
"(",
")",
",",
"scrollTop",
"=",
"Garnish",
".",
"$doc",
".",
"scrollTop",
"(",
")",
";... | Sets the focus on an item. | [
"Sets",
"the",
"focus",
"on",
"an",
"item",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L5390-L5403 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(ev) {
// ignore right clicks
if (ev.which !== Garnish.PRIMARY_CLICK) {
return;
}
// Enfore the filter
if (this.settings.filter && !$(ev.target).is(this.settings.filter)) {
return;
}
var $item =... | javascript | function(ev) {
// ignore right clicks
if (ev.which !== Garnish.PRIMARY_CLICK) {
return;
}
// Enfore the filter
if (this.settings.filter && !$(ev.target).is(this.settings.filter)) {
return;
}
var $item =... | [
"function",
"(",
"ev",
")",
"{",
"// ignore right clicks",
"if",
"(",
"ev",
".",
"which",
"!==",
"Garnish",
".",
"PRIMARY_CLICK",
")",
"{",
"return",
";",
"}",
"// Enfore the filter",
"if",
"(",
"this",
".",
"settings",
".",
"filter",
"&&",
"!",
"$",
"("... | On Mouse Up | [
"On",
"Mouse",
"Up"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L5454-L5485 | train | |
pixelandtonic/garnishjs | dist/garnish.js | function(item) {
var $handle = $.data(item, 'select-handle');
if ($handle) {
$handle.removeData('select-item');
this.removeAllListeners($handle);
}
$.removeData(item, 'select');
$.removeData(item, 'select-handle');
... | javascript | function(item) {
var $handle = $.data(item, 'select-handle');
if ($handle) {
$handle.removeData('select-item');
this.removeAllListeners($handle);
}
$.removeData(item, 'select');
$.removeData(item, 'select-handle');
... | [
"function",
"(",
"item",
")",
"{",
"var",
"$handle",
"=",
"$",
".",
"data",
"(",
"item",
",",
"'select-handle'",
")",
";",
"if",
"(",
"$handle",
")",
"{",
"$handle",
".",
"removeData",
"(",
"'select-item'",
")",
";",
"this",
".",
"removeAllListeners",
... | Deinitialize an item. | [
"Deinitialize",
"an",
"item",
"."
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/dist/garnish.js#L5716-L5730 | train | |
contentful/contentful-extension-cli | lib/command/update.js | loadCurrentVersion | function loadCurrentVersion (options, context) {
return new Extension(options, context).read()
.then(function (response) {
let version = response.sys.version;
options.version = version;
return options;
});
} | javascript | function loadCurrentVersion (options, context) {
return new Extension(options, context).read()
.then(function (response) {
let version = response.sys.version;
options.version = version;
return options;
});
} | [
"function",
"loadCurrentVersion",
"(",
"options",
",",
"context",
")",
"{",
"return",
"new",
"Extension",
"(",
"options",
",",
"context",
")",
".",
"read",
"(",
")",
".",
"then",
"(",
"function",
"(",
"response",
")",
"{",
"let",
"version",
"=",
"respons... | GETs the extension from the server and extends `options` with the
current version. | [
"GETs",
"the",
"extension",
"from",
"the",
"server",
"and",
"extends",
"options",
"with",
"the",
"current",
"version",
"."
] | 5405485695a0e920eb30a99a43d80bdc8778b5bd | https://github.com/contentful/contentful-extension-cli/blob/5405485695a0e920eb30a99a43d80bdc8778b5bd/lib/command/update.js#L58-L66 | train |
pixelandtonic/garnishjs | gulpfile.js | function(err) {
notify.onError({
title: "Garnish",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
console.log( 'plumber error!' );
this.emit('end');
} | javascript | function(err) {
notify.onError({
title: "Garnish",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
console.log( 'plumber error!' );
this.emit('end');
} | [
"function",
"(",
"err",
")",
"{",
"notify",
".",
"onError",
"(",
"{",
"title",
":",
"\"Garnish\"",
",",
"message",
":",
"\"Error: <%= error.message %>\"",
",",
"sound",
":",
"\"Beep\"",
"}",
")",
"(",
"err",
")",
";",
"console",
".",
"log",
"(",
"'plumbe... | error notification settings for plumber | [
"error",
"notification",
"settings",
"for",
"plumber"
] | 3e57331081c277eeac9a022feeadac5da3f4a2f9 | https://github.com/pixelandtonic/garnishjs/blob/3e57331081c277eeac9a022feeadac5da3f4a2f9/gulpfile.js#L28-L39 | train | |
dylang/random-puppy | index.js | all | function all(subreddit) {
const eventEmitter = new EventEmitter();
function emitRandomImage(subreddit) {
randomPuppy(subreddit).then(imageUrl => {
eventEmitter.emit('data', imageUrl + '#' + subreddit);
if (eventEmitter.listeners('data').length) {
setTimeout(() =>... | javascript | function all(subreddit) {
const eventEmitter = new EventEmitter();
function emitRandomImage(subreddit) {
randomPuppy(subreddit).then(imageUrl => {
eventEmitter.emit('data', imageUrl + '#' + subreddit);
if (eventEmitter.listeners('data').length) {
setTimeout(() =>... | [
"function",
"all",
"(",
"subreddit",
")",
"{",
"const",
"eventEmitter",
"=",
"new",
"EventEmitter",
"(",
")",
";",
"function",
"emitRandomImage",
"(",
"subreddit",
")",
"{",
"randomPuppy",
"(",
"subreddit",
")",
".",
"then",
"(",
"imageUrl",
"=>",
"{",
"ev... | silly feature to play with observables | [
"silly",
"feature",
"to",
"play",
"with",
"observables"
] | cf003bea00816ae03fd368bbeb7d3fbab6f2002b | https://github.com/dylang/random-puppy/blob/cf003bea00816ae03fd368bbeb7d3fbab6f2002b/index.js#L37-L51 | train |
punkave/mongo-dump-stream | index.js | function(dbOrUri, stream, callback) {
if (arguments.length === 2) {
callback = stream;
stream = undefined;
}
if (!stream) {
stream = process.stdout;
}
var db;
var out = stream;
var endOfCollection = crypto.pseudoRandomBytes(8).toString('base64');
write({
type: 'mo... | javascript | function(dbOrUri, stream, callback) {
if (arguments.length === 2) {
callback = stream;
stream = undefined;
}
if (!stream) {
stream = process.stdout;
}
var db;
var out = stream;
var endOfCollection = crypto.pseudoRandomBytes(8).toString('base64');
write({
type: 'mo... | [
"function",
"(",
"dbOrUri",
",",
"stream",
",",
"callback",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"callback",
"=",
"stream",
";",
"stream",
"=",
"undefined",
";",
"}",
"if",
"(",
"!",
"stream",
")",
"{",
"stream",
"... | If you leave out "stream" it'll be stdout | [
"If",
"you",
"leave",
"out",
"stream",
"it",
"ll",
"be",
"stdout"
] | ef0edec544ebd727b5376c8bac06f0f967a6d1c7 | https://github.com/punkave/mongo-dump-stream/blob/ef0edec544ebd727b5376c8bac06f0f967a6d1c7/index.js#L16-L122 | train | |
wooorm/markdown-escapes | index.js | escapes | function escapes(options) {
var settings = options || {}
if (settings.commonmark) {
return commonmark
}
return settings.gfm ? gfm : defaults
} | javascript | function escapes(options) {
var settings = options || {}
if (settings.commonmark) {
return commonmark
}
return settings.gfm ? gfm : defaults
} | [
"function",
"escapes",
"(",
"options",
")",
"{",
"var",
"settings",
"=",
"options",
"||",
"{",
"}",
"if",
"(",
"settings",
".",
"commonmark",
")",
"{",
"return",
"commonmark",
"}",
"return",
"settings",
".",
"gfm",
"?",
"gfm",
":",
"defaults",
"}"
] | Get markdown escapes. | [
"Get",
"markdown",
"escapes",
"."
] | 129e65017ee4ac1eb1ed7bc2e0160ed3bbc473d8 | https://github.com/wooorm/markdown-escapes/blob/129e65017ee4ac1eb1ed7bc2e0160ed3bbc473d8/index.js#L49-L57 | train |
agirorn/node-hid-stream | lib/keyboard-parser.js | parseModifiers | function parseModifiers(packet, bits) {
/* eslint-disable no-bitwise */
/* eslint-disable no-param-reassign */
packet.modifiers.l_control = ((bits & 1) !== 0);
packet.modifiers.l_shift = ((bits & 2) !== 0);
packet.modifiers.l_alt = ((bits & 4) !== 0);
packet.modifiers.l_meta = ((bits & 8) !== 0);
packet.m... | javascript | function parseModifiers(packet, bits) {
/* eslint-disable no-bitwise */
/* eslint-disable no-param-reassign */
packet.modifiers.l_control = ((bits & 1) !== 0);
packet.modifiers.l_shift = ((bits & 2) !== 0);
packet.modifiers.l_alt = ((bits & 4) !== 0);
packet.modifiers.l_meta = ((bits & 8) !== 0);
packet.m... | [
"function",
"parseModifiers",
"(",
"packet",
",",
"bits",
")",
"{",
"/* eslint-disable no-bitwise */",
"/* eslint-disable no-param-reassign */",
"packet",
".",
"modifiers",
".",
"l_control",
"=",
"(",
"(",
"bits",
"&",
"1",
")",
"!==",
"0",
")",
";",
"packet",
"... | Convert modifier key bits into
array of human-readable identifiers | [
"Convert",
"modifier",
"key",
"bits",
"into",
"array",
"of",
"human",
"-",
"readable",
"identifiers"
] | 3cbb1e0f85fc920f83618cd6c929d811df9b230c | https://github.com/agirorn/node-hid-stream/blob/3cbb1e0f85fc920f83618cd6c929d811df9b230c/lib/keyboard-parser.js#L22-L35 | train |
agirorn/node-hid-stream | lib/keyboard-parser.js | parseKeyCodes | function parseKeyCodes(arr, keys) {
if (typeof keys !== 'object') { return false; }
keys.forEach((key) => {
if (key > 3) { arr.keyCodes.push(key); }
});
return true;
} | javascript | function parseKeyCodes(arr, keys) {
if (typeof keys !== 'object') { return false; }
keys.forEach((key) => {
if (key > 3) { arr.keyCodes.push(key); }
});
return true;
} | [
"function",
"parseKeyCodes",
"(",
"arr",
",",
"keys",
")",
"{",
"if",
"(",
"typeof",
"keys",
"!==",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"keys",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"{",
"if",
"(",
"key",
">",
"3",
")",
"{",
... | Slice HID keycodes into separate array | [
"Slice",
"HID",
"keycodes",
"into",
"separate",
"array"
] | 3cbb1e0f85fc920f83618cd6c929d811df9b230c | https://github.com/agirorn/node-hid-stream/blob/3cbb1e0f85fc920f83618cd6c929d811df9b230c/lib/keyboard-parser.js#L41-L49 | train |
agirorn/node-hid-stream | lib/keyboard-parser.js | parseErrorState | function parseErrorState(packet, state) {
let states = 0;
state.forEach((s) => {
if (s === 1) {
states += 1;
}
});
if (states >= 6) {
packet.errorStatus = true; // eslint-disable-line no-param-reassign
}
} | javascript | function parseErrorState(packet, state) {
let states = 0;
state.forEach((s) => {
if (s === 1) {
states += 1;
}
});
if (states >= 6) {
packet.errorStatus = true; // eslint-disable-line no-param-reassign
}
} | [
"function",
"parseErrorState",
"(",
"packet",
",",
"state",
")",
"{",
"let",
"states",
"=",
"0",
";",
"state",
".",
"forEach",
"(",
"(",
"s",
")",
"=>",
"{",
"if",
"(",
"s",
"===",
"1",
")",
"{",
"states",
"+=",
"1",
";",
"}",
"}",
")",
";",
... | Detect keyboard rollover error
This occurs when the user has pressed too many keys for the
particular device to handle | [
"Detect",
"keyboard",
"rollover",
"error",
"This",
"occurs",
"when",
"the",
"user",
"has",
"pressed",
"too",
"many",
"keys",
"for",
"the",
"particular",
"device",
"to",
"handle"
] | 3cbb1e0f85fc920f83618cd6c929d811df9b230c | https://github.com/agirorn/node-hid-stream/blob/3cbb1e0f85fc920f83618cd6c929d811df9b230c/lib/keyboard-parser.js#L222-L234 | train |
seanmonstar/intel | lib/record.js | stack | function stack(e) {
return {
toString: function() {
// first line is err.message, which we already show, so start from
// second line
return e.stack.substr(e.stack.indexOf('\n'));
},
toJSON: function() {
return stacktrace.parse(e);
}
};
} | javascript | function stack(e) {
return {
toString: function() {
// first line is err.message, which we already show, so start from
// second line
return e.stack.substr(e.stack.indexOf('\n'));
},
toJSON: function() {
return stacktrace.parse(e);
}
};
} | [
"function",
"stack",
"(",
"e",
")",
"{",
"return",
"{",
"toString",
":",
"function",
"(",
")",
"{",
"// first line is err.message, which we already show, so start from",
"// second line",
"return",
"e",
".",
"stack",
".",
"substr",
"(",
"e",
".",
"stack",
".",
"... | stack formatter helper | [
"stack",
"formatter",
"helper"
] | 65e77bc379924fef0dda1f75adc611325028381d | https://github.com/seanmonstar/intel/blob/65e77bc379924fef0dda1f75adc611325028381d/lib/record.js#L20-L31 | train |
watson/original-url | index.js | getFirstHeader | function getFirstHeader (req, header) {
const value = req.headers[header]
return (Array.isArray(value) ? value[0] : value).split(', ')[0]
} | javascript | function getFirstHeader (req, header) {
const value = req.headers[header]
return (Array.isArray(value) ? value[0] : value).split(', ')[0]
} | [
"function",
"getFirstHeader",
"(",
"req",
",",
"header",
")",
"{",
"const",
"value",
"=",
"req",
".",
"headers",
"[",
"header",
"]",
"return",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
"?",
"value",
"[",
"0",
"]",
":",
"value",
")",
".",
"sp... | In case there's more than one header of a given name, we want the first one as it should be the one that was added by the first proxy in the chain | [
"In",
"case",
"there",
"s",
"more",
"than",
"one",
"header",
"of",
"a",
"given",
"name",
"we",
"want",
"the",
"first",
"one",
"as",
"it",
"should",
"be",
"the",
"one",
"that",
"was",
"added",
"by",
"the",
"first",
"proxy",
"in",
"the",
"chain"
] | 4447ad715030695b5a9627765e211e018e99c38c | https://github.com/watson/original-url/blob/4447ad715030695b5a9627765e211e018e99c38c/index.js#L88-L91 | train |
brunschgi/terrificjs | src/Application.js | Application | function Application(ctx, config) {
// validate params
if (!ctx && !config) {
// both empty
ctx = document;
config = {};
}
else if (Utils.isNode(config)) {
// reverse order of arguments
var tmpConfig = config;
config = ctx;
ctx = tmpConfig;
}
else if (!Utils.isNode(ctx) && !config) {
// only confi... | javascript | function Application(ctx, config) {
// validate params
if (!ctx && !config) {
// both empty
ctx = document;
config = {};
}
else if (Utils.isNode(config)) {
// reverse order of arguments
var tmpConfig = config;
config = ctx;
ctx = tmpConfig;
}
else if (!Utils.isNode(ctx) && !config) {
// only confi... | [
"function",
"Application",
"(",
"ctx",
",",
"config",
")",
"{",
"// validate params",
"if",
"(",
"!",
"ctx",
"&&",
"!",
"config",
")",
"{",
"// both empty",
"ctx",
"=",
"document",
";",
"config",
"=",
"{",
"}",
";",
"}",
"else",
"if",
"(",
"Utils",
"... | Responsible for application-wide issues such as the creation of modules.
@author Remo Brunschwiler
@namespace T
@class Application
@constructor
@param {Node} ctx
The context node
@param {Object} config
The configuration
/* global Sandbox, Utils, Module | [
"Responsible",
"for",
"application",
"-",
"wide",
"issues",
"such",
"as",
"the",
"creation",
"of",
"modules",
"."
] | 4e9055ffb99bec24b2014c9389c20682a23a209f | https://github.com/brunschgi/terrificjs/blob/4e9055ffb99bec24b2014c9389c20682a23a209f/src/Application.js#L28-L97 | train |
Zimbra-Community/js-zimbra | lib/utils/preauth.js | function (options, callback) {
LOG.debug('preauth#createPreauth called');
LOG.debug('Validating options');
try {
options = new preauthOptions.CreatePreauth().validate(options);
} catch (err) {
if (err.name === 'InvalidOption') {
LOG.error('In... | javascript | function (options, callback) {
LOG.debug('preauth#createPreauth called');
LOG.debug('Validating options');
try {
options = new preauthOptions.CreatePreauth().validate(options);
} catch (err) {
if (err.name === 'InvalidOption') {
LOG.error('In... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"LOG",
".",
"debug",
"(",
"'preauth#createPreauth called'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating options'",
")",
";",
"try",
"{",
"options",
"=",
"new",
"preauthOptions",
".",
"CreatePreauth",
... | Create a preauth value
@param {CreatePreauthOptions} options options for createPreauth
@param {callback} callback run with optional error (see throws) and
preauth key
@throws {InvalidOptionError}
@throws {SystemError} | [
"Create",
"a",
"preauth",
"value"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/utils/preauth.js#L25-L97 | train | |
NathanaelA/nativescript-liveedit | liveedit.ios.js | loadCss | function loadCss() {
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, application.cssFile);
var applicationCss;
if (FSA.fileExists(cssFileName)) {
FSA.readText(cssFileName, function (r) { applicationCss = r; });
//noinspection JSUnusedAssignment
application.cssSelec... | javascript | function loadCss() {
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, application.cssFile);
var applicationCss;
if (FSA.fileExists(cssFileName)) {
FSA.readText(cssFileName, function (r) { applicationCss = r; });
//noinspection JSUnusedAssignment
application.cssSelec... | [
"function",
"loadCss",
"(",
")",
"{",
"var",
"cssFileName",
"=",
"fs",
".",
"path",
".",
"join",
"(",
"fs",
".",
"knownFolders",
".",
"currentApp",
"(",
")",
".",
"path",
",",
"application",
".",
"cssFile",
")",
";",
"var",
"applicationCss",
";",
"if",... | This is the loadCss helper function to replace the one on Application | [
"This",
"is",
"the",
"loadCss",
"helper",
"function",
"to",
"replace",
"the",
"one",
"on",
"Application"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/liveedit.ios.js#L354-L373 | train |
NathanaelA/nativescript-liveedit | liveedit.ios.js | loadPageCss | function loadPageCss(cssFile) {
var cssFileName;
// Eliminate the ./ on the file if present so that we can add the full path
if (cssFile.startsWith("./")) {
cssFile = cssFile.substring(2);
}
if (cssFile.startsWith(UpdaterSingleton.currentAppPath())) {
cssFileName = cssFile;
} e... | javascript | function loadPageCss(cssFile) {
var cssFileName;
// Eliminate the ./ on the file if present so that we can add the full path
if (cssFile.startsWith("./")) {
cssFile = cssFile.substring(2);
}
if (cssFile.startsWith(UpdaterSingleton.currentAppPath())) {
cssFileName = cssFile;
} e... | [
"function",
"loadPageCss",
"(",
"cssFile",
")",
"{",
"var",
"cssFileName",
";",
"// Eliminate the ./ on the file if present so that we can add the full path",
"if",
"(",
"cssFile",
".",
"startsWith",
"(",
"\"./\"",
")",
")",
"{",
"cssFile",
"=",
"cssFile",
".",
"subst... | Override a single page's css
@param cssFile | [
"Override",
"a",
"single",
"page",
"s",
"css"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/liveedit.ios.js#L379-L407 | train |
Zimbra-Community/js-zimbra | lib/api/response.js | ResponseApi | function ResponseApi(constructorOptions) {
LOG.debug('Instantiating new response object');
LOG.debug('Validating options');
try {
this.options =
new responseOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
... | javascript | function ResponseApi(constructorOptions) {
LOG.debug('Instantiating new response object');
LOG.debug('Validating options');
try {
this.options =
new responseOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
... | [
"function",
"ResponseApi",
"(",
"constructorOptions",
")",
"{",
"LOG",
".",
"debug",
"(",
"'Instantiating new response object'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating options'",
")",
";",
"try",
"{",
"this",
".",
"options",
"=",
"new",
"responseOption... | Response-handling API
@param {ResponseConstructorOptions} constructorOptions
Options for the constructor
@constructor
@throws {NoBatchResponse}
@throws {InvalidOptionError} | [
"Response",
"-",
"handling",
"API"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/api/response.js#L22-L45 | train |
lirown/graphql-custom-directive | src/index.js | wrapFieldsWithMiddleware | function wrapFieldsWithMiddleware(type, deepWrap = true, typeMet = {}) {
if (!type) {
return;
}
let fields = type._fields;
typeMet[type.name] = true;
for (let label in fields) {
let field = fields[label];
if (field && !typeMet[field.type.name]) {
if (!!field && typeof field == 'object') {
... | javascript | function wrapFieldsWithMiddleware(type, deepWrap = true, typeMet = {}) {
if (!type) {
return;
}
let fields = type._fields;
typeMet[type.name] = true;
for (let label in fields) {
let field = fields[label];
if (field && !typeMet[field.type.name]) {
if (!!field && typeof field == 'object') {
... | [
"function",
"wrapFieldsWithMiddleware",
"(",
"type",
",",
"deepWrap",
"=",
"true",
",",
"typeMet",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"!",
"type",
")",
"{",
"return",
";",
"}",
"let",
"fields",
"=",
"type",
".",
"_fields",
";",
"typeMet",
"[",
"type... | Scanning the shema and wrapping the resolve of each field with the support
of the graphql custom directives resolve execution | [
"Scanning",
"the",
"shema",
"and",
"wrapping",
"the",
"resolve",
"of",
"each",
"field",
"with",
"the",
"support",
"of",
"the",
"graphql",
"custom",
"directives",
"resolve",
"execution"
] | 90b5a3641fda77cd484936a1e79909938955ee09 | https://github.com/lirown/graphql-custom-directive/blob/90b5a3641fda77cd484936a1e79909938955ee09/src/index.js#L144-L173 | train |
NathanaelA/nativescript-liveedit | liveedit.android.js | reloadPage | function reloadPage(page, isModal) {
if (!LiveEditSingleton.enabled()) {
return;
}
var t = frameCommon.topmost();
if (!t) {
return;
}
if (!page) {
if (!t.currentEntry || !t.currentEntry.entry) {
return;
}
page = t.currentEntry.entry.moduleNa... | javascript | function reloadPage(page, isModal) {
if (!LiveEditSingleton.enabled()) {
return;
}
var t = frameCommon.topmost();
if (!t) {
return;
}
if (!page) {
if (!t.currentEntry || !t.currentEntry.entry) {
return;
}
page = t.currentEntry.entry.moduleNa... | [
"function",
"reloadPage",
"(",
"page",
",",
"isModal",
")",
"{",
"if",
"(",
"!",
"LiveEditSingleton",
".",
"enabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"var",
"t",
"=",
"frameCommon",
".",
"topmost",
"(",
")",
";",
"if",
"(",
"!",
"t",
")",
... | This is a helper function to reload the current page
@param page | [
"This",
"is",
"a",
"helper",
"function",
"to",
"reload",
"the",
"current",
"page"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/liveedit.android.js#L789-L873 | train |
NathanaelA/nativescript-liveedit | support/watcher.js | isWatching | function isWatching(fileName) {
for (var i=0;i<watching.length;i++) {
if (fileName.endsWith(watching[i])) {
return true;
}
}
//noinspection RedundantIfStatementJS
if (fileName.toLowerCase().lastIndexOf("restart.livesync") === (fileName.length - 16)) {
return true;
... | javascript | function isWatching(fileName) {
for (var i=0;i<watching.length;i++) {
if (fileName.endsWith(watching[i])) {
return true;
}
}
//noinspection RedundantIfStatementJS
if (fileName.toLowerCase().lastIndexOf("restart.livesync") === (fileName.length - 16)) {
return true;
... | [
"function",
"isWatching",
"(",
"fileName",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"watching",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"fileName",
".",
"endsWith",
"(",
"watching",
"[",
"i",
"]",
")",
")",
"{",
"r... | isWatching - will respond true if watching this file type.
@param fileName
@returns {boolean} | [
"isWatching",
"-",
"will",
"respond",
"true",
"if",
"watching",
"this",
"file",
"type",
"."
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L206-L221 | train |
NathanaelA/nativescript-liveedit | support/watcher.js | normalPushADB | function normalPushADB(fileName, options, callback) {
if (typeof options === "function") {
callback = options;
options = null;
}
var srcFile = fileName;
if (options && typeof options.srcFile === "string") {
srcFile = options.srcFile;
}
var check = false;
if (options ... | javascript | function normalPushADB(fileName, options, callback) {
if (typeof options === "function") {
callback = options;
options = null;
}
var srcFile = fileName;
if (options && typeof options.srcFile === "string") {
srcFile = options.srcFile;
}
var check = false;
if (options ... | [
"function",
"normalPushADB",
"(",
"fileName",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"\"function\"",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"null",
";",
"}",
"var",
"srcFile",
"=",
"fileName",
... | This runs the adb command so that we can push the file up to the emulator or device
@param fileName
@param options
@param callback | [
"This",
"runs",
"the",
"adb",
"command",
"so",
"that",
"we",
"can",
"push",
"the",
"file",
"up",
"to",
"the",
"emulator",
"or",
"device"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L329-L367 | train |
NathanaelA/nativescript-liveedit | support/watcher.js | getWatcher | function getWatcher(dir) {
return function (event, fileName) {
if (event === "rename") {
verifyWatches();
if (fileName) {
if (!fs.existsSync(dir + fileName)) { return; }
var dirStat;
try {
dirStat = fs.statSync(dir +... | javascript | function getWatcher(dir) {
return function (event, fileName) {
if (event === "rename") {
verifyWatches();
if (fileName) {
if (!fs.existsSync(dir + fileName)) { return; }
var dirStat;
try {
dirStat = fs.statSync(dir +... | [
"function",
"getWatcher",
"(",
"dir",
")",
"{",
"return",
"function",
"(",
"event",
",",
"fileName",
")",
"{",
"if",
"(",
"event",
"===",
"\"rename\"",
")",
"{",
"verifyWatches",
"(",
")",
";",
"if",
"(",
"fileName",
")",
"{",
"if",
"(",
"!",
"fs",
... | This is the watcher callback to verify the file actually changed
@param dir
@returns {Function} | [
"This",
"is",
"the",
"watcher",
"callback",
"to",
"verify",
"the",
"file",
"actually",
"changed"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L616-L673 | train |
NathanaelA/nativescript-liveedit | support/watcher.js | setupWatchers | function setupWatchers(path) {
// We want to track the watchers now and return if we are already watching this folder
if (watchingFolders[path]) { return; }
watchingFolders[path] = fs.watch(path, getWatcher(path + "/"));
watchingFolders[path].on('error', function() { verifyWatches(); });
var fileL... | javascript | function setupWatchers(path) {
// We want to track the watchers now and return if we are already watching this folder
if (watchingFolders[path]) { return; }
watchingFolders[path] = fs.watch(path, getWatcher(path + "/"));
watchingFolders[path].on('error', function() { verifyWatches(); });
var fileL... | [
"function",
"setupWatchers",
"(",
"path",
")",
"{",
"// We want to track the watchers now and return if we are already watching this folder",
"if",
"(",
"watchingFolders",
"[",
"path",
"]",
")",
"{",
"return",
";",
"}",
"watchingFolders",
"[",
"path",
"]",
"=",
"fs",
... | This setups a watcher on a directory
@param path | [
"This",
"setups",
"a",
"watcher",
"on",
"a",
"directory"
] | 40fc852012d36f08d10669d4a79fc7a260a1618d | https://github.com/NathanaelA/nativescript-liveedit/blob/40fc852012d36f08d10669d4a79fc7a260a1618d/support/watcher.js#L679-L714 | train |
Zimbra-Community/js-zimbra | lib/api/communication.js | CommunicationApi | function CommunicationApi(constructorOptions) {
LOG.debug('Instantiating communication API');
LOG.debug('Validating constructor options');
// Sanitize option eventually throwing an InvalidOption
try {
this.options =
new communicationOptions.Constructor().validate(constructorOptio... | javascript | function CommunicationApi(constructorOptions) {
LOG.debug('Instantiating communication API');
LOG.debug('Validating constructor options');
// Sanitize option eventually throwing an InvalidOption
try {
this.options =
new communicationOptions.Constructor().validate(constructorOptio... | [
"function",
"CommunicationApi",
"(",
"constructorOptions",
")",
"{",
"LOG",
".",
"debug",
"(",
"'Instantiating communication API'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating constructor options'",
")",
";",
"// Sanitize option eventually throwing an InvalidOption",
"... | Communications-Handling API
@param {CommunicationConstructorOptions} constructorOptions
Options for constructor
@constructor
@throws {InvalidOptionError} | [
"Communications",
"-",
"Handling",
"API"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/api/communication.js#L27-L59 | train |
Zimbra-Community/js-zimbra | lib/api/request.js | RequestApi | function RequestApi(constructorOptions) {
LOG.debug('Instantiating new Request object');
LOG.debug('Validating options');
try {
this.options =
new requestOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
th... | javascript | function RequestApi(constructorOptions) {
LOG.debug('Instantiating new Request object');
LOG.debug('Validating options');
try {
this.options =
new requestOptions.Constructor().validate(constructorOptions);
} catch (err) {
LOG.error('Received error: %s', err);
th... | [
"function",
"RequestApi",
"(",
"constructorOptions",
")",
"{",
"LOG",
".",
"debug",
"(",
"'Instantiating new Request object'",
")",
";",
"LOG",
".",
"debug",
"(",
"'Validating options'",
")",
";",
"try",
"{",
"this",
".",
"options",
"=",
"new",
"requestOptions",... | Request-handling API
@param {ResponseConstructorOptions} Options for the
constructor
@constructor
@throws {InvalidOptionError} | [
"Request",
"-",
"handling",
"API"
] | dc073847a04da093b848463942731d15d256f00d | https://github.com/Zimbra-Community/js-zimbra/blob/dc073847a04da093b848463942731d15d256f00d/lib/api/request.js#L23-L46 | train |
fent/node-torrent | lib/hasher.js | round | function round(num, dec) {
var pow = Math.pow(10, dec);
return Math.round(num * pow) / pow;
} | javascript | function round(num, dec) {
var pow = Math.pow(10, dec);
return Math.round(num * pow) / pow;
} | [
"function",
"round",
"(",
"num",
",",
"dec",
")",
"{",
"var",
"pow",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"dec",
")",
";",
"return",
"Math",
".",
"round",
"(",
"num",
"*",
"pow",
")",
"/",
"pow",
";",
"}"
] | Rounds a number to given decimal place.
@param {Number} num
@param {Number} dec
@return {Number} | [
"Rounds",
"a",
"number",
"to",
"given",
"decimal",
"place",
"."
] | a6784b78867d3f026a54c0445abf2e18dc82323c | https://github.com/fent/node-torrent/blob/a6784b78867d3f026a54c0445abf2e18dc82323c/lib/hasher.js#L38-L41 | train |
c9/vfs-http-adapter | restful.js | jsonEncoder | function jsonEncoder(input, path) {
var output = new Stream();
output.readable = true;
var first = true;
input.on("data", function (entry) {
if (path) {
entry.href = path + entry.name;
var mime = entry.linkStat ? entry.linkStat.mime : entry.mime;
if (mime && mime.match(/(di... | javascript | function jsonEncoder(input, path) {
var output = new Stream();
output.readable = true;
var first = true;
input.on("data", function (entry) {
if (path) {
entry.href = path + entry.name;
var mime = entry.linkStat ? entry.linkStat.mime : entry.mime;
if (mime && mime.match(/(di... | [
"function",
"jsonEncoder",
"(",
"input",
",",
"path",
")",
"{",
"var",
"output",
"=",
"new",
"Stream",
"(",
")",
";",
"output",
".",
"readable",
"=",
"true",
";",
"var",
"first",
"=",
"true",
";",
"input",
".",
"on",
"(",
"\"data\"",
",",
"function",... | Returns a json stream that wraps input object stream | [
"Returns",
"a",
"json",
"stream",
"that",
"wraps",
"input",
"object",
"stream"
] | 89b1253e0f10c0a2edacd9a69d99cb20f95bfa73 | https://github.com/c9/vfs-http-adapter/blob/89b1253e0f10c0a2edacd9a69d99cb20f95bfa73/restful.js#L26-L61 | train |
TheRusskiy/pusher-redux | lib/pusher-redux.js | function (options) {
var result = {
type: options.actionType
};
if (options.channelName) {
result.channel = options.channelName
}
if (options.eventName) {
result.event = options.eventName
}
if (options.data) {
result.data = options.data
}
if (options.additionalParams) {
result.addi... | javascript | function (options) {
var result = {
type: options.actionType
};
if (options.channelName) {
result.channel = options.channelName
}
if (options.eventName) {
result.event = options.eventName
}
if (options.data) {
result.data = options.data
}
if (options.additionalParams) {
result.addi... | [
"function",
"(",
"options",
")",
"{",
"var",
"result",
"=",
"{",
"type",
":",
"options",
".",
"actionType",
"}",
";",
"if",
"(",
"options",
".",
"channelName",
")",
"{",
"result",
".",
"channel",
"=",
"options",
".",
"channelName",
"}",
"if",
"(",
"o... | create redux action | [
"create",
"redux",
"action"
] | 683a9c3cbdea0d8f0b29f547250c4ab6468bddd6 | https://github.com/TheRusskiy/pusher-redux/blob/683a9c3cbdea0d8f0b29f547250c4ab6468bddd6/lib/pusher-redux.js#L23-L40 | train | |
cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _characterFromEvent | function _characterFromEvent(e) {
// for keypress events we should return the character as is
if (e.type == 'keypress') {
var character = String.fromCharCode(e.which);
// if the shift key is not pressed then it is safe to assume
// that we want the character to be l... | javascript | function _characterFromEvent(e) {
// for keypress events we should return the character as is
if (e.type == 'keypress') {
var character = String.fromCharCode(e.which);
// if the shift key is not pressed then it is safe to assume
// that we want the character to be l... | [
"function",
"_characterFromEvent",
"(",
"e",
")",
"{",
"// for keypress events we should return the character as is",
"if",
"(",
"e",
".",
"type",
"==",
"'keypress'",
")",
"{",
"var",
"character",
"=",
"String",
".",
"fromCharCode",
"(",
"e",
".",
"which",
")",
... | takes the event and returns the key character
@param {Event} e
@return {string} | [
"takes",
"the",
"event",
"and",
"returns",
"the",
"key",
"character"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L180-L217 | train |
cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _eventModifiers | function _eventModifiers(e) {
var modifiers = [];
if (e.shiftKey) {
modifiers.push('shift');
}
if (e.altKey) {
modifiers.push('alt');
}
if (e.ctrlKey) {
modifiers.push('ctrl');
}
if (e.metaKey) {
modifier... | javascript | function _eventModifiers(e) {
var modifiers = [];
if (e.shiftKey) {
modifiers.push('shift');
}
if (e.altKey) {
modifiers.push('alt');
}
if (e.ctrlKey) {
modifiers.push('ctrl');
}
if (e.metaKey) {
modifier... | [
"function",
"_eventModifiers",
"(",
"e",
")",
"{",
"var",
"modifiers",
"=",
"[",
"]",
";",
"if",
"(",
"e",
".",
"shiftKey",
")",
"{",
"modifiers",
".",
"push",
"(",
"'shift'",
")",
";",
"}",
"if",
"(",
"e",
".",
"altKey",
")",
"{",
"modifiers",
"... | takes a key event and figures out what the modifiers are
@param {Event} e
@returns {Array} | [
"takes",
"a",
"key",
"event",
"and",
"figures",
"out",
"what",
"the",
"modifiers",
"are"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L236-L256 | train |
cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _pickBestAction | function _pickBestAction(key, modifiers, action) {
// if no action was picked in we should try to pick the one
// that we think would work best for this key
if (!action) {
action = _getReverseMap()[key] ? 'keydown' : 'keypress';
}
// modifier keys don't work as expe... | javascript | function _pickBestAction(key, modifiers, action) {
// if no action was picked in we should try to pick the one
// that we think would work best for this key
if (!action) {
action = _getReverseMap()[key] ? 'keydown' : 'keypress';
}
// modifier keys don't work as expe... | [
"function",
"_pickBestAction",
"(",
"key",
",",
"modifiers",
",",
"action",
")",
"{",
"// if no action was picked in we should try to pick the one",
"// that we think would work best for this key",
"if",
"(",
"!",
"action",
")",
"{",
"action",
"=",
"_getReverseMap",
"(",
... | picks the best action based on the key combination
@param {string} key - character for key
@param {Array} modifiers
@param {string=} action passed in | [
"picks",
"the",
"best",
"action",
"based",
"on",
"the",
"key",
"combination"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L330-L345 | train |
cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _resetSequences | function _resetSequences(doNotReset) {
doNotReset = doNotReset || {};
var activeSequences = false,
key;
for (key in _sequenceLevels) {
if (doNotReset[key]) {
activeSequences = true;
continue;
}
... | javascript | function _resetSequences(doNotReset) {
doNotReset = doNotReset || {};
var activeSequences = false,
key;
for (key in _sequenceLevels) {
if (doNotReset[key]) {
activeSequences = true;
continue;
}
... | [
"function",
"_resetSequences",
"(",
"doNotReset",
")",
"{",
"doNotReset",
"=",
"doNotReset",
"||",
"{",
"}",
";",
"var",
"activeSequences",
"=",
"false",
",",
"key",
";",
"for",
"(",
"key",
"in",
"_sequenceLevels",
")",
"{",
"if",
"(",
"doNotReset",
"[",
... | resets all sequence counters except for the ones passed in
@param {Object} doNotReset
@returns void | [
"resets",
"all",
"sequence",
"counters",
"except",
"for",
"the",
"ones",
"passed",
"in"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L497-L514 | train |
cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _handleKeyEvent | function _handleKeyEvent(e) {
// normalize e.which for key events
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
if (typeof e.which !== 'number') {
e.which = e.keyCode;
}
var character = _cha... | javascript | function _handleKeyEvent(e) {
// normalize e.which for key events
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
if (typeof e.which !== 'number') {
e.which = e.keyCode;
}
var character = _cha... | [
"function",
"_handleKeyEvent",
"(",
"e",
")",
"{",
"// normalize e.which for key events",
"// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion",
"if",
"(",
"typeof",
"e",
".",
"which",
"!==",
"'number'",
")",
"{",
"e",
".",
"which... | handles a keydown event
@param {Event} e
@returns void | [
"handles",
"a",
"keydown",
"event"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L705-L727 | train |
cozy/cozy-emails | client/plugins/keyboard/js/mousetrap.js | _bindSingle | function _bindSingle(combination, callback, action, sequenceName, level) {
// store a direct mapped reference for use with Mousetrap.trigger
self._directMap[combination + ':' + action] = callback;
// make sure multiple spaces in a row become a single space
combination =... | javascript | function _bindSingle(combination, callback, action, sequenceName, level) {
// store a direct mapped reference for use with Mousetrap.trigger
self._directMap[combination + ':' + action] = callback;
// make sure multiple spaces in a row become a single space
combination =... | [
"function",
"_bindSingle",
"(",
"combination",
",",
"callback",
",",
"action",
",",
"sequenceName",
",",
"level",
")",
"{",
"// store a direct mapped reference for use with Mousetrap.trigger",
"self",
".",
"_directMap",
"[",
"combination",
"+",
"':'",
"+",
"action",
"... | binds a single keyboard combination
@param {string} combination
@param {Function} callback
@param {string=} action
@param {string=} sequenceName - name of sequence if part of sequence
@param {number=} level - what part of the sequence the command is
@returns void | [
"binds",
"a",
"single",
"keyboard",
"combination"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/keyboard/js/mousetrap.js#L820-L861 | train |
cozy/cozy-emails | client/vendor/talkerjs-1.0.1.js | function(remoteWindow, remoteOrigin) {
this.remoteWindow = remoteWindow;
this.remoteOrigin = remoteOrigin;
this.timeout = 3000;
this.handshaken = false;
this.handshake = pinkySwearPromise();
this._id = 0;
this._queue = [];
this._sent = {};
var _this = this;
window.addEventListe... | javascript | function(remoteWindow, remoteOrigin) {
this.remoteWindow = remoteWindow;
this.remoteOrigin = remoteOrigin;
this.timeout = 3000;
this.handshaken = false;
this.handshake = pinkySwearPromise();
this._id = 0;
this._queue = [];
this._sent = {};
var _this = this;
window.addEventListe... | [
"function",
"(",
"remoteWindow",
",",
"remoteOrigin",
")",
"{",
"this",
".",
"remoteWindow",
"=",
"remoteWindow",
";",
"this",
".",
"remoteOrigin",
"=",
"remoteOrigin",
";",
"this",
".",
"timeout",
"=",
"3000",
";",
"this",
".",
"handshaken",
"=",
"false",
... | region Public Methods
Talker
Used to open a communication line between this window and a remote window via postMessage.
@param remoteWindow - The remote `window` object to post/receive messages to/from.
@property {Window} remoteWindow - The remote window object this Talker is communicating with
@property {string} remo... | [
"region",
"Public",
"Methods",
"Talker",
"Used",
"to",
"open",
"a",
"communication",
"line",
"between",
"this",
"window",
"and",
"a",
"remote",
"window",
"via",
"postMessage",
"."
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/vendor/talkerjs-1.0.1.js#L127-L143 | train | |
natefaubion/adt.js | adt.js | function () {
var args = arguments;
var len = names.length;
if (this instanceof ctr) {
if (args.length !== len) {
throw new Error(
'Unexpected number of arguments for ' + ctr.className + ': ' +
'got ' + args.length + ', but need ' + len + '.'
);
... | javascript | function () {
var args = arguments;
var len = names.length;
if (this instanceof ctr) {
if (args.length !== len) {
throw new Error(
'Unexpected number of arguments for ' + ctr.className + ': ' +
'got ' + args.length + ', but need ' + len + '.'
);
... | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
";",
"var",
"len",
"=",
"names",
".",
"length",
";",
"if",
"(",
"this",
"instanceof",
"ctr",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!==",
"len",
")",
"{",
"throw",
"new",
"Error",
... | A record's constructor can be called without `new` and will also throw an error if called with the wrong number of arguments. Its arguments can be curried as long as it isn't called with the `new` keyword. | [
"A",
"record",
"s",
"constructor",
"can",
"be",
"called",
"without",
"new",
"and",
"will",
"also",
"throw",
"an",
"error",
"if",
"called",
"with",
"the",
"wrong",
"number",
"of",
"arguments",
".",
"Its",
"arguments",
"can",
"be",
"curried",
"as",
"long",
... | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L194-L213 | train | |
natefaubion/adt.js | adt.js | function () {
var ctr = this.constructor;
var names = ctr.__names__;
var args = [], i = 0, n, val;
for (; n = names[i]; i++) {
val = this[n];
args[i] = val instanceof adt.__Base__
? val.clone()
: adt.nativeClone(val);
}
return ctr.apply(null, args... | javascript | function () {
var ctr = this.constructor;
var names = ctr.__names__;
var args = [], i = 0, n, val;
for (; n = names[i]; i++) {
val = this[n];
args[i] = val instanceof adt.__Base__
? val.clone()
: adt.nativeClone(val);
}
return ctr.apply(null, args... | [
"function",
"(",
")",
"{",
"var",
"ctr",
"=",
"this",
".",
"constructor",
";",
"var",
"names",
"=",
"ctr",
".",
"__names__",
";",
"var",
"args",
"=",
"[",
"]",
",",
"i",
"=",
"0",
",",
"n",
",",
"val",
";",
"for",
"(",
";",
"n",
"=",
"names",... | Clones any value that is an adt.js type, delegating other JS values to `adt.nativeClone`. | [
"Clones",
"any",
"value",
"that",
"is",
"an",
"adt",
".",
"js",
"type",
"delegating",
"other",
"JS",
"values",
"to",
"adt",
".",
"nativeClone",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L268-L279 | train | |
natefaubion/adt.js | adt.js | function (that) {
var ctr = this.constructor;
if (this === that) return true;
if (!(that instanceof ctr)) return false;
var names = ctr.__names__;
var i = 0, len = names.length;
var vala, valb, n;
for (; i < len; i++) {
n = names[i], vala = this[n], valb = that[n];
... | javascript | function (that) {
var ctr = this.constructor;
if (this === that) return true;
if (!(that instanceof ctr)) return false;
var names = ctr.__names__;
var i = 0, len = names.length;
var vala, valb, n;
for (; i < len; i++) {
n = names[i], vala = this[n], valb = that[n];
... | [
"function",
"(",
"that",
")",
"{",
"var",
"ctr",
"=",
"this",
".",
"constructor",
";",
"if",
"(",
"this",
"===",
"that",
")",
"return",
"true",
";",
"if",
"(",
"!",
"(",
"that",
"instanceof",
"ctr",
")",
")",
"return",
"false",
";",
"var",
"names",... | Recursively compares all adt.js types, delegating other JS values to `adt.nativeEquals`. | [
"Recursively",
"compares",
"all",
"adt",
".",
"js",
"types",
"delegating",
"other",
"JS",
"values",
"to",
"adt",
".",
"nativeEquals",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L283-L297 | train | |
natefaubion/adt.js | adt.js | function (field) {
var ctr = this.constructor;
var names = ctr.__names__;
var constraints = ctr.__constraints__;
if (typeof field === 'number') {
if (field < 0 || field > names.length - 1) {
throw new Error('Field index out of range: ' + field);
}
field = names[... | javascript | function (field) {
var ctr = this.constructor;
var names = ctr.__names__;
var constraints = ctr.__constraints__;
if (typeof field === 'number') {
if (field < 0 || field > names.length - 1) {
throw new Error('Field index out of range: ' + field);
}
field = names[... | [
"function",
"(",
"field",
")",
"{",
"var",
"ctr",
"=",
"this",
".",
"constructor",
";",
"var",
"names",
"=",
"ctr",
".",
"__names__",
";",
"var",
"constraints",
"=",
"ctr",
".",
"__constraints__",
";",
"if",
"(",
"typeof",
"field",
"===",
"'number'",
"... | Overloaded to take either strings or numbers. Throws an error if the key can't be found. | [
"Overloaded",
"to",
"take",
"either",
"strings",
"or",
"numbers",
".",
"Throws",
"an",
"error",
"if",
"the",
"key",
"can",
"t",
"be",
"found",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L301-L316 | train | |
natefaubion/adt.js | adt.js | addOrder | function addOrder (that) {
if (that.constructor) that = that.constructor;
that.__order__ = order++;
return that;
} | javascript | function addOrder (that) {
if (that.constructor) that = that.constructor;
that.__order__ = order++;
return that;
} | [
"function",
"addOrder",
"(",
"that",
")",
"{",
"if",
"(",
"that",
".",
"constructor",
")",
"that",
"=",
"that",
".",
"constructor",
";",
"that",
".",
"__order__",
"=",
"order",
"++",
";",
"return",
"that",
";",
"}"
] | Helper to add the order meta attribute to a type. | [
"Helper",
"to",
"add",
"the",
"order",
"meta",
"attribute",
"to",
"a",
"type",
"."
] | 0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6 | https://github.com/natefaubion/adt.js/blob/0163b8ea3b3f8f3f8c6ea53c672f3a670c4ce9d6/adt.js#L378-L382 | train |
wachunga/omega | r.js | makeRequire | function makeRequire(relModuleMap, enableBuildCallback, altRequire) {
var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback);
mixin(modRequire, {
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
... | javascript | function makeRequire(relModuleMap, enableBuildCallback, altRequire) {
var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback);
mixin(modRequire, {
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
... | [
"function",
"makeRequire",
"(",
"relModuleMap",
",",
"enableBuildCallback",
",",
"altRequire",
")",
"{",
"var",
"modRequire",
"=",
"makeContextModuleFunc",
"(",
"altRequire",
"||",
"context",
".",
"require",
",",
"relModuleMap",
",",
"enableBuildCallback",
")",
";",... | Helper function that creates a require function object to give to
modules that ask for it as a dependency. It needs to be specific
per module because of the implication of path mappings that may
need to be relative to the module name. | [
"Helper",
"function",
"that",
"creates",
"a",
"require",
"function",
"object",
"to",
"give",
"to",
"modules",
"that",
"ask",
"for",
"it",
"as",
"a",
"dependency",
".",
"It",
"needs",
"to",
"be",
"specific",
"per",
"module",
"because",
"of",
"the",
"implica... | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L500-L511 | train |
wachunga/omega | r.js | makeArgCallback | function makeArgCallback(manager, i) {
return function (value) {
//Only do the work if it has not been done
//already for a dependency. Cycle breaking
//logic in forceExec could mean this function
//is called more than once for a given dependen... | javascript | function makeArgCallback(manager, i) {
return function (value) {
//Only do the work if it has not been done
//already for a dependency. Cycle breaking
//logic in forceExec could mean this function
//is called more than once for a given dependen... | [
"function",
"makeArgCallback",
"(",
"manager",
",",
"i",
")",
"{",
"return",
"function",
"(",
"value",
")",
"{",
"//Only do the work if it has not been done",
"//already for a dependency. Cycle breaking",
"//logic in forceExec could mean this function",
"//is called more than once ... | Helper that creates a callack function that is called when a dependency
is ready, and sets the i-th dependency for the manager as the
value passed to the callback generated by this function. | [
"Helper",
"that",
"creates",
"a",
"callack",
"function",
"that",
"is",
"called",
"when",
"a",
"dependency",
"is",
"ready",
"and",
"sets",
"the",
"i",
"-",
"th",
"dependency",
"for",
"the",
"manager",
"as",
"the",
"value",
"passed",
"to",
"the",
"callback",... | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L629-L645 | train |
wachunga/omega | r.js | addWait | function addWait(manager) {
if (!waiting[manager.id]) {
waiting[manager.id] = manager;
waitAry.push(manager);
context.waitCount += 1;
}
} | javascript | function addWait(manager) {
if (!waiting[manager.id]) {
waiting[manager.id] = manager;
waitAry.push(manager);
context.waitCount += 1;
}
} | [
"function",
"addWait",
"(",
"manager",
")",
"{",
"if",
"(",
"!",
"waiting",
"[",
"manager",
".",
"id",
"]",
")",
"{",
"waiting",
"[",
"manager",
".",
"id",
"]",
"=",
"manager",
";",
"waitAry",
".",
"push",
"(",
"manager",
")",
";",
"context",
".",
... | Adds the manager to the waiting queue. Only fully
resolved items should be in the waiting queue. | [
"Adds",
"the",
"manager",
"to",
"the",
"waiting",
"queue",
".",
"Only",
"fully",
"resolved",
"items",
"should",
"be",
"in",
"the",
"waiting",
"queue",
"."
] | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L739-L745 | train |
wachunga/omega | r.js | toAstArray | function toAstArray(ary) {
var output = [
'array',
[]
],
i, item;
for (i = 0; (item = ary[i]); i++) {
output[1].push([
'string',
item
]);
}
return output;
} | javascript | function toAstArray(ary) {
var output = [
'array',
[]
],
i, item;
for (i = 0; (item = ary[i]); i++) {
output[1].push([
'string',
item
]);
}
return output;
} | [
"function",
"toAstArray",
"(",
"ary",
")",
"{",
"var",
"output",
"=",
"[",
"'array'",
",",
"[",
"]",
"]",
",",
"i",
",",
"item",
";",
"for",
"(",
"i",
"=",
"0",
";",
"(",
"item",
"=",
"ary",
"[",
"i",
"]",
")",
";",
"i",
"++",
")",
"{",
"... | Converts a regular JS array of strings to an AST node that
represents that array.
@param {Array} ary
@param {Node} an AST node that represents an array of strings. | [
"Converts",
"a",
"regular",
"JS",
"array",
"of",
"strings",
"to",
"an",
"AST",
"node",
"that",
"represents",
"that",
"array",
"."
] | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L6614-L6629 | train |
wachunga/omega | r.js | function (fileContents, fileName) {
//Uglify's ast generation removes comments, so just convert to ast,
//then back to source code to get rid of comments.
return uglify.uglify.gen_code(uglify.parser.parse(fileContents), true);
} | javascript | function (fileContents, fileName) {
//Uglify's ast generation removes comments, so just convert to ast,
//then back to source code to get rid of comments.
return uglify.uglify.gen_code(uglify.parser.parse(fileContents), true);
} | [
"function",
"(",
"fileContents",
",",
"fileName",
")",
"{",
"//Uglify's ast generation removes comments, so just convert to ast,",
"//then back to source code to get rid of comments.",
"return",
"uglify",
".",
"uglify",
".",
"gen_code",
"(",
"uglify",
".",
"parser",
".",
"par... | Removes the comments from a string.
@param {String} fileContents
@param {String} fileName mostly used for informative reasons if an error.
@returns {String} a string of JS with comments removed. | [
"Removes",
"the",
"comments",
"from",
"a",
"string",
"."
] | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L8262-L8266 | train | |
wachunga/omega | r.js | makeWriteFile | function makeWriteFile(anonDefRegExp, namespaceWithDot, layer) {
function writeFile(name, contents) {
logger.trace('Saving plugin-optimized file: ' + name);
file.saveUtf8File(name, contents);
}
writeFile.asModule = function (moduleName, fileName, contents) {
... | javascript | function makeWriteFile(anonDefRegExp, namespaceWithDot, layer) {
function writeFile(name, contents) {
logger.trace('Saving plugin-optimized file: ' + name);
file.saveUtf8File(name, contents);
}
writeFile.asModule = function (moduleName, fileName, contents) {
... | [
"function",
"makeWriteFile",
"(",
"anonDefRegExp",
",",
"namespaceWithDot",
",",
"layer",
")",
"{",
"function",
"writeFile",
"(",
"name",
",",
"contents",
")",
"{",
"logger",
".",
"trace",
"(",
"'Saving plugin-optimized file: '",
"+",
"name",
")",
";",
"file",
... | Method used by plugin writeFile calls, defined up here to avoid jslint warning about "making a function in a loop". | [
"Method",
"used",
"by",
"plugin",
"writeFile",
"calls",
"defined",
"up",
"here",
"to",
"avoid",
"jslint",
"warning",
"about",
"making",
"a",
"function",
"in",
"a",
"loop",
"."
] | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L8410-L8422 | train |
wachunga/omega | r.js | setBaseUrl | function setBaseUrl(fileName) {
//Use the file name's directory as the baseUrl if available.
dir = fileName.replace(/\\/g, '/');
if (dir.indexOf('/') !== -1) {
dir = dir.split('/');
dir.pop();
dir = dir.join('/');
exec("require({baseUrl: '" + dir +... | javascript | function setBaseUrl(fileName) {
//Use the file name's directory as the baseUrl if available.
dir = fileName.replace(/\\/g, '/');
if (dir.indexOf('/') !== -1) {
dir = dir.split('/');
dir.pop();
dir = dir.join('/');
exec("require({baseUrl: '" + dir +... | [
"function",
"setBaseUrl",
"(",
"fileName",
")",
"{",
"//Use the file name's directory as the baseUrl if available.",
"dir",
"=",
"fileName",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"'/'",
")",
";",
"if",
"(",
"dir",
".",
"indexOf",
"(",
"'/'",
")",
... | Sets the default baseUrl for requirejs to be directory of top level
script. | [
"Sets",
"the",
"default",
"baseUrl",
"for",
"requirejs",
"to",
"be",
"directory",
"of",
"top",
"level",
"script",
"."
] | c5ecf4ed058d2198065f17c3313b0884e8efa6a9 | https://github.com/wachunga/omega/blob/c5ecf4ed058d2198065f17c3313b0884e8efa6a9/r.js#L9406-L9415 | train |
cozy/cozy-emails | client/plugins/vcard/js/vcardjs-0.3.js | validateCompoundWithType | function validateCompoundWithType(attribute, values) {
for(var i in values) {
var value = values[i];
if(typeof(value) !== 'object') {
errors.push([attribute + '-' + i, "not-an-object"]);
} else if(! value.type) {
... | javascript | function validateCompoundWithType(attribute, values) {
for(var i in values) {
var value = values[i];
if(typeof(value) !== 'object') {
errors.push([attribute + '-' + i, "not-an-object"]);
} else if(! value.type) {
... | [
"function",
"validateCompoundWithType",
"(",
"attribute",
",",
"values",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"values",
")",
"{",
"var",
"value",
"=",
"values",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"(",
"value",
")",
"!==",
"'object'",
")",
"{... | make sure compound fields have their type & value set (to prevent mistakes such as vcard.addAttribute('email', 'foo@bar.baz') | [
"make",
"sure",
"compound",
"fields",
"have",
"their",
"type",
"&",
"value",
"set",
"(",
"to",
"prevent",
"mistakes",
"such",
"as",
"vcard",
".",
"addAttribute",
"(",
"email",
"foo"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/vcard/js/vcardjs-0.3.js#L150-L161 | train |
cozy/cozy-emails | client/plugins/vcard/js/vcardjs-0.3.js | function(key, value) {
console.log('add attribute', key, value);
if(! value) {
return;
}
if(VCard.multivaluedKeys[key]) {
if(this[key]) {
console.log('multivalued push');
this[key].push(value)
... | javascript | function(key, value) {
console.log('add attribute', key, value);
if(! value) {
return;
}
if(VCard.multivaluedKeys[key]) {
if(this[key]) {
console.log('multivalued push');
this[key].push(value)
... | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"console",
".",
"log",
"(",
"'add attribute'",
",",
"key",
",",
"value",
")",
";",
"if",
"(",
"!",
"value",
")",
"{",
"return",
";",
"}",
"if",
"(",
"VCard",
".",
"multivaluedKeys",
"[",
"key",
"]",
... | Set the given attribute to the given value. If the given attribute's key has cardinality > 1, instead of overwriting the current value, an additional value is appended. | [
"Set",
"the",
"given",
"attribute",
"to",
"the",
"given",
"value",
".",
"If",
"the",
"given",
"attribute",
"s",
"key",
"has",
"cardinality",
">",
"1",
"instead",
"of",
"overwriting",
"the",
"current",
"value",
"an",
"additional",
"value",
"is",
"appended",
... | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/vcard/js/vcardjs-0.3.js#L206-L222 | train | |
cozy/cozy-emails | client/plugins/vcard/js/vcardjs-0.3.js | function(aDate, bDate, addSub) {
if(typeof(addSub) == 'undefined') { addSub = true };
if(! aDate) { return bDate; }
if(! bDate) { return aDate; }
var a = Number(aDate);
var b = Number(bDate);
var c = addSub ? a + b : a - b;
return new D... | javascript | function(aDate, bDate, addSub) {
if(typeof(addSub) == 'undefined') { addSub = true };
if(! aDate) { return bDate; }
if(! bDate) { return aDate; }
var a = Number(aDate);
var b = Number(bDate);
var c = addSub ? a + b : a - b;
return new D... | [
"function",
"(",
"aDate",
",",
"bDate",
",",
"addSub",
")",
"{",
"if",
"(",
"typeof",
"(",
"addSub",
")",
"==",
"'undefined'",
")",
"{",
"addSub",
"=",
"true",
"}",
";",
"if",
"(",
"!",
"aDate",
")",
"{",
"return",
"bDate",
";",
"}",
"if",
"(",
... | add two dates. if addSub is false, substract instead of add. | [
"add",
"two",
"dates",
".",
"if",
"addSub",
"is",
"false",
"substract",
"instead",
"of",
"add",
"."
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/vcard/js/vcardjs-0.3.js#L629-L637 | train | |
cozy/cozy-emails | client/plugins/vcard/js/vcardjs-0.3.js | function(str){
str = (str || "").toString();
str = str.replace(/\=(?:\r?\n|$)/g, "");
var str2 = "";
for(var i=0, len = str.length; i<len; i++){
chr = str.charAt(i);
if(chr == "=" && (hex = str.substr(i+1, 2)) && /[\da-fA-F]{2}/.test(hex)){... | javascript | function(str){
str = (str || "").toString();
str = str.replace(/\=(?:\r?\n|$)/g, "");
var str2 = "";
for(var i=0, len = str.length; i<len; i++){
chr = str.charAt(i);
if(chr == "=" && (hex = str.substr(i+1, 2)) && /[\da-fA-F]{2}/.test(hex)){... | [
"function",
"(",
"str",
")",
"{",
"str",
"=",
"(",
"str",
"||",
"\"\"",
")",
".",
"toString",
"(",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\=(?:\\r?\\n|$)",
"/",
"g",
",",
"\"\"",
")",
";",
"var",
"str2",
"=",
"\"\"",
";",
"for... | Quoted Printable Parser
Parses quoted-printable strings, which sometimes appear in
vCard 2.1 files (usually the address field)
Code adapted from:
https://github.com/andris9/mimelib | [
"Quoted",
"Printable",
"Parser"
] | e31b4e724e6310a3e0451ab1703857287aef1f6f | https://github.com/cozy/cozy-emails/blob/e31b4e724e6310a3e0451ab1703857287aef1f6f/client/plugins/vcard/js/vcardjs-0.3.js#L793-L807 | train | |
mangalam-research/wed | lib/wed/polyfills/firstElementChild_etc.js | addParentNodeInterfaceToPrototype | function addParentNodeInterfaceToPrototype(p) {
Object.defineProperty(p, "firstElementChild", {
get: function firstElementChild() {
var el = this.firstChild;
while (el && el.nodeType !== 1) {
el = el.nextSibling;
}
return el;
},
});
Object.definePropert... | javascript | function addParentNodeInterfaceToPrototype(p) {
Object.defineProperty(p, "firstElementChild", {
get: function firstElementChild() {
var el = this.firstChild;
while (el && el.nodeType !== 1) {
el = el.nextSibling;
}
return el;
},
});
Object.definePropert... | [
"function",
"addParentNodeInterfaceToPrototype",
"(",
"p",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"p",
",",
"\"firstElementChild\"",
",",
"{",
"get",
":",
"function",
"firstElementChild",
"(",
")",
"{",
"var",
"el",
"=",
"this",
".",
"firstChild",
";"... | This polyfill has been tested with IE 11 and 10. It has not been tested with older versions of IE because we do not support them. | [
"This",
"polyfill",
"has",
"been",
"tested",
"with",
"IE",
"11",
"and",
"10",
".",
"It",
"has",
"not",
"been",
"tested",
"with",
"older",
"versions",
"of",
"IE",
"because",
"we",
"do",
"not",
"support",
"them",
"."
] | f0c6d23492ac97afa730098df46e18fdeb647ef5 | https://github.com/mangalam-research/wed/blob/f0c6d23492ac97afa730098df46e18fdeb647ef5/lib/wed/polyfills/firstElementChild_etc.js#L28-L60 | train |
mangalam-research/wed | lib/wed/polyfills/firstElementChild_etc.js | addChildrenToPrototype | function addChildrenToPrototype(p) {
// Unfortunately, it is not possible to emulate the liveness of the
// HTMLCollection this property *should* provide.
Object.defineProperty(p, "children", {
get: function children() {
var ret = [];
var el = this.firstElementChild;
while (el)... | javascript | function addChildrenToPrototype(p) {
// Unfortunately, it is not possible to emulate the liveness of the
// HTMLCollection this property *should* provide.
Object.defineProperty(p, "children", {
get: function children() {
var ret = [];
var el = this.firstElementChild;
while (el)... | [
"function",
"addChildrenToPrototype",
"(",
"p",
")",
"{",
"// Unfortunately, it is not possible to emulate the liveness of the",
"// HTMLCollection this property *should* provide.",
"Object",
".",
"defineProperty",
"(",
"p",
",",
"\"children\"",
",",
"{",
"get",
":",
"function"... | We separate children from the rest because it is possible to have firstElementChild, etc defined and yet not have children defined. Go figure... | [
"We",
"separate",
"children",
"from",
"the",
"rest",
"because",
"it",
"is",
"possible",
"to",
"have",
"firstElementChild",
"etc",
"defined",
"and",
"yet",
"not",
"have",
"children",
"defined",
".",
"Go",
"figure",
"..."
] | f0c6d23492ac97afa730098df46e18fdeb647ef5 | https://github.com/mangalam-research/wed/blob/f0c6d23492ac97afa730098df46e18fdeb647ef5/lib/wed/polyfills/firstElementChild_etc.js#L65-L80 | train |
mangalam-research/wed | misc/util.js | captureConfigObject | function captureConfigObject(config) {
let captured;
const require = {};
require.config = function _config(conf) {
captured = conf;
};
let wedConfig;
// eslint-disable-next-line no-unused-vars
function define(name, obj) {
if (wedConfig !== undefined) {
throw new Error("more than one define... | javascript | function captureConfigObject(config) {
let captured;
const require = {};
require.config = function _config(conf) {
captured = conf;
};
let wedConfig;
// eslint-disable-next-line no-unused-vars
function define(name, obj) {
if (wedConfig !== undefined) {
throw new Error("more than one define... | [
"function",
"captureConfigObject",
"(",
"config",
")",
"{",
"let",
"captured",
";",
"const",
"require",
"=",
"{",
"}",
";",
"require",
".",
"config",
"=",
"function",
"_config",
"(",
"conf",
")",
"{",
"captured",
"=",
"conf",
";",
"}",
";",
"let",
"wed... | This function defines ``require.config`` so that evaluating our
configuration file will capture the configuration passed to
``require.config``.
@param {String} config The text of the configuration file.
@returns {Object} The configuration object. | [
"This",
"function",
"defines",
"require",
".",
"config",
"so",
"that",
"evaluating",
"our",
"configuration",
"file",
"will",
"capture",
"the",
"configuration",
"passed",
"to",
"require",
".",
"config",
"."
] | f0c6d23492ac97afa730098df46e18fdeb647ef5 | https://github.com/mangalam-research/wed/blob/f0c6d23492ac97afa730098df46e18fdeb647ef5/misc/util.js#L14-L50 | train |
mangalam-research/wed | lib/wed/onerror.js | _reset | function _reset() {
terminating = false;
if (termination_timeout) {
termination_window.clearTimeout(termination_timeout);
termination_timeout = undefined;
}
$modal.off();
$modal.modal("hide");
$modal.remove();
} | javascript | function _reset() {
terminating = false;
if (termination_timeout) {
termination_window.clearTimeout(termination_timeout);
termination_timeout = undefined;
}
$modal.off();
$modal.modal("hide");
$modal.remove();
} | [
"function",
"_reset",
"(",
")",
"{",
"terminating",
"=",
"false",
";",
"if",
"(",
"termination_timeout",
")",
"{",
"termination_window",
".",
"clearTimeout",
"(",
"termination_timeout",
")",
";",
"termination_timeout",
"=",
"undefined",
";",
"}",
"$modal",
".",
... | Normally onerror will be reset by reloading but when testing with mocha we don't want reloading, so we export this function. | [
"Normally",
"onerror",
"will",
"be",
"reset",
"by",
"reloading",
"but",
"when",
"testing",
"with",
"mocha",
"we",
"don",
"t",
"want",
"reloading",
"so",
"we",
"export",
"this",
"function",
"."
] | f0c6d23492ac97afa730098df46e18fdeb647ef5 | https://github.com/mangalam-research/wed/blob/f0c6d23492ac97afa730098df46e18fdeb647ef5/lib/wed/onerror.js#L44-L53 | train |
mangalam-research/wed | lib/wed/onerror.js | showModal | function showModal(saveMessages, errorMessage) {
$(document.body).append($modal);
$modal.find(".save-messages")[0].innerHTML = saveMessages;
$modal.find(".error-message")[0].textContent = errorMessage;
$modal.on("hide.bs.modal.modal", function hidden() {
$modal.remove();
window.location.relo... | javascript | function showModal(saveMessages, errorMessage) {
$(document.body).append($modal);
$modal.find(".save-messages")[0].innerHTML = saveMessages;
$modal.find(".error-message")[0].textContent = errorMessage;
$modal.on("hide.bs.modal.modal", function hidden() {
$modal.remove();
window.location.relo... | [
"function",
"showModal",
"(",
"saveMessages",
",",
"errorMessage",
")",
"{",
"$",
"(",
"document",
".",
"body",
")",
".",
"append",
"(",
"$modal",
")",
";",
"$modal",
".",
"find",
"(",
"\".save-messages\"",
")",
"[",
"0",
"]",
".",
"innerHTML",
"=",
"s... | So that we can issue clearTimeout elsewhere. | [
"So",
"that",
"we",
"can",
"issue",
"clearTimeout",
"elsewhere",
"."
] | f0c6d23492ac97afa730098df46e18fdeb647ef5 | https://github.com/mangalam-research/wed/blob/f0c6d23492ac97afa730098df46e18fdeb647ef5/lib/wed/onerror.js#L78-L87 | train |
jonschlinkert/lazy-cache | index.js | lazyCache | function lazyCache(requireFn) {
var cache = {};
return function proxy(name, alias) {
var key = alias;
// camel-case the module `name` if `alias` is not defined
if (typeof key !== 'string') {
key = camelcase(name);
}
// create a getter to lazily invoke the module the first time it's call... | javascript | function lazyCache(requireFn) {
var cache = {};
return function proxy(name, alias) {
var key = alias;
// camel-case the module `name` if `alias` is not defined
if (typeof key !== 'string') {
key = camelcase(name);
}
// create a getter to lazily invoke the module the first time it's call... | [
"function",
"lazyCache",
"(",
"requireFn",
")",
"{",
"var",
"cache",
"=",
"{",
"}",
";",
"return",
"function",
"proxy",
"(",
"name",
",",
"alias",
")",
"{",
"var",
"key",
"=",
"alias",
";",
"// camel-case the module `name` if `alias` is not defined",
"if",
"("... | Cache results of the first function call to ensure only calling once.
```js
var utils = require('lazy-cache')(require);
// cache the call to `require('ansi-yellow')`
utils('ansi-yellow', 'yellow');
// use `ansi-yellow`
console.log(utils.yellow('this is yellow'));
```
@param {Function} `fn` Function that will be call... | [
"Cache",
"results",
"of",
"the",
"first",
"function",
"call",
"to",
"ensure",
"only",
"calling",
"once",
"."
] | 2f15129f05f2d69cbc2cb7ba52e383fc31b9fc2c | https://github.com/jonschlinkert/lazy-cache/blob/2f15129f05f2d69cbc2cb7ba52e383fc31b9fc2c/index.js#L21-L45 | train |
temando/remark-mermaid | src/utils.js | getDestinationDir | function getDestinationDir(vFile) {
if (vFile.data.destinationDir) {
return vFile.data.destinationDir;
}
return vFile.dirname;
} | javascript | function getDestinationDir(vFile) {
if (vFile.data.destinationDir) {
return vFile.data.destinationDir;
}
return vFile.dirname;
} | [
"function",
"getDestinationDir",
"(",
"vFile",
")",
"{",
"if",
"(",
"vFile",
".",
"data",
".",
"destinationDir",
")",
"{",
"return",
"vFile",
".",
"data",
".",
"destinationDir",
";",
"}",
"return",
"vFile",
".",
"dirname",
";",
"}"
] | Returns the destination for the SVG to be rendered at, explicity defined
using `vFile.data.destinationDir`, or falling back to the file's current
directory.
@param {vFile} vFile
@return {string} | [
"Returns",
"the",
"destination",
"for",
"the",
"SVG",
"to",
"be",
"rendered",
"at",
"explicity",
"defined",
"using",
"vFile",
".",
"data",
".",
"destinationDir",
"or",
"falling",
"back",
"to",
"the",
"file",
"s",
"current",
"directory",
"."
] | 3c0aaa8e90ff8ca0d043a9648c651683c0867ae3 | https://github.com/temando/remark-mermaid/blob/3c0aaa8e90ff8ca0d043a9648c651683c0867ae3/src/utils.js#L64-L70 | train |
IonicaBizau/parse-url | lib/index.js | parseUrl | function parseUrl(url, normalize = false) {
if (typeof url !== "string" || !url.trim()) {
throw new Error("Invalid url.")
}
if (normalize) {
if (typeof normalize !== "object") {
normalize = {
stripFragment: false
}
}
url = normalizeUrl(... | javascript | function parseUrl(url, normalize = false) {
if (typeof url !== "string" || !url.trim()) {
throw new Error("Invalid url.")
}
if (normalize) {
if (typeof normalize !== "object") {
normalize = {
stripFragment: false
}
}
url = normalizeUrl(... | [
"function",
"parseUrl",
"(",
"url",
",",
"normalize",
"=",
"false",
")",
"{",
"if",
"(",
"typeof",
"url",
"!==",
"\"string\"",
"||",
"!",
"url",
".",
"trim",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Invalid url.\"",
")",
"}",
"if",
"(",
... | parseUrl
Parses the input url.
**Note**: This *throws* if invalid urls are provided.
@name parseUrl
@function
@param {String} url The input url.
@param {Boolean|Object} normalize Wheter to normalize the url or not.
Default is `false`. If `true`, the url will
be normalized. If an object, it will be the
options object ... | [
"parseUrl",
"Parses",
"the",
"input",
"url",
"."
] | 0be4cd98d7ad1b82a006e1edd7dbb3bde56a7537 | https://github.com/IonicaBizau/parse-url/blob/0be4cd98d7ad1b82a006e1edd7dbb3bde56a7537/lib/index.js#L35-L49 | train |
Pamblam/jSQL | jSQL.js | function(query, data, successCallback, failureCallback) {
if(typeof successCallback != "function") successCallback = function(){};
if(typeof failureCallback != "function") failureCallback = function(){ return _throw(new jSQL_Error("0054")); };
var i, l, remaining;
if(!Array.isArray(data[0])) data = [data]... | javascript | function(query, data, successCallback, failureCallback) {
if(typeof successCallback != "function") successCallback = function(){};
if(typeof failureCallback != "function") failureCallback = function(){ return _throw(new jSQL_Error("0054")); };
var i, l, remaining;
if(!Array.isArray(data[0])) data = [data]... | [
"function",
"(",
"query",
",",
"data",
",",
"successCallback",
",",
"failureCallback",
")",
"{",
"if",
"(",
"typeof",
"successCallback",
"!=",
"\"function\"",
")",
"successCallback",
"=",
"function",
"(",
")",
"{",
"}",
";",
"if",
"(",
"typeof",
"failureCall... | private function to execute a query | [
"private",
"function",
"to",
"execute",
"a",
"query"
] | 507ef210e339fdb8f820b26412e2173aa8c19d82 | https://github.com/Pamblam/jSQL/blob/507ef210e339fdb8f820b26412e2173aa8c19d82/jSQL.js#L2370-L2395 | 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.