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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
zynga/atom | atom.js | provide | function provide(nucleus, key, provider) {
provider(preventMultiCall(function (result) {
set(nucleus, key, result);
}));
} | javascript | function provide(nucleus, key, provider) {
provider(preventMultiCall(function (result) {
set(nucleus, key, result);
}));
} | [
"function",
"provide",
"(",
"nucleus",
",",
"key",
",",
"provider",
")",
"{",
"provider",
"(",
"preventMultiCall",
"(",
"function",
"(",
"result",
")",
"{",
"set",
"(",
"nucleus",
",",
"key",
",",
"result",
")",
";",
"}",
")",
")",
";",
"}"
] | Helper function for setting up providers. | [
"Helper",
"function",
"for",
"setting",
"up",
"providers",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L136-L140 | train |
zynga/atom | atom.js | doNext | function doNext() {
if (q) {
q.pending = q.next = (!q.next && q.length) ?
q.shift() : q.next;
q.args = slice.call(arguments, 0);
if (q.pending) {
q.next = 0;
q.pending.apply({}, [preventMultiCall(doNext)].concat(q.args));
}
}
} | javascript | function doNext() {
if (q) {
q.pending = q.next = (!q.next && q.length) ?
q.shift() : q.next;
q.args = slice.call(arguments, 0);
if (q.pending) {
q.next = 0;
q.pending.apply({}, [preventMultiCall(doNext)].concat(q.args));
}
}
} | [
"function",
"doNext",
"(",
")",
"{",
"if",
"(",
"q",
")",
"{",
"q",
".",
"pending",
"=",
"q",
".",
"next",
"=",
"(",
"!",
"q",
".",
"next",
"&&",
"q",
".",
"length",
")",
"?",
"q",
".",
"shift",
"(",
")",
":",
"q",
".",
"next",
";",
"q",
... | Execute the next function in the async queue. | [
"Execute",
"the",
"next",
"function",
"in",
"the",
"async",
"queue",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L168-L178 | train |
zynga/atom | atom.js | function () {
if (q) {
for (var i = 0, len = arguments.length; i < len; i++) {
q.push(arguments[i]);
if (!q.pending) {
doNext.apply({}, q.args || []);
}
}
}
return me;
} | javascript | function () {
if (q) {
for (var i = 0, len = arguments.length; i < len; i++) {
q.push(arguments[i]);
if (!q.pending) {
doNext.apply({}, q.args || []);
}
}
}
return me;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"q",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"arguments",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"q",
".",
"push",
"(",
"arguments",
"[",
"i",
"]",
")",
";... | Add a function or functions to the async queue. Functions added thusly must call their first arg as a callback when done. Any args provided to the callback will be passed in to the next function in the queue. | [
"Add",
"a",
"function",
"or",
"functions",
"to",
"the",
"async",
"queue",
".",
"Functions",
"added",
"thusly",
"must",
"call",
"their",
"first",
"arg",
"as",
"a",
"callback",
"when",
"done",
".",
"Any",
"args",
"provided",
"to",
"the",
"callback",
"will",
... | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L186-L196 | train | |
zynga/atom | atom.js | function () {
delete nucleus.props;
delete nucleus.needs;
delete nucleus.providers;
delete nucleus.listeners;
while (q.length) {
q.pop();
}
nucleus = props = needs = providers = listeners =
q = q.pending = q.next = q.args = 0;
} | javascript | function () {
delete nucleus.props;
delete nucleus.needs;
delete nucleus.providers;
delete nucleus.listeners;
while (q.length) {
q.pop();
}
nucleus = props = needs = providers = listeners =
q = q.pending = q.next = q.args = 0;
} | [
"function",
"(",
")",
"{",
"delete",
"nucleus",
".",
"props",
";",
"delete",
"nucleus",
".",
"needs",
";",
"delete",
"nucleus",
".",
"providers",
";",
"delete",
"nucleus",
".",
"listeners",
";",
"while",
"(",
"q",
".",
"length",
")",
"{",
"q",
".",
"... | Remove references to all properties and listeners. This releases memory, and effective stops the atom from working. | [
"Remove",
"references",
"to",
"all",
"properties",
"and",
"listeners",
".",
"This",
"releases",
"memory",
"and",
"effective",
"stops",
"the",
"atom",
"from",
"working",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L200-L210 | train | |
zynga/atom | atom.js | function (keyOrList, func) {
var keys = toArray(keyOrList), i = -1, len = keys.length, key;
while (++i < len) {
key = keys[i];
func(key, me.get(key));
}
return me;
} | javascript | function (keyOrList, func) {
var keys = toArray(keyOrList), i = -1, len = keys.length, key;
while (++i < len) {
key = keys[i];
func(key, me.get(key));
}
return me;
} | [
"function",
"(",
"keyOrList",
",",
"func",
")",
"{",
"var",
"keys",
"=",
"toArray",
"(",
"keyOrList",
")",
",",
"i",
"=",
"-",
"1",
",",
"len",
"=",
"keys",
".",
"length",
",",
"key",
";",
"while",
"(",
"++",
"i",
"<",
"len",
")",
"{",
"key",
... | Call `func` on each of the specified keys. The key is provided as the first arg, and the value as the second. | [
"Call",
"func",
"on",
"each",
"of",
"the",
"specified",
"keys",
".",
"The",
"key",
"is",
"provided",
"as",
"the",
"first",
"arg",
"and",
"the",
"value",
"as",
"the",
"second",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L214-L221 | train | |
zynga/atom | atom.js | function (keyOrList, func) {
var result = get(nucleus, keyOrList, func);
return func ? result : typeof keyOrList === 'string' ?
result.values[0] : result.values;
} | javascript | function (keyOrList, func) {
var result = get(nucleus, keyOrList, func);
return func ? result : typeof keyOrList === 'string' ?
result.values[0] : result.values;
} | [
"function",
"(",
"keyOrList",
",",
"func",
")",
"{",
"var",
"result",
"=",
"get",
"(",
"nucleus",
",",
"keyOrList",
",",
"func",
")",
";",
"return",
"func",
"?",
"result",
":",
"typeof",
"keyOrList",
"===",
"'string'",
"?",
"result",
".",
"values",
"["... | Get current values for the specified keys. If `func` is provided, it will be called with the values as args. | [
"Get",
"current",
"values",
"for",
"the",
"specified",
"keys",
".",
"If",
"func",
"is",
"provided",
"it",
"will",
"be",
"called",
"with",
"the",
"values",
"as",
"args",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L263-L267 | train | |
zynga/atom | atom.js | function () {
var keys = [];
for (var key in props) {
if (hasOwn.call(props, key)) {
keys.push(key);
}
}
return keys;
} | javascript | function () {
var keys = [];
for (var key in props) {
if (hasOwn.call(props, key)) {
keys.push(key);
}
}
return keys;
} | [
"function",
"(",
")",
"{",
"var",
"keys",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"props",
")",
"{",
"if",
"(",
"hasOwn",
".",
"call",
"(",
"props",
",",
"key",
")",
")",
"{",
"keys",
".",
"push",
"(",
"key",
")",
";",
"}",
"}",... | Return a list of all keys. | [
"Return",
"a",
"list",
"of",
"all",
"keys",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L282-L290 | train | |
zynga/atom | atom.js | function (obj) {
for (var p in obj) {
if (hasOwn.call(obj, p)) {
me[p] = obj[p];
}
}
return me;
} | javascript | function (obj) {
for (var p in obj) {
if (hasOwn.call(obj, p)) {
me[p] = obj[p];
}
}
return me;
} | [
"function",
"(",
"obj",
")",
"{",
"for",
"(",
"var",
"p",
"in",
"obj",
")",
"{",
"if",
"(",
"hasOwn",
".",
"call",
"(",
"obj",
",",
"p",
")",
")",
"{",
"me",
"[",
"p",
"]",
"=",
"obj",
"[",
"p",
"]",
";",
"}",
"}",
"return",
"me",
";",
... | Add arbitrary properties to this atom's interface. | [
"Add",
"arbitrary",
"properties",
"to",
"this",
"atom",
"s",
"interface",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L293-L300 | train | |
zynga/atom | atom.js | function (keyOrList, func) { // alias: `bind`
listeners.unshift({ keys: toArray(keyOrList), cb: func,
calls: Infinity });
return me;
} | javascript | function (keyOrList, func) { // alias: `bind`
listeners.unshift({ keys: toArray(keyOrList), cb: func,
calls: Infinity });
return me;
} | [
"function",
"(",
"keyOrList",
",",
"func",
")",
"{",
"// alias: `bind`",
"listeners",
".",
"unshift",
"(",
"{",
"keys",
":",
"toArray",
"(",
"keyOrList",
")",
",",
"cb",
":",
"func",
",",
"calls",
":",
"Infinity",
"}",
")",
";",
"return",
"me",
";",
... | Call `func` whenever any of the specified keys change. The values of the keys will be provided as args to func. | [
"Call",
"func",
"whenever",
"any",
"of",
"the",
"specified",
"keys",
"change",
".",
"The",
"values",
"of",
"the",
"keys",
"will",
"be",
"provided",
"as",
"args",
"to",
"func",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L359-L363 | train | |
zynga/atom | atom.js | function (keyOrList, func) {
var keys = toArray(keyOrList),
results = get(nucleus, keys),
values = results.values,
missing = results.missing;
if (!missing) {
func.apply({}, values);
} else {
listeners.unshift(
{ keys: keys, cb: func, missing: missing, calls: 1 });
}
re... | javascript | function (keyOrList, func) {
var keys = toArray(keyOrList),
results = get(nucleus, keys),
values = results.values,
missing = results.missing;
if (!missing) {
func.apply({}, values);
} else {
listeners.unshift(
{ keys: keys, cb: func, missing: missing, calls: 1 });
}
re... | [
"function",
"(",
"keyOrList",
",",
"func",
")",
"{",
"var",
"keys",
"=",
"toArray",
"(",
"keyOrList",
")",
",",
"results",
"=",
"get",
"(",
"nucleus",
",",
"keys",
")",
",",
"values",
"=",
"results",
".",
"values",
",",
"missing",
"=",
"results",
"."... | Call `func` as soon as all of the specified keys have been set. If they are already set, the function will be called immediately, with all the values provided as args. Guaranteed to be called no more than once. | [
"Call",
"func",
"as",
"soon",
"as",
"all",
"of",
"the",
"specified",
"keys",
"have",
"been",
"set",
".",
"If",
"they",
"are",
"already",
"set",
"the",
"function",
"will",
"be",
"called",
"immediately",
"with",
"all",
"the",
"values",
"provided",
"as",
"a... | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L369-L381 | train | |
zynga/atom | atom.js | function (key, func) {
if (needs[key]) {
provide(nucleus, key, func);
} else if (!providers[key]) {
providers[key] = func;
}
return me;
} | javascript | function (key, func) {
if (needs[key]) {
provide(nucleus, key, func);
} else if (!providers[key]) {
providers[key] = func;
}
return me;
} | [
"function",
"(",
"key",
",",
"func",
")",
"{",
"if",
"(",
"needs",
"[",
"key",
"]",
")",
"{",
"provide",
"(",
"nucleus",
",",
"key",
",",
"func",
")",
";",
"}",
"else",
"if",
"(",
"!",
"providers",
"[",
"key",
"]",
")",
"{",
"providers",
"[",
... | Register a provider for a particular key. The provider `func` is a function that will be called if there is a need to create the key. It must call its first arg as a callback, with the value. Provider functions will be called at most once. | [
"Register",
"a",
"provider",
"for",
"a",
"particular",
"key",
".",
"The",
"provider",
"func",
"is",
"a",
"function",
"that",
"will",
"be",
"called",
"if",
"there",
"is",
"a",
"need",
"to",
"create",
"the",
"key",
".",
"It",
"must",
"call",
"its",
"firs... | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L387-L394 | train | |
zynga/atom | atom.js | function (keyOrMap, value) {
if (typeof keyOrMap === typeObj) {
for (var key in keyOrMap) {
if (hasOwn.call(keyOrMap, key)) {
set(nucleus, key, keyOrMap[key]);
}
}
} else {
set(nucleus, keyOrMap, value);
}
return me;
} | javascript | function (keyOrMap, value) {
if (typeof keyOrMap === typeObj) {
for (var key in keyOrMap) {
if (hasOwn.call(keyOrMap, key)) {
set(nucleus, key, keyOrMap[key]);
}
}
} else {
set(nucleus, keyOrMap, value);
}
return me;
} | [
"function",
"(",
"keyOrMap",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"keyOrMap",
"===",
"typeObj",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"keyOrMap",
")",
"{",
"if",
"(",
"hasOwn",
".",
"call",
"(",
"keyOrMap",
",",
"key",
")",
")",
"{",
... | Set value for a key, or if `keyOrMap` is an object then set all the keys' corresponding values. | [
"Set",
"value",
"for",
"a",
"key",
"or",
"if",
"keyOrMap",
"is",
"an",
"object",
"then",
"set",
"all",
"the",
"keys",
"corresponding",
"values",
"."
] | cf204967e9267df47d51c2b5b628261c7ed0cec7 | https://github.com/zynga/atom/blob/cf204967e9267df47d51c2b5b628261c7ed0cec7/atom.js#L398-L409 | train | |
mkloubert/nativescript-stringformat | plugin/index.js | join | function join(separator, itemList) {
var result = "";
for (var i = 0; i < itemList.length; i++) {
if (i > 0) {
result += separator;
}
result += itemList[i];
}
return result;
} | javascript | function join(separator, itemList) {
var result = "";
for (var i = 0; i < itemList.length; i++) {
if (i > 0) {
result += separator;
}
result += itemList[i];
}
return result;
} | [
"function",
"join",
"(",
"separator",
",",
"itemList",
")",
"{",
"var",
"result",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"itemList",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"res... | Joins items to one string.
@function join
@param {String} separator The separator.
@param {Array} itemList The list of items.
@return {String} The joined string. | [
"Joins",
"items",
"to",
"one",
"string",
"."
] | 83478b3a222574ad9e76f07076b798e6f2d8e6ac | https://github.com/mkloubert/nativescript-stringformat/blob/83478b3a222574ad9e76f07076b798e6f2d8e6ac/plugin/index.js#L564-L573 | train |
mkloubert/nativescript-stringformat | plugin/index.js | similarity | function similarity(left, right, ignoreCase, trim) {
if (left === right) {
return 1;
}
if (TypeUtils.isNullOrUndefined(left) ||
TypeUtils.isNullOrUndefined(right)) {
return 0;
}
if (arguments.length < 4) {
if (arguments.length < 3) {
ignoreCase =... | javascript | function similarity(left, right, ignoreCase, trim) {
if (left === right) {
return 1;
}
if (TypeUtils.isNullOrUndefined(left) ||
TypeUtils.isNullOrUndefined(right)) {
return 0;
}
if (arguments.length < 4) {
if (arguments.length < 3) {
ignoreCase =... | [
"function",
"similarity",
"(",
"left",
",",
"right",
",",
"ignoreCase",
",",
"trim",
")",
"{",
"if",
"(",
"left",
"===",
"right",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"TypeUtils",
".",
"isNullOrUndefined",
"(",
"left",
")",
"||",
"TypeUtils",
... | Returns the similarity of strings.
@function similarity
@param {string} left The "left" string.
@param {string} right The "right" string.
@param {boolean} [ignoreCase] Compare case insensitive or not.
@param {boolean} [trim] Trim both strings before comparison or not.
@return {Number} The similarity between 0 (0 %) ... | [
"Returns",
"the",
"similarity",
"of",
"strings",
"."
] | 83478b3a222574ad9e76f07076b798e6f2d8e6ac | https://github.com/mkloubert/nativescript-stringformat/blob/83478b3a222574ad9e76f07076b798e6f2d8e6ac/plugin/index.js#L587-L642 | train |
sheebz/phantom-proxy | lib/phantom.js | function (filename, callbackFn) {
var self = this;
request.post(this.options.hostAndPort + '/phantom/functions/injectJs', {form:{args:JSON.stringify(arguments)}},
function (error, response, body) {
if (response.statusCode === 200) {
... | javascript | function (filename, callbackFn) {
var self = this;
request.post(this.options.hostAndPort + '/phantom/functions/injectJs', {form:{args:JSON.stringify(arguments)}},
function (error, response, body) {
if (response.statusCode === 200) {
... | [
"function",
"(",
"filename",
",",
"callbackFn",
")",
"{",
"var",
"self",
"=",
"this",
";",
"request",
".",
"post",
"(",
"this",
".",
"options",
".",
"hostAndPort",
"+",
"'/phantom/functions/injectJs'",
",",
"{",
"form",
":",
"{",
"args",
":",
"JSON",
"."... | Injects external script code from the specified file. If the file can not be found in the current directory, libraryPath is used for additional look up. This function returns true if injection is successful, otherwise it returns false. | [
"Injects",
"external",
"script",
"code",
"from",
"the",
"specified",
"file",
".",
"If",
"the",
"file",
"can",
"not",
"be",
"found",
"in",
"the",
"current",
"directory",
"libraryPath",
"is",
"used",
"for",
"additional",
"look",
"up",
".",
"This",
"function",
... | a4963662205400e542668938ce5cf1ab9a66fba0 | https://github.com/sheebz/phantom-proxy/blob/a4963662205400e542668938ce5cf1ab9a66fba0/lib/phantom.js#L106-L118 | train | |
getdave/grunt-deployments | tasks/deployments.js | db_import | function db_import(config, src) {
var cmd;
// 1) Create cmd string from Lo-Dash template
var tpl_mysql = grunt.template.process(tpls.mysql, {
data: {
host: config.host,
user: config.user,
pass: config.pass,
database: c... | javascript | function db_import(config, src) {
var cmd;
// 1) Create cmd string from Lo-Dash template
var tpl_mysql = grunt.template.process(tpls.mysql, {
data: {
host: config.host,
user: config.user,
pass: config.pass,
database: c... | [
"function",
"db_import",
"(",
"config",
",",
"src",
")",
"{",
"var",
"cmd",
";",
"// 1) Create cmd string from Lo-Dash template",
"var",
"tpl_mysql",
"=",
"grunt",
".",
"template",
".",
"process",
"(",
"tpls",
".",
"mysql",
",",
"{",
"data",
":",
"{",
"host"... | Imports a .sql file into the DB provided | [
"Imports",
"a",
".",
"sql",
"file",
"into",
"the",
"DB",
"provided"
] | 504a50e9ce4367d0ee5e74fd83dd7d18d46ad3e7 | https://github.com/getdave/grunt-deployments/blob/504a50e9ce4367d0ee5e74fd83dd7d18d46ad3e7/tasks/deployments.js#L134-L170 | train |
getdave/grunt-deployments | tasks/deployments.js | db_dump | function db_dump(config, output_paths) {
var cmd;
grunt.file.mkdir(output_paths.dir);
// 2) Compile MYSQL cmd via Lo-Dash template string
var tpl_mysqldump = grunt.template.process(tpls.mysqldump, {
data: {
user: config.user,
pass: config.p... | javascript | function db_dump(config, output_paths) {
var cmd;
grunt.file.mkdir(output_paths.dir);
// 2) Compile MYSQL cmd via Lo-Dash template string
var tpl_mysqldump = grunt.template.process(tpls.mysqldump, {
data: {
user: config.user,
pass: config.p... | [
"function",
"db_dump",
"(",
"config",
",",
"output_paths",
")",
"{",
"var",
"cmd",
";",
"grunt",
".",
"file",
".",
"mkdir",
"(",
"output_paths",
".",
"dir",
")",
";",
"// 2) Compile MYSQL cmd via Lo-Dash template string",
"var",
"tpl_mysqldump",
"=",
"grunt",
".... | Dumps a MYSQL database to a suitable backup location | [
"Dumps",
"a",
"MYSQL",
"database",
"to",
"a",
"suitable",
"backup",
"location"
] | 504a50e9ce4367d0ee5e74fd83dd7d18d46ad3e7 | https://github.com/getdave/grunt-deployments/blob/504a50e9ce4367d0ee5e74fd83dd7d18d46ad3e7/tasks/deployments.js#L177-L219 | train |
sheebz/phantom-proxy | lib/proxy.js | function (callbackFn) {
var self = this;
request.post(this.options.hostAndPort + '/phantom/functions/exit', {
form:{
}
},
function (error, response, body) {
if (response && response.statusCode === 200) {... | javascript | function (callbackFn) {
var self = this;
request.post(this.options.hostAndPort + '/phantom/functions/exit', {
form:{
}
},
function (error, response, body) {
if (response && response.statusCode === 200) {... | [
"function",
"(",
"callbackFn",
")",
"{",
"var",
"self",
"=",
"this",
";",
"request",
".",
"post",
"(",
"this",
".",
"options",
".",
"hostAndPort",
"+",
"'/phantom/functions/exit'",
",",
"{",
"form",
":",
"{",
"}",
"}",
",",
"function",
"(",
"error",
",... | terminates phantomjs process | [
"terminates",
"phantomjs",
"process"
] | a4963662205400e542668938ce5cf1ab9a66fba0 | https://github.com/sheebz/phantom-proxy/blob/a4963662205400e542668938ce5cf1ab9a66fba0/lib/proxy.js#L245-L261 | train | |
sheebz/phantom-proxy | lib/proxy.js | function (options, callbackFn) {
var self = this;
//compensate for optional options parm
if (typeof options === 'function') {
callbackFn = options;
options = {};
}
//assign default port
options.port = options.port ... | javascript | function (options, callbackFn) {
var self = this;
//compensate for optional options parm
if (typeof options === 'function') {
callbackFn = options;
options = {};
}
//assign default port
options.port = options.port ... | [
"function",
"(",
"options",
",",
"callbackFn",
")",
"{",
"var",
"self",
"=",
"this",
";",
"//compensate for optional options parm",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callbackFn",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";... | creates a new proxy session - creates phantomjs process and webserver module | [
"creates",
"a",
"new",
"proxy",
"session",
"-",
"creates",
"phantomjs",
"process",
"and",
"webserver",
"module"
] | a4963662205400e542668938ce5cf1ab9a66fba0 | https://github.com/sheebz/phantom-proxy/blob/a4963662205400e542668938ce5cf1ab9a66fba0/lib/proxy.js#L263-L289 | train | |
frdmn/openssl-cert-tools | lib/information.js | function (cert, cb) {
var infoObject = {},
subjectElements = [],
err;
var openssl = spawn('openssl', ['req', '-noout', '-subject', '-nameopt', 'RFC2253']);
// Catch stderr
openssl.stderr.on('data', function (out) {
err = new Error(out);
// Callback and return array
retu... | javascript | function (cert, cb) {
var infoObject = {},
subjectElements = [],
err;
var openssl = spawn('openssl', ['req', '-noout', '-subject', '-nameopt', 'RFC2253']);
// Catch stderr
openssl.stderr.on('data', function (out) {
err = new Error(out);
// Callback and return array
retu... | [
"function",
"(",
"cert",
",",
"cb",
")",
"{",
"var",
"infoObject",
"=",
"{",
"}",
",",
"subjectElements",
"=",
"[",
"]",
",",
"err",
";",
"var",
"openssl",
"=",
"spawn",
"(",
"'openssl'",
",",
"[",
"'req'",
",",
"'-noout'",
",",
"'-subject'",
",",
... | Decodes information from the provided certificate
sign request.
@param {String|Buffer} cert Input certificate
@param {Function} cb Callback
@return {Error} err, {Object} info Error and information object | [
"Decodes",
"information",
"from",
"the",
"provided",
"certificate",
"sign",
"request",
"."
] | 20cb9530459e83f0a22a928f06b776681c9d7dfa | https://github.com/frdmn/openssl-cert-tools/blob/20cb9530459e83f0a22a928f06b776681c9d7dfa/lib/information.js#L106-L152 | train | |
mattdesl/garnish | index.js | toBunyan | function toBunyan (obj) {
if (obj.msg && !obj.message) {
obj.message = obj.msg
delete obj.msg
}
if (typeof obj.level === 'number') {
if (obj.level === 20) obj.level = 'debug'
if (obj.level === 30) obj.level = 'info'
if (obj.level === 40) obj.level = 'warn'
if (obj.level === 50) obj.level ... | javascript | function toBunyan (obj) {
if (obj.msg && !obj.message) {
obj.message = obj.msg
delete obj.msg
}
if (typeof obj.level === 'number') {
if (obj.level === 20) obj.level = 'debug'
if (obj.level === 30) obj.level = 'info'
if (obj.level === 40) obj.level = 'warn'
if (obj.level === 50) obj.level ... | [
"function",
"toBunyan",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"msg",
"&&",
"!",
"obj",
".",
"message",
")",
"{",
"obj",
".",
"message",
"=",
"obj",
".",
"msg",
"delete",
"obj",
".",
"msg",
"}",
"if",
"(",
"typeof",
"obj",
".",
"level",
"... | mutate a bole log to bunyan log obj -> null | [
"mutate",
"a",
"bole",
"log",
"to",
"bunyan",
"log",
"obj",
"-",
">",
"null"
] | 27e01cb2769cf5a7d3a1487478d8d9ae63879995 | https://github.com/mattdesl/garnish/blob/27e01cb2769cf5a7d3a1487478d8d9ae63879995/index.js#L47-L59 | train |
back4app/antframework | plugins/ant-graphql/functions/mock.js | mock | function mock (_, mockArgs, fieldArgs, currentValue) {
if (currentValue !== undefined) {
return currentValue;
}
if (mockArgs && mockArgs.with) {
if (fieldArgs) {
try {
return Mustache.render(mockArgs.with, fieldArgs);
} catch (e) {
logger.error(new AntError(
'Coould n... | javascript | function mock (_, mockArgs, fieldArgs, currentValue) {
if (currentValue !== undefined) {
return currentValue;
}
if (mockArgs && mockArgs.with) {
if (fieldArgs) {
try {
return Mustache.render(mockArgs.with, fieldArgs);
} catch (e) {
logger.error(new AntError(
'Coould n... | [
"function",
"mock",
"(",
"_",
",",
"mockArgs",
",",
"fieldArgs",
",",
"currentValue",
")",
"{",
"if",
"(",
"currentValue",
"!==",
"undefined",
")",
"{",
"return",
"currentValue",
";",
"}",
"if",
"(",
"mockArgs",
"&&",
"mockArgs",
".",
"with",
")",
"{",
... | This function mocks a GraphQL field value. | [
"This",
"function",
"mocks",
"a",
"GraphQL",
"field",
"value",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/plugins/ant-graphql/functions/mock.js#L11-L30 | train |
yanceyou/runge-kutta-4 | lib/RungeKutta4.js | function(derives, xStart, yStart, h) {
this.derives = derives
this.x = xStart
this.y = yStart || []
this.dimension = this.y.length
this.h = h || 0.01
// cache the k1, k2, k3, k4 of each step
this._k1
this._k2
this._k3
this._k4
} | javascript | function(derives, xStart, yStart, h) {
this.derives = derives
this.x = xStart
this.y = yStart || []
this.dimension = this.y.length
this.h = h || 0.01
// cache the k1, k2, k3, k4 of each step
this._k1
this._k2
this._k3
this._k4
} | [
"function",
"(",
"derives",
",",
"xStart",
",",
"yStart",
",",
"h",
")",
"{",
"this",
".",
"derives",
"=",
"derives",
"this",
".",
"x",
"=",
"xStart",
"this",
".",
"y",
"=",
"yStart",
"||",
"[",
"]",
"this",
".",
"dimension",
"=",
"this",
".",
"y... | The fourth order Runge-Kutta integration method
@class RungeKutta4
@param {Function} derives Differential equations which needed to integrate
@param {Number} xStart Initial value problem: x0
@param {Array} yStart Initial value problem: y0
@param {Number} h Each step-size value | [
"The",
"fourth",
"order",
"Runge",
"-",
"Kutta",
"integration",
"method"
] | 4d4f2b5a9366727f11006d5527398ca9f9dd5162 | https://github.com/yanceyou/runge-kutta-4/blob/4d4f2b5a9366727f11006d5527398ca9f9dd5162/lib/RungeKutta4.js#L12-L24 | train | |
yanceyou/runge-kutta-4 | lib/RungeKutta4.js | function() {
var derives = this.derives,
x = this.x,
dimension = this.dimension,
h = this.h
var i, _y = []
// Alias: f() <=> this.derives()
// Xn <=> this.x
// Yn <=> this.y
// H <=> ... | javascript | function() {
var derives = this.derives,
x = this.x,
dimension = this.dimension,
h = this.h
var i, _y = []
// Alias: f() <=> this.derives()
// Xn <=> this.x
// Yn <=> this.y
// H <=> ... | [
"function",
"(",
")",
"{",
"var",
"derives",
"=",
"this",
".",
"derives",
",",
"x",
"=",
"this",
".",
"x",
",",
"dimension",
"=",
"this",
".",
"dimension",
",",
"h",
"=",
"this",
".",
"h",
"var",
"i",
",",
"_y",
"=",
"[",
"]",
"// Alias: f() <=> ... | Calculate each step according to step-size h
@return {Array} calculated result at this.x | [
"Calculate",
"each",
"step",
"according",
"to",
"step",
"-",
"size",
"h"
] | 4d4f2b5a9366727f11006d5527398ca9f9dd5162 | https://github.com/yanceyou/runge-kutta-4/blob/4d4f2b5a9366727f11006d5527398ca9f9dd5162/lib/RungeKutta4.js#L32-L76 | train | |
jasonmorita/react-redux-ui-state | dist/reducer.js | reducer | function reducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments[1];
// add initial state
if (action.type === (0, _.generateType)(_.types.add, (0, _get2.default)(action, 'payload.name'))) {
return _extends({}, state, _defineProperty... | javascript | function reducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments[1];
// add initial state
if (action.type === (0, _.generateType)(_.types.add, (0, _get2.default)(action, 'payload.name'))) {
return _extends({}, state, _defineProperty... | [
"function",
"reducer",
"(",
")",
"{",
"var",
"state",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"var",
"action",
"=",
"arguments",
"[",
"1",... | this reducer handles all state changes for the uiState slice | [
"this",
"reducer",
"handles",
"all",
"state",
"changes",
"for",
"the",
"uiState",
"slice"
] | 366a896f260c0ec3948afed86b2edf80ba9307af | https://github.com/jasonmorita/react-redux-ui-state/blob/366a896f260c0ec3948afed86b2edf80ba9307af/dist/reducer.js#L26-L55 | train |
EdwonLim/node-sass-china | scripts/coverage.js | suite | function suite() {
process.env.NODESASS_COV = 1;
var coveralls = spawn(bin('coveralls'));
var args = [bin('_mocha')].concat(['--reporter', 'mocha-lcov-reporter']);
var mocha = spawn(process.sass.runtime.execPath, args, {
env: process.env
});
mocha.on('error', function(err) {
console.error(err);
... | javascript | function suite() {
process.env.NODESASS_COV = 1;
var coveralls = spawn(bin('coveralls'));
var args = [bin('_mocha')].concat(['--reporter', 'mocha-lcov-reporter']);
var mocha = spawn(process.sass.runtime.execPath, args, {
env: process.env
});
mocha.on('error', function(err) {
console.error(err);
... | [
"function",
"suite",
"(",
")",
"{",
"process",
".",
"env",
".",
"NODESASS_COV",
"=",
"1",
";",
"var",
"coveralls",
"=",
"spawn",
"(",
"bin",
"(",
"'coveralls'",
")",
")",
";",
"var",
"args",
"=",
"[",
"bin",
"(",
"'_mocha'",
")",
"]",
".",
"concat"... | Run test suite
@api private | [
"Run",
"test",
"suite"
] | 96c13a84e4d68f20d9c5388ad58e2750c2ce786f | https://github.com/EdwonLim/node-sass-china/blob/96c13a84e4d68f20d9c5388ad58e2750c2ce786f/scripts/coverage.js#L16-L38 | train |
EdwonLim/node-sass-china | scripts/coverage.js | coverage | function coverage() {
var jscoverage = spawn(bin('jscoverage'), ['lib', 'lib-cov']);
jscoverage.on('error', function(err) {
console.error(err);
process.exit(1);
});
jscoverage.stderr.setEncoding('utf8');
jscoverage.stderr.on('data', function(err) {
console.error(err);
process.exit(1);
});
... | javascript | function coverage() {
var jscoverage = spawn(bin('jscoverage'), ['lib', 'lib-cov']);
jscoverage.on('error', function(err) {
console.error(err);
process.exit(1);
});
jscoverage.stderr.setEncoding('utf8');
jscoverage.stderr.on('data', function(err) {
console.error(err);
process.exit(1);
});
... | [
"function",
"coverage",
"(",
")",
"{",
"var",
"jscoverage",
"=",
"spawn",
"(",
"bin",
"(",
"'jscoverage'",
")",
",",
"[",
"'lib'",
",",
"'lib-cov'",
"]",
")",
";",
"jscoverage",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"conso... | Generate coverage files
@api private | [
"Generate",
"coverage",
"files"
] | 96c13a84e4d68f20d9c5388ad58e2750c2ce786f | https://github.com/EdwonLim/node-sass-china/blob/96c13a84e4d68f20d9c5388ad58e2750c2ce786f/scripts/coverage.js#L46-L61 | train |
mattdesl/garnish | lib/renderer.js | destructureMessage | function destructureMessage (msg) {
const keys = Object.keys(msg)
var res = ''
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
var val = msg[key]
if (i !== 0) res += '\n'
res += chalk.blue(' "' + key + '"')
res += ': '
res += chalk.green('"' + val + '"')
}
return res
} | javascript | function destructureMessage (msg) {
const keys = Object.keys(msg)
var res = ''
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
var val = msg[key]
if (i !== 0) res += '\n'
res += chalk.blue(' "' + key + '"')
res += ': '
res += chalk.green('"' + val + '"')
}
return res
} | [
"function",
"destructureMessage",
"(",
"msg",
")",
"{",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"msg",
")",
"var",
"res",
"=",
"''",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"va... | destructure a message onto an object if the message is an object. obj -> str | [
"destructure",
"a",
"message",
"onto",
"an",
"object",
"if",
"the",
"message",
"is",
"an",
"object",
".",
"obj",
"-",
">",
"str"
] | 27e01cb2769cf5a7d3a1487478d8d9ae63879995 | https://github.com/mattdesl/garnish/blob/27e01cb2769cf5a7d3a1487478d8d9ae63879995/lib/renderer.js#L180-L192 | train |
glayzzle/php-reflection | src/utils/comment.js | function(ast) {
if (ast) {
try {
var doc = reader.parse(ast.lines);
} catch(e) {
console.error(e.stack);
console.log('Source : \n* ' + ast.lines.join('\n* '));
return;
}
this.summary = doc.summary;
this.tags = {};
this.a... | javascript | function(ast) {
if (ast) {
try {
var doc = reader.parse(ast.lines);
} catch(e) {
console.error(e.stack);
console.log('Source : \n* ' + ast.lines.join('\n* '));
return;
}
this.summary = doc.summary;
this.tags = {};
this.a... | [
"function",
"(",
"ast",
")",
"{",
"if",
"(",
"ast",
")",
"{",
"try",
"{",
"var",
"doc",
"=",
"reader",
".",
"parse",
"(",
"ast",
".",
"lines",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"error",
"(",
"e",
".",
"stack",
")",
... | Initialize a comment declaration
@public
@constructor comment
@property {String} summary
@property {tag[]} tags
@property {annotation[]} annotations | [
"Initialize",
"a",
"comment",
"declaration"
] | 5a636a31a5f5e3f1745987c60d8b69665def3ca9 | https://github.com/glayzzle/php-reflection/blob/5a636a31a5f5e3f1745987c60d8b69665def3ca9/src/utils/comment.js#L20-L48 | train | |
glayzzle/php-reflection | src/repository/parse.js | function(e) {
delete self._pending[filename];
self.emit('error', {
name: filename,
error: e
});
return reject(e);
} | javascript | function(e) {
delete self._pending[filename];
self.emit('error', {
name: filename,
error: e
});
return reject(e);
} | [
"function",
"(",
"e",
")",
"{",
"delete",
"self",
".",
"_pending",
"[",
"filename",
"]",
";",
"self",
".",
"emit",
"(",
"'error'",
",",
"{",
"name",
":",
"filename",
",",
"error",
":",
"e",
"}",
")",
";",
"return",
"reject",
"(",
"e",
")",
";",
... | error retrieved from worker | [
"error",
"retrieved",
"from",
"worker"
] | 5a636a31a5f5e3f1745987c60d8b69665def3ca9 | https://github.com/glayzzle/php-reflection/blob/5a636a31a5f5e3f1745987c60d8b69665def3ca9/src/repository/parse.js#L97-L104 | train | |
back4app/antframework | packages/ant-cli/spec/bin/ant.spec.js | _expectUsageInstructions | async function _expectUsageInstructions(args) {
const { stdout, stderr } = await exec(getAntCommand(args));
expect(stdout).not.toBeNull();
expect(stdout.split('\n')[0]).toEqual(
'Usage: ant.js [--help] [--version] [--config <path>] [--verbose] <command>'
);
expect(stdout).toContain(
`Usage: ant.js [--... | javascript | async function _expectUsageInstructions(args) {
const { stdout, stderr } = await exec(getAntCommand(args));
expect(stdout).not.toBeNull();
expect(stdout.split('\n')[0]).toEqual(
'Usage: ant.js [--help] [--version] [--config <path>] [--verbose] <command>'
);
expect(stdout).toContain(
`Usage: ant.js [--... | [
"async",
"function",
"_expectUsageInstructions",
"(",
"args",
")",
"{",
"const",
"{",
"stdout",
",",
"stderr",
"}",
"=",
"await",
"exec",
"(",
"getAntCommand",
"(",
"args",
")",
")",
";",
"expect",
"(",
"stdout",
")",
".",
"not",
".",
"toBeNull",
"(",
... | Helper function to run the CLI command with args and check the expected
usage instructions as an output.
@param {string} args The args to be sent to the CLI command.
@async
@private | [
"Helper",
"function",
"to",
"run",
"the",
"CLI",
"command",
"with",
"args",
"and",
"check",
"the",
"expected",
"usage",
"instructions",
"as",
"an",
"output",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/packages/ant-cli/spec/bin/ant.spec.js#L32-L63 | train |
back4app/antframework | packages/ant-cli/spec/bin/ant.spec.js | _expectErrorMessage | async function _expectErrorMessage(args, ...errorMessages) {
expect.hasAssertions();
try {
await exec(getAntCommand(args));
throw new Error('It is expected to throw some error');
} catch (e) {
const { code, stdout, stderr } = e;
expect(code).toEqual(1);
expect(stdout).toEqual('');
for(cons... | javascript | async function _expectErrorMessage(args, ...errorMessages) {
expect.hasAssertions();
try {
await exec(getAntCommand(args));
throw new Error('It is expected to throw some error');
} catch (e) {
const { code, stdout, stderr } = e;
expect(code).toEqual(1);
expect(stdout).toEqual('');
for(cons... | [
"async",
"function",
"_expectErrorMessage",
"(",
"args",
",",
"...",
"errorMessages",
")",
"{",
"expect",
".",
"hasAssertions",
"(",
")",
";",
"try",
"{",
"await",
"exec",
"(",
"getAntCommand",
"(",
"args",
")",
")",
";",
"throw",
"new",
"Error",
"(",
"'... | Helper function to run the CLI command with args and check the expected error
messages as an output.
@param {string} args The args to be sent to the CLI command.
@param {string} errorMessages The expected error messages.
@async
@private | [
"Helper",
"function",
"to",
"run",
"the",
"CLI",
"command",
"with",
"args",
"and",
"check",
"the",
"expected",
"error",
"messages",
"as",
"an",
"output",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/packages/ant-cli/spec/bin/ant.spec.js#L73-L86 | train |
back4app/antframework | packages/ant-cli/spec/bin/ant.spec.js | _expectSuccessMessage | async function _expectSuccessMessage(args, ...successMessages) {
const { stdout, stderr } = await exec(getAntCommand(args));
for (const successMessage of successMessages) {
expect(stdout).toContain(successMessage);
}
expect(stderr).toEqual('');
} | javascript | async function _expectSuccessMessage(args, ...successMessages) {
const { stdout, stderr } = await exec(getAntCommand(args));
for (const successMessage of successMessages) {
expect(stdout).toContain(successMessage);
}
expect(stderr).toEqual('');
} | [
"async",
"function",
"_expectSuccessMessage",
"(",
"args",
",",
"...",
"successMessages",
")",
"{",
"const",
"{",
"stdout",
",",
"stderr",
"}",
"=",
"await",
"exec",
"(",
"getAntCommand",
"(",
"args",
")",
")",
";",
"for",
"(",
"const",
"successMessage",
"... | Helper function to run the CLI command with args and check the expected CLI
success message.
@param {String} args The args to be sent to the CLI command.
@param {String|Array<String>} successMessages The expected success messages.
@async
@private | [
"Helper",
"function",
"to",
"run",
"the",
"CLI",
"command",
"with",
"args",
"and",
"check",
"the",
"expected",
"CLI",
"success",
"message",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/packages/ant-cli/spec/bin/ant.spec.js#L96-L102 | train |
back4app/antframework | packages/ant-cli/spec/bin/ant.spec.js | _expectPackageVersion | async function _expectPackageVersion(args) {
const packageVersion = require(
path.resolve(__dirname, '../../package.json')
).version;
await _expectSuccessMessage(args, `${packageVersion}\n`);
} | javascript | async function _expectPackageVersion(args) {
const packageVersion = require(
path.resolve(__dirname, '../../package.json')
).version;
await _expectSuccessMessage(args, `${packageVersion}\n`);
} | [
"async",
"function",
"_expectPackageVersion",
"(",
"args",
")",
"{",
"const",
"packageVersion",
"=",
"require",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'../../package.json'",
")",
")",
".",
"version",
";",
"await",
"_expectSuccessMessage",
"(",
"arg... | Helper function to run the CLI command with args and check the expected CLI
version.
@param {string} args The args to be sent to the CLI command.
@async
@private | [
"Helper",
"function",
"to",
"run",
"the",
"CLI",
"command",
"with",
"args",
"and",
"check",
"the",
"expected",
"CLI",
"version",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/packages/ant-cli/spec/bin/ant.spec.js#L111-L116 | train |
glayzzle/php-reflection | src/utils/position.js | function(node) {
if (node) {
this.start = {
line: node.start.line,
column: node.start.column
};
this.end = {
line: node.end.line,
column: node.end.column
};
this.offset = {
start: node.start.offset,
end: ... | javascript | function(node) {
if (node) {
this.start = {
line: node.start.line,
column: node.start.column
};
this.end = {
line: node.end.line,
column: node.end.column
};
this.offset = {
start: node.start.offset,
end: ... | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
")",
"{",
"this",
".",
"start",
"=",
"{",
"line",
":",
"node",
".",
"start",
".",
"line",
",",
"column",
":",
"node",
".",
"start",
".",
"column",
"}",
";",
"this",
".",
"end",
"=",
"{",
"... | Defines a position object
@constructor Position
@property {Object} start
@property {Object} end
@property {Object} offset | [
"Defines",
"a",
"position",
"object"
] | 5a636a31a5f5e3f1745987c60d8b69665def3ca9 | https://github.com/glayzzle/php-reflection/blob/5a636a31a5f5e3f1745987c60d8b69665def3ca9/src/utils/position.js#L15-L30 | train | |
jbhannah/amperize | lib/amperize.js | Amperize | function Amperize(options) {
this.config = _.merge({}, DEFAULTS, options || {});
this.emits = emits;
this.htmlParser = new html.Parser(
new html.DomHandler(this.emits('read'))
);
} | javascript | function Amperize(options) {
this.config = _.merge({}, DEFAULTS, options || {});
this.emits = emits;
this.htmlParser = new html.Parser(
new html.DomHandler(this.emits('read'))
);
} | [
"function",
"Amperize",
"(",
"options",
")",
"{",
"this",
".",
"config",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"DEFAULTS",
",",
"options",
"||",
"{",
"}",
")",
";",
"this",
".",
"emits",
"=",
"emits",
";",
"this",
".",
"htmlParser",
"=",
"n... | Amperizer constructor. Borrows from Minimize.
https://github.com/Swaagie/minimize/blob/4b815e274a424ca89551d28c4e0dd8b06d9bbdc2/lib/minimize.js#L15
@constructor
@param {Object} options Options object
@api public | [
"Amperizer",
"constructor",
".",
"Borrows",
"from",
"Minimize",
"."
] | 07eaf97136176cc5282702c688cfeef3e70991fb | https://github.com/jbhannah/amperize/blob/07eaf97136176cc5282702c688cfeef3e70991fb/lib/amperize.js#L43-L50 | train |
back4app/antframework | plugins/ant-graphql/functions/resolve.js | resolve | async function resolve (ant, resolveArgs, fieldArgs, currentValue, model) {
let field = null;
if (model) {
field = model.field;
}
if (ant && resolveArgs && resolveArgs.to) {
const antFunction = ant.functionController.getFunction(resolveArgs.to);
if (!antFunction) {
logger.error(new AntError(
... | javascript | async function resolve (ant, resolveArgs, fieldArgs, currentValue, model) {
let field = null;
if (model) {
field = model.field;
}
if (ant && resolveArgs && resolveArgs.to) {
const antFunction = ant.functionController.getFunction(resolveArgs.to);
if (!antFunction) {
logger.error(new AntError(
... | [
"async",
"function",
"resolve",
"(",
"ant",
",",
"resolveArgs",
",",
"fieldArgs",
",",
"currentValue",
",",
"model",
")",
"{",
"let",
"field",
"=",
"null",
";",
"if",
"(",
"model",
")",
"{",
"field",
"=",
"model",
".",
"field",
";",
"}",
"if",
"(",
... | This function resolves a GraphQL field value. | [
"This",
"function",
"resolves",
"a",
"GraphQL",
"field",
"value",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/plugins/ant-graphql/functions/resolve.js#L12-L54 | train |
jasonmorita/react-redux-ui-state | dist/index.js | dispatchToProps | function dispatchToProps(dispatch) {
return {
add: function add() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var name = arguments[1];
return dispatch({
type: generateType(types.add, name),
payload... | javascript | function dispatchToProps(dispatch) {
return {
add: function add() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var name = arguments[1];
return dispatch({
type: generateType(types.add, name),
payload... | [
"function",
"dispatchToProps",
"(",
"dispatch",
")",
"{",
"return",
"{",
"add",
":",
"function",
"add",
"(",
")",
"{",
"var",
"state",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[... | these are set as props on the HOC | [
"these",
"are",
"set",
"as",
"props",
"on",
"the",
"HOC"
] | 366a896f260c0ec3948afed86b2edf80ba9307af | https://github.com/jasonmorita/react-redux-ui-state/blob/366a896f260c0ec3948afed86b2edf80ba9307af/dist/index.js#L74-L121 | train |
dudemelo/sails-hook-flash | lib/flash.js | function (type) {
if (this.has(type)) {
var messages = req.session[_session_key][type];
delete req.session[_session_key][type];
}
return messages||[];
} | javascript | function (type) {
if (this.has(type)) {
var messages = req.session[_session_key][type];
delete req.session[_session_key][type];
}
return messages||[];
} | [
"function",
"(",
"type",
")",
"{",
"if",
"(",
"this",
".",
"has",
"(",
"type",
")",
")",
"{",
"var",
"messages",
"=",
"req",
".",
"session",
"[",
"_session_key",
"]",
"[",
"type",
"]",
";",
"delete",
"req",
".",
"session",
"[",
"_session_key",
"]",... | Get a specific type of flash messages
@param {string} type
@return {object} | [
"Get",
"a",
"specific",
"type",
"of",
"flash",
"messages"
] | f23f00239b4d2d9f1925920ebd7da45e42c3d79d | https://github.com/dudemelo/sails-hook-flash/blob/f23f00239b4d2d9f1925920ebd7da45e42c3d79d/lib/flash.js#L59-L65 | train | |
frdmn/openssl-cert-tools | lib/certificate.js | function (host, port, cb) {
var err,
data = {};
var openssl = spawn('openssl', ['s_client', '-connect', host + ':' + port, '-servername', host]);
// Clear timeout when execution was successful
openssl.on('exit', function(){
clearTimeout(timeoutTimer);
});
// Catch stderr and sea... | javascript | function (host, port, cb) {
var err,
data = {};
var openssl = spawn('openssl', ['s_client', '-connect', host + ':' + port, '-servername', host]);
// Clear timeout when execution was successful
openssl.on('exit', function(){
clearTimeout(timeoutTimer);
});
// Catch stderr and sea... | [
"function",
"(",
"host",
",",
"port",
",",
"cb",
")",
"{",
"var",
"err",
",",
"data",
"=",
"{",
"}",
";",
"var",
"openssl",
"=",
"spawn",
"(",
"'openssl'",
",",
"[",
"'s_client'",
",",
"'-connect'",
",",
"host",
"+",
"':'",
"+",
"port",
",",
"'-s... | Download certificate from remote host
@param {String} host Input hostname
@param {String} port Input port
@param {Function} cb Callback
@return {Error} err, {Object} data Error and data object | [
"Download",
"certificate",
"from",
"remote",
"host"
] | 20cb9530459e83f0a22a928f06b776681c9d7dfa | https://github.com/frdmn/openssl-cert-tools/blob/20cb9530459e83f0a22a928f06b776681c9d7dfa/lib/certificate.js#L19-L74 | train | |
EdwonLim/node-sass-china | scripts/install.js | applyProxy | function applyProxy(options, cb) {
npmconf.load({}, function (er, conf) {
var proxyUrl;
if (!er) {
proxyUrl = conf.get('https-proxy') ||
conf.get('proxy') ||
conf.get('http-proxy');
}
var env = process.env;
options.proxy = proxyUrl ||
... | javascript | function applyProxy(options, cb) {
npmconf.load({}, function (er, conf) {
var proxyUrl;
if (!er) {
proxyUrl = conf.get('https-proxy') ||
conf.get('proxy') ||
conf.get('http-proxy');
}
var env = process.env;
options.proxy = proxyUrl ||
... | [
"function",
"applyProxy",
"(",
"options",
",",
"cb",
")",
"{",
"npmconf",
".",
"load",
"(",
"{",
"}",
",",
"function",
"(",
"er",
",",
"conf",
")",
"{",
"var",
"proxyUrl",
";",
"if",
"(",
"!",
"er",
")",
"{",
"proxyUrl",
"=",
"conf",
".",
"get",
... | Get applyProxy settings
@param {Object} options
@param {Function} cb
@api private | [
"Get",
"applyProxy",
"settings"
] | 96c13a84e4d68f20d9c5388ad58e2750c2ce786f | https://github.com/EdwonLim/node-sass-china/blob/96c13a84e4d68f20d9c5388ad58e2750c2ce786f/scripts/install.js#L67-L87 | train |
ractivejs/ractive-load | dist/ractive-load.es.js | generateSourceMap | function generateSourceMap ( definition, options ) {
if ( options === void 0 ) { options = {}; }
if ( 'padding' in options ) {
options.offset = options.padding;
if ( !alreadyWarned ) {
console.warn( 'rcu: options.padding is deprecated, use options.offset instead' ); // eslint-disable-line no-console
alrea... | javascript | function generateSourceMap ( definition, options ) {
if ( options === void 0 ) { options = {}; }
if ( 'padding' in options ) {
options.offset = options.padding;
if ( !alreadyWarned ) {
console.warn( 'rcu: options.padding is deprecated, use options.offset instead' ); // eslint-disable-line no-console
alrea... | [
"function",
"generateSourceMap",
"(",
"definition",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"void",
"0",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"'padding'",
"in",
"options",
")",
"{",
"options",
".",
"offset",
"=",
"o... | Generates a v3 sourcemap between an original source and its built form
@param {object} definition - the result of `rcu.parse( originalSource )`
@param {object} options
@param {string} options.source - the name of the original source file
@param {number=} options.offset - the number of lines in the generated
code that p... | [
"Generates",
"a",
"v3",
"sourcemap",
"between",
"an",
"original",
"source",
"and",
"its",
"built",
"form"
] | 5fdb5e1b7c12c21330d7c96c8f281e149fb1df81 | https://github.com/ractivejs/ractive-load/blob/5fdb5e1b7c12c21330d7c96c8f281e149fb1df81/dist/ractive-load.es.js#L88-L155 | train |
back4app/antframework | packages/ant-util-yargs/lib/yargsHelper.js | handleErrorMessage | function handleErrorMessage (msg, err, command, exitProcess) {
setErrorHandled();
console.error(`Fatal => ${msg}`);
if (err) {
console.error();
if (isVerboseMode()) {
console.error('Error stack:');
console.error(err.stack);
} else {
console.error('For getting the error stack, use --v... | javascript | function handleErrorMessage (msg, err, command, exitProcess) {
setErrorHandled();
console.error(`Fatal => ${msg}`);
if (err) {
console.error();
if (isVerboseMode()) {
console.error('Error stack:');
console.error(err.stack);
} else {
console.error('For getting the error stack, use --v... | [
"function",
"handleErrorMessage",
"(",
"msg",
",",
"err",
",",
"command",
",",
"exitProcess",
")",
"{",
"setErrorHandled",
"(",
")",
";",
"console",
".",
"error",
"(",
"`",
"${",
"msg",
"}",
"`",
")",
";",
"if",
"(",
"err",
")",
"{",
"console",
".",
... | Helper function that can be used to handle and print error messages occurred
during Yargs parsing and execution.
@param {String} msg The error message.
@param {Error} err The error that generated the problem.
@param {String} command The command that failed.
@param {Boolean} exitProcess Flag indicating it should invoke ... | [
"Helper",
"function",
"that",
"can",
"be",
"used",
"to",
"handle",
"and",
"print",
"error",
"messages",
"occurred",
"during",
"Yargs",
"parsing",
"and",
"execution",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/packages/ant-util-yargs/lib/yargsHelper.js#L44-L68 | train |
back4app/antframework | packages/ant-util-yargs/lib/yargsHelper.js | attachFailHandler | function attachFailHandler (yargs, handler) {
yargs.fail((msg, err, usage) => {
// If failure was handled previously, does nothing.
if (errorHandled) {
return;
}
handler(msg, err, usage);
if (errorHandled) {
// Workaround to avoid yargs from running the command.
// Since yargs ha... | javascript | function attachFailHandler (yargs, handler) {
yargs.fail((msg, err, usage) => {
// If failure was handled previously, does nothing.
if (errorHandled) {
return;
}
handler(msg, err, usage);
if (errorHandled) {
// Workaround to avoid yargs from running the command.
// Since yargs ha... | [
"function",
"attachFailHandler",
"(",
"yargs",
",",
"handler",
")",
"{",
"yargs",
".",
"fail",
"(",
"(",
"msg",
",",
"err",
",",
"usage",
")",
"=>",
"{",
"// If failure was handled previously, does nothing.",
"if",
"(",
"errorHandled",
")",
"{",
"return",
";",... | Attaches an error handler into the Yargs instance.
Guarantees the single error handling with the `errorHandled` flag,
which can be set with the `setErrorHandled` function.
@param {!Yargs} yargs The [Yargs]{@link https://github.com/yargs/yargs/blob/master/yargs.js}
instance.
@param {!Function} handler The error handle... | [
"Attaches",
"an",
"error",
"handler",
"into",
"the",
"Yargs",
"instance",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/packages/ant-util-yargs/lib/yargsHelper.js#L80-L98 | train |
back4app/antframework | packages/ant-util-yargs/lib/yargsHelper.js | executeCommand | async function executeCommand(command, asyncFn) {
try {
await asyncFn();
process.exit(0);
} catch (e) {
handleErrorMessage(e.message, e, command);
}
} | javascript | async function executeCommand(command, asyncFn) {
try {
await asyncFn();
process.exit(0);
} catch (e) {
handleErrorMessage(e.message, e, command);
}
} | [
"async",
"function",
"executeCommand",
"(",
"command",
",",
"asyncFn",
")",
"{",
"try",
"{",
"await",
"asyncFn",
"(",
")",
";",
"process",
".",
"exit",
"(",
"0",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"handleErrorMessage",
"(",
"e",
".",
"messag... | Helper function encapsulates an asynchronous function to be executed
and handled on any errors thrown, providing a friendly error message
based on the command that this function represents.
In case of success, the process is exit with code 0.
In case of failure, the process is exit with code 1.
@param {!String} comman... | [
"Helper",
"function",
"encapsulates",
"an",
"asynchronous",
"function",
"to",
"be",
"executed",
"and",
"handled",
"on",
"any",
"errors",
"thrown",
"providing",
"a",
"friendly",
"error",
"message",
"based",
"on",
"the",
"command",
"that",
"this",
"function",
"rep... | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/packages/ant-util-yargs/lib/yargsHelper.js#L129-L136 | train |
back4app/antframework | plugins/ant-graphql/functions/subscribe.js | subscribe | async function subscribe (ant, field, directiveArgs, fieldArgs) {
if (ant && field && directiveArgs && directiveArgs.to) {
const antFunction = ant.functionController.getFunction(directiveArgs.to);
if (!antFunction) {
logger.error(new AntError(
`Could not find "${directiveArgs.to}" function`
... | javascript | async function subscribe (ant, field, directiveArgs, fieldArgs) {
if (ant && field && directiveArgs && directiveArgs.to) {
const antFunction = ant.functionController.getFunction(directiveArgs.to);
if (!antFunction) {
logger.error(new AntError(
`Could not find "${directiveArgs.to}" function`
... | [
"async",
"function",
"subscribe",
"(",
"ant",
",",
"field",
",",
"directiveArgs",
",",
"fieldArgs",
")",
"{",
"if",
"(",
"ant",
"&&",
"field",
"&&",
"directiveArgs",
"&&",
"directiveArgs",
".",
"to",
")",
"{",
"const",
"antFunction",
"=",
"ant",
".",
"fu... | This function resolves a GraphQL @subscribe directive value. | [
"This",
"function",
"resolves",
"a",
"GraphQL"
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/plugins/ant-graphql/functions/subscribe.js#L12-L35 | train |
bosonic/bosonic | dist/bosonic-runtime.js | function(inEvent) {
var eventCopy = Object.create(null);
var p;
for (var i = 0; i < CLONE_PROPS.length; i++) {
p = CLONE_PROPS[i];
eventCopy[p] = inEvent[p] || CLONE_DEFAULTS[i];
// Work around SVGInstanceElement shadow tree
// Return the <use> element that is represen... | javascript | function(inEvent) {
var eventCopy = Object.create(null);
var p;
for (var i = 0; i < CLONE_PROPS.length; i++) {
p = CLONE_PROPS[i];
eventCopy[p] = inEvent[p] || CLONE_DEFAULTS[i];
// Work around SVGInstanceElement shadow tree
// Return the <use> element that is represen... | [
"function",
"(",
"inEvent",
")",
"{",
"var",
"eventCopy",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"var",
"p",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"CLONE_PROPS",
".",
"length",
";",
"i",
"++",
")",
"{",
"p",
"=",
... | Returns a snapshot of inEvent, with writable properties.
@param {Event} inEvent An event that contains properties to copy.
@return {Object} An object containing shallow copies of `inEvent`'s
properties. | [
"Returns",
"a",
"snapshot",
"of",
"inEvent",
"with",
"writable",
"properties",
"."
] | b2d1b892e79f1d9bf7a9762205ea187cf24b8acd | https://github.com/bosonic/bosonic/blob/b2d1b892e79f1d9bf7a9762205ea187cf24b8acd/dist/bosonic-runtime.js#L426-L450 | train | |
bosonic/bosonic | dist/bosonic-runtime.js | function(inEvent) {
var lts = mouse.lastTouches;
var t = inEvent.changedTouches[0];
// only the primary finger will synth mouse events
if (this.isPrimaryTouch(t)) {
// remember x/y of last touch
var lt = { x: t.clientX, y: t.clientY };
lts.push(lt);
var fn = (fu... | javascript | function(inEvent) {
var lts = mouse.lastTouches;
var t = inEvent.changedTouches[0];
// only the primary finger will synth mouse events
if (this.isPrimaryTouch(t)) {
// remember x/y of last touch
var lt = { x: t.clientX, y: t.clientY };
lts.push(lt);
var fn = (fu... | [
"function",
"(",
"inEvent",
")",
"{",
"var",
"lts",
"=",
"mouse",
".",
"lastTouches",
";",
"var",
"t",
"=",
"inEvent",
".",
"changedTouches",
"[",
"0",
"]",
";",
"// only the primary finger will synth mouse events",
"if",
"(",
"this",
".",
"isPrimaryTouch",
"(... | prevent synth mouse events from creating pointer events | [
"prevent",
"synth",
"mouse",
"events",
"from",
"creating",
"pointer",
"events"
] | b2d1b892e79f1d9bf7a9762205ea187cf24b8acd | https://github.com/bosonic/bosonic/blob/b2d1b892e79f1d9bf7a9762205ea187cf24b8acd/dist/bosonic-runtime.js#L1237-L1255 | train | |
bosonic/bosonic | dist/bosonic-runtime.js | function(name, bool, node) {
node = node || this;
if (arguments.length == 1) {
bool = !node.hasAttribute(name) || node.getAttribute(name) == 'false';
}
bool ? node.setAttribute(name, 'true') : node.setAttribute(name, 'false');
} | javascript | function(name, bool, node) {
node = node || this;
if (arguments.length == 1) {
bool = !node.hasAttribute(name) || node.getAttribute(name) == 'false';
}
bool ? node.setAttribute(name, 'true') : node.setAttribute(name, 'false');
} | [
"function",
"(",
"name",
",",
"bool",
",",
"node",
")",
"{",
"node",
"=",
"node",
"||",
"this",
";",
"if",
"(",
"arguments",
".",
"length",
"==",
"1",
")",
"{",
"bool",
"=",
"!",
"node",
".",
"hasAttribute",
"(",
"name",
")",
"||",
"node",
".",
... | for ARIA state properties | [
"for",
"ARIA",
"state",
"properties"
] | b2d1b892e79f1d9bf7a9762205ea187cf24b8acd | https://github.com/bosonic/bosonic/blob/b2d1b892e79f1d9bf7a9762205ea187cf24b8acd/dist/bosonic-runtime.js#L1781-L1787 | train | |
back4app/antframework | plugins/ant-graphql/lib/util/schemaHelper.js | generateSchema | function generateSchema(ant, graphQL, _model) {
let model = [];
if (graphQL) {
for (const directive of graphQL.directiveController.directives) {
const directiveDefinition = graphQL.directiveController
.getDirectiveDefinition(directive);
if (directiveDefinition) {
model.push(directiv... | javascript | function generateSchema(ant, graphQL, _model) {
let model = [];
if (graphQL) {
for (const directive of graphQL.directiveController.directives) {
const directiveDefinition = graphQL.directiveController
.getDirectiveDefinition(directive);
if (directiveDefinition) {
model.push(directiv... | [
"function",
"generateSchema",
"(",
"ant",
",",
"graphQL",
",",
"_model",
")",
"{",
"let",
"model",
"=",
"[",
"]",
";",
"if",
"(",
"graphQL",
")",
"{",
"for",
"(",
"const",
"directive",
"of",
"graphQL",
".",
"directiveController",
".",
"directives",
")",
... | Helper function that can be used to generate a GraphQL schema from Ant
Framework's config.
@param {Ant} ant The {@link Ant} framework instance.
@param {GraphQL} graphQL The {@link GraphQL} plugin instance.
@param {String} _model An optional pre-loaded GraphQL model to be used
instead of requiring the GraphQL plugin to ... | [
"Helper",
"function",
"that",
"can",
"be",
"used",
"to",
"generate",
"a",
"GraphQL",
"schema",
"from",
"Ant",
"Framework",
"s",
"config",
"."
] | 7cba4eb6b4846648471662e0265aacd5a7f18645 | https://github.com/back4app/antframework/blob/7cba4eb6b4846648471662e0265aacd5a7f18645/plugins/ant-graphql/lib/util/schemaHelper.js#L21-L127 | train |
Adeptive/Loxone-NodeJS | loxone-api.js | function(url, callback) {
url = getBaseUrl() + url;
http.get(url, function(response) {
var output = "";
response.on('data', function (chunk) {
output += chunk;
});
response.on('end', function() {
output = JSON.parse(output... | javascript | function(url, callback) {
url = getBaseUrl() + url;
http.get(url, function(response) {
var output = "";
response.on('data', function (chunk) {
output += chunk;
});
response.on('end', function() {
output = JSON.parse(output... | [
"function",
"(",
"url",
",",
"callback",
")",
"{",
"url",
"=",
"getBaseUrl",
"(",
")",
"+",
"url",
";",
"http",
".",
"get",
"(",
"url",
",",
"function",
"(",
"response",
")",
"{",
"var",
"output",
"=",
"\"\"",
";",
"response",
".",
"on",
"(",
"'d... | UTILITY METHODS +++++++++++++++++++++++++++++ | [
"UTILITY",
"METHODS",
"+++++++++++++++++++++++++++++"
] | 8e047dbace33341dc07da4f9a1c304ae0dc85c7f | https://github.com/Adeptive/Loxone-NodeJS/blob/8e047dbace33341dc07da4f9a1c304ae0dc85c7f/loxone-api.js#L77-L113 | train | |
mikolalysenko/ao-mesher | mesh.js | facetAO | function facetAO(a00, a01, a02,
a10, a12,
a20, a21, a22) {
var s00 = (a00&OPAQUE_BIT) ? 1 : 0
, s01 = (a01&OPAQUE_BIT) ? 1 : 0
, s02 = (a02&OPAQUE_BIT) ? 1 : 0
, s10 = (a10&OPAQUE_BIT) ? 1 : 0
, s12 = (a12&OPAQUE_BIT) ? 1 : 0
, s20 = (a20&OPAQUE_BIT) ? 1 : 0
... | javascript | function facetAO(a00, a01, a02,
a10, a12,
a20, a21, a22) {
var s00 = (a00&OPAQUE_BIT) ? 1 : 0
, s01 = (a01&OPAQUE_BIT) ? 1 : 0
, s02 = (a02&OPAQUE_BIT) ? 1 : 0
, s10 = (a10&OPAQUE_BIT) ? 1 : 0
, s12 = (a12&OPAQUE_BIT) ? 1 : 0
, s20 = (a20&OPAQUE_BIT) ? 1 : 0
... | [
"function",
"facetAO",
"(",
"a00",
",",
"a01",
",",
"a02",
",",
"a10",
",",
"a12",
",",
"a20",
",",
"a21",
",",
"a22",
")",
"{",
"var",
"s00",
"=",
"(",
"a00",
"&",
"OPAQUE_BIT",
")",
"?",
"1",
":",
"0",
",",
"s01",
"=",
"(",
"a01",
"&",
"O... | Calculates the ambient occlusion bit mask for a facet | [
"Calculates",
"the",
"ambient",
"occlusion",
"bit",
"mask",
"for",
"a",
"facet"
] | d0a22c2d20fae6e3f64ec64bb8a7f6e35745aeae | https://github.com/mikolalysenko/ao-mesher/blob/d0a22c2d20fae6e3f64ec64bb8a7f6e35745aeae/mesh.js#L48-L63 | train |
mikolalysenko/ao-mesher | mesh.js | generateSurfaceVoxel | function generateSurfaceVoxel(
v000, v001, v002,
v010, v011, v012,
v020, v021, v022,
v100, v101, v102,
v110, v111, v112,
v120, v121, v122) {
var t0 = !(v011 & OPAQUE_BIT)
, t1 = !(v111 & OPAQUE_BIT)
if(v111 && (!v011 || (t0 && !t1))) {
return v111 | FLIP_BIT | facetAO(v000, v001, v002,
... | javascript | function generateSurfaceVoxel(
v000, v001, v002,
v010, v011, v012,
v020, v021, v022,
v100, v101, v102,
v110, v111, v112,
v120, v121, v122) {
var t0 = !(v011 & OPAQUE_BIT)
, t1 = !(v111 & OPAQUE_BIT)
if(v111 && (!v011 || (t0 && !t1))) {
return v111 | FLIP_BIT | facetAO(v000, v001, v002,
... | [
"function",
"generateSurfaceVoxel",
"(",
"v000",
",",
"v001",
",",
"v002",
",",
"v010",
",",
"v011",
",",
"v012",
",",
"v020",
",",
"v021",
",",
"v022",
",",
"v100",
",",
"v101",
",",
"v102",
",",
"v110",
",",
"v111",
",",
"v112",
",",
"v120",
",",... | Generates a surface voxel, complete with ambient occlusion type | [
"Generates",
"a",
"surface",
"voxel",
"complete",
"with",
"ambient",
"occlusion",
"type"
] | d0a22c2d20fae6e3f64ec64bb8a7f6e35745aeae | https://github.com/mikolalysenko/ao-mesher/blob/d0a22c2d20fae6e3f64ec64bb8a7f6e35745aeae/mesh.js#L66-L84 | train |
soplakanets/node-forecastio | index.js | ForecastIoAPIError | function ForecastIoAPIError(url, statusCode, body) {
this.response = {
statusCode: statusCode,
body: body
};
this.message = this._formatErrorMessage(body);
this.name = "ForecastIoAPIError";
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.request = "GET " + url;
} | javascript | function ForecastIoAPIError(url, statusCode, body) {
this.response = {
statusCode: statusCode,
body: body
};
this.message = this._formatErrorMessage(body);
this.name = "ForecastIoAPIError";
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.request = "GET " + url;
} | [
"function",
"ForecastIoAPIError",
"(",
"url",
",",
"statusCode",
",",
"body",
")",
"{",
"this",
".",
"response",
"=",
"{",
"statusCode",
":",
"statusCode",
",",
"body",
":",
"body",
"}",
";",
"this",
".",
"message",
"=",
"this",
".",
"_formatErrorMessage",... | Represents API errors. | [
"Represents",
"API",
"errors",
"."
] | 7082666ef19c358b3adcdf667aba34b5394d69e8 | https://github.com/soplakanets/node-forecastio/blob/7082666ef19c358b3adcdf667aba34b5394d69e8/index.js#L85-L95 | train |
EdwonLim/node-sass-china | lib/extensions.js | getRuntimeInfo | function getRuntimeInfo() {
var execPath = fs.realpathSync(process.execPath); // resolve symbolic link
var runtime = execPath
.split(/[\\/]+/).pop()
.split('.').shift();
runtime = runtime === 'nodejs' ? 'node' : runtime;
return {
name: runtime,
execPath: execPath
};
} | javascript | function getRuntimeInfo() {
var execPath = fs.realpathSync(process.execPath); // resolve symbolic link
var runtime = execPath
.split(/[\\/]+/).pop()
.split('.').shift();
runtime = runtime === 'nodejs' ? 'node' : runtime;
return {
name: runtime,
execPath: execPath
};
} | [
"function",
"getRuntimeInfo",
"(",
")",
"{",
"var",
"execPath",
"=",
"fs",
".",
"realpathSync",
"(",
"process",
".",
"execPath",
")",
";",
"// resolve symbolic link",
"var",
"runtime",
"=",
"execPath",
".",
"split",
"(",
"/",
"[\\\\/]+",
"/",
")",
".",
"po... | Get Runtime Info
@api private | [
"Get",
"Runtime",
"Info"
] | 96c13a84e4d68f20d9c5388ad58e2750c2ce786f | https://github.com/EdwonLim/node-sass-china/blob/96c13a84e4d68f20d9c5388ad58e2750c2ce786f/lib/extensions.js#L34-L47 | train |
EdwonLim/node-sass-china | lib/extensions.js | getBinaryUrl | function getBinaryUrl() {
var site = flags['--sass-binary-site'] ||
process.env.SASS_BINARY_SITE ||
pkg.nodeSassConfig.binarySite;
return [site, 'v' + pkg.version, sass.binaryName].join('/');
} | javascript | function getBinaryUrl() {
var site = flags['--sass-binary-site'] ||
process.env.SASS_BINARY_SITE ||
pkg.nodeSassConfig.binarySite;
return [site, 'v' + pkg.version, sass.binaryName].join('/');
} | [
"function",
"getBinaryUrl",
"(",
")",
"{",
"var",
"site",
"=",
"flags",
"[",
"'--sass-binary-site'",
"]",
"||",
"process",
".",
"env",
".",
"SASS_BINARY_SITE",
"||",
"pkg",
".",
"nodeSassConfig",
".",
"binarySite",
";",
"return",
"[",
"site",
",",
"'v'",
"... | Determine the URL to fetch binary file from.
By default feth from the node-sass distribution
site on GitHub.
The default URL can be overriden using
the environment variable SASS_BINARY_SITE
or a command line option --sass-binary-site:
node scripts/install.js --sass-binary-site http://example.com/
The URL should to t... | [
"Determine",
"the",
"URL",
"to",
"fetch",
"binary",
"file",
"from",
".",
"By",
"default",
"feth",
"from",
"the",
"node",
"-",
"sass",
"distribution",
"site",
"on",
"GitHub",
"."
] | 96c13a84e4d68f20d9c5388ad58e2750c2ce786f | https://github.com/EdwonLim/node-sass-china/blob/96c13a84e4d68f20d9c5388ad58e2750c2ce786f/lib/extensions.js#L104-L109 | train |
tntvis/tnt.genome | src/genome.js | function (where) {
if (where !== undefined) {
if (where.gene !== undefined) {
get_gene(where);
return;
} else {
if (where.species === undefined) {
where.species = genome_browser.species();
} else {
... | javascript | function (where) {
if (where !== undefined) {
if (where.gene !== undefined) {
get_gene(where);
return;
} else {
if (where.species === undefined) {
where.species = genome_browser.species();
} else {
... | [
"function",
"(",
"where",
")",
"{",
"if",
"(",
"where",
"!==",
"undefined",
")",
"{",
"if",
"(",
"where",
".",
"gene",
"!==",
"undefined",
")",
"{",
"get_gene",
"(",
"where",
")",
";",
"return",
";",
"}",
"else",
"{",
"if",
"(",
"where",
".",
"sp... | We hijack parent's start method | [
"We",
"hijack",
"parent",
"s",
"start",
"method"
] | 3fe11fa8b6145f181bb4baa4607a22fb360c0892 | https://github.com/tntvis/tnt.genome/blob/3fe11fa8b6145f181bb4baa4607a22fb360c0892/src/genome.js#L74-L140 | train | |
alphagov/govuk_frontend_toolkit_npm | javascripts/govuk/details.polyfill.js | function (node, type, callback) {
if (node.addEventListener) {
node.addEventListener(type, function (e) {
callback(e, e.target)
}, false)
} else if (node.attachEvent) {
node.attachEvent('on' + type, function (e) {
callback(e, e.srcElement)
})
}
} | javascript | function (node, type, callback) {
if (node.addEventListener) {
node.addEventListener(type, function (e) {
callback(e, e.target)
}, false)
} else if (node.attachEvent) {
node.attachEvent('on' + type, function (e) {
callback(e, e.srcElement)
})
}
} | [
"function",
"(",
"node",
",",
"type",
",",
"callback",
")",
"{",
"if",
"(",
"node",
".",
"addEventListener",
")",
"{",
"node",
".",
"addEventListener",
"(",
"type",
",",
"function",
"(",
"e",
")",
"{",
"callback",
"(",
"e",
",",
"e",
".",
"target",
... | Add event construct for modern browsers or IE which fires the callback with a pre-converted target reference | [
"Add",
"event",
"construct",
"for",
"modern",
"browsers",
"or",
"IE",
"which",
"fires",
"the",
"callback",
"with",
"a",
"pre",
"-",
"converted",
"target",
"reference"
] | 761632e5bed24c5106f4bdbd8cc99688d8ca616d | https://github.com/alphagov/govuk_frontend_toolkit_npm/blob/761632e5bed24c5106f4bdbd8cc99688d8ca616d/javascripts/govuk/details.polyfill.js#L25-L35 | train | |
alphagov/govuk_frontend_toolkit_npm | javascripts/govuk/details.polyfill.js | function (node, callback) {
GOVUK.details.addEvent(node, 'keypress', function (e, target) {
// When the key gets pressed - check if it is enter or space
if (GOVUK.details.charCode(e) === GOVUK.details.KEY_ENTER || GOVUK.details.charCode(e) === GOVUK.details.KEY_SPACE) {
if (target.nodeNa... | javascript | function (node, callback) {
GOVUK.details.addEvent(node, 'keypress', function (e, target) {
// When the key gets pressed - check if it is enter or space
if (GOVUK.details.charCode(e) === GOVUK.details.KEY_ENTER || GOVUK.details.charCode(e) === GOVUK.details.KEY_SPACE) {
if (target.nodeNa... | [
"function",
"(",
"node",
",",
"callback",
")",
"{",
"GOVUK",
".",
"details",
".",
"addEvent",
"(",
"node",
",",
"'keypress'",
",",
"function",
"(",
"e",
",",
"target",
")",
"{",
"// When the key gets pressed - check if it is enter or space",
"if",
"(",
"GOVUK",
... | Handle cross-modal click events | [
"Handle",
"cross",
"-",
"modal",
"click",
"events"
] | 761632e5bed24c5106f4bdbd8cc99688d8ca616d | https://github.com/alphagov/govuk_frontend_toolkit_npm/blob/761632e5bed24c5106f4bdbd8cc99688d8ca616d/javascripts/govuk/details.polyfill.js#L62-L93 | train | |
alphagov/govuk_frontend_toolkit_npm | javascripts/govuk/details.polyfill.js | function (node, match) {
do {
if (!node || node.nodeName.toLowerCase() === match) {
break
}
node = node.parentNode
} while (node)
return node
} | javascript | function (node, match) {
do {
if (!node || node.nodeName.toLowerCase() === match) {
break
}
node = node.parentNode
} while (node)
return node
} | [
"function",
"(",
"node",
",",
"match",
")",
"{",
"do",
"{",
"if",
"(",
"!",
"node",
"||",
"node",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
"===",
"match",
")",
"{",
"break",
"}",
"node",
"=",
"node",
".",
"parentNode",
"}",
"while",
"(",
"n... | Get the nearest ancestor element of a node that matches a given tag name | [
"Get",
"the",
"nearest",
"ancestor",
"element",
"of",
"a",
"node",
"that",
"matches",
"a",
"given",
"tag",
"name"
] | 761632e5bed24c5106f4bdbd8cc99688d8ca616d | https://github.com/alphagov/govuk_frontend_toolkit_npm/blob/761632e5bed24c5106f4bdbd8cc99688d8ca616d/javascripts/govuk/details.polyfill.js#L96-L105 | train | |
alphagov/govuk_frontend_toolkit_npm | javascripts/govuk/details.polyfill.js | function (summary) {
var expanded = summary.__details.__summary.getAttribute('aria-expanded') === 'true'
var hidden = summary.__details.__content.getAttribute('aria-hidden') === 'true'
summary.__details.__summary.setAttribute('aria-expanded', (expanded ? 'false' : 'true'))
summary.__details.__c... | javascript | function (summary) {
var expanded = summary.__details.__summary.getAttribute('aria-expanded') === 'true'
var hidden = summary.__details.__content.getAttribute('aria-hidden') === 'true'
summary.__details.__summary.setAttribute('aria-expanded', (expanded ? 'false' : 'true'))
summary.__details.__c... | [
"function",
"(",
"summary",
")",
"{",
"var",
"expanded",
"=",
"summary",
".",
"__details",
".",
"__summary",
".",
"getAttribute",
"(",
"'aria-expanded'",
")",
"===",
"'true'",
"var",
"hidden",
"=",
"summary",
".",
"__details",
".",
"__content",
".",
"getAttr... | Define a statechange function that updates aria-expanded and style.display Also update the arrow position | [
"Define",
"a",
"statechange",
"function",
"that",
"updates",
"aria",
"-",
"expanded",
"and",
"style",
".",
"display",
"Also",
"update",
"the",
"arrow",
"position"
] | 761632e5bed24c5106f4bdbd8cc99688d8ca616d | https://github.com/alphagov/govuk_frontend_toolkit_npm/blob/761632e5bed24c5106f4bdbd8cc99688d8ca616d/javascripts/govuk/details.polyfill.js#L201-L225 | train | |
alphagov/govuk_frontend_toolkit_npm | javascripts/govuk/details.polyfill.js | function ($container) {
GOVUK.details.addEvent(document, 'DOMContentLoaded', GOVUK.details.addDetailsPolyfill)
GOVUK.details.addEvent(window, 'load', GOVUK.details.addDetailsPolyfill)
} | javascript | function ($container) {
GOVUK.details.addEvent(document, 'DOMContentLoaded', GOVUK.details.addDetailsPolyfill)
GOVUK.details.addEvent(window, 'load', GOVUK.details.addDetailsPolyfill)
} | [
"function",
"(",
"$container",
")",
"{",
"GOVUK",
".",
"details",
".",
"addEvent",
"(",
"document",
",",
"'DOMContentLoaded'",
",",
"GOVUK",
".",
"details",
".",
"addDetailsPolyfill",
")",
"GOVUK",
".",
"details",
".",
"addEvent",
"(",
"window",
",",
"'load'... | Bind two load events for modern and older browsers If the first one fires it will set a flag to block the second one but if it's not supported then the second one will fire | [
"Bind",
"two",
"load",
"events",
"for",
"modern",
"and",
"older",
"browsers",
"If",
"the",
"first",
"one",
"fires",
"it",
"will",
"set",
"a",
"flag",
"to",
"block",
"the",
"second",
"one",
"but",
"if",
"it",
"s",
"not",
"supported",
"then",
"the",
"sec... | 761632e5bed24c5106f4bdbd8cc99688d8ca616d | https://github.com/alphagov/govuk_frontend_toolkit_npm/blob/761632e5bed24c5106f4bdbd8cc99688d8ca616d/javascripts/govuk/details.polyfill.js#L234-L237 | train | |
lukem512/pronounceable | pronounceable.js | undef | function undef(w, i, depth, probs) {
if (depth <= 1) return typeof probs[w[i]] === "undefined";
if (typeof probs[w[i]] === "undefined") return true;
return undef(w, i + 1, depth - 1, probs[w[i]]);
} | javascript | function undef(w, i, depth, probs) {
if (depth <= 1) return typeof probs[w[i]] === "undefined";
if (typeof probs[w[i]] === "undefined") return true;
return undef(w, i + 1, depth - 1, probs[w[i]]);
} | [
"function",
"undef",
"(",
"w",
",",
"i",
",",
"depth",
",",
"probs",
")",
"{",
"if",
"(",
"depth",
"<=",
"1",
")",
"return",
"typeof",
"probs",
"[",
"w",
"[",
"i",
"]",
"]",
"===",
"\"undefined\"",
";",
"if",
"(",
"typeof",
"probs",
"[",
"w",
"... | Check for undefined probabilities. | [
"Check",
"for",
"undefined",
"probabilities",
"."
] | 5719a96fe9e9b87e0f1f9b56c19b88f06a9ad9cf | https://github.com/lukem512/pronounceable/blob/5719a96fe9e9b87e0f1f9b56c19b88f06a9ad9cf/pronounceable.js#L29-L33 | train |
lukem512/pronounceable | pronounceable.js | trainTuples | function trainTuples(words) {
var probs = {};
var count = 0;
words.forEach(function(w) {
w = clean(w);
for (var i = 0; i < w.length - 1; i++) {
if (!probs[w[i]]) probs[w[i]] = {};
if (!probs[w[i]][w[i + 1]]) probs[w[i]][w[i + 1]] = 1;
else probs[w[i]][w[i + 1]]++;
count++;
}
... | javascript | function trainTuples(words) {
var probs = {};
var count = 0;
words.forEach(function(w) {
w = clean(w);
for (var i = 0; i < w.length - 1; i++) {
if (!probs[w[i]]) probs[w[i]] = {};
if (!probs[w[i]][w[i + 1]]) probs[w[i]][w[i + 1]] = 1;
else probs[w[i]][w[i + 1]]++;
count++;
}
... | [
"function",
"trainTuples",
"(",
"words",
")",
"{",
"var",
"probs",
"=",
"{",
"}",
";",
"var",
"count",
"=",
"0",
";",
"words",
".",
"forEach",
"(",
"function",
"(",
"w",
")",
"{",
"w",
"=",
"clean",
"(",
"w",
")",
";",
"for",
"(",
"var",
"i",
... | Extract probabilities of word t uple. | [
"Extract",
"probabilities",
"of",
"word",
"t",
"uple",
"."
] | 5719a96fe9e9b87e0f1f9b56c19b88f06a9ad9cf | https://github.com/lukem512/pronounceable/blob/5719a96fe9e9b87e0f1f9b56c19b88f06a9ad9cf/pronounceable.js#L36-L58 | train |
lukem512/pronounceable | pronounceable.js | trainTriples | function trainTriples(words) {
var probs = {};
var count = 0;
words.forEach(function(w) {
w = clean(w);
for (var i = 0; i < w.length - 2; i++) {
if (!probs[w[i]]) probs[w[i]] = {};
if (!probs[w[i]][w[i + 1]]) probs[w[i]][w[i + 1]] = {};
if (!probs[w[i]][w[i + 1]][w[i + 2]]) probs[w[i]]... | javascript | function trainTriples(words) {
var probs = {};
var count = 0;
words.forEach(function(w) {
w = clean(w);
for (var i = 0; i < w.length - 2; i++) {
if (!probs[w[i]]) probs[w[i]] = {};
if (!probs[w[i]][w[i + 1]]) probs[w[i]][w[i + 1]] = {};
if (!probs[w[i]][w[i + 1]][w[i + 2]]) probs[w[i]]... | [
"function",
"trainTriples",
"(",
"words",
")",
"{",
"var",
"probs",
"=",
"{",
"}",
";",
"var",
"count",
"=",
"0",
";",
"words",
".",
"forEach",
"(",
"function",
"(",
"w",
")",
"{",
"w",
"=",
"clean",
"(",
"w",
")",
";",
"for",
"(",
"var",
"i",
... | Extract probabilities of word triples. | [
"Extract",
"probabilities",
"of",
"word",
"triples",
"."
] | 5719a96fe9e9b87e0f1f9b56c19b88f06a9ad9cf | https://github.com/lukem512/pronounceable/blob/5719a96fe9e9b87e0f1f9b56c19b88f06a9ad9cf/pronounceable.js#L61-L89 | train |
bvalosek/infusionsoft-api | infusionsoft/services/IOrderService.js | function(apiKey, contactId, creditCardId,
payPlanId, productIds, subscriptionPlanIds, processSpecials,
promoCodes, _leadAffiliatedId, _affiliatedId) {} | javascript | function(apiKey, contactId, creditCardId,
payPlanId, productIds, subscriptionPlanIds, processSpecials,
promoCodes, _leadAffiliatedId, _affiliatedId) {} | [
"function",
"(",
"apiKey",
",",
"contactId",
",",
"creditCardId",
",",
"payPlanId",
",",
"productIds",
",",
"subscriptionPlanIds",
",",
"processSpecials",
",",
"promoCodes",
",",
"_leadAffiliatedId",
",",
"_affiliatedId",
")",
"{",
"}"
] | Returns the result of order placement. The ids of the order and invoice that were created are returned along with the status of a credit card charge if one was made. | [
"Returns",
"the",
"result",
"of",
"order",
"placement",
".",
"The",
"ids",
"of",
"the",
"order",
"and",
"invoice",
"that",
"were",
"created",
"are",
"returned",
"along",
"with",
"the",
"status",
"of",
"a",
"credit",
"card",
"charge",
"if",
"one",
"was",
... | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/infusionsoft/services/IOrderService.js#L13-L15 | train | |
maurobussini/jslinq | src/jslinq.js | equals | function equals(first, second){
//If are the same instance, true
if (first === second)
return true;
//If values are equals, return true
if (first == second)
return true;
//If different type, false
if (typeof first != typeof second)
return false;
//If are not objects, check value
if... | javascript | function equals(first, second){
//If are the same instance, true
if (first === second)
return true;
//If values are equals, return true
if (first == second)
return true;
//If different type, false
if (typeof first != typeof second)
return false;
//If are not objects, check value
if... | [
"function",
"equals",
"(",
"first",
",",
"second",
")",
"{",
"//If are the same instance, true",
"if",
"(",
"first",
"===",
"second",
")",
"return",
"true",
";",
"//If values are equals, return true",
"if",
"(",
"first",
"==",
"second",
")",
"return",
"true",
";... | Verify if first and second element are equals in values | [
"Verify",
"if",
"first",
"and",
"second",
"element",
"are",
"equals",
"in",
"values"
] | cb0bfbe079803a2899196de76916abf604664b55 | https://github.com/maurobussini/jslinq/blob/cb0bfbe079803a2899196de76916abf604664b55/src/jslinq.js#L61-L97 | train |
maurobussini/jslinq | src/jslinq.js | function(a, b){
//Get value for "a" and "b" element
var aValue = expression(a);
var bValue = expression(b);
//Check if one element is greater then the second one
if(aValue < bValue) return -1;
if(aValue > bValue) return 1;
return 0;
} | javascript | function(a, b){
//Get value for "a" and "b" element
var aValue = expression(a);
var bValue = expression(b);
//Check if one element is greater then the second one
if(aValue < bValue) return -1;
if(aValue > bValue) return 1;
return 0;
} | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"//Get value for \"a\" and \"b\" element",
"var",
"aValue",
"=",
"expression",
"(",
"a",
")",
";",
"var",
"bValue",
"=",
"expression",
"(",
"b",
")",
";",
"//Check if one element is greater then the second one",
"if",
"(",... | Define sort action estracting values from objects | [
"Define",
"sort",
"action",
"estracting",
"values",
"from",
"objects"
] | cb0bfbe079803a2899196de76916abf604664b55 | https://github.com/maurobussini/jslinq/blob/cb0bfbe079803a2899196de76916abf604664b55/src/jslinq.js#L284-L294 | train | |
maurobussini/jslinq | src/jslinq.js | subtract | function subtract(otherData, compareExpression) {
//If other data is invalid, return empty array
if (!otherData)
return new jslinq([]);
//Data for output
var outData = [];
//Check every element of "items"
for (var n = 0; n < this.items.length; n++) {
//... | javascript | function subtract(otherData, compareExpression) {
//If other data is invalid, return empty array
if (!otherData)
return new jslinq([]);
//Data for output
var outData = [];
//Check every element of "items"
for (var n = 0; n < this.items.length; n++) {
//... | [
"function",
"subtract",
"(",
"otherData",
",",
"compareExpression",
")",
"{",
"//If other data is invalid, return empty array",
"if",
"(",
"!",
"otherData",
")",
"return",
"new",
"jslinq",
"(",
"[",
"]",
")",
";",
"//Data for output",
"var",
"outData",
"=",
"[",
... | Get only elements NOT contained on provided "otherData" using same instance or compare expression | [
"Get",
"only",
"elements",
"NOT",
"contained",
"on",
"provided",
"otherData",
"using",
"same",
"instance",
"or",
"compare",
"expression"
] | cb0bfbe079803a2899196de76916abf604664b55 | https://github.com/maurobussini/jslinq/blob/cb0bfbe079803a2899196de76916abf604664b55/src/jslinq.js#L757-L820 | train |
retextjs/retext-intensify | index.js | transformer | function transformer(tree, file) {
search(tree, phrases, searcher)
function searcher(match, index, parent, phrase) {
var type = weasel
var message
if (weasels.indexOf(phrase) === -1) {
type = fillers.indexOf(phrase) === -1 ? hedge : filler
}
message = file.warn(
... | javascript | function transformer(tree, file) {
search(tree, phrases, searcher)
function searcher(match, index, parent, phrase) {
var type = weasel
var message
if (weasels.indexOf(phrase) === -1) {
type = fillers.indexOf(phrase) === -1 ? hedge : filler
}
message = file.warn(
... | [
"function",
"transformer",
"(",
"tree",
",",
"file",
")",
"{",
"search",
"(",
"tree",
",",
"phrases",
",",
"searcher",
")",
"function",
"searcher",
"(",
"match",
",",
"index",
",",
"parent",
",",
"phrase",
")",
"{",
"var",
"type",
"=",
"weasel",
"var",... | Search `tree` for validations. | [
"Search",
"tree",
"for",
"validations",
"."
] | 8d52a7eb54de75a50d7f5c4fea18b151c1a656a2 | https://github.com/retextjs/retext-intensify/blob/8d52a7eb54de75a50d7f5c4fea18b151c1a656a2/index.js#L37-L59 | train |
jonschlinkert/html-toc | index.js | buildHTML | function buildHTML(navigation, first, sParentLink) {
return '<ul class="nav' + (first ? ' sidenav' : '') + '">' + navigation.map(function(loc) {
if (!loc || !loc.link) return '';
loc.link = (opts.parentLink && sParentLink ? sParentLink + '-' : '') + loc.link;
loc.$ele.attr('id', loc.link);
... | javascript | function buildHTML(navigation, first, sParentLink) {
return '<ul class="nav' + (first ? ' sidenav' : '') + '">' + navigation.map(function(loc) {
if (!loc || !loc.link) return '';
loc.link = (opts.parentLink && sParentLink ? sParentLink + '-' : '') + loc.link;
loc.$ele.attr('id', loc.link);
... | [
"function",
"buildHTML",
"(",
"navigation",
",",
"first",
",",
"sParentLink",
")",
"{",
"return",
"'<ul class=\"nav'",
"+",
"(",
"first",
"?",
"' sidenav'",
":",
"''",
")",
"+",
"'\">'",
"+",
"navigation",
".",
"map",
"(",
"function",
"(",
"loc",
")",
"{... | Build the HTML for side navigation. | [
"Build",
"the",
"HTML",
"for",
"side",
"navigation",
"."
] | c529bad2f5b964652c8230be7bb4270e31ba734d | https://github.com/jonschlinkert/html-toc/blob/c529bad2f5b964652c8230be7bb4270e31ba734d/index.js#L68-L77 | train |
fabienb4/meteor-jsdoc | example/meteor/client/templates/search.js | function(arrayOfSearchResultsArrays) {
let ids = {};
let dedupedResults = [];
_.each(arrayOfSearchResultsArrays, (searchResults) => {
_.each(searchResults, (item) => {
if (! ids.hasOwnProperty(item._id)) {
ids[item._id] = true;
dedupedResults.push(item);
}
});
});
return... | javascript | function(arrayOfSearchResultsArrays) {
let ids = {};
let dedupedResults = [];
_.each(arrayOfSearchResultsArrays, (searchResults) => {
_.each(searchResults, (item) => {
if (! ids.hasOwnProperty(item._id)) {
ids[item._id] = true;
dedupedResults.push(item);
}
});
});
return... | [
"function",
"(",
"arrayOfSearchResultsArrays",
")",
"{",
"let",
"ids",
"=",
"{",
"}",
";",
"let",
"dedupedResults",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"arrayOfSearchResultsArrays",
",",
"(",
"searchResults",
")",
"=>",
"{",
"_",
".",
"each",
"(",... | When you have two arrays of search results, use this function to deduplicate them | [
"When",
"you",
"have",
"two",
"arrays",
"of",
"search",
"results",
"use",
"this",
"function",
"to",
"deduplicate",
"them"
] | f11ea7d694fac18025f53cb4826cafe80c69c625 | https://github.com/fabienb4/meteor-jsdoc/blob/f11ea7d694fac18025f53cb4826cafe80c69c625/example/meteor/client/templates/search.js#L147-L162 | train | |
mike-goodwin/connect-azuretables | lib/connect-azuretables.js | logOrThrow | function logOrThrow(error, result) {
if (result) {
self.log('connect-azuretables created table ' + self.table);
}
if (error) {
throw ('failed to create table: ' + error);
}
} | javascript | function logOrThrow(error, result) {
if (result) {
self.log('connect-azuretables created table ' + self.table);
}
if (error) {
throw ('failed to create table: ' + error);
}
} | [
"function",
"logOrThrow",
"(",
"error",
",",
"result",
")",
"{",
"if",
"(",
"result",
")",
"{",
"self",
".",
"log",
"(",
"'connect-azuretables created table '",
"+",
"self",
".",
"table",
")",
";",
"}",
"if",
"(",
"error",
")",
"{",
"throw",
"(",
"'fai... | reducing function complexity to keep code climate happy | [
"reducing",
"function",
"complexity",
"to",
"keep",
"code",
"climate",
"happy"
] | b148c19ee6abcf636fd58d8c983aed0a3d0d21b2 | https://github.com/mike-goodwin/connect-azuretables/blob/b148c19ee6abcf636fd58d8c983aed0a3d0d21b2/lib/connect-azuretables.js#L79-L88 | train |
mike-goodwin/connect-azuretables | lib/connect-azuretables.js | errorOrResult | function errorOrResult(error, result, fn) {
return error ? fn(error) : fn(null, result);
} | javascript | function errorOrResult(error, result, fn) {
return error ? fn(error) : fn(null, result);
} | [
"function",
"errorOrResult",
"(",
"error",
",",
"result",
",",
"fn",
")",
"{",
"return",
"error",
"?",
"fn",
"(",
"error",
")",
":",
"fn",
"(",
"null",
",",
"result",
")",
";",
"}"
] | removing duplicate code to keep code climate happy | [
"removing",
"duplicate",
"code",
"to",
"keep",
"code",
"climate",
"happy"
] | b148c19ee6abcf636fd58d8c983aed0a3d0d21b2 | https://github.com/mike-goodwin/connect-azuretables/blob/b148c19ee6abcf636fd58d8c983aed0a3d0d21b2/lib/connect-azuretables.js#L259-L261 | train |
mike-goodwin/connect-azuretables | lib/connect-azuretables.js | getExpiryDate | function getExpiryDate(store, data) {
var offset;
if (data.cookie.originalMaxAge) {
offset = data.cookie.originalMaxAge;
} else {
offset = store.sessionTimeOut * 60000;
}
return offset ? new Date(Date.now() + offset) : null;
} | javascript | function getExpiryDate(store, data) {
var offset;
if (data.cookie.originalMaxAge) {
offset = data.cookie.originalMaxAge;
} else {
offset = store.sessionTimeOut * 60000;
}
return offset ? new Date(Date.now() + offset) : null;
} | [
"function",
"getExpiryDate",
"(",
"store",
",",
"data",
")",
"{",
"var",
"offset",
";",
"if",
"(",
"data",
".",
"cookie",
".",
"originalMaxAge",
")",
"{",
"offset",
"=",
"data",
".",
"cookie",
".",
"originalMaxAge",
";",
"}",
"else",
"{",
"offset",
"="... | expiry date for sessions | [
"expiry",
"date",
"for",
"sessions"
] | b148c19ee6abcf636fd58d8c983aed0a3d0d21b2 | https://github.com/mike-goodwin/connect-azuretables/blob/b148c19ee6abcf636fd58d8c983aed0a3d0d21b2/lib/connect-azuretables.js#L264-L275 | train |
jaredLunde/react-emoji-component | examples/every-emoji/webpack/startServer.js | startListening | function startListening () {
if (isBuilt === false) {
app.listen(
parseInt(port),
host,
() => {
isBuilt = true
console.log(chalk.green(`[React Emoji Component SSR] ${host}:${port}`))
}
)
}
} | javascript | function startListening () {
if (isBuilt === false) {
app.listen(
parseInt(port),
host,
() => {
isBuilt = true
console.log(chalk.green(`[React Emoji Component SSR] ${host}:${port}`))
}
)
}
} | [
"function",
"startListening",
"(",
")",
"{",
"if",
"(",
"isBuilt",
"===",
"false",
")",
"{",
"app",
".",
"listen",
"(",
"parseInt",
"(",
"port",
")",
",",
"host",
",",
"(",
")",
"=>",
"{",
"isBuilt",
"=",
"true",
"console",
".",
"log",
"(",
"chalk"... | express listener which is run after the compiler is done | [
"express",
"listener",
"which",
"is",
"run",
"after",
"the",
"compiler",
"is",
"done"
] | a5083fa3df2b546e66ccfab943623101954c5527 | https://github.com/jaredLunde/react-emoji-component/blob/a5083fa3df2b546e66ccfab943623101954c5527/examples/every-emoji/webpack/startServer.js#L32-L43 | train |
mjyc/cycle-robot-drivers | docs/slides/20190327_rosseattlemeetup/export/libs/reveal.js/3.7.0/plugin/zoom-js/zoom.js | magnify | function magnify( rect, scale ) {
var scrollOffset = getScrollOffset();
// Ensure a width/height is set
rect.width = rect.width || 1;
rect.height = rect.height || 1;
// Center the rect within the zoomed viewport
rect.x -= ( window.innerWidth - ( rect.width * scale ) ) / 2;
rect.y -= ( window.innerHeigh... | javascript | function magnify( rect, scale ) {
var scrollOffset = getScrollOffset();
// Ensure a width/height is set
rect.width = rect.width || 1;
rect.height = rect.height || 1;
// Center the rect within the zoomed viewport
rect.x -= ( window.innerWidth - ( rect.width * scale ) ) / 2;
rect.y -= ( window.innerHeigh... | [
"function",
"magnify",
"(",
"rect",
",",
"scale",
")",
"{",
"var",
"scrollOffset",
"=",
"getScrollOffset",
"(",
")",
";",
"// Ensure a width/height is set",
"rect",
".",
"width",
"=",
"rect",
".",
"width",
"||",
"1",
";",
"rect",
".",
"height",
"=",
"rect"... | Applies the CSS required to zoom in, prefers the use of CSS3
transforms but falls back on zoom for IE.
@param {Object} rect
@param {Number} scale | [
"Applies",
"the",
"CSS",
"required",
"to",
"zoom",
"in",
"prefers",
"the",
"use",
"of",
"CSS3",
"transforms",
"but",
"falls",
"back",
"on",
"zoom",
"for",
"IE",
"."
] | acdc666150d686ee79b0ba917b6afcf09172c925 | https://github.com/mjyc/cycle-robot-drivers/blob/acdc666150d686ee79b0ba917b6afcf09172c925/docs/slides/20190327_rosseattlemeetup/export/libs/reveal.js/3.7.0/plugin/zoom-js/zoom.js#L85-L155 | train |
bvalosek/infusionsoft-api | lib/Queryable.js | function(T)
{
var ret = [];
_(typedef.signature(T)).each(function(info, key) {
if (info.decorations.FIELD)
ret.push(key);
});
return ret;
} | javascript | function(T)
{
var ret = [];
_(typedef.signature(T)).each(function(info, key) {
if (info.decorations.FIELD)
ret.push(key);
});
return ret;
} | [
"function",
"(",
"T",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"_",
"(",
"typedef",
".",
"signature",
"(",
"T",
")",
")",
".",
"each",
"(",
"function",
"(",
"info",
",",
"key",
")",
"{",
"if",
"(",
"info",
".",
"decorations",
".",
"FIELD",
... | Attempt to determine all the fields on a given type | [
"Attempt",
"to",
"determine",
"all",
"the",
"fields",
"on",
"a",
"given",
"type"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/Queryable.js#L35-L45 | train | |
bvalosek/infusionsoft-api | lib/Queryable.js | function(o)
{
var q = this.clone();
q._orderBy = o;
q._ascending = true;
return q;
} | javascript | function(o)
{
var q = this.clone();
q._orderBy = o;
q._ascending = true;
return q;
} | [
"function",
"(",
"o",
")",
"{",
"var",
"q",
"=",
"this",
".",
"clone",
"(",
")",
";",
"q",
".",
"_orderBy",
"=",
"o",
";",
"q",
".",
"_ascending",
"=",
"true",
";",
"return",
"q",
";",
"}"
] | Field to order results | [
"Field",
"to",
"order",
"results"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/Queryable.js#L114-L120 | train | |
bvalosek/infusionsoft-api | lib/Queryable.js | function(f)
{
var q = this.clone();
if (arguments.length > 1)
q._fields = _(arguments).toArray();
else if (f)
q._fields = _(f).isArray() ? f : [f];
else
q._fields = Queryable.getFields(this._T);
return q;
} | javascript | function(f)
{
var q = this.clone();
if (arguments.length > 1)
q._fields = _(arguments).toArray();
else if (f)
q._fields = _(f).isArray() ? f : [f];
else
q._fields = Queryable.getFields(this._T);
return q;
} | [
"function",
"(",
"f",
")",
"{",
"var",
"q",
"=",
"this",
".",
"clone",
"(",
")",
";",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"q",
".",
"_fields",
"=",
"_",
"(",
"arguments",
")",
".",
"toArray",
"(",
")",
";",
"else",
"if",
"("... | Set what fields we will be using | [
"Set",
"what",
"fields",
"we",
"will",
"be",
"using"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/Queryable.js#L131-L143 | train | |
bvalosek/infusionsoft-api | lib/Queryable.js | function()
{
if (this._executePromise)
return this._executePromise;
var q = this.clone();
var table = q._T.__name__;
var page = q._page;
var fields = q._fields;
// Create the query from our stuff
var query = {};
_(q._where.concat(q._l... | javascript | function()
{
if (this._executePromise)
return this._executePromise;
var q = this.clone();
var table = q._T.__name__;
var page = q._page;
var fields = q._fields;
// Create the query from our stuff
var query = {};
_(q._where.concat(q._l... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_executePromise",
")",
"return",
"this",
".",
"_executePromise",
";",
"var",
"q",
"=",
"this",
".",
"clone",
"(",
")",
";",
"var",
"table",
"=",
"q",
".",
"_T",
".",
"__name__",
";",
"var",
"page"... | Actually hit the API. Returns a promise for the eventual value of these results. Ends up mutating the query and marking it as done If we already have a promise, return that, meaning that it can only be eecuted once | [
"Actually",
"hit",
"the",
"API",
".",
"Returns",
"a",
"promise",
"for",
"the",
"eventual",
"value",
"of",
"these",
"results",
".",
"Ends",
"up",
"mutating",
"the",
"query",
"and",
"marking",
"it",
"as",
"done",
"If",
"we",
"already",
"have",
"a",
"promis... | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/Queryable.js#L260-L313 | train | |
bvalosek/infusionsoft-api | lib/Queryable.js | function(table, limit, page, query, fields)
{
if (this._doneLoading)
return;
var _this = this;
// Execute -- add orderBy and ascending?
var args = [table, limit, page, query, fields];
if (this._orderBy) {
args.push(this._orderBy);
args.pu... | javascript | function(table, limit, page, query, fields)
{
if (this._doneLoading)
return;
var _this = this;
// Execute -- add orderBy and ascending?
var args = [table, limit, page, query, fields];
if (this._orderBy) {
args.push(this._orderBy);
args.pu... | [
"function",
"(",
"table",
",",
"limit",
",",
"page",
",",
"query",
",",
"fields",
")",
"{",
"if",
"(",
"this",
".",
"_doneLoading",
")",
"return",
";",
"var",
"_this",
"=",
"this",
";",
"// Execute -- add orderBy and ascending?",
"var",
"args",
"=",
"[",
... | Where the actual API call is fired off. Returns a promise for the eventual raw value from the API call | [
"Where",
"the",
"actual",
"API",
"call",
"is",
"fired",
"off",
".",
"Returns",
"a",
"promise",
"for",
"the",
"eventual",
"raw",
"value",
"from",
"the",
"API",
"call"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/Queryable.js#L317-L351 | train | |
bvalosek/infusionsoft-api | infusionsoft/services/IAPIEmailService.js | function(apiKey, pieceTitle, categories,
fromAddress, toAddress, ccAddress, bccAddress, subject, textBody,
htmlBody, contentType, mergeContext) {} | javascript | function(apiKey, pieceTitle, categories,
fromAddress, toAddress, ccAddress, bccAddress, subject, textBody,
htmlBody, contentType, mergeContext) {} | [
"function",
"(",
"apiKey",
",",
"pieceTitle",
",",
"categories",
",",
"fromAddress",
",",
"toAddress",
",",
"ccAddress",
",",
"bccAddress",
",",
"subject",
",",
"textBody",
",",
"htmlBody",
",",
"contentType",
",",
"mergeContext",
")",
"{",
"}"
] | Create a new email template that can be used for future emails | [
"Create",
"a",
"new",
"email",
"template",
"that",
"can",
"be",
"used",
"for",
"future",
"emails"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/infusionsoft/services/IAPIEmailService.js#L13-L15 | train | |
bvalosek/infusionsoft-api | infusionsoft/services/IAPIEmailService.js | function(apiKey, contactId, fromName,
fromAddress, toAddress, ccAddresses, bccAddresses, contentType,
subject, htmlBody, textBody, header, receivedDate, sentDate,
emailSentType) {} | javascript | function(apiKey, contactId, fromName,
fromAddress, toAddress, ccAddresses, bccAddresses, contentType,
subject, htmlBody, textBody, header, receivedDate, sentDate,
emailSentType) {} | [
"function",
"(",
"apiKey",
",",
"contactId",
",",
"fromName",
",",
"fromAddress",
",",
"toAddress",
",",
"ccAddresses",
",",
"bccAddresses",
",",
"contentType",
",",
"subject",
",",
"htmlBody",
",",
"textBody",
",",
"header",
",",
"receivedDate",
",",
"sentDat... | This will create an item in the email history for a contact. This does not actually send the email, it only places an item into the email history. Using the API to instruct Infusionsoft to send an email will handle this automatically. | [
"This",
"will",
"create",
"an",
"item",
"in",
"the",
"email",
"history",
"for",
"a",
"contact",
".",
"This",
"does",
"not",
"actually",
"send",
"the",
"email",
"it",
"only",
"places",
"an",
"item",
"into",
"the",
"email",
"history",
".",
"Using",
"the",
... | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/infusionsoft/services/IAPIEmailService.js#L21-L24 | train | |
bvalosek/infusionsoft-api | infusionsoft/services/IAPIEmailService.js | function(apiKey, contactList, fromAddress,
toAddress, ccAddresses, bccAddresses, contentType, subject, htmlBody,
textBody, _templateId) {} | javascript | function(apiKey, contactList, fromAddress,
toAddress, ccAddresses, bccAddresses, contentType, subject, htmlBody,
textBody, _templateId) {} | [
"function",
"(",
"apiKey",
",",
"contactList",
",",
"fromAddress",
",",
"toAddress",
",",
"ccAddresses",
",",
"bccAddresses",
",",
"contentType",
",",
"subject",
",",
"htmlBody",
",",
"textBody",
",",
"_templateId",
")",
"{",
"}"
] | This will send an email to a list of contacts, as well as record the email in the contacts' email history | [
"This",
"will",
"send",
"an",
"email",
"to",
"a",
"list",
"of",
"contacts",
"as",
"well",
"as",
"record",
"the",
"email",
"in",
"the",
"contacts",
"email",
"history"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/infusionsoft/services/IAPIEmailService.js#L45-L47 | train | |
bvalosek/infusionsoft-api | infusionsoft/services/IAPIEmailService.js | function(apiKey, templateId, pieceTitle,
category, fromAddress, toAddress, ccAddress, bccAddresses, subject,
textBody, htmlBody, contentType, mergeContext) {} | javascript | function(apiKey, templateId, pieceTitle,
category, fromAddress, toAddress, ccAddress, bccAddresses, subject,
textBody, htmlBody, contentType, mergeContext) {} | [
"function",
"(",
"apiKey",
",",
"templateId",
",",
"pieceTitle",
",",
"category",
",",
"fromAddress",
",",
"toAddress",
",",
"ccAddress",
",",
"bccAddresses",
",",
"subject",
",",
"textBody",
",",
"htmlBody",
",",
"contentType",
",",
"mergeContext",
")",
"{",
... | This method is used to update an already existing email template | [
"This",
"method",
"is",
"used",
"to",
"update",
"an",
"already",
"existing",
"email",
"template"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/infusionsoft/services/IAPIEmailService.js#L54-L56 | train | |
topaxi/postcss-selector-namespace | lib/plugin.js | parentIsAllowedAtRule | function parentIsAllowedAtRule(rule) {
return (
rule.parent &&
rule.parent.type === 'atrule' &&
!/(?:media|supports|for)$/.test(rule.parent.name)
)
} | javascript | function parentIsAllowedAtRule(rule) {
return (
rule.parent &&
rule.parent.type === 'atrule' &&
!/(?:media|supports|for)$/.test(rule.parent.name)
)
} | [
"function",
"parentIsAllowedAtRule",
"(",
"rule",
")",
"{",
"return",
"(",
"rule",
".",
"parent",
"&&",
"rule",
".",
"parent",
".",
"type",
"===",
"'atrule'",
"&&",
"!",
"/",
"(?:media|supports|for)$",
"/",
".",
"test",
"(",
"rule",
".",
"parent",
".",
"... | Returns true if the parent rule is a not a media or supports atrule
@param {Rule} rule The rule to check
@return {boolean} true if the direct parent is a keyframe rule | [
"Returns",
"true",
"if",
"the",
"parent",
"rule",
"is",
"a",
"not",
"a",
"media",
"or",
"supports",
"atrule"
] | 96e02400bd2771c7559621af597f9e1de31c5981 | https://github.com/topaxi/postcss-selector-namespace/blob/96e02400bd2771c7559621af597f9e1de31c5981/lib/plugin.js#L85-L91 | train |
topaxi/postcss-selector-namespace | lib/plugin.js | hasParentRule | function hasParentRule(rule) {
if (!rule.parent) {
return false
}
if (rule.parent.type === 'rule') {
return true
}
return hasParentRule(rule.parent)
} | javascript | function hasParentRule(rule) {
if (!rule.parent) {
return false
}
if (rule.parent.type === 'rule') {
return true
}
return hasParentRule(rule.parent)
} | [
"function",
"hasParentRule",
"(",
"rule",
")",
"{",
"if",
"(",
"!",
"rule",
".",
"parent",
")",
"{",
"return",
"false",
"}",
"if",
"(",
"rule",
".",
"parent",
".",
"type",
"===",
"'rule'",
")",
"{",
"return",
"true",
"}",
"return",
"hasParentRule",
"... | Returns true if any parent rule is of type 'rule'
@param {Rule} rule The rule to check
@return {boolean} true if any parent rule is of type 'rule' else false | [
"Returns",
"true",
"if",
"any",
"parent",
"rule",
"is",
"of",
"type",
"rule"
] | 96e02400bd2771c7559621af597f9e1de31c5981 | https://github.com/topaxi/postcss-selector-namespace/blob/96e02400bd2771c7559621af597f9e1de31c5981/lib/plugin.js#L99-L109 | train |
topaxi/postcss-selector-namespace | lib/plugin.js | regexpToGlobalRegexp | function regexpToGlobalRegexp(regexp) {
let source = regexp instanceof RegExp ? regexp.source : regexp
return new RegExp(source, 'g')
} | javascript | function regexpToGlobalRegexp(regexp) {
let source = regexp instanceof RegExp ? regexp.source : regexp
return new RegExp(source, 'g')
} | [
"function",
"regexpToGlobalRegexp",
"(",
"regexp",
")",
"{",
"let",
"source",
"=",
"regexp",
"instanceof",
"RegExp",
"?",
"regexp",
".",
"source",
":",
"regexp",
"return",
"new",
"RegExp",
"(",
"source",
",",
"'g'",
")",
"}"
] | Newer javascript engines allow setting flags when passing existing regexp
to the RegExp constructor, until then, we extract the regexp source and
build a new object.
@param {RegExp|string} regexp The regexp to modify
@return {RegExp} The new regexp instance | [
"Newer",
"javascript",
"engines",
"allow",
"setting",
"flags",
"when",
"passing",
"existing",
"regexp",
"to",
"the",
"RegExp",
"constructor",
"until",
"then",
"we",
"extract",
"the",
"regexp",
"source",
"and",
"build",
"a",
"new",
"object",
"."
] | 96e02400bd2771c7559621af597f9e1de31c5981 | https://github.com/topaxi/postcss-selector-namespace/blob/96e02400bd2771c7559621af597f9e1de31c5981/lib/plugin.js#L119-L123 | train |
alphagov/govuk_frontend_toolkit_npm | javascripts/govuk/show-hide-content.js | init | function init ($container, elementSelector, eventSelectors, handler) {
$container = $container || $(document.body)
// Handle control clicks
function deferred () {
var $control = $(this)
handler($control, getToggledContent($control))
}
// Prepare ARIA attributes
var ... | javascript | function init ($container, elementSelector, eventSelectors, handler) {
$container = $container || $(document.body)
// Handle control clicks
function deferred () {
var $control = $(this)
handler($control, getToggledContent($control))
}
// Prepare ARIA attributes
var ... | [
"function",
"init",
"(",
"$container",
",",
"elementSelector",
",",
"eventSelectors",
",",
"handler",
")",
"{",
"$container",
"=",
"$container",
"||",
"$",
"(",
"document",
".",
"body",
")",
"// Handle control clicks",
"function",
"deferred",
"(",
")",
"{",
"v... | Set up event handlers etc | [
"Set",
"up",
"event",
"handlers",
"etc"
] | 761632e5bed24c5106f4bdbd8cc99688d8ca616d | https://github.com/alphagov/govuk_frontend_toolkit_npm/blob/761632e5bed24c5106f4bdbd8cc99688d8ca616d/javascripts/govuk/show-hide-content.js#L102-L124 | train |
alphagov/govuk_frontend_toolkit_npm | javascripts/govuk/show-hide-content.js | getEventSelectorsForRadioGroups | function getEventSelectorsForRadioGroups () {
var radioGroups = []
// Build an array of radio group selectors
return $(selectors.radio).map(function () {
var groupName = $(this).attr('name')
if ($.inArray(groupName, radioGroups) === -1) {
radioGroups.push(groupName)
... | javascript | function getEventSelectorsForRadioGroups () {
var radioGroups = []
// Build an array of radio group selectors
return $(selectors.radio).map(function () {
var groupName = $(this).attr('name')
if ($.inArray(groupName, radioGroups) === -1) {
radioGroups.push(groupName)
... | [
"function",
"getEventSelectorsForRadioGroups",
"(",
")",
"{",
"var",
"radioGroups",
"=",
"[",
"]",
"// Build an array of radio group selectors",
"return",
"$",
"(",
"selectors",
".",
"radio",
")",
".",
"map",
"(",
"function",
"(",
")",
"{",
"var",
"groupName",
"... | Get event selectors for all radio groups | [
"Get",
"event",
"selectors",
"for",
"all",
"radio",
"groups"
] | 761632e5bed24c5106f4bdbd8cc99688d8ca616d | https://github.com/alphagov/govuk_frontend_toolkit_npm/blob/761632e5bed24c5106f4bdbd8cc99688d8ca616d/javascripts/govuk/show-hide-content.js#L127-L140 | train |
jquense/react-layer | vendor/sinon-1.10.3.js | getIndex | function getIndex(objects, obj) {
var i;
for (i = 0; i < objects.length; i++) {
if (objects[i] === obj) {
return i;
}
}
return -1;
} | javascript | function getIndex(objects, obj) {
var i;
for (i = 0; i < objects.length; i++) {
if (objects[i] === obj) {
return i;
}
}
return -1;
} | [
"function",
"getIndex",
"(",
"objects",
",",
"obj",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"objects",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"objects",
"[",
"i",
"]",
"===",
"obj",
")",
"{",
"return"... | returns the index of the given object in the
given objects array, -1 if not contained
only needed for cyclic logic | [
"returns",
"the",
"index",
"of",
"the",
"given",
"object",
"in",
"the",
"given",
"objects",
"array",
"-",
"1",
"if",
"not",
"contained",
"only",
"needed",
"for",
"cyclic",
"logic"
] | 9b12a1a1af9715e39edbb67dcca0b9ef3277b461 | https://github.com/jquense/react-layer/blob/9b12a1a1af9715e39edbb67dcca0b9ef3277b461/vendor/sinon-1.10.3.js#L216-L226 | train |
bvalosek/infusionsoft-api | lib/DataContext.js | function()
{
var _this = this;
_(api.services).each(function(service, key) {
_this._addService(service);
});
} | javascript | function()
{
var _this = this;
_(api.services).each(function(service, key) {
_this._addService(service);
});
} | [
"function",
"(",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"_",
"(",
"api",
".",
"services",
")",
".",
"each",
"(",
"function",
"(",
"service",
",",
"key",
")",
"{",
"_this",
".",
"_addService",
"(",
"service",
")",
";",
"}",
")",
";",
"}"
] | Create all of the API services in this data context | [
"Create",
"all",
"of",
"the",
"API",
"services",
"in",
"this",
"data",
"context"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/DataContext.js#L31-L38 | train | |
bvalosek/infusionsoft-api | lib/DataContext.js | function(T)
{
var tName = inflection.pluralize(T.__name__);
this[tName] = new Queryable(T, this.DataService);
} | javascript | function(T)
{
var tName = inflection.pluralize(T.__name__);
this[tName] = new Queryable(T, this.DataService);
} | [
"function",
"(",
"T",
")",
"{",
"var",
"tName",
"=",
"inflection",
".",
"pluralize",
"(",
"T",
".",
"__name__",
")",
";",
"this",
"[",
"tName",
"]",
"=",
"new",
"Queryable",
"(",
"T",
",",
"this",
".",
"DataService",
")",
";",
"}"
] | Create a queryable that can be used via data service | [
"Create",
"a",
"queryable",
"that",
"can",
"be",
"used",
"via",
"data",
"service"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/DataContext.js#L50-L54 | train | |
bvalosek/infusionsoft-api | lib/DataContext.js | function(iface)
{
var hash = {};
var collection = iface.__name__.substring(1);
var dataContext = this;
_(typedef.signature(iface)).each(function (info, key) {
// create the function that calls method call and returns a promise
hash[key] = function() ... | javascript | function(iface)
{
var hash = {};
var collection = iface.__name__.substring(1);
var dataContext = this;
_(typedef.signature(iface)).each(function (info, key) {
// create the function that calls method call and returns a promise
hash[key] = function() ... | [
"function",
"(",
"iface",
")",
"{",
"var",
"hash",
"=",
"{",
"}",
";",
"var",
"collection",
"=",
"iface",
".",
"__name__",
".",
"substring",
"(",
"1",
")",
";",
"var",
"dataContext",
"=",
"this",
";",
"_",
"(",
"typedef",
".",
"signature",
"(",
"if... | Given an interface, create and instantiate a class that let's us call all of the methods | [
"Given",
"an",
"interface",
"create",
"and",
"instantiate",
"a",
"class",
"that",
"let",
"s",
"us",
"call",
"all",
"of",
"the",
"methods"
] | 883955e23b6f6102db24209ed81a85fb0be596b6 | https://github.com/bvalosek/infusionsoft-api/blob/883955e23b6f6102db24209ed81a85fb0be596b6/lib/DataContext.js#L58-L85 | train | |
deployd/dpd-dashboard | dashboard/js/lib/ui.js | Dialog | function Dialog(options) {
ui.Emitter.call(this);
options = options || {};
this.template = html;
this.el = $(this.template);
this.render(options);
if (active && !active.hiding) active.hide();
if (Dialog.effect) this.effect(Dialog.effect);
active = this;
} | javascript | function Dialog(options) {
ui.Emitter.call(this);
options = options || {};
this.template = html;
this.el = $(this.template);
this.render(options);
if (active && !active.hiding) active.hide();
if (Dialog.effect) this.effect(Dialog.effect);
active = this;
} | [
"function",
"Dialog",
"(",
"options",
")",
"{",
"ui",
".",
"Emitter",
".",
"call",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"template",
"=",
"html",
";",
"this",
".",
"el",
"=",
"$",
"(",
"this",
".",
... | Initialize a new `Dialog`.
Options:
- `title` dialog title
- `message` a message to display
Emits:
- `show` when visible
- `hide` when hidden
@param {Object} options
@api public | [
"Initialize",
"a",
"new",
"Dialog",
"."
] | 1ffb4c09cbeba7bf040dfe388aa46f206292be18 | https://github.com/deployd/dpd-dashboard/blob/1ffb4c09cbeba7bf040dfe388aa46f206292be18/dashboard/js/lib/ui.js#L155-L164 | train |
deployd/dpd-dashboard | dashboard/js/lib/ui.js | ColorPicker | function ColorPicker() {
ui.Emitter.call(this);
this._colorPos = {};
this.el = $(html);
this.main = this.el.find('.main').get(0);
this.spectrum = this.el.find('.spectrum').get(0);
$(this.main).bind('selectstart', function(e){ e.preventDefault() });
$(this.spectrum).bind('selectstart', function(e){ e.preve... | javascript | function ColorPicker() {
ui.Emitter.call(this);
this._colorPos = {};
this.el = $(html);
this.main = this.el.find('.main').get(0);
this.spectrum = this.el.find('.spectrum').get(0);
$(this.main).bind('selectstart', function(e){ e.preventDefault() });
$(this.spectrum).bind('selectstart', function(e){ e.preve... | [
"function",
"ColorPicker",
"(",
")",
"{",
"ui",
".",
"Emitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_colorPos",
"=",
"{",
"}",
";",
"this",
".",
"el",
"=",
"$",
"(",
"html",
")",
";",
"this",
".",
"main",
"=",
"this",
".",
"el",
... | Initialize a new `ColorPicker`.
Emits:
- `change` with the given color object
@api public | [
"Initialize",
"a",
"new",
"ColorPicker",
"."
] | 1ffb4c09cbeba7bf040dfe388aa46f206292be18 | https://github.com/deployd/dpd-dashboard/blob/1ffb4c09cbeba7bf040dfe388aa46f206292be18/dashboard/js/lib/ui.js#L624-L638 | train |
deployd/dpd-dashboard | dashboard/js/lib/ui.js | type | function type(type) {
return function(title, msg){
return exports.notify.apply(this, arguments)
.type(type);
}
} | javascript | function type(type) {
return function(title, msg){
return exports.notify.apply(this, arguments)
.type(type);
}
} | [
"function",
"type",
"(",
"type",
")",
"{",
"return",
"function",
"(",
"title",
",",
"msg",
")",
"{",
"return",
"exports",
".",
"notify",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
".",
"type",
"(",
"type",
")",
";",
"}",
"}"
] | Construct a notification function for `type`.
@param {String} type
@return {Function}
@api private | [
"Construct",
"a",
"notification",
"function",
"for",
"type",
"."
] | 1ffb4c09cbeba7bf040dfe388aa46f206292be18 | https://github.com/deployd/dpd-dashboard/blob/1ffb4c09cbeba7bf040dfe388aa46f206292be18/dashboard/js/lib/ui.js#L983-L988 | train |
deployd/dpd-dashboard | dashboard/js/lib/ui.js | Notification | function Notification(options) {
ui.Emitter.call(this);
options = options || {};
this.template = html;
this.el = $(this.template);
this.render(options);
if (Notification.effect) this.effect(Notification.effect);
} | javascript | function Notification(options) {
ui.Emitter.call(this);
options = options || {};
this.template = html;
this.el = $(this.template);
this.render(options);
if (Notification.effect) this.effect(Notification.effect);
} | [
"function",
"Notification",
"(",
"options",
")",
"{",
"ui",
".",
"Emitter",
".",
"call",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"template",
"=",
"html",
";",
"this",
".",
"el",
"=",
"$",
"(",
"this",
"... | Initialize a new `Notification`.
Options:
- `title` dialog title
- `message` a message to display
@param {Object} options
@api public | [
"Initialize",
"a",
"new",
"Notification",
"."
] | 1ffb4c09cbeba7bf040dfe388aa46f206292be18 | https://github.com/deployd/dpd-dashboard/blob/1ffb4c09cbeba7bf040dfe388aa46f206292be18/dashboard/js/lib/ui.js#L1010-L1017 | train |
deployd/dpd-dashboard | dashboard/js/lib/ui.js | SplitButton | function SplitButton(label) {
ui.Emitter.call(this);
this.el = $(html);
this.events();
this.render({ label: label });
this.state = 'hidden';
} | javascript | function SplitButton(label) {
ui.Emitter.call(this);
this.el = $(html);
this.events();
this.render({ label: label });
this.state = 'hidden';
} | [
"function",
"SplitButton",
"(",
"label",
")",
"{",
"ui",
".",
"Emitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"el",
"=",
"$",
"(",
"html",
")",
";",
"this",
".",
"events",
"(",
")",
";",
"this",
".",
"render",
"(",
"{",
"label",
":"... | Initialize a new `SplitButton`
with an optional `label`.
@param {String} label
@api public | [
"Initialize",
"a",
"new",
"SplitButton",
"with",
"an",
"optional",
"label",
"."
] | 1ffb4c09cbeba7bf040dfe388aa46f206292be18 | https://github.com/deployd/dpd-dashboard/blob/1ffb4c09cbeba7bf040dfe388aa46f206292be18/dashboard/js/lib/ui.js#L1189-L1195 | 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.