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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TNRIS/weather-alerts-geojson | lib/feature-transform.js | polygonize | function polygonize (str, properties) {
var coordinates = str.split(' ').map(function (pairStr) {
return pairStr.split(',').reverse().map(Number);
});
return polygon([coordinates], properties);
} | javascript | function polygonize (str, properties) {
var coordinates = str.split(' ').map(function (pairStr) {
return pairStr.split(',').reverse().map(Number);
});
return polygon([coordinates], properties);
} | [
"function",
"polygonize",
"(",
"str",
",",
"properties",
")",
"{",
"var",
"coordinates",
"=",
"str",
".",
"split",
"(",
"' '",
")",
".",
"map",
"(",
"function",
"(",
"pairStr",
")",
"{",
"return",
"pairStr",
".",
"split",
"(",
"','",
")",
".",
"rever... | converts an alert polygon string to a GeoJSON polygon geometry | [
"converts",
"an",
"alert",
"polygon",
"string",
"to",
"a",
"GeoJSON",
"polygon",
"geometry"
] | ccc91f033e5bc91957c9903763d4593a2a97a3d1 | https://github.com/TNRIS/weather-alerts-geojson/blob/ccc91f033e5bc91957c9903763d4593a2a97a3d1/lib/feature-transform.js#L8-L14 | train |
TNRIS/weather-alerts-geojson | lib/feature-transform.js | decodify | function decodify (featureCollection, code, properties) {
var feature = find(featureCollection.features, {'id': code});
if (feature) {
feature.properties = properties;
}
return feature;
} | javascript | function decodify (featureCollection, code, properties) {
var feature = find(featureCollection.features, {'id': code});
if (feature) {
feature.properties = properties;
}
return feature;
} | [
"function",
"decodify",
"(",
"featureCollection",
",",
"code",
",",
"properties",
")",
"{",
"var",
"feature",
"=",
"find",
"(",
"featureCollection",
".",
"features",
",",
"{",
"'id'",
":",
"code",
"}",
")",
";",
"if",
"(",
"feature",
")",
"{",
"feature",... | pulls feature from featureCollection with ID matching code, and creates a new feature from that geometry with properties substituted in | [
"pulls",
"feature",
"from",
"featureCollection",
"with",
"ID",
"matching",
"code",
"and",
"creates",
"a",
"new",
"feature",
"from",
"that",
"geometry",
"with",
"properties",
"substituted",
"in"
] | ccc91f033e5bc91957c9903763d4593a2a97a3d1 | https://github.com/TNRIS/weather-alerts-geojson/blob/ccc91f033e5bc91957c9903763d4593a2a97a3d1/lib/feature-transform.js#L19-L27 | train |
rtsao/scope-styles | lib/inline-prop-to-css.js | toCSSProp | function toCSSProp(prop) {
var dashed = prop.replace(regex, '-$&').toLowerCase();
return dashed[0] === 'm' && dashed[1] === 's' ? '-' + dashed : dashed;
} | javascript | function toCSSProp(prop) {
var dashed = prop.replace(regex, '-$&').toLowerCase();
return dashed[0] === 'm' && dashed[1] === 's' ? '-' + dashed : dashed;
} | [
"function",
"toCSSProp",
"(",
"prop",
")",
"{",
"var",
"dashed",
"=",
"prop",
".",
"replace",
"(",
"regex",
",",
"'-$&'",
")",
".",
"toLowerCase",
"(",
")",
";",
"return",
"dashed",
"[",
"0",
"]",
"===",
"'m'",
"&&",
"dashed",
"[",
"1",
"]",
"===",... | Converts a style object property name to its CSS property name equivalent,
taking into account the exception of `-ms` vendor prefixes
@param {string} prop - Style object property name, e.g. `WebkitTransition`
@return {string} - CSS property name, e.g. `-webkit-transition` | [
"Converts",
"a",
"style",
"object",
"property",
"name",
"to",
"its",
"CSS",
"property",
"name",
"equivalent",
"taking",
"into",
"account",
"the",
"exception",
"of",
"-",
"ms",
"vendor",
"prefixes"
] | 4ea0b959f4b58e7736408d746fca78f8747bd476 | https://github.com/rtsao/scope-styles/blob/4ea0b959f4b58e7736408d746fca78f8747bd476/lib/inline-prop-to-css.js#L11-L14 | train |
MoOx/reduce-function-call | index.js | reduceFunctionCall | function reduceFunctionCall(string, functionRE, callback) {
var call = string
return getFunctionCalls(string, functionRE).reduce(function(string, obj) {
return string.replace(obj.functionIdentifier + "(" + obj.matches.body + ")", evalFunctionCall(obj.matches.body, obj.functionIdentifier, callback, call, functio... | javascript | function reduceFunctionCall(string, functionRE, callback) {
var call = string
return getFunctionCalls(string, functionRE).reduce(function(string, obj) {
return string.replace(obj.functionIdentifier + "(" + obj.matches.body + ")", evalFunctionCall(obj.matches.body, obj.functionIdentifier, callback, call, functio... | [
"function",
"reduceFunctionCall",
"(",
"string",
",",
"functionRE",
",",
"callback",
")",
"{",
"var",
"call",
"=",
"string",
"return",
"getFunctionCalls",
"(",
"string",
",",
"functionRE",
")",
".",
"reduce",
"(",
"function",
"(",
"string",
",",
"obj",
")",
... | Walkthrough all expressions, evaluate them and insert them into the declaration
@param {Array} expressions
@param {Object} declaration | [
"Walkthrough",
"all",
"expressions",
"evaluate",
"them",
"and",
"insert",
"them",
"into",
"the",
"declaration"
] | d947e59b75e5c01502993c1f8aaae4741ca35d0f | https://github.com/MoOx/reduce-function-call/blob/d947e59b75e5c01502993c1f8aaae4741ca35d0f/index.js#L20-L25 | train |
MoOx/reduce-function-call | index.js | getFunctionCalls | function getFunctionCalls(call, functionRE) {
var expressions = []
var fnRE = typeof functionRE === "string" ? new RegExp("\\b(" + functionRE + ")\\(") : functionRE
do {
var searchMatch = fnRE.exec(call)
if (!searchMatch) {
return expressions
}
if (searchMatch[1] === undefined) {
thro... | javascript | function getFunctionCalls(call, functionRE) {
var expressions = []
var fnRE = typeof functionRE === "string" ? new RegExp("\\b(" + functionRE + ")\\(") : functionRE
do {
var searchMatch = fnRE.exec(call)
if (!searchMatch) {
return expressions
}
if (searchMatch[1] === undefined) {
thro... | [
"function",
"getFunctionCalls",
"(",
"call",
",",
"functionRE",
")",
"{",
"var",
"expressions",
"=",
"[",
"]",
"var",
"fnRE",
"=",
"typeof",
"functionRE",
"===",
"\"string\"",
"?",
"new",
"RegExp",
"(",
"\"\\\\b(\"",
"+",
"functionRE",
"+",
"\")\\\\(\"",
")"... | Parses expressions in a value
@param {String} value
@returns {Array}
@api private | [
"Parses",
"expressions",
"in",
"a",
"value"
] | d947e59b75e5c01502993c1f8aaae4741ca35d0f | https://github.com/MoOx/reduce-function-call/blob/d947e59b75e5c01502993c1f8aaae4741ca35d0f/index.js#L35-L61 | train |
MoOx/reduce-function-call | index.js | evalFunctionCall | function evalFunctionCall (string, functionIdentifier, callback, call, functionRE) {
// allow recursivity
return callback(reduceFunctionCall(string, functionRE, callback), functionIdentifier, call)
} | javascript | function evalFunctionCall (string, functionIdentifier, callback, call, functionRE) {
// allow recursivity
return callback(reduceFunctionCall(string, functionRE, callback), functionIdentifier, call)
} | [
"function",
"evalFunctionCall",
"(",
"string",
",",
"functionIdentifier",
",",
"callback",
",",
"call",
",",
"functionRE",
")",
"{",
"// allow recursivity",
"return",
"callback",
"(",
"reduceFunctionCall",
"(",
"string",
",",
"functionRE",
",",
"callback",
")",
",... | Evaluates an expression
@param {String} expression
@returns {String}
@api private | [
"Evaluates",
"an",
"expression"
] | d947e59b75e5c01502993c1f8aaae4741ca35d0f | https://github.com/MoOx/reduce-function-call/blob/d947e59b75e5c01502993c1f8aaae4741ca35d0f/index.js#L71-L74 | train |
OLIOEX/gulp-json-modify | index.js | space | function space(json) {
var match = json.match(/^(?:(\t+)|( +))"/m)
return match ? (match[1] ? '\t' : match[2].length) : ''
} | javascript | function space(json) {
var match = json.match(/^(?:(\t+)|( +))"/m)
return match ? (match[1] ? '\t' : match[2].length) : ''
} | [
"function",
"space",
"(",
"json",
")",
"{",
"var",
"match",
"=",
"json",
".",
"match",
"(",
"/",
"^(?:(\\t+)|( +))\"",
"/",
"m",
")",
"return",
"match",
"?",
"(",
"match",
"[",
"1",
"]",
"?",
"'\\t'",
":",
"match",
"[",
"2",
"]",
".",
"length",
"... | Figured out which "space" params to be used for JSON.stringfiy. | [
"Figured",
"out",
"which",
"space",
"params",
"to",
"be",
"used",
"for",
"JSON",
".",
"stringfiy",
"."
] | a26a66e9139bba2ac1849abdf4c38d09e7ec10fe | https://github.com/OLIOEX/gulp-json-modify/blob/a26a66e9139bba2ac1849abdf4c38d09e7ec10fe/index.js#L89-L92 | train |
andreypopp/rrouter | src/mergeInto.js | mergeInto | function mergeInto(one, two) {
checkMergeObjectArg(one);
if (two != null) {
checkMergeObjectArg(two);
for (var key in two) {
if (!two.hasOwnProperty(key)) {
continue;
}
one[key] = two[key];
}
}
} | javascript | function mergeInto(one, two) {
checkMergeObjectArg(one);
if (two != null) {
checkMergeObjectArg(two);
for (var key in two) {
if (!two.hasOwnProperty(key)) {
continue;
}
one[key] = two[key];
}
}
} | [
"function",
"mergeInto",
"(",
"one",
",",
"two",
")",
"{",
"checkMergeObjectArg",
"(",
"one",
")",
";",
"if",
"(",
"two",
"!=",
"null",
")",
"{",
"checkMergeObjectArg",
"(",
"two",
")",
";",
"for",
"(",
"var",
"key",
"in",
"two",
")",
"{",
"if",
"(... | Shallow merges two structures by mutating the first parameter.
@param {object} one Object to be merged into.
@param {?object} two Optional object with properties to merge from. | [
"Shallow",
"merges",
"two",
"structures",
"by",
"mutating",
"the",
"first",
"parameter",
"."
] | 4287dc666254af61f1d169c12fb61a1bfd7e2623 | https://github.com/andreypopp/rrouter/blob/4287dc666254af61f1d169c12fb61a1bfd7e2623/src/mergeInto.js#L32-L43 | train |
tralves/ns-vue-loader | lib/loader.js | getRawRequest | function getRawRequest (
{ resource, loaderIndex, loaders },
excludedPreLoaders = /eslint-loader/
) {
return loaderUtils.getRemainingRequest({
resource: resource,
loaderIndex: loaderIndex,
loaders: loaders.filter(loader => !excludedPreLoaders.test(loader.path))
})
} | javascript | function getRawRequest (
{ resource, loaderIndex, loaders },
excludedPreLoaders = /eslint-loader/
) {
return loaderUtils.getRemainingRequest({
resource: resource,
loaderIndex: loaderIndex,
loaders: loaders.filter(loader => !excludedPreLoaders.test(loader.path))
})
} | [
"function",
"getRawRequest",
"(",
"{",
"resource",
",",
"loaderIndex",
",",
"loaders",
"}",
",",
"excludedPreLoaders",
"=",
"/",
"eslint-loader",
"/",
")",
"{",
"return",
"loaderUtils",
".",
"getRemainingRequest",
"(",
"{",
"resource",
":",
"resource",
",",
"l... | When extracting parts from the source vue file, we want to apply the loaders chained before ns-vue-loader, but exclude some loaders that simply produces side effects such as linting. | [
"When",
"extracting",
"parts",
"from",
"the",
"source",
"vue",
"file",
"we",
"want",
"to",
"apply",
"the",
"loaders",
"chained",
"before",
"ns",
"-",
"vue",
"-",
"loader",
"but",
"exclude",
"some",
"loaders",
"that",
"simply",
"produces",
"side",
"effects",
... | 6ff08bcae22bc37bcc394fb55181f76924eeb49c | https://github.com/tralves/ns-vue-loader/blob/6ff08bcae22bc37bcc394fb55181f76924eeb49c/lib/loader.js#L36-L45 | train |
tralves/ns-vue-loader | lib/loader.js | stringifyLoaders | function stringifyLoaders (loaders) {
return loaders
.map(
obj =>
obj && typeof obj === 'object' && typeof obj.loader === 'string'
? obj.loader +
(obj.options ? '?' + JSON.stringify(obj.options) : '')
: obj
)
.join('!')
} | javascript | function stringifyLoaders (loaders) {
return loaders
.map(
obj =>
obj && typeof obj === 'object' && typeof obj.loader === 'string'
? obj.loader +
(obj.options ? '?' + JSON.stringify(obj.options) : '')
: obj
)
.join('!')
} | [
"function",
"stringifyLoaders",
"(",
"loaders",
")",
"{",
"return",
"loaders",
".",
"map",
"(",
"obj",
"=>",
"obj",
"&&",
"typeof",
"obj",
"===",
"'object'",
"&&",
"typeof",
"obj",
".",
"loader",
"===",
"'string'",
"?",
"obj",
".",
"loader",
"+",
"(",
... | stringify an Array of loader objects | [
"stringify",
"an",
"Array",
"of",
"loader",
"objects"
] | 6ff08bcae22bc37bcc394fb55181f76924eeb49c | https://github.com/tralves/ns-vue-loader/blob/6ff08bcae22bc37bcc394fb55181f76924eeb49c/lib/loader.js#L516-L526 | train |
zxqfox/reserved-words | lib/reserved-words.js | _hash | function _hash() {
var set = Array.prototype.map.call(arguments, function(v) {
return typeof v === 'string' ? v : Object.keys(v).join(' ');
}).join(' ');
return set.split(/\s+/)
.reduce(function(res, keyword) {
res[keyword] = true;
return res;
}, {});
} | javascript | function _hash() {
var set = Array.prototype.map.call(arguments, function(v) {
return typeof v === 'string' ? v : Object.keys(v).join(' ');
}).join(' ');
return set.split(/\s+/)
.reduce(function(res, keyword) {
res[keyword] = true;
return res;
}, {});
} | [
"function",
"_hash",
"(",
")",
"{",
"var",
"set",
"=",
"Array",
".",
"prototype",
".",
"map",
".",
"call",
"(",
"arguments",
",",
"function",
"(",
"v",
")",
"{",
"return",
"typeof",
"v",
"===",
"'string'",
"?",
"v",
":",
"Object",
".",
"keys",
"(",... | Generates hash from strings
@private
@param {...String|KeywordsHash} keywords - Space-delimited string or previous result of _hash
@return {KeywordsHash} - Object with keywords in keys and true in values | [
"Generates",
"hash",
"from",
"strings"
] | d4dcf840d14efa590158364374d0ad20b2474485 | https://github.com/zxqfox/reserved-words/blob/d4dcf840d14efa590158364374d0ad20b2474485/lib/reserved-words.js#L167-L177 | train |
andreypopp/rrouter | src/matchRoutes.js | matchRoute | function matchRoute(route, path) {
if (route.pattern === undefined && route.path !== undefined) {
var routePattern;
if (route.path instanceof RegExp) {
routePattern = route.path;
} else {
var routePath = normalize(route.path);
routePattern = route.children.length > 0 ? routePath + '*' ... | javascript | function matchRoute(route, path) {
if (route.pattern === undefined && route.path !== undefined) {
var routePattern;
if (route.path instanceof RegExp) {
routePattern = route.path;
} else {
var routePath = normalize(route.path);
routePattern = route.children.length > 0 ? routePath + '*' ... | [
"function",
"matchRoute",
"(",
"route",
",",
"path",
")",
"{",
"if",
"(",
"route",
".",
"pattern",
"===",
"undefined",
"&&",
"route",
".",
"path",
"!==",
"undefined",
")",
"{",
"var",
"routePattern",
";",
"if",
"(",
"route",
".",
"path",
"instanceof",
... | Match route against path
@param {Route} route
@param {String} path
@returns {Match|Null} | [
"Match",
"route",
"against",
"path"
] | 4287dc666254af61f1d169c12fb61a1bfd7e2623 | https://github.com/andreypopp/rrouter/blob/4287dc666254af61f1d169c12fb61a1bfd7e2623/src/matchRoutes.js#L37-L73 | train |
andreypopp/rrouter | src/matchRoutes.js | matchRoutes | function matchRoutes(routes, path, query) {
query = query === undefined ? {} : isString(query) ? qs.parse(query) : query;
return matchRoutesImpl(routes, path, query);
} | javascript | function matchRoutes(routes, path, query) {
query = query === undefined ? {} : isString(query) ? qs.parse(query) : query;
return matchRoutesImpl(routes, path, query);
} | [
"function",
"matchRoutes",
"(",
"routes",
",",
"path",
",",
"query",
")",
"{",
"query",
"=",
"query",
"===",
"undefined",
"?",
"{",
"}",
":",
"isString",
"(",
"query",
")",
"?",
"qs",
".",
"parse",
"(",
"query",
")",
":",
"query",
";",
"return",
"m... | Match routes against path
@param {Route} routes
@param {String} path
@returns {Match} | [
"Match",
"routes",
"against",
"path"
] | 4287dc666254af61f1d169c12fb61a1bfd7e2623 | https://github.com/andreypopp/rrouter/blob/4287dc666254af61f1d169c12fb61a1bfd7e2623/src/matchRoutes.js#L121-L124 | train |
doowb/async-helpers | index.js | AsyncHelpers | function AsyncHelpers(options) {
if (!(this instanceof AsyncHelpers)) {
return new AsyncHelpers(options);
}
this.options = Object.assign({}, options);
this.prefix = this.options.prefix || '{$ASYNCID$';
this.globalCounter = AsyncHelpers.globalCounter++;
this.helpers = {};
this.counter = 0;
this.prefi... | javascript | function AsyncHelpers(options) {
if (!(this instanceof AsyncHelpers)) {
return new AsyncHelpers(options);
}
this.options = Object.assign({}, options);
this.prefix = this.options.prefix || '{$ASYNCID$';
this.globalCounter = AsyncHelpers.globalCounter++;
this.helpers = {};
this.counter = 0;
this.prefi... | [
"function",
"AsyncHelpers",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"AsyncHelpers",
")",
")",
"{",
"return",
"new",
"AsyncHelpers",
"(",
"options",
")",
";",
"}",
"this",
".",
"options",
"=",
"Object",
".",
"assign",
"(",
"... | Create a new instance of AsyncHelpers
```js
var asyncHelpers = new AsyncHelpers();
```
@param {Object} `options` options to pass to instance
@return {Object} new AsyncHelpers instance
@api public | [
"Create",
"a",
"new",
"instance",
"of",
"AsyncHelpers"
] | ea33b6e2062ec49a9b4780f847f6f24eb52fd43e | https://github.com/doowb/async-helpers/blob/ea33b6e2062ec49a9b4780f847f6f24eb52fd43e/index.js#L32-L42 | train |
doowb/async-helpers | index.js | wrapper | function wrapper() {
var num = self.counter++;
var id = createId(prefix, num);
var token = {
name: name,
async: !!fn.async,
prefix: prefix,
num: num,
id: id,
fn: fn,
args: [].slice.call(arguments)
};
define(token, 'context', this);
stash[id] = token;
... | javascript | function wrapper() {
var num = self.counter++;
var id = createId(prefix, num);
var token = {
name: name,
async: !!fn.async,
prefix: prefix,
num: num,
id: id,
fn: fn,
args: [].slice.call(arguments)
};
define(token, 'context', this);
stash[id] = token;
... | [
"function",
"wrapper",
"(",
")",
"{",
"var",
"num",
"=",
"self",
".",
"counter",
"++",
";",
"var",
"id",
"=",
"createId",
"(",
"prefix",
",",
"num",
")",
";",
"var",
"token",
"=",
"{",
"name",
":",
"name",
",",
"async",
":",
"!",
"!",
"fn",
"."... | wrap the helper and generate a unique ID for resolving it | [
"wrap",
"the",
"helper",
"and",
"generate",
"a",
"unique",
"ID",
"for",
"resolving",
"it"
] | ea33b6e2062ec49a9b4780f847f6f24eb52fd43e | https://github.com/doowb/async-helpers/blob/ea33b6e2062ec49a9b4780f847f6f24eb52fd43e/index.js#L198-L215 | train |
doowb/async-helpers | index.js | formatError | function formatError(err, helper, args) {
err.helper = helper;
define(err, 'args', args);
return err;
} | javascript | function formatError(err, helper, args) {
err.helper = helper;
define(err, 'args', args);
return err;
} | [
"function",
"formatError",
"(",
"err",
",",
"helper",
",",
"args",
")",
"{",
"err",
".",
"helper",
"=",
"helper",
";",
"define",
"(",
"err",
",",
"'args'",
",",
"args",
")",
";",
"return",
"err",
";",
"}"
] | Format an error message to provide better information about the
helper and the arguments passed to the helper when the error occurred.
@param {Object} `err` Error object
@param {Object} `helper` helper object to provide more information
@param {Array} `args` Array of arguments passed to the helper.
@return {Object}... | [
"Format",
"an",
"error",
"message",
"to",
"provide",
"better",
"information",
"about",
"the",
"helper",
"and",
"the",
"arguments",
"passed",
"to",
"the",
"helper",
"when",
"the",
"error",
"occurred",
"."
] | ea33b6e2062ec49a9b4780f847f6f24eb52fd43e | https://github.com/doowb/async-helpers/blob/ea33b6e2062ec49a9b4780f847f6f24eb52fd43e/index.js#L460-L464 | train |
doowb/async-helpers | index.js | toRegex | function toRegex(prefix) {
var key = appendPrefix(prefix, '(\\d+)');
if (cache.hasOwnProperty(key)) {
return cache[key];
}
var regex = new RegExp(createRegexString(key), 'g');
cache[key] = regex;
return regex;
} | javascript | function toRegex(prefix) {
var key = appendPrefix(prefix, '(\\d+)');
if (cache.hasOwnProperty(key)) {
return cache[key];
}
var regex = new RegExp(createRegexString(key), 'g');
cache[key] = regex;
return regex;
} | [
"function",
"toRegex",
"(",
"prefix",
")",
"{",
"var",
"key",
"=",
"appendPrefix",
"(",
"prefix",
",",
"'(\\\\d+)'",
")",
";",
"if",
"(",
"cache",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"return",
"cache",
"[",
"key",
"]",
";",
"}",
"var",
... | Create a regular expression based on the given `prefix`.
@param {String} `prefix`
@return {RegExp} | [
"Create",
"a",
"regular",
"expression",
"based",
"on",
"the",
"given",
"prefix",
"."
] | ea33b6e2062ec49a9b4780f847f6f24eb52fd43e | https://github.com/doowb/async-helpers/blob/ea33b6e2062ec49a9b4780f847f6f24eb52fd43e/index.js#L496-L504 | train |
doowb/async-helpers | index.js | createRegexString | function createRegexString(prefix) {
var key = 'createRegexString:' + prefix;
if (cache.hasOwnProperty(key)) {
return cache[key];
}
var str = (prefix + '(\\d+)$}').replace(/\\?([${}])/g, '\\$1');
cache[key] = str;
return str;
} | javascript | function createRegexString(prefix) {
var key = 'createRegexString:' + prefix;
if (cache.hasOwnProperty(key)) {
return cache[key];
}
var str = (prefix + '(\\d+)$}').replace(/\\?([${}])/g, '\\$1');
cache[key] = str;
return str;
} | [
"function",
"createRegexString",
"(",
"prefix",
")",
"{",
"var",
"key",
"=",
"'createRegexString:'",
"+",
"prefix",
";",
"if",
"(",
"cache",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"return",
"cache",
"[",
"key",
"]",
";",
"}",
"var",
"str",
"... | Create a string to pass into `RegExp` for checking for and finding async ids.
@param {String} `prefix` prefix to use for the first part of the regex
@return {String} string to pass into `RegExp` | [
"Create",
"a",
"string",
"to",
"pass",
"into",
"RegExp",
"for",
"checking",
"for",
"and",
"finding",
"async",
"ids",
"."
] | ea33b6e2062ec49a9b4780f847f6f24eb52fd43e | https://github.com/doowb/async-helpers/blob/ea33b6e2062ec49a9b4780f847f6f24eb52fd43e/index.js#L512-L520 | train |
jostinsu/postcss-svg-sprite | index.js | getCss | function getCss(shapes, options) {
const spriteRelative = path.relative(options.styleOutput, options.spritePath);
return new CSS(shapes, {
nameSpace: options.nameSpace,
block: options.dirname,
separator: options.cssSeparator,
spriteRelative: path.normalize(spriteRelative).replace(/\\/g, '/')
}).getCss();
} | javascript | function getCss(shapes, options) {
const spriteRelative = path.relative(options.styleOutput, options.spritePath);
return new CSS(shapes, {
nameSpace: options.nameSpace,
block: options.dirname,
separator: options.cssSeparator,
spriteRelative: path.normalize(spriteRelative).replace(/\\/g, '/')
}).getCss();
} | [
"function",
"getCss",
"(",
"shapes",
",",
"options",
")",
"{",
"const",
"spriteRelative",
"=",
"path",
".",
"relative",
"(",
"options",
".",
"styleOutput",
",",
"options",
".",
"spritePath",
")",
";",
"return",
"new",
"CSS",
"(",
"shapes",
",",
"{",
"nam... | Get css code which corresponding to svg sprite
@param {Object} shapes
@param {Object} options
@return {String} cssStr | [
"Get",
"css",
"code",
"which",
"corresponding",
"to",
"svg",
"sprite"
] | 8d19ac5b93a9a1177adcbe06249b7d37b39f1a67 | https://github.com/jostinsu/postcss-svg-sprite/blob/8d19ac5b93a9a1177adcbe06249b7d37b39f1a67/index.js#L174-L182 | train |
jostinsu/postcss-svg-sprite | index.js | _isSvgFile | function _isSvgFile(file, dirPath) {
let flag = false,
isFile = fs.statSync(path.resolve(dirPath, file)).isFile();
if (isFile) { // Exclude directory
if (path.extname(file) === '.svg') { // Only accept files which with svg suffix
flag = true;
}
}
return flag;
} | javascript | function _isSvgFile(file, dirPath) {
let flag = false,
isFile = fs.statSync(path.resolve(dirPath, file)).isFile();
if (isFile) { // Exclude directory
if (path.extname(file) === '.svg') { // Only accept files which with svg suffix
flag = true;
}
}
return flag;
} | [
"function",
"_isSvgFile",
"(",
"file",
",",
"dirPath",
")",
"{",
"let",
"flag",
"=",
"false",
",",
"isFile",
"=",
"fs",
".",
"statSync",
"(",
"path",
".",
"resolve",
"(",
"dirPath",
",",
"file",
")",
")",
".",
"isFile",
"(",
")",
";",
"if",
"(",
... | Determine whether the current file is an svg file
@param {String} file
@param {String} dirPath
@return {Boolean} | [
"Determine",
"whether",
"the",
"current",
"file",
"is",
"an",
"svg",
"file"
] | 8d19ac5b93a9a1177adcbe06249b7d37b39f1a67 | https://github.com/jostinsu/postcss-svg-sprite/blob/8d19ac5b93a9a1177adcbe06249b7d37b39f1a67/index.js#L220-L230 | train |
jostinsu/postcss-svg-sprite | index.js | log | function log(msg, type) {
switch (type) {
case 'error':
fancyLog(`${PLUGINNAME}: ${colors.red(`Error, ${msg}`)}`);
break;
case 'warn':
fancyLog(`${PLUGINNAME}: ${colors.yellow(`Warning, ${msg}`)}`);
break;
case 'info':
fancyLog(`${PLUGINNAME}: ${colors.green(`Info, ${msg}`)}`);
break;
default:
fan... | javascript | function log(msg, type) {
switch (type) {
case 'error':
fancyLog(`${PLUGINNAME}: ${colors.red(`Error, ${msg}`)}`);
break;
case 'warn':
fancyLog(`${PLUGINNAME}: ${colors.yellow(`Warning, ${msg}`)}`);
break;
case 'info':
fancyLog(`${PLUGINNAME}: ${colors.green(`Info, ${msg}`)}`);
break;
default:
fan... | [
"function",
"log",
"(",
"msg",
",",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"'error'",
":",
"fancyLog",
"(",
"`",
"${",
"PLUGINNAME",
"}",
"${",
"colors",
".",
"red",
"(",
"`",
"${",
"msg",
"}",
"`",
")",
"}",
"`",
")",
";",
... | Format log based on different types
@param {String} msg
@param {String} type | [
"Format",
"log",
"based",
"on",
"different",
"types"
] | 8d19ac5b93a9a1177adcbe06249b7d37b39f1a67 | https://github.com/jostinsu/postcss-svg-sprite/blob/8d19ac5b93a9a1177adcbe06249b7d37b39f1a67/index.js#L239-L258 | train |
zzarcon/psaux | lib/psaux.js | parseProcesses | function parseProcesses(list, ps) {
var p = ps.split(/ +/);
list.push({
user: p[0],
pid: p[1],
cpu: parseFloat(p[2]),
mem: parseFloat(p[3]),
vsz: p[4],
rss: p[5],
tt: p[6],
stat: p[7],
started: p[8],
time: p[9],
command: p.slice(10).join(' ')
});
return list;
} | javascript | function parseProcesses(list, ps) {
var p = ps.split(/ +/);
list.push({
user: p[0],
pid: p[1],
cpu: parseFloat(p[2]),
mem: parseFloat(p[3]),
vsz: p[4],
rss: p[5],
tt: p[6],
stat: p[7],
started: p[8],
time: p[9],
command: p.slice(10).join(' ')
});
return list;
} | [
"function",
"parseProcesses",
"(",
"list",
",",
"ps",
")",
"{",
"var",
"p",
"=",
"ps",
".",
"split",
"(",
"/",
" +",
"/",
")",
";",
"list",
".",
"push",
"(",
"{",
"user",
":",
"p",
"[",
"0",
"]",
",",
"pid",
":",
"p",
"[",
"1",
"]",
",",
... | Normalizes the process payload into a readable object.
@param {Array} list
@param {Array} ps
@return {Array} | [
"Normalizes",
"the",
"process",
"payload",
"into",
"a",
"readable",
"object",
"."
] | 616ee237ecdada422e540b466eda8f097001330d | https://github.com/zzarcon/psaux/blob/616ee237ecdada422e540b466eda8f097001330d/lib/psaux.js#L90-L108 | train |
zzarcon/psaux | lib/psaux.js | cleanValue | function cleanValue(val, char) {
var num;
var conditions = val.split(' ');
var i = 0;
while (!num && i < conditions.length) {
if (conditions[i].indexOf(char) > -1) {
num = conditions[i].replace(/<|>|~/g, '');
}
i++;
}
return parseFloat(num);
} | javascript | function cleanValue(val, char) {
var num;
var conditions = val.split(' ');
var i = 0;
while (!num && i < conditions.length) {
if (conditions[i].indexOf(char) > -1) {
num = conditions[i].replace(/<|>|~/g, '');
}
i++;
}
return parseFloat(num);
} | [
"function",
"cleanValue",
"(",
"val",
",",
"char",
")",
"{",
"var",
"num",
";",
"var",
"conditions",
"=",
"val",
".",
"split",
"(",
"' '",
")",
";",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"!",
"num",
"&&",
"i",
"<",
"conditions",
".",
"length",... | Return the value for a certain condition
@example
cleanValue('foo <100', '<') == 100
cleanValue('>5 <1 bar', '>') == 5
@param {String} val
@param {String} char
@return {Float} | [
"Return",
"the",
"value",
"for",
"a",
"certain",
"condition"
] | 616ee237ecdada422e540b466eda8f097001330d | https://github.com/zzarcon/psaux/blob/616ee237ecdada422e540b466eda8f097001330d/lib/psaux.js#L171-L184 | train |
benekastah/oppo | website/js/ender.js | ancestorMatch | function ancestorMatch(el, tokens, dividedTokens, root) {
var cand
// recursively work backwards through the tokens and up the dom, covering all options
function crawl(e, i, p) {
while (p = walker[dividedTokens[i]](p, e)) {
if (isNode(p) && (found = interpret.apply(p, q(tokens[i]))))... | javascript | function ancestorMatch(el, tokens, dividedTokens, root) {
var cand
// recursively work backwards through the tokens and up the dom, covering all options
function crawl(e, i, p) {
while (p = walker[dividedTokens[i]](p, e)) {
if (isNode(p) && (found = interpret.apply(p, q(tokens[i]))))... | [
"function",
"ancestorMatch",
"(",
"el",
",",
"tokens",
",",
"dividedTokens",
",",
"root",
")",
"{",
"var",
"cand",
"// recursively work backwards through the tokens and up the dom, covering all options",
"function",
"crawl",
"(",
"e",
",",
"i",
",",
"p",
")",
"{",
"... | given elements matching the right-most part of a selector, filter out any that don't match the rest | [
"given",
"elements",
"matching",
"the",
"right",
"-",
"most",
"part",
"of",
"a",
"selector",
"filter",
"out",
"any",
"that",
"don",
"t",
"match",
"the",
"rest"
] | 5cfc3dfd47c71a28b597de2a75fffc9d28880178 | https://github.com/benekastah/oppo/blob/5cfc3dfd47c71a28b597de2a75fffc9d28880178/website/js/ender.js#L2863-L2876 | train |
nwtn/grunt-respimg | tasks/respimg.js | function(callback) {
async.each(task.files, function(file, callback2) {
var srcPath = file.src[0],
extName = path.extname(srcPath).toLowerCase();
// if it’s an SVG or a PDF, copy the file to the output dir
if (extName === '.svg' || extName === '.pdf') {
var dstPath = getDestination(srcPa... | javascript | function(callback) {
async.each(task.files, function(file, callback2) {
var srcPath = file.src[0],
extName = path.extname(srcPath).toLowerCase();
// if it’s an SVG or a PDF, copy the file to the output dir
if (extName === '.svg' || extName === '.pdf') {
var dstPath = getDestination(srcPa... | [
"function",
"(",
"callback",
")",
"{",
"async",
".",
"each",
"(",
"task",
".",
"files",
",",
"function",
"(",
"file",
",",
"callback2",
")",
"{",
"var",
"srcPath",
"=",
"file",
".",
"src",
"[",
"0",
"]",
",",
"extName",
"=",
"path",
".",
"extname",... | copy SVGs and PDFs | [
"copy",
"SVGs",
"and",
"PDFs"
] | 0f3a95d68737d63ac9ff062b2bf83f8d610b3bea | https://github.com/nwtn/grunt-respimg/blob/0f3a95d68737d63ac9ff062b2bf83f8d610b3bea/tasks/respimg.js#L1470-L1491 | train | |
wanderview/node-netbios-name-service | lib/broadcast.js | function(response) {
delete self._requestState[transactionId];
if (typeof callback === 'function') {
// negative response
if (response.error) {
var owner = response.answerRecords[0].nb.entries[0].address;
callback(null, false, owner);
// positive response
... | javascript | function(response) {
delete self._requestState[transactionId];
if (typeof callback === 'function') {
// negative response
if (response.error) {
var owner = response.answerRecords[0].nb.entries[0].address;
callback(null, false, owner);
// positive response
... | [
"function",
"(",
"response",
")",
"{",
"delete",
"self",
".",
"_requestState",
"[",
"transactionId",
"]",
";",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"// negative response",
"if",
"(",
"response",
".",
"error",
")",
"{",
"var",
"ow... | In broadcast mode if we get a response then that means someone is disputing our claim to this name. | [
"In",
"broadcast",
"mode",
"if",
"we",
"get",
"a",
"response",
"then",
"that",
"means",
"someone",
"is",
"disputing",
"our",
"claim",
"to",
"this",
"name",
"."
] | 90cd3c36b5625123ec435577bad1d054de420961 | https://github.com/wanderview/node-netbios-name-service/blob/90cd3c36b5625123ec435577bad1d054de420961/lib/broadcast.js#L116-L129 | train | |
wanderview/node-netbios-name-service | lib/broadcast.js | function() {
delete self._requestState[transactionId];
self._localMap.add(nbname, group, address, ttl, self._type);
self._sendRefresh(nbname, function(error) {
if (typeof callback === 'function') {
callback(error, !error);
}
});
} | javascript | function() {
delete self._requestState[transactionId];
self._localMap.add(nbname, group, address, ttl, self._type);
self._sendRefresh(nbname, function(error) {
if (typeof callback === 'function') {
callback(error, !error);
}
});
} | [
"function",
"(",
")",
"{",
"delete",
"self",
".",
"_requestState",
"[",
"transactionId",
"]",
";",
"self",
".",
"_localMap",
".",
"add",
"(",
"nbname",
",",
"group",
",",
"address",
",",
"ttl",
",",
"self",
".",
"_type",
")",
";",
"self",
".",
"_send... | If we send the required number of registration requests and do not get a conflict response from any other nodes then we can safely declare this name ours. | [
"If",
"we",
"send",
"the",
"required",
"number",
"of",
"registration",
"requests",
"and",
"do",
"not",
"get",
"a",
"conflict",
"response",
"from",
"any",
"other",
"nodes",
"then",
"we",
"can",
"safely",
"declare",
"this",
"name",
"ours",
"."
] | 90cd3c36b5625123ec435577bad1d054de420961 | https://github.com/wanderview/node-netbios-name-service/blob/90cd3c36b5625123ec435577bad1d054de420961/lib/broadcast.js#L134-L142 | train | |
thingtrack/node-red-contrib-inotify | inotify/inotify.js | getWatcherByPath | function getWatcherByPath(path) {
var rlt = undefined;
watchers.forEach(function(watcher) {
if (watcher.path == path)
rlt = watcher;
});
return rlt;
} | javascript | function getWatcherByPath(path) {
var rlt = undefined;
watchers.forEach(function(watcher) {
if (watcher.path == path)
rlt = watcher;
});
return rlt;
} | [
"function",
"getWatcherByPath",
"(",
"path",
")",
"{",
"var",
"rlt",
"=",
"undefined",
";",
"watchers",
".",
"forEach",
"(",
"function",
"(",
"watcher",
")",
"{",
"if",
"(",
"watcher",
".",
"path",
"==",
"path",
")",
"rlt",
"=",
"watcher",
";",
"}",
... | global watcher list | [
"global",
"watcher",
"list"
] | 376d61dd00ef34e4b61c681e6011618c75ada6e1 | https://github.com/thingtrack/node-red-contrib-inotify/blob/376d61dd00ef34e4b61c681e6011618c75ada6e1/inotify/inotify.js#L6-L15 | train |
andreypopp/rrouter | src/makeViewFactoryForMatch.js | makeViewFactoryForMatch | function makeViewFactoryForMatch(match) {
var views = {};
for (var i = match.activeTrace.length - 1; i >= 0; i--) {
var step = match.activeTrace[i];
var stepProps = getStepProps(step);
views = merge(views, collectSubViews(stepProps, views));
if (step.route.view !== undefined) {
return makeV... | javascript | function makeViewFactoryForMatch(match) {
var views = {};
for (var i = match.activeTrace.length - 1; i >= 0; i--) {
var step = match.activeTrace[i];
var stepProps = getStepProps(step);
views = merge(views, collectSubViews(stepProps, views));
if (step.route.view !== undefined) {
return makeV... | [
"function",
"makeViewFactoryForMatch",
"(",
"match",
")",
"{",
"var",
"views",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"match",
".",
"activeTrace",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"step",
"=... | Make view factory for a match object
@param {Match} match
@param {Object} props
@returns {ReactComponent} | [
"Make",
"view",
"factory",
"for",
"a",
"match",
"object"
] | 4287dc666254af61f1d169c12fb61a1bfd7e2623 | https://github.com/andreypopp/rrouter/blob/4287dc666254af61f1d169c12fb61a1bfd7e2623/src/makeViewFactoryForMatch.js#L62-L75 | train |
andreypopp/rrouter | examples/async-code-loading/index.js | AsyncRoute | function AsyncRoute(props) {
props = merge(props, {
viewPromise: loadViewModule,
viewModule: props.view,
view: undefined
})
return Route(props);
} | javascript | function AsyncRoute(props) {
props = merge(props, {
viewPromise: loadViewModule,
viewModule: props.view,
view: undefined
})
return Route(props);
} | [
"function",
"AsyncRoute",
"(",
"props",
")",
"{",
"props",
"=",
"merge",
"(",
"props",
",",
"{",
"viewPromise",
":",
"loadViewModule",
",",
"viewModule",
":",
"props",
".",
"view",
",",
"view",
":",
"undefined",
"}",
")",
"return",
"Route",
"(",
"props",... | a "syntax sugar" which shortcuts defining view code loading | [
"a",
"syntax",
"sugar",
"which",
"shortcuts",
"defining",
"view",
"code",
"loading"
] | 4287dc666254af61f1d169c12fb61a1bfd7e2623 | https://github.com/andreypopp/rrouter/blob/4287dc666254af61f1d169c12fb61a1bfd7e2623/examples/async-code-loading/index.js#L21-L28 | train |
markogresak/canihazip | index.js | CanIHazIp | function CanIHazIp(callback) {
return new Promise(function (resolve) {
var httpCallback = function (response) {
var responseData = '';
// When data is received, append it to `responseData`.
response.on('data', function (chunk) {
responseData += chunk;
});
// When response e... | javascript | function CanIHazIp(callback) {
return new Promise(function (resolve) {
var httpCallback = function (response) {
var responseData = '';
// When data is received, append it to `responseData`.
response.on('data', function (chunk) {
responseData += chunk;
});
// When response e... | [
"function",
"CanIHazIp",
"(",
"callback",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"var",
"httpCallback",
"=",
"function",
"(",
"response",
")",
"{",
"var",
"responseData",
"=",
"''",
";",
"// When data is received, appe... | CanIHazIp constructor function.
@param {Function=} callback (optional) Function to be called with IP data after server responds.
@returns {Promise} Promise which is resolved with IP data after server responds. | [
"CanIHazIp",
"constructor",
"function",
"."
] | 8d930ee990f3572a304be0205bf7c7d5f2c3cdf4 | https://github.com/markogresak/canihazip/blob/8d930ee990f3572a304be0205bf7c7d5f2c3cdf4/index.js#L22-L51 | train |
infusionsoft/bower-locker | bower-locker-common.js | mapDependencyData | function mapDependencyData(bowerInfo) {
return {
name: bowerInfo.name,
commit: bowerInfo._resolution !== undefined ? bowerInfo._resolution.commit : undefined,
release: bowerInfo._release,
src: bowerInfo._source,
originalSrc: bowerInfo._originalSource
};
} | javascript | function mapDependencyData(bowerInfo) {
return {
name: bowerInfo.name,
commit: bowerInfo._resolution !== undefined ? bowerInfo._resolution.commit : undefined,
release: bowerInfo._release,
src: bowerInfo._source,
originalSrc: bowerInfo._originalSource
};
} | [
"function",
"mapDependencyData",
"(",
"bowerInfo",
")",
"{",
"return",
"{",
"name",
":",
"bowerInfo",
".",
"name",
",",
"commit",
":",
"bowerInfo",
".",
"_resolution",
"!==",
"undefined",
"?",
"bowerInfo",
".",
"_resolution",
".",
"commit",
":",
"undefined",
... | Function to pull out and map the specific bower component metadata to our preferred form
@param {Object} bowerInfo
@returns {{name: String, commit: String, release: String, src: String, originalSrc: String}} | [
"Function",
"to",
"pull",
"out",
"and",
"map",
"the",
"specific",
"bower",
"component",
"metadata",
"to",
"our",
"preferred",
"form"
] | 9da98159684015ca872b4c35a1a72eb17ee93b37 | https://github.com/infusionsoft/bower-locker/blob/9da98159684015ca872b4c35a1a72eb17ee93b37/bower-locker-common.js#L13-L21 | train |
infusionsoft/bower-locker | bower-locker-common.js | getDependency | function getDependency(filepath) {
var bowerInfoStr = fs.readFileSync(filepath, {encoding: 'utf8'});
var bowerInfo = JSON.parse(bowerInfoStr);
return mapDependencyData(bowerInfo);
} | javascript | function getDependency(filepath) {
var bowerInfoStr = fs.readFileSync(filepath, {encoding: 'utf8'});
var bowerInfo = JSON.parse(bowerInfoStr);
return mapDependencyData(bowerInfo);
} | [
"function",
"getDependency",
"(",
"filepath",
")",
"{",
"var",
"bowerInfoStr",
"=",
"fs",
".",
"readFileSync",
"(",
"filepath",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
")",
";",
"var",
"bowerInfo",
"=",
"JSON",
".",
"parse",
"(",
"bowerInfoStr",
")",
"... | Function to read and return the specific metadata of a bower component
@param {String} filepath Filepath pointing to the JSON metadata
@returns {Object} Returns dependency metadata object (dirName, commit, release, src, etc.) | [
"Function",
"to",
"read",
"and",
"return",
"the",
"specific",
"metadata",
"of",
"a",
"bower",
"component"
] | 9da98159684015ca872b4c35a1a72eb17ee93b37 | https://github.com/infusionsoft/bower-locker/blob/9da98159684015ca872b4c35a1a72eb17ee93b37/bower-locker-common.js#L28-L32 | train |
infusionsoft/bower-locker | bower-locker-common.js | getBowerFolder | function getBowerFolder() {
var bowerRC = getBowerRC();
if (bowerRC === null || bowerRC.directory === undefined) {
return 'bower_components';
}
return bowerRC.directory;
} | javascript | function getBowerFolder() {
var bowerRC = getBowerRC();
if (bowerRC === null || bowerRC.directory === undefined) {
return 'bower_components';
}
return bowerRC.directory;
} | [
"function",
"getBowerFolder",
"(",
")",
"{",
"var",
"bowerRC",
"=",
"getBowerRC",
"(",
")",
";",
"if",
"(",
"bowerRC",
"===",
"null",
"||",
"bowerRC",
".",
"directory",
"===",
"undefined",
")",
"{",
"return",
"'bower_components'",
";",
"}",
"return",
"bowe... | Gets the folder in which Bower components are stored
@returns {String} | [
"Gets",
"the",
"folder",
"in",
"which",
"Bower",
"components",
"are",
"stored"
] | 9da98159684015ca872b4c35a1a72eb17ee93b37 | https://github.com/infusionsoft/bower-locker/blob/9da98159684015ca872b4c35a1a72eb17ee93b37/bower-locker-common.js#L50-L57 | train |
infusionsoft/bower-locker | bower-locker-common.js | getAllDependencies | function getAllDependencies() {
var folder = './' + getBowerFolder();
var bowerDependencies = fs.readdirSync(folder, {encoding: 'utf8'});
var dependencyInfos = [];
bowerDependencies.forEach(function(dirname) {
var filepath = nodePath.resolve(cwd, folder, dirname, '.bower.json');
if (fs.... | javascript | function getAllDependencies() {
var folder = './' + getBowerFolder();
var bowerDependencies = fs.readdirSync(folder, {encoding: 'utf8'});
var dependencyInfos = [];
bowerDependencies.forEach(function(dirname) {
var filepath = nodePath.resolve(cwd, folder, dirname, '.bower.json');
if (fs.... | [
"function",
"getAllDependencies",
"(",
")",
"{",
"var",
"folder",
"=",
"'./'",
"+",
"getBowerFolder",
"(",
")",
";",
"var",
"bowerDependencies",
"=",
"fs",
".",
"readdirSync",
"(",
"folder",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
")",
";",
"var",
"dep... | Function to return the metadata for all the dependencies loaded within the `bower_components` directory
@returns {Object} Returns dependency object for each dependency containing (dirName, commit, release, src, etc.) | [
"Function",
"to",
"return",
"the",
"metadata",
"for",
"all",
"the",
"dependencies",
"loaded",
"within",
"the",
"bower_components",
"directory"
] | 9da98159684015ca872b4c35a1a72eb17ee93b37 | https://github.com/infusionsoft/bower-locker/blob/9da98159684015ca872b4c35a1a72eb17ee93b37/bower-locker-common.js#L63-L78 | train |
cavinsmith/bdsm.js | src/bdsm.js | optimizeHistogram | function optimizeHistogram(histogram, options) {
options = _.defaults(options || {}, {
colorDistanceThreshold: 22
});
for (var i = 0; i < histogram.length - 1; i++) {
if (histogram[i].count === 0) {
continue;
}
for (var j = i + 1; j < histogram.length; j++) {
var distance = getColorD... | javascript | function optimizeHistogram(histogram, options) {
options = _.defaults(options || {}, {
colorDistanceThreshold: 22
});
for (var i = 0; i < histogram.length - 1; i++) {
if (histogram[i].count === 0) {
continue;
}
for (var j = i + 1; j < histogram.length; j++) {
var distance = getColorD... | [
"function",
"optimizeHistogram",
"(",
"histogram",
",",
"options",
")",
"{",
"options",
"=",
"_",
".",
"defaults",
"(",
"options",
"||",
"{",
"}",
",",
"{",
"colorDistanceThreshold",
":",
"22",
"}",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i... | Merges groups with colors that are close enough into single group. | [
"Merges",
"groups",
"with",
"colors",
"that",
"are",
"close",
"enough",
"into",
"single",
"group",
"."
] | 3707073d9d382e4c4eca30243ec3d94ce632b39d | https://github.com/cavinsmith/bdsm.js/blob/3707073d9d382e4c4eca30243ec3d94ce632b39d/src/bdsm.js#L68-L93 | train |
ben-yip/grunt-html-imports | tasks/html_imports.js | function (filepath) {
// console.log('processing: ' + filepath);
// read file source, saved in RAM
var content = grunt.file.read(filepath);
/*
* Reset pattern's last search index to 0
* at the beginning for each file content.
*
... | javascript | function (filepath) {
// console.log('processing: ' + filepath);
// read file source, saved in RAM
var content = grunt.file.read(filepath);
/*
* Reset pattern's last search index to 0
* at the beginning for each file content.
*
... | [
"function",
"(",
"filepath",
")",
"{",
"// console.log('processing: ' + filepath);",
"// read file source, saved in RAM",
"var",
"content",
"=",
"grunt",
".",
"file",
".",
"read",
"(",
"filepath",
")",
";",
"/*\n * Reset pattern's last search index to 0\n ... | Search and replace import-link tag with its file content recursively
until no more import-link detected in the source file.
@param filepath
@returns {*} | [
"Search",
"and",
"replace",
"import",
"-",
"link",
"tag",
"with",
"its",
"file",
"content",
"recursively",
"until",
"no",
"more",
"import",
"-",
"link",
"detected",
"in",
"the",
"source",
"file",
"."
] | 9dd6815f3b4dc511c017463c84ecd10cacec7931 | https://github.com/ben-yip/grunt-html-imports/blob/9dd6815f3b4dc511c017463c84ecd10cacec7931/tasks/html_imports.js#L59-L132 | train | |
wanderview/node-netbios-name-service | lib/unpack.js | unpackQuestion | function unpackQuestion(buf, offset) {
var bytes = 0;
var question = {};
// - variable length compressed question name
var nbname = NBName.fromBuffer(buf, offset + bytes);
if (nbname.error) {
return {error: nbname.error};
}
question.nbname = nbname;
bytes += nbname.bytesRead;
// Ensure we have... | javascript | function unpackQuestion(buf, offset) {
var bytes = 0;
var question = {};
// - variable length compressed question name
var nbname = NBName.fromBuffer(buf, offset + bytes);
if (nbname.error) {
return {error: nbname.error};
}
question.nbname = nbname;
bytes += nbname.bytesRead;
// Ensure we have... | [
"function",
"unpackQuestion",
"(",
"buf",
",",
"offset",
")",
"{",
"var",
"bytes",
"=",
"0",
";",
"var",
"question",
"=",
"{",
"}",
";",
"// - variable length compressed question name",
"var",
"nbname",
"=",
"NBName",
".",
"fromBuffer",
"(",
"buf",
",",
"of... | Parse question section - variable length compressed question name - 16-bit question type - 16-bit question class | [
"Parse",
"question",
"section",
"-",
"variable",
"length",
"compressed",
"question",
"name",
"-",
"16",
"-",
"bit",
"question",
"type",
"-",
"16",
"-",
"bit",
"question",
"class"
] | 90cd3c36b5625123ec435577bad1d054de420961 | https://github.com/wanderview/node-netbios-name-service/blob/90cd3c36b5625123ec435577bad1d054de420961/lib/unpack.js#L145-L192 | train |
dutchenkoOleg/node-w3c-validator | bin/cmd.js | detectUserOptions | function detectUserOptions () {
let outputPath = program.output;
let userOptions = {
output: false
};
cliProps.forEach(prop => {
let value = program[prop];
if ((prop === 'stream' || prop === 'langdetect') && value) {
return;
}
if (value !== undefined) {
userOptions[prop] = value;
}
});
if (typ... | javascript | function detectUserOptions () {
let outputPath = program.output;
let userOptions = {
output: false
};
cliProps.forEach(prop => {
let value = program[prop];
if ((prop === 'stream' || prop === 'langdetect') && value) {
return;
}
if (value !== undefined) {
userOptions[prop] = value;
}
});
if (typ... | [
"function",
"detectUserOptions",
"(",
")",
"{",
"let",
"outputPath",
"=",
"program",
".",
"output",
";",
"let",
"userOptions",
"=",
"{",
"output",
":",
"false",
"}",
";",
"cliProps",
".",
"forEach",
"(",
"prop",
"=>",
"{",
"let",
"value",
"=",
"program",... | Detect user's specified properties
@returns {Object}
@private
@sourceCode | [
"Detect",
"user",
"s",
"specified",
"properties"
] | 79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e | https://github.com/dutchenkoOleg/node-w3c-validator/blob/79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e/bin/cmd.js#L59-L79 | train |
dutchenkoOleg/node-w3c-validator | bin/cmd.js | detectUserInput | function detectUserInput () {
let validatePath = program.input;
if (typeof validatePath !== 'string') {
validatePath = process.cwd();
} else {
if (!(/^(http(s)?:)?\/\//i.test(validatePath))) {
if (/^\//.test(validatePath)) {
validatePath = path.resolve(validatePath);
}
}
}
return validatePath;
} | javascript | function detectUserInput () {
let validatePath = program.input;
if (typeof validatePath !== 'string') {
validatePath = process.cwd();
} else {
if (!(/^(http(s)?:)?\/\//i.test(validatePath))) {
if (/^\//.test(validatePath)) {
validatePath = path.resolve(validatePath);
}
}
}
return validatePath;
} | [
"function",
"detectUserInput",
"(",
")",
"{",
"let",
"validatePath",
"=",
"program",
".",
"input",
";",
"if",
"(",
"typeof",
"validatePath",
"!==",
"'string'",
")",
"{",
"validatePath",
"=",
"process",
".",
"cwd",
"(",
")",
";",
"}",
"else",
"{",
"if",
... | Detect input path where testing files lies
@returns {*} | [
"Detect",
"input",
"path",
"where",
"testing",
"files",
"lies"
] | 79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e | https://github.com/dutchenkoOleg/node-w3c-validator/blob/79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e/bin/cmd.js#L85-L98 | train |
dutchenkoOleg/node-w3c-validator | lib/validator.js | getOptions | function getOptions (userOptions = {}) {
let options = _.cloneDeep(userOptions);
if (options.format === 'html') {
options.outputAsHtml = true;
options.verbose = true;
options.format = 'json';
}
return options;
} | javascript | function getOptions (userOptions = {}) {
let options = _.cloneDeep(userOptions);
if (options.format === 'html') {
options.outputAsHtml = true;
options.verbose = true;
options.format = 'json';
}
return options;
} | [
"function",
"getOptions",
"(",
"userOptions",
"=",
"{",
"}",
")",
"{",
"let",
"options",
"=",
"_",
".",
"cloneDeep",
"(",
"userOptions",
")",
";",
"if",
"(",
"options",
".",
"format",
"===",
"'html'",
")",
"{",
"options",
".",
"outputAsHtml",
"=",
"tru... | Get run options from user settled options
@param {Object} [userOptions={}]
@returns {Object}
@private
@sourceCode | [
"Get",
"run",
"options",
"from",
"user",
"settled",
"options"
] | 79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e | https://github.com/dutchenkoOleg/node-w3c-validator/blob/79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e/lib/validator.js#L83-L93 | train |
dutchenkoOleg/node-w3c-validator | lib/validator.js | getArgvFromObject | function getArgvFromObject (options) {
let argv = [];
let format = options.format;
if (formatList.get(format)) {
argv.push(`--format ${format}`);
}
if (options.asciiquotes) {
argv.push('--asciiquotes yes');
}
if (options.stream === false) {
argv.push('--no-stream');
}
if (options.langdetect === false... | javascript | function getArgvFromObject (options) {
let argv = [];
let format = options.format;
if (formatList.get(format)) {
argv.push(`--format ${format}`);
}
if (options.asciiquotes) {
argv.push('--asciiquotes yes');
}
if (options.stream === false) {
argv.push('--no-stream');
}
if (options.langdetect === false... | [
"function",
"getArgvFromObject",
"(",
"options",
")",
"{",
"let",
"argv",
"=",
"[",
"]",
";",
"let",
"format",
"=",
"options",
".",
"format",
";",
"if",
"(",
"formatList",
".",
"get",
"(",
"format",
")",
")",
"{",
"argv",
".",
"push",
"(",
"`",
"${... | Get arguments from given object
@param {Object} options
@returns {Array}
@private
@sourceCode | [
"Get",
"arguments",
"from",
"given",
"object"
] | 79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e | https://github.com/dutchenkoOleg/node-w3c-validator/blob/79bc6ee63bdfad0208c6c6d8dcd5e25a629b006e/lib/validator.js#L102-L137 | train |
flitbit/fpipe | examples/example.js | doSomethingUninteresting | function doSomethingUninteresting(data) {
// simulate latency
var wait = randomWait(1000);
return Promise.delay(wait).then(
() => `It took me ${wait} milliseconds to notice you gave me ${data}.`
);
} | javascript | function doSomethingUninteresting(data) {
// simulate latency
var wait = randomWait(1000);
return Promise.delay(wait).then(
() => `It took me ${wait} milliseconds to notice you gave me ${data}.`
);
} | [
"function",
"doSomethingUninteresting",
"(",
"data",
")",
"{",
"// simulate latency",
"var",
"wait",
"=",
"randomWait",
"(",
"1000",
")",
";",
"return",
"Promise",
".",
"delay",
"(",
"wait",
")",
".",
"then",
"(",
"(",
")",
"=>",
"`",
"${",
"wait",
"}",
... | Waits a random period of time before returning a dumb message to the callback given. | [
"Waits",
"a",
"random",
"period",
"of",
"time",
"before",
"returning",
"a",
"dumb",
"message",
"to",
"the",
"callback",
"given",
"."
] | 39509c0f4e2c46e62c48a94e15b8ba8ed05c7d77 | https://github.com/flitbit/fpipe/blob/39509c0f4e2c46e62c48a94e15b8ba8ed05c7d77/examples/example.js#L12-L18 | train |
andreypopp/rrouter | src/data.js | fetchProps | function fetchProps(props, match) {
var newProps = {};
var deferreds = {};
var promises = {};
var tasks = {};
var name;
for (name in props) {
var m = isPromisePropRe.exec(name);
if (m) {
var promiseName = m[1];
var deferred = Promise.defer();
tasks[promiseName] = makeTask(props[... | javascript | function fetchProps(props, match) {
var newProps = {};
var deferreds = {};
var promises = {};
var tasks = {};
var name;
for (name in props) {
var m = isPromisePropRe.exec(name);
if (m) {
var promiseName = m[1];
var deferred = Promise.defer();
tasks[promiseName] = makeTask(props[... | [
"function",
"fetchProps",
"(",
"props",
",",
"match",
")",
"{",
"var",
"newProps",
"=",
"{",
"}",
";",
"var",
"deferreds",
"=",
"{",
"}",
";",
"var",
"promises",
"=",
"{",
"}",
";",
"var",
"tasks",
"=",
"{",
"}",
";",
"var",
"name",
";",
"for",
... | Fetch all promises defined in props
@param {Object} props
@returns {Promise<Object>} | [
"Fetch",
"all",
"promises",
"defined",
"in",
"props"
] | 4287dc666254af61f1d169c12fb61a1bfd7e2623 | https://github.com/andreypopp/rrouter/blob/4287dc666254af61f1d169c12fb61a1bfd7e2623/src/data.js#L48-L94 | train |
Jam3/gl-pixel-stream | demo.js | renderScene | function renderScene () {
gl.clearColor(0, 0, 0, 1)
gl.clear(gl.COLOR_BUFFER_BIT)
gl.viewport(0, 0, shape[0], shape[1])
shader.bind()
shader.uniforms.iResolution = shape
shader.uniforms.iGlobalTime = 0
triangle(gl)
} | javascript | function renderScene () {
gl.clearColor(0, 0, 0, 1)
gl.clear(gl.COLOR_BUFFER_BIT)
gl.viewport(0, 0, shape[0], shape[1])
shader.bind()
shader.uniforms.iResolution = shape
shader.uniforms.iGlobalTime = 0
triangle(gl)
} | [
"function",
"renderScene",
"(",
")",
"{",
"gl",
".",
"clearColor",
"(",
"0",
",",
"0",
",",
"0",
",",
"1",
")",
"gl",
".",
"clear",
"(",
"gl",
".",
"COLOR_BUFFER_BIT",
")",
"gl",
".",
"viewport",
"(",
"0",
",",
"0",
",",
"shape",
"[",
"0",
"]",... | can be any type of render function | [
"can",
"be",
"any",
"type",
"of",
"render",
"function"
] | 7da1fc9da0b5895d5c5a54d5208193e3cf1ab237 | https://github.com/Jam3/gl-pixel-stream/blob/7da1fc9da0b5895d5c5a54d5208193e3cf1ab237/demo.js#L59-L67 | train |
wyicwx/bone | lib/fs.js | FileSystem | function FileSystem(base, options) {
options || (options = {});
this.base = this.pathResolve(base);
if(options.captureFile) {
this._readFiles = [];
}
if(options.globalAct) {
this.globalAct = options.globalAct;
}
} | javascript | function FileSystem(base, options) {
options || (options = {});
this.base = this.pathResolve(base);
if(options.captureFile) {
this._readFiles = [];
}
if(options.globalAct) {
this.globalAct = options.globalAct;
}
} | [
"function",
"FileSystem",
"(",
"base",
",",
"options",
")",
"{",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"this",
".",
"base",
"=",
"this",
".",
"pathResolve",
"(",
"base",
")",
";",
"if",
"(",
"options",
".",
"captureFile",
")",
"... | file path src | [
"file",
"path",
"src"
] | eb6c12080f6da8c5a20767d567bf80a49a099430 | https://github.com/wyicwx/bone/blob/eb6c12080f6da8c5a20767d567bf80a49a099430/lib/fs.js#L12-L21 | train |
jdeal/doctor | view/default/jquery-ui/development-bundle/ui/jquery-ui-1.8.16.custom.js | function(pos) {
var topOffset = $(this).css(pos).offset().top;
if (topOffset < 0) {
$(this).css('top', pos.top - topOffset);
}
} | javascript | function(pos) {
var topOffset = $(this).css(pos).offset().top;
if (topOffset < 0) {
$(this).css('top', pos.top - topOffset);
}
} | [
"function",
"(",
"pos",
")",
"{",
"var",
"topOffset",
"=",
"$",
"(",
"this",
")",
".",
"css",
"(",
"pos",
")",
".",
"offset",
"(",
")",
".",
"top",
";",
"if",
"(",
"topOffset",
"<",
"0",
")",
"{",
"$",
"(",
"this",
")",
".",
"css",
"(",
"'t... | ensure that the titlebar is never outside the document | [
"ensure",
"that",
"the",
"titlebar",
"is",
"never",
"outside",
"the",
"document"
] | e1516f9cac6a899dbf3c624026deac3061f4ec63 | https://github.com/jdeal/doctor/blob/e1516f9cac6a899dbf3c624026deac3061f4ec63/view/default/jquery-ui/development-bundle/ui/jquery-ui-1.8.16.custom.js#L6015-L6020 | train | |
jdeal/doctor | view/default/jquery-ui/development-bundle/ui/jquery-ui-1.8.16.custom.js | function(force, event) {
var self = this,
options = self.options,
saveScroll;
if ((options.modal && !force) ||
(!options.stack && !options.modal)) {
return self._trigger('focus', event);
}
if (options.zIndex > $.ui.dialog.maxZ) {
$.ui.dialog.maxZ = options.zIndex;
}
if (self.overlay) {
$... | javascript | function(force, event) {
var self = this,
options = self.options,
saveScroll;
if ((options.modal && !force) ||
(!options.stack && !options.modal)) {
return self._trigger('focus', event);
}
if (options.zIndex > $.ui.dialog.maxZ) {
$.ui.dialog.maxZ = options.zIndex;
}
if (self.overlay) {
$... | [
"function",
"(",
"force",
",",
"event",
")",
"{",
"var",
"self",
"=",
"this",
",",
"options",
"=",
"self",
".",
"options",
",",
"saveScroll",
";",
"if",
"(",
"(",
"options",
".",
"modal",
"&&",
"!",
"force",
")",
"||",
"(",
"!",
"options",
".",
"... | the force parameter allows us to move modal dialogs to their correct position on open | [
"the",
"force",
"parameter",
"allows",
"us",
"to",
"move",
"modal",
"dialogs",
"to",
"their",
"correct",
"position",
"on",
"open"
] | e1516f9cac6a899dbf3c624026deac3061f4ec63 | https://github.com/jdeal/doctor/blob/e1516f9cac6a899dbf3c624026deac3061f4ec63/view/default/jquery-ui/development-bundle/ui/jquery-ui-1.8.16.custom.js#L6230-L6257 | train | |
jdeal/doctor | view/default/jquery-ui/development-bundle/ui/jquery-ui-1.8.16.custom.js | function(match, value, len) {
var num = '' + value;
if (lookAhead(match))
while (num.length < len)
num = '0' + num;
return num;
} | javascript | function(match, value, len) {
var num = '' + value;
if (lookAhead(match))
while (num.length < len)
num = '0' + num;
return num;
} | [
"function",
"(",
"match",
",",
"value",
",",
"len",
")",
"{",
"var",
"num",
"=",
"''",
"+",
"value",
";",
"if",
"(",
"lookAhead",
"(",
"match",
")",
")",
"while",
"(",
"num",
".",
"length",
"<",
"len",
")",
"num",
"=",
"'0'",
"+",
"num",
";",
... | Format a number, with leading zero if necessary | [
"Format",
"a",
"number",
"with",
"leading",
"zero",
"if",
"necessary"
] | e1516f9cac6a899dbf3c624026deac3061f4ec63 | https://github.com/jdeal/doctor/blob/e1516f9cac6a899dbf3c624026deac3061f4ec63/view/default/jquery-ui/development-bundle/ui/jquery-ui-1.8.16.custom.js#L9423-L9429 | train | |
ivee-tech/three-asciieffect | index.js | asciifyImage | function asciifyImage( canvasRenderer, oAscii ) {
oCtx.clearRect( 0, 0, iWidth, iHeight );
oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );
var oImgData = oCtx.getImageData( 0, 0, iWidth, iHeight ).data;
// Coloring loop starts now
var strChars = "";
// console.time('rendering');
for ( var y = 0; ... | javascript | function asciifyImage( canvasRenderer, oAscii ) {
oCtx.clearRect( 0, 0, iWidth, iHeight );
oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );
var oImgData = oCtx.getImageData( 0, 0, iWidth, iHeight ).data;
// Coloring loop starts now
var strChars = "";
// console.time('rendering');
for ( var y = 0; ... | [
"function",
"asciifyImage",
"(",
"canvasRenderer",
",",
"oAscii",
")",
"{",
"oCtx",
".",
"clearRect",
"(",
"0",
",",
"0",
",",
"iWidth",
",",
"iHeight",
")",
";",
"oCtx",
".",
"drawImage",
"(",
"oCanvasImg",
",",
"0",
",",
"0",
",",
"iWidth",
",",
"i... | can't get a span or div to flow like an img element, but a table works? convert img element to ascii | [
"can",
"t",
"get",
"a",
"span",
"or",
"div",
"to",
"flow",
"like",
"an",
"img",
"element",
"but",
"a",
"table",
"works?",
"convert",
"img",
"element",
"to",
"ascii"
] | 19194b28547c40a4901bfc0494047cdcc40e02cf | https://github.com/ivee-tech/three-asciieffect/blob/19194b28547c40a4901bfc0494047cdcc40e02cf/index.js#L205-L283 | train |
sergiolepore/hexo-broken-link-checker | lib/core/brokenLinkChecker.js | BrokenLinkChecker | function BrokenLinkChecker(options) {
this.runningScope = options.scope || BrokenLinkChecker.RUNNING_SCOPE_COMMAND;
this.pluginConfig = {};
this.pluginConfig.enabled = (typeof userConfig.enabled !== 'undefined')? userConfig.enabled : true;
this.pluginConfig.storageDir = userConfig.storage_dir || 'temp/link_chec... | javascript | function BrokenLinkChecker(options) {
this.runningScope = options.scope || BrokenLinkChecker.RUNNING_SCOPE_COMMAND;
this.pluginConfig = {};
this.pluginConfig.enabled = (typeof userConfig.enabled !== 'undefined')? userConfig.enabled : true;
this.pluginConfig.storageDir = userConfig.storage_dir || 'temp/link_chec... | [
"function",
"BrokenLinkChecker",
"(",
"options",
")",
"{",
"this",
".",
"runningScope",
"=",
"options",
".",
"scope",
"||",
"BrokenLinkChecker",
".",
"RUNNING_SCOPE_COMMAND",
";",
"this",
".",
"pluginConfig",
"=",
"{",
"}",
";",
"this",
".",
"pluginConfig",
".... | BrokenLinkChecker constructor.
Options:
- `scope`: BrokenLinkChecker.RUNNING_SCOPE_*
- `silentLogs`: output all log info to a file, instead
using the stdout.
@class BrokenLinkChecker
@constructor
@param {Object} options | [
"BrokenLinkChecker",
"constructor",
"."
] | b2da55b87a77609b3e07e34666c32971a523b88d | https://github.com/sergiolepore/hexo-broken-link-checker/blob/b2da55b87a77609b3e07e34666c32971a523b88d/lib/core/brokenLinkChecker.js#L33-L80 | train |
emalherbi/grunt-php-shield | tasks/php_shield.js | function(src, dest) {
if (grunt.file.isDir(src)) {
grunt.file.mkdir(dest);
if (options.log) {
Utils.writeln(chalk.gray.bold(' create dir => ' + dest));
}
return true;
}
return false;
} | javascript | function(src, dest) {
if (grunt.file.isDir(src)) {
grunt.file.mkdir(dest);
if (options.log) {
Utils.writeln(chalk.gray.bold(' create dir => ' + dest));
}
return true;
}
return false;
} | [
"function",
"(",
"src",
",",
"dest",
")",
"{",
"if",
"(",
"grunt",
".",
"file",
".",
"isDir",
"(",
"src",
")",
")",
"{",
"grunt",
".",
"file",
".",
"mkdir",
"(",
"dest",
")",
";",
"if",
"(",
"options",
".",
"log",
")",
"{",
"Utils",
".",
"wri... | create a dir | [
"create",
"a",
"dir"
] | 40eec9f08cd6c88ec93cef3b6cacf977f5b1b1ca | https://github.com/emalherbi/grunt-php-shield/blob/40eec9f08cd6c88ec93cef3b6cacf977f5b1b1ca/tasks/php_shield.js#L46-L55 | train | |
postmanlabs/generic-bitmask | lib/descriptor.js | function (names) {
this.names = Object.keys(names); // store the keys
this.hash = util.map(names, function (value) { // store values for corresponding keys
return parseInt(value, 10);
});
} | javascript | function (names) {
this.names = Object.keys(names); // store the keys
this.hash = util.map(names, function (value) { // store values for corresponding keys
return parseInt(value, 10);
});
} | [
"function",
"(",
"names",
")",
"{",
"this",
".",
"names",
"=",
"Object",
".",
"keys",
"(",
"names",
")",
";",
"// store the keys",
"this",
".",
"hash",
"=",
"util",
".",
"map",
"(",
"names",
",",
"function",
"(",
"value",
")",
"{",
"// store values for... | Set the named bits for the descriptors.
@param {object<number>} values | [
"Set",
"the",
"named",
"bits",
"for",
"the",
"descriptors",
"."
] | 9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d | https://github.com/postmanlabs/generic-bitmask/blob/9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d/lib/descriptor.js#L23-L28 | train | |
postmanlabs/generic-bitmask | lib/descriptor.js | function (name, lazy) {
return Array.isArray(name) ? (name.length ? name.every(function (name) {
return this.defined(name, lazy);
}, this) : !!lazy) : (name ? !!this.hash[name] : !!lazy);
} | javascript | function (name, lazy) {
return Array.isArray(name) ? (name.length ? name.every(function (name) {
return this.defined(name, lazy);
}, this) : !!lazy) : (name ? !!this.hash[name] : !!lazy);
} | [
"function",
"(",
"name",
",",
"lazy",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"name",
")",
"?",
"(",
"name",
".",
"length",
"?",
"name",
".",
"every",
"(",
"function",
"(",
"name",
")",
"{",
"return",
"this",
".",
"defined",
"(",
"name",
... | Verifies whether the specified named bits are defined in the descriptor
@param {Array<string>|string} name
@param {boolean=} [lazy=false] - if set to true, this function will return true for empty names or array
@return {boolean} | [
"Verifies",
"whether",
"the",
"specified",
"named",
"bits",
"are",
"defined",
"in",
"the",
"descriptor"
] | 9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d | https://github.com/postmanlabs/generic-bitmask/blob/9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d/lib/descriptor.js#L36-L40 | train | |
postmanlabs/generic-bitmask | lib/descriptor.js | function (name) {
return Array.isArray(name) ? (name.map(this.valueOf.bind(this))) : this.hash[name];
} | javascript | function (name) {
return Array.isArray(name) ? (name.map(this.valueOf.bind(this))) : this.hash[name];
} | [
"function",
"(",
"name",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"name",
")",
"?",
"(",
"name",
".",
"map",
"(",
"this",
".",
"valueOf",
".",
"bind",
"(",
"this",
")",
")",
")",
":",
"this",
".",
"hash",
"[",
"name",
"]",
";",
"}"
] | Returns the value of a descriptor name
@param {Array<string>|string} name
@returns {number} | [
"Returns",
"the",
"value",
"of",
"a",
"descriptor",
"name"
] | 9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d | https://github.com/postmanlabs/generic-bitmask/blob/9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d/lib/descriptor.js#L48-L50 | train | |
wyicwx/bone | lib/utils.js | function(file) {
var FileSystem = require('./fs.js');
var ReadStream = require('./read_stream.js');
if(FileSystem.fs.existFile(file)) {
file = FileSystem.fs.pathResolve(file);
var readStream = new ReadStream(file);
return _.clone(readStream.trackStack);
... | javascript | function(file) {
var FileSystem = require('./fs.js');
var ReadStream = require('./read_stream.js');
if(FileSystem.fs.existFile(file)) {
file = FileSystem.fs.pathResolve(file);
var readStream = new ReadStream(file);
return _.clone(readStream.trackStack);
... | [
"function",
"(",
"file",
")",
"{",
"var",
"FileSystem",
"=",
"require",
"(",
"'./fs.js'",
")",
";",
"var",
"ReadStream",
"=",
"require",
"(",
"'./read_stream.js'",
")",
";",
"if",
"(",
"FileSystem",
".",
"fs",
".",
"existFile",
"(",
"file",
")",
")",
"... | track file stack | [
"track",
"file",
"stack"
] | eb6c12080f6da8c5a20767d567bf80a49a099430 | https://github.com/wyicwx/bone/blob/eb6c12080f6da8c5a20767d567bf80a49a099430/lib/utils.js#L12-L24 | train | |
simonepri/osm-countries | index.js | get | function get(code) {
if (!Object.prototype.hasOwnProperty.call(osm, code)) {
throw new TypeError('The alpha-3 code provided was not found: ' + code);
}
return osm[code];
} | javascript | function get(code) {
if (!Object.prototype.hasOwnProperty.call(osm, code)) {
throw new TypeError('The alpha-3 code provided was not found: ' + code);
}
return osm[code];
} | [
"function",
"get",
"(",
"code",
")",
"{",
"if",
"(",
"!",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"osm",
",",
"code",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'The alpha-3 code provided was not found: '",
"+",
"code",
... | Converts an alpha-3 iso 3166-1 code to its corrispective relation id on OSM.
@public
@param {string} code Alpha-3 iso 3166-1 country code.
@return {string} OSM relation id of the given country. | [
"Converts",
"an",
"alpha",
"-",
"3",
"iso",
"3166",
"-",
"1",
"code",
"to",
"its",
"corrispective",
"relation",
"id",
"on",
"OSM",
"."
] | 60aa88eb5fd7199f26ac7c5410cbae0936378ebb | https://github.com/simonepri/osm-countries/blob/60aa88eb5fd7199f26ac7c5410cbae0936378ebb/index.js#L11-L16 | train |
clubedaentrega/validate-fields | types/numeric.js | registerDual | function registerDual(numberType, numericType, checkFn, toJSONSchema) {
context.registerType(numberType, 'number', checkFn, numberType, extra => toJSONSchema('number', extra))
context.registerType(numericType, 'string', value => {
let numberValue = toNumber(value)
checkFn(numberValue)
return numberValue
... | javascript | function registerDual(numberType, numericType, checkFn, toJSONSchema) {
context.registerType(numberType, 'number', checkFn, numberType, extra => toJSONSchema('number', extra))
context.registerType(numericType, 'string', value => {
let numberValue = toNumber(value)
checkFn(numberValue)
return numberValue
... | [
"function",
"registerDual",
"(",
"numberType",
",",
"numericType",
",",
"checkFn",
",",
"toJSONSchema",
")",
"{",
"context",
".",
"registerType",
"(",
"numberType",
",",
"'number'",
",",
"checkFn",
",",
"numberType",
",",
"extra",
"=>",
"toJSONSchema",
"(",
"'... | Register number and numeric dual basic types
@param {string} numberType
@param {string} numericType
@param {Function} checkFn
@param {function(string, *):Object} toJSONSchema
@private | [
"Register",
"number",
"and",
"numeric",
"dual",
"basic",
"types"
] | 7213b20c082ddabe4cbe926100d72fc44da69327 | https://github.com/clubedaentrega/validate-fields/blob/7213b20c082ddabe4cbe926100d72fc44da69327/types/numeric.js#L139-L150 | train |
clubedaentrega/validate-fields | types/numeric.js | registerTaggedDual | function registerTaggedDual(numberTag, numericTag, checkFn, toJSONSchema) {
context.registerTaggedType({
tag: numberTag,
jsonType: 'number',
minArgs: 2,
maxArgs: 2,
sparse: true,
numeric: true
}, checkFn, returnOriginal, toJSONSchema)
context.registerTaggedType({
tag: numericTag,
jsonType... | javascript | function registerTaggedDual(numberTag, numericTag, checkFn, toJSONSchema) {
context.registerTaggedType({
tag: numberTag,
jsonType: 'number',
minArgs: 2,
maxArgs: 2,
sparse: true,
numeric: true
}, checkFn, returnOriginal, toJSONSchema)
context.registerTaggedType({
tag: numericTag,
jsonType... | [
"function",
"registerTaggedDual",
"(",
"numberTag",
",",
"numericTag",
",",
"checkFn",
",",
"toJSONSchema",
")",
"{",
"context",
".",
"registerTaggedType",
"(",
"{",
"tag",
":",
"numberTag",
",",
"jsonType",
":",
"'number'",
",",
"minArgs",
":",
"2",
",",
"m... | Register number and numeric dual tagged types
@param {string} numberTag
@param {string} numericTag
@param {Function} checkFn
@param {function(*):Object} toJSONSchema
@private | [
"Register",
"number",
"and",
"numeric",
"dual",
"tagged",
"types"
] | 7213b20c082ddabe4cbe926100d72fc44da69327 | https://github.com/clubedaentrega/validate-fields/blob/7213b20c082ddabe4cbe926100d72fc44da69327/types/numeric.js#L160-L185 | train |
gamtiq/eva | src/eva.js | createFunction | function createFunction(sCode, settings) {
/*jshint evil:true, laxbreak:true, quotmark:false*/
var nI, params, sName;
if (! settings) {
settings = {};
}
params = settings.paramNames;
if (settings.expression) {
sCode = "return (" + sCode + ");";
}
if (settings.scope) {
... | javascript | function createFunction(sCode, settings) {
/*jshint evil:true, laxbreak:true, quotmark:false*/
var nI, params, sName;
if (! settings) {
settings = {};
}
params = settings.paramNames;
if (settings.expression) {
sCode = "return (" + sCode + ");";
}
if (settings.scope) {
... | [
"function",
"createFunction",
"(",
"sCode",
",",
"settings",
")",
"{",
"/*jshint evil:true, laxbreak:true, quotmark:false*/",
"var",
"nI",
",",
"params",
",",
"sName",
";",
"if",
"(",
"!",
"settings",
")",
"{",
"settings",
"=",
"{",
"}",
";",
"}",
"params",
... | Create function to further use.
@param {String} sCode
Function's code.
@param {Object} [settings]
Operation settings. Keys are settings names, values are corresponding settings values.
The following settings are supported (setting's default value is specified in parentheses):
* `debug`: `Boolean` (`false`) - specifie... | [
"Create",
"function",
"to",
"further",
"use",
"."
] | ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5 | https://github.com/gamtiq/eva/blob/ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5/src/eva.js#L47-L85 | train |
gamtiq/eva | src/eva.js | createDelegateMethod | function createDelegateMethod(delegate, sMethod, settings) {
var result = function() {
return delegate[sMethod].apply(delegate, arguments);
};
if (settings && settings.destination) {
settings.destination[settings.destinationMethod || sMethod] = result;
}
return result;
} | javascript | function createDelegateMethod(delegate, sMethod, settings) {
var result = function() {
return delegate[sMethod].apply(delegate, arguments);
};
if (settings && settings.destination) {
settings.destination[settings.destinationMethod || sMethod] = result;
}
return result;
} | [
"function",
"createDelegateMethod",
"(",
"delegate",
",",
"sMethod",
",",
"settings",
")",
"{",
"var",
"result",
"=",
"function",
"(",
")",
"{",
"return",
"delegate",
"[",
"sMethod",
"]",
".",
"apply",
"(",
"delegate",
",",
"arguments",
")",
";",
"}",
";... | Create function that executes specified method of the given object.
@param {Object} delegate
Object whose method will be executed when created function is called.
@param {String} sMethod
Name of method that will be executed.
@param {Object} [settings]
Operation settings. Keys are settings names, values are correspondi... | [
"Create",
"function",
"that",
"executes",
"specified",
"method",
"of",
"the",
"given",
"object",
"."
] | ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5 | https://github.com/gamtiq/eva/blob/ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5/src/eva.js#L125-L133 | train |
gamtiq/eva | src/eva.js | closure | function closure(action, paramList, context, settings) {
if (! settings) {
settings = {};
}
var bUseArgs = ! settings.ignoreArgs,
bAppendArgs = ! settings.prependArgs;
return function() {
var params;
if (bUseArgs) {
params = paramList ? Array.prototype.sl... | javascript | function closure(action, paramList, context, settings) {
if (! settings) {
settings = {};
}
var bUseArgs = ! settings.ignoreArgs,
bAppendArgs = ! settings.prependArgs;
return function() {
var params;
if (bUseArgs) {
params = paramList ? Array.prototype.sl... | [
"function",
"closure",
"(",
"action",
",",
"paramList",
",",
"context",
",",
"settings",
")",
"{",
"if",
"(",
"!",
"settings",
")",
"{",
"settings",
"=",
"{",
"}",
";",
"}",
"var",
"bUseArgs",
"=",
"!",
"settings",
".",
"ignoreArgs",
",",
"bAppendArgs"... | Create function that executes specified function with given parameters and context and returns result of call.
@param {Function} action
Target function that will be executed when created function is called.
@param {Array} [paramList]
Array-like object representing parameters that should be passed into the target funct... | [
"Create",
"function",
"that",
"executes",
"specified",
"function",
"with",
"given",
"parameters",
"and",
"context",
"and",
"returns",
"result",
"of",
"call",
"."
] | ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5 | https://github.com/gamtiq/eva/blob/ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5/src/eva.js#L160-L183 | train |
gamtiq/eva | src/eva.js | map | function map(funcList, paramList, context, settings) {
/*jshint laxbreak:true*/
var result = [],
nL = funcList.length,
bGetContext, bGetParamList, func, nI;
if (! paramList) {
paramList = [];
}
if (! context) {
context = null;
}
if (! settings) {
setti... | javascript | function map(funcList, paramList, context, settings) {
/*jshint laxbreak:true*/
var result = [],
nL = funcList.length,
bGetContext, bGetParamList, func, nI;
if (! paramList) {
paramList = [];
}
if (! context) {
context = null;
}
if (! settings) {
setti... | [
"function",
"map",
"(",
"funcList",
",",
"paramList",
",",
"context",
",",
"settings",
")",
"{",
"/*jshint laxbreak:true*/",
"var",
"result",
"=",
"[",
"]",
",",
"nL",
"=",
"funcList",
".",
"length",
",",
"bGetContext",
",",
"bGetParamList",
",",
"func",
"... | Call each function from specified list and return array containing results of calls.
@param {Array} funcList
Target functions that should be called.
@param {Array | Function} [paramList]
Parameters that should be passed into each target function.
If function is specified it should return array that will be used as par... | [
"Call",
"each",
"function",
"from",
"specified",
"list",
"and",
"return",
"array",
"containing",
"results",
"of",
"calls",
"."
] | ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5 | https://github.com/gamtiq/eva/blob/ae2987da163d7f0a59e4e551cbcc8d4f4dae4cd5/src/eva.js#L213-L239 | train |
klarstil/lifx-http-api | source/utils.js | function(response, body) {
var responseCodes = [
{ codes: 400, message: 'Request was invalid.' },
{ codes: 401, message: 'Bad access token.' },
{ codes: 403, message: 'Bad OAuth scope.' },
{ codes: 404, message: 'Selector did not match any lights.' },
... | javascript | function(response, body) {
var responseCodes = [
{ codes: 400, message: 'Request was invalid.' },
{ codes: 401, message: 'Bad access token.' },
{ codes: 403, message: 'Bad OAuth scope.' },
{ codes: 404, message: 'Selector did not match any lights.' },
... | [
"function",
"(",
"response",
",",
"body",
")",
"{",
"var",
"responseCodes",
"=",
"[",
"{",
"codes",
":",
"400",
",",
"message",
":",
"'Request was invalid.'",
"}",
",",
"{",
"codes",
":",
"401",
",",
"message",
":",
"'Bad access token.'",
"}",
",",
"{",
... | Checks the HTTP response code and returns the according error message.
See: <http://api.developer.lifx.com/docs/errors>
@param {object} response
@param {string} body
@returns {string} | [
"Checks",
"the",
"HTTP",
"response",
"code",
"and",
"returns",
"the",
"according",
"error",
"message",
"."
] | 90afb556c30ea5d1ac14958a159490f6f579241a | https://github.com/klarstil/lifx-http-api/blob/90afb556c30ea5d1ac14958a159490f6f579241a/source/utils.js#L14-L46 | train | |
klarstil/lifx-http-api | source/utils.js | function(selector) {
var validSelectors = [
'all',
'label:',
'id:',
'group_id:',
'group:',
'location_id:',
'location:',
'scene_id:'
], isValid = false;
if(!selector || !selector.length) {
... | javascript | function(selector) {
var validSelectors = [
'all',
'label:',
'id:',
'group_id:',
'group:',
'location_id:',
'location:',
'scene_id:'
], isValid = false;
if(!selector || !selector.length) {
... | [
"function",
"(",
"selector",
")",
"{",
"var",
"validSelectors",
"=",
"[",
"'all'",
",",
"'label:'",
",",
"'id:'",
",",
"'group_id:'",
",",
"'group:'",
",",
"'location_id:'",
",",
"'location:'",
",",
"'scene_id:'",
"]",
",",
"isValid",
"=",
"false",
";",
"i... | Checks the light selector if it's valid.
See: <http://api.developer.lifx.com/docs/selectors>
@param {string} selector
@returns {boolean} | [
"Checks",
"the",
"light",
"selector",
"if",
"it",
"s",
"valid",
"."
] | 90afb556c30ea5d1ac14958a159490f6f579241a | https://github.com/klarstil/lifx-http-api/blob/90afb556c30ea5d1ac14958a159490f6f579241a/source/utils.js#L56-L83 | train | |
clubedaentrega/validate-fields | index.js | context | function context(schema, value, options) {
schema = context.parse(schema)
let ret = schema.validate(value, options)
context.lastError = schema.lastError
context.lastErrorMessage = schema.lastErrorMessage
context.lastErrorPath = schema.lastErrorPath
return ret
} | javascript | function context(schema, value, options) {
schema = context.parse(schema)
let ret = schema.validate(value, options)
context.lastError = schema.lastError
context.lastErrorMessage = schema.lastErrorMessage
context.lastErrorPath = schema.lastErrorPath
return ret
} | [
"function",
"context",
"(",
"schema",
",",
"value",
",",
"options",
")",
"{",
"schema",
"=",
"context",
".",
"parse",
"(",
"schema",
")",
"let",
"ret",
"=",
"schema",
".",
"validate",
"(",
"value",
",",
"options",
")",
"context",
".",
"lastError",
"=",... | Validate the given value against the given schema
@param {*} schema
@param {*} value The value can be altered by the validation
@param {Object} [options] Validation options
@returns {boolean} whether the value is valid or nor
@throw if the schema is invalid | [
"Validate",
"the",
"given",
"value",
"against",
"the",
"given",
"schema"
] | 7213b20c082ddabe4cbe926100d72fc44da69327 | https://github.com/clubedaentrega/validate-fields/blob/7213b20c082ddabe4cbe926100d72fc44da69327/index.js#L36-L43 | train |
clubedaentrega/validate-fields | index.js | parseTagged | function parseTagged(definition, taggedTypes) {
let match = definition.match(/^(\w+)(?:\((.*)\))?$/),
tag, args, typeInfo
if (!match) {
return
}
// Get type info
tag = match[1]
typeInfo = taggedTypes[tag]
if (!typeInfo) {
return
}
// Special no-'()' case: only match 'tag' if minArgs is zero
if (typeIn... | javascript | function parseTagged(definition, taggedTypes) {
let match = definition.match(/^(\w+)(?:\((.*)\))?$/),
tag, args, typeInfo
if (!match) {
return
}
// Get type info
tag = match[1]
typeInfo = taggedTypes[tag]
if (!typeInfo) {
return
}
// Special no-'()' case: only match 'tag' if minArgs is zero
if (typeIn... | [
"function",
"parseTagged",
"(",
"definition",
",",
"taggedTypes",
")",
"{",
"let",
"match",
"=",
"definition",
".",
"match",
"(",
"/",
"^(\\w+)(?:\\((.*)\\))?$",
"/",
")",
",",
"tag",
",",
"args",
",",
"typeInfo",
"if",
"(",
"!",
"match",
")",
"{",
"retu... | Try to parse a string definition as a tagged type
@private
@param {string} definition
@param {Object<String, Object>} taggedTypes
@returns {?Field} | [
"Try",
"to",
"parse",
"a",
"string",
"definition",
"as",
"a",
"tagged",
"type"
] | 7213b20c082ddabe4cbe926100d72fc44da69327 | https://github.com/clubedaentrega/validate-fields/blob/7213b20c082ddabe4cbe926100d72fc44da69327/index.js#L279-L329 | train |
postmanlabs/generic-bitmask | lib/util.js | function (recipient, donor) {
for (var prop in donor) {
donor.hasOwnProperty(prop) && (recipient[prop] = donor[prop]);
}
return recipient;
} | javascript | function (recipient, donor) {
for (var prop in donor) {
donor.hasOwnProperty(prop) && (recipient[prop] = donor[prop]);
}
return recipient;
} | [
"function",
"(",
"recipient",
",",
"donor",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"donor",
")",
"{",
"donor",
".",
"hasOwnProperty",
"(",
"prop",
")",
"&&",
"(",
"recipient",
"[",
"prop",
"]",
"=",
"donor",
"[",
"prop",
"]",
")",
";",
"}",
"... | Performs shallow copy of one object into another.
@param {object} recipient
@param {object} donor
@returns {object} - returns the seeded recipient parameter | [
"Performs",
"shallow",
"copy",
"of",
"one",
"object",
"into",
"another",
"."
] | 9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d | https://github.com/postmanlabs/generic-bitmask/blob/9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d/lib/util.js#L12-L17 | train | |
postmanlabs/generic-bitmask | lib/util.js | function (obj, mapper, scope) {
var map = {},
prop;
scope = scope || obj;
for (prop in obj) {
obj.hasOwnProperty(prop) && (map[prop] = mapper.call(scope, obj[prop], prop, obj));
}
return map;
} | javascript | function (obj, mapper, scope) {
var map = {},
prop;
scope = scope || obj;
for (prop in obj) {
obj.hasOwnProperty(prop) && (map[prop] = mapper.call(scope, obj[prop], prop, obj));
}
return map;
} | [
"function",
"(",
"obj",
",",
"mapper",
",",
"scope",
")",
"{",
"var",
"map",
"=",
"{",
"}",
",",
"prop",
";",
"scope",
"=",
"scope",
"||",
"obj",
";",
"for",
"(",
"prop",
"in",
"obj",
")",
"{",
"obj",
".",
"hasOwnProperty",
"(",
"prop",
")",
"&... | Creates a new object with mapped values from another object
@param {object} obj
@param {function} mapper
@param {*=} [scope]
@returns {object} | [
"Creates",
"a",
"new",
"object",
"with",
"mapped",
"values",
"from",
"another",
"object"
] | 9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d | https://github.com/postmanlabs/generic-bitmask/blob/9c940f6ef7c2fdef2f8523b1cb562ebcc8b8a50d/lib/util.js#L27-L37 | train | |
frankgerhardt/botkit-matrix | matrixClient.js | verifyDevice | async function verifyDevice (userId, deviceId) {
await exports.matrixClient.setDeviceKnown(userId, deviceId, true);
await exports.matrixClient.setDeviceVerified(userId, deviceId, true);
} | javascript | async function verifyDevice (userId, deviceId) {
await exports.matrixClient.setDeviceKnown(userId, deviceId, true);
await exports.matrixClient.setDeviceVerified(userId, deviceId, true);
} | [
"async",
"function",
"verifyDevice",
"(",
"userId",
",",
"deviceId",
")",
"{",
"await",
"exports",
".",
"matrixClient",
".",
"setDeviceKnown",
"(",
"userId",
",",
"deviceId",
",",
"true",
")",
";",
"await",
"exports",
".",
"matrixClient",
".",
"setDeviceVerifi... | This function calls the functions from matrix-js-sdk to verify
the devices.
Implicitly returns a Promise because it's an async function.
@function verifyDevice
@param userId - The user who's devices has to be verified
@param deviceId - The ID of the device which has to be verified
@returns {Promise<void>} | [
"This",
"function",
"calls",
"the",
"functions",
"from",
"matrix",
"-",
"js",
"-",
"sdk",
"to",
"verify",
"the",
"devices",
".",
"Implicitly",
"returns",
"a",
"Promise",
"because",
"it",
"s",
"an",
"async",
"function",
"."
] | 3d7ae1f0c46af6905f6edbe945d43585b5de4bd1 | https://github.com/frankgerhardt/botkit-matrix/blob/3d7ae1f0c46af6905f6edbe945d43585b5de4bd1/matrixClient.js#L54-L57 | train |
azu/textlint-plugin-asciidoc-loose | src/NodeBuilder.js | fixParagraphNode | function fixParagraphNode(node, fullText) {
const firstNode = node.children[0];
const lastNode = node.children[node.children.length - 1];
node.range = [firstNode.range[0], lastNode.range[1]];
node.raw = fullText.slice(node.range[0], node.range[1]);
node.loc = {
start: {
line: fir... | javascript | function fixParagraphNode(node, fullText) {
const firstNode = node.children[0];
const lastNode = node.children[node.children.length - 1];
node.range = [firstNode.range[0], lastNode.range[1]];
node.raw = fullText.slice(node.range[0], node.range[1]);
node.loc = {
start: {
line: fir... | [
"function",
"fixParagraphNode",
"(",
"node",
",",
"fullText",
")",
"{",
"const",
"firstNode",
"=",
"node",
".",
"children",
"[",
"0",
"]",
";",
"const",
"lastNode",
"=",
"node",
".",
"children",
"[",
"node",
".",
"children",
".",
"length",
"-",
"1",
"]... | fill properties of paragraph node.
@param {TxtNode} node - Paragraph node to modify
@param {string} fullText - Full text of the document | [
"fill",
"properties",
"of",
"paragraph",
"node",
"."
] | 7a69051adbb550bcc874fa25d84ebec07fa481ac | https://github.com/azu/textlint-plugin-asciidoc-loose/blob/7a69051adbb550bcc874fa25d84ebec07fa481ac/src/NodeBuilder.js#L25-L40 | train |
jdeal/doctor | report/default.js | fixSignatureParams | function fixSignatureParams(node, item, signature) {
signature.params = [];
for (var i = 0; i < signature.arity; i++) {
var paramCopy = _.extend({}, item.params[i]);
if (node && node.paramTags) {
if (node.paramTags[paramCopy.name]) {
_.extend(paramCopy, node.paramTags[paramCopy.name]);
}... | javascript | function fixSignatureParams(node, item, signature) {
signature.params = [];
for (var i = 0; i < signature.arity; i++) {
var paramCopy = _.extend({}, item.params[i]);
if (node && node.paramTags) {
if (node.paramTags[paramCopy.name]) {
_.extend(paramCopy, node.paramTags[paramCopy.name]);
}... | [
"function",
"fixSignatureParams",
"(",
"node",
",",
"item",
",",
"signature",
")",
"{",
"signature",
".",
"params",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"signature",
".",
"arity",
";",
"i",
"++",
")",
"{",
"var",
"... | make a set of params to match the signature | [
"make",
"a",
"set",
"of",
"params",
"to",
"match",
"the",
"signature"
] | e1516f9cac6a899dbf3c624026deac3061f4ec63 | https://github.com/jdeal/doctor/blob/e1516f9cac6a899dbf3c624026deac3061f4ec63/report/default.js#L7-L18 | train |
enmasseio/distribus | lib/Host.js | closeHost | function closeHost() {
// close the host itself
me.addresses = {};
if (me.server) {
me.server.close();
me.server = null;
me.address = null;
me.port = null;
me.url = null;
}
return me;
} | javascript | function closeHost() {
// close the host itself
me.addresses = {};
if (me.server) {
me.server.close();
me.server = null;
me.address = null;
me.port = null;
me.url = null;
}
return me;
} | [
"function",
"closeHost",
"(",
")",
"{",
"// close the host itself",
"me",
".",
"addresses",
"=",
"{",
"}",
";",
"if",
"(",
"me",
".",
"server",
")",
"{",
"me",
".",
"server",
".",
"close",
"(",
")",
";",
"me",
".",
"server",
"=",
"null",
";",
"me",... | close the host, and clean up cache | [
"close",
"the",
"host",
"and",
"clean",
"up",
"cache"
] | ce8dd12cd2fdf15de7eee89426e291b26e70bdc8 | https://github.com/enmasseio/distribus/blob/ce8dd12cd2fdf15de7eee89426e291b26e70bdc8/lib/Host.js#L562-L575 | train |
filefog/filefog | lib/errors.js | FFParameterRejected | function FFParameterRejected(parameter) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.message = 'A parameter provided is absent, malformed or invalid for other reasons: '+parameter;
} | javascript | function FFParameterRejected(parameter) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.message = 'A parameter provided is absent, malformed or invalid for other reasons: '+parameter;
} | [
"function",
"FFParameterRejected",
"(",
"parameter",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"message",
"=",
"'A parameter provided is absent... | Thrown when a parameter provided is absent, malformed or invalid for other reasons
@constructor FFParameterRejected
@method FFParameterRejected
@param {String} parameter - the name of the parameter that is invalid
@return | [
"Thrown",
"when",
"a",
"parameter",
"provided",
"is",
"absent",
"malformed",
"or",
"invalid",
"for",
"other",
"reasons"
] | 16040ef431e0af8aeee08b445c046a6805242cf3 | https://github.com/filefog/filefog/blob/16040ef431e0af8aeee08b445c046a6805242cf3/lib/errors.js#L10-L14 | train |
jeremenichelli/web-component-refs | src/web-component-refs.js | collectRefs | function collectRefs() {
// check if there's a shadow root in the element
if (typeof this.shadowRoot === 'undefined') {
throw new Error('You must create a shadowRoot on the element');
}
// create refs base object
this.refs = {};
var refsList = this.shadowRoot.querySelectorAll('[ref]');
// collect r... | javascript | function collectRefs() {
// check if there's a shadow root in the element
if (typeof this.shadowRoot === 'undefined') {
throw new Error('You must create a shadowRoot on the element');
}
// create refs base object
this.refs = {};
var refsList = this.shadowRoot.querySelectorAll('[ref]');
// collect r... | [
"function",
"collectRefs",
"(",
")",
"{",
"// check if there's a shadow root in the element",
"if",
"(",
"typeof",
"this",
".",
"shadowRoot",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'You must create a shadowRoot on the element'",
")",
";",
"}",
... | Inspects shadow root and creates a refs object in a custom element
@method collectRefs
@returns {undefined} | [
"Inspects",
"shadow",
"root",
"and",
"creates",
"a",
"refs",
"object",
"in",
"a",
"custom",
"element"
] | c98c04ee458084773fa5a3eac533da289ba4348c | https://github.com/jeremenichelli/web-component-refs/blob/c98c04ee458084773fa5a3eac533da289ba4348c/src/web-component-refs.js#L6-L31 | train |
jeremenichelli/web-component-refs | src/web-component-refs.js | _isRefNode | function _isRefNode(node) {
return (
node.nodeType
&& node.nodeType === 1
&& (node.hasAttribute('ref') || typeof node.__refString__ === 'string')
);
} | javascript | function _isRefNode(node) {
return (
node.nodeType
&& node.nodeType === 1
&& (node.hasAttribute('ref') || typeof node.__refString__ === 'string')
);
} | [
"function",
"_isRefNode",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"nodeType",
"&&",
"node",
".",
"nodeType",
"===",
"1",
"&&",
"(",
"node",
".",
"hasAttribute",
"(",
"'ref'",
")",
"||",
"typeof",
"node",
".",
"__refString__",
"===",
"'string'"... | Checks if node has a ref attribute
@method _isRefNode
@param {Node} node
@returns {Boolean} | [
"Checks",
"if",
"node",
"has",
"a",
"ref",
"attribute"
] | c98c04ee458084773fa5a3eac533da289ba4348c | https://github.com/jeremenichelli/web-component-refs/blob/c98c04ee458084773fa5a3eac533da289ba4348c/src/web-component-refs.js#L49-L55 | train |
jeremenichelli/web-component-refs | src/web-component-refs.js | _handleSingleMutation | function _handleSingleMutation(mutation) {
var addedNodes = _toArray(mutation.addedNodes);
var addedRefs = addedNodes.filter(_isRefNode);
// assign added nodes
addedRefs.map(_assignRef.bind(this));
var removedNodes = _toArray(mutation.removedNodes);
var removedRefs = removedNodes.filter(_isRefNode);
//... | javascript | function _handleSingleMutation(mutation) {
var addedNodes = _toArray(mutation.addedNodes);
var addedRefs = addedNodes.filter(_isRefNode);
// assign added nodes
addedRefs.map(_assignRef.bind(this));
var removedNodes = _toArray(mutation.removedNodes);
var removedRefs = removedNodes.filter(_isRefNode);
//... | [
"function",
"_handleSingleMutation",
"(",
"mutation",
")",
"{",
"var",
"addedNodes",
"=",
"_toArray",
"(",
"mutation",
".",
"addedNodes",
")",
";",
"var",
"addedRefs",
"=",
"addedNodes",
".",
"filter",
"(",
"_isRefNode",
")",
";",
"// assign added nodes",
"added... | Callback to detect added and removed nodes from a single mutation
@method _handleSingleMutation
@param {MutationRecord} mutation
@returns {undefined} | [
"Callback",
"to",
"detect",
"added",
"and",
"removed",
"nodes",
"from",
"a",
"single",
"mutation"
] | c98c04ee458084773fa5a3eac533da289ba4348c | https://github.com/jeremenichelli/web-component-refs/blob/c98c04ee458084773fa5a3eac533da289ba4348c/src/web-component-refs.js#L91-L103 | train |
rjrodger/seneca-jsonrest-api | jsonrest-api.js | action_putpost | function action_putpost(si,args,done) {
var ent_type = parse_ent(args)
var ent = si.make(ent_type.zone,ent_type.base,ent_type.name)
var data = args.data || {}
var good = _.filter(_.keys(data),function(k){return !~k.indexOf('$')})
var fields = _.pick(data,good)
ent.data$(fields)
if( null... | javascript | function action_putpost(si,args,done) {
var ent_type = parse_ent(args)
var ent = si.make(ent_type.zone,ent_type.base,ent_type.name)
var data = args.data || {}
var good = _.filter(_.keys(data),function(k){return !~k.indexOf('$')})
var fields = _.pick(data,good)
ent.data$(fields)
if( null... | [
"function",
"action_putpost",
"(",
"si",
",",
"args",
",",
"done",
")",
"{",
"var",
"ent_type",
"=",
"parse_ent",
"(",
"args",
")",
"var",
"ent",
"=",
"si",
".",
"make",
"(",
"ent_type",
".",
"zone",
",",
"ent_type",
".",
"base",
",",
"ent_type",
"."... | lenient with PUT and POST - treat them as aliases, and both can create new entities | [
"lenient",
"with",
"PUT",
"and",
"POST",
"-",
"treat",
"them",
"as",
"aliases",
"and",
"both",
"can",
"create",
"new",
"entities"
] | b5c749de78694c599f67b999f1c1e47e36708133 | https://github.com/rjrodger/seneca-jsonrest-api/blob/b5c749de78694c599f67b999f1c1e47e36708133/jsonrest-api.js#L194-L219 | train |
johnsonjo4531/videojs-gifplayer | src/plugin.js | handleVisibilityChange | function handleVisibilityChange() {
if (document[hidden]) {
let gifPlayers = document.querySelectorAll('.vjs-gifplayer');
for (let gifPlayer of gifPlayers) {
let player = gifPlayer.player;
if (player) {
player.pause();
}
}
} else {
autoPlayGifs();
}
} | javascript | function handleVisibilityChange() {
if (document[hidden]) {
let gifPlayers = document.querySelectorAll('.vjs-gifplayer');
for (let gifPlayer of gifPlayers) {
let player = gifPlayer.player;
if (player) {
player.pause();
}
}
} else {
autoPlayGifs();
}
} | [
"function",
"handleVisibilityChange",
"(",
")",
"{",
"if",
"(",
"document",
"[",
"hidden",
"]",
")",
"{",
"let",
"gifPlayers",
"=",
"document",
".",
"querySelectorAll",
"(",
"'.vjs-gifplayer'",
")",
";",
"for",
"(",
"let",
"gifPlayer",
"of",
"gifPlayers",
")... | If the page is hidden, pause the video; if the page is shown, play the video | [
"If",
"the",
"page",
"is",
"hidden",
"pause",
"the",
"video",
";",
"if",
"the",
"page",
"is",
"shown",
"play",
"the",
"video"
] | 101c4f6f791e33c3185e4ba2e380177447bee125 | https://github.com/johnsonjo4531/videojs-gifplayer/blob/101c4f6f791e33c3185e4ba2e380177447bee125/src/plugin.js#L98-L112 | train |
bodil/pink | lib/mousetrap.js | _getKeyInfo | function _getKeyInfo(combination, action) {
var keys,
key,
i,
modifiers = [];
// take the keys from this pattern and figure out what the actual
// pattern is all about
keys = _keysFromString(combination);
for (i = 0; i < keys.length; ++i) {
key = keys[i];
// normalize key names
... | javascript | function _getKeyInfo(combination, action) {
var keys,
key,
i,
modifiers = [];
// take the keys from this pattern and figure out what the actual
// pattern is all about
keys = _keysFromString(combination);
for (i = 0; i < keys.length; ++i) {
key = keys[i];
// normalize key names
... | [
"function",
"_getKeyInfo",
"(",
"combination",
",",
"action",
")",
"{",
"var",
"keys",
",",
"key",
",",
"i",
",",
"modifiers",
"=",
"[",
"]",
";",
"// take the keys from this pattern and figure out what the actual",
"// pattern is all about",
"keys",
"=",
"_keysFromSt... | Gets info for a specific key combination
@param {string} combination key combination ("command+s" or "a" or "*")
@param {string=} action
@returns {Object} | [
"Gets",
"info",
"for",
"a",
"specific",
"key",
"combination"
] | 1c0496e03e39b2bbc0330eb514f5f15ff965a073 | https://github.com/bodil/pink/blob/1c0496e03e39b2bbc0330eb514f5f15ff965a073/lib/mousetrap.js#L735-L776 | train |
bodil/pink | lib/mousetrap.js | function(keys, callback, action) {
keys = keys instanceof Array ? keys : [keys];
_bindMultiple(keys, callback, action);
return this;
} | javascript | function(keys, callback, action) {
keys = keys instanceof Array ? keys : [keys];
_bindMultiple(keys, callback, action);
return this;
} | [
"function",
"(",
"keys",
",",
"callback",
",",
"action",
")",
"{",
"keys",
"=",
"keys",
"instanceof",
"Array",
"?",
"keys",
":",
"[",
"keys",
"]",
";",
"_bindMultiple",
"(",
"keys",
",",
"callback",
",",
"action",
")",
";",
"return",
"this",
";",
"}"... | binds an event to mousetrap
can be a single key, a combination of keys separated with +,
an array of keys, or a sequence of keys separated by spaces
be sure to list the modifier keys first to make sure that the
correct key ends up getting bound (the last key in the pattern)
@param {string|Array} keys
@param {Functio... | [
"binds",
"an",
"event",
"to",
"mousetrap"
] | 1c0496e03e39b2bbc0330eb514f5f15ff965a073 | https://github.com/bodil/pink/blob/1c0496e03e39b2bbc0330eb514f5f15ff965a073/lib/mousetrap.js#L866-L870 | train | |
bodil/pink | lib/mousetrap.js | function(e, element) {
// if the element has the class "mousetrap" then no need to stop
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
return false;
}
// stop for input, select, and textarea
return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagNa... | javascript | function(e, element) {
// if the element has the class "mousetrap" then no need to stop
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
return false;
}
// stop for input, select, and textarea
return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagNa... | [
"function",
"(",
"e",
",",
"element",
")",
"{",
"// if the element has the class \"mousetrap\" then no need to stop",
"if",
"(",
"(",
"' '",
"+",
"element",
".",
"className",
"+",
"' '",
")",
".",
"indexOf",
"(",
"' mousetrap '",
")",
">",
"-",
"1",
")",
"{",
... | should we stop this event before firing off callbacks
@param {Event} e
@param {Element} element
@return {boolean} | [
"should",
"we",
"stop",
"this",
"event",
"before",
"firing",
"off",
"callbacks"
] | 1c0496e03e39b2bbc0330eb514f5f15ff965a073 | https://github.com/bodil/pink/blob/1c0496e03e39b2bbc0330eb514f5f15ff965a073/lib/mousetrap.js#L927-L936 | train | |
filefog/filefog | lib/wrapper/provider_wrapper.js | function (name, transform, config, filefog_options){
this.name = name;
this.config = config || {};
this._transform = transform;
this.filefog_options = extend(true, {transform:true, include_raw:true, auto_paginate:true,root_identifier:null}, filefog_options || {});
base_provider.c... | javascript | function (name, transform, config, filefog_options){
this.name = name;
this.config = config || {};
this._transform = transform;
this.filefog_options = extend(true, {transform:true, include_raw:true, auto_paginate:true,root_identifier:null}, filefog_options || {});
base_provider.c... | [
"function",
"(",
"name",
",",
"transform",
",",
"config",
",",
"filefog_options",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"config",
"=",
"config",
"||",
"{",
"}",
";",
"this",
".",
"_transform",
"=",
"transform",
";",
"this",
".... | Wraps the provided base Provider constructor and provides instance variables.
@constructor ProviderWrapper
@method ProviderWrapper
@param {String} name - the name the provider is registered with (using the use method)
@param {Transform} transform - the provider specified transforms for all the client methods.
@param {O... | [
"Wraps",
"the",
"provided",
"base",
"Provider",
"constructor",
"and",
"provides",
"instance",
"variables",
"."
] | 16040ef431e0af8aeee08b445c046a6805242cf3 | https://github.com/filefog/filefog/blob/16040ef431e0af8aeee08b445c046a6805242cf3/lib/wrapper/provider_wrapper.js#L27-L33 | train | |
bodil/pink | lib/events.js | on | function on(emitter, eventName, handler, context) {
handler = context ? handler.bind(context) : handler;
emitter.addEventListener(eventName, handler);
return handler;
} | javascript | function on(emitter, eventName, handler, context) {
handler = context ? handler.bind(context) : handler;
emitter.addEventListener(eventName, handler);
return handler;
} | [
"function",
"on",
"(",
"emitter",
",",
"eventName",
",",
"handler",
",",
"context",
")",
"{",
"handler",
"=",
"context",
"?",
"handler",
".",
"bind",
"(",
"context",
")",
":",
"handler",
";",
"emitter",
".",
"addEventListener",
"(",
"eventName",
",",
"ha... | Register to receive events. | [
"Register",
"to",
"receive",
"events",
"."
] | 1c0496e03e39b2bbc0330eb514f5f15ff965a073 | https://github.com/bodil/pink/blob/1c0496e03e39b2bbc0330eb514f5f15ff965a073/lib/events.js#L33-L37 | train |
bodil/pink | lib/events.js | once | function once(emitter, eventName, handler, context) {
handler = context ? handler.bind(context) : handler;
let wrapper = function onceHandler(event) {
emitter.removeEventListener(eventName, onceHandler);
handler(event);
};
emitter.addEventListener(eventName, wrapper);
return wrapper;
} | javascript | function once(emitter, eventName, handler, context) {
handler = context ? handler.bind(context) : handler;
let wrapper = function onceHandler(event) {
emitter.removeEventListener(eventName, onceHandler);
handler(event);
};
emitter.addEventListener(eventName, wrapper);
return wrapper;
} | [
"function",
"once",
"(",
"emitter",
",",
"eventName",
",",
"handler",
",",
"context",
")",
"{",
"handler",
"=",
"context",
"?",
"handler",
".",
"bind",
"(",
"context",
")",
":",
"handler",
";",
"let",
"wrapper",
"=",
"function",
"onceHandler",
"(",
"even... | Register to receive one single event. | [
"Register",
"to",
"receive",
"one",
"single",
"event",
"."
] | 1c0496e03e39b2bbc0330eb514f5f15ff965a073 | https://github.com/bodil/pink/blob/1c0496e03e39b2bbc0330eb514f5f15ff965a073/lib/events.js#L40-L48 | train |
bodil/pink | lib/events.js | until | function until(emitter, eventName, handler, context) {
handler = context ? handler.bind(context) : handler;
let wrapper = function untilHandler(event) {
if (handler(event))
emitter.removeEventListener(eventName, untilHandler);
};
emitter.addEventListener(eventName, wrapper);
return wrapper;
} | javascript | function until(emitter, eventName, handler, context) {
handler = context ? handler.bind(context) : handler;
let wrapper = function untilHandler(event) {
if (handler(event))
emitter.removeEventListener(eventName, untilHandler);
};
emitter.addEventListener(eventName, wrapper);
return wrapper;
} | [
"function",
"until",
"(",
"emitter",
",",
"eventName",
",",
"handler",
",",
"context",
")",
"{",
"handler",
"=",
"context",
"?",
"handler",
".",
"bind",
"(",
"context",
")",
":",
"handler",
";",
"let",
"wrapper",
"=",
"function",
"untilHandler",
"(",
"ev... | Register to receive events until the handler function returns true. | [
"Register",
"to",
"receive",
"events",
"until",
"the",
"handler",
"function",
"returns",
"true",
"."
] | 1c0496e03e39b2bbc0330eb514f5f15ff965a073 | https://github.com/bodil/pink/blob/1c0496e03e39b2bbc0330eb514f5f15ff965a073/lib/events.js#L51-L59 | train |
ololoepepe/vk-openapi | index.js | function(cb, settings) {
if (!VK._apiId) {
return false;
}
var url = VK._domain.main + VK._path.login + '?client_id='+VK._apiId+'&display=popup&redirect_uri=close.html&response_type=token';
if (settings && parseInt(settings, 10) > 0) {
url += '&scope=' + settings;
... | javascript | function(cb, settings) {
if (!VK._apiId) {
return false;
}
var url = VK._domain.main + VK._path.login + '?client_id='+VK._apiId+'&display=popup&redirect_uri=close.html&response_type=token';
if (settings && parseInt(settings, 10) > 0) {
url += '&scope=' + settings;
... | [
"function",
"(",
"cb",
",",
"settings",
")",
"{",
"if",
"(",
"!",
"VK",
".",
"_apiId",
")",
"{",
"return",
"false",
";",
"}",
"var",
"url",
"=",
"VK",
".",
"_domain",
".",
"main",
"+",
"VK",
".",
"_path",
".",
"login",
"+",
"'?client_id='",
"+",
... | Public VK.Auth methods | [
"Public",
"VK",
".",
"Auth",
"methods"
] | 0e2213f78b3e03c27ea908ed6041e268572211db | https://github.com/ololoepepe/vk-openapi/blob/0e2213f78b3e03c27ea908ed6041e268572211db/index.js#L416-L463 | train | |
kevinconway/Defer.js | defer/defer.js | postMessage | function postMessage(ctx) {
var queue = [],
message = "nextTick";
function handle(event) {
if (event.source === ctx && event.data === message) {
if (!!event.stopPropogation) {
event.stopPropogation();
}
if (queue.length > 0) {
queue.shift()();
... | javascript | function postMessage(ctx) {
var queue = [],
message = "nextTick";
function handle(event) {
if (event.source === ctx && event.data === message) {
if (!!event.stopPropogation) {
event.stopPropogation();
}
if (queue.length > 0) {
queue.shift()();
... | [
"function",
"postMessage",
"(",
"ctx",
")",
"{",
"var",
"queue",
"=",
"[",
"]",
",",
"message",
"=",
"\"nextTick\"",
";",
"function",
"handle",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"source",
"===",
"ctx",
"&&",
"event",
".",
"data",
"==="... | window.postMessage is refered to quite a bit in articles discussing a potential setZeroTimeout for browsers. The problem it attempts to solve is that setTimeout has a minimum wait time in all browsers. This means your function is not scheduled to run on the next cycle of the event loop but, rather, at the next cycle of... | [
"window",
".",
"postMessage",
"is",
"refered",
"to",
"quite",
"a",
"bit",
"in",
"articles",
"discussing",
"a",
"potential",
"setZeroTimeout",
"for",
"browsers",
".",
"The",
"problem",
"it",
"attempts",
"to",
"solve",
"is",
"that",
"setTimeout",
"has",
"a",
"... | f8925ff6536d16eb4388487845ed603aa85d4cb4 | https://github.com/kevinconway/Defer.js/blob/f8925ff6536d16eb4388487845ed603aa85d4cb4/defer/defer.js#L58-L98 | train |
mylisabox/lisa-ui | src/scripts/primus.js | send | function send(ev, data, fn) {
/* jshint validthis: true */
// ignore newListener event to avoid this error in node 0.8
// https://github.com/cayasso/primus-emitter/issues/3
if (/^(newListener|removeListener)/.test(ev)) return this;
this.emitter.send.apply(this... | javascript | function send(ev, data, fn) {
/* jshint validthis: true */
// ignore newListener event to avoid this error in node 0.8
// https://github.com/cayasso/primus-emitter/issues/3
if (/^(newListener|removeListener)/.test(ev)) return this;
this.emitter.send.apply(this... | [
"function",
"send",
"(",
"ev",
",",
"data",
",",
"fn",
")",
"{",
"/* jshint validthis: true */",
"// ignore newListener event to avoid this error in node 0.8",
"// https://github.com/cayasso/primus-emitter/issues/3",
"if",
"(",
"/",
"^(newListener|removeListener)",
"/",
".",
"t... | Emits to this Spark.
@param {String} ev The event
@param {Mixed} [data] The data to broadcast
@param {Function} [fn] The callback function
@return {Primus|Spark} this
@api public | [
"Emits",
"to",
"this",
"Spark",
"."
] | 1fa0ef0ff894882d1f982210a796d37d7aeb36e3 | https://github.com/mylisabox/lisa-ui/blob/1fa0ef0ff894882d1f982210a796d37d7aeb36e3/src/scripts/primus.js#L3352-L3359 | train |
mylisabox/lisa-ui | src/scripts/primus.js | Emitter | function Emitter(conn) {
if (!(this instanceof Emitter)) return new Emitter(conn);
this.ids = 1;
this.acks = {};
this.conn = conn;
if (this.conn) this.bind();
} | javascript | function Emitter(conn) {
if (!(this instanceof Emitter)) return new Emitter(conn);
this.ids = 1;
this.acks = {};
this.conn = conn;
if (this.conn) this.bind();
} | [
"function",
"Emitter",
"(",
"conn",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Emitter",
")",
")",
"return",
"new",
"Emitter",
"(",
"conn",
")",
";",
"this",
".",
"ids",
"=",
"1",
";",
"this",
".",
"acks",
"=",
"{",
"}",
";",
"this",
... | Initialize a new `Emitter`.
@param {Primus|Spark} conn
@return {Emitter} `Emitter` instance
@api public | [
"Initialize",
"a",
"new",
"Emitter",
"."
] | 1fa0ef0ff894882d1f982210a796d37d7aeb36e3 | https://github.com/mylisabox/lisa-ui/blob/1fa0ef0ff894882d1f982210a796d37d7aeb36e3/src/scripts/primus.js#L3395-L3401 | train |
Lanfei/webpack-isomorphic | example/ssr.js | renderToString | function renderToString(reactClass, data) {
let classPath = path.join(viewsDir, reactClass);
let element = React.createElement(require(classPath).default, data);
return ReactDOMServer.renderToString(element);
} | javascript | function renderToString(reactClass, data) {
let classPath = path.join(viewsDir, reactClass);
let element = React.createElement(require(classPath).default, data);
return ReactDOMServer.renderToString(element);
} | [
"function",
"renderToString",
"(",
"reactClass",
",",
"data",
")",
"{",
"let",
"classPath",
"=",
"path",
".",
"join",
"(",
"viewsDir",
",",
"reactClass",
")",
";",
"let",
"element",
"=",
"React",
".",
"createElement",
"(",
"require",
"(",
"classPath",
")",... | Render a react class to string | [
"Render",
"a",
"react",
"class",
"to",
"string"
] | 6e808f58681a3c103a81c493fdb38a702ad7daad | https://github.com/Lanfei/webpack-isomorphic/blob/6e808f58681a3c103a81c493fdb38a702ad7daad/example/ssr.js#L13-L17 | train |
tanhauhau/generator-badge | lib/cmd/installed.js | installed | function installed(){
findUp('README.*')
.then(function(filepath){
if(filepath === null){
return process.cwd();
}else{
return path.resolve(filepath[0], '../');
}
})
.then(function(parent){
return config.readLocal(parent);
})
.then(data => {... | javascript | function installed(){
findUp('README.*')
.then(function(filepath){
if(filepath === null){
return process.cwd();
}else{
return path.resolve(filepath[0], '../');
}
})
.then(function(parent){
return config.readLocal(parent);
})
.then(data => {... | [
"function",
"installed",
"(",
")",
"{",
"findUp",
"(",
"'README.*'",
")",
".",
"then",
"(",
"function",
"(",
"filepath",
")",
"{",
"if",
"(",
"filepath",
"===",
"null",
")",
"{",
"return",
"process",
".",
"cwd",
"(",
")",
";",
"}",
"else",
"{",
"re... | List installed badges, based on .badge.json | [
"List",
"installed",
"badges",
"based",
"on",
".",
"badge",
".",
"json"
] | 32279bdf1eeab39fef86d8ece9f2b6b07e2b6baf | https://github.com/tanhauhau/generator-badge/blob/32279bdf1eeab39fef86d8ece9f2b6b07e2b6baf/lib/cmd/installed.js#L9-L30 | train |
filefog/filefog | lib/wrapper/client_wrapper.js | function(name,transform, provider_config, credentials, filefog_options){
this.name = name;
this.config = provider_config || {};
this.credentials = credentials || {};
this.filefog_options = extend(true, {transform:true, include_raw:true, auto_paginate:true,root_identifier:null}, filefog_o... | javascript | function(name,transform, provider_config, credentials, filefog_options){
this.name = name;
this.config = provider_config || {};
this.credentials = credentials || {};
this.filefog_options = extend(true, {transform:true, include_raw:true, auto_paginate:true,root_identifier:null}, filefog_o... | [
"function",
"(",
"name",
",",
"transform",
",",
"provider_config",
",",
"credentials",
",",
"filefog_options",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"config",
"=",
"provider_config",
"||",
"{",
"}",
";",
"this",
".",
"credentials",
... | Wraps the provided base Client constructor and provides instance variables to be used by provider Clients.
@constructor ClientWrapper
@method ClientWrapper
@param {String} name - the name that the provider is registered with.
@param {Transform} transform - the provider specified transforms for all the client methods.
@... | [
"Wraps",
"the",
"provided",
"base",
"Client",
"constructor",
"and",
"provides",
"instance",
"variables",
"to",
"be",
"used",
"by",
"provider",
"Clients",
"."
] | 16040ef431e0af8aeee08b445c046a6805242cf3 | https://github.com/filefog/filefog/blob/16040ef431e0af8aeee08b445c046a6805242cf3/lib/wrapper/client_wrapper.js#L30-L38 | train | |
scripting/reader | davereader.js | convertOutline | function convertOutline (jstruct) { //7/16/14 by DW
var theNewOutline = {}, atts, subs;
if (jstruct ["source:outline"] != undefined) {
if (jstruct ["@"] != undefined) {
atts = jstruct ["@"];
subs = jstruct ["source:outline"];
}
else {
atts = jstruct ["source:outline"] ["@"];
... | javascript | function convertOutline (jstruct) { //7/16/14 by DW
var theNewOutline = {}, atts, subs;
if (jstruct ["source:outline"] != undefined) {
if (jstruct ["@"] != undefined) {
atts = jstruct ["@"];
subs = jstruct ["source:outline"];
}
else {
atts = jstruct ["source:outline"] ["@"];
... | [
"function",
"convertOutline",
"(",
"jstruct",
")",
"{",
"//7/16/14 by DW",
"var",
"theNewOutline",
"=",
"{",
"}",
",",
"atts",
",",
"subs",
";",
"if",
"(",
"jstruct",
"[",
"\"source:outline\"",
"]",
"!=",
"undefined",
")",
"{",
"if",
"(",
"jstruct",
"[",
... | copy selected elements from the object from feedparser, into the item for the river | [
"copy",
"selected",
"elements",
"from",
"the",
"object",
"from",
"feedparser",
"into",
"the",
"item",
"for",
"the",
"river"
] | 40050c7ecffe0512e73c5915436358fd3f3f1032 | https://github.com/scripting/reader/blob/40050c7ecffe0512e73c5915436358fd3f3f1032/davereader.js#L1608-L1643 | train |
carloscuesta/react-native-layout-debug | index.js | getDebugger | function getDebugger() {
const isCustom = arguments.length === 1;
const layoutDebug = isCustom ? new Debugger(arguments[0]) : defaultDebugger;
return isCustom ? debuggerDecorator.bind(layoutDebug) : debuggerDecorator.call(layoutDebug, ...arguments);
} | javascript | function getDebugger() {
const isCustom = arguments.length === 1;
const layoutDebug = isCustom ? new Debugger(arguments[0]) : defaultDebugger;
return isCustom ? debuggerDecorator.bind(layoutDebug) : debuggerDecorator.call(layoutDebug, ...arguments);
} | [
"function",
"getDebugger",
"(",
")",
"{",
"const",
"isCustom",
"=",
"arguments",
".",
"length",
"===",
"1",
";",
"const",
"layoutDebug",
"=",
"isCustom",
"?",
"new",
"Debugger",
"(",
"arguments",
"[",
"0",
"]",
")",
":",
"defaultDebugger",
";",
"return",
... | Wrapper for debugger decorator to allow custom params
@return {Function} | [
"Wrapper",
"for",
"debugger",
"decorator",
"to",
"allow",
"custom",
"params"
] | 77fb74185d4d6cf99f494e6196d3b8101d608e4c | https://github.com/carloscuesta/react-native-layout-debug/blob/77fb74185d4d6cf99f494e6196d3b8101d608e4c/index.js#L32-L36 | train |
audiojs/web-audio-write | index.js | consume | function consume (len) {
count -= len
if (count < 0) {
count = 0;
console.warn('Not enough samples fed for the next data frame. Expected frame is ' + samplesPerFrame + ' samples ' + channels + ' channels')
}
if (!callbackMarks.length) return
for (let i = 0, l = callbackMarks.length; i < l; i++) {
c... | javascript | function consume (len) {
count -= len
if (count < 0) {
count = 0;
console.warn('Not enough samples fed for the next data frame. Expected frame is ' + samplesPerFrame + ' samples ' + channels + ' channels')
}
if (!callbackMarks.length) return
for (let i = 0, l = callbackMarks.length; i < l; i++) {
c... | [
"function",
"consume",
"(",
"len",
")",
"{",
"count",
"-=",
"len",
"if",
"(",
"count",
"<",
"0",
")",
"{",
"count",
"=",
"0",
";",
"console",
".",
"warn",
"(",
"'Not enough samples fed for the next data frame. Expected frame is '",
"+",
"samplesPerFrame",
"+",
... | walk over callback stack, invoke according callbacks | [
"walk",
"over",
"callback",
"stack",
"invoke",
"according",
"callbacks"
] | 2a1a623b98b028a9e6ff5b08601fa0324e010e74 | https://github.com/audiojs/web-audio-write/blob/2a1a623b98b028a9e6ff5b08601fa0324e010e74/index.js#L262-L280 | train |
johanlahti/intro-guide-js | gulpfile.js | getLibPaths | function getLibPaths(libs, inject) {
inject = inject || false;
var libName,
libSrcs = [],
outSrcs = [];
for (libName in libs) {
libSrcs = libs[libName];
if (typeof libSrcs === "string") {
libSrcs = [libSrcs];
}
var basePath;
if (inject === true) {
// Adapt basepath for inject
basePath = path.... | javascript | function getLibPaths(libs, inject) {
inject = inject || false;
var libName,
libSrcs = [],
outSrcs = [];
for (libName in libs) {
libSrcs = libs[libName];
if (typeof libSrcs === "string") {
libSrcs = [libSrcs];
}
var basePath;
if (inject === true) {
// Adapt basepath for inject
basePath = path.... | [
"function",
"getLibPaths",
"(",
"libs",
",",
"inject",
")",
"{",
"inject",
"=",
"inject",
"||",
"false",
";",
"var",
"libName",
",",
"libSrcs",
"=",
"[",
"]",
",",
"outSrcs",
"=",
"[",
"]",
";",
"for",
"(",
"libName",
"in",
"libs",
")",
"{",
"libSr... | Adapts the lib paths for moving and injecting by
adding a basepath.
@param {Object} libs The libs in original key-value format
@param {Boolean} inject Get paths adapted for inject (if false, paths point to the lib source)
@return {Array} Array of libs | [
"Adapts",
"the",
"lib",
"paths",
"for",
"moving",
"and",
"injecting",
"by",
"adding",
"a",
"basepath",
"."
] | 02aa607dfcbe66dd19a4401c8aa900147b409196 | https://github.com/johanlahti/intro-guide-js/blob/02aa607dfcbe66dd19a4401c8aa900147b409196/gulpfile.js#L85-L112 | train |
jasontbradshaw/irobot | lib/sensors.js | function (valueKey, signed) {
return function (bytes) {
var result = {};
result[valueKey] = misc.bufferToInt(bytes, signed);
return result;
};
} | javascript | function (valueKey, signed) {
return function (bytes) {
var result = {};
result[valueKey] = misc.bufferToInt(bytes, signed);
return result;
};
} | [
"function",
"(",
"valueKey",
",",
"signed",
")",
"{",
"return",
"function",
"(",
"bytes",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"result",
"[",
"valueKey",
"]",
"=",
"misc",
".",
"bufferToInt",
"(",
"bytes",
",",
"signed",
")",
";",
"return",... | build a function that takes in some bytes, parses them as an integer, and returns an object with that value assigned to the given key. | [
"build",
"a",
"function",
"that",
"takes",
"in",
"some",
"bytes",
"parses",
"them",
"as",
"an",
"integer",
"and",
"returns",
"an",
"object",
"with",
"that",
"value",
"assigned",
"to",
"the",
"given",
"key",
"."
] | 20efd28ea603c17b9c15701f4e364a4ebb507c45 | https://github.com/jasontbradshaw/irobot/blob/20efd28ea603c17b9c15701f4e364a4ebb507c45/lib/sensors.js#L10-L16 | train | |
jasontbradshaw/irobot | lib/sensors.js | function (options) {
return function (bytes) {
var result = {
min: options.min,
max: options.max,
range: options.max - options.min,
raw: misc.bufferToInt(bytes)
};
result.magnitude = 1.0 * result.raw / result.range;
return result;
};
} | javascript | function (options) {
return function (bytes) {
var result = {
min: options.min,
max: options.max,
range: options.max - options.min,
raw: misc.bufferToInt(bytes)
};
result.magnitude = 1.0 * result.raw / result.range;
return result;
};
} | [
"function",
"(",
"options",
")",
"{",
"return",
"function",
"(",
"bytes",
")",
"{",
"var",
"result",
"=",
"{",
"min",
":",
"options",
".",
"min",
",",
"max",
":",
"options",
".",
"max",
",",
"range",
":",
"options",
".",
"max",
"-",
"options",
".",... | build a function that takes in some bytes, parses them as an unsigned int, and returns an object with useful data about the value's magnitude between some minimum and maximum. | [
"build",
"a",
"function",
"that",
"takes",
"in",
"some",
"bytes",
"parses",
"them",
"as",
"an",
"unsigned",
"int",
"and",
"returns",
"an",
"object",
"with",
"useful",
"data",
"about",
"the",
"value",
"s",
"magnitude",
"between",
"some",
"minimum",
"and",
"... | 20efd28ea603c17b9c15701f4e364a4ebb507c45 | https://github.com/jasontbradshaw/irobot/blob/20efd28ea603c17b9c15701f4e364a4ebb507c45/lib/sensors.js#L37-L50 | train | |
jasontbradshaw/irobot | lib/sensors.js | function (name, id, bytes, parser) {
this.name = name;
this.id = id;
this.bytes = bytes;
// the parser is null by default, otherwise the specified function
this.parser = _.isFunction(parser) ? parser : function () {};
} | javascript | function (name, id, bytes, parser) {
this.name = name;
this.id = id;
this.bytes = bytes;
// the parser is null by default, otherwise the specified function
this.parser = _.isFunction(parser) ? parser : function () {};
} | [
"function",
"(",
"name",
",",
"id",
",",
"bytes",
",",
"parser",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"bytes",
"=",
"bytes",
";",
"// the parser is null by default, otherwise the specified function"... | stores data about a sensor packet, and holds a function that parses its raw bytes into a more descriptive object format. | [
"stores",
"data",
"about",
"a",
"sensor",
"packet",
"and",
"holds",
"a",
"function",
"that",
"parses",
"its",
"raw",
"bytes",
"into",
"a",
"more",
"descriptive",
"object",
"format",
"."
] | 20efd28ea603c17b9c15701f4e364a4ebb507c45 | https://github.com/jasontbradshaw/irobot/blob/20efd28ea603c17b9c15701f4e364a4ebb507c45/lib/sensors.js#L54-L61 | 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.