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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
vkiding/judpack-lib | src/plugman/fetch.js | checkID | function checkID(expectedIdAndVersion, pinfo) {
if (!expectedIdAndVersion) return;
var parsedSpec = pluginSpec.parse(expectedIdAndVersion);
if (parsedSpec.id != pinfo.id) {
var alias = parsedSpec.scope ? null : pluginMappernto[parsedSpec.id] || pluginMapperotn[parsedSpec.id];
if (alias !== p... | javascript | function checkID(expectedIdAndVersion, pinfo) {
if (!expectedIdAndVersion) return;
var parsedSpec = pluginSpec.parse(expectedIdAndVersion);
if (parsedSpec.id != pinfo.id) {
var alias = parsedSpec.scope ? null : pluginMappernto[parsedSpec.id] || pluginMapperotn[parsedSpec.id];
if (alias !== p... | [
"function",
"checkID",
"(",
"expectedIdAndVersion",
",",
"pinfo",
")",
"{",
"if",
"(",
"!",
"expectedIdAndVersion",
")",
"return",
";",
"var",
"parsedSpec",
"=",
"pluginSpec",
".",
"parse",
"(",
"expectedIdAndVersion",
")",
";",
"if",
"(",
"parsedSpec",
".",
... | Helper function for checking expected plugin IDs against reality. | [
"Helper",
"function",
"for",
"checking",
"expected",
"plugin",
"IDs",
"against",
"reality",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/plugman/fetch.js#L217-L229 | train |
bholloway/gulp-track-filenames | index.js | function() {
return through.obj(function(file, encode, done){
addBefore(file.path);
this.push(file);
done();
});
} | javascript | function() {
return through.obj(function(file, encode, done){
addBefore(file.path);
this.push(file);
done();
});
} | [
"function",
"(",
")",
"{",
"return",
"through",
".",
"obj",
"(",
"function",
"(",
"file",
",",
"encode",
",",
"done",
")",
"{",
"addBefore",
"(",
"file",
".",
"path",
")",
";",
"this",
".",
"push",
"(",
"file",
")",
";",
"done",
"(",
")",
";",
... | Consider file names from the input stream as those before transformation.
Outputs a stream of the same files.
@returns {stream.Through} A through stream that performs the operation of a gulp stream | [
"Consider",
"file",
"names",
"from",
"the",
"input",
"stream",
"as",
"those",
"before",
"transformation",
".",
"Outputs",
"a",
"stream",
"of",
"the",
"same",
"files",
"."
] | 12b2410061ab4d3be51e0966cc1578b1d0a8eeb3 | https://github.com/bholloway/gulp-track-filenames/blob/12b2410061ab4d3be51e0966cc1578b1d0a8eeb3/index.js#L38-L44 | train | |
bholloway/gulp-track-filenames | index.js | function() {
return through.obj(function(file, encode, done){
addAfter(file.path);
this.push(file);
done();
});
} | javascript | function() {
return through.obj(function(file, encode, done){
addAfter(file.path);
this.push(file);
done();
});
} | [
"function",
"(",
")",
"{",
"return",
"through",
".",
"obj",
"(",
"function",
"(",
"file",
",",
"encode",
",",
"done",
")",
"{",
"addAfter",
"(",
"file",
".",
"path",
")",
";",
"this",
".",
"push",
"(",
"file",
")",
";",
"done",
"(",
")",
";",
"... | Consider file names from the input stream as those after transformation.
Order must be preserved so as to correctly match the corresponding before files.
Outputs a stream of the same files.
@returns {stream.Through} A through stream that performs the operation of a gulp stream | [
"Consider",
"file",
"names",
"from",
"the",
"input",
"stream",
"as",
"those",
"after",
"transformation",
".",
"Order",
"must",
"be",
"preserved",
"so",
"as",
"to",
"correctly",
"match",
"the",
"corresponding",
"before",
"files",
".",
"Outputs",
"a",
"stream",
... | 12b2410061ab4d3be51e0966cc1578b1d0a8eeb3 | https://github.com/bholloway/gulp-track-filenames/blob/12b2410061ab4d3be51e0966cc1578b1d0a8eeb3/index.js#L52-L58 | train | |
subfuzion/snapfinder-lib | lib/snapdb.js | connect | function connect(uri, callback) {
console.log('connecting to database (' + uri + ')');
mongo.MongoClient.connect(uri, {safe: true}, function (err, client) {
if (err) return callback(err);
db = client;
db.addListener("error", function (error) {
console.log("mongo client error: " + error);
});
... | javascript | function connect(uri, callback) {
console.log('connecting to database (' + uri + ')');
mongo.MongoClient.connect(uri, {safe: true}, function (err, client) {
if (err) return callback(err);
db = client;
db.addListener("error", function (error) {
console.log("mongo client error: " + error);
});
... | [
"function",
"connect",
"(",
"uri",
",",
"callback",
")",
"{",
"console",
".",
"log",
"(",
"'connecting to database ('",
"+",
"uri",
"+",
"')'",
")",
";",
"mongo",
".",
"MongoClient",
".",
"connect",
"(",
"uri",
",",
"{",
"safe",
":",
"true",
"}",
",",
... | Connect to snapdb mongo database. | [
"Connect",
"to",
"snapdb",
"mongo",
"database",
"."
] | 121172f10a9ec64bc5f3d749fba97662b336caae | https://github.com/subfuzion/snapfinder-lib/blob/121172f10a9ec64bc5f3d749fba97662b336caae/lib/snapdb.js#L17-L29 | train |
subfuzion/snapfinder-lib | lib/snapdb.js | findStoresInZip | function findStoresInZip(zip, callback) {
var zip5 = typeof(zip) == 'string' ? parseInt(zip, 10) : zip;
db.collection(stores, function(err, collection) {
if (err) return callback(err);
collection.find({zip5:zip5}).toArray(function(err, docs) {
if (err) return callback(err);
callback(null, docs... | javascript | function findStoresInZip(zip, callback) {
var zip5 = typeof(zip) == 'string' ? parseInt(zip, 10) : zip;
db.collection(stores, function(err, collection) {
if (err) return callback(err);
collection.find({zip5:zip5}).toArray(function(err, docs) {
if (err) return callback(err);
callback(null, docs... | [
"function",
"findStoresInZip",
"(",
"zip",
",",
"callback",
")",
"{",
"var",
"zip5",
"=",
"typeof",
"(",
"zip",
")",
"==",
"'string'",
"?",
"parseInt",
"(",
"zip",
",",
"10",
")",
":",
"zip",
";",
"db",
".",
"collection",
"(",
"stores",
",",
"functio... | Find all the stores within a zip code. | [
"Find",
"all",
"the",
"stores",
"within",
"a",
"zip",
"code",
"."
] | 121172f10a9ec64bc5f3d749fba97662b336caae | https://github.com/subfuzion/snapfinder-lib/blob/121172f10a9ec64bc5f3d749fba97662b336caae/lib/snapdb.js#L80-L91 | train |
Wizcorp/component-hint | lib/component-hint.js | ComponentHint | function ComponentHint(options) {
// Make this an event emitter
EventEmitter.call(this);
// List of all components that have been checked, we keep this list so that the same components
// are not checked twice.
this.lintedComponents = [];
// Object holding all external dependencies and their versions
this.depe... | javascript | function ComponentHint(options) {
// Make this an event emitter
EventEmitter.call(this);
// List of all components that have been checked, we keep this list so that the same components
// are not checked twice.
this.lintedComponents = [];
// Object holding all external dependencies and their versions
this.depe... | [
"function",
"ComponentHint",
"(",
"options",
")",
"{",
"// Make this an event emitter",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"// List of all components that have been checked, we keep this list so that the same components",
"// are not checked twice.",
"this",
".",
... | Component Hint event emitter object.
@param {Object} options
@returns {ComponentHint} | [
"Component",
"Hint",
"event",
"emitter",
"object",
"."
] | ccd314a9af5dc5b7cb24dc06227c4b95f2034b19 | https://github.com/Wizcorp/component-hint/blob/ccd314a9af5dc5b7cb24dc06227c4b95f2034b19/lib/component-hint.js#L57-L94 | train |
copress/copress-component-oauth2 | lib/oauth2-helper.js | isScopeAllowed | function isScopeAllowed(allowedScopes, tokenScopes) {
allowedScopes = normalizeScope(allowedScopes);
tokenScopes = normalizeScope(tokenScopes);
if (allowedScopes.length === 0) {
return true;
}
for (var i = 0, n = allowedScopes.length; i < n; i++) {
if (tokenScopes.indexOf(allowedScop... | javascript | function isScopeAllowed(allowedScopes, tokenScopes) {
allowedScopes = normalizeScope(allowedScopes);
tokenScopes = normalizeScope(tokenScopes);
if (allowedScopes.length === 0) {
return true;
}
for (var i = 0, n = allowedScopes.length; i < n; i++) {
if (tokenScopes.indexOf(allowedScop... | [
"function",
"isScopeAllowed",
"(",
"allowedScopes",
",",
"tokenScopes",
")",
"{",
"allowedScopes",
"=",
"normalizeScope",
"(",
"allowedScopes",
")",
";",
"tokenScopes",
"=",
"normalizeScope",
"(",
"tokenScopes",
")",
";",
"if",
"(",
"allowedScopes",
".",
"length",... | Check if one of the scopes is in the allowedScopes array
@param {String[]} allowedScopes An array of required scopes
@param {String[]} scopes An array of granted scopes
@returns {boolean} | [
"Check",
"if",
"one",
"of",
"the",
"scopes",
"is",
"in",
"the",
"allowedScopes",
"array"
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/oauth2-helper.js#L66-L78 | train |
copress/copress-component-oauth2 | lib/oauth2-helper.js | isScopeAuthorized | function isScopeAuthorized(requestedScopes, authorizedScopes) {
requestedScopes = normalizeScope(requestedScopes);
authorizedScopes = normalizeScope(authorizedScopes);
if (requestedScopes.length === 0) {
return true;
}
for (var i = 0, n = requestedScopes.length; i < n; i++) {
if (aut... | javascript | function isScopeAuthorized(requestedScopes, authorizedScopes) {
requestedScopes = normalizeScope(requestedScopes);
authorizedScopes = normalizeScope(authorizedScopes);
if (requestedScopes.length === 0) {
return true;
}
for (var i = 0, n = requestedScopes.length; i < n; i++) {
if (aut... | [
"function",
"isScopeAuthorized",
"(",
"requestedScopes",
",",
"authorizedScopes",
")",
"{",
"requestedScopes",
"=",
"normalizeScope",
"(",
"requestedScopes",
")",
";",
"authorizedScopes",
"=",
"normalizeScope",
"(",
"authorizedScopes",
")",
";",
"if",
"(",
"requestedS... | Check if the requested scopes are covered by authorized scopes
@param {String|String[]) requestedScopes
@param {String|String[]) authorizedScopes
@returns {boolean} | [
"Check",
"if",
"the",
"requested",
"scopes",
"are",
"covered",
"by",
"authorized",
"scopes"
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/oauth2-helper.js#L86-L98 | train |
muniere/node-behalter | lib/behalter.js | Behalter | function Behalter(parent, options) {
// normalize arguments for the case of `new Behalter(options)`
if (arguments.length === 1 && !(parent instanceof Behalter) && _.isPlainObject(parent)) {
options = parent;
parent = void 0;
}
// for hierarchical search, validate type of parent
if (parent && !(paren... | javascript | function Behalter(parent, options) {
// normalize arguments for the case of `new Behalter(options)`
if (arguments.length === 1 && !(parent instanceof Behalter) && _.isPlainObject(parent)) {
options = parent;
parent = void 0;
}
// for hierarchical search, validate type of parent
if (parent && !(paren... | [
"function",
"Behalter",
"(",
"parent",
",",
"options",
")",
"{",
"// normalize arguments for the case of `new Behalter(options)`",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
"&&",
"!",
"(",
"parent",
"instanceof",
"Behalter",
")",
"&&",
"_",
".",
"isPlainO... | Create a new behalter.
@param {(Behalter|Object)} [parent]
@param {Object} [options={}]
@constructor | [
"Create",
"a",
"new",
"behalter",
"."
] | e991c9cad610f1268c6012c3042fbc3fa9802fee | https://github.com/muniere/node-behalter/blob/e991c9cad610f1268c6012c3042fbc3fa9802fee/lib/behalter.js#L16-L46 | train |
muniere/node-behalter | lib/behalter.js | reserved | function reserved(name) {
if (!_.isString(name)) {
return false;
}
return _.contains(RESERVED, name);
} | javascript | function reserved(name) {
if (!_.isString(name)) {
return false;
}
return _.contains(RESERVED, name);
} | [
"function",
"reserved",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"_",
".",
"contains",
"(",
"RESERVED",
",",
"name",
")",
";",
"}"
] | Judge if name is reserved word or not.
@param {string} name
@returns {boolean} true if reserved | [
"Judge",
"if",
"name",
"is",
"reserved",
"word",
"or",
"not",
"."
] | e991c9cad610f1268c6012c3042fbc3fa9802fee | https://github.com/muniere/node-behalter/blob/e991c9cad610f1268c6012c3042fbc3fa9802fee/lib/behalter.js#L427-L433 | train |
muniere/node-behalter | lib/behalter.js | annotate | function annotate(fn) {
var matched = /function +[^\(]*\(([^\)]*)\).*/.exec(fn.toString());
var names = _.reject(matched[1].split(',') || [], _.isEmpty);
return _.map(names, function(name) {
return name.replace(/\s+/g, '');
});
} | javascript | function annotate(fn) {
var matched = /function +[^\(]*\(([^\)]*)\).*/.exec(fn.toString());
var names = _.reject(matched[1].split(',') || [], _.isEmpty);
return _.map(names, function(name) {
return name.replace(/\s+/g, '');
});
} | [
"function",
"annotate",
"(",
"fn",
")",
"{",
"var",
"matched",
"=",
"/",
"function +[^\\(]*\\(([^\\)]*)\\).*",
"/",
".",
"exec",
"(",
"fn",
".",
"toString",
"(",
")",
")",
";",
"var",
"names",
"=",
"_",
".",
"reject",
"(",
"matched",
"[",
"1",
"]",
"... | Extract names of arguments for function.
@param {function} fn
@returns {string[]} names of arguments | [
"Extract",
"names",
"of",
"arguments",
"for",
"function",
"."
] | e991c9cad610f1268c6012c3042fbc3fa9802fee | https://github.com/muniere/node-behalter/blob/e991c9cad610f1268c6012c3042fbc3fa9802fee/lib/behalter.js#L441-L448 | train |
ex-machine/express-ko | lib/index.js | ko | function ko(fn, isParamHandler) {
// handlers and middlewares may have safeguard properties to be skipped
if ('$$koified' in fn) {
return fn;
}
let handler = function (req, res, next) {
let argsLength = arguments.length;
let args = new Array(argsLength);
for (let i = 0; i < argsLength; i++) {
... | javascript | function ko(fn, isParamHandler) {
// handlers and middlewares may have safeguard properties to be skipped
if ('$$koified' in fn) {
return fn;
}
let handler = function (req, res, next) {
let argsLength = arguments.length;
let args = new Array(argsLength);
for (let i = 0; i < argsLength; i++) {
... | [
"function",
"ko",
"(",
"fn",
",",
"isParamHandler",
")",
"{",
"// handlers and middlewares may have safeguard properties to be skipped\r",
"if",
"(",
"'$$koified'",
"in",
"fn",
")",
"{",
"return",
"fn",
";",
"}",
"let",
"handler",
"=",
"function",
"(",
"req",
",",... | Wraps a generator or promise-returning callback function | [
"Wraps",
"a",
"generator",
"or",
"promise",
"-",
"returning",
"callback",
"function"
] | e45a2959274ab52e52b96933545fa5491d4a05a2 | https://github.com/ex-machine/express-ko/blob/e45a2959274ab52e52b96933545fa5491d4a05a2/lib/index.js#L24-L80 | train |
ex-machine/express-ko | lib/index.js | koifyHandler | function koifyHandler(fn, args, isErrHandler) {
let fnResult;
if (isGeneratorFunction(fn)) {
fnResult = co(function* () {
return yield* fn(...args);
});
} else {
fnResult = fn(...args);
}
if (!isPromise(fnResult)) {
return fnResult;
}
let req, res, next;
if (isErrHandler) {
re... | javascript | function koifyHandler(fn, args, isErrHandler) {
let fnResult;
if (isGeneratorFunction(fn)) {
fnResult = co(function* () {
return yield* fn(...args);
});
} else {
fnResult = fn(...args);
}
if (!isPromise(fnResult)) {
return fnResult;
}
let req, res, next;
if (isErrHandler) {
re... | [
"function",
"koifyHandler",
"(",
"fn",
",",
"args",
",",
"isErrHandler",
")",
"{",
"let",
"fnResult",
";",
"if",
"(",
"isGeneratorFunction",
"(",
"fn",
")",
")",
"{",
"fnResult",
"=",
"co",
"(",
"function",
"*",
"(",
")",
"{",
"return",
"yield",
"*",
... | Optionally co-ifies a generator, then chains a promise | [
"Optionally",
"co",
"-",
"ifies",
"a",
"generator",
"then",
"chains",
"a",
"promise"
] | e45a2959274ab52e52b96933545fa5491d4a05a2 | https://github.com/ex-machine/express-ko/blob/e45a2959274ab52e52b96933545fa5491d4a05a2/lib/index.js#L85-L137 | train |
ex-machine/express-ko | lib/index.js | koify | function koify() {
let args = slice.call(arguments);
let Router;
let Route;
if ((args.length === 1) && ('Router' in args[0]) && ('Route' in args[0])) {
let express = args[0];
Router = express.Router;
Route = express.Route;
} else {
Router = args[0];
Route = args[1];
}
if (Router) ... | javascript | function koify() {
let args = slice.call(arguments);
let Router;
let Route;
if ((args.length === 1) && ('Router' in args[0]) && ('Route' in args[0])) {
let express = args[0];
Router = express.Router;
Route = express.Route;
} else {
Router = args[0];
Route = args[1];
}
if (Router) ... | [
"function",
"koify",
"(",
")",
"{",
"let",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"let",
"Router",
";",
"let",
"Route",
";",
"if",
"(",
"(",
"args",
".",
"length",
"===",
"1",
")",
"&&",
"(",
"'Router'",
"in",
"args",
"[",... | Patches Express router | [
"Patches",
"Express",
"router"
] | e45a2959274ab52e52b96933545fa5491d4a05a2 | https://github.com/ex-machine/express-ko/blob/e45a2959274ab52e52b96933545fa5491d4a05a2/lib/index.js#L142-L166 | train |
ex-machine/express-ko | lib/index.js | koifyRouter | function koifyRouter(Router) {
// router factory function is the prototype
let routerPrototype = Router;
// original router methods
let routerPrototype_ = {};
// router duck testing
let routerMethods = Object.keys(routerPrototype).sort();
function isRouter(someRouter) {
let someRouterPrototype = ... | javascript | function koifyRouter(Router) {
// router factory function is the prototype
let routerPrototype = Router;
// original router methods
let routerPrototype_ = {};
// router duck testing
let routerMethods = Object.keys(routerPrototype).sort();
function isRouter(someRouter) {
let someRouterPrototype = ... | [
"function",
"koifyRouter",
"(",
"Router",
")",
"{",
"// router factory function is the prototype\r",
"let",
"routerPrototype",
"=",
"Router",
";",
"// original router methods\r",
"let",
"routerPrototype_",
"=",
"{",
"}",
";",
"// router duck testing\r",
"let",
"routerMethod... | Patches router methods | [
"Patches",
"router",
"methods"
] | e45a2959274ab52e52b96933545fa5491d4a05a2 | https://github.com/ex-machine/express-ko/blob/e45a2959274ab52e52b96933545fa5491d4a05a2/lib/index.js#L172-L227 | train |
ex-machine/express-ko | lib/index.js | koifyRoute | function koifyRoute(Route) {
let routePrototype = Route.prototype;
let routePrototype_ = {};
for (let method of [...methods, 'all']) {
routePrototype_[method] = routePrototype[method];
routePrototype[method] = function () {
let args = slice.call(arguments);
for (let i = 0; i < args.length; i++) ... | javascript | function koifyRoute(Route) {
let routePrototype = Route.prototype;
let routePrototype_ = {};
for (let method of [...methods, 'all']) {
routePrototype_[method] = routePrototype[method];
routePrototype[method] = function () {
let args = slice.call(arguments);
for (let i = 0; i < args.length; i++) ... | [
"function",
"koifyRoute",
"(",
"Route",
")",
"{",
"let",
"routePrototype",
"=",
"Route",
".",
"prototype",
";",
"let",
"routePrototype_",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"method",
"of",
"[",
"...",
"methods",
",",
"'all'",
"]",
")",
"{",
"routeP... | Patches route HTTP methods | [
"Patches",
"route",
"HTTP",
"methods"
] | e45a2959274ab52e52b96933545fa5491d4a05a2 | https://github.com/ex-machine/express-ko/blob/e45a2959274ab52e52b96933545fa5491d4a05a2/lib/index.js#L232-L254 | train |
gethuman/pancakes-recipe | utils/obj.utils.js | matchesCriteria | function matchesCriteria(data, criteria) {
data = data || {};
criteria = criteria || {};
var match = true;
_.each(criteria, function (val, key) {
var hasNotOperand = false;
if (_.isObject(val) && val['$ne'] ) {
hasNotOperand = true;
... | javascript | function matchesCriteria(data, criteria) {
data = data || {};
criteria = criteria || {};
var match = true;
_.each(criteria, function (val, key) {
var hasNotOperand = false;
if (_.isObject(val) && val['$ne'] ) {
hasNotOperand = true;
... | [
"function",
"matchesCriteria",
"(",
"data",
",",
"criteria",
")",
"{",
"data",
"=",
"data",
"||",
"{",
"}",
";",
"criteria",
"=",
"criteria",
"||",
"{",
"}",
";",
"var",
"match",
"=",
"true",
";",
"_",
".",
"each",
"(",
"criteria",
",",
"function",
... | True if the given data matches the criteria. If criteria empty,
then always true
Examples
Obj: { a: 'monday', b: 'tuesday' } Criteria: { a: 'monday' } // true
Obj: { a: 'monday', b: 'tuesday' } Criteria: { a: 'tuesday' } // false
Obj: { a: 'monday', b: 'tuesday' } Criteria: { c: 'monday' } // false
Obj: { a: 'mond... | [
"True",
"if",
"the",
"given",
"data",
"matches",
"the",
"criteria",
".",
"If",
"criteria",
"empty",
"then",
"always",
"true"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/obj.utils.js#L151-L179 | train |
vergeplayer/vQ | src/js/module/event.js | function (element, type, handler, context) {
var own = this;
//非Dom元素不处理
if (!(1 == element.nodeType || element.nodeType == 9 || element === window)|| !vQ.isFunction(handler)) {
return;
}
//获取传入参数
var args = slice.call(arguments);
... | javascript | function (element, type, handler, context) {
var own = this;
//非Dom元素不处理
if (!(1 == element.nodeType || element.nodeType == 9 || element === window)|| !vQ.isFunction(handler)) {
return;
}
//获取传入参数
var args = slice.call(arguments);
... | [
"function",
"(",
"element",
",",
"type",
",",
"handler",
",",
"context",
")",
"{",
"var",
"own",
"=",
"this",
";",
"//非Dom元素不处理",
"if",
"(",
"!",
"(",
"1",
"==",
"element",
".",
"nodeType",
"||",
"element",
".",
"nodeType",
"==",
"9",
"||",
"element"... | Trigger a listener only once for an event
@param {Element|Object} elem Element or object to
@param {String|Array} type
@param {Function} fn
@private | [
"Trigger",
"a",
"listener",
"only",
"once",
"for",
"an",
"event"
] | 6a84635efb6fbf5c47c41cf05931ab53207024ca | https://github.com/vergeplayer/vQ/blob/6a84635efb6fbf5c47c41cf05931ab53207024ca/src/js/module/event.js#L124-L159 | train | |
mathieudutour/nplint | lib/JSON-parser.js | makeError | function makeError(e) {
return {
fatal: true,
severity: 2,
message: (e.message || '').split('\n', 1)[0],
line: parser.line,
column: parser.column
};
} | javascript | function makeError(e) {
return {
fatal: true,
severity: 2,
message: (e.message || '').split('\n', 1)[0],
line: parser.line,
column: parser.column
};
} | [
"function",
"makeError",
"(",
"e",
")",
"{",
"return",
"{",
"fatal",
":",
"true",
",",
"severity",
":",
"2",
",",
"message",
":",
"(",
"e",
".",
"message",
"||",
"''",
")",
".",
"split",
"(",
"'\\n'",
",",
"1",
")",
"[",
"0",
"]",
",",
"line",
... | generate a detailed error using the parser's state | [
"generate",
"a",
"detailed",
"error",
"using",
"the",
"parser",
"s",
"state"
] | ef444abcc6dd08fb61d5fc8ce618598d4455e08e | https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/JSON-parser.js#L20-L28 | train |
wenwuwu/events-es5 | events.js | function (eventNames) {
var events = this._events;
for (var i = 0; i < arguments.length; i++) {
var eventName = arguments[i];
this._validateName(eventName);
if (typeof events[eventName] === 'undefi... | javascript | function (eventNames) {
var events = this._events;
for (var i = 0; i < arguments.length; i++) {
var eventName = arguments[i];
this._validateName(eventName);
if (typeof events[eventName] === 'undefi... | [
"function",
"(",
"eventNames",
")",
"{",
"var",
"events",
"=",
"this",
".",
"_events",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"eventName",
"=",
"arguments",
"[",
"i",
"]"... | Defines a list of events.
@param eventNames {String...}
@returns {Events} | [
"Defines",
"a",
"list",
"of",
"events",
"."
] | 86c7d54102dafe725f57d0278479aa5bf8234ebc | https://github.com/wenwuwu/events-es5/blob/86c7d54102dafe725f57d0278479aa5bf8234ebc/events.js#L43-L57 | train | |
wenwuwu/events-es5 | events.js | function (eventName, fn) {
if (typeof eventName === 'object') {
if (eventName === null) {
throw "IllegalArgumentException: eventName must be a String, or an Object.";
}
for (var name in eventName) {
if (eventName... | javascript | function (eventName, fn) {
if (typeof eventName === 'object') {
if (eventName === null) {
throw "IllegalArgumentException: eventName must be a String, or an Object.";
}
for (var name in eventName) {
if (eventName... | [
"function",
"(",
"eventName",
",",
"fn",
")",
"{",
"if",
"(",
"typeof",
"eventName",
"===",
"'object'",
")",
"{",
"if",
"(",
"eventName",
"===",
"null",
")",
"{",
"throw",
"\"IllegalArgumentException: eventName must be a String, or an Object.\"",
";",
"}",
"for",
... | Binds a listener to an event.
@param eventName {String or Object}
@param fn {Function} - Not required if 1st argument is an Object.
@returns {Events} A pointer to this instance, allowing call chaining. | [
"Binds",
"a",
"listener",
"to",
"an",
"event",
"."
] | 86c7d54102dafe725f57d0278479aa5bf8234ebc | https://github.com/wenwuwu/events-es5/blob/86c7d54102dafe725f57d0278479aa5bf8234ebc/events.js#L74-L103 | train | |
wenwuwu/events-es5 | events.js | function (eventName, fn) {
if (typeof fn !== 'function') {
throw "IllegalArgumentException: fn must be a Function.";
}
var fns = this._events[eventName];
if (fns instanceof Array) {
var len = fns.length;
... | javascript | function (eventName, fn) {
if (typeof fn !== 'function') {
throw "IllegalArgumentException: fn must be a Function.";
}
var fns = this._events[eventName];
if (fns instanceof Array) {
var len = fns.length;
... | [
"function",
"(",
"eventName",
",",
"fn",
")",
"{",
"if",
"(",
"typeof",
"fn",
"!==",
"'function'",
")",
"{",
"throw",
"\"IllegalArgumentException: fn must be a Function.\"",
";",
"}",
"var",
"fns",
"=",
"this",
".",
"_events",
"[",
"eventName",
"]",
";",
"if... | Removes the bind between a listener and an event.
@param eventName {String}
@param fn {Function}
@returns {Events} A pointer to this instance, allowing call chaining. | [
"Removes",
"the",
"bind",
"between",
"a",
"listener",
"and",
"an",
"event",
"."
] | 86c7d54102dafe725f57d0278479aa5bf8234ebc | https://github.com/wenwuwu/events-es5/blob/86c7d54102dafe725f57d0278479aa5bf8234ebc/events.js#L111-L134 | train | |
wenwuwu/events-es5 | events.js | function (eventName) {
var fns = this._events[eventName];
if (typeof fns === 'undefined') {
throw "IllegalArgumentException: unsupported eventName (" + eventName + ")";
}
if (fns.length > 0) {
var args = []... | javascript | function (eventName) {
var fns = this._events[eventName];
if (typeof fns === 'undefined') {
throw "IllegalArgumentException: unsupported eventName (" + eventName + ")";
}
if (fns.length > 0) {
var args = []... | [
"function",
"(",
"eventName",
")",
"{",
"var",
"fns",
"=",
"this",
".",
"_events",
"[",
"eventName",
"]",
";",
"if",
"(",
"typeof",
"fns",
"===",
"'undefined'",
")",
"{",
"throw",
"\"IllegalArgumentException: unsupported eventName (\"",
"+",
"eventName",
"+",
... | Sends an event to all listeners.
This method returns <code>false</code> if any of the
listeners returned <code>false</code>. If there are
no listeners to this event, or if none of them
returned <code>false</code>, this method returns <code>true</code>.
Typically, a listener will return <code>false</code> to indicate... | [
"Sends",
"an",
"event",
"to",
"all",
"listeners",
"."
] | 86c7d54102dafe725f57d0278479aa5bf8234ebc | https://github.com/wenwuwu/events-es5/blob/86c7d54102dafe725f57d0278479aa5bf8234ebc/events.js#L180-L207 | train | |
taoyuan/lwim | lib/bitmap.js | Bitmap | function Bitmap(width, height, bytesPerPixel, endianness) {
if (!(this instanceof Bitmap)) {
return new Bitmap(width, height, bytesPerPixel, endianness);
}
// Validate bytes per pixel
if (bytesPerPixel === undefined) {
bytesPerPixel = 1;
}
if (bytesPerPixel !== 1 && bytesPerPixel !== 2 && bytesPerP... | javascript | function Bitmap(width, height, bytesPerPixel, endianness) {
if (!(this instanceof Bitmap)) {
return new Bitmap(width, height, bytesPerPixel, endianness);
}
// Validate bytes per pixel
if (bytesPerPixel === undefined) {
bytesPerPixel = 1;
}
if (bytesPerPixel !== 1 && bytesPerPixel !== 2 && bytesPerP... | [
"function",
"Bitmap",
"(",
"width",
",",
"height",
",",
"bytesPerPixel",
",",
"endianness",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Bitmap",
")",
")",
"{",
"return",
"new",
"Bitmap",
"(",
"width",
",",
"height",
",",
"bytesPerPixel",
",",
... | Creates an in-memory bitmap. Bitmaps with 1 byte per pixel are handled in conjunction with a
palette.
@class
@param {number} width
@param {number} height
@param {number} [bytesPerPixel=1] Possible values: <code>1</code>, <code>2</code>,
<code>4</code>
@param {Endianness} [endianness=BIG] Use big- or little-endian when... | [
"Creates",
"an",
"in",
"-",
"memory",
"bitmap",
".",
"Bitmaps",
"with",
"1",
"byte",
"per",
"pixel",
"are",
"handled",
"in",
"conjunction",
"with",
"a",
"palette",
"."
] | 90014f5d058bb514768df24caa6605437ec586e2 | https://github.com/taoyuan/lwim/blob/90014f5d058bb514768df24caa6605437ec586e2/lib/bitmap.js#L87-L110 | train |
taoyuan/impack | lib/download/git.js | normalize | function normalize(repo) {
const regex = /^((github|gitlab|bitbucket|oschina):)?((.+):)?([^/]+)\/([^#]+)(#(.+))?$/;
const match = regex.exec(repo);
const type = match[2] || 'github';
let host = match[4] || null;
const owner = match[5];
const name = match[6];
const checkout = match[8] || 'master';
if (host === ... | javascript | function normalize(repo) {
const regex = /^((github|gitlab|bitbucket|oschina):)?((.+):)?([^/]+)\/([^#]+)(#(.+))?$/;
const match = regex.exec(repo);
const type = match[2] || 'github';
let host = match[4] || null;
const owner = match[5];
const name = match[6];
const checkout = match[8] || 'master';
if (host === ... | [
"function",
"normalize",
"(",
"repo",
")",
"{",
"const",
"regex",
"=",
"/",
"^((github|gitlab|bitbucket|oschina):)?((.+):)?([^/]+)\\/([^#]+)(#(.+))?$",
"/",
";",
"const",
"match",
"=",
"regex",
".",
"exec",
"(",
"repo",
")",
";",
"const",
"type",
"=",
"match",
"... | Normalize a repo string.
@param {String} repo
@return {Object} | [
"Normalize",
"a",
"repo",
"string",
"."
] | 4dba8e91b9d2c8785eda5db634943ec00683bff7 | https://github.com/taoyuan/impack/blob/4dba8e91b9d2c8785eda5db634943ec00683bff7/lib/download/git.js#L59-L87 | train |
taoyuan/impack | lib/download/git.js | getUrl | function getUrl(repo, clone) {
let url;
if (repo.type === 'github') {
url = github(repo, clone);
} else if (repo.type === 'gitlab') {
url = gitlab(repo, clone);
} else if (repo.type === 'bitbucket') {
url = bitbucket(repo, clone);
} else if (repo.type === 'oschina') {
url = oschina(repo, clone);
} else {... | javascript | function getUrl(repo, clone) {
let url;
if (repo.type === 'github') {
url = github(repo, clone);
} else if (repo.type === 'gitlab') {
url = gitlab(repo, clone);
} else if (repo.type === 'bitbucket') {
url = bitbucket(repo, clone);
} else if (repo.type === 'oschina') {
url = oschina(repo, clone);
} else {... | [
"function",
"getUrl",
"(",
"repo",
",",
"clone",
")",
"{",
"let",
"url",
";",
"if",
"(",
"repo",
".",
"type",
"===",
"'github'",
")",
"{",
"url",
"=",
"github",
"(",
"repo",
",",
"clone",
")",
";",
"}",
"else",
"if",
"(",
"repo",
".",
"type",
"... | Return a zip or git url for a given `repo`.
@param {Object} repo
@param {Boolean} [clone]
@return {String|Object} | [
"Return",
"a",
"zip",
"or",
"git",
"url",
"for",
"a",
"given",
"repo",
"."
] | 4dba8e91b9d2c8785eda5db634943ec00683bff7 | https://github.com/taoyuan/impack/blob/4dba8e91b9d2c8785eda5db634943ec00683bff7/lib/download/git.js#L111-L127 | train |
taoyuan/impack | lib/download/git.js | github | function github(repo, clone) {
let url;
if (clone)
url = 'git@' + repo.host + ':' + repo.owner + '/' + repo.name + '.git';
else
url = addProtocol(repo.host) + '/' + repo.owner + '/' + repo.name + '/archive/' + repo.checkout + '.zip';
return url;
} | javascript | function github(repo, clone) {
let url;
if (clone)
url = 'git@' + repo.host + ':' + repo.owner + '/' + repo.name + '.git';
else
url = addProtocol(repo.host) + '/' + repo.owner + '/' + repo.name + '/archive/' + repo.checkout + '.zip';
return url;
} | [
"function",
"github",
"(",
"repo",
",",
"clone",
")",
"{",
"let",
"url",
";",
"if",
"(",
"clone",
")",
"url",
"=",
"'git@'",
"+",
"repo",
".",
"host",
"+",
"':'",
"+",
"repo",
".",
"owner",
"+",
"'/'",
"+",
"repo",
".",
"name",
"+",
"'.git'",
"... | Return a GitHub url for a given `repo` object.
@param {Object} repo
@param {Boolean} [clone]
@return {String} | [
"Return",
"a",
"GitHub",
"url",
"for",
"a",
"given",
"repo",
"object",
"."
] | 4dba8e91b9d2c8785eda5db634943ec00683bff7 | https://github.com/taoyuan/impack/blob/4dba8e91b9d2c8785eda5db634943ec00683bff7/lib/download/git.js#L137-L146 | train |
taoyuan/impack | lib/download/git.js | oschina | function oschina(repo, clone) {
let url;
// oschina canceled download directly
clone = true;
if (clone)
url = addProtocol(repo.host) + '/' + repo.owner + '/' + repo.name;
// url = 'git@' + repo.host + ':' + repo.owner + '/' + repo.name + '.git';
else
url = addProtocol(repo.host) + '/' + repo.owner + '/' + ... | javascript | function oschina(repo, clone) {
let url;
// oschina canceled download directly
clone = true;
if (clone)
url = addProtocol(repo.host) + '/' + repo.owner + '/' + repo.name;
// url = 'git@' + repo.host + ':' + repo.owner + '/' + repo.name + '.git';
else
url = addProtocol(repo.host) + '/' + repo.owner + '/' + ... | [
"function",
"oschina",
"(",
"repo",
",",
"clone",
")",
"{",
"let",
"url",
";",
"// oschina canceled download directly",
"clone",
"=",
"true",
";",
"if",
"(",
"clone",
")",
"url",
"=",
"addProtocol",
"(",
"repo",
".",
"host",
")",
"+",
"'/'",
"+",
"repo",... | Return a GitLab url for a given `repo` object.
@param {Object} repo
@param {Boolean} [clone]
@return {Object} | [
"Return",
"a",
"GitLab",
"url",
"for",
"a",
"given",
"repo",
"object",
"."
] | 4dba8e91b9d2c8785eda5db634943ec00683bff7 | https://github.com/taoyuan/impack/blob/4dba8e91b9d2c8785eda5db634943ec00683bff7/lib/download/git.js#L194-L207 | train |
ryanramage/schema-couch-boilerplate | jam/ractive/build/Ractive.runtime.js | function () {
var str, i, len;
// TODO void tags
str = '' +
'<' + this.descriptor.e;
len = this.attributes.length;
for ( i=0; i<len; i+=1 ) {
str += ' ' + this.attributes[i].toString();
}
str += '>';
if ( this.html ) {
str += this.html;
} else if ( this.fragment ) {
str += this.fragmen... | javascript | function () {
var str, i, len;
// TODO void tags
str = '' +
'<' + this.descriptor.e;
len = this.attributes.length;
for ( i=0; i<len; i+=1 ) {
str += ' ' + this.attributes[i].toString();
}
str += '>';
if ( this.html ) {
str += this.html;
} else if ( this.fragment ) {
str += this.fragmen... | [
"function",
"(",
")",
"{",
"var",
"str",
",",
"i",
",",
"len",
";",
"// TODO void tags",
"str",
"=",
"''",
"+",
"'<'",
"+",
"this",
".",
"descriptor",
".",
"e",
";",
"len",
"=",
"this",
".",
"attributes",
".",
"length",
";",
"for",
"(",
"i",
"=",... | just so event proxy and transition fragments have something to call! | [
"just",
"so",
"event",
"proxy",
"and",
"transition",
"fragments",
"have",
"something",
"to",
"call!"
] | c323516f02c90101aa6b21592bfdd2a6f2e47680 | https://github.com/ryanramage/schema-couch-boilerplate/blob/c323516f02c90101aa6b21592bfdd2a6f2e47680/jam/ractive/build/Ractive.runtime.js#L6040-L6063 | train | |
tgi-io/tgi-core | lib/models/tgi-core-model-session.spec.js | userStored | function userStored(model, error) {
if (typeof error != 'undefined') {
callback(error);
return;
}
if (user1.get('id') && user2.get('id')) {
// users added to store now log them both in and also generate 2 errors
self.goodCount = 0;
... | javascript | function userStored(model, error) {
if (typeof error != 'undefined') {
callback(error);
return;
}
if (user1.get('id') && user2.get('id')) {
// users added to store now log them both in and also generate 2 errors
self.goodCount = 0;
... | [
"function",
"userStored",
"(",
"model",
",",
"error",
")",
"{",
"if",
"(",
"typeof",
"error",
"!=",
"'undefined'",
")",
"{",
"callback",
"(",
"error",
")",
";",
"return",
";",
"}",
"if",
"(",
"user1",
".",
"get",
"(",
"'id'",
")",
"&&",
"user2",
".... | callback after users stored | [
"callback",
"after",
"users",
"stored"
] | d965f11e9b168d5a401d9e2627f2786b5e4bcf30 | https://github.com/tgi-io/tgi-core/blob/d965f11e9b168d5a401d9e2627f2786b5e4bcf30/lib/models/tgi-core-model-session.spec.js#L100-L114 | train |
tgi-io/tgi-core | lib/models/tgi-core-model-session.spec.js | usersStarted | function usersStarted(err, session) {
if (err)
self.badCount++;
else
self.goodCount++;
if (self.badCount == 2 && self.goodCount == 2) {
// Resume session1 correctly
new Session().resumeSession(store, ip1, session1.get('passCode'), sessionRes... | javascript | function usersStarted(err, session) {
if (err)
self.badCount++;
else
self.goodCount++;
if (self.badCount == 2 && self.goodCount == 2) {
// Resume session1 correctly
new Session().resumeSession(store, ip1, session1.get('passCode'), sessionRes... | [
"function",
"usersStarted",
"(",
"err",
",",
"session",
")",
"{",
"if",
"(",
"err",
")",
"self",
".",
"badCount",
"++",
";",
"else",
"self",
".",
"goodCount",
"++",
";",
"if",
"(",
"self",
".",
"badCount",
"==",
"2",
"&&",
"self",
".",
"goodCount",
... | callback after session started called | [
"callback",
"after",
"session",
"started",
"called"
] | d965f11e9b168d5a401d9e2627f2786b5e4bcf30 | https://github.com/tgi-io/tgi-core/blob/d965f11e9b168d5a401d9e2627f2786b5e4bcf30/lib/models/tgi-core-model-session.spec.js#L117-L127 | train |
solick/xbee-helper | src/xbee-helper.js | function(debug, milliseconds)
{
if(debug == null)
{
this_debug = false;
}
else
{
this._debug = debug;
}
if(milliseconds == null)
{
this._milliseconds = false;
}
else
{
this._milliseconds = true;
}
} | javascript | function(debug, milliseconds)
{
if(debug == null)
{
this_debug = false;
}
else
{
this._debug = debug;
}
if(milliseconds == null)
{
this._milliseconds = false;
}
else
{
this._milliseconds = true;
}
} | [
"function",
"(",
"debug",
",",
"milliseconds",
")",
"{",
"if",
"(",
"debug",
"==",
"null",
")",
"{",
"this_debug",
"=",
"false",
";",
"}",
"else",
"{",
"this",
".",
"_debug",
"=",
"debug",
";",
"}",
"if",
"(",
"milliseconds",
"==",
"null",
")",
"{"... | Class with several helper function for communication and work with xbee-api
@param debug
@constructor | [
"Class",
"with",
"several",
"helper",
"function",
"for",
"communication",
"and",
"work",
"with",
"xbee",
"-",
"api"
] | e2783b88b049cf7e227df683c86ae934b4c54cc6 | https://github.com/solick/xbee-helper/blob/e2783b88b049cf7e227df683c86ae934b4c54cc6/src/xbee-helper.js#L19-L41 | train | |
feedhenry/fh-mbaas-middleware | lib/util/requestTranslator.js | parseCreateAlertRequest | function parseCreateAlertRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.alertName = req.body.alertName;
reqObj.emails = req.body.emails;
reqObj.eventCategories = req.body.eventCategories.split(',');
reqObj.eventNames = req.body.eventNames.split(',');
reqObj.eventSeverities = ... | javascript | function parseCreateAlertRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.alertName = req.body.alertName;
reqObj.emails = req.body.emails;
reqObj.eventCategories = req.body.eventCategories.split(',');
reqObj.eventNames = req.body.eventNames.split(',');
reqObj.eventSeverities = ... | [
"function",
"parseCreateAlertRequest",
"(",
"req",
")",
"{",
"var",
"reqObj",
"=",
"{",
"}",
";",
"reqObj",
".",
"originalUrl",
"=",
"req",
".",
"originalUrl",
";",
"reqObj",
".",
"alertName",
"=",
"req",
".",
"body",
".",
"alertName",
";",
"reqObj",
"."... | Parse the incoming Create Alert Request into a common object | [
"Parse",
"the",
"incoming",
"Create",
"Alert",
"Request",
"into",
"a",
"common",
"object"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/requestTranslator.js#L15-L30 | train |
feedhenry/fh-mbaas-middleware | lib/util/requestTranslator.js | parseUpdateAlertRequest | function parseUpdateAlertRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.alertName = req.body.alertName;
reqObj.emails = req.body.emails.split(',');
reqObj.eventCategories = req.body.eventCategories.split(',');
reqObj.eventNames = req.body.eventNames.split(',');
reqObj.eventSev... | javascript | function parseUpdateAlertRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.alertName = req.body.alertName;
reqObj.emails = req.body.emails.split(',');
reqObj.eventCategories = req.body.eventCategories.split(',');
reqObj.eventNames = req.body.eventNames.split(',');
reqObj.eventSev... | [
"function",
"parseUpdateAlertRequest",
"(",
"req",
")",
"{",
"var",
"reqObj",
"=",
"{",
"}",
";",
"reqObj",
".",
"originalUrl",
"=",
"req",
".",
"originalUrl",
";",
"reqObj",
".",
"alertName",
"=",
"req",
".",
"body",
".",
"alertName",
";",
"reqObj",
"."... | Parse the incoming Update Alert Request into a common object | [
"Parse",
"the",
"incoming",
"Update",
"Alert",
"Request",
"into",
"a",
"common",
"object"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/requestTranslator.js#L76-L90 | train |
feedhenry/fh-mbaas-middleware | lib/util/requestTranslator.js | parseListRequest | function parseListRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.uid = req.params.guid;
reqObj.env = req.params.environment;
reqObj.domain = req.params.domain;
return reqObj;
} | javascript | function parseListRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.uid = req.params.guid;
reqObj.env = req.params.environment;
reqObj.domain = req.params.domain;
return reqObj;
} | [
"function",
"parseListRequest",
"(",
"req",
")",
"{",
"var",
"reqObj",
"=",
"{",
"}",
";",
"reqObj",
".",
"originalUrl",
"=",
"req",
".",
"originalUrl",
";",
"reqObj",
".",
"uid",
"=",
"req",
".",
"params",
".",
"guid",
";",
"reqObj",
".",
"env",
"="... | Parse the incoming List Alert Request into a common object | [
"Parse",
"the",
"incoming",
"List",
"Alert",
"Request",
"into",
"a",
"common",
"object"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/requestTranslator.js#L95-L102 | train |
feedhenry/fh-mbaas-middleware | lib/util/requestTranslator.js | parseDeleteRequest | function parseDeleteRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.uid = req.params.guid;
reqObj.env =req.params.environment;
reqObj.domain = req.params.domain;
reqObj._id = req.params.id;
return reqObj;
} | javascript | function parseDeleteRequest(req){
var reqObj = {};
reqObj.originalUrl = req.originalUrl;
reqObj.uid = req.params.guid;
reqObj.env =req.params.environment;
reqObj.domain = req.params.domain;
reqObj._id = req.params.id;
return reqObj;
} | [
"function",
"parseDeleteRequest",
"(",
"req",
")",
"{",
"var",
"reqObj",
"=",
"{",
"}",
";",
"reqObj",
".",
"originalUrl",
"=",
"req",
".",
"originalUrl",
";",
"reqObj",
".",
"uid",
"=",
"req",
".",
"params",
".",
"guid",
";",
"reqObj",
".",
"env",
"... | Parse the incoming Delete Alert Request into a common object | [
"Parse",
"the",
"incoming",
"Delete",
"Alert",
"Request",
"into",
"a",
"common",
"object"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/util/requestTranslator.js#L107-L115 | train |
wait1/wait1.js | lib/connection.js | parseAuth | function parseAuth(auth) {
var parts = auth.split(':');
if (parts[0] && !parts[1]) return ['wait1|t' + parts[0]];
if (!parts[0] && parts[1]) return ['wait1|t' + parts[1]];
if (!parts[0] && !parts[1]) return [];
return ['wait1|b' + (new Buffer(auth)).toString('base64')];
} | javascript | function parseAuth(auth) {
var parts = auth.split(':');
if (parts[0] && !parts[1]) return ['wait1|t' + parts[0]];
if (!parts[0] && parts[1]) return ['wait1|t' + parts[1]];
if (!parts[0] && !parts[1]) return [];
return ['wait1|b' + (new Buffer(auth)).toString('base64')];
} | [
"function",
"parseAuth",
"(",
"auth",
")",
"{",
"var",
"parts",
"=",
"auth",
".",
"split",
"(",
"':'",
")",
";",
"if",
"(",
"parts",
"[",
"0",
"]",
"&&",
"!",
"parts",
"[",
"1",
"]",
")",
"return",
"[",
"'wait1|t'",
"+",
"parts",
"[",
"0",
"]",... | Parse an auth string | [
"Parse",
"an",
"auth",
"string"
] | 4d3739a787c7b62414a049df7d88dde61a03ab32 | https://github.com/wait1/wait1.js/blob/4d3739a787c7b62414a049df7d88dde61a03ab32/lib/connection.js#L134-L140 | train |
tolokoban/ToloFrameWork | ker/com/x-img2css/x-img2css.com.js | zipSVG | function zipSVG(libs, svgContent, src) {
svgContent = svgContent
// Remove space between two tags.
.replace(/>[ \t\n\r]+</g, '><')
// Replace double quotes with single quotes.
.replace(/"/g, "'")
// Replace many spaces by one single space.
.replace(/[ \t\n\r]+/g, ' ');
var s... | javascript | function zipSVG(libs, svgContent, src) {
svgContent = svgContent
// Remove space between two tags.
.replace(/>[ \t\n\r]+</g, '><')
// Replace double quotes with single quotes.
.replace(/"/g, "'")
// Replace many spaces by one single space.
.replace(/[ \t\n\r]+/g, ' ');
var s... | [
"function",
"zipSVG",
"(",
"libs",
",",
"svgContent",
",",
"src",
")",
"{",
"svgContent",
"=",
"svgContent",
"// Remove space between two tags.",
".",
"replace",
"(",
"/",
">[ \\t\\n\\r]+<",
"/",
"g",
",",
"'><'",
")",
"// Replace double quotes with single quotes.",
... | Return the lightest SVG possible. | [
"Return",
"the",
"lightest",
"SVG",
"possible",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-img2css/x-img2css.com.js#L83-L197 | train |
tolokoban/ToloFrameWork | ker/com/x-img2css/x-img2css.com.js | startsWith | function startsWith(text) {
var i, arg;
for (i = 1 ; i < arguments.length ; i++) {
arg = arguments[i];
if (text.substr(0, arg.length) == arg) return true;
}
return false;
} | javascript | function startsWith(text) {
var i, arg;
for (i = 1 ; i < arguments.length ; i++) {
arg = arguments[i];
if (text.substr(0, arg.length) == arg) return true;
}
return false;
} | [
"function",
"startsWith",
"(",
"text",
")",
"{",
"var",
"i",
",",
"arg",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"arg",
"=",
"arguments",
"[",
"i",
"]",
";",
"if",
"(",
"text",
".",... | Return True if `text` starts by at least one of the remaining arguments. | [
"Return",
"True",
"if",
"text",
"starts",
"by",
"at",
"least",
"one",
"of",
"the",
"remaining",
"arguments",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/com/x-img2css/x-img2css.com.js#L203-L210 | train |
Amberlamps/object-subset | dist/objectSubset.js | createSubset | function createSubset(keywords, doc) {
if (!keywords || Object.prototype.toString.call(keywords) !== '[object Array]') {
return doc;
}
var lookup = createLookUp(keywords);
return traverseThroughObject(lookup, doc);
} | javascript | function createSubset(keywords, doc) {
if (!keywords || Object.prototype.toString.call(keywords) !== '[object Array]') {
return doc;
}
var lookup = createLookUp(keywords);
return traverseThroughObject(lookup, doc);
} | [
"function",
"createSubset",
"(",
"keywords",
",",
"doc",
")",
"{",
"if",
"(",
"!",
"keywords",
"||",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"keywords",
")",
"!==",
"'[object Array]'",
")",
"{",
"return",
"doc",
";",
"}",
"var",
... | createSubset is initializing the creation of the subset.
If keywords is not an array return doc immediately. | [
"createSubset",
"is",
"initializing",
"the",
"creation",
"of",
"the",
"subset",
".",
"If",
"keywords",
"is",
"not",
"an",
"array",
"return",
"doc",
"immediately",
"."
] | c96436360381a4e0c662531c18a82afc6290ea0c | https://github.com/Amberlamps/object-subset/blob/c96436360381a4e0c662531c18a82afc6290ea0c/dist/objectSubset.js#L23-L33 | train |
Amberlamps/object-subset | dist/objectSubset.js | createLookUp | function createLookUp(keywords) {
return keywords.reduce(function(p, c) {
c.split('.').reduce(function(pr, cu) {
if (pr.hasOwnProperty(cu)) {
return pr[cu];
} else {
pr[cu] = {};
return pr[cu];
}
}, p);
return p;
}, {});
} | javascript | function createLookUp(keywords) {
return keywords.reduce(function(p, c) {
c.split('.').reduce(function(pr, cu) {
if (pr.hasOwnProperty(cu)) {
return pr[cu];
} else {
pr[cu] = {};
return pr[cu];
}
}, p);
return p;
}, {});
} | [
"function",
"createLookUp",
"(",
"keywords",
")",
"{",
"return",
"keywords",
".",
"reduce",
"(",
"function",
"(",
"p",
",",
"c",
")",
"{",
"c",
".",
"split",
"(",
"'.'",
")",
".",
"reduce",
"(",
"function",
"(",
"pr",
",",
"cu",
")",
"{",
"if",
"... | createLookUp iterates over every keyword and creates a tree
where the leaves are empty objects. The lookup object is used
to be able to traverse along the input document. | [
"createLookUp",
"iterates",
"over",
"every",
"keyword",
"and",
"creates",
"a",
"tree",
"where",
"the",
"leaves",
"are",
"empty",
"objects",
".",
"The",
"lookup",
"object",
"is",
"used",
"to",
"be",
"able",
"to",
"traverse",
"along",
"the",
"input",
"document... | c96436360381a4e0c662531c18a82afc6290ea0c | https://github.com/Amberlamps/object-subset/blob/c96436360381a4e0c662531c18a82afc6290ea0c/dist/objectSubset.js#L41-L64 | train |
Amberlamps/object-subset | dist/objectSubset.js | traverseThroughObject | function traverseThroughObject(lookup, doc, output) {
if (!output) {
output = {};
}
for (var key in lookup) {
if (doc.hasOwnProperty(key)) {
if(Object.keys(lookup[key]).length === 0) {
output[key] = doc[key];
} else {
if (!output.hasOwnProperty(key)) {
... | javascript | function traverseThroughObject(lookup, doc, output) {
if (!output) {
output = {};
}
for (var key in lookup) {
if (doc.hasOwnProperty(key)) {
if(Object.keys(lookup[key]).length === 0) {
output[key] = doc[key];
} else {
if (!output.hasOwnProperty(key)) {
... | [
"function",
"traverseThroughObject",
"(",
"lookup",
",",
"doc",
",",
"output",
")",
"{",
"if",
"(",
"!",
"output",
")",
"{",
"output",
"=",
"{",
"}",
";",
"}",
"for",
"(",
"var",
"key",
"in",
"lookup",
")",
"{",
"if",
"(",
"doc",
".",
"hasOwnProper... | traverseThroughObject is traversing through the object
by the fields described in lookup and filling the
output object accordingly in the process. | [
"traverseThroughObject",
"is",
"traversing",
"through",
"the",
"object",
"by",
"the",
"fields",
"described",
"in",
"lookup",
"and",
"filling",
"the",
"output",
"object",
"accordingly",
"in",
"the",
"process",
"."
] | c96436360381a4e0c662531c18a82afc6290ea0c | https://github.com/Amberlamps/object-subset/blob/c96436360381a4e0c662531c18a82afc6290ea0c/dist/objectSubset.js#L72-L116 | train |
Alhadis/Chai-Untab | chai-untab.js | setUntab | function setUntab(depth, trim){
started = true;
/** Disable untab */
if(!depth){
_depth = null;
_trim = false;
}
else{
_depth = depth;
_trim = trim;
}
} | javascript | function setUntab(depth, trim){
started = true;
/** Disable untab */
if(!depth){
_depth = null;
_trim = false;
}
else{
_depth = depth;
_trim = trim;
}
} | [
"function",
"setUntab",
"(",
"depth",
",",
"trim",
")",
"{",
"started",
"=",
"true",
";",
"/** Disable untab */",
"if",
"(",
"!",
"depth",
")",
"{",
"_depth",
"=",
"null",
";",
"_trim",
"=",
"false",
";",
"}",
"else",
"{",
"_depth",
"=",
"depth",
";"... | Set unindentation settings for this suite level.
@param {Number} depth
@param {Boolean} trim
@private | [
"Set",
"unindentation",
"settings",
"for",
"this",
"suite",
"level",
"."
] | 4669cdf71a46d4370ade92ef387709615d5eb204 | https://github.com/Alhadis/Chai-Untab/blob/4669cdf71a46d4370ade92ef387709615d5eb204/chai-untab.js#L67-L80 | train |
Alhadis/Chai-Untab | chai-untab.js | doUntab | function doUntab(input, depth = undefined, trim = undefined){
/** Not a string? Leave it. */
if("[object String]" !== Object.prototype.toString.call(input))
return input;
if(trim === undefined) trim = _trim;
if(depth === undefined) depth = _depth;
/** Strip leading and trailing lines if told to */
if(tr... | javascript | function doUntab(input, depth = undefined, trim = undefined){
/** Not a string? Leave it. */
if("[object String]" !== Object.prototype.toString.call(input))
return input;
if(trim === undefined) trim = _trim;
if(depth === undefined) depth = _depth;
/** Strip leading and trailing lines if told to */
if(tr... | [
"function",
"doUntab",
"(",
"input",
",",
"depth",
"=",
"undefined",
",",
"trim",
"=",
"undefined",
")",
"{",
"/** Not a string? Leave it. */",
"if",
"(",
"\"[object String]\"",
"!==",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"input",
")"... | Remove leading indentation using Chai's current untab- settings.
Called automatically, but exposed for external use. If the supplied
argument isn't a string, it's returned untouched without further ado.
Arguments beyond the first are optional: if either depth or trim are
omitted, they default to those set for the cur... | [
"Remove",
"leading",
"indentation",
"using",
"Chai",
"s",
"current",
"untab",
"-",
"settings",
"."
] | 4669cdf71a46d4370ade92ef387709615d5eb204 | https://github.com/Alhadis/Chai-Untab/blob/4669cdf71a46d4370ade92ef387709615d5eb204/chai-untab.js#L98-L113 | train |
Alhadis/Chai-Untab | chai-untab.js | hookIntoChai | function hookIntoChai(){
if(hooked) return;
hooked = true;
for(const method of ["equal", "string"]){
Chai.Assertion.overwriteMethod(method, function(__super){
return function(input, ...rest){
__super.apply(this, [ doUntab(input), ...rest ]);
}
});
}
} | javascript | function hookIntoChai(){
if(hooked) return;
hooked = true;
for(const method of ["equal", "string"]){
Chai.Assertion.overwriteMethod(method, function(__super){
return function(input, ...rest){
__super.apply(this, [ doUntab(input), ...rest ]);
}
});
}
} | [
"function",
"hookIntoChai",
"(",
")",
"{",
"if",
"(",
"hooked",
")",
"return",
";",
"hooked",
"=",
"true",
";",
"for",
"(",
"const",
"method",
"of",
"[",
"\"equal\"",
",",
"\"string\"",
"]",
")",
"{",
"Chai",
".",
"Assertion",
".",
"overwriteMethod",
"... | Overwrite the necessary Chai methods for comparing string-blocks.
Only executed the first time Chai.untab is set.
@private | [
"Overwrite",
"the",
"necessary",
"Chai",
"methods",
"for",
"comparing",
"string",
"-",
"blocks",
"."
] | 4669cdf71a46d4370ade92ef387709615d5eb204 | https://github.com/Alhadis/Chai-Untab/blob/4669cdf71a46d4370ade92ef387709615d5eb204/chai-untab.js#L122-L133 | train |
Xen3r0/pagesJson_uirouter | tasks/pagesJson_uirouter.js | objectToString | function objectToString(object, tabs) {
var result = [];
var keys = Object.keys(object);
keys.forEach(function (key, keyIndex) {
var line;
var formatedKey;
if (-1 < key.indexOf('@')) {
formatedKey = '\'' + key + '\... | javascript | function objectToString(object, tabs) {
var result = [];
var keys = Object.keys(object);
keys.forEach(function (key, keyIndex) {
var line;
var formatedKey;
if (-1 < key.indexOf('@')) {
formatedKey = '\'' + key + '\... | [
"function",
"objectToString",
"(",
"object",
",",
"tabs",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
";",
"keys",
".",
"forEach",
"(",
"function",
"(",
"key",
",",
"keyIndex",
")",
... | Transformer un objet en chaine
@param {Object} object
@param {Number} tabs | [
"Transformer",
"un",
"objet",
"en",
"chaine"
] | 2d15ec9cac71c010073ff812239613f3ab101ba2 | https://github.com/Xen3r0/pagesJson_uirouter/blob/2d15ec9cac71c010073ff812239613f3ab101ba2/tasks/pagesJson_uirouter.js#L81-L141 | train |
Xen3r0/pagesJson_uirouter | tasks/pagesJson_uirouter.js | stateRefSearch | function stateRefSearch(pages, stateName) {
for (var i = 0; i < pages.length; i++) {
if (pages[i].name === stateName) {
return pages[i];
}
}
return null;
} | javascript | function stateRefSearch(pages, stateName) {
for (var i = 0; i < pages.length; i++) {
if (pages[i].name === stateName) {
return pages[i];
}
}
return null;
} | [
"function",
"stateRefSearch",
"(",
"pages",
",",
"stateName",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"pages",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pages",
"[",
"i",
"]",
".",
"name",
"===",
"stateName",
")",
... | Chercher une state
@param {Object[]} pages
@param {String} stateName
@returns {null|Object} | [
"Chercher",
"une",
"state"
] | 2d15ec9cac71c010073ff812239613f3ab101ba2 | https://github.com/Xen3r0/pagesJson_uirouter/blob/2d15ec9cac71c010073ff812239613f3ab101ba2/tasks/pagesJson_uirouter.js#L312-L320 | train |
Xen3r0/pagesJson_uirouter | tasks/pagesJson_uirouter.js | isEmpty | function isEmpty(str) {
if (null === str || typeof str === 'undefined') {
return true;
}
if (typeof str === 'string') {
return (0 === str.length);
}
if (typeof str === 'object' && Array.isArray(str)) {
return (... | javascript | function isEmpty(str) {
if (null === str || typeof str === 'undefined') {
return true;
}
if (typeof str === 'string') {
return (0 === str.length);
}
if (typeof str === 'object' && Array.isArray(str)) {
return (... | [
"function",
"isEmpty",
"(",
"str",
")",
"{",
"if",
"(",
"null",
"===",
"str",
"||",
"typeof",
"str",
"===",
"'undefined'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"typeof",
"str",
"===",
"'string'",
")",
"{",
"return",
"(",
"0",
"===",
"st... | Chaine vide ?
@param {*} str
@returns {Boolean} | [
"Chaine",
"vide",
"?"
] | 2d15ec9cac71c010073ff812239613f3ab101ba2 | https://github.com/Xen3r0/pagesJson_uirouter/blob/2d15ec9cac71c010073ff812239613f3ab101ba2/tasks/pagesJson_uirouter.js#L327-L341 | train |
alantu/queues | lib/sqs.js | Provider | function Provider(id, secret) {
if (!(this instanceof Provider)) {
return new Provider(id, secret);
}
this.client = new AWS.SQS({
accessKeyId: id,
secretAccessKey: secret,
region: 'us-east-1'
});
this.queues = {};
} | javascript | function Provider(id, secret) {
if (!(this instanceof Provider)) {
return new Provider(id, secret);
}
this.client = new AWS.SQS({
accessKeyId: id,
secretAccessKey: secret,
region: 'us-east-1'
});
this.queues = {};
} | [
"function",
"Provider",
"(",
"id",
",",
"secret",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Provider",
")",
")",
"{",
"return",
"new",
"Provider",
"(",
"id",
",",
"secret",
")",
";",
"}",
"this",
".",
"client",
"=",
"new",
"AWS",
".",
... | AWS SQS provider
@class Provider | [
"AWS",
"SQS",
"provider"
] | 709bf8688b662e3ccbb67647a30bbd69066d9996 | https://github.com/alantu/queues/blob/709bf8688b662e3ccbb67647a30bbd69066d9996/lib/sqs.js#L24-L36 | train |
whyhankee/oap | oap.js | checkAdd | function checkAdd(list, key, func) {
list.push({key: key, func: func});
} | javascript | function checkAdd(list, key, func) {
list.push({key: key, func: func});
} | [
"function",
"checkAdd",
"(",
"list",
",",
"key",
",",
"func",
")",
"{",
"list",
".",
"push",
"(",
"{",
"key",
":",
"key",
",",
"func",
":",
"func",
"}",
")",
";",
"}"
] | Argument checking flow | [
"Argument",
"checking",
"flow"
] | 668133c1fd9bc28eb7f5f66630b99611d228120e | https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L113-L115 | train |
whyhankee/oap | oap.js | checksDo | function checksDo(listChecks, cb) {
if (listChecks.length === 0) {
return cb();
}
var check = listChecks.shift();
check.func(check.key, function () {
// schedule the next check
setImmediate(checksDo, listChecks, cb);
});
} | javascript | function checksDo(listChecks, cb) {
if (listChecks.length === 0) {
return cb();
}
var check = listChecks.shift();
check.func(check.key, function () {
// schedule the next check
setImmediate(checksDo, listChecks, cb);
});
} | [
"function",
"checksDo",
"(",
"listChecks",
",",
"cb",
")",
"{",
"if",
"(",
"listChecks",
".",
"length",
"===",
"0",
")",
"{",
"return",
"cb",
"(",
")",
";",
"}",
"var",
"check",
"=",
"listChecks",
".",
"shift",
"(",
")",
";",
"check",
".",
"func",
... | Do all the checks in the list | [
"Do",
"all",
"the",
"checks",
"in",
"the",
"list"
] | 668133c1fd9bc28eb7f5f66630b99611d228120e | https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L136-L146 | train |
whyhankee/oap | oap.js | checkRequired | function checkRequired(k, cb) {
if (k in args)
return cb(null);
else
return cb(buildError(k, 'argument missing'));
} | javascript | function checkRequired(k, cb) {
if (k in args)
return cb(null);
else
return cb(buildError(k, 'argument missing'));
} | [
"function",
"checkRequired",
"(",
"k",
",",
"cb",
")",
"{",
"if",
"(",
"k",
"in",
"args",
")",
"return",
"cb",
"(",
"null",
")",
";",
"else",
"return",
"cb",
"(",
"buildError",
"(",
"k",
",",
"'argument missing'",
")",
")",
";",
"}"
] | The argument checking functions | [
"The",
"argument",
"checking",
"functions"
] | 668133c1fd9bc28eb7f5f66630b99611d228120e | https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L151-L156 | train |
whyhankee/oap | oap.js | buildError | function buildError(k, message) {
if (!Array.isArray(errors[k])) errors[k] = [];
errors[k].push(message);
} | javascript | function buildError(k, message) {
if (!Array.isArray(errors[k])) errors[k] = [];
errors[k].push(message);
} | [
"function",
"buildError",
"(",
"k",
",",
"message",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"errors",
"[",
"k",
"]",
")",
")",
"errors",
"[",
"k",
"]",
"=",
"[",
"]",
";",
"errors",
"[",
"k",
"]",
".",
"push",
"(",
"message",
... | Add's error to the errors object; | [
"Add",
"s",
"error",
"to",
"the",
"errors",
"object",
";"
] | 668133c1fd9bc28eb7f5f66630b99611d228120e | https://github.com/whyhankee/oap/blob/668133c1fd9bc28eb7f5f66630b99611d228120e/oap.js#L195-L198 | train |
wzr1337/grunt-closure-linter | tasks/lib/common.js | function(options, opt_fileList, opt_dirList) {
var cmd = '';
// Detect if the tool file is a python script. If so we need to
// prefix the exec command with 'python'.
if (stringEndsWith(options.toolFile, '.py')) {
cmd += 'python ';
}
// Normalize the folder path and join the tool file.
cmd += path.... | javascript | function(options, opt_fileList, opt_dirList) {
var cmd = '';
// Detect if the tool file is a python script. If so we need to
// prefix the exec command with 'python'.
if (stringEndsWith(options.toolFile, '.py')) {
cmd += 'python ';
}
// Normalize the folder path and join the tool file.
cmd += path.... | [
"function",
"(",
"options",
",",
"opt_fileList",
",",
"opt_dirList",
")",
"{",
"var",
"cmd",
"=",
"''",
";",
"// Detect if the tool file is a python script. If so we need to",
"// prefix the exec command with 'python'.",
"if",
"(",
"stringEndsWith",
"(",
"options",
".",
"... | Create the linter command.
@param {object} options Grunt options.
@param {array=} opt_fileList List of source files to be linted.
@param {array=} opt_dirList List of directories to be linted. | [
"Create",
"the",
"linter",
"command",
"."
] | c4ee930d6d384c2d25207bbe1ca01c852d5e092e | https://github.com/wzr1337/grunt-closure-linter/blob/c4ee930d6d384c2d25207bbe1ca01c852d5e092e/tasks/lib/common.js#L38-L65 | train | |
wzr1337/grunt-closure-linter | tasks/lib/common.js | function(results, filePath) {
var destDir = path.dirname(filePath);
if (!grunt.file.exists(destDir)) {
grunt.file.mkdir(destDir);
}
grunt.file.write(filePath, results);
grunt.log.ok('File "' + filePath + '" created.');
} | javascript | function(results, filePath) {
var destDir = path.dirname(filePath);
if (!grunt.file.exists(destDir)) {
grunt.file.mkdir(destDir);
}
grunt.file.write(filePath, results);
grunt.log.ok('File "' + filePath + '" created.');
} | [
"function",
"(",
"results",
",",
"filePath",
")",
"{",
"var",
"destDir",
"=",
"path",
".",
"dirname",
"(",
"filePath",
")",
";",
"if",
"(",
"!",
"grunt",
".",
"file",
".",
"exists",
"(",
"destDir",
")",
")",
"{",
"grunt",
".",
"file",
".",
"mkdir",... | Writes linter |results| to file.
@param {!string} results Linter results as a string.
@param {!string} filePath Path to the file. | [
"Writes",
"linter",
"|results|",
"to",
"file",
"."
] | c4ee930d6d384c2d25207bbe1ca01c852d5e092e | https://github.com/wzr1337/grunt-closure-linter/blob/c4ee930d6d384c2d25207bbe1ca01c852d5e092e/tasks/lib/common.js#L73-L83 | train | |
gethuman/pancakes-recipe | middleware/mw.app.context.js | setLanguage | function setLanguage(req) {
var host = req.info.host;
// hack fix for m.reviews, m.fr, m.es, etc.
if (host.substring(0, 2) === 'm.') {
req.app.isLegacyMobile = true;
host = host.substring(2);
}
var subdomain = host.substring(0, 2);
// either at ... | javascript | function setLanguage(req) {
var host = req.info.host;
// hack fix for m.reviews, m.fr, m.es, etc.
if (host.substring(0, 2) === 'm.') {
req.app.isLegacyMobile = true;
host = host.substring(2);
}
var subdomain = host.substring(0, 2);
// either at ... | [
"function",
"setLanguage",
"(",
"req",
")",
"{",
"var",
"host",
"=",
"req",
".",
"info",
".",
"host",
";",
"// hack fix for m.reviews, m.fr, m.es, etc.",
"if",
"(",
"host",
".",
"substring",
"(",
"0",
",",
"2",
")",
"===",
"'m.'",
")",
"{",
"req",
".",
... | Set the language depending on a couple different potential sources
@param req | [
"Set",
"the",
"language",
"depending",
"on",
"a",
"couple",
"different",
"potential",
"sources"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L14-L28 | train |
gethuman/pancakes-recipe | middleware/mw.app.context.js | setAppInfo | function setAppInfo(req, domainMap) {
var host = req.info.hostname;
var domain;
// hack fix for m.reviews, m.fr, m.es, etc.
if (host.substring(0, 2) === 'm.') {
req.app.isLegacyMobile = true;
host = host.substring(2);
}
// if the host starts with... | javascript | function setAppInfo(req, domainMap) {
var host = req.info.hostname;
var domain;
// hack fix for m.reviews, m.fr, m.es, etc.
if (host.substring(0, 2) === 'm.') {
req.app.isLegacyMobile = true;
host = host.substring(2);
}
// if the host starts with... | [
"function",
"setAppInfo",
"(",
"req",
",",
"domainMap",
")",
"{",
"var",
"host",
"=",
"req",
".",
"info",
".",
"hostname",
";",
"var",
"domain",
";",
"// hack fix for m.reviews, m.fr, m.es, etc.",
"if",
"(",
"host",
".",
"substring",
"(",
"0",
",",
"2",
")... | Set the app domain and name
@param req
@param domainMap Key is subdomain value, value is the name of the app | [
"Set",
"the",
"app",
"domain",
"and",
"name"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L35-L78 | train |
gethuman/pancakes-recipe | middleware/mw.app.context.js | setContext | function setContext(req) {
var session = cls.getNamespace('appSession');
var appName = req.app.name;
if (session && session.active) {
session.set('app', appName);
session.set('lang', req.app.lang);
session.set('url', routeHelper.getBaseUrl(appName) + req.url.... | javascript | function setContext(req) {
var session = cls.getNamespace('appSession');
var appName = req.app.name;
if (session && session.active) {
session.set('app', appName);
session.set('lang', req.app.lang);
session.set('url', routeHelper.getBaseUrl(appName) + req.url.... | [
"function",
"setContext",
"(",
"req",
")",
"{",
"var",
"session",
"=",
"cls",
".",
"getNamespace",
"(",
"'appSession'",
")",
";",
"var",
"appName",
"=",
"req",
".",
"app",
".",
"name",
";",
"if",
"(",
"session",
"&&",
"session",
".",
"active",
")",
"... | Set the context into CLS for later usage
@param req | [
"Set",
"the",
"context",
"into",
"CLS",
"for",
"later",
"usage"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L84-L93 | train |
gethuman/pancakes-recipe | middleware/mw.app.context.js | getDomainMap | function getDomainMap() {
var domainMap = { 'www': 'www' }; // temp hack for mobile redirect stuff (remove later)
_.each(appConfigs, function (appConfig, appName) {
var domain = appConfig.domain || appName; // by default domain is the app name
domainMap[domain] = appName;
... | javascript | function getDomainMap() {
var domainMap = { 'www': 'www' }; // temp hack for mobile redirect stuff (remove later)
_.each(appConfigs, function (appConfig, appName) {
var domain = appConfig.domain || appName; // by default domain is the app name
domainMap[domain] = appName;
... | [
"function",
"getDomainMap",
"(",
")",
"{",
"var",
"domainMap",
"=",
"{",
"'www'",
":",
"'www'",
"}",
";",
"// temp hack for mobile redirect stuff (remove later)",
"_",
".",
"each",
"(",
"appConfigs",
",",
"function",
"(",
"appConfig",
",",
"appName",
")",
"{",
... | Get the domain map by inspecting the app files
@returns {{}} | [
"Get",
"the",
"domain",
"map",
"by",
"inspecting",
"the",
"app",
"files"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L99-L107 | train |
gethuman/pancakes-recipe | middleware/mw.app.context.js | init | function init(ctx) {
var domainMap = getDomainMap();
// for each request we need to set the proper context
ctx.server.ext('onRequest', function (req, reply) {
setLanguage(req);
setAppInfo(req, domainMap);
var appName = req.app.name;
var lang = re... | javascript | function init(ctx) {
var domainMap = getDomainMap();
// for each request we need to set the proper context
ctx.server.ext('onRequest', function (req, reply) {
setLanguage(req);
setAppInfo(req, domainMap);
var appName = req.app.name;
var lang = re... | [
"function",
"init",
"(",
"ctx",
")",
"{",
"var",
"domainMap",
"=",
"getDomainMap",
"(",
")",
";",
"// for each request we need to set the proper context",
"ctx",
".",
"server",
".",
"ext",
"(",
"'onRequest'",
",",
"function",
"(",
"req",
",",
"reply",
")",
"{"... | Figure out the language and target app
@param ctx
@returns {Q} | [
"Figure",
"out",
"the",
"language",
"and",
"target",
"app"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.app.context.js#L114-L135 | train |
appsngen/generator-appsngen-web-widget | app/index.js | function (directoryNames) {
var i, directoryName;
for (i = 0; i < directoryNames.length; i++) {
directoryName = directoryNames[i];
mkdirp.sync(directoryName);
// make output similar to yeoman's
console.log(' ' + chalk.green('create') + ' ' + directoryN... | javascript | function (directoryNames) {
var i, directoryName;
for (i = 0; i < directoryNames.length; i++) {
directoryName = directoryNames[i];
mkdirp.sync(directoryName);
// make output similar to yeoman's
console.log(' ' + chalk.green('create') + ' ' + directoryN... | [
"function",
"(",
"directoryNames",
")",
"{",
"var",
"i",
",",
"directoryName",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"directoryNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"directoryName",
"=",
"directoryNames",
"[",
"i",
"]",
";",
"mkdi... | copyFiles doesn't create empty folders so we need to create them manually | [
"copyFiles",
"doesn",
"t",
"create",
"empty",
"folders",
"so",
"we",
"need",
"to",
"create",
"them",
"manually"
] | f10e55bcf6742abf7a555294385070f25be467c8 | https://github.com/appsngen/generator-appsngen-web-widget/blob/f10e55bcf6742abf7a555294385070f25be467c8/app/index.js#L42-L52 | train | |
cemtopkaya/kuark-db | src/db_ihale.js | f_teklif_tumu | function f_teklif_tumu(_tahta_id, _ihale_id, _arama) {
return f_teklif_idleri(_tahta_id, _ihale_id, _arama.Sayfalama)
.then(
/**
*
* @param {string[]} _teklif_idler
* @returns {*}
*/
functio... | javascript | function f_teklif_tumu(_tahta_id, _ihale_id, _arama) {
return f_teklif_idleri(_tahta_id, _ihale_id, _arama.Sayfalama)
.then(
/**
*
* @param {string[]} _teklif_idler
* @returns {*}
*/
functio... | [
"function",
"f_teklif_tumu",
"(",
"_tahta_id",
",",
"_ihale_id",
",",
"_arama",
")",
"{",
"return",
"f_teklif_idleri",
"(",
"_tahta_id",
",",
"_ihale_id",
",",
"_arama",
".",
"Sayfalama",
")",
".",
"then",
"(",
"/**\r\n *\r\n * @param {... | ihaleye ait teklifleri bulur
@param {integer} _tahta_id
@param {integer} _ihale_id
@param {URLQuery} _arama
@returns {Promise} | [
"ihaleye",
"ait",
"teklifleri",
"bulur"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/src/db_ihale.js#L270-L314 | train |
redisjs/jsr-conf | lib/encoder.js | Encoder | function Encoder(options) {
Transform.call(this);
this._writableState.objectMode = true;
this._readableState.objectMode = false;
this.eol = options.eol;
} | javascript | function Encoder(options) {
Transform.call(this);
this._writableState.objectMode = true;
this._readableState.objectMode = false;
this.eol = options.eol;
} | [
"function",
"Encoder",
"(",
"options",
")",
"{",
"Transform",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_writableState",
".",
"objectMode",
"=",
"true",
";",
"this",
".",
"_readableState",
".",
"objectMode",
"=",
"false",
";",
"this",
".",
"eol",... | Configuration file encoder. | [
"Configuration",
"file",
"encoder",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/encoder.js#L7-L14 | train |
SoftwarePlumbers/abstract-query | src/range.js | isComparable | function isComparable(object) {
let type = typeof object;
if (type === 'number' || type === 'string' || type == 'boolean') return true;
if (type === 'object' && object instanceof Date) return true;
return false;
} | javascript | function isComparable(object) {
let type = typeof object;
if (type === 'number' || type === 'string' || type == 'boolean') return true;
if (type === 'object' && object instanceof Date) return true;
return false;
} | [
"function",
"isComparable",
"(",
"object",
")",
"{",
"let",
"type",
"=",
"typeof",
"object",
";",
"if",
"(",
"type",
"===",
"'number'",
"||",
"type",
"===",
"'string'",
"||",
"type",
"==",
"'boolean'",
")",
"return",
"true",
";",
"if",
"(",
"type",
"==... | Types on which comparison operators are valid.
@typedef {number|string|boolean|Date} Comparable
Return true if object is one of the comparable types
@param object - object to test
@returns true if object is comparable (@see Comparable) | [
"Types",
"on",
"which",
"comparison",
"operators",
"are",
"valid",
"."
] | b67f40cf20f392d7eb00bca31aedec58de55ceff | https://github.com/SoftwarePlumbers/abstract-query/blob/b67f40cf20f392d7eb00bca31aedec58de55ceff/src/range.js#L27-L32 | train |
gethuman/pancakes-recipe | utils/casing.js | dashCase | function dashCase(str) {
var newStr = '';
for (var i = 0, len = str.length; i < len; i++) {
if (str[i] === str[i].toUpperCase()) { newStr += '-'; }
newStr += str[i].toLowerCase();
}
return newStr;
} | javascript | function dashCase(str) {
var newStr = '';
for (var i = 0, len = str.length; i < len; i++) {
if (str[i] === str[i].toUpperCase()) { newStr += '-'; }
newStr += str[i].toLowerCase();
}
return newStr;
} | [
"function",
"dashCase",
"(",
"str",
")",
"{",
"var",
"newStr",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"str",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"str",
"[",
"i",
"]",
"===",
... | Convert a camelCase string into dash case
@param str | [
"Convert",
"a",
"camelCase",
"string",
"into",
"dash",
"case"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/casing.js#L41-L50 | train |
SoftwarePlumbers/db-plumbing-map | store.js | defaultComparator | function defaultComparator(key, a, b) {
if (key(a) < key(b)) return -1;
if (key(a) > key(b)) return 1;
return 0;
} | javascript | function defaultComparator(key, a, b) {
if (key(a) < key(b)) return -1;
if (key(a) > key(b)) return 1;
return 0;
} | [
"function",
"defaultComparator",
"(",
"key",
",",
"a",
",",
"b",
")",
"{",
"if",
"(",
"key",
"(",
"a",
")",
"<",
"key",
"(",
"b",
")",
")",
"return",
"-",
"1",
";",
"if",
"(",
"key",
"(",
"a",
")",
">",
"key",
"(",
"b",
")",
")",
"return",
... | Default comparison operation.
@param key {Function} function that extracts a key value (number or string) from a stored object
@param a {Object} First object
@param b {Object} Second object
@returns {boolean} -1, 1, 0 depending on whether a < b, b < a, or a == b | [
"Default",
"comparison",
"operation",
"."
] | fef5f4db895ccd2817b8ba9179b18b0252b8b0a6 | https://github.com/SoftwarePlumbers/db-plumbing-map/blob/fef5f4db895ccd2817b8ba9179b18b0252b8b0a6/store.js#L18-L22 | train |
nearform/docker-container | lib/localExecutor.js | function(mode, targetHost, system, containerDef, container, out, cb) {
if (container.specific && container.specific.dockerContainerId) {
var stopCmd = commands.kill.replace('__TARGETID__', container.specific.dockerContainerId);
executor.exec(mode, stopCmd, config.imageCachePath, out, function(err) {
... | javascript | function(mode, targetHost, system, containerDef, container, out, cb) {
if (container.specific && container.specific.dockerContainerId) {
var stopCmd = commands.kill.replace('__TARGETID__', container.specific.dockerContainerId);
executor.exec(mode, stopCmd, config.imageCachePath, out, function(err) {
... | [
"function",
"(",
"mode",
",",
"targetHost",
",",
"system",
",",
"containerDef",
",",
"container",
",",
"out",
",",
"cb",
")",
"{",
"if",
"(",
"container",
".",
"specific",
"&&",
"container",
".",
"specific",
".",
"dockerContainerId",
")",
"{",
"var",
"st... | stop needs to | [
"stop",
"needs",
"to"
] | 724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17 | https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/localExecutor.js#L106-L117 | train | |
nearform/docker-container | lib/localExecutor.js | function(mode, targetHost, system, containerDef, container, out, newConfig, cb) {
if (container.specific && container.specific.dockerContainerId && container.specific.configPath && container.specific.hup) {
tmp.file(function(err, path) {
if (err) { return cb(err); }
fs.writeFile(path, newCon... | javascript | function(mode, targetHost, system, containerDef, container, out, newConfig, cb) {
if (container.specific && container.specific.dockerContainerId && container.specific.configPath && container.specific.hup) {
tmp.file(function(err, path) {
if (err) { return cb(err); }
fs.writeFile(path, newCon... | [
"function",
"(",
"mode",
",",
"targetHost",
",",
"system",
",",
"containerDef",
",",
"container",
",",
"out",
",",
"newConfig",
",",
"cb",
")",
"{",
"if",
"(",
"container",
".",
"specific",
"&&",
"container",
".",
"specific",
".",
"dockerContainerId",
"&&"... | provide a new config and hup the container internal daemon | [
"provide",
"a",
"new",
"config",
"and",
"hup",
"the",
"container",
"internal",
"daemon"
] | 724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17 | https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/localExecutor.js#L133-L157 | train | |
samplx/samplx-agentdb | utils/check-status.js | addInsert | function addInsert(agent) {
/*
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`userAgent` VARCHAR(255) NOT NULL,
`agentGroup_id` INT UNSIGNED NOT NULL DEFAULT '1',
`agentSource_id` INT UNSIGNED NOT NULL DEFAULT '1',
`timesReported` INT UNSIGNED NOT NULL DEFAULT '1',
`status` TINYINT UNSI... | javascript | function addInsert(agent) {
/*
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`userAgent` VARCHAR(255) NOT NULL,
`agentGroup_id` INT UNSIGNED NOT NULL DEFAULT '1',
`agentSource_id` INT UNSIGNED NOT NULL DEFAULT '1',
`timesReported` INT UNSIGNED NOT NULL DEFAULT '1',
`status` TINYINT UNSI... | [
"function",
"addInsert",
"(",
"agent",
")",
"{",
"/*\n `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `userAgent` VARCHAR(255) NOT NULL,\n `agentGroup_id` INT UNSIGNED NOT NULL DEFAULT '1',\n `agentSource_id` INT UNSIGNED NOT NULL DEFAULT '1',\n `timesReported` INT UNSIGNED NOT ... | create an INSERT statement to add a user-agent.
This is normally not needed since the agents.json file comes from
the database to which the data would be inserted. | [
"create",
"an",
"INSERT",
"statement",
"to",
"add",
"a",
"user",
"-",
"agent",
".",
"This",
"is",
"normally",
"not",
"needed",
"since",
"the",
"agents",
".",
"json",
"file",
"comes",
"from",
"the",
"database",
"to",
"which",
"the",
"data",
"would",
"be",... | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/check-status.js#L54-L71 | train |
samplx/samplx-agentdb | utils/check-status.js | updateAgent | function updateAgent(id, group, source, status) {
var groupId = groups.indexOf(group);
if (groupId <= 0) {
console.error("ERROR: group='" + group + "' was not found.");
return;
}
var sourceId = sources.indexOf(source);
if (sourceId <= 0) {
console.error("ERROR: source='" + so... | javascript | function updateAgent(id, group, source, status) {
var groupId = groups.indexOf(group);
if (groupId <= 0) {
console.error("ERROR: group='" + group + "' was not found.");
return;
}
var sourceId = sources.indexOf(source);
if (sourceId <= 0) {
console.error("ERROR: source='" + so... | [
"function",
"updateAgent",
"(",
"id",
",",
"group",
",",
"source",
",",
"status",
")",
"{",
"var",
"groupId",
"=",
"groups",
".",
"indexOf",
"(",
"group",
")",
";",
"if",
"(",
"groupId",
"<=",
"0",
")",
"{",
"console",
".",
"error",
"(",
"\"ERROR: gr... | create an UPDATE statement to set Agent status, groupId and sourceId.
@param id Agent.id
@param group string.
@param source string. | [
"create",
"an",
"UPDATE",
"statement",
"to",
"set",
"Agent",
"status",
"groupId",
"and",
"sourceId",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/check-status.js#L90-L105 | train |
samplx/samplx-agentdb | utils/check-status.js | main | function main() {
agents.forEach(function (agent) {
var r = agentdb.lookupPattern(agent.agent);
if (r !== null) {
if (agent.groupId == 1) { // Unknown group -> update agent
updateAgent(agent.id, r.group, r.source, 2);
} else if (agent.status != 1) {
... | javascript | function main() {
agents.forEach(function (agent) {
var r = agentdb.lookupPattern(agent.agent);
if (r !== null) {
if (agent.groupId == 1) { // Unknown group -> update agent
updateAgent(agent.id, r.group, r.source, 2);
} else if (agent.status != 1) {
... | [
"function",
"main",
"(",
")",
"{",
"agents",
".",
"forEach",
"(",
"function",
"(",
"agent",
")",
"{",
"var",
"r",
"=",
"agentdb",
".",
"lookupPattern",
"(",
"agent",
".",
"agent",
")",
";",
"if",
"(",
"r",
"!==",
"null",
")",
"{",
"if",
"(",
"age... | check-status main function. | [
"check",
"-",
"status",
"main",
"function",
"."
] | 4ded3176c8a9dceb3f2017f66581929d3cfc1084 | https://github.com/samplx/samplx-agentdb/blob/4ded3176c8a9dceb3f2017f66581929d3cfc1084/utils/check-status.js#L110-L158 | train |
kimvin/hny-gulp-htmlcs | src/index.js | onStreamEnd | function onStreamEnd(done) {
Promise
.all(lintPromiseList)
.then(passLintResultsThroughReporters)
.then(lintResults => {
process.nextTick(() => {
const errorCount = lintResults.reduce((sum, res) => {
const errors = res.results[0].warnings.filter(isErrorSeverity);
... | javascript | function onStreamEnd(done) {
Promise
.all(lintPromiseList)
.then(passLintResultsThroughReporters)
.then(lintResults => {
process.nextTick(() => {
const errorCount = lintResults.reduce((sum, res) => {
const errors = res.results[0].warnings.filter(isErrorSeverity);
... | [
"function",
"onStreamEnd",
"(",
"done",
")",
"{",
"Promise",
".",
"all",
"(",
"lintPromiseList",
")",
".",
"then",
"(",
"passLintResultsThroughReporters",
")",
".",
"then",
"(",
"lintResults",
"=>",
"{",
"process",
".",
"nextTick",
"(",
"(",
")",
"=>",
"{"... | Resolves promises and provides accumulated report to reporters.
@param {Function} done - Stream completion callback.
@return {undefined} Nothing is returned (done callback is used instead). | [
"Resolves",
"promises",
"and",
"provides",
"accumulated",
"report",
"to",
"reporters",
"."
] | c7dd41dc4e6f572a8adf995f0e07ea9fc367c8dc | https://github.com/kimvin/hny-gulp-htmlcs/blob/c7dd41dc4e6f572a8adf995f0e07ea9fc367c8dc/src/index.js#L178-L203 | train |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/heatmap.src.js | function (userOptions) {
Axis.prototype.setOptions.call(this, userOptions);
this.options.crosshair = this.options.marker;
this.coll = 'colorAxis';
} | javascript | function (userOptions) {
Axis.prototype.setOptions.call(this, userOptions);
this.options.crosshair = this.options.marker;
this.coll = 'colorAxis';
} | [
"function",
"(",
"userOptions",
")",
"{",
"Axis",
".",
"prototype",
".",
"setOptions",
".",
"call",
"(",
"this",
",",
"userOptions",
")",
";",
"this",
".",
"options",
".",
"crosshair",
"=",
"this",
".",
"options",
".",
"marker",
";",
"this",
".",
"coll... | Extend the setOptions method to process extreme colors and color
stops. | [
"Extend",
"the",
"setOptions",
"method",
"to",
"process",
"extreme",
"colors",
"and",
"color",
"stops",
"."
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L175-L180 | train | |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/heatmap.src.js | function (value, point) {
var pos,
stops = this.stops,
from,
to,
color,
dataClasses = this.dataClasses,
dataClass,
i;
if (dataClasses) {
i = dataClasses.length;
while (i--) {
dataClass = dataClasses[i];
from = dataClass.from;
to = dataClass.to;
if ((from === UNDEFINED || ... | javascript | function (value, point) {
var pos,
stops = this.stops,
from,
to,
color,
dataClasses = this.dataClasses,
dataClass,
i;
if (dataClasses) {
i = dataClasses.length;
while (i--) {
dataClass = dataClasses[i];
from = dataClass.from;
to = dataClass.to;
if ((from === UNDEFINED || ... | [
"function",
"(",
"value",
",",
"point",
")",
"{",
"var",
"pos",
",",
"stops",
"=",
"this",
".",
"stops",
",",
"from",
",",
"to",
",",
"color",
",",
"dataClasses",
"=",
"this",
".",
"dataClasses",
",",
"dataClass",
",",
"i",
";",
"if",
"(",
"dataCla... | Translate from a value to a color | [
"Translate",
"from",
"a",
"value",
"to",
"a",
"color"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L206-L256 | train | |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/heatmap.src.js | function () {
var grad,
horiz = this.horiz,
options = this.options,
reversed = this.reversed;
grad = horiz ? [+reversed, 0, +!reversed, 0] : [0, +!reversed, 0, +reversed]; // #3190
this.legendColor = {
linearGradient: { x1: grad[0], y1: grad[1], x2: grad[2], y2: grad[3] },
stops: options.stops || ... | javascript | function () {
var grad,
horiz = this.horiz,
options = this.options,
reversed = this.reversed;
grad = horiz ? [+reversed, 0, +!reversed, 0] : [0, +!reversed, 0, +reversed]; // #3190
this.legendColor = {
linearGradient: { x1: grad[0], y1: grad[1], x2: grad[2], y2: grad[3] },
stops: options.stops || ... | [
"function",
"(",
")",
"{",
"var",
"grad",
",",
"horiz",
"=",
"this",
".",
"horiz",
",",
"options",
"=",
"this",
".",
"options",
",",
"reversed",
"=",
"this",
".",
"reversed",
";",
"grad",
"=",
"horiz",
"?",
"[",
"+",
"reversed",
",",
"0",
",",
"+... | Create the color gradient | [
"Create",
"the",
"color",
"gradient"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L286-L300 | train | |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/heatmap.src.js | function (legend, item) {
var padding = legend.padding,
legendOptions = legend.options,
horiz = this.horiz,
box,
width = pick(legendOptions.symbolWidth, horiz ? 200 : 12),
height = pick(legendOptions.symbolHeight, horiz ? 12 : 200),
labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30),
... | javascript | function (legend, item) {
var padding = legend.padding,
legendOptions = legend.options,
horiz = this.horiz,
box,
width = pick(legendOptions.symbolWidth, horiz ? 200 : 12),
height = pick(legendOptions.symbolHeight, horiz ? 12 : 200),
labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30),
... | [
"function",
"(",
"legend",
",",
"item",
")",
"{",
"var",
"padding",
"=",
"legend",
".",
"padding",
",",
"legendOptions",
"=",
"legend",
".",
"options",
",",
"horiz",
"=",
"this",
".",
"horiz",
",",
"box",
",",
"width",
"=",
"pick",
"(",
"legendOptions"... | The color axis appears inside the legend and has its own legend symbol | [
"The",
"color",
"axis",
"appears",
"inside",
"the",
"legend",
"and",
"has",
"its",
"own",
"legend",
"symbol"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L305-L331 | train | |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/heatmap.src.js | function () {
var axis = this,
chart = this.chart,
legendItems = this.legendItems,
legendOptions = chart.options.legend,
valueDecimals = legendOptions.valueDecimals,
valueSuffix = legendOptions.valueSuffix || '',
name;
if (!legendItems.length) {
each(this.dataClasses, function (dataClass, i) {... | javascript | function () {
var axis = this,
chart = this.chart,
legendItems = this.legendItems,
legendOptions = chart.options.legend,
valueDecimals = legendOptions.valueDecimals,
valueSuffix = legendOptions.valueSuffix || '',
name;
if (!legendItems.length) {
each(this.dataClasses, function (dataClass, i) {... | [
"function",
"(",
")",
"{",
"var",
"axis",
"=",
"this",
",",
"chart",
"=",
"this",
".",
"chart",
",",
"legendItems",
"=",
"this",
".",
"legendItems",
",",
"legendOptions",
"=",
"chart",
".",
"options",
".",
"legend",
",",
"valueDecimals",
"=",
"legendOpti... | Get the legend item symbols for data classes | [
"Get",
"the",
"legend",
"item",
"symbols",
"for",
"data",
"classes"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L400-L456 | train | |
MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/heatmap.src.js | function () {
var options;
seriesTypes.scatter.prototype.init.apply(this, arguments);
options = this.options;
this.pointRange = options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData
this.yAxis.axisPointRange = options.rowsize || 1; // general point range
... | javascript | function () {
var options;
seriesTypes.scatter.prototype.init.apply(this, arguments);
options = this.options;
this.pointRange = options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData
this.yAxis.axisPointRange = options.rowsize || 1; // general point range
... | [
"function",
"(",
")",
"{",
"var",
"options",
";",
"seriesTypes",
".",
"scatter",
".",
"prototype",
".",
"init",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"options",
"=",
"this",
".",
"options",
";",
"this",
".",
"pointRange",
"=",
"options... | Override the init method to add point ranges on both axes. | [
"Override",
"the",
"init",
"method",
"to",
"add",
"point",
"ranges",
"on",
"both",
"axes",
"."
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/heatmap.src.js#L596-L603 | train | |
wacky6/grunt-fontmin | tasks/fontmin.js | taskFontmin | function taskFontmin() {
// prase options
let opts = this.options()
let data = this.data
let destdir = opts.dest || './'
let basedir = opts.basedir || './'
let src = grunt.file.expand(data.src)
let fonts = grunt.file.expand(join(basedir, this.target))
let getText = opts.ge... | javascript | function taskFontmin() {
// prase options
let opts = this.options()
let data = this.data
let destdir = opts.dest || './'
let basedir = opts.basedir || './'
let src = grunt.file.expand(data.src)
let fonts = grunt.file.expand(join(basedir, this.target))
let getText = opts.ge... | [
"function",
"taskFontmin",
"(",
")",
"{",
"// prase options",
"let",
"opts",
"=",
"this",
".",
"options",
"(",
")",
"let",
"data",
"=",
"this",
".",
"data",
"let",
"destdir",
"=",
"opts",
".",
"dest",
"||",
"'./'",
"let",
"basedir",
"=",
"opts",
".",
... | grunt task function | [
"grunt",
"task",
"function"
] | ed73e44e67326e45db86d78aa7bdef83d5acbc25 | https://github.com/wacky6/grunt-fontmin/blob/ed73e44e67326e45db86d78aa7bdef83d5acbc25/tasks/fontmin.js#L19-L64 | train |
nikitadyumin/stk | src/arrays.js | extract | function extract(arr, obj) {
return arr.filter(item => Object.keys(obj).every(key => item[key] === obj[key]));
} | javascript | function extract(arr, obj) {
return arr.filter(item => Object.keys(obj).every(key => item[key] === obj[key]));
} | [
"function",
"extract",
"(",
"arr",
",",
"obj",
")",
"{",
"return",
"arr",
".",
"filter",
"(",
"item",
"=>",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"every",
"(",
"key",
"=>",
"item",
"[",
"key",
"]",
"===",
"obj",
"[",
"key",
"]",
")",
")"... | Created by ndyumin on 15.09.2016. | [
"Created",
"by",
"ndyumin",
"on",
"15",
".",
"09",
".",
"2016",
"."
] | 7bf8e3c8c042061b3c976b7a919b6b700d7b96bd | https://github.com/nikitadyumin/stk/blob/7bf8e3c8c042061b3c976b7a919b6b700d7b96bd/src/arrays.js#L4-L6 | train |
socialally/emanate | lib/event-emitter.js | once | function once(event, listener) {
function g() {
this.removeListener(event, g);
listener.apply(this, arguments);
};
this.on(event, g);
return this;
} | javascript | function once(event, listener) {
function g() {
this.removeListener(event, g);
listener.apply(this, arguments);
};
this.on(event, g);
return this;
} | [
"function",
"once",
"(",
"event",
",",
"listener",
")",
"{",
"function",
"g",
"(",
")",
"{",
"this",
".",
"removeListener",
"(",
"event",
",",
"g",
")",
";",
"listener",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
";",
"this",
".",
... | Registers a listener to be invoked once.
@param event The event name.
@param listener The listener function. | [
"Registers",
"a",
"listener",
"to",
"be",
"invoked",
"once",
"."
] | bdfcbae2d1dcb92c6354da3db07e1993258518fa | https://github.com/socialally/emanate/blob/bdfcbae2d1dcb92c6354da3db07e1993258518fa/lib/event-emitter.js#L25-L32 | train |
socialally/emanate | lib/event-emitter.js | removeListener | function removeListener(event, listener) {
this._events = this._events || {};
if(event in this._events) {
this._events[event].splice(this._events[event].indexOf(listener), 1);
}
return this;
} | javascript | function removeListener(event, listener) {
this._events = this._events || {};
if(event in this._events) {
this._events[event].splice(this._events[event].indexOf(listener), 1);
}
return this;
} | [
"function",
"removeListener",
"(",
"event",
",",
"listener",
")",
"{",
"this",
".",
"_events",
"=",
"this",
".",
"_events",
"||",
"{",
"}",
";",
"if",
"(",
"event",
"in",
"this",
".",
"_events",
")",
"{",
"this",
".",
"_events",
"[",
"event",
"]",
... | Remove a listener for an event.
@param event The event name.
@param listener The event listener function. | [
"Remove",
"a",
"listener",
"for",
"an",
"event",
"."
] | bdfcbae2d1dcb92c6354da3db07e1993258518fa | https://github.com/socialally/emanate/blob/bdfcbae2d1dcb92c6354da3db07e1993258518fa/lib/event-emitter.js#L54-L60 | train |
socialally/emanate | lib/event-emitter.js | emit | function emit(event /* , args... */) {
this._events = this._events || {};
// NOTE: copy array so that removing listeners in listeners (once etc)
// NOTE: does not affect the iteration
var list = (this._events[event] || []).slice(0);
for(var i = 0; i < list.length; i++) {
list[i].apply(this, Array.prototyp... | javascript | function emit(event /* , args... */) {
this._events = this._events || {};
// NOTE: copy array so that removing listeners in listeners (once etc)
// NOTE: does not affect the iteration
var list = (this._events[event] || []).slice(0);
for(var i = 0; i < list.length; i++) {
list[i].apply(this, Array.prototyp... | [
"function",
"emit",
"(",
"event",
"/* , args... */",
")",
"{",
"this",
".",
"_events",
"=",
"this",
".",
"_events",
"||",
"{",
"}",
";",
"// NOTE: copy array so that removing listeners in listeners (once etc)",
"// NOTE: does not affect the iteration",
"var",
"list",
"=",... | Execute each of the listeners in order with the supplied arguments.
Returns true if event had listeners, false otherwise.
@param event The event name.
@param args... The arguments to pass to event listeners. | [
"Execute",
"each",
"of",
"the",
"listeners",
"in",
"order",
"with",
"the",
"supplied",
"arguments",
"."
] | bdfcbae2d1dcb92c6354da3db07e1993258518fa | https://github.com/socialally/emanate/blob/bdfcbae2d1dcb92c6354da3db07e1993258518fa/lib/event-emitter.js#L78-L87 | train |
Digznav/bilberry | promise-write-file.js | promiseWriteFile | function promiseWriteFile(targetPath, content, tabs = 2) {
const fileName = targetPath.split('/').pop();
let contentHolder = content;
if (targetPath.endsWith('.json')) {
contentHolder = JSON.stringify(contentHolder, null, tabs);
}
return new Promise((resolve, reject) => {
fs.writeFile(targetPath, co... | javascript | function promiseWriteFile(targetPath, content, tabs = 2) {
const fileName = targetPath.split('/').pop();
let contentHolder = content;
if (targetPath.endsWith('.json')) {
contentHolder = JSON.stringify(contentHolder, null, tabs);
}
return new Promise((resolve, reject) => {
fs.writeFile(targetPath, co... | [
"function",
"promiseWriteFile",
"(",
"targetPath",
",",
"content",
",",
"tabs",
"=",
"2",
")",
"{",
"const",
"fileName",
"=",
"targetPath",
".",
"split",
"(",
"'/'",
")",
".",
"pop",
"(",
")",
";",
"let",
"contentHolder",
"=",
"content",
";",
"if",
"("... | Promise-base `writeFile` function.
@param {string} targetPath File path.
@param {string} content File content.
@param {number} tabs Number of tabs.
@return {promise} Promise to write the given file. | [
"Promise",
"-",
"base",
"writeFile",
"function",
"."
] | ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4 | https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/promise-write-file.js#L10-L29 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.gestures.js | getGesture | function getGesture( element_ ) {
const element = ensureDom( element_ );
if ( !element[ SYMBOL ] ) element[ SYMBOL ] = new Gesture( element );
return element[ SYMBOL ];
} | javascript | function getGesture( element_ ) {
const element = ensureDom( element_ );
if ( !element[ SYMBOL ] ) element[ SYMBOL ] = new Gesture( element );
return element[ SYMBOL ];
} | [
"function",
"getGesture",
"(",
"element_",
")",
"{",
"const",
"element",
"=",
"ensureDom",
"(",
"element_",
")",
";",
"if",
"(",
"!",
"element",
"[",
"SYMBOL",
"]",
")",
"element",
"[",
"SYMBOL",
"]",
"=",
"new",
"Gesture",
"(",
"element",
")",
";",
... | Return the associated gesture object. If it does not exist, create it.
@param {[type]} element_ [description]
@returns {[type]} [description] | [
"Return",
"the",
"associated",
"gesture",
"object",
".",
"If",
"it",
"does",
"not",
"exist",
"create",
"it",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L87-L91 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.gestures.js | handlerWithChainOfResponsability | function handlerWithChainOfResponsability( eventName, evt ) {
const chain = this._events[ eventName ].chain;
for ( let i = 0; i < chain.length; i++ ) {
const responsible = chain[ i ];
if ( responsible( evt ) === true ) return;
}
} | javascript | function handlerWithChainOfResponsability( eventName, evt ) {
const chain = this._events[ eventName ].chain;
for ( let i = 0; i < chain.length; i++ ) {
const responsible = chain[ i ];
if ( responsible( evt ) === true ) return;
}
} | [
"function",
"handlerWithChainOfResponsability",
"(",
"eventName",
",",
"evt",
")",
"{",
"const",
"chain",
"=",
"this",
".",
"_events",
"[",
"eventName",
"]",
".",
"chain",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"chain",
".",
"length",
";... | We map a chain of responsability to each hammer event we need to deal with.
When an item of that chain returns `true` that means it will take the responsability and we do
not ask the others. | [
"We",
"map",
"a",
"chain",
"of",
"responsability",
"to",
"each",
"hammer",
"event",
"we",
"need",
"to",
"deal",
"with",
".",
"When",
"an",
"item",
"of",
"that",
"chain",
"returns",
"true",
"that",
"means",
"it",
"will",
"take",
"the",
"responsability",
"... | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L98-L104 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.gestures.js | doRegister | function doRegister( event, responsible ) {
var hammerEvent = getEventNameForPrefix( event, "hammer." );
if ( hammerEvent && !this._hammer ) {
this._hammer = new Hammer( this.$, { domEvents: true } );
// To get domEvents.stopPropagation() available.
this._hammer.domEvents = true;
}
... | javascript | function doRegister( event, responsible ) {
var hammerEvent = getEventNameForPrefix( event, "hammer." );
if ( hammerEvent && !this._hammer ) {
this._hammer = new Hammer( this.$, { domEvents: true } );
// To get domEvents.stopPropagation() available.
this._hammer.domEvents = true;
}
... | [
"function",
"doRegister",
"(",
"event",
",",
"responsible",
")",
"{",
"var",
"hammerEvent",
"=",
"getEventNameForPrefix",
"(",
"event",
",",
"\"hammer.\"",
")",
";",
"if",
"(",
"hammerEvent",
"&&",
"!",
"this",
".",
"_hammer",
")",
"{",
"this",
".",
"_hamm... | Add a responsability item in the chain of a hammer event. | [
"Add",
"a",
"responsability",
"item",
"in",
"the",
"chain",
"of",
"a",
"hammer",
"event",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L109-L126 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.gestures.js | onDrag | function onDrag( register, slot, args ) {
const that = this;
register( 'hammer.pan', function ( evt ) {
if ( evt.isFinal ) return false;
setHammerXY( that.$, evt );
if ( typeof that._dragX === 'undefined' ) {
that._dragX = evt.x;
that._dragY = evt.y;
... | javascript | function onDrag( register, slot, args ) {
const that = this;
register( 'hammer.pan', function ( evt ) {
if ( evt.isFinal ) return false;
setHammerXY( that.$, evt );
if ( typeof that._dragX === 'undefined' ) {
that._dragX = evt.x;
that._dragY = evt.y;
... | [
"function",
"onDrag",
"(",
"register",
",",
"slot",
",",
"args",
")",
"{",
"const",
"that",
"=",
"this",
";",
"register",
"(",
"'hammer.pan'",
",",
"function",
"(",
"evt",
")",
"{",
"if",
"(",
"evt",
".",
"isFinal",
")",
"return",
"false",
";",
"setH... | Dragging is moving while touching.
@this Gesture
@param {function} register - Hammer register function.
@param {function} slot - Function to call when the event occurs.
@param {any} args - Any argument to send to the slot.
@returns {undefined} | [
"Dragging",
"is",
"moving",
"while",
"touching",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.gestures.js#L261-L291 | train |
jslovesyou/resolver-revolver | lib/completion.js | froms | function froms(froms) {
var args = Array.prototype.splice.call(arguments, 0);
if (isUndefined(froms)) {
froms = [];
}
if (!isArray(froms)) {
throw {
name: 'Error',
message: 'Argument is not an array',
arguments: args
};
}
var f = froms
.filter(function (from) {
retu... | javascript | function froms(froms) {
var args = Array.prototype.splice.call(arguments, 0);
if (isUndefined(froms)) {
froms = [];
}
if (!isArray(froms)) {
throw {
name: 'Error',
message: 'Argument is not an array',
arguments: args
};
}
var f = froms
.filter(function (from) {
retu... | [
"function",
"froms",
"(",
"froms",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"splice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"if",
"(",
"isUndefined",
"(",
"froms",
")",
")",
"{",
"froms",
"=",
"[",
"]",
";",
"}",... | Helper function which returns an array of | [
"Helper",
"function",
"which",
"returns",
"an",
"array",
"of"
] | bf76dd899f3ccfe05be1aa637b4bf638c02a9af5 | https://github.com/jslovesyou/resolver-revolver/blob/bf76dd899f3ccfe05be1aa637b4bf638c02a9af5/lib/completion.js#L97-L140 | train |
rowanmanning/thingme | lib/thingme.js | createThingme | function createThingme (opts) {
opts = defaultOptions(opts);
validateThings(opts.things);
return createWebservice(opts);
} | javascript | function createThingme (opts) {
opts = defaultOptions(opts);
validateThings(opts.things);
return createWebservice(opts);
} | [
"function",
"createThingme",
"(",
"opts",
")",
"{",
"opts",
"=",
"defaultOptions",
"(",
"opts",
")",
";",
"validateThings",
"(",
"opts",
".",
"things",
")",
";",
"return",
"createWebservice",
"(",
"opts",
")",
";",
"}"
] | Create a thingme web-service | [
"Create",
"a",
"thingme",
"web",
"-",
"service"
] | e74a9e20535e9b52229950e55b73c179d34f6ae2 | https://github.com/rowanmanning/thingme/blob/e74a9e20535e9b52229950e55b73c179d34f6ae2/lib/thingme.js#L9-L13 | train |
rowanmanning/thingme | lib/thingme.js | createWebservice | function createWebservice (opts) {
var server = new Hapi.Server(opts.host, opts.port, {
cors: {
methods: ['GET']
}
});
defineRoutes(server, opts);
return {
address: 'http://' + opts.host + ':' + opts.port + '/',
hapi: server,
options: opts,
sta... | javascript | function createWebservice (opts) {
var server = new Hapi.Server(opts.host, opts.port, {
cors: {
methods: ['GET']
}
});
defineRoutes(server, opts);
return {
address: 'http://' + opts.host + ':' + opts.port + '/',
hapi: server,
options: opts,
sta... | [
"function",
"createWebservice",
"(",
"opts",
")",
"{",
"var",
"server",
"=",
"new",
"Hapi",
".",
"Server",
"(",
"opts",
".",
"host",
",",
"opts",
".",
"port",
",",
"{",
"cors",
":",
"{",
"methods",
":",
"[",
"'GET'",
"]",
"}",
"}",
")",
";",
"def... | Create a webservice | [
"Create",
"a",
"webservice"
] | e74a9e20535e9b52229950e55b73c179d34f6ae2 | https://github.com/rowanmanning/thingme/blob/e74a9e20535e9b52229950e55b73c179d34f6ae2/lib/thingme.js#L16-L29 | train |
rowanmanning/thingme | lib/thingme.js | defineRoutes | function defineRoutes (server, opts) {
require('../route')(server, opts);
require('../route/things')(server, opts);
require('../route/random')(server, opts);
require('../route/bomb')(server, opts);
require('../route/count')(server, opts);
} | javascript | function defineRoutes (server, opts) {
require('../route')(server, opts);
require('../route/things')(server, opts);
require('../route/random')(server, opts);
require('../route/bomb')(server, opts);
require('../route/count')(server, opts);
} | [
"function",
"defineRoutes",
"(",
"server",
",",
"opts",
")",
"{",
"require",
"(",
"'../route'",
")",
"(",
"server",
",",
"opts",
")",
";",
"require",
"(",
"'../route/things'",
")",
"(",
"server",
",",
"opts",
")",
";",
"require",
"(",
"'../route/random'",
... | Define webservice routes | [
"Define",
"webservice",
"routes"
] | e74a9e20535e9b52229950e55b73c179d34f6ae2 | https://github.com/rowanmanning/thingme/blob/e74a9e20535e9b52229950e55b73c179d34f6ae2/lib/thingme.js#L32-L38 | train |
Minetrocity/nodb | index.js | write | function write (database) {
var deferred = q.defer();
// Write database to file under database name
fs.writeFile(globalConfig.db.location + database + '.db.json', JSON.stringify(databases[database]), function (err) {
if(err) return deferred.reject(err);
deferred.resolve();
});
return deferred.promi... | javascript | function write (database) {
var deferred = q.defer();
// Write database to file under database name
fs.writeFile(globalConfig.db.location + database + '.db.json', JSON.stringify(databases[database]), function (err) {
if(err) return deferred.reject(err);
deferred.resolve();
});
return deferred.promi... | [
"function",
"write",
"(",
"database",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"// Write database to file under database name",
"fs",
".",
"writeFile",
"(",
"globalConfig",
".",
"db",
".",
"location",
"+",
"database",
"+",
"'.db.json... | Writes a database to file
@param {string} database Database to write
@return {promise} Denotes success or failure of write | [
"Writes",
"a",
"database",
"to",
"file"
] | e45e8f1d8141d3f2c788ebafb69ca8be6a816ada | https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L142-L153 | train |
Minetrocity/nodb | index.js | verifyConfig | function verifyConfig (config) {
config = config || {};
config.db = config.db || {};
config.db.location = config.db.location || __dirname + 'databases/'; // /cwd/databases/ default
config.db.timeout = config.db.timeout || 1000 * 60 * 5; // 5 minute default
config.db.fileTimeout = config.db.fileTimeout || -1; ... | javascript | function verifyConfig (config) {
config = config || {};
config.db = config.db || {};
config.db.location = config.db.location || __dirname + 'databases/'; // /cwd/databases/ default
config.db.timeout = config.db.timeout || 1000 * 60 * 5; // 5 minute default
config.db.fileTimeout = config.db.fileTimeout || -1; ... | [
"function",
"verifyConfig",
"(",
"config",
")",
"{",
"config",
"=",
"config",
"||",
"{",
"}",
";",
"config",
".",
"db",
"=",
"config",
".",
"db",
"||",
"{",
"}",
";",
"config",
".",
"db",
".",
"location",
"=",
"config",
".",
"db",
".",
"location",
... | Verifies the needed config options are available
@param {object} config Configuration object
@return {object} Returns the properly adjusted config object | [
"Verifies",
"the",
"needed",
"config",
"options",
"are",
"available"
] | e45e8f1d8141d3f2c788ebafb69ca8be6a816ada | https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L161-L169 | train |
Minetrocity/nodb | index.js | createLocation | function createLocation () {
var deferred = q.defer();
// Make the directory, and report status
mkdirp(globalConfig.db.location, function (err, made) {
if(err) return deferred.reject(err);
deferred.resolve(made);
});
return deferred.promise;
} | javascript | function createLocation () {
var deferred = q.defer();
// Make the directory, and report status
mkdirp(globalConfig.db.location, function (err, made) {
if(err) return deferred.reject(err);
deferred.resolve(made);
});
return deferred.promise;
} | [
"function",
"createLocation",
"(",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"// Make the directory, and report status",
"mkdirp",
"(",
"globalConfig",
".",
"db",
".",
"location",
",",
"function",
"(",
"err",
",",
"made",
")",
"{",
... | Verifies the database location exists
@return {promise} Denotes success or failure of folder creation | [
"Verifies",
"the",
"database",
"location",
"exists"
] | e45e8f1d8141d3f2c788ebafb69ca8be6a816ada | https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L176-L187 | train |
Minetrocity/nodb | index.js | createDatabase | function createDatabase (name) {
var deferred = q.defer();
// Make sure the database location exists
ready.then(function () {
// Check if database exists
fs.exists(globalConfig.db.location + name + '.db.json', function (exists) {
if(exists) return deferred.resolve();
// If database is non-ex... | javascript | function createDatabase (name) {
var deferred = q.defer();
// Make sure the database location exists
ready.then(function () {
// Check if database exists
fs.exists(globalConfig.db.location + name + '.db.json', function (exists) {
if(exists) return deferred.resolve();
// If database is non-ex... | [
"function",
"createDatabase",
"(",
"name",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"// Make sure the database location exists",
"ready",
".",
"then",
"(",
"function",
"(",
")",
"{",
"// Check if database exists",
"fs",
".",
"exists",
... | Checks for existence of a database, creates if non-existent
@param {string} name Name of database to open
@return {promise} Denotes existence of database | [
"Checks",
"for",
"existence",
"of",
"a",
"database",
"creates",
"if",
"non",
"-",
"existent"
] | e45e8f1d8141d3f2c788ebafb69ca8be6a816ada | https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L233-L254 | train |
Minetrocity/nodb | index.js | closeDatabase | function closeDatabase (name) {
var deferred = q.defer();
// We need to be sure the database location exists
ready.then(function () {
clearTimeout(timeouts[name]);
// Write to file
write(name).then(function () {
// Remove database from memory
delete databases[name];
deferred.resol... | javascript | function closeDatabase (name) {
var deferred = q.defer();
// We need to be sure the database location exists
ready.then(function () {
clearTimeout(timeouts[name]);
// Write to file
write(name).then(function () {
// Remove database from memory
delete databases[name];
deferred.resol... | [
"function",
"closeDatabase",
"(",
"name",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"// We need to be sure the database location exists",
"ready",
".",
"then",
"(",
"function",
"(",
")",
"{",
"clearTimeout",
"(",
"timeouts",
"[",
"nam... | Closes a database and writes to file
@param {[type]}
@return {[type]} | [
"Closes",
"a",
"database",
"and",
"writes",
"to",
"file"
] | e45e8f1d8141d3f2c788ebafb69ca8be6a816ada | https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L262-L283 | train |
Minetrocity/nodb | index.js | actionOn | function actionOn (name) {
// Clear a possibly existing timeout
clearTimeout(timeouts[name]);
// Make sure user hasn't declined auto-close
if(globalConfig.db.timeout < 0) return;
// Set up auto-close
timeouts[name] = setTimeout(function () {
closeDatabase(name);
}, globalConfig.db.timeout);
} | javascript | function actionOn (name) {
// Clear a possibly existing timeout
clearTimeout(timeouts[name]);
// Make sure user hasn't declined auto-close
if(globalConfig.db.timeout < 0) return;
// Set up auto-close
timeouts[name] = setTimeout(function () {
closeDatabase(name);
}, globalConfig.db.timeout);
} | [
"function",
"actionOn",
"(",
"name",
")",
"{",
"// Clear a possibly existing timeout",
"clearTimeout",
"(",
"timeouts",
"[",
"name",
"]",
")",
";",
"// Make sure user hasn't declined auto-close",
"if",
"(",
"globalConfig",
".",
"db",
".",
"timeout",
"<",
"0",
")",
... | Logs actions to the database, and preps for auto-close if specified
@param {string} name Database with action | [
"Logs",
"actions",
"to",
"the",
"database",
"and",
"preps",
"for",
"auto",
"-",
"close",
"if",
"specified"
] | e45e8f1d8141d3f2c788ebafb69ca8be6a816ada | https://github.com/Minetrocity/nodb/blob/e45e8f1d8141d3f2c788ebafb69ca8be6a816ada/index.js#L290-L301 | train |
fronteerio/node-embdr | lib/api/resources.js | function(file, options, callback) {
// If the file is a string, we assume it's a path on disk
if (_.isString(file)) {
try {
file = fs.createReadStream(file);
} catch (err) {
return callback({'message': 'A stream could not be... | javascript | function(file, options, callback) {
// If the file is a string, we assume it's a path on disk
if (_.isString(file)) {
try {
file = fs.createReadStream(file);
} catch (err) {
return callback({'message': 'A stream could not be... | [
"function",
"(",
"file",
",",
"options",
",",
"callback",
")",
"{",
"// If the file is a string, we assume it's a path on disk",
"if",
"(",
"_",
".",
"isString",
"(",
"file",
")",
")",
"{",
"try",
"{",
"file",
"=",
"fs",
".",
"createReadStream",
"(",
"file",
... | Create and process a file
@param {stream} file A stream that holds the data for a file that should be uploaded and processed
@param {Object} [options] A set of extra options
@param {string[]} [options.thumbnailSizes] A set of thumbnail dimensions
@pa... | [
"Create",
"and",
"process",
"a",
"file"
] | 050916baa37b069d894fdd4db3b80f110ad8c51e | https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/api/resources.js#L25-L45 | train | |
fronteerio/node-embdr | lib/api/resources.js | function(link, options, callback) {
var data = {'link': link};
addSizes(data, options, 'thumbnailSizes');
addSizes(data, options, 'imageSizes');
return processr._request('POST', '/resources', data, callback);
} | javascript | function(link, options, callback) {
var data = {'link': link};
addSizes(data, options, 'thumbnailSizes');
addSizes(data, options, 'imageSizes');
return processr._request('POST', '/resources', data, callback);
} | [
"function",
"(",
"link",
",",
"options",
",",
"callback",
")",
"{",
"var",
"data",
"=",
"{",
"'link'",
":",
"link",
"}",
";",
"addSizes",
"(",
"data",
",",
"options",
",",
"'thumbnailSizes'",
")",
";",
"addSizes",
"(",
"data",
",",
"options",
",",
"'... | Create and process a link
@param {string} link The link that should be processed
@param {Object} [options] A set of extra options
@param {string[]} [options.thumbnailSizes] A set of thumbnail dimensions
@param {string[]} [options.imageSizes] ... | [
"Create",
"and",
"process",
"a",
"link"
] | 050916baa37b069d894fdd4db3b80f110ad8c51e | https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/api/resources.js#L58-L63 | 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.