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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Runnable/api-client | lib/external/primus-client.js | defaults | function defaults(name, selfie, opts) {
return millisecond(
name in opts ? opts[name] : (name in selfie ? selfie[name] : Recovery[name])
);
} | javascript | function defaults(name, selfie, opts) {
return millisecond(
name in opts ? opts[name] : (name in selfie ? selfie[name] : Recovery[name])
);
} | [
"function",
"defaults",
"(",
"name",
",",
"selfie",
",",
"opts",
")",
"{",
"return",
"millisecond",
"(",
"name",
"in",
"opts",
"?",
"opts",
"[",
"name",
"]",
":",
"(",
"name",
"in",
"selfie",
"?",
"selfie",
"[",
"name",
"]",
":",
"Recovery",
"[",
"... | Returns sane defaults about a given value.
@param {String} name Name of property we want.
@param {Recovery} selfie Recovery instance that got created.
@param {Object} opts User supplied options we want to check.
@returns {Number} Some default value.
@api private | [
"Returns",
"sane",
"defaults",
"about",
"a",
"given",
"value",
"."
] | e6089c4ed0b8c6ed383a82cbd50514e1e720f154 | https://github.com/Runnable/api-client/blob/e6089c4ed0b8c6ed383a82cbd50514e1e720f154/lib/external/primus-client.js#L493-L497 | train |
Runnable/api-client | lib/external/primus-client.js | Recovery | function Recovery(options) {
var recovery = this;
if (!(recovery instanceof Recovery)) return new Recovery(options);
options = options || {};
recovery.attempt = null; // Stores the current reconnect attempt.
recovery._fn = null; // Stores the callback.
recovery[... | javascript | function Recovery(options) {
var recovery = this;
if (!(recovery instanceof Recovery)) return new Recovery(options);
options = options || {};
recovery.attempt = null; // Stores the current reconnect attempt.
recovery._fn = null; // Stores the callback.
recovery[... | [
"function",
"Recovery",
"(",
"options",
")",
"{",
"var",
"recovery",
"=",
"this",
";",
"if",
"(",
"!",
"(",
"recovery",
"instanceof",
"Recovery",
")",
")",
"return",
"new",
"Recovery",
"(",
"options",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}"... | Attempt to recover your connection with reconnection attempt.
@constructor
@param {Object} options Configuration
@api public | [
"Attempt",
"to",
"recover",
"your",
"connection",
"with",
"reconnection",
"attempt",
"."
] | e6089c4ed0b8c6ed383a82cbd50514e1e720f154 | https://github.com/Runnable/api-client/blob/e6089c4ed0b8c6ed383a82cbd50514e1e720f154/lib/external/primus-client.js#L506-L522 | train |
Runnable/api-client | lib/external/primus-client.js | URL | function URL(address, location, parser) {
if (!(this instanceof URL)) {
return new URL(address, location, parser);
}
var relative = relativere.test(address)
, parse, instruction, index, key
, type = typeof location
, url = this
, i = 0;
//
// The f... | javascript | function URL(address, location, parser) {
if (!(this instanceof URL)) {
return new URL(address, location, parser);
}
var relative = relativere.test(address)
, parse, instruction, index, key
, type = typeof location
, url = this
, i = 0;
//
// The f... | [
"function",
"URL",
"(",
"address",
",",
"location",
",",
"parser",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"URL",
")",
")",
"{",
"return",
"new",
"URL",
"(",
"address",
",",
"location",
",",
"parser",
")",
";",
"}",
"var",
"relative",
... | The actual URL instance. Instead of returning an object we've opted-in to
create an actual constructor as it's much more memory efficient and
faster and it pleases my CDO.
@constructor
@param {String} address URL we want to parse.
@param {Boolean|function} parser Parser for the query string.
@param {Object} location L... | [
"The",
"actual",
"URL",
"instance",
".",
"Instead",
"of",
"returning",
"an",
"object",
"we",
"ve",
"opted",
"-",
"in",
"to",
"create",
"an",
"actual",
"constructor",
"as",
"it",
"s",
"much",
"more",
"memory",
"efficient",
"and",
"faster",
"and",
"it",
"p... | e6089c4ed0b8c6ed383a82cbd50514e1e720f154 | https://github.com/Runnable/api-client/blob/e6089c4ed0b8c6ed383a82cbd50514e1e720f154/lib/external/primus-client.js#L1118-L1215 | train |
Runnable/api-client | lib/external/primus-client.js | Primus | function Primus(url, options) {
if (!(this instanceof Primus)) return new Primus(url, options);
if ('function' !== typeof this.client) {
var message = 'The client library has not been compiled correctly, ' +
'see https://github.com/primus/primus#client-library for more details';
re... | javascript | function Primus(url, options) {
if (!(this instanceof Primus)) return new Primus(url, options);
if ('function' !== typeof this.client) {
var message = 'The client library has not been compiled correctly, ' +
'see https://github.com/primus/primus#client-library for more details';
re... | [
"function",
"Primus",
"(",
"url",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Primus",
")",
")",
"return",
"new",
"Primus",
"(",
"url",
",",
"options",
")",
";",
"if",
"(",
"'function'",
"!==",
"typeof",
"this",
".",
"client... | Primus is a real-time library agnostic framework for establishing real-time
connections with servers.
Options:
- reconnect, configuration for the reconnect process.
- manual, don't automatically call `.open` to start the connection.
- websockets, force the use of WebSockets, even when you should avoid them.
- timeout,... | [
"Primus",
"is",
"a",
"real",
"-",
"time",
"library",
"agnostic",
"framework",
"for",
"establishing",
"real",
"-",
"time",
"connections",
"with",
"servers",
"."
] | e6089c4ed0b8c6ed383a82cbd50514e1e720f154 | https://github.com/Runnable/api-client/blob/e6089c4ed0b8c6ed383a82cbd50514e1e720f154/lib/external/primus-client.js#L1469-L1585 | train |
Runnable/api-client | lib/external/primus-client.js | pong | function pong() {
primus.timers.clear('pong');
//
// The network events already captured the offline event.
//
if (!primus.online) return;
primus.online = false;
primus.emit('offline');
primus.emit('incoming::end');
} | javascript | function pong() {
primus.timers.clear('pong');
//
// The network events already captured the offline event.
//
if (!primus.online) return;
primus.online = false;
primus.emit('offline');
primus.emit('incoming::end');
} | [
"function",
"pong",
"(",
")",
"{",
"primus",
".",
"timers",
".",
"clear",
"(",
"'pong'",
")",
";",
"//",
"// The network events already captured the offline event.",
"//",
"if",
"(",
"!",
"primus",
".",
"online",
")",
"return",
";",
"primus",
".",
"online",
... | Exterminate the connection as we've timed out.
@api private | [
"Exterminate",
"the",
"connection",
"as",
"we",
"ve",
"timed",
"out",
"."
] | e6089c4ed0b8c6ed383a82cbd50514e1e720f154 | https://github.com/Runnable/api-client/blob/e6089c4ed0b8c6ed383a82cbd50514e1e720f154/lib/external/primus-client.js#L2268-L2279 | train |
Runnable/api-client | lib/external/primus-client.js | ping | function ping() {
var value = +new Date();
primus.timers.clear('ping');
primus._write('primus::ping::'+ value);
primus.emit('outgoing::ping', value);
primus.timers.setTimeout('pong', pong, primus.options.pong);
} | javascript | function ping() {
var value = +new Date();
primus.timers.clear('ping');
primus._write('primus::ping::'+ value);
primus.emit('outgoing::ping', value);
primus.timers.setTimeout('pong', pong, primus.options.pong);
} | [
"function",
"ping",
"(",
")",
"{",
"var",
"value",
"=",
"+",
"new",
"Date",
"(",
")",
";",
"primus",
".",
"timers",
".",
"clear",
"(",
"'ping'",
")",
";",
"primus",
".",
"_write",
"(",
"'primus::ping::'",
"+",
"value",
")",
";",
"primus",
".",
"emi... | We should send a ping message to the server.
@api private | [
"We",
"should",
"send",
"a",
"ping",
"message",
"to",
"the",
"server",
"."
] | e6089c4ed0b8c6ed383a82cbd50514e1e720f154 | https://github.com/Runnable/api-client/blob/e6089c4ed0b8c6ed383a82cbd50514e1e720f154/lib/external/primus-client.js#L2286-L2293 | train |
atsid/circuits-js | js/util.js | function (name, separator) {
var fullName, sep = separator || "/";
if (name.indexOf(sep) >= 0) {
fullName = name; //already got fully-qualified (theoretically)
} else if (name.indexOf("Service") >= 0) {
fullName = "Schema" + sep +... | javascript | function (name, separator) {
var fullName, sep = separator || "/";
if (name.indexOf(sep) >= 0) {
fullName = name; //already got fully-qualified (theoretically)
} else if (name.indexOf("Service") >= 0) {
fullName = "Schema" + sep +... | [
"function",
"(",
"name",
",",
"separator",
")",
"{",
"var",
"fullName",
",",
"sep",
"=",
"separator",
"||",
"\"/\"",
";",
"if",
"(",
"name",
".",
"indexOf",
"(",
"sep",
")",
">=",
"0",
")",
"{",
"fullName",
"=",
"name",
";",
"//already got fully-qualif... | Returns a fully-qualified name for a service from one of several partial formats. | [
"Returns",
"a",
"fully",
"-",
"qualified",
"name",
"for",
"a",
"service",
"from",
"one",
"of",
"several",
"partial",
"formats",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/util.js#L42-L58 | train | |
atsid/circuits-js | js/util.js | function (plugins, func) {
var idx, plugin = null;
// iterate to process in reverse order without side-effects.
for (idx = 1; idx <= plugins.length; idx += 1) {
plugin = plugins[plugins.length - idx];
func(plugin);
... | javascript | function (plugins, func) {
var idx, plugin = null;
// iterate to process in reverse order without side-effects.
for (idx = 1; idx <= plugins.length; idx += 1) {
plugin = plugins[plugins.length - idx];
func(plugin);
... | [
"function",
"(",
"plugins",
",",
"func",
")",
"{",
"var",
"idx",
",",
"plugin",
"=",
"null",
";",
"// iterate to process in reverse order without side-effects.",
"for",
"(",
"idx",
"=",
"1",
";",
"idx",
"<=",
"plugins",
".",
"length",
";",
"idx",
"+=",
"1",
... | Execute a plugin array, terminating if a plugin sets its stopProcessing property.
@param plugins - the array of plugins to execute.
@param func - the function to apply to each plugin, it accepts the plugin its single parameter. | [
"Execute",
"a",
"plugin",
"array",
"terminating",
"if",
"a",
"plugin",
"sets",
"its",
"stopProcessing",
"property",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/util.js#L83-L93 | train | |
kt3k/bundle-through | index.js | bundleThrough | function bundleThrough(options) {
options = options || {}
var browserifyShouldCreateSourcemaps = options.debug || options.sourcemaps
var bundleTransform = through(function (file, enc, callback) {
var bundler = browserify(file.path, assign({}, options, {debug: browserifyShouldCreateSourcemaps}))
if (o... | javascript | function bundleThrough(options) {
options = options || {}
var browserifyShouldCreateSourcemaps = options.debug || options.sourcemaps
var bundleTransform = through(function (file, enc, callback) {
var bundler = browserify(file.path, assign({}, options, {debug: browserifyShouldCreateSourcemaps}))
if (o... | [
"function",
"bundleThrough",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"var",
"browserifyShouldCreateSourcemaps",
"=",
"options",
".",
"debug",
"||",
"options",
".",
"sourcemaps",
"var",
"bundleTransform",
"=",
"through",
"(",
"functio... | Returns a transform stream which bundles files in the given stream.
@param {object} [options] The options. This options are directly passed to the `browserify` constructor. You can pass any browserify options such as `transform` `plugin` `debug` etc.
@param {boolean} [options.buffer] `true` iff you want output file to... | [
"Returns",
"a",
"transform",
"stream",
"which",
"bundles",
"files",
"in",
"the",
"given",
"stream",
"."
] | e474509585866a894fdae53347e9835e61b8e6d4 | https://github.com/kt3k/bundle-through/blob/e474509585866a894fdae53347e9835e61b8e6d4/index.js#L18-L51 | train |
kt3k/bundle-through | index.js | createNewFileByContents | function createNewFileByContents(file, newContents) {
var newFile = file.clone()
newFile.contents = newContents
return newFile
} | javascript | function createNewFileByContents(file, newContents) {
var newFile = file.clone()
newFile.contents = newContents
return newFile
} | [
"function",
"createNewFileByContents",
"(",
"file",
",",
"newContents",
")",
"{",
"var",
"newFile",
"=",
"file",
".",
"clone",
"(",
")",
"newFile",
".",
"contents",
"=",
"newContents",
"return",
"newFile",
"}"
] | Returns a new file from the given file and contents.
@param {Vinyl} file The input file
@param {Buffer|Stream} newContents The new contents for the file | [
"Returns",
"a",
"new",
"file",
"from",
"the",
"given",
"file",
"and",
"contents",
"."
] | e474509585866a894fdae53347e9835e61b8e6d4 | https://github.com/kt3k/bundle-through/blob/e474509585866a894fdae53347e9835e61b8e6d4/index.js#L58-L65 | train |
veo-labs/openveo-api | lib/middlewares/imageProcessorMiddleware.js | fetchStyle | function fetchStyle(id) {
for (var i = 0; i < styles.length; i++)
if (styles[i].id === id) return styles[i];
} | javascript | function fetchStyle(id) {
for (var i = 0; i < styles.length; i++)
if (styles[i].id === id) return styles[i];
} | [
"function",
"fetchStyle",
"(",
"id",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"styles",
".",
"length",
";",
"i",
"++",
")",
"if",
"(",
"styles",
"[",
"i",
"]",
".",
"id",
"===",
"id",
")",
"return",
"styles",
"[",
"i",
"]",
... | Fetches a style by its id from the list of styles.
@param {String} id The id of the style to fetch
@return {Object} The style description object | [
"Fetches",
"a",
"style",
"by",
"its",
"id",
"from",
"the",
"list",
"of",
"styles",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/middlewares/imageProcessorMiddleware.js#L61-L64 | train |
veo-labs/openveo-api | lib/middlewares/imageProcessorMiddleware.js | sendFile | function sendFile(imagePath) {
response.set(headers);
response.download(imagePath, request.query.filename);
} | javascript | function sendFile(imagePath) {
response.set(headers);
response.download(imagePath, request.query.filename);
} | [
"function",
"sendFile",
"(",
"imagePath",
")",
"{",
"response",
".",
"set",
"(",
"headers",
")",
";",
"response",
".",
"download",
"(",
"imagePath",
",",
"request",
".",
"query",
".",
"filename",
")",
";",
"}"
] | Sends an image to client as response.
@param {String} imagePath The absolute image path | [
"Sends",
"an",
"image",
"to",
"client",
"as",
"response",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/middlewares/imageProcessorMiddleware.js#L82-L85 | train |
LeisureLink/magicbus | lib/middleware/pipeline.js | Pipeline | function Pipeline(actionFactory, pipe) {
assert.func(actionFactory, 'actionFactory');
assert.optionalArrayOfFunc(pipe, 'pipe');
let middleware = (pipe || []).slice();
let logger;
let module = {
/** Clone the middleware pipeline */
clone: () => {
return Pipeline(actionFactory, middleware);
... | javascript | function Pipeline(actionFactory, pipe) {
assert.func(actionFactory, 'actionFactory');
assert.optionalArrayOfFunc(pipe, 'pipe');
let middleware = (pipe || []).slice();
let logger;
let module = {
/** Clone the middleware pipeline */
clone: () => {
return Pipeline(actionFactory, middleware);
... | [
"function",
"Pipeline",
"(",
"actionFactory",
",",
"pipe",
")",
"{",
"assert",
".",
"func",
"(",
"actionFactory",
",",
"'actionFactory'",
")",
";",
"assert",
".",
"optionalArrayOfFunc",
"(",
"pipe",
",",
"'pipe'",
")",
";",
"let",
"middleware",
"=",
"(",
"... | Represents a pipeline of middleware to be executed for a message
@param {Function} actionFactory - factory function that returns an Actions instance
@param {Array} pipe - array of middleware to be executed
@returns {Object} a module with clone, use, and prepare functions | [
"Represents",
"a",
"pipeline",
"of",
"middleware",
"to",
"be",
"executed",
"for",
"a",
"message"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/middleware/pipeline.js#L12-L72 | train |
veo-labs/openveo-plugin-generator | generators/app/templates/tasks/_concat.js | getMinifiedJSFiles | function getMinifiedJSFiles(files) {
var minifiedFiles = [];
files.forEach(function(path) {
minifiedFiles.push('<%- project.uglify %>/' + path.replace('.js', '.min.js').replace('/<%= originalPluginName %>/', ''));
});
return minifiedFiles;
} | javascript | function getMinifiedJSFiles(files) {
var minifiedFiles = [];
files.forEach(function(path) {
minifiedFiles.push('<%- project.uglify %>/' + path.replace('.js', '.min.js').replace('/<%= originalPluginName %>/', ''));
});
return minifiedFiles;
} | [
"function",
"getMinifiedJSFiles",
"(",
"files",
")",
"{",
"var",
"minifiedFiles",
"=",
"[",
"]",
";",
"files",
".",
"forEach",
"(",
"function",
"(",
"path",
")",
"{",
"minifiedFiles",
".",
"push",
"(",
"'<%- project.uglify %>/'",
"+",
"path",
".",
"replace",... | Gets the list of minified JavaScript files from the given list of files.
It will just replace ".js" by ".min.js".
@param Array files The list of files
@return Array The list of minified files | [
"Gets",
"the",
"list",
"of",
"minified",
"JavaScript",
"files",
"from",
"the",
"given",
"list",
"of",
"files",
"."
] | ce54e1a17a81ef220a90a74e834dc4a5ff0b3f6b | https://github.com/veo-labs/openveo-plugin-generator/blob/ce54e1a17a81ef220a90a74e834dc4a5ff0b3f6b/generators/app/templates/tasks/_concat.js#L13-L19 | train |
emeryrose/boscar | index.js | _createStreamPointer | function _createStreamPointer(self, stream, serializer) {
let id = uuid();
let readable = typeof stream.read === 'function';
let type = readable ? 'readable' : 'writable';
let pointer = `boscar:${type}:${id}`;
self.streams.set(id, stream);
if (readable) {
_bindReadable(pointer, stream, serializer);
... | javascript | function _createStreamPointer(self, stream, serializer) {
let id = uuid();
let readable = typeof stream.read === 'function';
let type = readable ? 'readable' : 'writable';
let pointer = `boscar:${type}:${id}`;
self.streams.set(id, stream);
if (readable) {
_bindReadable(pointer, stream, serializer);
... | [
"function",
"_createStreamPointer",
"(",
"self",
",",
"stream",
",",
"serializer",
")",
"{",
"let",
"id",
"=",
"uuid",
"(",
")",
";",
"let",
"readable",
"=",
"typeof",
"stream",
".",
"read",
"===",
"'function'",
";",
"let",
"type",
"=",
"readable",
"?",
... | Converts a stream object into a pointer string and sets up stream tracking
@param {object} self - Object with a `streams` property
@param {object} stream
@param {object} serializer
@returns {string} | [
"Converts",
"a",
"stream",
"object",
"into",
"a",
"pointer",
"string",
"and",
"sets",
"up",
"stream",
"tracking"
] | 19d3c953a4380d6d6515eb0659fffe789a9eddd0 | https://github.com/emeryrose/boscar/blob/19d3c953a4380d6d6515eb0659fffe789a9eddd0/index.js#L87-L100 | train |
emeryrose/boscar | index.js | _bindReadable | function _bindReadable(pointer, stream, serializer) {
stream.on('data', (data) => {
serializer.write(jsonrpc.notification(pointer, [data]));
});
stream.on('end', () => {
serializer.write(jsonrpc.notification(pointer, [null]));
});
stream.on('error', () => {
serializer.write(jsonrpc.notification(po... | javascript | function _bindReadable(pointer, stream, serializer) {
stream.on('data', (data) => {
serializer.write(jsonrpc.notification(pointer, [data]));
});
stream.on('end', () => {
serializer.write(jsonrpc.notification(pointer, [null]));
});
stream.on('error', () => {
serializer.write(jsonrpc.notification(po... | [
"function",
"_bindReadable",
"(",
"pointer",
",",
"stream",
",",
"serializer",
")",
"{",
"stream",
".",
"on",
"(",
"'data'",
",",
"(",
"data",
")",
"=>",
"{",
"serializer",
".",
"write",
"(",
"jsonrpc",
".",
"notification",
"(",
"pointer",
",",
"[",
"d... | Binds to readable stream events and write messages to the given serializer
@param {string} pointer
@param {object} stream
@param {object} serializer | [
"Binds",
"to",
"readable",
"stream",
"events",
"and",
"write",
"messages",
"to",
"the",
"given",
"serializer"
] | 19d3c953a4380d6d6515eb0659fffe789a9eddd0 | https://github.com/emeryrose/boscar/blob/19d3c953a4380d6d6515eb0659fffe789a9eddd0/index.js#L108-L118 | train |
localnerve/element-size-reporter | src/lib/index.js | round | function round (value, rules) {
let unit = 1.0, roundOp = Math.round;
if (rules) {
roundOp = Math[rules.type === 'top' ? 'floor' : 'ceil'];
if ('object' === typeof rules.grow) {
unit = rules.grow[rules.type] || 1.0;
}
}
return roundOp(value / unit) * unit;
} | javascript | function round (value, rules) {
let unit = 1.0, roundOp = Math.round;
if (rules) {
roundOp = Math[rules.type === 'top' ? 'floor' : 'ceil'];
if ('object' === typeof rules.grow) {
unit = rules.grow[rules.type] || 1.0;
}
}
return roundOp(value / unit) * unit;
} | [
"function",
"round",
"(",
"value",
",",
"rules",
")",
"{",
"let",
"unit",
"=",
"1.0",
",",
"roundOp",
"=",
"Math",
".",
"round",
";",
"if",
"(",
"rules",
")",
"{",
"roundOp",
"=",
"Math",
"[",
"rules",
".",
"type",
"===",
"'top'",
"?",
"'floor'",
... | Round a number to nearest multiple according to rules.
Default multiple is 1.0. Supply nearest multiple in rules.grow parameter.
Rounding rules:
type === 'top' then use floor rounding.
otherwise, use ceiling rounding.
@param {Number} value - The raw value to round.
@param {Object} [rules] - Rounding rules. If omitted... | [
"Round",
"a",
"number",
"to",
"nearest",
"multiple",
"according",
"to",
"rules",
".",
"Default",
"multiple",
"is",
"1",
".",
"0",
".",
"Supply",
"nearest",
"multiple",
"in",
"rules",
".",
"grow",
"parameter",
"."
] | f4b43c794df390a3dc89da0c28ef416a772047d7 | https://github.com/localnerve/element-size-reporter/blob/f4b43c794df390a3dc89da0c28ef416a772047d7/src/lib/index.js#L50-L61 | train |
Runnable/monitor-dog | lib/monitor.js | Monitor | function Monitor (opt) {
opt = opt || {};
this.prefix = opt.prefix || process.env.MONITOR_PREFIX || null;
this.host = opt.host || process.env.DATADOG_HOST;
this.port = opt.port || process.env.DATADOG_PORT;
this.interval = opt.interval || process.env.MONITOR_INTERVAL;
if (this.host && this.port) {
this.c... | javascript | function Monitor (opt) {
opt = opt || {};
this.prefix = opt.prefix || process.env.MONITOR_PREFIX || null;
this.host = opt.host || process.env.DATADOG_HOST;
this.port = opt.port || process.env.DATADOG_PORT;
this.interval = opt.interval || process.env.MONITOR_INTERVAL;
if (this.host && this.port) {
this.c... | [
"function",
"Monitor",
"(",
"opt",
")",
"{",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"this",
".",
"prefix",
"=",
"opt",
".",
"prefix",
"||",
"process",
".",
"env",
".",
"MONITOR_PREFIX",
"||",
"null",
";",
"this",
".",
"host",
"=",
"opt",
".",
"h... | Monitoring and reporting.
@class
@param {object} opt Monitor options.
@param {string} [opt.prefix] User defined event prefix.
@param {string} [opt.host] Datadog host.
@param {string} [opt.port] Datadog port.
@param {string} [opt.interval] Sockets Monitor stats poll interval | [
"Monitoring",
"and",
"reporting",
"."
] | 040b259dfc8c6b5d934dc235f76028e5ab9094cc | https://github.com/Runnable/monitor-dog/blob/040b259dfc8c6b5d934dc235f76028e5ab9094cc/lib/monitor.js#L31-L41 | train |
SalvatorePreviti/eslint-config-quick | eslint-config-quick/eslint-quick.js | eslint | function eslint(options) {
if (typeof options === 'boolean') {
options = { fail: options }
}
options = { ...new ESLintOptions(), ...options }
return new Promise((resolve, reject) => {
const args = generateArguments(options)
const child = spawn('node', args, { stdio: options.stdio, cwd: path.resolve... | javascript | function eslint(options) {
if (typeof options === 'boolean') {
options = { fail: options }
}
options = { ...new ESLintOptions(), ...options }
return new Promise((resolve, reject) => {
const args = generateArguments(options)
const child = spawn('node', args, { stdio: options.stdio, cwd: path.resolve... | [
"function",
"eslint",
"(",
"options",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'boolean'",
")",
"{",
"options",
"=",
"{",
"fail",
":",
"options",
"}",
"}",
"options",
"=",
"{",
"...",
"new",
"ESLintOptions",
"(",
")",
",",
"...",
"options",
... | Executes eslint for a project, asynchronously.
@param {boolean|ESLintOptions|undefined} [options=undefined] The options to use. If a boolean, options will be { fail: true|false }.
@returns {Promise<boolean>} A promise | [
"Executes",
"eslint",
"for",
"a",
"project",
"asynchronously",
"."
] | 371541613d86a3a3ef44ee4cb2c896e5cbcf602c | https://github.com/SalvatorePreviti/eslint-config-quick/blob/371541613d86a3a3ef44ee4cb2c896e5cbcf602c/eslint-config-quick/eslint-quick.js#L65-L93 | train |
LaxarJS/laxar-tooling | src/serialize.js | serializeArray | function serializeArray( array, indent = INDENT, pad = 0, space ) {
const elements = array
.map( element => serialize( element, indent, pad + indent, space ) );
return '[' + serializeList( elements, indent, pad, space ) + ']';
} | javascript | function serializeArray( array, indent = INDENT, pad = 0, space ) {
const elements = array
.map( element => serialize( element, indent, pad + indent, space ) );
return '[' + serializeList( elements, indent, pad, space ) + ']';
} | [
"function",
"serializeArray",
"(",
"array",
",",
"indent",
"=",
"INDENT",
",",
"pad",
"=",
"0",
",",
"space",
")",
"{",
"const",
"elements",
"=",
"array",
".",
"map",
"(",
"element",
"=>",
"serialize",
"(",
"element",
",",
"indent",
",",
"pad",
"+",
... | Serialize an array.
@private
@param {Array} array the array to serialize
@param {Number} [indent] the number of spaces to use for indent
@param {Number} [pad] the initial left padding
@param {String} [space] the character(s) to use for padding
@return {String} the serialized JavaScript code | [
"Serialize",
"an",
"array",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/serialize.js#L69-L74 | train |
LaxarJS/laxar-tooling | src/serialize.js | serializeObject | function serializeObject( object, indent = INDENT, pad = 0, space ) {
const properties = Object.keys( object )
.map( key => serializeKey( key ) + ': ' +
serialize( object[ key ], indent, pad + indent, space ) );
return '{' + serializeList( properties, indent, pad, space ) + '}';
} | javascript | function serializeObject( object, indent = INDENT, pad = 0, space ) {
const properties = Object.keys( object )
.map( key => serializeKey( key ) + ': ' +
serialize( object[ key ], indent, pad + indent, space ) );
return '{' + serializeList( properties, indent, pad, space ) + '}';
} | [
"function",
"serializeObject",
"(",
"object",
",",
"indent",
"=",
"INDENT",
",",
"pad",
"=",
"0",
",",
"space",
")",
"{",
"const",
"properties",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"map",
"(",
"key",
"=>",
"serializeKey",
"(",
"key",
... | Serialize an object.
@private
@param {Object} object the object to serialize
@param {Number} [indent] the number of spaces to use for indent
@param {Number} [pad] the initial left padding
@param {String} [space] the character(s) to use for padding
@return {String} the serialized JavaScript code | [
"Serialize",
"an",
"object",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/serialize.js#L85-L91 | train |
LaxarJS/laxar-tooling | src/serialize.js | serializeList | function serializeList( elements, indent = INDENT, pad = 0, space ) {
if( elements.length === 0 ) {
return '';
}
const length = elements.reduce( ( sum, e ) => sum + e.length + 2, pad );
const multiline = elements.some( element => /\n/.test( element ) );
const compact = length < LIST_LENGTH && !mul... | javascript | function serializeList( elements, indent = INDENT, pad = 0, space ) {
if( elements.length === 0 ) {
return '';
}
const length = elements.reduce( ( sum, e ) => sum + e.length + 2, pad );
const multiline = elements.some( element => /\n/.test( element ) );
const compact = length < LIST_LENGTH && !mul... | [
"function",
"serializeList",
"(",
"elements",
",",
"indent",
"=",
"INDENT",
",",
"pad",
"=",
"0",
",",
"space",
")",
"{",
"if",
"(",
"elements",
".",
"length",
"===",
"0",
")",
"{",
"return",
"''",
";",
"}",
"const",
"length",
"=",
"elements",
".",
... | Serialize the body of a list or object.
@private
@param {Array<String>} elements the serialized elements or key-value pairs
@param {Number} [indent] the number of spaces to use for indent
@param {Number} [pad] the initial left padding
@param {String} [space] the character(s) to use for padding
@return {String} the seri... | [
"Serialize",
"the",
"body",
"of",
"a",
"list",
"or",
"object",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/serialize.js#L102-L118 | train |
LaxarJS/laxar-tooling | src/serialize.js | serializeKey | function serializeKey( name ) {
const identifier = /^[A-Za-z$_][A-Za-z0-9$_]*$/.test( name );
const keyword = [
'if', 'else',
'switch', 'case', 'default',
'try', 'catch', 'finally',
'function', 'return',
'var', 'let', 'const'
].indexOf( name ) >= 0;
return ( identifier && !key... | javascript | function serializeKey( name ) {
const identifier = /^[A-Za-z$_][A-Za-z0-9$_]*$/.test( name );
const keyword = [
'if', 'else',
'switch', 'case', 'default',
'try', 'catch', 'finally',
'function', 'return',
'var', 'let', 'const'
].indexOf( name ) >= 0;
return ( identifier && !key... | [
"function",
"serializeKey",
"(",
"name",
")",
"{",
"const",
"identifier",
"=",
"/",
"^[A-Za-z$_][A-Za-z0-9$_]*$",
"/",
".",
"test",
"(",
"name",
")",
";",
"const",
"keyword",
"=",
"[",
"'if'",
",",
"'else'",
",",
"'switch'",
",",
"'case'",
",",
"'default'"... | Serialize an object key.
Wrap the key in quotes if it is either not a valid identifier or if it
is a problematic keyword.
@private
@param {String} name the key to serialize
@return {String} the serialized key | [
"Serialize",
"an",
"object",
"key",
".",
"Wrap",
"the",
"key",
"in",
"quotes",
"if",
"it",
"is",
"either",
"not",
"a",
"valid",
"identifier",
"or",
"if",
"it",
"is",
"a",
"problematic",
"keyword",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/serialize.js#L128-L139 | train |
LaxarJS/laxar-tooling | src/serialize.js | serializeValue | function serializeValue( value, indent, pad, space ) {
return leftpad( JSON.stringify( value, null, indent ), pad, space );
} | javascript | function serializeValue( value, indent, pad, space ) {
return leftpad( JSON.stringify( value, null, indent ), pad, space );
} | [
"function",
"serializeValue",
"(",
"value",
",",
"indent",
",",
"pad",
",",
"space",
")",
"{",
"return",
"leftpad",
"(",
"JSON",
".",
"stringify",
"(",
"value",
",",
"null",
",",
"indent",
")",
",",
"pad",
",",
"space",
")",
";",
"}"
] | Serialize an atomic value.
Treat as JSON and pad with spaces to the specified indent.
@private
@param {Object} value the value to serialize
@param {Number} [indent] the number of spaces to use for indent
@param {Number} [pad] the initial left padding
@param {String} [space] the character(s) to use for padding
@return {... | [
"Serialize",
"an",
"atomic",
"value",
".",
"Treat",
"as",
"JSON",
"and",
"pad",
"with",
"spaces",
"to",
"the",
"specified",
"indent",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/serialize.js#L151-L153 | train |
LaxarJS/laxar-tooling | src/serialize.js | leftpad | function leftpad( string, pad, space ) {
return string.split( '\n' ).join( `\n${spaces( pad, space )}` );
} | javascript | function leftpad( string, pad, space ) {
return string.split( '\n' ).join( `\n${spaces( pad, space )}` );
} | [
"function",
"leftpad",
"(",
"string",
",",
"pad",
",",
"space",
")",
"{",
"return",
"string",
".",
"split",
"(",
"'\\n'",
")",
".",
"join",
"(",
"`",
"\\n",
"${",
"spaces",
"(",
"pad",
",",
"space",
")",
"}",
"`",
")",
";",
"}"
] | Take a multi-line string and pad each line with the given number of spaces.
@private
@param {String} string the string to pad
@param {Number} [pad] the number of spaces to use for indent
@param {String} [space] the character to repeat
@return {String} a string that can be used as padding | [
"Take",
"a",
"multi",
"-",
"line",
"string",
"and",
"pad",
"each",
"line",
"with",
"the",
"given",
"number",
"of",
"spaces",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/serialize.js#L174-L176 | train |
byu-oit/sans-server-router | bin/router.js | Router | function Router(req, res, next) {
const server = this;
const state = {
method: req.method.toUpperCase(),
params: {},
routes: routes.concat(),
routeUnhandled: true,
server: server,
};
run(state, req, res, err => {
req... | javascript | function Router(req, res, next) {
const server = this;
const state = {
method: req.method.toUpperCase(),
params: {},
routes: routes.concat(),
routeUnhandled: true,
server: server,
};
run(state, req, res, err => {
req... | [
"function",
"Router",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"const",
"server",
"=",
"this",
";",
"const",
"state",
"=",
"{",
"method",
":",
"req",
".",
"method",
".",
"toUpperCase",
"(",
")",
",",
"params",
":",
"{",
"}",
",",
"routes",
... | define the router middleware | [
"define",
"the",
"router",
"middleware"
] | d9986804fce06c9ec20098b7923cd83e7805a2d9 | https://github.com/byu-oit/sans-server-router/blob/d9986804fce06c9ec20098b7923cd83e7805a2d9/bin/router.js#L50-L64 | train |
Mammut-FE/nejm | src/util/cache/cookie.js | function(_name){
var _cookie = document.cookie,
_search = '\\b'+_name+'=',
_index1 = _cookie.search(_search);
if (_index1<0) return '';
_index1 += _search.length-2;
var _index2 = _cookie.indexOf(';',_index1);
if (_index2<0) _ind... | javascript | function(_name){
var _cookie = document.cookie,
_search = '\\b'+_name+'=',
_index1 = _cookie.search(_search);
if (_index1<0) return '';
_index1 += _search.length-2;
var _index2 = _cookie.indexOf(';',_index1);
if (_index2<0) _ind... | [
"function",
"(",
"_name",
")",
"{",
"var",
"_cookie",
"=",
"document",
".",
"cookie",
",",
"_search",
"=",
"'\\\\b'",
"+",
"_name",
"+",
"'='",
",",
"_index1",
"=",
"_cookie",
".",
"search",
"(",
"_search",
")",
";",
"if",
"(",
"_index1",
"<",
"0",
... | milliseconds of one day | [
"milliseconds",
"of",
"one",
"day"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/cache/cookie.js#L55-L64 | train | |
arokor/pararr.js | lib/pararr.js | add | function add(item) {
var newEnd = (end + 1) % BUF_SIZE;
if(end >= 0 && newEnd === begin) {
throw Error('Buffer overflow: Buffer exceeded max size: ' + BUF_SIZE);
}
buffer[newEnd] = item;
end = newEnd;
} | javascript | function add(item) {
var newEnd = (end + 1) % BUF_SIZE;
if(end >= 0 && newEnd === begin) {
throw Error('Buffer overflow: Buffer exceeded max size: ' + BUF_SIZE);
}
buffer[newEnd] = item;
end = newEnd;
} | [
"function",
"add",
"(",
"item",
")",
"{",
"var",
"newEnd",
"=",
"(",
"end",
"+",
"1",
")",
"%",
"BUF_SIZE",
";",
"if",
"(",
"end",
">=",
"0",
"&&",
"newEnd",
"===",
"begin",
")",
"{",
"throw",
"Error",
"(",
"'Buffer overflow: Buffer exceeded max size: '"... | Add item to buffer | [
"Add",
"item",
"to",
"buffer"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L31-L40 | train |
arokor/pararr.js | lib/pararr.js | next | function next() {
var next;
if (end < 0) { // Buffer is empty
return null;
}
next = buffer[begin];
delete buffer[begin];
if (begin === end) { // Last element
initBuffer();
} else {
begin = (begin + 1) % BUF_SIZE;
}
return next;
} | javascript | function next() {
var next;
if (end < 0) { // Buffer is empty
return null;
}
next = buffer[begin];
delete buffer[begin];
if (begin === end) { // Last element
initBuffer();
} else {
begin = (begin + 1) % BUF_SIZE;
}
return next;
} | [
"function",
"next",
"(",
")",
"{",
"var",
"next",
";",
"if",
"(",
"end",
"<",
"0",
")",
"{",
"// Buffer is empty",
"return",
"null",
";",
"}",
"next",
"=",
"buffer",
"[",
"begin",
"]",
";",
"delete",
"buffer",
"[",
"begin",
"]",
";",
"if",
"(",
"... | Get next item from buffer | [
"Get",
"next",
"item",
"from",
"buffer"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L43-L59 | train |
arokor/pararr.js | lib/pararr.js | dispatchWorkItems | function dispatchWorkItems() {
var i,
workItem;
if (!buffer.isEmpty()) {
i = workerJobCount.indexOf(0);
if(i >= 0) { //Free worker found
workItem = buffer.next();
// Send task to worker
workerExec(i, workItem);
//Check for more free workers
dispatchWorkItems();
}
}
} | javascript | function dispatchWorkItems() {
var i,
workItem;
if (!buffer.isEmpty()) {
i = workerJobCount.indexOf(0);
if(i >= 0) { //Free worker found
workItem = buffer.next();
// Send task to worker
workerExec(i, workItem);
//Check for more free workers
dispatchWorkItems();
}
}
} | [
"function",
"dispatchWorkItems",
"(",
")",
"{",
"var",
"i",
",",
"workItem",
";",
"if",
"(",
"!",
"buffer",
".",
"isEmpty",
"(",
")",
")",
"{",
"i",
"=",
"workerJobCount",
".",
"indexOf",
"(",
"0",
")",
";",
"if",
"(",
"i",
">=",
"0",
")",
"{",
... | Dispatch work items on free workers | [
"Dispatch",
"work",
"items",
"on",
"free",
"workers"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L83-L98 | train |
arokor/pararr.js | lib/pararr.js | handleArrayResult | function handleArrayResult(m, workerIdx) {
var job = jobs[m.context.jobID],
partition = m.context.partition,
subResult = m.result,
result = [],
i;
job.result[partition] = subResult;
// Increase callback count.
job.cbCount++;
// When all workers are finished return result
if(job.cbCount === workers.le... | javascript | function handleArrayResult(m, workerIdx) {
var job = jobs[m.context.jobID],
partition = m.context.partition,
subResult = m.result,
result = [],
i;
job.result[partition] = subResult;
// Increase callback count.
job.cbCount++;
// When all workers are finished return result
if(job.cbCount === workers.le... | [
"function",
"handleArrayResult",
"(",
"m",
",",
"workerIdx",
")",
"{",
"var",
"job",
"=",
"jobs",
"[",
"m",
".",
"context",
".",
"jobID",
"]",
",",
"partition",
"=",
"m",
".",
"context",
".",
"partition",
",",
"subResult",
"=",
"m",
".",
"result",
",... | Handles results from parallel array operations | [
"Handles",
"results",
"from",
"parallel",
"array",
"operations"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L124-L149 | train |
arokor/pararr.js | lib/pararr.js | handleExecResult | function handleExecResult(m, workerIdx) {
var job = jobs[m.context.jobID];
job.cb(m.err, m.result);
// Worker is finished.
workerJobCount[workerIdx]--;
dispatchWorkItems();
} | javascript | function handleExecResult(m, workerIdx) {
var job = jobs[m.context.jobID];
job.cb(m.err, m.result);
// Worker is finished.
workerJobCount[workerIdx]--;
dispatchWorkItems();
} | [
"function",
"handleExecResult",
"(",
"m",
",",
"workerIdx",
")",
"{",
"var",
"job",
"=",
"jobs",
"[",
"m",
".",
"context",
".",
"jobID",
"]",
";",
"job",
".",
"cb",
"(",
"m",
".",
"err",
",",
"m",
".",
"result",
")",
";",
"// Worker is finished.",
... | Handles results from parallel function execution | [
"Handles",
"results",
"from",
"parallel",
"function",
"execution"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L152-L160 | train |
arokor/pararr.js | lib/pararr.js | handleMessage | function handleMessage(m, workerIdx) {
var job = jobs[m.context.jobID];
switch(job.type) {
case 'func':
handleArrayResult(m, workerIdx);
break;
case 'exec':
handleExecResult(m, workerIdx);
break;
default:
throw Error('Invalid job type: ' + job.type);
}
} | javascript | function handleMessage(m, workerIdx) {
var job = jobs[m.context.jobID];
switch(job.type) {
case 'func':
handleArrayResult(m, workerIdx);
break;
case 'exec':
handleExecResult(m, workerIdx);
break;
default:
throw Error('Invalid job type: ' + job.type);
}
} | [
"function",
"handleMessage",
"(",
"m",
",",
"workerIdx",
")",
"{",
"var",
"job",
"=",
"jobs",
"[",
"m",
".",
"context",
".",
"jobID",
"]",
";",
"switch",
"(",
"job",
".",
"type",
")",
"{",
"case",
"'func'",
":",
"handleArrayResult",
"(",
"m",
",",
... | Handles messages from the workers | [
"Handles",
"messages",
"from",
"the",
"workers"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L163-L176 | train |
arokor/pararr.js | lib/pararr.js | executeParallel | function executeParallel(op, arr, iter, cb) {
var chunkSize = Math.floor(arr.length / numCPUs),
worker,
iterStr,
task,
offset,
i;
// Lazy initialization
init();
// Check params
if (!cb) {
throw Error('Expected callback');
}
if (arr == null) {
cb(null, []);
return;
}
if (!Array.isArray(a... | javascript | function executeParallel(op, arr, iter, cb) {
var chunkSize = Math.floor(arr.length / numCPUs),
worker,
iterStr,
task,
offset,
i;
// Lazy initialization
init();
// Check params
if (!cb) {
throw Error('Expected callback');
}
if (arr == null) {
cb(null, []);
return;
}
if (!Array.isArray(a... | [
"function",
"executeParallel",
"(",
"op",
",",
"arr",
",",
"iter",
",",
"cb",
")",
"{",
"var",
"chunkSize",
"=",
"Math",
".",
"floor",
"(",
"arr",
".",
"length",
"/",
"numCPUs",
")",
",",
"worker",
",",
"iterStr",
",",
"task",
",",
"offset",
",",
"... | Execute an array operation in parallel | [
"Execute",
"an",
"array",
"operation",
"in",
"parallel"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L186-L252 | train |
arokor/pararr.js | lib/pararr.js | merge | function merge(arrays, comp) {
var mid,
a1, i1,
a2, i2,
result;
if (arrays.length === 1) {
return arrays[0];
} else if (arrays.length === 2) {
// merge two arrays
a1 = arrays[0];
a2 = arrays[1];
i1 = i2 = 0;
result = [];
while(i1 < a1.length && i2 < a2.length) {
if (comp(a2[i2],... | javascript | function merge(arrays, comp) {
var mid,
a1, i1,
a2, i2,
result;
if (arrays.length === 1) {
return arrays[0];
} else if (arrays.length === 2) {
// merge two arrays
a1 = arrays[0];
a2 = arrays[1];
i1 = i2 = 0;
result = [];
while(i1 < a1.length && i2 < a2.length) {
if (comp(a2[i2],... | [
"function",
"merge",
"(",
"arrays",
",",
"comp",
")",
"{",
"var",
"mid",
",",
"a1",
",",
"i1",
",",
"a2",
",",
"i2",
",",
"result",
";",
"if",
"(",
"arrays",
".",
"length",
"===",
"1",
")",
"{",
"return",
"arrays",
"[",
"0",
"]",
";",
"}",
"e... | Merge a number of arrays | [
"Merge",
"a",
"number",
"of",
"arrays"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L342-L382 | train |
arokor/pararr.js | lib/pararr.js | defaultComp | function defaultComp(a,b) {
var as = '' + a,
bs = '' + b;
if (as < bs) {
return -1;
} else if (as > bs) {
return 1;
} else {
return 0;
}
} | javascript | function defaultComp(a,b) {
var as = '' + a,
bs = '' + b;
if (as < bs) {
return -1;
} else if (as > bs) {
return 1;
} else {
return 0;
}
} | [
"function",
"defaultComp",
"(",
"a",
",",
"b",
")",
"{",
"var",
"as",
"=",
"''",
"+",
"a",
",",
"bs",
"=",
"''",
"+",
"b",
";",
"if",
"(",
"as",
"<",
"bs",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"as",
">",
"bs",
")",
... | The default comparator | [
"The",
"default",
"comparator"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L385-L396 | train |
arokor/pararr.js | lib/pararr.js | constructSortingFunction | function constructSortingFunction(comp) {
var funcStr = 'function(arr) { return arr.sort(%comp%); };',
func;
funcStr = funcStr.replace('%comp%', comp.toString());
// Eval is evil but necessary in this case
eval('func = '+ funcStr);
return func;
} | javascript | function constructSortingFunction(comp) {
var funcStr = 'function(arr) { return arr.sort(%comp%); };',
func;
funcStr = funcStr.replace('%comp%', comp.toString());
// Eval is evil but necessary in this case
eval('func = '+ funcStr);
return func;
} | [
"function",
"constructSortingFunction",
"(",
"comp",
")",
"{",
"var",
"funcStr",
"=",
"'function(arr) { return arr.sort(%comp%); };'",
",",
"func",
";",
"funcStr",
"=",
"funcStr",
".",
"replace",
"(",
"'%comp%'",
",",
"comp",
".",
"toString",
"(",
")",
")",
";",... | Construct a sorting function for a specific comparator | [
"Construct",
"a",
"sorting",
"function",
"for",
"a",
"specific",
"comparator"
] | 215ddc452e24fd239b42de3997738510d1888135 | https://github.com/arokor/pararr.js/blob/215ddc452e24fd239b42de3997738510d1888135/lib/pararr.js#L399-L407 | train |
veo-labs/openveo-api | lib/grunt/ngDpTask/ngDpTask.js | mergeResults | function mergeResults(newResults) {
if (newResults.definitions)
results.definitions = utilApi.joinArray(results.definitions, newResults.definitions);
if (newResults.dependencies)
results.dependencies = utilApi.joinArray(results.dependencies, newResults.dependencies);
if (newResults.module)
... | javascript | function mergeResults(newResults) {
if (newResults.definitions)
results.definitions = utilApi.joinArray(results.definitions, newResults.definitions);
if (newResults.dependencies)
results.dependencies = utilApi.joinArray(results.dependencies, newResults.dependencies);
if (newResults.module)
... | [
"function",
"mergeResults",
"(",
"newResults",
")",
"{",
"if",
"(",
"newResults",
".",
"definitions",
")",
"results",
".",
"definitions",
"=",
"utilApi",
".",
"joinArray",
"(",
"results",
".",
"definitions",
",",
"newResults",
".",
"definitions",
")",
";",
"... | Merges results from sub expressions into results for the current expression.
@param {Object} newResults Sub expressions results
@param {Array} [newResults.definitions] The list of definitions in sub expression
@param {Array} [newResults.dependencies] The list of dependencies in sub expression
@param {String} [newResul... | [
"Merges",
"results",
"from",
"sub",
"expressions",
"into",
"results",
"for",
"the",
"current",
"expression",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/grunt/ngDpTask/ngDpTask.js#L66-L75 | train |
veo-labs/openveo-api | lib/grunt/ngDpTask/ngDpTask.js | findScript | function findScript(scripts, property, value) {
for (var i = 0; i < scripts.length; i++) {
if ((Object.prototype.toString.call(scripts[i][property]) === '[object Array]' &&
scripts[i][property].indexOf(value) > -1) ||
(scripts[i][property] === value)
) {
return scripts[i];
}
}
r... | javascript | function findScript(scripts, property, value) {
for (var i = 0; i < scripts.length; i++) {
if ((Object.prototype.toString.call(scripts[i][property]) === '[object Array]' &&
scripts[i][property].indexOf(value) > -1) ||
(scripts[i][property] === value)
) {
return scripts[i];
}
}
r... | [
"function",
"findScript",
"(",
"scripts",
",",
"property",
",",
"value",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"scripts",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"Object",
".",
"prototype",
".",
"toString",
"... | Fetches a script from a list of scripts.
@method findScript
@param {Array} scripts The list of scripts
@param {String} property The script property used to identify the script to fetch
@param {String} value The expected value of the script property
@return {Object|Null} The found script or null if not found
@private | [
"Fetches",
"a",
"script",
"from",
"a",
"list",
"of",
"scripts",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/grunt/ngDpTask/ngDpTask.js#L156-L167 | train |
veo-labs/openveo-api | lib/grunt/ngDpTask/ngDpTask.js | findLongestDependencyChains | function findLongestDependencyChains(scripts, script, modulesToIgnore) {
var chains = [];
if (!script) script = scripts[0];
// Avoid circular dependencies
if (modulesToIgnore && script.module && modulesToIgnore.indexOf(script.module) !== -1) return chains;
// Get script dependencies
if (script.dependenci... | javascript | function findLongestDependencyChains(scripts, script, modulesToIgnore) {
var chains = [];
if (!script) script = scripts[0];
// Avoid circular dependencies
if (modulesToIgnore && script.module && modulesToIgnore.indexOf(script.module) !== -1) return chains;
// Get script dependencies
if (script.dependenci... | [
"function",
"findLongestDependencyChains",
"(",
"scripts",
",",
"script",
",",
"modulesToIgnore",
")",
"{",
"var",
"chains",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"script",
")",
"script",
"=",
"scripts",
"[",
"0",
"]",
";",
"// Avoid circular dependencies",
"i... | Browses a flat list of scripts to find a script longest dependency chains.
Each script may have several dependencies, each dependency can also have several dependencies.
findLongestDependencyChains helps find the longest dependency chain of one of the script.
As the script may have several longest dependency chain, a ... | [
"Browses",
"a",
"flat",
"list",
"of",
"scripts",
"to",
"find",
"a",
"script",
"longest",
"dependency",
"chains",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/grunt/ngDpTask/ngDpTask.js#L190-L242 | train |
veo-labs/openveo-api | lib/grunt/ngDpTask/ngDpTask.js | buildTree | function buildTree(scripts) {
var chains = [];
var tree = {
children: []
};
var currentTreeNode = tree;
// Get the longest dependency chain for each script with the highest dependency
// as the first element of the chain
scripts.forEach(function(script) {
chains = chains.concat(findLongestDepende... | javascript | function buildTree(scripts) {
var chains = [];
var tree = {
children: []
};
var currentTreeNode = tree;
// Get the longest dependency chain for each script with the highest dependency
// as the first element of the chain
scripts.forEach(function(script) {
chains = chains.concat(findLongestDepende... | [
"function",
"buildTree",
"(",
"scripts",
")",
"{",
"var",
"chains",
"=",
"[",
"]",
";",
"var",
"tree",
"=",
"{",
"children",
":",
"[",
"]",
"}",
";",
"var",
"currentTreeNode",
"=",
"tree",
";",
"// Get the longest dependency chain for each script with the highes... | Builds the dependencies tree.
@method buildTree
@param {Array} scripts The flat list of scripts with for each script:
- **dependencies** The list of dependency names of the script
- **definitions** The list of definition names of the script
- **path** The script path
@return {Array} The list of scripts with their depe... | [
"Builds",
"the",
"dependencies",
"tree",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/grunt/ngDpTask/ngDpTask.js#L255-L311 | train |
urturn/urturn-expression-api | lib/expression-api/import.js | function(list, name) {
if (Object.prototype.toString.call(list) === '[object Array]' && Object.prototype.toString.call(name) === '[object String]') {
for (var i = 0; i < list.length; i++) {
if (list[i] === name) {
return true;
}
}
}
return false;
} | javascript | function(list, name) {
if (Object.prototype.toString.call(list) === '[object Array]' && Object.prototype.toString.call(name) === '[object String]') {
for (var i = 0; i < list.length; i++) {
if (list[i] === name) {
return true;
}
}
}
return false;
} | [
"function",
"(",
"list",
",",
"name",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"list",
")",
"===",
"'[object Array]'",
"&&",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"name",
")",
"===",
... | Internal function for checking if a string is contained in a given array | [
"Internal",
"function",
"for",
"checking",
"if",
"a",
"string",
"is",
"contained",
"in",
"a",
"given",
"array"
] | 009a272ee670dbbe5eefb5c070ed827dd778bb07 | https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/expression-api/import.js#L12-L21 | train | |
atsid/circuits-js | js/declare.js | isInstanceOf | function isInstanceOf(cls) {
var i, l, bases = this.constructor._meta.bases;
for (i = 0, l = bases.length; i < l; i += 1) {
if (bases[i] === cls) {
return true;
}
}
return this instanceof cls;
} | javascript | function isInstanceOf(cls) {
var i, l, bases = this.constructor._meta.bases;
for (i = 0, l = bases.length; i < l; i += 1) {
if (bases[i] === cls) {
return true;
}
}
return this instanceof cls;
} | [
"function",
"isInstanceOf",
"(",
"cls",
")",
"{",
"var",
"i",
",",
"l",
",",
"bases",
"=",
"this",
".",
"constructor",
".",
"_meta",
".",
"bases",
";",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"bases",
".",
"length",
";",
"i",
"<",
"l",
";",
... | emulation of "instanceof" | [
"emulation",
"of",
"instanceof"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/declare.js#L311-L319 | train |
atsid/circuits-js | js/declare.js | safeMixin | function safeMixin(target, source) {
var name, t;
// add props adding metadata for incoming functions skipping a constructor
for (name in source) {
t = source[name];
if ((t !== op[name] || !(name in op)) && name !== cname) {
if (opts.call(t) === "[object F... | javascript | function safeMixin(target, source) {
var name, t;
// add props adding metadata for incoming functions skipping a constructor
for (name in source) {
t = source[name];
if ((t !== op[name] || !(name in op)) && name !== cname) {
if (opts.call(t) === "[object F... | [
"function",
"safeMixin",
"(",
"target",
",",
"source",
")",
"{",
"var",
"name",
",",
"t",
";",
"// add props adding metadata for incoming functions skipping a constructor",
"for",
"(",
"name",
"in",
"source",
")",
"{",
"t",
"=",
"source",
"[",
"name",
"]",
";",
... | implementation of safe mixin function | [
"implementation",
"of",
"safe",
"mixin",
"function"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/declare.js#L332-L346 | train |
cronvel/roots-db | lib/doormen-extensions.js | toLink | function toLink( data ) {
if ( data && typeof data === 'object' ) {
if ( data.constructor.name === 'ObjectID' || data.constructor.name === 'ObjectId' ) {
return { _id: data } ;
}
data._id = toObjectId( data._id ) ;
}
else if ( typeof data === 'string' ) {
try {
data = { _id: mongodb.ObjectID( data ) }... | javascript | function toLink( data ) {
if ( data && typeof data === 'object' ) {
if ( data.constructor.name === 'ObjectID' || data.constructor.name === 'ObjectId' ) {
return { _id: data } ;
}
data._id = toObjectId( data._id ) ;
}
else if ( typeof data === 'string' ) {
try {
data = { _id: mongodb.ObjectID( data ) }... | [
"function",
"toLink",
"(",
"data",
")",
"{",
"if",
"(",
"data",
"&&",
"typeof",
"data",
"===",
"'object'",
")",
"{",
"if",
"(",
"data",
".",
"constructor",
".",
"name",
"===",
"'ObjectID'",
"||",
"data",
".",
"constructor",
".",
"name",
"===",
"'Object... | Allow one to pass the whole linked target object | [
"Allow",
"one",
"to",
"pass",
"the",
"whole",
"linked",
"target",
"object"
] | 7945a32677e4243d7a1200b9f47e7d06b7b6b56f | https://github.com/cronvel/roots-db/blob/7945a32677e4243d7a1200b9f47e7d06b7b6b56f/lib/doormen-extensions.js#L146-L162 | train |
studybreak/casio | lib/cql.js | quote | function quote(s) {
if (typeof(s) === 'string') {
return "'" + s.replace(/'/g, "''") + "'";
} else if (s instanceof Array) {
return _.map(s, quote).join(', ');
}
return s;
} | javascript | function quote(s) {
if (typeof(s) === 'string') {
return "'" + s.replace(/'/g, "''") + "'";
} else if (s instanceof Array) {
return _.map(s, quote).join(', ');
}
return s;
} | [
"function",
"quote",
"(",
"s",
")",
"{",
"if",
"(",
"typeof",
"(",
"s",
")",
"===",
"'string'",
")",
"{",
"return",
"\"'\"",
"+",
"s",
".",
"replace",
"(",
"/",
"'",
"/",
"g",
",",
"\"''\"",
")",
"+",
"\"'\"",
";",
"}",
"else",
"if",
"(",
"s"... | escape all single-quotes on strings... | [
"escape",
"all",
"single",
"-",
"quotes",
"on",
"strings",
"..."
] | 814546bdd4c861cc363d5398762035598f6dbc09 | https://github.com/studybreak/casio/blob/814546bdd4c861cc363d5398762035598f6dbc09/lib/cql.js#L5-L13 | train |
Thorinjs/Thorin-store-sql | lib/loader.js | ToJSON | function ToJSON(jsonName) {
if (jsonName === 'result') jsonName = 'default';
let args = Array.prototype.slice.call(arguments);
if (typeof jsonName === 'undefined') {
jsonName = 'default';
} else if (typeof jsonName === 'string') {
args.splice(0, 1); //remove the name... | javascript | function ToJSON(jsonName) {
if (jsonName === 'result') jsonName = 'default';
let args = Array.prototype.slice.call(arguments);
if (typeof jsonName === 'undefined') {
jsonName = 'default';
} else if (typeof jsonName === 'string') {
args.splice(0, 1); //remove the name... | [
"function",
"ToJSON",
"(",
"jsonName",
")",
"{",
"if",
"(",
"jsonName",
"===",
"'result'",
")",
"jsonName",
"=",
"'default'",
";",
"let",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"if",
"(",
"typeof"... | wrap the toJSON function to exclude private fields. | [
"wrap",
"the",
"toJSON",
"function",
"to",
"exclude",
"private",
"fields",
"."
] | d863a6cc9902dbc69fbdc3a49ba7a1a6d17613f0 | https://github.com/Thorinjs/Thorin-store-sql/blob/d863a6cc9902dbc69fbdc3a49ba7a1a6d17613f0/lib/loader.js#L199-L231 | train |
cronvel/babel-tower | lib/en.js | switchPersonStr | function switchPersonStr( str ) {
var switchPersonStrVerb = {} ;
return str.replace( /\s+|(i|you|he|she|it|we|they)\s+(\S+)(?=\s)/gi , ( match , pronoun , verb ) => {
if ( ! pronoun ) { return match ; }
var person = null , plural = null , switchedPronoun = null ;
pronoun = pronoun.toLowerCase() ;
verb = ve... | javascript | function switchPersonStr( str ) {
var switchPersonStrVerb = {} ;
return str.replace( /\s+|(i|you|he|she|it|we|they)\s+(\S+)(?=\s)/gi , ( match , pronoun , verb ) => {
if ( ! pronoun ) { return match ; }
var person = null , plural = null , switchedPronoun = null ;
pronoun = pronoun.toLowerCase() ;
verb = ve... | [
"function",
"switchPersonStr",
"(",
"str",
")",
"{",
"var",
"switchPersonStrVerb",
"=",
"{",
"}",
";",
"return",
"str",
".",
"replace",
"(",
"/",
"\\s+|(i|you|he|she|it|we|they)\\s+(\\S+)(?=\\s)",
"/",
"gi",
",",
"(",
"match",
",",
"pronoun",
",",
"verb",
")",... | Switch a person, using a string | [
"Switch",
"a",
"person",
"using",
"a",
"string"
] | ad1e73b73eb74ae97cdbff3b782a641a48b57eb6 | https://github.com/cronvel/babel-tower/blob/ad1e73b73eb74ae97cdbff3b782a641a48b57eb6/lib/en.js#L74-L103 | train |
LeisureLink/magicbus | lib/event-dispatcher.js | on | function on(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
for (let i... | javascript | function on(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
for (let i... | [
"function",
"on",
"(",
"eventNamesOrPatterns",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"eventNamesOrPatterns",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Must pass at least one event name or matching RegEx'",
")",
";",
"}",
"assert",
".",
"func",
"(",
"handler",
... | Subscribe to an event
@public
@method
@param {String|RegEx|Array} eventNamesOrPatterns - name(s) of event, or pattern(s) for RegEx matching (required)
@param {Function} handler - event handler (required) | [
"Subscribe",
"to",
"an",
"event"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/event-dispatcher.js#L32-L46 | train |
LeisureLink/magicbus | lib/event-dispatcher.js | once | function once(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
let defe... | javascript | function once(eventNamesOrPatterns, handler) {
if (!eventNamesOrPatterns) {
throw new Error('Must pass at least one event name or matching RegEx');
}
assert.func(handler, 'handler');
if (!Array.isArray(eventNamesOrPatterns)) {
eventNamesOrPatterns = [eventNamesOrPatterns];
}
let defe... | [
"function",
"once",
"(",
"eventNamesOrPatterns",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"eventNamesOrPatterns",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Must pass at least one event name or matching RegEx'",
")",
";",
"}",
"assert",
".",
"func",
"(",
"handler"... | Subscribe to an event for one event only
@public
@method
@param {String|RegEx|Array} eventNamesOrPatterns - name(s) of event, or pattern(s) for RegEx matching (required)
@param {Function} handler - event handler (required)
@returns {Promise} a promise that is fulfilled when the event has been processed | [
"Subscribe",
"to",
"an",
"event",
"for",
"one",
"event",
"only"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/event-dispatcher.js#L57-L74 | train |
arthmoeros/rik-health | src/health-loader.js | setupHealth | function setupHealth(expressRouter, baseURI, dependenciesDef, logger) {
if (typeof (dependenciesDef) === 'string') {
if (!dependenciesDef.startsWith('/')) {
dependenciesDef = `${process.cwd()}/${dependenciesDef}`;
}
if (!fs.existsSync(dependenciesDef)) {
throw new Error(`Health dependencies fi... | javascript | function setupHealth(expressRouter, baseURI, dependenciesDef, logger) {
if (typeof (dependenciesDef) === 'string') {
if (!dependenciesDef.startsWith('/')) {
dependenciesDef = `${process.cwd()}/${dependenciesDef}`;
}
if (!fs.existsSync(dependenciesDef)) {
throw new Error(`Health dependencies fi... | [
"function",
"setupHealth",
"(",
"expressRouter",
",",
"baseURI",
",",
"dependenciesDef",
",",
"logger",
")",
"{",
"if",
"(",
"typeof",
"(",
"dependenciesDef",
")",
"===",
"'string'",
")",
"{",
"if",
"(",
"!",
"dependenciesDef",
".",
"startsWith",
"(",
"'/'",... | Setup a healthcheck endpoint in the specified Router
@param {express.Router} expressRouter Express Router reference
@param {string} baseURI Base URI where to setup a health endpoint
@param {(any|string)} dependenciesDef dependencies to check (can be an object or a yml file name)
@param {*} logger Logger object that mu... | [
"Setup",
"a",
"healthcheck",
"endpoint",
"in",
"the",
"specified",
"Router"
] | ef619216f440c3c8efa7104fc59499c7bf6d174d | https://github.com/arthmoeros/rik-health/blob/ef619216f440c3c8efa7104fc59499c7bf6d174d/src/health-loader.js#L17-L32 | train |
Mammut-FE/nejm | src/util/placeholder/platform/holder.patch.js | function(_id){
var _input = _e._$get(_id);
_cache[_id] = 2;
if (!!_input.value) return;
_e._$setStyle(
_e._$wrapInline(_input,_ropt),
'display','none'
);
} | javascript | function(_id){
var _input = _e._$get(_id);
_cache[_id] = 2;
if (!!_input.value) return;
_e._$setStyle(
_e._$wrapInline(_input,_ropt),
'display','none'
);
} | [
"function",
"(",
"_id",
")",
"{",
"var",
"_input",
"=",
"_e",
".",
"_$get",
"(",
"_id",
")",
";",
"_cache",
"[",
"_id",
"]",
"=",
"2",
";",
"if",
"(",
"!",
"!",
"_input",
".",
"value",
")",
"return",
";",
"_e",
".",
"_$setStyle",
"(",
"_e",
"... | input foucs hide placeholder | [
"input",
"foucs",
"hide",
"placeholder"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/placeholder/platform/holder.patch.js#L30-L38 | train | |
Mammut-FE/nejm | src/util/placeholder/platform/holder.patch.js | function(_input,_clazz){
var _id = _e._$id(_input),
_label = _e._$wrapInline(_input,{
tag:'label',
clazz:_clazz,
nid:_ropt.nid
});
_label.htmlFor = _id;
var _text = _e._$attr(_input,'placeholder')||'';
... | javascript | function(_input,_clazz){
var _id = _e._$id(_input),
_label = _e._$wrapInline(_input,{
tag:'label',
clazz:_clazz,
nid:_ropt.nid
});
_label.htmlFor = _id;
var _text = _e._$attr(_input,'placeholder')||'';
... | [
"function",
"(",
"_input",
",",
"_clazz",
")",
"{",
"var",
"_id",
"=",
"_e",
".",
"_$id",
"(",
"_input",
")",
",",
"_label",
"=",
"_e",
".",
"_$wrapInline",
"(",
"_input",
",",
"{",
"tag",
":",
"'label'",
",",
"clazz",
":",
"_clazz",
",",
"nid",
... | wrapper input control | [
"wrapper",
"input",
"control"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/placeholder/platform/holder.patch.js#L59-L76 | train | |
atsid/circuits-js | gulpfile.js | inc | function inc(importance) {
var git = require('gulp-git'),
bump = require('gulp-bump'),
filter = require('gulp-filter'),
tag_version = require('gulp-tag-version');
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
// bump the version ... | javascript | function inc(importance) {
var git = require('gulp-git'),
bump = require('gulp-bump'),
filter = require('gulp-filter'),
tag_version = require('gulp-tag-version');
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
// bump the version ... | [
"function",
"inc",
"(",
"importance",
")",
"{",
"var",
"git",
"=",
"require",
"(",
"'gulp-git'",
")",
",",
"bump",
"=",
"require",
"(",
"'gulp-bump'",
")",
",",
"filter",
"=",
"require",
"(",
"'gulp-filter'",
")",
",",
"tag_version",
"=",
"require",
"(",... | Versioning tasks
Increments a version value within the package json and bower json | [
"Versioning",
"tasks",
"Increments",
"a",
"version",
"value",
"within",
"the",
"package",
"json",
"and",
"bower",
"json"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/gulpfile.js#L54-L73 | train |
LeisureLink/magicbus | lib/binder.js | Binder | function Binder(topology, logger) {
assert.object(topology, 'connectionInfo');
assert.object(logger, 'logger');
/**
* Ensures the topology is created for a route
* @private
* @param {Object} route - the route
* @returns {Promise} a promise that is fulfilled with the resulting topology names after the... | javascript | function Binder(topology, logger) {
assert.object(topology, 'connectionInfo');
assert.object(logger, 'logger');
/**
* Ensures the topology is created for a route
* @private
* @param {Object} route - the route
* @returns {Promise} a promise that is fulfilled with the resulting topology names after the... | [
"function",
"Binder",
"(",
"topology",
",",
"logger",
")",
"{",
"assert",
".",
"object",
"(",
"topology",
",",
"'connectionInfo'",
")",
";",
"assert",
".",
"object",
"(",
"logger",
",",
"'logger'",
")",
";",
"/**\n * Ensures the topology is created for a route\n... | Creates a binder which can be used to bind a publishing route to a consuming route, mainly for use across service domains
@public
@constructor
@param {Object} topology - connected rabbitmq topology
@param {Object} logger - the logger | [
"Creates",
"a",
"binder",
"which",
"can",
"be",
"used",
"to",
"bind",
"a",
"publishing",
"route",
"to",
"a",
"consuming",
"route",
"mainly",
"for",
"use",
"across",
"service",
"domains"
] | 0370c38ebb8c7917cfd3894263d734aefc2d3d29 | https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/binder.js#L13-L60 | train |
cafjs/caf_platform | lib/cron_security.js | function() {
$._.$.log && $._.$.log.debug('Cron ' + spec.name + ' waking up');
var cb0 = function(err) {
if (err) {
$._.$.log && $._.$.log.debug('pulser_cron ' +
myUtils.errToPrettyStr(err));
} e... | javascript | function() {
$._.$.log && $._.$.log.debug('Cron ' + spec.name + ' waking up');
var cb0 = function(err) {
if (err) {
$._.$.log && $._.$.log.debug('pulser_cron ' +
myUtils.errToPrettyStr(err));
} e... | [
"function",
"(",
")",
"{",
"$",
".",
"_",
".",
"$",
".",
"log",
"&&",
"$",
".",
"_",
".",
"$",
".",
"log",
".",
"debug",
"(",
"'Cron '",
"+",
"spec",
".",
"name",
"+",
"' waking up'",
")",
";",
"var",
"cb0",
"=",
"function",
"(",
"err",
")",
... | this function is bound as a method of 'that' | [
"this",
"function",
"is",
"bound",
"as",
"a",
"method",
"of",
"that"
] | 5d7ce3410f631167ca09ee495c4df7d026b0361e | https://github.com/cafjs/caf_platform/blob/5d7ce3410f631167ca09ee495c4df7d026b0361e/lib/cron_security.js#L37-L50 | train | |
atsid/circuits-js | js/ZypSMDReader.js | resolveExtensions | function resolveExtensions(schema) {
var xprops, props;
xprops = getExtendedProperties(schema, []);
//unwind the property stack so that the earliest gets inheritance link
schema.properties = schema.properties || {};
function copy... | javascript | function resolveExtensions(schema) {
var xprops, props;
xprops = getExtendedProperties(schema, []);
//unwind the property stack so that the earliest gets inheritance link
schema.properties = schema.properties || {};
function copy... | [
"function",
"resolveExtensions",
"(",
"schema",
")",
"{",
"var",
"xprops",
",",
"props",
";",
"xprops",
"=",
"getExtendedProperties",
"(",
"schema",
",",
"[",
"]",
")",
";",
"//unwind the property stack so that the earliest gets inheritance link\r",
"schema",
".",
"pr... | looks in JSONSchema objects for "extends" and copies properties to children | [
"looks",
"in",
"JSONSchema",
"objects",
"for",
"extends",
"and",
"copies",
"properties",
"to",
"children"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L89-L105 | train |
atsid/circuits-js | js/ZypSMDReader.js | resolveExtendedParameters | function resolveExtendedParameters(obj) {
// assume all references are resolved, just copy parameters down the
// inheritence chain. If I am derived check base first.
if (obj["extends"]) {
resolveExtendedParameters(obj["extends"]);
... | javascript | function resolveExtendedParameters(obj) {
// assume all references are resolved, just copy parameters down the
// inheritence chain. If I am derived check base first.
if (obj["extends"]) {
resolveExtendedParameters(obj["extends"]);
... | [
"function",
"resolveExtendedParameters",
"(",
"obj",
")",
"{",
"// assume all references are resolved, just copy parameters down the\r",
"// inheritence chain. If I am derived check base first.\r",
"if",
"(",
"obj",
"[",
"\"extends\"",
"]",
")",
"{",
"resolveExtendedParameters",
"(... | mix-in parameters for extended schemas | [
"mix",
"-",
"in",
"parameters",
"for",
"extended",
"schemas"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L108-L117 | train |
atsid/circuits-js | js/ZypSMDReader.js | resolveProperties | function resolveProperties(schema) {
logger.debug("Resolving sub-properties for " + schema.id);
// resolve inherited global parameters
resolveExtendedParameters(schema);
Object.keys(schema.services || {}).forEach(function (key) {
... | javascript | function resolveProperties(schema) {
logger.debug("Resolving sub-properties for " + schema.id);
// resolve inherited global parameters
resolveExtendedParameters(schema);
Object.keys(schema.services || {}).forEach(function (key) {
... | [
"function",
"resolveProperties",
"(",
"schema",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Resolving sub-properties for \"",
"+",
"schema",
".",
"id",
")",
";",
"// resolve inherited global parameters\r",
"resolveExtendedParameters",
"(",
"schema",
")",
";",
"Object",
... | copies properties from parent as defaults, as well as extensions for params | [
"copies",
"properties",
"from",
"parent",
"as",
"defaults",
"as",
"well",
"as",
"extensions",
"for",
"params"
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L120-L171 | train |
atsid/circuits-js | js/ZypSMDReader.js | function () {
var names = [];
Object.keys(this.smd.services || {}).forEach(function (serviceName) {
names.push(serviceName);
});
return names;
} | javascript | function () {
var names = [];
Object.keys(this.smd.services || {}).forEach(function (serviceName) {
names.push(serviceName);
});
return names;
} | [
"function",
"(",
")",
"{",
"var",
"names",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"this",
".",
"smd",
".",
"services",
"||",
"{",
"}",
")",
".",
"forEach",
"(",
"function",
"(",
"serviceName",
")",
"{",
"names",
".",
"push",
"(",
"servic... | Gets a list of the service method names defined by the SMD. | [
"Gets",
"a",
"list",
"of",
"the",
"service",
"method",
"names",
"defined",
"by",
"the",
"SMD",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L234-L242 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function () {
var services = [], smdServices = this.smd.services;
Object.keys(smdServices || []).forEach(function (serviceName) {
services.push(smdServices[serviceName]);
});
return services;
} | javascript | function () {
var services = [], smdServices = this.smd.services;
Object.keys(smdServices || []).forEach(function (serviceName) {
services.push(smdServices[serviceName]);
});
return services;
} | [
"function",
"(",
")",
"{",
"var",
"services",
"=",
"[",
"]",
",",
"smdServices",
"=",
"this",
".",
"smd",
".",
"services",
";",
"Object",
".",
"keys",
"(",
"smdServices",
"||",
"[",
"]",
")",
".",
"forEach",
"(",
"function",
"(",
"serviceName",
")",
... | Gets list of service methods in the SMD. These are the actual schema objects. | [
"Gets",
"list",
"of",
"service",
"methods",
"in",
"the",
"SMD",
".",
"These",
"are",
"the",
"actual",
"schema",
"objects",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L247-L255 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var names = [], params = this.getParameters(methodName);
params.forEach(function (param) {
names.push(param.name);
});
return names;
} | javascript | function (methodName) {
var names = [], params = this.getParameters(methodName);
params.forEach(function (param) {
names.push(param.name);
});
return names;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"names",
"=",
"[",
"]",
",",
"params",
"=",
"this",
".",
"getParameters",
"(",
"methodName",
")",
";",
"params",
".",
"forEach",
"(",
"function",
"(",
"param",
")",
"{",
"names",
".",
"push",
"(",
"para... | Gets a list of parameter names for a specified service. | [
"Gets",
"a",
"list",
"of",
"parameter",
"names",
"for",
"a",
"specified",
"service",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L272-L280 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var parameters = this.smd.parameters || [];
parameters = parameters.concat(this.smd.services[methodName].parameters || []);
return parameters;
} | javascript | function (methodName) {
var parameters = this.smd.parameters || [];
parameters = parameters.concat(this.smd.services[methodName].parameters || []);
return parameters;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"parameters",
"=",
"this",
".",
"smd",
".",
"parameters",
"||",
"[",
"]",
";",
"parameters",
"=",
"parameters",
".",
"concat",
"(",
"this",
".",
"smd",
".",
"services",
"[",
"methodName",
"]",
".",
"param... | Gets a list of parameters for a specified service. These are the actual objects. | [
"Gets",
"a",
"list",
"of",
"parameters",
"for",
"a",
"specified",
"service",
".",
"These",
"are",
"the",
"actual",
"objects",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L285-L291 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function (methodName, argName) {
var required = this.findParameter(methodName, argName).required;
//default is false, so if "required" is undefined, return false anyway
if (required) {
return true;
}
return false;
} | javascript | function (methodName, argName) {
var required = this.findParameter(methodName, argName).required;
//default is false, so if "required" is undefined, return false anyway
if (required) {
return true;
}
return false;
} | [
"function",
"(",
"methodName",
",",
"argName",
")",
"{",
"var",
"required",
"=",
"this",
".",
"findParameter",
"(",
"methodName",
",",
"argName",
")",
".",
"required",
";",
"//default is false, so if \"required\" is undefined, return false anyway\r",
"if",
"(",
"requi... | Indicates whether the specified argument on a service method is required or not. | [
"Indicates",
"whether",
"the",
"specified",
"argument",
"on",
"a",
"service",
"method",
"is",
"required",
"or",
"not",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L296-L303 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function (methodName, args) {
var service = this.smd.services[methodName],
basePath = this.getRootPath(),
url,
parameters = this.enumerateParameters(service);
//if no service target, it sits at the root
url = basePath + (servi... | javascript | function (methodName, args) {
var service = this.smd.services[methodName],
basePath = this.getRootPath(),
url,
parameters = this.enumerateParameters(service);
//if no service target, it sits at the root
url = basePath + (servi... | [
"function",
"(",
"methodName",
",",
"args",
")",
"{",
"var",
"service",
"=",
"this",
".",
"smd",
".",
"services",
"[",
"methodName",
"]",
",",
"basePath",
"=",
"this",
".",
"getRootPath",
"(",
")",
",",
"url",
",",
"parameters",
"=",
"this",
".",
"en... | For the specified service, map the args object to the target + parameters to
get a full, functional URL. | [
"For",
"the",
"specified",
"service",
"map",
"the",
"args",
"object",
"to",
"the",
"target",
"+",
"parameters",
"to",
"get",
"a",
"full",
"functional",
"URL",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L309-L327 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var params = this.getParameters(methodName),
ret;
params.forEach(function (param) {
if (param && (param.envelope === 'JSON' ||
param.envelope === 'ENTITY')) {
ret = param;
}... | javascript | function (methodName) {
var params = this.getParameters(methodName),
ret;
params.forEach(function (param) {
if (param && (param.envelope === 'JSON' ||
param.envelope === 'ENTITY')) {
ret = param;
}... | [
"function",
"(",
"methodName",
")",
"{",
"var",
"params",
"=",
"this",
".",
"getParameters",
"(",
"methodName",
")",
",",
"ret",
";",
"params",
".",
"forEach",
"(",
"function",
"(",
"param",
")",
"{",
"if",
"(",
"param",
"&&",
"(",
"param",
".",
"env... | Returns the parameter associated with the payload of a request if there is one.
@param methodName - the service method to return a payload schema for.
@return the payload parameter or undefined | [
"Returns",
"the",
"parameter",
"associated",
"with",
"the",
"payload",
"of",
"a",
"request",
"if",
"there",
"is",
"one",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L436-L446 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var smd = this.smd,
method = smd.services[methodName],
payloadName = (method && method.payload) || smd.payload;
return payloadName;
} | javascript | function (methodName) {
var smd = this.smd,
method = smd.services[methodName],
payloadName = (method && method.payload) || smd.payload;
return payloadName;
} | [
"function",
"(",
"methodName",
")",
"{",
"var",
"smd",
"=",
"this",
".",
"smd",
",",
"method",
"=",
"smd",
".",
"services",
"[",
"methodName",
"]",
",",
"payloadName",
"=",
"(",
"method",
"&&",
"method",
".",
"payload",
")",
"||",
"smd",
".",
"payloa... | Returns the name of the primary payload object.
@param methodName - the service method to return a payload schema for.
If the "payload" field is not defined on the method, check the service root. | [
"Returns",
"the",
"name",
"of",
"the",
"primary",
"payload",
"object",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L464-L471 | train | |
atsid/circuits-js | js/ZypSMDReader.js | function (methodName) {
var response = this.getResponseSchema(methodName),
payloadName = this.getResponsePayloadName(methodName),
isList = false;
if (response.type !== "null") {
if ((payloadName && response.properties[payloadName] && respons... | javascript | function (methodName) {
var response = this.getResponseSchema(methodName),
payloadName = this.getResponsePayloadName(methodName),
isList = false;
if (response.type !== "null") {
if ((payloadName && response.properties[payloadName] && respons... | [
"function",
"(",
"methodName",
")",
"{",
"var",
"response",
"=",
"this",
".",
"getResponseSchema",
"(",
"methodName",
")",
",",
"payloadName",
"=",
"this",
".",
"getResponsePayloadName",
"(",
"methodName",
")",
",",
"isList",
"=",
"false",
";",
"if",
"(",
... | Returns whether the primary payload is a list, by checking for "array" type on the SMD.
Defaults to false if return type is JSONSchema "null" primitive type. | [
"Returns",
"whether",
"the",
"primary",
"payload",
"is",
"a",
"list",
"by",
"checking",
"for",
"array",
"type",
"on",
"the",
"SMD",
".",
"Defaults",
"to",
"false",
"if",
"return",
"type",
"is",
"JSONSchema",
"null",
"primitive",
"type",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ZypSMDReader.js#L489-L502 | train | |
LaxarJS/laxar-tooling | src/artifact_listing.js | defaultAssets | function defaultAssets( { name, category, descriptor } ) {
switch( category ) {
case 'themes':
return {
assetUrls: [ descriptor.styleSource || 'css/theme.css' ]
};
case 'layouts':
case 'widgets':
case 'controls':
return {
assetsForTheme: [ de... | javascript | function defaultAssets( { name, category, descriptor } ) {
switch( category ) {
case 'themes':
return {
assetUrls: [ descriptor.styleSource || 'css/theme.css' ]
};
case 'layouts':
case 'widgets':
case 'controls':
return {
assetsForTheme: [ de... | [
"function",
"defaultAssets",
"(",
"{",
"name",
",",
"category",
",",
"descriptor",
"}",
")",
"{",
"switch",
"(",
"category",
")",
"{",
"case",
"'themes'",
":",
"return",
"{",
"assetUrls",
":",
"[",
"descriptor",
".",
"styleSource",
"||",
"'css/theme.css'",
... | Return the default assets for the given artifact, determined by it's type
and descriptor's `styleSource` and `templateSource` attributes.
@param {Object} artifact an artifact created by the {@link ArtifactCollector}
@return {Object} a partial descriptor containing the artifact's default assets | [
"Return",
"the",
"default",
"assets",
"for",
"the",
"given",
"artifact",
"determined",
"by",
"it",
"s",
"type",
"and",
"descriptor",
"s",
"styleSource",
"and",
"templateSource",
"attributes",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/artifact_listing.js#L22-L38 | train |
LaxarJS/laxar-tooling | src/artifact_listing.js | buildAssets | function buildAssets( artifact, themes = [] ) {
const { descriptor } = artifact;
const {
assets,
assetUrls,
assetsForTheme,
assetUrlsForTheme
} = extendAssets( descriptor, defaultAssets( artifact ) );
return Promise.all( [
assetResolver
.... | javascript | function buildAssets( artifact, themes = [] ) {
const { descriptor } = artifact;
const {
assets,
assetUrls,
assetsForTheme,
assetUrlsForTheme
} = extendAssets( descriptor, defaultAssets( artifact ) );
return Promise.all( [
assetResolver
.... | [
"function",
"buildAssets",
"(",
"artifact",
",",
"themes",
"=",
"[",
"]",
")",
"{",
"const",
"{",
"descriptor",
"}",
"=",
"artifact",
";",
"const",
"{",
"assets",
",",
"assetUrls",
",",
"assetsForTheme",
",",
"assetUrlsForTheme",
"}",
"=",
"extendAssets",
... | Build the assets object for an artifact and the given themes.
@memberOf ArtifactListing
@param {Object} artifact
the artifact to generate the asset listing for
@param {Array<Object>} themes
the themes to use for resolving themed artifacts
@return {Object}
the asset listing, containing sub-listings for each theme and e... | [
"Build",
"the",
"assets",
"object",
"for",
"an",
"artifact",
"and",
"the",
"given",
"themes",
"."
] | 1c4a221994f342ec03a98b68533c4de77ccfeec6 | https://github.com/LaxarJS/laxar-tooling/blob/1c4a221994f342ec03a98b68533c4de77ccfeec6/src/artifact_listing.js#L233-L251 | train |
cafjs/caf_cli | lib/Session.js | function() {
var cb = function(err, meta) {
if (err) {
var error =
new Error('BUG: __external_ca_touch__ ' +
'should not return app error');
error['err'] = err;
that.close(error);
} ... | javascript | function() {
var cb = function(err, meta) {
if (err) {
var error =
new Error('BUG: __external_ca_touch__ ' +
'should not return app error');
error['err'] = err;
that.close(error);
} ... | [
"function",
"(",
")",
"{",
"var",
"cb",
"=",
"function",
"(",
"err",
",",
"meta",
")",
"{",
"if",
"(",
"err",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"'BUG: __external_ca_touch__ '",
"+",
"'should not return app error'",
")",
";",
"error",
"[... | Internal WebSocket event handlers that delegate to external ones. | [
"Internal",
"WebSocket",
"event",
"handlers",
"that",
"delegate",
"to",
"external",
"ones",
"."
] | cec279882068bc04ee0ee0ca278bb29bd9eefd0f | https://github.com/cafjs/caf_cli/blob/cec279882068bc04ee0ee0ca278bb29bd9eefd0f/lib/Session.js#L413-L437 | train | |
liamray/nexl-engine | nexl-engine/nexl-engine-utils.js | replaceSpecialChars | function replaceSpecialChars(item) {
if (!j79.isString(item)) {
return item;
}
var result = item;
var specialChars = Object.keys(SPECIAL_CHARS_MAP);
for (var index in specialChars) {
result = replaceSpecialChar(result, specialChars[index]);
}
return result;
} | javascript | function replaceSpecialChars(item) {
if (!j79.isString(item)) {
return item;
}
var result = item;
var specialChars = Object.keys(SPECIAL_CHARS_MAP);
for (var index in specialChars) {
result = replaceSpecialChar(result, specialChars[index]);
}
return result;
} | [
"function",
"replaceSpecialChars",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"j79",
".",
"isString",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"var",
"result",
"=",
"item",
";",
"var",
"specialChars",
"=",
"Object",
".",
"keys",
"(",
"SPEC... | string representation of \n, \t characters is replaced with their real value | [
"string",
"representation",
"of",
"\\",
"n",
"\\",
"t",
"characters",
"is",
"replaced",
"with",
"their",
"real",
"value"
] | 47cd168460dbe724626953047b4d3268ba981abf | https://github.com/liamray/nexl-engine/blob/47cd168460dbe724626953047b4d3268ba981abf/nexl-engine/nexl-engine-utils.js#L238-L251 | train |
om-mani-padme-hum/ezobjects | index.js | validateClassConfig | function validateClassConfig(obj) {
/** If configuration is not plain object, throw error */
if ( typeof obj != `object` || obj.constructor.name != `Object` )
throw new Error(`ezobjects.validateClassConfig(): Invalid table configuration argument, must be plain object.`);
/** If configuration has missing ... | javascript | function validateClassConfig(obj) {
/** If configuration is not plain object, throw error */
if ( typeof obj != `object` || obj.constructor.name != `Object` )
throw new Error(`ezobjects.validateClassConfig(): Invalid table configuration argument, must be plain object.`);
/** If configuration has missing ... | [
"function",
"validateClassConfig",
"(",
"obj",
")",
"{",
"/** If configuration is not plain object, throw error */",
"if",
"(",
"typeof",
"obj",
"!=",
"`",
"`",
"||",
"obj",
".",
"constructor",
".",
"name",
"!=",
"`",
"`",
")",
"throw",
"new",
"Error",
"(",
"`... | Validate configuration for a class | [
"Validate",
"configuration",
"for",
"a",
"class"
] | 7427695776df8a747c68d5af7844df35d9b30ac2 | https://github.com/om-mani-padme-hum/ezobjects/blob/7427695776df8a747c68d5af7844df35d9b30ac2/index.js#L221-L244 | train |
cafjs/caf_platform | lib/pipeline_main.js | function(req, res) {
return function(err) {
err = err || new Error('wsFinalHandler error');
err.msg = req.body;
var code = json_rpc.ERROR_CODES.methodNotFound;
var error = json_rpc.newSysError(req.body, code,
... | javascript | function(req, res) {
return function(err) {
err = err || new Error('wsFinalHandler error');
err.msg = req.body;
var code = json_rpc.ERROR_CODES.methodNotFound;
var error = json_rpc.newSysError(req.body, code,
... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"return",
"function",
"(",
"err",
")",
"{",
"err",
"=",
"err",
"||",
"new",
"Error",
"(",
"'wsFinalHandler error'",
")",
";",
"err",
".",
"msg",
"=",
"req",
".",
"body",
";",
"var",
"code",
"=",
"json_r... | track connections for fast shutdown | [
"track",
"connections",
"for",
"fast",
"shutdown"
] | 5d7ce3410f631167ca09ee495c4df7d026b0361e | https://github.com/cafjs/caf_platform/blob/5d7ce3410f631167ca09ee495c4df7d026b0361e/lib/pipeline_main.js#L65-L76 | train | |
zazuko/trifid-core | plugins/headers-fix.js | init | function init (router) {
router.use((err, req, res, next) => {
res._headers = res._headers || {}
next(err)
})
} | javascript | function init (router) {
router.use((err, req, res, next) => {
res._headers = res._headers || {}
next(err)
})
} | [
"function",
"init",
"(",
"router",
")",
"{",
"router",
".",
"use",
"(",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"=>",
"{",
"res",
".",
"_headers",
"=",
"res",
".",
"_headers",
"||",
"{",
"}",
"next",
"(",
"err",
")",
"}",
")",
"... | workaround for missing headers after hijack
@param router | [
"workaround",
"for",
"missing",
"headers",
"after",
"hijack"
] | 47068ef508971f562e35768d829e15699ce3e19c | https://github.com/zazuko/trifid-core/blob/47068ef508971f562e35768d829e15699ce3e19c/plugins/headers-fix.js#L5-L11 | train |
zazuko/trifid-core | plugins/static-views.js | staticViews | function staticViews (router, options) {
if (!options) {
return
}
Object.keys(options).filter(urlPath => options[urlPath]).forEach((urlPath) => {
const filePath = options[urlPath]
router.get(urlPath, (req, res) => {
res.render(filePath)
})
})
} | javascript | function staticViews (router, options) {
if (!options) {
return
}
Object.keys(options).filter(urlPath => options[urlPath]).forEach((urlPath) => {
const filePath = options[urlPath]
router.get(urlPath, (req, res) => {
res.render(filePath)
})
})
} | [
"function",
"staticViews",
"(",
"router",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"return",
"}",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"filter",
"(",
"urlPath",
"=>",
"options",
"[",
"urlPath",
"]",
")",
".",
"forEac... | Adds routes for rendering static templates
@param router
@param options | [
"Adds",
"routes",
"for",
"rendering",
"static",
"templates"
] | 47068ef508971f562e35768d829e15699ce3e19c | https://github.com/zazuko/trifid-core/blob/47068ef508971f562e35768d829e15699ce3e19c/plugins/static-views.js#L6-L18 | train |
atsid/circuits-js | js/PluginMatcher.js | function (name, pointcutOrPlugin) {
var method, matchstr;
matchstr = (pointcutOrPlugin && (pointcutOrPlugin.pointcut || pointcutOrPlugin.pattern)) || pointcutOrPlugin;
if ((pointcutOrPlugin && pointcutOrPlugin.pointcut) || typeof (pointcutOrPlugin) === 'string') {
m... | javascript | function (name, pointcutOrPlugin) {
var method, matchstr;
matchstr = (pointcutOrPlugin && (pointcutOrPlugin.pointcut || pointcutOrPlugin.pattern)) || pointcutOrPlugin;
if ((pointcutOrPlugin && pointcutOrPlugin.pointcut) || typeof (pointcutOrPlugin) === 'string') {
m... | [
"function",
"(",
"name",
",",
"pointcutOrPlugin",
")",
"{",
"var",
"method",
",",
"matchstr",
";",
"matchstr",
"=",
"(",
"pointcutOrPlugin",
"&&",
"(",
"pointcutOrPlugin",
".",
"pointcut",
"||",
"pointcutOrPlugin",
".",
"pattern",
")",
")",
"||",
"pointcutOrPl... | Returns a boolean indicating whether the passed in plugin or pointcut matches the given name. If a string is passed
as the second arg it is assumed to be a pointcut. If a plugin object is passed, it is checked for either a
pointcut or a pattern attribute. In either case the method delegates to the matchPointcut or matc... | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"passed",
"in",
"plugin",
"or",
"pointcut",
"matches",
"the",
"given",
"name",
".",
"If",
"a",
"string",
"is",
"passed",
"as",
"the",
"second",
"arg",
"it",
"is",
"assumed",
"to",
"be",
"a",
"poi... | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L41-L52 | train | |
atsid/circuits-js | js/PluginMatcher.js | function (name, pointcut) {
var regexString,
regex,
ret;
pointcut = pointcut || "*.*";
regexString = pointcut.replace(/\./g, "\\.").replace(/\*/g, ".*");
logger.debug("pointcut is: " + pointcut);
//adds word boundaries at ei... | javascript | function (name, pointcut) {
var regexString,
regex,
ret;
pointcut = pointcut || "*.*";
regexString = pointcut.replace(/\./g, "\\.").replace(/\*/g, ".*");
logger.debug("pointcut is: " + pointcut);
//adds word boundaries at ei... | [
"function",
"(",
"name",
",",
"pointcut",
")",
"{",
"var",
"regexString",
",",
"regex",
",",
"ret",
";",
"pointcut",
"=",
"pointcut",
"||",
"\"*.*\"",
";",
"regexString",
"=",
"pointcut",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"\"\\\\.\"",
")"... | Returns a boolean indicating whether the passed in plugin's pointcut matches the service and method names provided.
@param name - service and method name in dot notation, like "CaseService.readCase".
@param pointcut - poincut string for matching against names. The pointcut format is "regex-like",
using basic wildcard ... | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"passed",
"in",
"plugin",
"s",
"pointcut",
"matches",
"the",
"service",
"and",
"method",
"names",
"provided",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L66-L94 | train | |
atsid/circuits-js | js/PluginMatcher.js | function (serviceName, methodNames, type, plugins) {
var newPlugins = [];
if (plugins && plugins.length > 0) {
plugins.forEach(function (plugin) {
var match = this.matchingMethodNames(serviceName, methodNames, plugin);
if (match.length &&... | javascript | function (serviceName, methodNames, type, plugins) {
var newPlugins = [];
if (plugins && plugins.length > 0) {
plugins.forEach(function (plugin) {
var match = this.matchingMethodNames(serviceName, methodNames, plugin);
if (match.length &&... | [
"function",
"(",
"serviceName",
",",
"methodNames",
",",
"type",
",",
"plugins",
")",
"{",
"var",
"newPlugins",
"=",
"[",
"]",
";",
"if",
"(",
"plugins",
"&&",
"plugins",
".",
"length",
">",
"0",
")",
"{",
"plugins",
".",
"forEach",
"(",
"function",
... | Returns just the plugins from the given array with pointcuts that match the
any method on a service.
@param serviceName - the name of the service to match against.
@param methodNames - the names of all methods on this service.
@param type - the type of plugin to match.
@param plugins - the array of plugins to use as t... | [
"Returns",
"just",
"the",
"plugins",
"from",
"the",
"given",
"array",
"with",
"pointcuts",
"that",
"match",
"the",
"any",
"method",
"on",
"a",
"service",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L159-L177 | train | |
atsid/circuits-js | js/PluginMatcher.js | function (serviceName, methodNames, pointCut) {
var fullName, ret = [];
methodNames.forEach(function (name) {
fullName = serviceName + "." + name;
var match = this.match(fullName, pointCut);
if (match) {
ret.push(name);
... | javascript | function (serviceName, methodNames, pointCut) {
var fullName, ret = [];
methodNames.forEach(function (name) {
fullName = serviceName + "." + name;
var match = this.match(fullName, pointCut);
if (match) {
ret.push(name);
... | [
"function",
"(",
"serviceName",
",",
"methodNames",
",",
"pointCut",
")",
"{",
"var",
"fullName",
",",
"ret",
"=",
"[",
"]",
";",
"methodNames",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"fullName",
"=",
"serviceName",
"+",
"\".\"",
"+",
... | Returns the method names from the passed array that match the given
pointCut.
@param serviceName - the name of the service to match against.
@param methodNames - array of names to match against.
@param pointCut = the pointcut to match. | [
"Returns",
"the",
"method",
"names",
"from",
"the",
"passed",
"array",
"that",
"match",
"the",
"given",
"pointCut",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L187-L199 | train | |
atsid/circuits-js | js/PluginMatcher.js | function (serviceName, methodName, factoryPlugins, servicePlugins, invokePlugins) {
var ret = util.mixin({}, this.defaults), that = this;
Object.keys(ret).forEach(function (key) {
var pf = that.list(serviceName, methodName, key, factoryPlugins),
ps = that.li... | javascript | function (serviceName, methodName, factoryPlugins, servicePlugins, invokePlugins) {
var ret = util.mixin({}, this.defaults), that = this;
Object.keys(ret).forEach(function (key) {
var pf = that.list(serviceName, methodName, key, factoryPlugins),
ps = that.li... | [
"function",
"(",
"serviceName",
",",
"methodName",
",",
"factoryPlugins",
",",
"servicePlugins",
",",
"invokePlugins",
")",
"{",
"var",
"ret",
"=",
"util",
".",
"mixin",
"(",
"{",
"}",
",",
"this",
".",
"defaults",
")",
",",
"that",
"=",
"this",
";",
"... | Construct an object containing the arrays of plugins for each phase with precedence and
execution order resolved.
@param {String} serviceName the name of the service to match against.
@param {String} methodName - the name of the method on the service to match against.
@param {Array of circuits.Plugin} factoryPlugins t... | [
"Construct",
"an",
"object",
"containing",
"the",
"arrays",
"of",
"plugins",
"for",
"each",
"phase",
"with",
"precedence",
"and",
"execution",
"order",
"resolved",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/PluginMatcher.js#L213-L225 | train | |
ofidj/fidj | .todo/miapp.tools.sense.js | onWhichEvent | function onWhichEvent(sense, name, nbFinger) {
var prefix = 'Short';
if (sense.hasPaused) prefix = 'Long';
var onEventName = 'on' + prefix + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
if (sen... | javascript | function onWhichEvent(sense, name, nbFinger) {
var prefix = 'Short';
if (sense.hasPaused) prefix = 'Long';
var onEventName = 'on' + prefix + name + nbFinger;
if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) {
return onEventName;
}
if (sen... | [
"function",
"onWhichEvent",
"(",
"sense",
",",
"name",
",",
"nbFinger",
")",
"{",
"var",
"prefix",
"=",
"'Short'",
";",
"if",
"(",
"sense",
".",
"hasPaused",
")",
"prefix",
"=",
"'Long'",
";",
"var",
"onEventName",
"=",
"'on'",
"+",
"prefix",
"+",
"nam... | Gesture events utilities | [
"Gesture",
"events",
"utilities"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.sense.js#L2438-L2471 | train |
ofidj/fidj | .todo/miapp.tools.sense.js | clearDrops | function clearDrops(sense) {
sense.dropsStarted = [];
sense.dropOver = null;
sense.dropEvt = {
dataType: 'text/plain',
dataTransfer: ''
};
} | javascript | function clearDrops(sense) {
sense.dropsStarted = [];
sense.dropOver = null;
sense.dropEvt = {
dataType: 'text/plain',
dataTransfer: ''
};
} | [
"function",
"clearDrops",
"(",
"sense",
")",
"{",
"sense",
".",
"dropsStarted",
"=",
"[",
"]",
";",
"sense",
".",
"dropOver",
"=",
"null",
";",
"sense",
".",
"dropEvt",
"=",
"{",
"dataType",
":",
"'text/plain'",
",",
"dataTransfer",
":",
"''",
"}",
";"... | Drag and Drop utilities | [
"Drag",
"and",
"Drop",
"utilities"
] | e57ebece54ee68211d43802a8e0feeef098d3e36 | https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.sense.js#L2493-L2500 | train |
veo-labs/openveo-api | lib/errors/AccessError.js | AccessError | function AccessError(message) {
Error.captureStackTrace(this, this.constructor);
Object.defineProperties(this, {
/**
* Error message.
*
* @property message
* @type String
* @final
*/
message: {value: message, writable: true},
/**
* Error name.
*
* @propert... | javascript | function AccessError(message) {
Error.captureStackTrace(this, this.constructor);
Object.defineProperties(this, {
/**
* Error message.
*
* @property message
* @type String
* @final
*/
message: {value: message, writable: true},
/**
* Error name.
*
* @propert... | [
"function",
"AccessError",
"(",
"message",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"this",
".",
"constructor",
")",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"/**\n * Error message.\n *\n * @property message\n ... | Defines an AccessError to be thrown when a resource is forbidden.
var openVeoApi = require('@openveo/api');
throw new openVeoApi.errors.AccessError('You do not have permission to access this resource');
@class AccessError
@extends Error
@constructor
@param {String} message The error message | [
"Defines",
"an",
"AccessError",
"to",
"be",
"thrown",
"when",
"a",
"resource",
"is",
"forbidden",
"."
] | 493a811e9a5ba4d3e14910facaa7452caba1ab38 | https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/errors/AccessError.js#L20-L44 | train |
kt3k/bundle-through | lib/through-obj.js | through | function through(transform) {
var th = new Transform({objectMode: true})
th._transform = transform
return th
} | javascript | function through(transform) {
var th = new Transform({objectMode: true})
th._transform = transform
return th
} | [
"function",
"through",
"(",
"transform",
")",
"{",
"var",
"th",
"=",
"new",
"Transform",
"(",
"{",
"objectMode",
":",
"true",
"}",
")",
"th",
".",
"_transform",
"=",
"transform",
"return",
"th",
"}"
] | Returns a transform stream with the given _transform implementation in the object mode.
@return {Transform} | [
"Returns",
"a",
"transform",
"stream",
"with",
"the",
"given",
"_transform",
"implementation",
"in",
"the",
"object",
"mode",
"."
] | e474509585866a894fdae53347e9835e61b8e6d4 | https://github.com/kt3k/bundle-through/blob/e474509585866a894fdae53347e9835e61b8e6d4/lib/through-obj.js#L9-L15 | train |
unfoldingWord-dev/node-door43-client | lib/request.js | read | function read(uri) {
"use strict";
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
var agent = parsedUr... | javascript | function read(uri) {
"use strict";
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
var agent = parsedUr... | [
"function",
"read",
"(",
"uri",
")",
"{",
"\"use strict\"",
";",
"var",
"parsedUrl",
"=",
"url",
".",
"parse",
"(",
"uri",
",",
"false",
",",
"true",
")",
";",
"var",
"makeRequest",
"=",
"parsedUrl",
".",
"protocol",
"===",
"'https:'",
"?",
"https",
".... | Reads the contents of a url as a string.
@param uri {string} the url to read
@returns {Promise.<string>} the url contents | [
"Reads",
"the",
"contents",
"of",
"a",
"url",
"as",
"a",
"string",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/request.js#L21-L57 | train |
unfoldingWord-dev/node-door43-client | lib/request.js | download | function download(uri, dest, progressCallback) {
"use strict";
progressCallback = progressCallback || function() {};
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ?... | javascript | function download(uri, dest, progressCallback) {
"use strict";
progressCallback = progressCallback || function() {};
var parsedUrl = url.parse(uri, false, true);
var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
var serverPort = parsedUrl.port ?... | [
"function",
"download",
"(",
"uri",
",",
"dest",
",",
"progressCallback",
")",
"{",
"\"use strict\"",
";",
"progressCallback",
"=",
"progressCallback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"parsedUrl",
"=",
"url",
".",
"parse",
"(",
"uri",
","... | Downloads a url to a file.
@param uri {string} the uri to download
@param dest {string}
@param progressCallback {function} receives progress updates
@returns {Promise.<{}|Error>} the status code or an error | [
"Downloads",
"a",
"url",
"to",
"a",
"file",
"."
] | 18f518368ee89f4baf8943500a1c53ef5efcfb3e | https://github.com/unfoldingWord-dev/node-door43-client/blob/18f518368ee89f4baf8943500a1c53ef5efcfb3e/lib/request.js#L67-L111 | train |
bootprint/customize-write-files | lib/write.js | writeStream | async function writeStream (filename, contents) {
await new Promise((resolve, reject) => {
contents.pipe(fs.createWriteStream(filename))
.on('finish', function () {
resolve(filename)
})
.on('error', /* istanbul ignore next */ function (err) {
reject(err)
})
})
return fi... | javascript | async function writeStream (filename, contents) {
await new Promise((resolve, reject) => {
contents.pipe(fs.createWriteStream(filename))
.on('finish', function () {
resolve(filename)
})
.on('error', /* istanbul ignore next */ function (err) {
reject(err)
})
})
return fi... | [
"async",
"function",
"writeStream",
"(",
"filename",
",",
"contents",
")",
"{",
"await",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"contents",
".",
"pipe",
"(",
"fs",
".",
"createWriteStream",
"(",
"filename",
")",
")",
".",
... | Write a Readable to a file and
@param {string} filename
@param {stream.Readable} contents
@private
@returns {Promise<string>} a promise for the filename | [
"Write",
"a",
"Readable",
"to",
"a",
"file",
"and"
] | af77ce78b5196f40ce90670bfdb6e1e7e496a415 | https://github.com/bootprint/customize-write-files/blob/af77ce78b5196f40ce90670bfdb6e1e7e496a415/lib/write.js#L43-L54 | train |
AnyFetch/anyfetch-hydrater.js | lib/helpers/child-process.js | downloadFile | function downloadFile(cb) {
if(task.file_path) {
// Download the file
var stream = fs.createWriteStream(path);
// Store error if statusCode !== 200
var err;
stream.on("finish", function() {
cb(err);
});
var urlToDownload = url.parse(task.file_pat... | javascript | function downloadFile(cb) {
if(task.file_path) {
// Download the file
var stream = fs.createWriteStream(path);
// Store error if statusCode !== 200
var err;
stream.on("finish", function() {
cb(err);
});
var urlToDownload = url.parse(task.file_pat... | [
"function",
"downloadFile",
"(",
"cb",
")",
"{",
"if",
"(",
"task",
".",
"file_path",
")",
"{",
"// Download the file",
"var",
"stream",
"=",
"fs",
".",
"createWriteStream",
"(",
"path",
")",
";",
"// Store error if statusCode !== 200",
"var",
"err",
";",
"str... | Download the file from task.file_path, store it in a temporary file if there is file_path | [
"Download",
"the",
"file",
"from",
"task",
".",
"file_path",
"store",
"it",
"in",
"a",
"temporary",
"file",
"if",
"there",
"is",
"file_path"
] | 1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae | https://github.com/AnyFetch/anyfetch-hydrater.js/blob/1e70fdb5d8dcd26382e2a16de747b91a5b3ef3ae/lib/helpers/child-process.js#L46-L92 | train |
atsid/circuits-js | js/ServiceMethod.js | function (payload, plugins, ioArgs) {
var writePayload = payload || "", intermediate, that = this;
// Very simiplistic payload type coercion
if (this.requestPayloadName && !payload[this.requestPayloadName]) {
payload = {};
pa... | javascript | function (payload, plugins, ioArgs) {
var writePayload = payload || "", intermediate, that = this;
// Very simiplistic payload type coercion
if (this.requestPayloadName && !payload[this.requestPayloadName]) {
payload = {};
pa... | [
"function",
"(",
"payload",
",",
"plugins",
",",
"ioArgs",
")",
"{",
"var",
"writePayload",
"=",
"payload",
"||",
"\"\"",
",",
"intermediate",
",",
"that",
"=",
"this",
";",
"// Very simiplistic payload type coercion\r",
"if",
"(",
"this",
".",
"requestPayloadNa... | An internal method used by invoke to massage and perform plugin processing on
a request payload. The method attempts to coerce the payload into the type specified
in the smd and then runs the 'request' and 'write' plugins returning the new payload.
@param {Object} payload - the request data passed to the service metho... | [
"An",
"internal",
"method",
"used",
"by",
"invoke",
"to",
"massage",
"and",
"perform",
"plugin",
"processing",
"on",
"a",
"request",
"payload",
".",
"The",
"method",
"attempts",
"to",
"coerce",
"the",
"payload",
"into",
"the",
"type",
"specified",
"in",
"the... | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceMethod.js#L151-L188 | train | |
atsid/circuits-js | js/ServiceMethod.js | function (statusCode, data, plugins, ioArgs) {
var isList = this.reader.isListResponse(this.name),
//TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere
returnType = this.reader.getR... | javascript | function (statusCode, data, plugins, ioArgs) {
var isList = this.reader.isListResponse(this.name),
//TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere
returnType = this.reader.getR... | [
"function",
"(",
"statusCode",
",",
"data",
",",
"plugins",
",",
"ioArgs",
")",
"{",
"var",
"isList",
"=",
"this",
".",
"reader",
".",
"isListResponse",
"(",
"this",
".",
"name",
")",
",",
"//TODO: \"any\" is JSONSchema default if no type is defined. this should com... | An internal method used by the handler method generated by invoke to perform plugin processing on the
response data.
@param statusCode {Number} The status code from the request
@param data {Object} The response data returned by the provider
@param plugins {Array of circuits.Plugin} The merged plugins for the invocation... | [
"An",
"internal",
"method",
"used",
"by",
"the",
"handler",
"method",
"generated",
"by",
"invoke",
"to",
"perform",
"plugin",
"processing",
"on",
"the",
"response",
"data",
"."
] | f1fa5e98d406b3b9f577dd8995782c7115d6b346 | https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/ServiceMethod.js#L198-L258 | train | |
hairyhenderson/node-fellowshipone | lib/household_addresses.js | HouseholdAddresses | function HouseholdAddresses (f1, householdID) {
if (!householdID) {
throw new Error('HouseholdAddresses requires a household ID!')
}
Addresses.call(this, f1, {
path: '/Households/' + householdID + '/Addresses'
})
} | javascript | function HouseholdAddresses (f1, householdID) {
if (!householdID) {
throw new Error('HouseholdAddresses requires a household ID!')
}
Addresses.call(this, f1, {
path: '/Households/' + householdID + '/Addresses'
})
} | [
"function",
"HouseholdAddresses",
"(",
"f1",
",",
"householdID",
")",
"{",
"if",
"(",
"!",
"householdID",
")",
"{",
"throw",
"new",
"Error",
"(",
"'HouseholdAddresses requires a household ID!'",
")",
"}",
"Addresses",
".",
"call",
"(",
"this",
",",
"f1",
",",
... | The Addresses object, in a Household context.
@param {Object} f1 - the F1 object
@param {Number} householdID - the Household ID, for context | [
"The",
"Addresses",
"object",
"in",
"a",
"Household",
"context",
"."
] | 5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b | https://github.com/hairyhenderson/node-fellowshipone/blob/5e80eb9ec31fb6dceee1e8c211e7b6e0e373b08b/lib/household_addresses.js#L10-L17 | train |
Mammut-FE/nejm | src/util/form/form.js | function(v,node){
var format = this.__dataset(node,'format')||'yyyy-MM-dd';
return !v||(!isNaN(this.__doParseDate(v)) && _u._$format(this.__doParseDate(v),format) == v);
} | javascript | function(v,node){
var format = this.__dataset(node,'format')||'yyyy-MM-dd';
return !v||(!isNaN(this.__doParseDate(v)) && _u._$format(this.__doParseDate(v),format) == v);
} | [
"function",
"(",
"v",
",",
"node",
")",
"{",
"var",
"format",
"=",
"this",
".",
"__dataset",
"(",
"node",
",",
"'format'",
")",
"||",
"'yyyy-MM-dd'",
";",
"return",
"!",
"v",
"||",
"(",
"!",
"isNaN",
"(",
"this",
".",
"__doParseDate",
"(",
"v",
")"... | xx-x-xx or xxxx-xx-x | [
"xx",
"-",
"x",
"-",
"xx",
"or",
"xxxx",
"-",
"xx",
"-",
"x"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L623-L626 | train | |
Mammut-FE/nejm | src/util/form/form.js | function(_node){
var _type = _node.type,
_novalue = !_node.value,
_nocheck = (_type=='checkbox'||
_type=='radio')&&!_node.checked;
if (_nocheck||_novalue) return -1;
} | javascript | function(_node){
var _type = _node.type,
_novalue = !_node.value,
_nocheck = (_type=='checkbox'||
_type=='radio')&&!_node.checked;
if (_nocheck||_novalue) return -1;
} | [
"function",
"(",
"_node",
")",
"{",
"var",
"_type",
"=",
"_node",
".",
"type",
",",
"_novalue",
"=",
"!",
"_node",
".",
"value",
",",
"_nocheck",
"=",
"(",
"_type",
"==",
"'checkbox'",
"||",
"_type",
"==",
"'radio'",
")",
"&&",
"!",
"_node",
".",
"... | value require for text checked require for checkbox or radio | [
"value",
"require",
"for",
"text",
"checked",
"require",
"for",
"checkbox",
"or",
"radio"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L632-L638 | train | |
Mammut-FE/nejm | src/util/form/form.js | function(_node,_options){
var _reg = this.__treg[_options.type],
_val = _node.value.trim(),
_tested = !!_reg.test&&!_reg.test(_val),
_funced = _u._$isFunction(_reg)&&!_reg.call(this,_val,_node);
if (_tested||_funced) return -2;
... | javascript | function(_node,_options){
var _reg = this.__treg[_options.type],
_val = _node.value.trim(),
_tested = !!_reg.test&&!_reg.test(_val),
_funced = _u._$isFunction(_reg)&&!_reg.call(this,_val,_node);
if (_tested||_funced) return -2;
... | [
"function",
"(",
"_node",
",",
"_options",
")",
"{",
"var",
"_reg",
"=",
"this",
".",
"__treg",
"[",
"_options",
".",
"type",
"]",
",",
"_val",
"=",
"_node",
".",
"value",
".",
"trim",
"(",
")",
",",
"_tested",
"=",
"!",
"!",
"_reg",
".",
"test",... | type supported in _regmap | [
"type",
"supported",
"in",
"_regmap"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L640-L646 | train | |
Mammut-FE/nejm | src/util/form/form.js | function(_node,_options){
var _number = this.__number(
_node.value,
_options.type,
_options.time
);
if (isNaN(_number)||
_number<_options.min)
return -6;
} | javascript | function(_node,_options){
var _number = this.__number(
_node.value,
_options.type,
_options.time
);
if (isNaN(_number)||
_number<_options.min)
return -6;
} | [
"function",
"(",
"_node",
",",
"_options",
")",
"{",
"var",
"_number",
"=",
"this",
".",
"__number",
"(",
"_node",
".",
"value",
",",
"_options",
".",
"type",
",",
"_options",
".",
"time",
")",
";",
"if",
"(",
"isNaN",
"(",
"_number",
")",
"||",
"_... | min value check | [
"min",
"value",
"check"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L673-L682 | train | |
Mammut-FE/nejm | src/util/form/form.js | function(_value,_node){
// for multiple select
if (!!_node.multiple){
var _map;
if (!_u._$isArray(_value)){
_map[_value] = _value;
}else{
_map = _u._$array2object(_value);
}
_u... | javascript | function(_value,_node){
// for multiple select
if (!!_node.multiple){
var _map;
if (!_u._$isArray(_value)){
_map[_value] = _value;
}else{
_map = _u._$array2object(_value);
}
_u... | [
"function",
"(",
"_value",
",",
"_node",
")",
"{",
"// for multiple select",
"if",
"(",
"!",
"!",
"_node",
".",
"multiple",
")",
"{",
"var",
"_map",
";",
"if",
"(",
"!",
"_u",
".",
"_$isArray",
"(",
"_value",
")",
")",
"{",
"_map",
"[",
"_value",
"... | set select value | [
"set",
"select",
"value"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L920-L937 | train | |
Mammut-FE/nejm | src/util/form/form.js | function(_value,_node){
if (_reg0.test(_node.type||'')){
// radio/checkbox
_node.checked = _value==_node.value;
}else if(_node.tagName=='SELECT'){
// for select node
_doSetSelect(_value,_node);
}else{
// ... | javascript | function(_value,_node){
if (_reg0.test(_node.type||'')){
// radio/checkbox
_node.checked = _value==_node.value;
}else if(_node.tagName=='SELECT'){
// for select node
_doSetSelect(_value,_node);
}else{
// ... | [
"function",
"(",
"_value",
",",
"_node",
")",
"{",
"if",
"(",
"_reg0",
".",
"test",
"(",
"_node",
".",
"type",
"||",
"''",
")",
")",
"{",
"// radio/checkbox",
"_node",
".",
"checked",
"=",
"_value",
"==",
"_node",
".",
"value",
";",
"}",
"else",
"i... | set node value | [
"set",
"node",
"value"
] | dfc09ac66a8d67620a7aea65e34d8a179976b3fb | https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/form/form.js#L939-L950 | train | |
urturn/urturn-expression-api | dist/iframe.js | function(callbackUUID, result) {
var callback = apiListeners[callbackUUID];
if (callback) {
if ( !(result && result instanceof Array )) {
if(window.console && console.error){
console.error('received result is not an array.', result);
}
}
callback.apply(this, result);
... | javascript | function(callbackUUID, result) {
var callback = apiListeners[callbackUUID];
if (callback) {
if ( !(result && result instanceof Array )) {
if(window.console && console.error){
console.error('received result is not an array.', result);
}
}
callback.apply(this, result);
... | [
"function",
"(",
"callbackUUID",
",",
"result",
")",
"{",
"var",
"callback",
"=",
"apiListeners",
"[",
"callbackUUID",
"]",
";",
"if",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"result",
"&&",
"result",
"instanceof",
"Array",
")",
")",
"{",
"if",... | Events called when callback are received from post message.
@private
@param callBackUUID the uuid of the callback to call
@param result the result parameter to the caallback | [
"Events",
"called",
"when",
"callback",
"are",
"received",
"from",
"post",
"message",
"."
] | 009a272ee670dbbe5eefb5c070ed827dd778bb07 | https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/dist/iframe.js#L2636-L2647 | train | |
urturn/urturn-expression-api | dist/iframe.js | function(options, callback, errorCallback){
if(typeof options == 'function'){
callback = options;
options = {};
}
UT.Expression._callAPI(
'document.textInput',
[options.value || null, options.max || null, options.multiline || false],
callback
);
} | javascript | function(options, callback, errorCallback){
if(typeof options == 'function'){
callback = options;
options = {};
}
UT.Expression._callAPI(
'document.textInput',
[options.value || null, options.max || null, options.multiline || false],
callback
);
} | [
"function",
"(",
"options",
",",
"callback",
",",
"errorCallback",
")",
"{",
"if",
"(",
"typeof",
"options",
"==",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"UT",
".",
"Expression",
".",
"_callAPI",
"(... | Public Functions
Native text input for mobile.
if options is passed, it might contains:
- value, the default value,
- max, the number of chars allowed,
- multiline, if true, allow for a multiline text input
The callback will be passed the resulting string or null
if no value have been selected.
XXX: Need to be supp... | [
"Public",
"Functions",
"Native",
"text",
"input",
"for",
"mobile",
"."
] | 009a272ee670dbbe5eefb5c070ed827dd778bb07 | https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/dist/iframe.js#L2927-L2937 | 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.