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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mixdown/mixdown-cli | index.js | function() {
if (_.keys(children).length == 0) {
that.stop(process.exit);
}
else {
setImmediate(checkExit); // keep polling for safe shutdown.
}
} | javascript | function() {
if (_.keys(children).length == 0) {
that.stop(process.exit);
}
else {
setImmediate(checkExit); // keep polling for safe shutdown.
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"_",
".",
"keys",
"(",
"children",
")",
".",
"length",
"==",
"0",
")",
"{",
"that",
".",
"stop",
"(",
"process",
".",
"exit",
")",
";",
"}",
"else",
"{",
"setImmediate",
"(",
"checkExit",
")",
";",
"// keep p... | create function to check that all workers are dead. | [
"create",
"function",
"to",
"check",
"that",
"all",
"workers",
"are",
"dead",
"."
] | 2792cd743ac4299d5aab0e88e87edf1231f5a9a2 | https://github.com/mixdown/mixdown-cli/blob/2792cd743ac4299d5aab0e88e87edf1231f5a9a2/index.js#L113-L120 | train | |
adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/autoresize/plugin.js | resize | function resize(e) {
var deltaSize, doc, body, docElm, resizeHeight, myHeight,
marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
doc = editor.getDoc();
if (!doc) {
return;
}
body = doc.body;
docElm = doc.documentElement;
... | javascript | function resize(e) {
var deltaSize, doc, body, docElm, resizeHeight, myHeight,
marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
doc = editor.getDoc();
if (!doc) {
return;
}
body = doc.body;
docElm = doc.documentElement;
... | [
"function",
"resize",
"(",
"e",
")",
"{",
"var",
"deltaSize",
",",
"doc",
",",
"body",
",",
"docElm",
",",
"resizeHeight",
",",
"myHeight",
",",
"marginTop",
",",
"marginBottom",
",",
"paddingTop",
",",
"paddingBottom",
",",
"borderTop",
",",
"borderBottom",... | This method gets executed each time the editor needs to resize. | [
"This",
"method",
"gets",
"executed",
"each",
"time",
"the",
"editor",
"needs",
"to",
"resize",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/autoresize/plugin.js#L208-L276 | train |
adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/autoresize/plugin.js | wait | function wait(times, interval, callback) {
Delay.setEditorTimeout(editor, function () {
resize({});
if (times--) {
wait(times, interval, callback);
} else if (callback) {
callback();
}
}, interval);
} | javascript | function wait(times, interval, callback) {
Delay.setEditorTimeout(editor, function () {
resize({});
if (times--) {
wait(times, interval, callback);
} else if (callback) {
callback();
}
}, interval);
} | [
"function",
"wait",
"(",
"times",
",",
"interval",
",",
"callback",
")",
"{",
"Delay",
".",
"setEditorTimeout",
"(",
"editor",
",",
"function",
"(",
")",
"{",
"resize",
"(",
"{",
"}",
")",
";",
"if",
"(",
"times",
"--",
")",
"{",
"wait",
"(",
"time... | Calls the resize x times in 100ms intervals. We can't wait for load events since
the CSS files might load async. | [
"Calls",
"the",
"resize",
"x",
"times",
"in",
"100ms",
"intervals",
".",
"We",
"can",
"t",
"wait",
"for",
"load",
"events",
"since",
"the",
"CSS",
"files",
"might",
"load",
"async",
"."
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/autoresize/plugin.js#L282-L292 | train |
ArtOfCode-/nails | src/nails.js | lazy | function lazy(key, get) {
const uninitialized = {};
let _val = uninitialized;
Object.defineProperty(exports, key, {
get() {
if (_val === uninitialized) {
_val = get();
}
return _val;
},
});
} | javascript | function lazy(key, get) {
const uninitialized = {};
let _val = uninitialized;
Object.defineProperty(exports, key, {
get() {
if (_val === uninitialized) {
_val = get();
}
return _val;
},
});
} | [
"function",
"lazy",
"(",
"key",
",",
"get",
")",
"{",
"const",
"uninitialized",
"=",
"{",
"}",
";",
"let",
"_val",
"=",
"uninitialized",
";",
"Object",
".",
"defineProperty",
"(",
"exports",
",",
"key",
",",
"{",
"get",
"(",
")",
"{",
"if",
"(",
"_... | Define a lazy property on `exports` that
retrieves the value when accessed
the first time
@private
@param {string} key The key to add
@param {Function} get The function to generate the value | [
"Define",
"a",
"lazy",
"property",
"on",
"exports",
"that",
"retrieves",
"the",
"value",
"when",
"accessed",
"the",
"first",
"time"
] | 1ba9158742ba72bc727ad5c881035ee9d99b700c | https://github.com/ArtOfCode-/nails/blob/1ba9158742ba72bc727ad5c881035ee9d99b700c/src/nails.js#L32-L43 | train |
tualo/tualo-imap | lib/imap.js | Connection | function Connection(options) {
if (!(this instanceof Connection)){
return new Connection(options);
}
this.prefixCounter = 0;
this.serverMessages = {};
this._options = {
username: options.username || options.user || '',
password: options.password || '',
host: options.host || 'localhost',
port: optio... | javascript | function Connection(options) {
if (!(this instanceof Connection)){
return new Connection(options);
}
this.prefixCounter = 0;
this.serverMessages = {};
this._options = {
username: options.username || options.user || '',
password: options.password || '',
host: options.host || 'localhost',
port: optio... | [
"function",
"Connection",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Connection",
")",
")",
"{",
"return",
"new",
"Connection",
"(",
"options",
")",
";",
"}",
"this",
".",
"prefixCounter",
"=",
"0",
";",
"this",
".",
"serverM... | Create a new instance of Connection. This instance inherits all functions of the EventEmitter.
@constructor
@this {Connection}
@param {object} options | [
"Create",
"a",
"new",
"instance",
"of",
"Connection",
".",
"This",
"instance",
"inherits",
"all",
"functions",
"of",
"the",
"EventEmitter",
"."
] | 948d9cb4693eb0d0e82530365ece36c1d8dbecf3 | https://github.com/tualo/tualo-imap/blob/948d9cb4693eb0d0e82530365ece36c1d8dbecf3/lib/imap.js#L19-L66 | train |
tungtung-dev/common-helper | src/random/randomId.js | makeId | function makeId(length = RANDOM_CHARACTER_LENGTH) {
let text = "";
for (let i = 0; i < length; i++) {
text += RANDOM_CHARACTER_SOURCE.charAt(Math.floor(Math.random() * RANDOM_CHARACTER_SOURCE.length));
}
return text;
} | javascript | function makeId(length = RANDOM_CHARACTER_LENGTH) {
let text = "";
for (let i = 0; i < length; i++) {
text += RANDOM_CHARACTER_SOURCE.charAt(Math.floor(Math.random() * RANDOM_CHARACTER_SOURCE.length));
}
return text;
} | [
"function",
"makeId",
"(",
"length",
"=",
"RANDOM_CHARACTER_LENGTH",
")",
"{",
"let",
"text",
"=",
"\"\"",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"text",
"+=",
"RANDOM_CHARACTER_SOURCE",
".",
"charAt",... | Support generate random string with 5 characters
@returns {string} | [
"Support",
"generate",
"random",
"string",
"with",
"5",
"characters"
] | 94abeff34fee3b2366b308571e94f2da8b0db655 | https://github.com/tungtung-dev/common-helper/blob/94abeff34fee3b2366b308571e94f2da8b0db655/src/random/randomId.js#L12-L19 | train |
HPSoftware/node-offline-debug | lib/config.js | merge_config | function merge_config(top_config, base_config)
{
for (var option in top_config)
{
if (Array.isArray(top_config[option])) // handle array elements in the same order
{
if (!Array.isArray(base_config[option]))
base_config[option] = top_config[option];
else
... | javascript | function merge_config(top_config, base_config)
{
for (var option in top_config)
{
if (Array.isArray(top_config[option])) // handle array elements in the same order
{
if (!Array.isArray(base_config[option]))
base_config[option] = top_config[option];
else
... | [
"function",
"merge_config",
"(",
"top_config",
",",
"base_config",
")",
"{",
"for",
"(",
"var",
"option",
"in",
"top_config",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"top_config",
"[",
"option",
"]",
")",
")",
"// handle array elements in the same o... | copy app_config configurations over package configurations | [
"copy",
"app_config",
"configurations",
"over",
"package",
"configurations"
] | 2b4638cfc568c6e82a6e4b6dcbbefef4215f27f1 | https://github.com/HPSoftware/node-offline-debug/blob/2b4638cfc568c6e82a6e4b6dcbbefef4215f27f1/lib/config.js#L16-L46 | train |
wilmoore/rerun-script | index.js | getWatches | function getWatches (directory) {
var package_path = resolve(directory || './')
var pkg = read(package_path)
var watches = extract(pkg)
return Array.isArray(watches) ? watches : []
} | javascript | function getWatches (directory) {
var package_path = resolve(directory || './')
var pkg = read(package_path)
var watches = extract(pkg)
return Array.isArray(watches) ? watches : []
} | [
"function",
"getWatches",
"(",
"directory",
")",
"{",
"var",
"package_path",
"=",
"resolve",
"(",
"directory",
"||",
"'./'",
")",
"var",
"pkg",
"=",
"read",
"(",
"package_path",
")",
"var",
"watches",
"=",
"extract",
"(",
"pkg",
")",
"return",
"Array",
"... | Get package watches.
@param {String} directory
Package directory.
@return {Array}
Array of watches. | [
"Get",
"package",
"watches",
"."
] | 922e17baca2e53a55586e8b86a7c42f6571dc8c8 | https://github.com/wilmoore/rerun-script/blob/922e17baca2e53a55586e8b86a7c42f6571dc8c8/index.js#L26-L31 | train |
sitegui/asynconnection-core | lib/Context.js | Context | function Context() {
/**
* @member {Object}
* @property {Object} client
* @property {Object<Call>} client.map - map from call name and call id
* @property {Array<Call>} client.list
* @property {Object} server
* @property {Object<Call>} server.map - map from call name and call id
* @property {Array<Call>}... | javascript | function Context() {
/**
* @member {Object}
* @property {Object} client
* @property {Object<Call>} client.map - map from call name and call id
* @property {Array<Call>} client.list
* @property {Object} server
* @property {Object<Call>} server.map - map from call name and call id
* @property {Array<Call>}... | [
"function",
"Context",
"(",
")",
"{",
"/**\n\t * @member {Object}\n\t * @property {Object} client\n\t * @property {Object<Call>} client.map - map from call name and call id\n\t * @property {Array<Call>} client.list\n\t * @property {Object} server\n\t * @property {Object<Call>} server.map - map from call n... | A collection of registered calls and messages.
Many `peers` can be linked to a context.
@class | [
"A",
"collection",
"of",
"registered",
"calls",
"and",
"messages",
".",
"Many",
"peers",
"can",
"be",
"linked",
"to",
"a",
"context",
"."
] | 4db029d1d4f0aedacf6001986ae09f04c2a44dde | https://github.com/sitegui/asynconnection-core/blob/4db029d1d4f0aedacf6001986ae09f04c2a44dde/lib/Context.js#L8-L50 | train |
flitbit/oops | examples/example-simple.js | Person | function Person(firstname, lastname, middlenames) {
Person.super_.call(this);
var _priv = {
first: firstname || '-unknown-',
last: lastname || '-unknown-',
middle: middlenames || '-unknown-'
};
this.defines
.value('_state', {})
.property('first_name',
function() { return _priv.first; },
function(first... | javascript | function Person(firstname, lastname, middlenames) {
Person.super_.call(this);
var _priv = {
first: firstname || '-unknown-',
last: lastname || '-unknown-',
middle: middlenames || '-unknown-'
};
this.defines
.value('_state', {})
.property('first_name',
function() { return _priv.first; },
function(first... | [
"function",
"Person",
"(",
"firstname",
",",
"lastname",
",",
"middlenames",
")",
"{",
"Person",
".",
"super_",
".",
"call",
"(",
"this",
")",
";",
"var",
"_priv",
"=",
"{",
"first",
":",
"firstname",
"||",
"'-unknown-'",
",",
"last",
":",
"lastname",
... | Simple observable person object | [
"Simple",
"observable",
"person",
"object"
] | 73c36d459b98d1ac9485327ab3d6bf180c78d254 | https://github.com/flitbit/oops/blob/73c36d459b98d1ac9485327ab3d6bf180c78d254/examples/example-simple.js#L9-L65 | train |
flitbit/oops | examples/example-simple.js | fullnameFormatter | function fullnameFormatter( first, last, middle ) {
return ''.concat(first,
(last) ? ' '.concat(last) : '',
(middle) ? ' '.concat(middle) : '');
} | javascript | function fullnameFormatter( first, last, middle ) {
return ''.concat(first,
(last) ? ' '.concat(last) : '',
(middle) ? ' '.concat(middle) : '');
} | [
"function",
"fullnameFormatter",
"(",
"first",
",",
"last",
",",
"middle",
")",
"{",
"return",
"''",
".",
"concat",
"(",
"first",
",",
"(",
"last",
")",
"?",
"' '",
".",
"concat",
"(",
"last",
")",
":",
"''",
",",
"(",
"middle",
")",
"?",
"' '",
... | The default fullname formatter. | [
"The",
"default",
"fullname",
"formatter",
"."
] | 73c36d459b98d1ac9485327ab3d6bf180c78d254 | https://github.com/flitbit/oops/blob/73c36d459b98d1ac9485327ab3d6bf180c78d254/examples/example-simple.js#L71-L75 | train |
patrickarlt/grunt-acetate | tasks/acetate.js | printLogHeader | function printLogHeader (e) {
if (e.show && logHeader) {
logHeader = false;
grunt.log.header('Task "acetate:' + target + '" running');
}
} | javascript | function printLogHeader (e) {
if (e.show && logHeader) {
logHeader = false;
grunt.log.header('Task "acetate:' + target + '" running');
}
} | [
"function",
"printLogHeader",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"show",
"&&",
"logHeader",
")",
"{",
"logHeader",
"=",
"false",
";",
"grunt",
".",
"log",
".",
"header",
"(",
"'Task \"acetate:'",
"+",
"target",
"+",
"'\" running'",
")",
";",
"}",... | whenever we log anything spit out a header cleaner output when using grunt watch | [
"whenever",
"we",
"log",
"anything",
"spit",
"out",
"a",
"header",
"cleaner",
"output",
"when",
"using",
"grunt",
"watch"
] | 9464869fa47bb1639311d89fb9444a85aae83689 | https://github.com/patrickarlt/grunt-acetate/blob/9464869fa47bb1639311d89fb9444a85aae83689/tasks/acetate.js#L34-L39 | train |
tgolen/skelenode-dispatcher | index.js | attached | function attached(context) {
if (DEBUG_DISPATCHER) log.info('ATTACHED: ' + ((!!context.dispatcher) ? 'yes' : 'no'));
if (!context) {
return false;
}
return !!context.dispatcher;
} | javascript | function attached(context) {
if (DEBUG_DISPATCHER) log.info('ATTACHED: ' + ((!!context.dispatcher) ? 'yes' : 'no'));
if (!context) {
return false;
}
return !!context.dispatcher;
} | [
"function",
"attached",
"(",
"context",
")",
"{",
"if",
"(",
"DEBUG_DISPATCHER",
")",
"log",
".",
"info",
"(",
"'ATTACHED: '",
"+",
"(",
"(",
"!",
"!",
"context",
".",
"dispatcher",
")",
"?",
"'yes'",
":",
"'no'",
")",
")",
";",
"if",
"(",
"!",
"co... | Determines whether or not the dispatcher has been attached to the specified context.
@param context An object that wants to subscribe to events sent through the dispatcher.
@returns {boolean} Attached or not. | [
"Determines",
"whether",
"or",
"not",
"the",
"dispatcher",
"has",
"been",
"attached",
"to",
"the",
"specified",
"context",
"."
] | fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6 | https://github.com/tgolen/skelenode-dispatcher/blob/fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6/index.js#L94-L100 | train |
tgolen/skelenode-dispatcher | index.js | subscribe | function subscribe(event, callback) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('SUBSCRIBE: ' + event);
if (!event || !callback) {
return this;
}
if (this._callbacks[event]) {
this._callbacks[event].push(callback);
}
else {
this._callbacks[event] = [ callback ];
}
this._client.subscribe... | javascript | function subscribe(event, callback) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('SUBSCRIBE: ' + event);
if (!event || !callback) {
return this;
}
if (this._callbacks[event]) {
this._callbacks[event].push(callback);
}
else {
this._callbacks[event] = [ callback ];
}
this._client.subscribe... | [
"function",
"subscribe",
"(",
"event",
",",
"callback",
")",
"{",
"/*jshint validthis: true */",
"if",
"(",
"DEBUG_DISPATCHER",
")",
"log",
".",
"info",
"(",
"'SUBSCRIBE: '",
"+",
"event",
")",
";",
"if",
"(",
"!",
"event",
"||",
"!",
"callback",
")",
"{",... | Subscribes to a particular event. Anytime this event is published to a dispatcher, on any node in the system, the callback will be
executed shortly thereafter.
@param event A string name for an event, such as "org_14301" to be notified whenever that org is updated.
@param callback A callback to be executed when the eve... | [
"Subscribes",
"to",
"a",
"particular",
"event",
".",
"Anytime",
"this",
"event",
"is",
"published",
"to",
"a",
"dispatcher",
"on",
"any",
"node",
"in",
"the",
"system",
"the",
"callback",
"will",
"be",
"executed",
"shortly",
"thereafter",
"."
] | fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6 | https://github.com/tgolen/skelenode-dispatcher/blob/fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6/index.js#L109-L125 | train |
tgolen/skelenode-dispatcher | index.js | publish | function publish(event) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('PUBLISH: ' + event);
if (!event) {
return;
}
redisPublisher.publish(event, '');
return this;
} | javascript | function publish(event) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('PUBLISH: ' + event);
if (!event) {
return;
}
redisPublisher.publish(event, '');
return this;
} | [
"function",
"publish",
"(",
"event",
")",
"{",
"/*jshint validthis: true */",
"if",
"(",
"DEBUG_DISPATCHER",
")",
"log",
".",
"info",
"(",
"'PUBLISH: '",
"+",
"event",
")",
";",
"if",
"(",
"!",
"event",
")",
"{",
"return",
";",
"}",
"redisPublisher",
".",
... | Publishes an event across the cluster. All dispatchers that are listening for this event will notify their attached contexts.
@param event A string name for an event, such as "org_14301" to be notified whenever that org is updated.
@returns {*} The dispatcher, for fluent calls. | [
"Publishes",
"an",
"event",
"across",
"the",
"cluster",
".",
"All",
"dispatchers",
"that",
"are",
"listening",
"for",
"this",
"event",
"will",
"notify",
"their",
"attached",
"contexts",
"."
] | fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6 | https://github.com/tgolen/skelenode-dispatcher/blob/fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6/index.js#L132-L140 | train |
tgolen/skelenode-dispatcher | index.js | handleMessage | function handleMessage(event, message) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('MESSAGE: ' + event);
if (!event) {
return;
}
if (message && message !== '') {
throw 'A message payload was sent across Redis. We intentionally do not support this to avoid security issues.';
}
var callbacks ... | javascript | function handleMessage(event, message) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('MESSAGE: ' + event);
if (!event) {
return;
}
if (message && message !== '') {
throw 'A message payload was sent across Redis. We intentionally do not support this to avoid security issues.';
}
var callbacks ... | [
"function",
"handleMessage",
"(",
"event",
",",
"message",
")",
"{",
"/*jshint validthis: true */",
"if",
"(",
"DEBUG_DISPATCHER",
")",
"log",
".",
"info",
"(",
"'MESSAGE: '",
"+",
"event",
")",
";",
"if",
"(",
"!",
"event",
")",
"{",
"return",
";",
"}",
... | An internal method, called when a new message is received. It loops through all callbacks for the event, and executes them.
@param event The string name for an event that was passed to the "publish" call.
@param message A string payload sent with the publish. | [
"An",
"internal",
"method",
"called",
"when",
"a",
"new",
"message",
"is",
"received",
".",
"It",
"loops",
"through",
"all",
"callbacks",
"for",
"the",
"event",
"and",
"executes",
"them",
"."
] | fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6 | https://github.com/tgolen/skelenode-dispatcher/blob/fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6/index.js#L147-L162 | train |
tgolen/skelenode-dispatcher | index.js | unsubscribe | function unsubscribe(event, callback) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('UNSUBSCRIBE: ' + event);
if (!event || !callback) {
return;
}
var callbacks = this._callbacks[event];
if (callbacks) {
for (var i = callbacks.length - 1; i >= 0; i--) {
if (callbacks[i] === callback) {
c... | javascript | function unsubscribe(event, callback) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('UNSUBSCRIBE: ' + event);
if (!event || !callback) {
return;
}
var callbacks = this._callbacks[event];
if (callbacks) {
for (var i = callbacks.length - 1; i >= 0; i--) {
if (callbacks[i] === callback) {
c... | [
"function",
"unsubscribe",
"(",
"event",
",",
"callback",
")",
"{",
"/*jshint validthis: true */",
"if",
"(",
"DEBUG_DISPATCHER",
")",
"log",
".",
"info",
"(",
"'UNSUBSCRIBE: '",
"+",
"event",
")",
";",
"if",
"(",
"!",
"event",
"||",
"!",
"callback",
")",
... | Unsubscribes from a particular event.
@param event The string name passed to the "subscribe" call.
@param callback The callback passed to the "subscribe" call.
@returns {*} The context, for fluent calls. | [
"Unsubscribes",
"from",
"a",
"particular",
"event",
"."
] | fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6 | https://github.com/tgolen/skelenode-dispatcher/blob/fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6/index.js#L170-L190 | train |
tgolen/skelenode-dispatcher | index.js | detach | function detach(context) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('DETACHED.');
if (!context) {
return;
}
if (!attached(context)) {
return;
}
context.dispatcher._client.quit();
context.dispatcher._client.dispatcher = null;
context.dispatcher = null;
return this;
} | javascript | function detach(context) {
/*jshint validthis: true */
if (DEBUG_DISPATCHER) log.info('DETACHED.');
if (!context) {
return;
}
if (!attached(context)) {
return;
}
context.dispatcher._client.quit();
context.dispatcher._client.dispatcher = null;
context.dispatcher = null;
return this;
} | [
"function",
"detach",
"(",
"context",
")",
"{",
"/*jshint validthis: true */",
"if",
"(",
"DEBUG_DISPATCHER",
")",
"log",
".",
"info",
"(",
"'DETACHED.'",
")",
";",
"if",
"(",
"!",
"context",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"attached",
"(",... | Detaches the dispatcher from a particular context, remove the "dispatcher" namespace from it and stopping all subscriptions.
@param context The object passed to the "attach" call.
@returns {*} The dispatcher, for fluent calls. | [
"Detaches",
"the",
"dispatcher",
"from",
"a",
"particular",
"context",
"remove",
"the",
"dispatcher",
"namespace",
"from",
"it",
"and",
"stopping",
"all",
"subscriptions",
"."
] | fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6 | https://github.com/tgolen/skelenode-dispatcher/blob/fb64eb7a7f3390d6316f6a5b35ae3a5bea0761f6/index.js#L197-L212 | train |
airbrite/muni | controller.js | function(query) {
var result = {};
if (!_.isObject(query) || _.isEmpty(query)) {
return result;
}
// timestamp might be in `ms` or `s`
_.forEach(query, function(timestamp, operator) {
if (!_.includes(['gt', 'gte', 'lt', 'lte', 'ne'], operator)) {
return;
}
// Timest... | javascript | function(query) {
var result = {};
if (!_.isObject(query) || _.isEmpty(query)) {
return result;
}
// timestamp might be in `ms` or `s`
_.forEach(query, function(timestamp, operator) {
if (!_.includes(['gt', 'gte', 'lt', 'lte', 'ne'], operator)) {
return;
}
// Timest... | [
"function",
"(",
"query",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"query",
")",
"||",
"_",
".",
"isEmpty",
"(",
"query",
")",
")",
"{",
"return",
"result",
";",
"}",
"// timestamp might be in `ms` or ... | Converts a url query object containing time range data
into a Mongo compatible query
Note:
- timestamps can be either milliseconds or seconds
- timestamps can be strings, they will be parsed into Integers
Example:
{
gt: 1405494000,
lt: 1431327600
}
Possible Keys:
- `gt` Greater than
- `gte` Greather than or equal... | [
"Converts",
"a",
"url",
"query",
"object",
"containing",
"time",
"range",
"data",
"into",
"a",
"Mongo",
"compatible",
"query"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L40-L70 | train | |
airbrite/muni | controller.js | function(fields, data) {
if (!_.isString(fields)) {
return data;
}
// If a field is specified as `foo.bar` or `foo.bar.baz`,
// Convert it to just `foo`
var map = {};
_.forEach(fields.split(','), function(field) {
map[field.split('.')[0]] = 1;
});
var keys = _.keys(map);
... | javascript | function(fields, data) {
if (!_.isString(fields)) {
return data;
}
// If a field is specified as `foo.bar` or `foo.bar.baz`,
// Convert it to just `foo`
var map = {};
_.forEach(fields.split(','), function(field) {
map[field.split('.')[0]] = 1;
});
var keys = _.keys(map);
... | [
"function",
"(",
"fields",
",",
"data",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"fields",
")",
")",
"{",
"return",
"data",
";",
"}",
"// If a field is specified as `foo.bar` or `foo.bar.baz`,",
"// Convert it to just `foo`",
"var",
"map",
"=",
"{",
... | Modify `data` to only contain keys that are specified in `fields`
@param {Object} fields
@param {Object|Array} data
@return {Object|Array} | [
"Modify",
"data",
"to",
"only",
"contain",
"keys",
"that",
"are",
"specified",
"in",
"fields"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L80-L102 | train | |
airbrite/muni | controller.js | function() {
// Routes
this.routes = {
all: {},
get: {},
post: {},
put: {},
patch: {},
delete: {}
};
// Middleware(s)
this.pre = []; // run before route middleware
this.before = []; // run after route middleware but before route handler
this.after = []; /... | javascript | function() {
// Routes
this.routes = {
all: {},
get: {},
post: {},
put: {},
patch: {},
delete: {}
};
// Middleware(s)
this.pre = []; // run before route middleware
this.before = []; // run after route middleware but before route handler
this.after = []; /... | [
"function",
"(",
")",
"{",
"// Routes",
"this",
".",
"routes",
"=",
"{",
"all",
":",
"{",
"}",
",",
"get",
":",
"{",
"}",
",",
"post",
":",
"{",
"}",
",",
"put",
":",
"{",
"}",
",",
"patch",
":",
"{",
"}",
",",
"delete",
":",
"{",
"}",
"}... | Called after the constructor | [
"Called",
"after",
"the",
"constructor"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L194-L220 | train | |
airbrite/muni | controller.js | function(req, res, next) {
return function(modelOrCollection) {
this.prepareResponse(modelOrCollection, req, res, next);
}.bind(this);
} | javascript | function(req, res, next) {
return function(modelOrCollection) {
this.prepareResponse(modelOrCollection, req, res, next);
}.bind(this);
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"return",
"function",
"(",
"modelOrCollection",
")",
"{",
"this",
".",
"prepareResponse",
"(",
"modelOrCollection",
",",
"req",
",",
"res",
",",
"next",
")",
";",
"}",
".",
"bind",
"(",
"this",... | Convenience middleware to render a Model or Collection
DEPRECATED 2015-06-08
@return {Function} A middleware handler | [
"Convenience",
"middleware",
"to",
"render",
"a",
"Model",
"or",
"Collection"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L288-L292 | train | |
airbrite/muni | controller.js | function(modelOrCollection, req, res, next) {
if (!modelOrCollection) {
return next();
}
if (modelOrCollection instanceof Model) {
// Data is a Model
res.data = modelOrCollection.render();
} else if (modelOrCollection instanceof Collection) {
// Data is a Collection
res.da... | javascript | function(modelOrCollection, req, res, next) {
if (!modelOrCollection) {
return next();
}
if (modelOrCollection instanceof Model) {
// Data is a Model
res.data = modelOrCollection.render();
} else if (modelOrCollection instanceof Collection) {
// Data is a Collection
res.da... | [
"function",
"(",
"modelOrCollection",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"!",
"modelOrCollection",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"if",
"(",
"modelOrCollection",
"instanceof",
"Model",
")",
"{",
"// Data is a Model",... | Attempt to render a Model or Collection
If input is not a Model or Collection, pass it thru unmodified
DEPRECATED 2015-06-08
@param {*} modelOrCollection | [
"Attempt",
"to",
"render",
"a",
"Model",
"or",
"Collection",
"If",
"input",
"is",
"not",
"a",
"Model",
"or",
"Collection",
"pass",
"it",
"thru",
"unmodified"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L303-L320 | train | |
airbrite/muni | controller.js | function(req, res, next) {
var data = res.data || null;
var code = 200;
if (_.isNumber(res.code)) {
code = res.code;
}
var envelope = {
meta: {
code: code
},
data: data
};
// Optional paging meta
if (res.paging) {
envelope.meta.paging = res.paging;
... | javascript | function(req, res, next) {
var data = res.data || null;
var code = 200;
if (_.isNumber(res.code)) {
code = res.code;
}
var envelope = {
meta: {
code: code
},
data: data
};
// Optional paging meta
if (res.paging) {
envelope.meta.paging = res.paging;
... | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"data",
"=",
"res",
".",
"data",
"||",
"null",
";",
"var",
"code",
"=",
"200",
";",
"if",
"(",
"_",
".",
"isNumber",
"(",
"res",
".",
"code",
")",
")",
"{",
"code",
"=",
"res",... | Default middleware for handling successful responses | [
"Default",
"middleware",
"for",
"handling",
"successful",
"responses"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L326-L351 | train | |
airbrite/muni | controller.js | function(err, req, res, next) {
err.message = err.message || 'Internal Server Error';
err.code = err.code || res.code || 500;
if (!_.isNumber(err.code)) {
err.code = 500;
}
try {
err.line = err.stack.split('\n')[1].match(/\(.+\)/)[0];
} catch (e) {
err.line = null;
}
... | javascript | function(err, req, res, next) {
err.message = err.message || 'Internal Server Error';
err.code = err.code || res.code || 500;
if (!_.isNumber(err.code)) {
err.code = 500;
}
try {
err.line = err.stack.split('\n')[1].match(/\(.+\)/)[0];
} catch (e) {
err.line = null;
}
... | [
"function",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"err",
".",
"message",
"=",
"err",
".",
"message",
"||",
"'Internal Server Error'",
";",
"err",
".",
"code",
"=",
"err",
".",
"code",
"||",
"res",
".",
"code",
"||",
"500",
";",... | Default middleware for handling error responses | [
"Default",
"middleware",
"for",
"handling",
"error",
"responses"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L357-L387 | train | |
airbrite/muni | controller.js | function(req, res, next) {
// If we timed out before managing to respond, don't send the response
if (res.headersSent) {
return;
}
// Look for `.json` or `.xml` extension in path
// And override request accept header
if (/.json$/.test(req.path)) {
req.headers.accept = 'application/j... | javascript | function(req, res, next) {
// If we timed out before managing to respond, don't send the response
if (res.headersSent) {
return;
}
// Look for `.json` or `.xml` extension in path
// And override request accept header
if (/.json$/.test(req.path)) {
req.headers.accept = 'application/j... | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// If we timed out before managing to respond, don't send the response",
"if",
"(",
"res",
".",
"headersSent",
")",
"{",
"return",
";",
"}",
"// Look for `.json` or `.xml` extension in path",
"// And override reque... | Final middleware for handling all responses
Server actually responds and terminates to the request here | [
"Final",
"middleware",
"for",
"handling",
"all",
"responses",
"Server",
"actually",
"responds",
"and",
"terminates",
"to",
"the",
"request",
"here"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L394-L425 | train | |
airbrite/muni | controller.js | function(req) {
var fields = {};
// Fields
if (_.isString(req.query.fields)) {
_.forEach(req.query.fields.split(','), function(field) {
fields[field] = 1;
});
}
return fields;
} | javascript | function(req) {
var fields = {};
// Fields
if (_.isString(req.query.fields)) {
_.forEach(req.query.fields.split(','), function(field) {
fields[field] = 1;
});
}
return fields;
} | [
"function",
"(",
"req",
")",
"{",
"var",
"fields",
"=",
"{",
"}",
";",
"// Fields",
"if",
"(",
"_",
".",
"isString",
"(",
"req",
".",
"query",
".",
"fields",
")",
")",
"{",
"_",
".",
"forEach",
"(",
"req",
".",
"query",
".",
"fields",
".",
"spl... | Parses the request query string for `fields`
Converse it into a Mongo friendly `fields` Object
Example: `?fields=hello,world,foo.bar`
@param {Object} req
@return {Object} | [
"Parses",
"the",
"request",
"query",
"string",
"for",
"fields"
] | ea8b26aa94836514374907c325a0d79f28838e2e | https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/controller.js#L438-L449 | train | |
silverlight513/pengwyn-router | src/index.js | Link | function Link(props) {
// Handle clicks of the link
const onClick = e => {
e.preventDefault();
routeTo(path);
};
// If link is for a new tab
if(props.openIn === 'new') {
return (
<a href={props.to} target="_blank" rel="noopener noreferrer">
{props.children}
</a>
);
}
... | javascript | function Link(props) {
// Handle clicks of the link
const onClick = e => {
e.preventDefault();
routeTo(path);
};
// If link is for a new tab
if(props.openIn === 'new') {
return (
<a href={props.to} target="_blank" rel="noopener noreferrer">
{props.children}
</a>
);
}
... | [
"function",
"Link",
"(",
"props",
")",
"{",
"// Handle clicks of the link",
"const",
"onClick",
"=",
"e",
"=>",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"routeTo",
"(",
"path",
")",
";",
"}",
";",
"// If link is for a new tab",
"if",
"(",
"props",
"... | Create the Link component | [
"Create",
"the",
"Link",
"component"
] | aeea05f44ba93e0939ef279946000002d0147241 | https://github.com/silverlight513/pengwyn-router/blob/aeea05f44ba93e0939ef279946000002d0147241/src/index.js#L36-L58 | train |
silverlight513/pengwyn-router | src/index.js | getQuery | function getQuery(path = '') {
const query = {};
// Check if the path even has a query first
if(!path.includes('?')) {
return query;
}
const queryString = path.split('?')[1];
// Check if the query string has any values
if(!queryString.includes('=')) {
return query;
}
const values = queryS... | javascript | function getQuery(path = '') {
const query = {};
// Check if the path even has a query first
if(!path.includes('?')) {
return query;
}
const queryString = path.split('?')[1];
// Check if the query string has any values
if(!queryString.includes('=')) {
return query;
}
const values = queryS... | [
"function",
"getQuery",
"(",
"path",
"=",
"''",
")",
"{",
"const",
"query",
"=",
"{",
"}",
";",
"// Check if the path even has a query first",
"if",
"(",
"!",
"path",
".",
"includes",
"(",
"'?'",
")",
")",
"{",
"return",
"query",
";",
"}",
"const",
"quer... | Function to get the query object from a given path | [
"Function",
"to",
"get",
"the",
"query",
"object",
"from",
"a",
"given",
"path"
] | aeea05f44ba93e0939ef279946000002d0147241 | https://github.com/silverlight513/pengwyn-router/blob/aeea05f44ba93e0939ef279946000002d0147241/src/index.js#L63-L95 | train |
silverlight513/pengwyn-router | src/index.js | normalizePath | function normalizePath(path = '') {
// Remove the trailing slash if one has been given
if(path.length > 1 && path.endsWith('/')) {
path = path.slice(0, -1);
}
// Remove the first slash
if(path.startsWith('/')) {
path = path.slice(1);
}
// Remove the query if it exists
if(path.includes('?')) {... | javascript | function normalizePath(path = '') {
// Remove the trailing slash if one has been given
if(path.length > 1 && path.endsWith('/')) {
path = path.slice(0, -1);
}
// Remove the first slash
if(path.startsWith('/')) {
path = path.slice(1);
}
// Remove the query if it exists
if(path.includes('?')) {... | [
"function",
"normalizePath",
"(",
"path",
"=",
"''",
")",
"{",
"// Remove the trailing slash if one has been given",
"if",
"(",
"path",
".",
"length",
">",
"1",
"&&",
"path",
".",
"endsWith",
"(",
"'/'",
")",
")",
"{",
"path",
"=",
"path",
".",
"slice",
"(... | Function that normalizes a path string | [
"Function",
"that",
"normalizes",
"a",
"path",
"string"
] | aeea05f44ba93e0939ef279946000002d0147241 | https://github.com/silverlight513/pengwyn-router/blob/aeea05f44ba93e0939ef279946000002d0147241/src/index.js#L100-L121 | train |
silverlight513/pengwyn-router | src/index.js | match | function match(routes, path) {
// Get the query object before it gets stripped by the normalizer
const query = getQuery(path);
const pathname = path;
// Normalize the path
path = normalizePath(path);
// Loop over each route to find the match
for (let i = 0; i < routes.length; i++) {
// Normalize t... | javascript | function match(routes, path) {
// Get the query object before it gets stripped by the normalizer
const query = getQuery(path);
const pathname = path;
// Normalize the path
path = normalizePath(path);
// Loop over each route to find the match
for (let i = 0; i < routes.length; i++) {
// Normalize t... | [
"function",
"match",
"(",
"routes",
",",
"path",
")",
"{",
"// Get the query object before it gets stripped by the normalizer",
"const",
"query",
"=",
"getQuery",
"(",
"path",
")",
";",
"const",
"pathname",
"=",
"path",
";",
"// Normalize the path",
"path",
"=",
"no... | Function to determine what route matches the current path | [
"Function",
"to",
"determine",
"what",
"route",
"matches",
"the",
"current",
"path"
] | aeea05f44ba93e0939ef279946000002d0147241 | https://github.com/silverlight513/pengwyn-router/blob/aeea05f44ba93e0939ef279946000002d0147241/src/index.js#L126-L226 | train |
danigb/music-gamut | operations.js | distances | function distances (tonic, gamut) {
if (!tonic) {
if (!gamut[0]) return []
tonic = gamut[0]
}
tonic = op.setDefaultOctave(0, tonic)
return gamut.map(function (p) {
return p ? op.subtract(tonic, op.setDefaultOctave(0, p)) : null
})
} | javascript | function distances (tonic, gamut) {
if (!tonic) {
if (!gamut[0]) return []
tonic = gamut[0]
}
tonic = op.setDefaultOctave(0, tonic)
return gamut.map(function (p) {
return p ? op.subtract(tonic, op.setDefaultOctave(0, p)) : null
})
} | [
"function",
"distances",
"(",
"tonic",
",",
"gamut",
")",
"{",
"if",
"(",
"!",
"tonic",
")",
"{",
"if",
"(",
"!",
"gamut",
"[",
"0",
"]",
")",
"return",
"[",
"]",
"tonic",
"=",
"gamut",
"[",
"0",
"]",
"}",
"tonic",
"=",
"op",
".",
"setDefaultOc... | get distances from tonic to the rest of the notes | [
"get",
"distances",
"from",
"tonic",
"to",
"the",
"rest",
"of",
"the",
"notes"
] | a59779316a2d68abc7aabbac21fbc00ef2941608 | https://github.com/danigb/music-gamut/blob/a59779316a2d68abc7aabbac21fbc00ef2941608/operations.js#L22-L31 | train |
danigb/music-gamut | operations.js | uniq | function uniq (gamut) {
var semitones = heights(gamut)
return gamut.reduce(function (uniq, current, currentIndex) {
if (current) {
var index = semitones.indexOf(semitones[currentIndex])
if (index === currentIndex) uniq.push(current)
}
return uniq
}, [])
} | javascript | function uniq (gamut) {
var semitones = heights(gamut)
return gamut.reduce(function (uniq, current, currentIndex) {
if (current) {
var index = semitones.indexOf(semitones[currentIndex])
if (index === currentIndex) uniq.push(current)
}
return uniq
}, [])
} | [
"function",
"uniq",
"(",
"gamut",
")",
"{",
"var",
"semitones",
"=",
"heights",
"(",
"gamut",
")",
"return",
"gamut",
".",
"reduce",
"(",
"function",
"(",
"uniq",
",",
"current",
",",
"currentIndex",
")",
"{",
"if",
"(",
"current",
")",
"{",
"var",
"... | remove duplicated notes AND nulls | [
"remove",
"duplicated",
"notes",
"AND",
"nulls"
] | a59779316a2d68abc7aabbac21fbc00ef2941608 | https://github.com/danigb/music-gamut/blob/a59779316a2d68abc7aabbac21fbc00ef2941608/operations.js#L34-L43 | train |
raincatcher-beta/raincatcher-sync | lib/client/data-manager.js | getItemId | function getItemId(_existingItem) {
if (_.has(_existingItem, 'id')) {
itemToUpdate.id = _existingItem.id;
return String(_existingItem.id);
} else {
return itemToUpdate._localuid;
}
} | javascript | function getItemId(_existingItem) {
if (_.has(_existingItem, 'id')) {
itemToUpdate.id = _existingItem.id;
return String(_existingItem.id);
} else {
return itemToUpdate._localuid;
}
} | [
"function",
"getItemId",
"(",
"_existingItem",
")",
"{",
"if",
"(",
"_",
".",
"has",
"(",
"_existingItem",
",",
"'id'",
")",
")",
"{",
"itemToUpdate",
".",
"id",
"=",
"_existingItem",
".",
"id",
";",
"return",
"String",
"(",
"_existingItem",
".",
"id",
... | Getting the unique ID of the item.
If the existingItem has an ID assigned, then assign this to the item to update.
The reason for this is that the "id" field of the record is assigned in the remote store.
We must be able to relate the item saved locally (Using the _localuid field) to the remote identifier field (id)... | [
"Getting",
"the",
"unique",
"ID",
"of",
"the",
"item",
"."
] | a51eeb8fdea30a6afdcd0587019bd1148bf30468 | https://github.com/raincatcher-beta/raincatcher-sync/blob/a51eeb8fdea30a6afdcd0587019bd1148bf30468/lib/client/data-manager.js#L317-L324 | train |
shinuza/captain-core | lib/util/crypto.js | encode | function encode(password, cb) {
var secret_key = conf.secret_key
, iterations = conf.pbkdf2_iterations
, keylen = conf.pbkdf2_keylen;
crypto.pbkdf2(password, secret_key, iterations, keylen, function(err, derivedKey) {
var str;
if(err) {
cb(err);
} else {
str = new Buffer(derivedKey... | javascript | function encode(password, cb) {
var secret_key = conf.secret_key
, iterations = conf.pbkdf2_iterations
, keylen = conf.pbkdf2_keylen;
crypto.pbkdf2(password, secret_key, iterations, keylen, function(err, derivedKey) {
var str;
if(err) {
cb(err);
} else {
str = new Buffer(derivedKey... | [
"function",
"encode",
"(",
"password",
",",
"cb",
")",
"{",
"var",
"secret_key",
"=",
"conf",
".",
"secret_key",
",",
"iterations",
"=",
"conf",
".",
"pbkdf2_iterations",
",",
"keylen",
"=",
"conf",
".",
"pbkdf2_keylen",
";",
"crypto",
".",
"pbkdf2",
"(",
... | Passes an encoded version of `password` to `cb` or and error
@param password
@param cb | [
"Passes",
"an",
"encoded",
"version",
"of",
"password",
"to",
"cb",
"or",
"and",
"error"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/util/crypto.js#L20-L35 | train |
justinhelmer/vinyl-tasks | lib/pipeline.js | chain | function chain(tasks) {
return function() {
var pipeline = fullPipeline();
_.each(tasks, function(task) {
pipeline = pipeline.pipe(task.callback(options)());
});
return pipeline;
};
} | javascript | function chain(tasks) {
return function() {
var pipeline = fullPipeline();
_.each(tasks, function(task) {
pipeline = pipeline.pipe(task.callback(options)());
});
return pipeline;
};
} | [
"function",
"chain",
"(",
"tasks",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"pipeline",
"=",
"fullPipeline",
"(",
")",
";",
"_",
".",
"each",
"(",
"tasks",
",",
"function",
"(",
"task",
")",
"{",
"pipeline",
"=",
"pipeline",
".",
"pipe",... | Create the pipeline chain for the provided tasks.
@name chain
@param {Array} tasks - The list of task objects to chain callbacks.
@return {Function} - A function that when invoked, runs the entire pipeline and returns the vinyl stream. | [
"Create",
"the",
"pipeline",
"chain",
"for",
"the",
"provided",
"tasks",
"."
] | eca1f79065a3653023896c4f546dc44dbac81e62 | https://github.com/justinhelmer/vinyl-tasks/blob/eca1f79065a3653023896c4f546dc44dbac81e62/lib/pipeline.js#L72-L82 | train |
danmasta/env | lib/util.js | parse | function parse(str) {
let res = {};
str.split(constants.REGEX.newline).map(line => {
line = line.trim();
// ignore empty lines and comments
if (!line || line[0] === '#') {
return;
}
// replace variables that are not escaped
line = line.replace(con... | javascript | function parse(str) {
let res = {};
str.split(constants.REGEX.newline).map(line => {
line = line.trim();
// ignore empty lines and comments
if (!line || line[0] === '#') {
return;
}
// replace variables that are not escaped
line = line.replace(con... | [
"function",
"parse",
"(",
"str",
")",
"{",
"let",
"res",
"=",
"{",
"}",
";",
"str",
".",
"split",
"(",
"constants",
".",
"REGEX",
".",
"newline",
")",
".",
"map",
"(",
"line",
"=>",
"{",
"line",
"=",
"line",
".",
"trim",
"(",
")",
";",
"// igno... | parse a string and return an env object | [
"parse",
"a",
"string",
"and",
"return",
"an",
"env",
"object"
] | cd6df18f4f837797d47cd96bcfb125c0264685a7 | https://github.com/danmasta/env/blob/cd6df18f4f837797d47cd96bcfb125c0264685a7/lib/util.js#L55-L96 | train |
mgesmundo/port-manager | lib/port-finder.js | checkPort | function checkPort(port, cb) {
var server = new net.Server();
server.on('error', function (err) {
server.removeAllListeners();
cb(err);
});
server.listen(port, function () {
server.on('close', function () {
server.removeAllListeners();
cb(null, port);
});
server.close();
});
} | javascript | function checkPort(port, cb) {
var server = new net.Server();
server.on('error', function (err) {
server.removeAllListeners();
cb(err);
});
server.listen(port, function () {
server.on('close', function () {
server.removeAllListeners();
cb(null, port);
});
server.close();
});
} | [
"function",
"checkPort",
"(",
"port",
",",
"cb",
")",
"{",
"var",
"server",
"=",
"new",
"net",
".",
"Server",
"(",
")",
";",
"server",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"server",
".",
"removeAllListeners",
"(",
")",
... | Check if a port is available
@param {Number} port The port to check if available
@param {Function} cb Function called as result
@param {Error} cb.err The error if occurred
@param {Number} cb.port The port if available
@private
@ignore | [
"Check",
"if",
"a",
"port",
"is",
"available"
] | a09356b9063c228616d0ffc56217b93c479f2604 | https://github.com/mgesmundo/port-manager/blob/a09356b9063c228616d0ffc56217b93c479f2604/lib/port-finder.js#L16-L29 | train |
mgesmundo/port-manager | lib/port-finder.js | find | function find(ports, callback) {
if (_.isEmpty(ports)) {
callback(new Error('no free port available'));
} else {
var port = ports.shift();
checkPort(port, function (err, found) {
if (!err) {
callback(null, found);
} else {
find(ports, callback);
}
});
}
} | javascript | function find(ports, callback) {
if (_.isEmpty(ports)) {
callback(new Error('no free port available'));
} else {
var port = ports.shift();
checkPort(port, function (err, found) {
if (!err) {
callback(null, found);
} else {
find(ports, callback);
}
});
}
} | [
"function",
"find",
"(",
"ports",
",",
"callback",
")",
"{",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"ports",
")",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"'no free port available'",
")",
")",
";",
"}",
"else",
"{",
"var",
"port",
"=",
"ports",
... | Find the first available port in a ports list
@param {Array} ports The ports list to find the first available
@param {Function} callback Function called as result
@param {Error} callback.err The error if occurred
@param {Number} callback.port The first port available
@private
@ignore | [
"Find",
"the",
"first",
"available",
"port",
"in",
"a",
"ports",
"list"
] | a09356b9063c228616d0ffc56217b93c479f2604 | https://github.com/mgesmundo/port-manager/blob/a09356b9063c228616d0ffc56217b93c479f2604/lib/port-finder.js#L41-L54 | train |
jldec/pub-pkg-github-oauth | github-oauth.js | authenticate | function authenticate(req, cb) {
request.post(
'https://github.com/login/oauth/access_token',
{ form:
{ client_id: process.env.GHID, // don't store credentials in opts
client_secret: process.env.GHCS, // get them straight from process.env
code: req.query.code } },
... | javascript | function authenticate(req, cb) {
request.post(
'https://github.com/login/oauth/access_token',
{ form:
{ client_id: process.env.GHID, // don't store credentials in opts
client_secret: process.env.GHCS, // get them straight from process.env
code: req.query.code } },
... | [
"function",
"authenticate",
"(",
"req",
",",
"cb",
")",
"{",
"request",
".",
"post",
"(",
"'https://github.com/login/oauth/access_token'",
",",
"{",
"form",
":",
"{",
"client_id",
":",
"process",
".",
"env",
".",
"GHID",
",",
"// don't store credentials in opts",
... | get access token from github | [
"get",
"access",
"token",
"from",
"github"
] | bb97e18dd22b5165c402523bc7994dc14f9e34a2 | https://github.com/jldec/pub-pkg-github-oauth/blob/bb97e18dd22b5165c402523bc7994dc14f9e34a2/github-oauth.js#L100-L115 | train |
Colingo/populate | examples/complex.js | function (value, elem) {
var tmpl = elem.firstElementChild
elem.removeChild(tmpl)
value.forEach(function (text) {
var clone = tmpl.cloneNode(true)
clone.textContent = text
elem.appendChild(clone)
})
} | javascript | function (value, elem) {
var tmpl = elem.firstElementChild
elem.removeChild(tmpl)
value.forEach(function (text) {
var clone = tmpl.cloneNode(true)
clone.textContent = text
elem.appendChild(clone)
})
} | [
"function",
"(",
"value",
",",
"elem",
")",
"{",
"var",
"tmpl",
"=",
"elem",
".",
"firstElementChild",
"elem",
".",
"removeChild",
"(",
"tmpl",
")",
"value",
".",
"forEach",
"(",
"function",
"(",
"text",
")",
"{",
"var",
"clone",
"=",
"tmpl",
".",
"c... | Custom logic. Mappings are just functions, do anything you want! | [
"Custom",
"logic",
".",
"Mappings",
"are",
"just",
"functions",
"do",
"anything",
"you",
"want!"
] | a5244b9d72ac96c3a090b5efb6d23801f9afc3a0 | https://github.com/Colingo/populate/blob/a5244b9d72ac96c3a090b5efb6d23801f9afc3a0/examples/complex.js#L26-L35 | train | |
opsmezzo/composer-api | node.js/lib/client/client.js | isOk | function isOk(err, res, body) {
if (err) {
return callback(err);
}
var statusCode = res.statusCode.toString(),
error;
//
// Emit response for debug purpose
//
self.emit('debug::response', { statusCode: statusCode, result: body });
if (Object.keys(self.failCodes).indexOf... | javascript | function isOk(err, res, body) {
if (err) {
return callback(err);
}
var statusCode = res.statusCode.toString(),
error;
//
// Emit response for debug purpose
//
self.emit('debug::response', { statusCode: statusCode, result: body });
if (Object.keys(self.failCodes).indexOf... | [
"function",
"isOk",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"var",
"statusCode",
"=",
"res",
".",
"statusCode",
".",
"toString",
"(",
")",
",",
"error",
";",
"//"... | Helper function for checking response codes | [
"Helper",
"function",
"for",
"checking",
"response",
"codes"
] | 85d595a4046a0fd39c30afe564628882994926f7 | https://github.com/opsmezzo/composer-api/blob/85d595a4046a0fd39c30afe564628882994926f7/node.js/lib/client/client.js#L133-L158 | train |
schahriar/herb | lib/super.js | function(attributes, isPermanent) {
if(isPermanent) attributes.permanent = true;
if(attributes === 'reset') this.markerAttributes = {
background: undefined,
color: undefined,
style: undefined,
verbosity: undefined
}; else _.default... | javascript | function(attributes, isPermanent) {
if(isPermanent) attributes.permanent = true;
if(attributes === 'reset') this.markerAttributes = {
background: undefined,
color: undefined,
style: undefined,
verbosity: undefined
}; else _.default... | [
"function",
"(",
"attributes",
",",
"isPermanent",
")",
"{",
"if",
"(",
"isPermanent",
")",
"attributes",
".",
"permanent",
"=",
"true",
";",
"if",
"(",
"attributes",
"===",
"'reset'",
")",
"this",
".",
"markerAttributes",
"=",
"{",
"background",
":",
"und... | Marker allows for modification of each log | [
"Marker",
"allows",
"for",
"modification",
"of",
"each",
"log"
] | 76239befbe59bc040298be56d3b0889bd6342ca1 | https://github.com/schahriar/herb/blob/76239befbe59bc040298be56d3b0889bd6342ca1/lib/super.js#L36-L46 | train | |
rkusa/swac-odm | lib/observable.js | binarySearch | function binarySearch(o, v, i, compareFunction){
var h = o.length, l = -1, m
while(h - l > 1)
if(compareFunction(o[m = h + l >> 1], v) < 1) l = m
else h = m
return o[h] != v ? i ? h : -1 : h
} | javascript | function binarySearch(o, v, i, compareFunction){
var h = o.length, l = -1, m
while(h - l > 1)
if(compareFunction(o[m = h + l >> 1], v) < 1) l = m
else h = m
return o[h] != v ? i ? h : -1 : h
} | [
"function",
"binarySearch",
"(",
"o",
",",
"v",
",",
"i",
",",
"compareFunction",
")",
"{",
"var",
"h",
"=",
"o",
".",
"length",
",",
"l",
"=",
"-",
"1",
",",
"m",
"while",
"(",
"h",
"-",
"l",
">",
"1",
")",
"if",
"(",
"compareFunction",
"(",
... | modified version of + Carlos R. L. Rodrigues @ http://jsfromhell.com/array/search [rev. #2] o: array that will be looked up v: object that will be searched b: if true, the function will return the index where the value should be inserted to keep the array ordered, otherwise returns the index where the value was found o... | [
"modified",
"version",
"of",
"+",
"Carlos",
"R",
".",
"L",
".",
"Rodrigues"
] | a1df9a2e78098cc4f17be2a37afc32ff7f8bf54f | https://github.com/rkusa/swac-odm/blob/a1df9a2e78098cc4f17be2a37afc32ff7f8bf54f/lib/observable.js#L575-L581 | train |
wenwuwu/number-es5 | lib/number.js | function (n1, n2) {
var isOk1 = _isNumber(n1),
isOk2 = _isNumber(n2);
if (isOk1 && isOk2) {
// both are finite numbers
return (n1 - n2);
}
else if (isOk1)
return -1;
else if... | javascript | function (n1, n2) {
var isOk1 = _isNumber(n1),
isOk2 = _isNumber(n2);
if (isOk1 && isOk2) {
// both are finite numbers
return (n1 - n2);
}
else if (isOk1)
return -1;
else if... | [
"function",
"(",
"n1",
",",
"n2",
")",
"{",
"var",
"isOk1",
"=",
"_isNumber",
"(",
"n1",
")",
",",
"isOk2",
"=",
"_isNumber",
"(",
"n2",
")",
";",
"if",
"(",
"isOk1",
"&&",
"isOk2",
")",
"{",
"// both are finite numbers\r",
"return",
"(",
"n1",
"-",
... | Compare two numbers. | [
"Compare",
"two",
"numbers",
"."
] | f59fae84690f011e758a19107fbe5282aef757b4 | https://github.com/wenwuwu/number-es5/blob/f59fae84690f011e758a19107fbe5282aef757b4/lib/number.js#L263-L277 | train | |
wenwuwu/number-es5 | lib/number.js | function (itr, noError) {
if ( typeof itr.hasNext !== 'function'
|| typeof itr.next !== 'function' )
throw "IllegalArgumentException: itr must implement methods hasNext() and next().";
var prec = 0;
while (itr.hasN... | javascript | function (itr, noError) {
if ( typeof itr.hasNext !== 'function'
|| typeof itr.next !== 'function' )
throw "IllegalArgumentException: itr must implement methods hasNext() and next().";
var prec = 0;
while (itr.hasN... | [
"function",
"(",
"itr",
",",
"noError",
")",
"{",
"if",
"(",
"typeof",
"itr",
".",
"hasNext",
"!==",
"'function'",
"||",
"typeof",
"itr",
".",
"next",
"!==",
"'function'",
")",
"throw",
"\"IllegalArgumentException: itr must implement methods hasNext() and next().\"",
... | Returns the max precision within an Iterator of numbers.
If this is a float, this method returns the number of decimals.
If this is an integer, this method returns a negative number.
@param itr {Arrays.Iterator}
@param noError {Boolean} Optional. Whether throw exception when encountering a
non-numeric value. Default i... | [
"Returns",
"the",
"max",
"precision",
"within",
"an",
"Iterator",
"of",
"numbers",
".",
"If",
"this",
"is",
"a",
"float",
"this",
"method",
"returns",
"the",
"number",
"of",
"decimals",
".",
"If",
"this",
"is",
"an",
"integer",
"this",
"method",
"returns",... | f59fae84690f011e758a19107fbe5282aef757b4 | https://github.com/wenwuwu/number-es5/blob/f59fae84690f011e758a19107fbe5282aef757b4/lib/number.js#L419-L433 | train | |
wenwuwu/number-es5 | lib/number.js | function (num) {
if (typeof num !== 'number')
throw "TypeMismatch: num: Number";
else if (!isFinite(num))
return num.toString();
else {
var p = _getPrecision(num);
return num.toFi... | javascript | function (num) {
if (typeof num !== 'number')
throw "TypeMismatch: num: Number";
else if (!isFinite(num))
return num.toString();
else {
var p = _getPrecision(num);
return num.toFi... | [
"function",
"(",
"num",
")",
"{",
"if",
"(",
"typeof",
"num",
"!==",
"'number'",
")",
"throw",
"\"TypeMismatch: num: Number\"",
";",
"else",
"if",
"(",
"!",
"isFinite",
"(",
"num",
")",
")",
"return",
"num",
".",
"toString",
"(",
")",
";",
"else",
"{",... | Converts a number to a String.
This function covers the problem of the IEEE weirdness.
This function is useful when converting a number to String
without knowing how many decimals a number has.
Note that if caller knows how many decimals it wants then
it should use Number.toFixed() instead.
( Because inside this meth... | [
"Converts",
"a",
"number",
"to",
"a",
"String",
".",
"This",
"function",
"covers",
"the",
"problem",
"of",
"the",
"IEEE",
"weirdness",
"."
] | f59fae84690f011e758a19107fbe5282aef757b4 | https://github.com/wenwuwu/number-es5/blob/f59fae84690f011e758a19107fbe5282aef757b4/lib/number.js#L476-L488 | train | |
wenwuwu/number-es5 | lib/number.js | function (format) {
_validFormat(format);
var fn = null;
if (_formatFnAll.hasOwnProperty(format))
fn = _formatFnAll[format];
else {
var m = _regexDecFormat.exec... | javascript | function (format) {
_validFormat(format);
var fn = null;
if (_formatFnAll.hasOwnProperty(format))
fn = _formatFnAll[format];
else {
var m = _regexDecFormat.exec... | [
"function",
"(",
"format",
")",
"{",
"_validFormat",
"(",
"format",
")",
";",
"var",
"fn",
"=",
"null",
";",
"if",
"(",
"_formatFnAll",
".",
"hasOwnProperty",
"(",
"format",
")",
")",
"fn",
"=",
"_formatFnAll",
"[",
"format",
"]",
";",
"else",
"{",
"... | Returns a Function that formats numbers
into a 'string' value.
Examples:
Number.getFormatter("0.00")(5.125) == "5.13"
Number.getFormatter("0.0000")(5.125) == "5.1250"
Number.getFormatter("0'1/8")(5.125) == "5'1"
@param format {String}
@return {Function} A function that takes one 'number'
argument and converts it into... | [
"Returns",
"a",
"Function",
"that",
"formats",
"numbers",
"into",
"a",
"string",
"value",
"."
] | f59fae84690f011e758a19107fbe5282aef757b4 | https://github.com/wenwuwu/number-es5/blob/f59fae84690f011e758a19107fbe5282aef757b4/lib/number.js#L538-L570 | train | |
wenwuwu/number-es5 | lib/number.js | function (format) {
_validFormat(format);
var m = _regexDecFormat.exec(format);
if (m !== null)
return ( (typeof m[3] === 'string') ? m[3].length : 0 )
+ ( (m[4] === '%') ? 2 : 0 );
els... | javascript | function (format) {
_validFormat(format);
var m = _regexDecFormat.exec(format);
if (m !== null)
return ( (typeof m[3] === 'string') ? m[3].length : 0 )
+ ( (m[4] === '%') ? 2 : 0 );
els... | [
"function",
"(",
"format",
")",
"{",
"_validFormat",
"(",
"format",
")",
";",
"var",
"m",
"=",
"_regexDecFormat",
".",
"exec",
"(",
"format",
")",
";",
"if",
"(",
"m",
"!==",
"null",
")",
"return",
"(",
"(",
"typeof",
"m",
"[",
"3",
"]",
"===",
"... | Returns the number of decimals necessary to do
math operations accurately with specified 'format'.
@param format {String}
@return {Integer} Number of decimals, >= 0 | [
"Returns",
"the",
"number",
"of",
"decimals",
"necessary",
"to",
"do",
"math",
"operations",
"accurately",
"with",
"specified",
"format",
"."
] | f59fae84690f011e758a19107fbe5282aef757b4 | https://github.com/wenwuwu/number-es5/blob/f59fae84690f011e758a19107fbe5282aef757b4/lib/number.js#L579-L594 | train | |
Magneds/hapi-plugin-barcode | source/Barcode.js | unify | function unify(options) {
const map = {
height: 'barHeight',
background: 'bgColor',
text: 'showHRI'
};
return Object.keys(options).reduce(
(carry, key) => ({
...carry,
[key in map ? map[key] : key]: options[key]
}),
{}
);
} | javascript | function unify(options) {
const map = {
height: 'barHeight',
background: 'bgColor',
text: 'showHRI'
};
return Object.keys(options).reduce(
(carry, key) => ({
...carry,
[key in map ? map[key] : key]: options[key]
}),
{}
);
} | [
"function",
"unify",
"(",
"options",
")",
"{",
"const",
"map",
"=",
"{",
"height",
":",
"'barHeight'",
",",
"background",
":",
"'bgColor'",
",",
"text",
":",
"'showHRI'",
"}",
";",
"return",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"reduce",
"(... | Unify the parameters for the barcode plugin
@param {object} options
@returns {object} options | [
"Unify",
"the",
"parameters",
"for",
"the",
"barcode",
"plugin"
] | 4822bd2d1aa327a752a9573151396496c080424d | https://github.com/Magneds/hapi-plugin-barcode/blob/4822bd2d1aa327a752a9573151396496c080424d/source/Barcode.js#L17-L31 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/topologies/mongos.js | applyAuth | function applyAuth(authContexts, server, callback) {
if (authContexts.length === 0) return callback();
// Get the first auth context
var authContext = authContexts.shift();
// Copy the params
var customAuthContext = authContext.slice(0);
// Push our callback handler
customAuthContext.push(fu... | javascript | function applyAuth(authContexts, server, callback) {
if (authContexts.length === 0) return callback();
// Get the first auth context
var authContext = authContexts.shift();
// Copy the params
var customAuthContext = authContext.slice(0);
// Push our callback handler
customAuthContext.push(fu... | [
"function",
"applyAuth",
"(",
"authContexts",
",",
"server",
",",
"callback",
")",
"{",
"if",
"(",
"authContexts",
".",
"length",
"===",
"0",
")",
"return",
"callback",
"(",
")",
";",
"// Get the first auth context",
"var",
"authContext",
"=",
"authContexts",
... | Apply one of the contexts | [
"Apply",
"one",
"of",
"the",
"contexts"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/topologies/mongos.js#L660-L673 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/topologies/mongos.js | function(self, op, ns, ops, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
// Pick a server
let server = pickProxy(self);
// No server found error out
if (!server) return callback(new MongoError('no mongos proxy available'));
if (!o... | javascript | function(self, op, ns, ops, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
// Pick a server
let server = pickProxy(self);
// No server found error out
if (!server) return callback(new MongoError('no mongos proxy available'));
if (!o... | [
"function",
"(",
"self",
",",
"op",
",",
"ns",
",",
"ops",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"(",
"callback",
"=",
"options",
")",
",",
"(",
"options",
"=",
"{",
"}",
")",
";",
"o... | Operations Execute write operation | [
"Operations",
"Execute",
"write",
"operation"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/topologies/mongos.js#L885-L920 | train | |
soldair/node-mocktimers | index.js | ordered | function ordered (ondelay) {
var clk = 0
var queue = []
var checking = 0
function check () {
if (checking++) return
setImmediate(function () {
var o = queue.shift()
clk = o[1]
ondelay(function () {
checking = 0
if (queue.length) check()
o[0]()
}, o[2])
... | javascript | function ordered (ondelay) {
var clk = 0
var queue = []
var checking = 0
function check () {
if (checking++) return
setImmediate(function () {
var o = queue.shift()
clk = o[1]
ondelay(function () {
checking = 0
if (queue.length) check()
o[0]()
}, o[2])
... | [
"function",
"ordered",
"(",
"ondelay",
")",
"{",
"var",
"clk",
"=",
"0",
"var",
"queue",
"=",
"[",
"]",
"var",
"checking",
"=",
"0",
"function",
"check",
"(",
")",
"{",
"if",
"(",
"checking",
"++",
")",
"return",
"setImmediate",
"(",
"function",
"(",... | one call gets run each turn on setImmediate until none are left. | [
"one",
"call",
"gets",
"run",
"each",
"turn",
"on",
"setImmediate",
"until",
"none",
"are",
"left",
"."
] | ee3f3e66dd962da060bc8ce2ecc35a6afea469d3 | https://github.com/soldair/node-mocktimers/blob/ee3f3e66dd962da060bc8ce2ecc35a6afea469d3/index.js#L71-L104 | train |
nopnop/docflux | lib/markdown.js | markdown | function markdown(options) {
options = _.extend({
depth: 1,
indent: true
}, options || {})
var isFirst = true;
return through2.obj(function(doc, encoding, done) {
var out = [];
if(isFirst) { isFirst = false } else { out.push('\n\n') }
var depth = options.depth;
if(options.indent && ... | javascript | function markdown(options) {
options = _.extend({
depth: 1,
indent: true
}, options || {})
var isFirst = true;
return through2.obj(function(doc, encoding, done) {
var out = [];
if(isFirst) { isFirst = false } else { out.push('\n\n') }
var depth = options.depth;
if(options.indent && ... | [
"function",
"markdown",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"depth",
":",
"1",
",",
"indent",
":",
"true",
"}",
",",
"options",
"||",
"{",
"}",
")",
"var",
"isFirst",
"=",
"true",
";",
"return",
"through2",
".",
... | Transform a docflux stream to a markdown stream
This is more a docflux's usage example than a full featured tool
Example:
```javascript
var docflux = require('docflux');
process.stdin(docflux())
.pipe(docflux.markdown())
.pipe(process.stdout)
```
@param {Object} [options]
Some rendering options
- `depth`: The base ... | [
"Transform",
"a",
"docflux",
"stream",
"to",
"a",
"markdown",
"stream"
] | 3929fdac9d1e959946fb48f3e8a269d338841902 | https://github.com/nopnop/docflux/blob/3929fdac9d1e959946fb48f3e8a269d338841902/lib/markdown.js#L34-L86 | train |
melvincarvalho/rdf-shell | lib/post.js | post | function post(argv, callback) {
if (!argv[2]) {
console.error("url is required");
console.error("Usage : post <url> <data>");
process.exit(-1);
}
if (!argv[3]) {
console.error("data is required");
console.error("Usage : post <url> <data>");
process.exit(-1);
}
util.post(argv[2], argv[3... | javascript | function post(argv, callback) {
if (!argv[2]) {
console.error("url is required");
console.error("Usage : post <url> <data>");
process.exit(-1);
}
if (!argv[3]) {
console.error("data is required");
console.error("Usage : post <url> <data>");
process.exit(-1);
}
util.post(argv[2], argv[3... | [
"function",
"post",
"(",
"argv",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"argv",
"[",
"2",
"]",
")",
"{",
"console",
".",
"error",
"(",
"\"url is required\"",
")",
";",
"console",
".",
"error",
"(",
"\"Usage : post <url> <data>\"",
")",
";",
"process"... | post gets list of files for a given container
@param {String} argv[2] url
@param {String} argv[3] data
@callback {bin~cb} callback | [
"post",
"gets",
"list",
"of",
"files",
"for",
"a",
"given",
"container"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/lib/post.js#L14-L32 | train |
andrewffff/node-webmon | node-webmon.js | DbWriter | function DbWriter(db,errorLogObject,successLogObject) {
this.db = db;
this.errorLogObject = errorLogObject;
this.successLogObject = successLogObject;
} | javascript | function DbWriter(db,errorLogObject,successLogObject) {
this.db = db;
this.errorLogObject = errorLogObject;
this.successLogObject = successLogObject;
} | [
"function",
"DbWriter",
"(",
"db",
",",
"errorLogObject",
",",
"successLogObject",
")",
"{",
"this",
".",
"db",
"=",
"db",
";",
"this",
".",
"errorLogObject",
"=",
"errorLogObject",
";",
"this",
".",
"successLogObject",
"=",
"successLogObject",
";",
"}"
] | Stuff to log content and errors into the database | [
"Stuff",
"to",
"log",
"content",
"and",
"errors",
"into",
"the",
"database"
] | 3f9a7b7a3a0a1209fe0408d20c6f5f61f48923bc | https://github.com/andrewffff/node-webmon/blob/3f9a7b7a3a0a1209fe0408d20c6f5f61f48923bc/node-webmon.js#L20-L24 | train |
andrewffff/node-webmon | node-webmon.js | handleError | function handleError(note,needsReconnect) {
writer.logError({
src_id: streamConfig.src_id,
ts: Date.now(),
error: note
});
if(needsReconnect) {
setTimeout(function() { doIoStream(streamConfig); }, 1000*streamConfig.error_wait_secs);
}
} | javascript | function handleError(note,needsReconnect) {
writer.logError({
src_id: streamConfig.src_id,
ts: Date.now(),
error: note
});
if(needsReconnect) {
setTimeout(function() { doIoStream(streamConfig); }, 1000*streamConfig.error_wait_secs);
}
} | [
"function",
"handleError",
"(",
"note",
",",
"needsReconnect",
")",
"{",
"writer",
".",
"logError",
"(",
"{",
"src_id",
":",
"streamConfig",
".",
"src_id",
",",
"ts",
":",
"Date",
".",
"now",
"(",
")",
",",
"error",
":",
"note",
"}",
")",
";",
"if",
... | we regard disconnection as an "error" for logging purposes, and a reconnect to be a "new connection". we use the "normal wait" time for the reconnection attempts that socket.io itself performs. when socket.io gives up after a few attempts, we use the "error wait" time before forcing a retry | [
"we",
"regard",
"disconnection",
"as",
"an",
"error",
"for",
"logging",
"purposes",
"and",
"a",
"reconnect",
"to",
"be",
"a",
"new",
"connection",
".",
"we",
"use",
"the",
"normal",
"wait",
"time",
"for",
"the",
"reconnection",
"attempts",
"that",
"socket",
... | 3f9a7b7a3a0a1209fe0408d20c6f5f61f48923bc | https://github.com/andrewffff/node-webmon/blob/3f9a7b7a3a0a1209fe0408d20c6f5f61f48923bc/node-webmon.js#L211-L221 | train |
Ma3Route/node-sdk | lib/utils.js | setup | function setup(settings) {
if (!settings) {
return _.cloneDeep(SETTINGS);
}
_.merge(SETTINGS, settings);
return _.cloneDeep(SETTINGS);
} | javascript | function setup(settings) {
if (!settings) {
return _.cloneDeep(SETTINGS);
}
_.merge(SETTINGS, settings);
return _.cloneDeep(SETTINGS);
} | [
"function",
"setup",
"(",
"settings",
")",
"{",
"if",
"(",
"!",
"settings",
")",
"{",
"return",
"_",
".",
"cloneDeep",
"(",
"SETTINGS",
")",
";",
"}",
"_",
".",
"merge",
"(",
"SETTINGS",
",",
"settings",
")",
";",
"return",
"_",
".",
"cloneDeep",
"... | Set the SDK settings
@public
@param {SETTINGS} settings - new SDK settings
@return {Object} the newly-set SDK settings | [
"Set",
"the",
"SDK",
"settings"
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L76-L82 | train |
Ma3Route/node-sdk | lib/utils.js | parseResponse | function parseResponse(response) {
var code = response.statusCode;
var type = code / 100 | 0;
response.type = type;
// basics
switch (type) {
case 1:
response.info = type;
break;
case 2:
response.ok = type;
break;
case 3:
// ???
break;
... | javascript | function parseResponse(response) {
var code = response.statusCode;
var type = code / 100 | 0;
response.type = type;
// basics
switch (type) {
case 1:
response.info = type;
break;
case 2:
response.ok = type;
break;
case 3:
// ???
break;
... | [
"function",
"parseResponse",
"(",
"response",
")",
"{",
"var",
"code",
"=",
"response",
".",
"statusCode",
";",
"var",
"type",
"=",
"code",
"/",
"100",
"|",
"0",
";",
"response",
".",
"type",
"=",
"type",
";",
"// basics",
"switch",
"(",
"type",
")",
... | Add properties to response
@private
@see {@link http://visionmedia.github.io/superagent/#response-properties}
@param {Object} response - as from the `request` module
@return {Object} the originally passed but modified reponse | [
"Add",
"properties",
"to",
"response"
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L239-L318 | train |
Ma3Route/node-sdk | lib/utils.js | passResponse | function passResponse(callback, options) {
options = options || {};
return function handleResponse(error, response, body) {
if (error) {
return callback(new errors.io.IOError(error.mesage, error));
}
response = parseResponse(response);
body = body || { };
if (... | javascript | function passResponse(callback, options) {
options = options || {};
return function handleResponse(error, response, body) {
if (error) {
return callback(new errors.io.IOError(error.mesage, error));
}
response = parseResponse(response);
body = body || { };
if (... | [
"function",
"passResponse",
"(",
"callback",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"return",
"function",
"handleResponse",
"(",
"error",
",",
"response",
",",
"body",
")",
"{",
"if",
"(",
"error",
")",
"{",
"return",
... | Parse response then pass to callback
@public
@param {Function} callback - user's callback
@param {Object} [options]
@param {Boolean} [options.post] - callback is for a POST request
@param {Boolean} [options.put] - callback is for a PUT request
@return {Function} function to handle responses from `request` calls | [
"Parse",
"response",
"then",
"pass",
"to",
"callback"
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L332-L349 | train |
Ma3Route/node-sdk | lib/utils.js | allowOptionalParams | function allowOptionalParams(params, callback) {
if (!callback) {
callback = params;
params = { };
}
return {
params: params,
callback: callback,
};
} | javascript | function allowOptionalParams(params, callback) {
if (!callback) {
callback = params;
params = { };
}
return {
params: params,
callback: callback,
};
} | [
"function",
"allowOptionalParams",
"(",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
")",
"{",
"callback",
"=",
"params",
";",
"params",
"=",
"{",
"}",
";",
"}",
"return",
"{",
"params",
":",
"params",
",",
"callback",
":",
"callbac... | Allow 'params' to be optional, thus user can pass 'callback' in its place.
@public
@param {*} params - user's params
@param {Function} [callback] - user's callback
@return {Object} args
@return {Function} args.callback
@return {Function} args.params | [
"Allow",
"params",
"to",
"be",
"optional",
"thus",
"user",
"can",
"pass",
"callback",
"in",
"its",
"place",
"."
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L395-L404 | train |
Ma3Route/node-sdk | lib/utils.js | getOptions | function getOptions(sources, keys, dest) {
var options = dest || { };
// allow source be an array
if (!_.isArray(sources)) {
sources = [ sources ];
}
// using the keys for lookup
keys.forEach(function(key) {
// from each source
sources.forEach(function(source) {
... | javascript | function getOptions(sources, keys, dest) {
var options = dest || { };
// allow source be an array
if (!_.isArray(sources)) {
sources = [ sources ];
}
// using the keys for lookup
keys.forEach(function(key) {
// from each source
sources.forEach(function(source) {
... | [
"function",
"getOptions",
"(",
"sources",
",",
"keys",
",",
"dest",
")",
"{",
"var",
"options",
"=",
"dest",
"||",
"{",
"}",
";",
"// allow source be an array",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"sources",
")",
")",
"{",
"sources",
"=",
"[",
... | Return an object with key-value pairs, using keys, from an object
@param {Object|Object[]} sources - object(s) to look for the properties
@param {Array} keys - an array of keys of the properties to look up
@param {Object} [dest] - destination object
@return {Object} options | [
"Return",
"an",
"object",
"with",
"key",
"-",
"value",
"pairs",
"using",
"keys",
"from",
"an",
"object"
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L415-L434 | train |
Ma3Route/node-sdk | lib/utils.js | removeOptions | function removeOptions(args, keys) {
if (!_.isArray(keys)) {
keys = [ keys ];
}
for (var index = 0; index < args.length; index++) {
var arg = args[index];
for (var key in arg) {
if (_.includes(keys, key)) {
delete arg[key];
}
}
}
} | javascript | function removeOptions(args, keys) {
if (!_.isArray(keys)) {
keys = [ keys ];
}
for (var index = 0; index < args.length; index++) {
var arg = args[index];
for (var key in arg) {
if (_.includes(keys, key)) {
delete arg[key];
}
}
}
} | [
"function",
"removeOptions",
"(",
"args",
",",
"keys",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"keys",
")",
")",
"{",
"keys",
"=",
"[",
"keys",
"]",
";",
"}",
"for",
"(",
"var",
"index",
"=",
"0",
";",
"index",
"<",
"args",
".",
"... | Delete keys from objects
@param {Object[]} args
@param {String|String[]} keys | [
"Delete",
"keys",
"from",
"objects"
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L455-L467 | train |
Ma3Route/node-sdk | lib/utils.js | pickParams | function pickParams(params, keys) {
params = _.cloneDeep(params);
// decamelize all options
for (var key in params) {
var value = params[key];
delete params[key];
// TODO: handle this inconsistency consistently in the library :(
// 'base64String': introduced by 'image.upload(... | javascript | function pickParams(params, keys) {
params = _.cloneDeep(params);
// decamelize all options
for (var key in params) {
var value = params[key];
delete params[key];
// TODO: handle this inconsistency consistently in the library :(
// 'base64String': introduced by 'image.upload(... | [
"function",
"pickParams",
"(",
"params",
",",
"keys",
")",
"{",
"params",
"=",
"_",
".",
"cloneDeep",
"(",
"params",
")",
";",
"// decamelize all options",
"for",
"(",
"var",
"key",
"in",
"params",
")",
"{",
"var",
"value",
"=",
"params",
"[",
"key",
"... | Pick out parameters
@param {Object} params
@return {Object} cleaner params | [
"Pick",
"out",
"parameters"
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L520-L537 | train |
Ma3Route/node-sdk | lib/utils.js | collectPages | function collectPages(func, callback) {
var items = [];
var lastReadId = 0;
function __collect() {
return func(lastReadId, function(error, page) {
if (error) {
return callback(error);
}
if (!page.length) {
return callback(null, item... | javascript | function collectPages(func, callback) {
var items = [];
var lastReadId = 0;
function __collect() {
return func(lastReadId, function(error, page) {
if (error) {
return callback(error);
}
if (!page.length) {
return callback(null, item... | [
"function",
"collectPages",
"(",
"func",
",",
"callback",
")",
"{",
"var",
"items",
"=",
"[",
"]",
";",
"var",
"lastReadId",
"=",
"0",
";",
"function",
"__collect",
"(",
")",
"{",
"return",
"func",
"(",
"lastReadId",
",",
"function",
"(",
"error",
",",... | Helper function for collecting all pages of items.
@param {Function} func(lastReadId, next) Function invoked to fetch requests
@param {Object} callback(error, items) Function invoked once all pages have been fetched | [
"Helper",
"function",
"for",
"collecting",
"all",
"pages",
"of",
"items",
"."
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/utils.js#L546-L563 | train |
IonicaBizau/node-levdist | lib/index.js | LevDist | function LevDist (s, t) {
var d = []
, n = s.length
, m = t.length
, i
, j
, s_i
, t_j
, cost
, mi
, b
, c
;
if (n == 0) return m;
if (m == 0) return n;
// Step 1
for (i = n; i >= 0; --i) { d[i] = []; }
// Step 2
for (i = n... | javascript | function LevDist (s, t) {
var d = []
, n = s.length
, m = t.length
, i
, j
, s_i
, t_j
, cost
, mi
, b
, c
;
if (n == 0) return m;
if (m == 0) return n;
// Step 1
for (i = n; i >= 0; --i) { d[i] = []; }
// Step 2
for (i = n... | [
"function",
"LevDist",
"(",
"s",
",",
"t",
")",
"{",
"var",
"d",
"=",
"[",
"]",
",",
"n",
"=",
"s",
".",
"length",
",",
"m",
"=",
"t",
".",
"length",
",",
"i",
",",
"j",
",",
"s_i",
",",
"t_j",
",",
"cost",
",",
"mi",
",",
"b",
",",
"c"... | LevDist
Calculates the Levenshtein distance.
@name LevDist
@function
@param {String} s The first string.
@param {String} t The second string.
@return {Number} The Levenshtein distance value. | [
"LevDist",
"Calculates",
"the",
"Levenshtein",
"distance",
"."
] | 9a869f98504cf02bcd37c2900e6b71d2245d3a76 | https://github.com/IonicaBizau/node-levdist/blob/9a869f98504cf02bcd37c2900e6b71d2245d3a76/lib/index.js#L11-L70 | train |
craiglonsdale/repohelper | lib/githubAuthentication.js | readTokenFile | function readTokenFile(tokenFile) {
return new Promise((resolve, reject) => {
fs.readFile(tokenFile, 'utf8', (err, token) => {
if (err) {
reject(err);
}
resolve(token.slice(0, 40));
});
});
} | javascript | function readTokenFile(tokenFile) {
return new Promise((resolve, reject) => {
fs.readFile(tokenFile, 'utf8', (err, token) => {
if (err) {
reject(err);
}
resolve(token.slice(0, 40));
});
});
} | [
"function",
"readTokenFile",
"(",
"tokenFile",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"readFile",
"(",
"tokenFile",
",",
"'utf8'",
",",
"(",
"err",
",",
"token",
")",
"=>",
"{",
"if",
"(",... | Read the token string from a file
@param {String} tokenFile The name of a file to read
@return {Promise} Resolves to the 40-char token | [
"Read",
"the",
"token",
"string",
"from",
"a",
"file"
] | 9685a71e0d2cfc78df76280b9b1a8e66d0001587 | https://github.com/craiglonsdale/repohelper/blob/9685a71e0d2cfc78df76280b9b1a8e66d0001587/lib/githubAuthentication.js#L34-L43 | train |
craiglonsdale/repohelper | lib/githubAuthentication.js | createGithubCredentials | function createGithubCredentials(token) {
return new Promise((resolve, reject) => {
if (token) {
resolve({ type: 'oauth', token: token });
}
else {
reject('Missing token');
}
});
} | javascript | function createGithubCredentials(token) {
return new Promise((resolve, reject) => {
if (token) {
resolve({ type: 'oauth', token: token });
}
else {
reject('Missing token');
}
});
} | [
"function",
"createGithubCredentials",
"(",
"token",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"token",
")",
"{",
"resolve",
"(",
"{",
"type",
":",
"'oauth'",
",",
"token",
":",
"token",
"}",
... | Takes a token and returns an object used for authenticating with the Github API.
@param {String} token 40-char token string
@return {Promise} Resolves to an Object containing the token | [
"Takes",
"a",
"token",
"and",
"returns",
"an",
"object",
"used",
"for",
"authenticating",
"with",
"the",
"Github",
"API",
"."
] | 9685a71e0d2cfc78df76280b9b1a8e66d0001587 | https://github.com/craiglonsdale/repohelper/blob/9685a71e0d2cfc78df76280b9b1a8e66d0001587/lib/githubAuthentication.js#L50-L59 | train |
craiglonsdale/repohelper | lib/githubAuthentication.js | getUserCredentials | function getUserCredentials() {
return new Promise((resolve) => {
print(clc.bold('Sign in to authorize this app to find open pull-requests'), true);
gitUser.email((err, email) => {
prompt.message = '';
prompt.delimiter = '';
prompt.start();
prompt.get({
properties: {
... | javascript | function getUserCredentials() {
return new Promise((resolve) => {
print(clc.bold('Sign in to authorize this app to find open pull-requests'), true);
gitUser.email((err, email) => {
prompt.message = '';
prompt.delimiter = '';
prompt.start();
prompt.get({
properties: {
... | [
"function",
"getUserCredentials",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
")",
"=>",
"{",
"print",
"(",
"clc",
".",
"bold",
"(",
"'Sign in to authorize this app to find open pull-requests'",
")",
",",
"true",
")",
";",
"gitUser",
".",
"... | Prompts the user to enter their Github login details.
@return {Promise} Resolves to an object containin a username and password | [
"Prompts",
"the",
"user",
"to",
"enter",
"their",
"Github",
"login",
"details",
"."
] | 9685a71e0d2cfc78df76280b9b1a8e66d0001587 | https://github.com/craiglonsdale/repohelper/blob/9685a71e0d2cfc78df76280b9b1a8e66d0001587/lib/githubAuthentication.js#L65-L90 | train |
craiglonsdale/repohelper | lib/githubAuthentication.js | authorizeApp | function authorizeApp(user, tokenName, scope) {
return new Promise((resolve, reject) => {
request.post('https://api.github.com/authorizations', {
auth: {
user: user.username,
pass: user.password,
sendImmediately: true
},
headers: {
'content-type': 'application/x-w... | javascript | function authorizeApp(user, tokenName, scope) {
return new Promise((resolve, reject) => {
request.post('https://api.github.com/authorizations', {
auth: {
user: user.username,
pass: user.password,
sendImmediately: true
},
headers: {
'content-type': 'application/x-w... | [
"function",
"authorizeApp",
"(",
"user",
",",
"tokenName",
",",
"scope",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
".",
"post",
"(",
"'https://api.github.com/authorizations'",
",",
"{",
"auth",
":",
... | Attempt to create a new Personal Access Token with the Github API.
@param {Object} user Object containing the username and password
@param {String} tokenName Name of the token to be created_at
@param {Array} scope List of priviledges to allow the token (See
https://developer.github.com/v3/oauth/#scopes)
@r... | [
"Attempt",
"to",
"create",
"a",
"new",
"Personal",
"Access",
"Token",
"with",
"the",
"Github",
"API",
"."
] | 9685a71e0d2cfc78df76280b9b1a8e66d0001587 | https://github.com/craiglonsdale/repohelper/blob/9685a71e0d2cfc78df76280b9b1a8e66d0001587/lib/githubAuthentication.js#L100-L130 | train |
craiglonsdale/repohelper | lib/githubAuthentication.js | createTokenFile | function createTokenFile(token, tokenFile) {
return new Promise((resolve, reject) => {
fs.writeFile(tokenFile, token, (err) => {
if (err) {
reject(err);
}
resolve(token);
});
});
} | javascript | function createTokenFile(token, tokenFile) {
return new Promise((resolve, reject) => {
fs.writeFile(tokenFile, token, (err) => {
if (err) {
reject(err);
}
resolve(token);
});
});
} | [
"function",
"createTokenFile",
"(",
"token",
",",
"tokenFile",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"writeFile",
"(",
"tokenFile",
",",
"token",
",",
"(",
"err",
")",
"=>",
"{",
"if",
"(... | Write a token to a given file.
@param {String} token The token to save to a file
@param {String} tokenFile Name of the file to create
@return {Promise} Resolves back the token that was passed in | [
"Write",
"a",
"token",
"to",
"a",
"given",
"file",
"."
] | 9685a71e0d2cfc78df76280b9b1a8e66d0001587 | https://github.com/craiglonsdale/repohelper/blob/9685a71e0d2cfc78df76280b9b1a8e66d0001587/lib/githubAuthentication.js#L138-L147 | train |
kengz/reqscraper | scraper.js | scrape | function scrape(dyn, url, scope, selector) {
return new Promise(function(dresolve, dreject) {
var scraper = dyn ? dx : x;
scraper(url, scope, selector)(function(err, res) {
dresolve(res);
})
})
} | javascript | function scrape(dyn, url, scope, selector) {
return new Promise(function(dresolve, dreject) {
var scraper = dyn ? dx : x;
scraper(url, scope, selector)(function(err, res) {
dresolve(res);
})
})
} | [
"function",
"scrape",
"(",
"dyn",
",",
"url",
",",
"scope",
",",
"selector",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"dresolve",
",",
"dreject",
")",
"{",
"var",
"scraper",
"=",
"dyn",
"?",
"dx",
":",
"x",
";",
"scraper",
"(",
"... | Scrapes a url with html selectors. If dyn == true, use a dynamic scraper dx. Returns a promise. | [
"Scrapes",
"a",
"url",
"with",
"html",
"selectors",
".",
"If",
"dyn",
"==",
"true",
"use",
"a",
"dynamic",
"scraper",
"dx",
".",
"Returns",
"a",
"promise",
"."
] | 62950eaa4995ba9ae187ab4a803c4dcff0fa667a | https://github.com/kengz/reqscraper/blob/62950eaa4995ba9ae187ab4a803c4dcff0fa667a/scraper.js#L91-L98 | train |
TempoIQ/tempoiq-node-js | lib/models/sensor.js | Sensor | function Sensor(key, params) {
var p = params || {};
// The sensor primary key [String]
this.key = key;
// Human readable name of the sensor [String] EG - "Thermometer 1"
this.name = p.name || "";
// Indexable attributes. Useful for grouping related sensors.
// EG - {unit: "F", model: 'FHZ343'}
this.a... | javascript | function Sensor(key, params) {
var p = params || {};
// The sensor primary key [String]
this.key = key;
// Human readable name of the sensor [String] EG - "Thermometer 1"
this.name = p.name || "";
// Indexable attributes. Useful for grouping related sensors.
// EG - {unit: "F", model: 'FHZ343'}
this.a... | [
"function",
"Sensor",
"(",
"key",
",",
"params",
")",
"{",
"var",
"p",
"=",
"params",
"||",
"{",
"}",
";",
"// The sensor primary key [String]",
"this",
".",
"key",
"=",
"key",
";",
"// Human readable name of the sensor [String] EG - \"Thermometer 1\"",
"this",
".",... | The container for a stream of time series DataPoints. | [
"The",
"container",
"for",
"a",
"stream",
"of",
"time",
"series",
"DataPoints",
"."
] | b3ab72f9d7760a54df9ef75093d349b28a29864c | https://github.com/TempoIQ/tempoiq-node-js/blob/b3ab72f9d7760a54df9ef75093d349b28a29864c/lib/models/sensor.js#L4-L15 | train |
mucbuc/flukeJS | fluke.js | splitNext | function splitNext(source, cb, rules) {
var matchPos = source.search( makeRegExp( joinProperties( rules ) ) );
if (matchPos != -1) {
var match = source.substr( 0, matchPos + 1 )
for (property in rules) {
var rule = rules[property]
, re = makeRegExp( rule );
if (source.search(re) == m... | javascript | function splitNext(source, cb, rules) {
var matchPos = source.search( makeRegExp( joinProperties( rules ) ) );
if (matchPos != -1) {
var match = source.substr( 0, matchPos + 1 )
for (property in rules) {
var rule = rules[property]
, re = makeRegExp( rule );
if (source.search(re) == m... | [
"function",
"splitNext",
"(",
"source",
",",
"cb",
",",
"rules",
")",
"{",
"var",
"matchPos",
"=",
"source",
".",
"search",
"(",
"makeRegExp",
"(",
"joinProperties",
"(",
"rules",
")",
")",
")",
";",
"if",
"(",
"matchPos",
"!=",
"-",
"1",
")",
"{",
... | process next token in source | [
"process",
"next",
"token",
"in",
"source"
] | 45f4643c3fa5b9e2f3240ee8af214a4e545dd3fb | https://github.com/mucbuc/flukeJS/blob/45f4643c3fa5b9e2f3240ee8af214a4e545dd3fb/fluke.js#L3-L36 | train |
mucbuc/flukeJS | fluke.js | splitAll | function splitAll(source, cb, rules) {
var done = false
, stash = '';
do {
splitNext( source, function(event, response) {
response.stash = stash;
if (event == 'end') done = true;
else {
source = response.rhs;
stash += response.lhs + response.token;
... | javascript | function splitAll(source, cb, rules) {
var done = false
, stash = '';
do {
splitNext( source, function(event, response) {
response.stash = stash;
if (event == 'end') done = true;
else {
source = response.rhs;
stash += response.lhs + response.token;
... | [
"function",
"splitAll",
"(",
"source",
",",
"cb",
",",
"rules",
")",
"{",
"var",
"done",
"=",
"false",
",",
"stash",
"=",
"''",
";",
"do",
"{",
"splitNext",
"(",
"source",
",",
"function",
"(",
"event",
",",
"response",
")",
"{",
"response",
".",
"... | process all tokens in tokens | [
"process",
"all",
"tokens",
"in",
"tokens"
] | 45f4643c3fa5b9e2f3240ee8af214a4e545dd3fb | https://github.com/mucbuc/flukeJS/blob/45f4643c3fa5b9e2f3240ee8af214a4e545dd3fb/fluke.js#L39-L69 | train |
jbaylina/ethconnector | eth_connector.js | send | function send(method, params, callback) {
if (typeof params === "function") {
callback = params;
params = [];
}
self.web3.currentProvider.sendAsync({
jsonrpc: "2.0",
method,
params: params || [],
... | javascript | function send(method, params, callback) {
if (typeof params === "function") {
callback = params;
params = [];
}
self.web3.currentProvider.sendAsync({
jsonrpc: "2.0",
method,
params: params || [],
... | [
"function",
"send",
"(",
"method",
",",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"params",
"===",
"\"function\"",
")",
"{",
"callback",
"=",
"params",
";",
"params",
"=",
"[",
"]",
";",
"}",
"self",
".",
"web3",
".",
"currentProvider",... | CALL a low level rpc | [
"CALL",
"a",
"low",
"level",
"rpc"
] | f9b4640ac002eccfbf9f371d9cf6c7bee72c55c2 | https://github.com/jbaylina/ethconnector/blob/f9b4640ac002eccfbf9f371d9cf6c7bee72c55c2/eth_connector.js#L244-L256 | train |
jpitts/rapt-modelrizerly | lib/modelrizerly.js | underscoreToCamel | function underscoreToCamel (str) {
str = str.charAt(0).toUpperCase() + str.slice(1);
return str.replace(/\_(.)/g, function (x, chr) {
return chr.toUpperCase();
})
} | javascript | function underscoreToCamel (str) {
str = str.charAt(0).toUpperCase() + str.slice(1);
return str.replace(/\_(.)/g, function (x, chr) {
return chr.toUpperCase();
})
} | [
"function",
"underscoreToCamel",
"(",
"str",
")",
"{",
"str",
"=",
"str",
".",
"charAt",
"(",
"0",
")",
".",
"toUpperCase",
"(",
")",
"+",
"str",
".",
"slice",
"(",
"1",
")",
";",
"return",
"str",
".",
"replace",
"(",
"/",
"\\_(.)",
"/",
"g",
","... | convert the underscore convention to camelized | [
"convert",
"the",
"underscore",
"convention",
"to",
"camelized"
] | 4b6b5bd0e7838c05029e7c20d500c9f4f7b0cc92 | https://github.com/jpitts/rapt-modelrizerly/blob/4b6b5bd0e7838c05029e7c20d500c9f4f7b0cc92/lib/modelrizerly.js#L205-L210 | train |
GTDev87/tuber-deploy | lib/index.js | find3rdPartyCaveatParts | function find3rdPartyCaveatParts(macaroonWithCaveat, secretPem) {
var macaroonSerialized = macaroonWithCaveat.macaroon;
var discharge = macaroonWithCaveat.discharge;
var key = new NodeRSA();
key.importKey(secretPem);
var macaroon = MacaroonsBuilder.deserialize(macaroonSerialized);
var getDischargeParts =... | javascript | function find3rdPartyCaveatParts(macaroonWithCaveat, secretPem) {
var macaroonSerialized = macaroonWithCaveat.macaroon;
var discharge = macaroonWithCaveat.discharge;
var key = new NodeRSA();
key.importKey(secretPem);
var macaroon = MacaroonsBuilder.deserialize(macaroonSerialized);
var getDischargeParts =... | [
"function",
"find3rdPartyCaveatParts",
"(",
"macaroonWithCaveat",
",",
"secretPem",
")",
"{",
"var",
"macaroonSerialized",
"=",
"macaroonWithCaveat",
".",
"macaroon",
";",
"var",
"discharge",
"=",
"macaroonWithCaveat",
".",
"discharge",
";",
"var",
"key",
"=",
"new"... | this needs to be separated into own library separate from 3rd party macaroons. | [
"this",
"needs",
"to",
"be",
"separated",
"into",
"own",
"library",
"separate",
"from",
"3rd",
"party",
"macaroons",
"."
] | 6d519bebf4afb451d8d8f88dfd7453bbbfe1650f | https://github.com/GTDev87/tuber-deploy/blob/6d519bebf4afb451d8d8f88dfd7453bbbfe1650f/lib/index.js#L12-L49 | train |
webinverters/robust-ioc | index.js | function() {
serviceFactory.optionalDeps = {}
_.each(arguments, function(depName) {
serviceFactory.optionalDeps[depName] = true
})
} | javascript | function() {
serviceFactory.optionalDeps = {}
_.each(arguments, function(depName) {
serviceFactory.optionalDeps[depName] = true
})
} | [
"function",
"(",
")",
"{",
"serviceFactory",
".",
"optionalDeps",
"=",
"{",
"}",
"_",
".",
"each",
"(",
"arguments",
",",
"function",
"(",
"depName",
")",
"{",
"serviceFactory",
".",
"optionalDeps",
"[",
"depName",
"]",
"=",
"true",
"}",
")",
"}"
] | use this chain method to mark optional dependencies to suppress warnings. | [
"use",
"this",
"chain",
"method",
"to",
"mark",
"optional",
"dependencies",
"to",
"suppress",
"warnings",
"."
] | 497b92e9f14b63cb01cc41f48716d15a2f39cb1f | https://github.com/webinverters/robust-ioc/blob/497b92e9f14b63cb01cc41f48716d15a2f39cb1f/index.js#L135-L140 | train | |
cliffano/bagofholding | lib/obj.js | value | function value(dsv, obj) {
dsv = dsv || '';
obj = obj || {};
var props = dsv.split('.'),
_value;
for (var i = 0, ln = props.length; i < ln; i += 1) {
_value = (_value) ? _value[props[i]] : obj[props[i]];
if (_value === undefined) {
break;
}
}
return _value;
} | javascript | function value(dsv, obj) {
dsv = dsv || '';
obj = obj || {};
var props = dsv.split('.'),
_value;
for (var i = 0, ln = props.length; i < ln; i += 1) {
_value = (_value) ? _value[props[i]] : obj[props[i]];
if (_value === undefined) {
break;
}
}
return _value;
} | [
"function",
"value",
"(",
"dsv",
",",
"obj",
")",
"{",
"dsv",
"=",
"dsv",
"||",
"''",
";",
"obj",
"=",
"obj",
"||",
"{",
"}",
";",
"var",
"props",
"=",
"dsv",
".",
"split",
"(",
"'.'",
")",
",",
"_value",
";",
"for",
"(",
"var",
"i",
"=",
"... | Retrieve the value of nested properties within an object.
@param {String} dsv: dot-separated nested properties name
@param {Object} obj: the object to find the nested properties from
@return {?} value of the nested properties | [
"Retrieve",
"the",
"value",
"of",
"nested",
"properties",
"within",
"an",
"object",
"."
] | da36a914f85dcc34c375ef08046b2968df2f17c1 | https://github.com/cliffano/bagofholding/blob/da36a914f85dcc34c375ef08046b2968df2f17c1/lib/obj.js#L20-L36 | train |
torworx/ovy | ovy.js | function (value) {
var type = typeof value,
checkLength = false;
if (value && type != 'string') {
// Functions have a length property, so we need to filter them out
if (type == 'function') {
// In Safari,... | javascript | function (value) {
var type = typeof value,
checkLength = false;
if (value && type != 'string') {
// Functions have a length property, so we need to filter them out
if (type == 'function') {
// In Safari,... | [
"function",
"(",
"value",
")",
"{",
"var",
"type",
"=",
"typeof",
"value",
",",
"checkLength",
"=",
"false",
";",
"if",
"(",
"value",
"&&",
"type",
"!=",
"'string'",
")",
"{",
"// Functions have a length property, so we need to filter them out",
"if",
"(",
"type... | Returns true if the passed value is iterable, false otherwise
@param {Object} value The value to test
@return {Boolean} | [
"Returns",
"true",
"if",
"the",
"passed",
"value",
"is",
"iterable",
"false",
"otherwise"
] | 18e9727305ab37acee1954a3facdd65b3a3526ab | https://github.com/torworx/ovy/blob/18e9727305ab37acee1954a3facdd65b3a3526ab/ovy.js#L84-L100 | train | |
OctaveWealth/passy | lib/identity.js | _getDateMillis | function _getDateMillis (epoc) {
// Use highres time if available as JS date is +- 15ms
try {
var microtime = require('microtime');
// Time in microsecs, convert to ms
return (Math.round(microtime.now() / 1000) - epoc.getTime()).toString(2);
} catch (err) {}
return ((new Date()) - epoc).toString(2)... | javascript | function _getDateMillis (epoc) {
// Use highres time if available as JS date is +- 15ms
try {
var microtime = require('microtime');
// Time in microsecs, convert to ms
return (Math.round(microtime.now() / 1000) - epoc.getTime()).toString(2);
} catch (err) {}
return ((new Date()) - epoc).toString(2)... | [
"function",
"_getDateMillis",
"(",
"epoc",
")",
"{",
"// Use highres time if available as JS date is +- 15ms",
"try",
"{",
"var",
"microtime",
"=",
"require",
"(",
"'microtime'",
")",
";",
"// Time in microsecs, convert to ms",
"return",
"(",
"Math",
".",
"round",
"(",
... | Get Milliseconds since supplied epoc, using
highres timers if available
@private
@param {Date} epoc The epoc to use
@return {string} Milliseconds encoded as bitstring | [
"Get",
"Milliseconds",
"since",
"supplied",
"epoc",
"using",
"highres",
"timers",
"if",
"available"
] | 6e357b018952f73e8570b89eda95393780328fab | https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/identity.js#L62-L71 | train |
OctaveWealth/passy | lib/identity.js | _identity | function _identity (ndate, nrandom, nchecksum, epoc) {
// ms since EPOC (1 Jan 1970)
var since = _getDateMillis(epoc);
// Max of ndate
if (since.length > ndate) {
throw new Error('Date too big');
}
// Pad to ndate
since = bitString.pad(since, ndate);
// Add nrandom Random bits
since += bitStrin... | javascript | function _identity (ndate, nrandom, nchecksum, epoc) {
// ms since EPOC (1 Jan 1970)
var since = _getDateMillis(epoc);
// Max of ndate
if (since.length > ndate) {
throw new Error('Date too big');
}
// Pad to ndate
since = bitString.pad(since, ndate);
// Add nrandom Random bits
since += bitStrin... | [
"function",
"_identity",
"(",
"ndate",
",",
"nrandom",
",",
"nchecksum",
",",
"epoc",
")",
"{",
"// ms since EPOC (1 Jan 1970)",
"var",
"since",
"=",
"_getDateMillis",
"(",
"epoc",
")",
";",
"// Max of ndate",
"if",
"(",
"since",
".",
"length",
">",
"ndate",
... | Build an identity function
@private
@param {integer} ndate Size of date bits
@param {integer} nrandom Size of random bits
@param {integer} nchecksum Size of checksum bits
@param {Date} epoc Epoc to use
@return {string} BaseURL encoded id | [
"Build",
"an",
"identity",
"function"
] | 6e357b018952f73e8570b89eda95393780328fab | https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/identity.js#L82-L102 | train |
OctaveWealth/passy | lib/identity.js | _isValid | function _isValid (ndate, nrandom, nchecksum, id) {
// Guard
if (!baseURL.isValid(id)) return false;
if (id.length !== (ndate + nrandom + nchecksum) / 6) return false;
// Test
var bits = baseURL.decode(id),
main = bits.slice(0, bits.length - nchecksum),
check = bits.slice(bits.length - nchecksum, bit... | javascript | function _isValid (ndate, nrandom, nchecksum, id) {
// Guard
if (!baseURL.isValid(id)) return false;
if (id.length !== (ndate + nrandom + nchecksum) / 6) return false;
// Test
var bits = baseURL.decode(id),
main = bits.slice(0, bits.length - nchecksum),
check = bits.slice(bits.length - nchecksum, bit... | [
"function",
"_isValid",
"(",
"ndate",
",",
"nrandom",
",",
"nchecksum",
",",
"id",
")",
"{",
"// Guard",
"if",
"(",
"!",
"baseURL",
".",
"isValid",
"(",
"id",
")",
")",
"return",
"false",
";",
"if",
"(",
"id",
".",
"length",
"!==",
"(",
"ndate",
"+... | Check if a id is valid
@private
@param {integer} ndate Size of date bits
@param {integer} nrandom Size of random bits
@param {integer} nchecksum Size of checksum bits
@param {string} id BaseURL encoded Id to test
@return {Boolean} [description] | [
"Check",
"if",
"a",
"id",
"is",
"valid"
] | 6e357b018952f73e8570b89eda95393780328fab | https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/identity.js#L113-L124 | train |
OctaveWealth/passy | lib/identity.js | _toDate | function _toDate (ndate, nrandom, nchecksum, epoc, id) {
// Guard
if (!_isValid(ndate, nrandom, nchecksum, id)) throw new Error('identity#toDate: Invalid Id');
// Calculate
var bits = baseURL.decode(id),
dateBits = bits.slice(0, ndate);
return new Date(parseInt(dateBits, 2) + epoc.getTime());
} | javascript | function _toDate (ndate, nrandom, nchecksum, epoc, id) {
// Guard
if (!_isValid(ndate, nrandom, nchecksum, id)) throw new Error('identity#toDate: Invalid Id');
// Calculate
var bits = baseURL.decode(id),
dateBits = bits.slice(0, ndate);
return new Date(parseInt(dateBits, 2) + epoc.getTime());
} | [
"function",
"_toDate",
"(",
"ndate",
",",
"nrandom",
",",
"nchecksum",
",",
"epoc",
",",
"id",
")",
"{",
"// Guard",
"if",
"(",
"!",
"_isValid",
"(",
"ndate",
",",
"nrandom",
",",
"nchecksum",
",",
"id",
")",
")",
"throw",
"new",
"Error",
"(",
"'iden... | Get date from id
@private
@param {integer} ndate Size of date bits
@param {integer} nrandom Size of random bits
@param {integer} nchecksum Size of checksum bits
@param {Date} epoc Epoc to use
@param {string} id BaseURL encoded Id to test
@return {Date} The date of id creation | [
"Get",
"date",
"from",
"id"
] | 6e357b018952f73e8570b89eda95393780328fab | https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/identity.js#L136-L144 | train |
OctaveWealth/passy | lib/identity.js | createIdentity | function createIdentity (ndate, nrandom, nchecksum, epoc) {
var def = function identity () {
return _identity(ndate, nrandom, nchecksum, epoc);
};
def.EPOC = epoc;
def.dateLength = ndate;
def.randomLength = nrandom;
def.checksumLength = nchecksum;
def.size = ndate + nrandom + nchecksum;
def.isVali... | javascript | function createIdentity (ndate, nrandom, nchecksum, epoc) {
var def = function identity () {
return _identity(ndate, nrandom, nchecksum, epoc);
};
def.EPOC = epoc;
def.dateLength = ndate;
def.randomLength = nrandom;
def.checksumLength = nchecksum;
def.size = ndate + nrandom + nchecksum;
def.isVali... | [
"function",
"createIdentity",
"(",
"ndate",
",",
"nrandom",
",",
"nchecksum",
",",
"epoc",
")",
"{",
"var",
"def",
"=",
"function",
"identity",
"(",
")",
"{",
"return",
"_identity",
"(",
"ndate",
",",
"nrandom",
",",
"nchecksum",
",",
"epoc",
")",
";",
... | Build a identity function by currying
@private
@param {integer} ndate Size of date bits
@param {integer} nrandom Size of random bits
@param {integer} nchecksum Size of checksum bits
@param {Date} epoc Epoc to use
@return {Function} A identity function | [
"Build",
"a",
"identity",
"function",
"by",
"currying"
] | 6e357b018952f73e8570b89eda95393780328fab | https://github.com/OctaveWealth/passy/blob/6e357b018952f73e8570b89eda95393780328fab/lib/identity.js#L155-L174 | train |
nodesource/gather-dependencies | gather-dependencies.js | rpt_cb | function rpt_cb (err, data) {
if (err) return logger.error(err)
if (data.error) return logger.error(data.error)
if (!data.package) {
logger.warn('`data.package` not defined. Initializing placeholder.')
data.package = {}
}
var dependencyReport = {}
if (!data.package || !data.package... | javascript | function rpt_cb (err, data) {
if (err) return logger.error(err)
if (data.error) return logger.error(data.error)
if (!data.package) {
logger.warn('`data.package` not defined. Initializing placeholder.')
data.package = {}
}
var dependencyReport = {}
if (!data.package || !data.package... | [
"function",
"rpt_cb",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"return",
"logger",
".",
"error",
"(",
"err",
")",
"if",
"(",
"data",
".",
"error",
")",
"return",
"logger",
".",
"error",
"(",
"data",
".",
"error",
")",
"if",
"(",
... | read-package-tree callback
@param {error} err read-package-tree error
@param {object} data read-package-tree blob (contains cyclical refrences) | [
"read",
"-",
"package",
"-",
"tree",
"callback"
] | 383e3b867423293501688e26ef462121cc9452d5 | https://github.com/nodesource/gather-dependencies/blob/383e3b867423293501688e26ef462121cc9452d5/gather-dependencies.js#L64-L91 | train |
nodesource/gather-dependencies | gather-dependencies.js | buildDependencyReport | function buildDependencyReport (report, data, options, depth) {
if (!report) report = {}
if (!data) data = {}
if (!options) options = {}
if (!depth) depth = 0
var lookup = {}
var npmDependencyTypes = depth ? depthNpmDependencyTypes : topLevelNpmDependencyTypes
// build list of all dependencies
npmDepe... | javascript | function buildDependencyReport (report, data, options, depth) {
if (!report) report = {}
if (!data) data = {}
if (!options) options = {}
if (!depth) depth = 0
var lookup = {}
var npmDependencyTypes = depth ? depthNpmDependencyTypes : topLevelNpmDependencyTypes
// build list of all dependencies
npmDepe... | [
"function",
"buildDependencyReport",
"(",
"report",
",",
"data",
",",
"options",
",",
"depth",
")",
"{",
"if",
"(",
"!",
"report",
")",
"report",
"=",
"{",
"}",
"if",
"(",
"!",
"data",
")",
"data",
"=",
"{",
"}",
"if",
"(",
"!",
"options",
")",
"... | Build dependency report
@param {object} report report object being operated on
@param {object} data npm dependency tree data
@param {object} options
@param {number} depth Depth to evaluate. 0 is top level only.
@return {object} Completed report object. | [
"Build",
"dependency",
"report"
] | 383e3b867423293501688e26ef462121cc9452d5 | https://github.com/nodesource/gather-dependencies/blob/383e3b867423293501688e26ef462121cc9452d5/gather-dependencies.js#L116-L151 | train |
timshadel/smd | index.js | SmD | function SmD(ms_per_unit, range) {
this.ms_per_unit = ms_per_unit;
this.range = range;
this.range_in_ms = ms_per_unit * range;
} | javascript | function SmD(ms_per_unit, range) {
this.ms_per_unit = ms_per_unit;
this.range = range;
this.range_in_ms = ms_per_unit * range;
} | [
"function",
"SmD",
"(",
"ms_per_unit",
",",
"range",
")",
"{",
"this",
".",
"ms_per_unit",
"=",
"ms_per_unit",
";",
"this",
".",
"range",
"=",
"range",
";",
"this",
".",
"range_in_ms",
"=",
"ms_per_unit",
"*",
"range",
";",
"}"
] | Create a smd
@param {String} name
@return {Type}
@api public | [
"Create",
"a",
"smd"
] | 86de2ffbe1b0e760b3a53a959233bddb8cd4e2c6 | https://github.com/timshadel/smd/blob/86de2ffbe1b0e760b3a53a959233bddb8cd4e2c6/index.js#L47-L51 | train |
jhermsmeier/node-json-web-algorithms | lib/signature.js | function( digest ) {
var signature = ECDSASignature.decode( digest, 'der' )
var length = ( this.bits / 8 | 0 ) + ( this.bits % 8 !== 0 ? 1 : 0 )
var r = Buffer.from( signature.r.toString( 'hex', length ), 'hex' )
var s = Buffer.from( signature.s.toString( 'hex', length ), 'hex' )
return Buffer.co... | javascript | function( digest ) {
var signature = ECDSASignature.decode( digest, 'der' )
var length = ( this.bits / 8 | 0 ) + ( this.bits % 8 !== 0 ? 1 : 0 )
var r = Buffer.from( signature.r.toString( 'hex', length ), 'hex' )
var s = Buffer.from( signature.s.toString( 'hex', length ), 'hex' )
return Buffer.co... | [
"function",
"(",
"digest",
")",
"{",
"var",
"signature",
"=",
"ECDSASignature",
".",
"decode",
"(",
"digest",
",",
"'der'",
")",
"var",
"length",
"=",
"(",
"this",
".",
"bits",
"/",
"8",
"|",
"0",
")",
"+",
"(",
"this",
".",
"bits",
"%",
"8",
"!=... | Create a ECDSA signature for a given digest
@internal used by `.sign()`
@param {Buffer} digest
@return {Buffer} | [
"Create",
"a",
"ECDSA",
"signature",
"for",
"a",
"given",
"digest"
] | 3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6 | https://github.com/jhermsmeier/node-json-web-algorithms/blob/3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6/lib/signature.js#L70-L80 | train | |
jhermsmeier/node-json-web-algorithms | lib/signature.js | function( input, key ) {
if( !Buffer.isBuffer( input ) )
throw new TypeError( 'Input must be a buffer' )
if( this.type === 'PLAIN' )
return Buffer.allocUnsafe(0)
if( !Buffer.isBuffer( key ) )
throw new TypeError( 'Key must be a buffer' )
var signature = this.type === 'HS' ?
c... | javascript | function( input, key ) {
if( !Buffer.isBuffer( input ) )
throw new TypeError( 'Input must be a buffer' )
if( this.type === 'PLAIN' )
return Buffer.allocUnsafe(0)
if( !Buffer.isBuffer( key ) )
throw new TypeError( 'Key must be a buffer' )
var signature = this.type === 'HS' ?
c... | [
"function",
"(",
"input",
",",
"key",
")",
"{",
"if",
"(",
"!",
"Buffer",
".",
"isBuffer",
"(",
"input",
")",
")",
"throw",
"new",
"TypeError",
"(",
"'Input must be a buffer'",
")",
"if",
"(",
"this",
".",
"type",
"===",
"'PLAIN'",
")",
"return",
"Buff... | Sign an input with a given key
@param {Buffer} input
@param {Buffer} key
@return {Buffer} | [
"Sign",
"an",
"input",
"with",
"a",
"given",
"key"
] | 3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6 | https://github.com/jhermsmeier/node-json-web-algorithms/blob/3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6/lib/signature.js#L88-L114 | train | |
jhermsmeier/node-json-web-algorithms | lib/signature.js | function( signature, input, key ) {
var check = this.sign( input, key )
return signature.toString( 'hex' ) ===
check.toString( 'hex' )
} | javascript | function( signature, input, key ) {
var check = this.sign( input, key )
return signature.toString( 'hex' ) ===
check.toString( 'hex' )
} | [
"function",
"(",
"signature",
",",
"input",
",",
"key",
")",
"{",
"var",
"check",
"=",
"this",
".",
"sign",
"(",
"input",
",",
"key",
")",
"return",
"signature",
".",
"toString",
"(",
"'hex'",
")",
"===",
"check",
".",
"toString",
"(",
"'hex'",
")",
... | Verify an HMAC signature
@internal used by `.verify()`
@param {Buffer} signature
@param {Buffer} input
@param {Buffer} key
@return {Boolean} | [
"Verify",
"an",
"HMAC",
"signature"
] | 3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6 | https://github.com/jhermsmeier/node-json-web-algorithms/blob/3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6/lib/signature.js#L124-L131 | train | |
jhermsmeier/node-json-web-algorithms | lib/signature.js | function( signature, input, key ) {
var verifier = crypto.createVerify( this.algorithm + this.bits )
return verifier.update( input )
.verify( key, signature )
} | javascript | function( signature, input, key ) {
var verifier = crypto.createVerify( this.algorithm + this.bits )
return verifier.update( input )
.verify( key, signature )
} | [
"function",
"(",
"signature",
",",
"input",
",",
"key",
")",
"{",
"var",
"verifier",
"=",
"crypto",
".",
"createVerify",
"(",
"this",
".",
"algorithm",
"+",
"this",
".",
"bits",
")",
"return",
"verifier",
".",
"update",
"(",
"input",
")",
".",
"verify"... | Verify an RSA signature
@internal used by `.verify()`
@param {Buffer} signature
@param {Buffer} input
@param {Buffer} key
@return {Boolean} | [
"Verify",
"an",
"RSA",
"signature"
] | 3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6 | https://github.com/jhermsmeier/node-json-web-algorithms/blob/3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6/lib/signature.js#L141-L148 | train | |
jhermsmeier/node-json-web-algorithms | lib/signature.js | function( signature, input, key ) {
var length = ( this.bits / 8 | 0 ) + ( this.bits % 8 !== 0 ? 1 : 0 )
if( signature.length !== length * 2 )
return false
var sig = ECDSASignature.encode({
r: new BigNum( signature.slice( 0, length ), 10, 'be' ).iabs(),
s: new BigNum( signature.slice( le... | javascript | function( signature, input, key ) {
var length = ( this.bits / 8 | 0 ) + ( this.bits % 8 !== 0 ? 1 : 0 )
if( signature.length !== length * 2 )
return false
var sig = ECDSASignature.encode({
r: new BigNum( signature.slice( 0, length ), 10, 'be' ).iabs(),
s: new BigNum( signature.slice( le... | [
"function",
"(",
"signature",
",",
"input",
",",
"key",
")",
"{",
"var",
"length",
"=",
"(",
"this",
".",
"bits",
"/",
"8",
"|",
"0",
")",
"+",
"(",
"this",
".",
"bits",
"%",
"8",
"!==",
"0",
"?",
"1",
":",
"0",
")",
"if",
"(",
"signature",
... | Verify an ECDSA signature
@internal used by `.verify()`
@param {Buffer} signature
@param {Buffer} input
@param {Buffer} key
@return {Boolean} | [
"Verify",
"an",
"ECDSA",
"signature"
] | 3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6 | https://github.com/jhermsmeier/node-json-web-algorithms/blob/3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6/lib/signature.js#L158-L173 | train | |
jhermsmeier/node-json-web-algorithms | lib/signature.js | function( signature, input, key ) {
if( !Buffer.isBuffer( input ) )
throw new TypeError( 'Input must be a buffer' )
if( !Buffer.isBuffer( signature ) )
throw new TypeError( 'Signature must be a buffer' )
if( this.type === 'PLAIN' )
return signature.length === 0
if( !Buffer.isBuffer... | javascript | function( signature, input, key ) {
if( !Buffer.isBuffer( input ) )
throw new TypeError( 'Input must be a buffer' )
if( !Buffer.isBuffer( signature ) )
throw new TypeError( 'Signature must be a buffer' )
if( this.type === 'PLAIN' )
return signature.length === 0
if( !Buffer.isBuffer... | [
"function",
"(",
"signature",
",",
"input",
",",
"key",
")",
"{",
"if",
"(",
"!",
"Buffer",
".",
"isBuffer",
"(",
"input",
")",
")",
"throw",
"new",
"TypeError",
"(",
"'Input must be a buffer'",
")",
"if",
"(",
"!",
"Buffer",
".",
"isBuffer",
"(",
"sig... | Verify a signature against an input & key
@param {Buffer} signature
@param {Buffer} input
@param {Buffer} key
@return {Boolean} | [
"Verify",
"a",
"signature",
"against",
"an",
"input",
"&",
"key"
] | 3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6 | https://github.com/jhermsmeier/node-json-web-algorithms/blob/3a98e12c9c33ea7bcd39f9a6bbcff0ec3f1265c6/lib/signature.js#L182-L204 | train | |
pinyin/outline | vendor/transformation-matrix/isAffineMatrix.js | isAffineMatrix | function isAffineMatrix(object) {
return isObject(object) && object.hasOwnProperty('a') && isNumeric(object.a) && object.hasOwnProperty('b') && isNumeric(object.b) && object.hasOwnProperty('c') && isNumeric(object.c) && object.hasOwnProperty('d') && isNumeric(object.d) && object.hasOwnProperty('e') && isNumeric(obj... | javascript | function isAffineMatrix(object) {
return isObject(object) && object.hasOwnProperty('a') && isNumeric(object.a) && object.hasOwnProperty('b') && isNumeric(object.b) && object.hasOwnProperty('c') && isNumeric(object.c) && object.hasOwnProperty('d') && isNumeric(object.d) && object.hasOwnProperty('e') && isNumeric(obj... | [
"function",
"isAffineMatrix",
"(",
"object",
")",
"{",
"return",
"isObject",
"(",
"object",
")",
"&&",
"object",
".",
"hasOwnProperty",
"(",
"'a'",
")",
"&&",
"isNumeric",
"(",
"object",
".",
"a",
")",
"&&",
"object",
".",
"hasOwnProperty",
"(",
"'b'",
"... | Check if the object contain an affine matrix
@param object
@return {boolean} | [
"Check",
"if",
"the",
"object",
"contain",
"an",
"affine",
"matrix"
] | e49f05d2f8ab384f5b1d71b2b10875cd48d41051 | https://github.com/pinyin/outline/blob/e49f05d2f8ab384f5b1d71b2b10875cd48d41051/vendor/transformation-matrix/isAffineMatrix.js#L26-L28 | train |
jgable/broccoli-es6-import-validate | lib/BroccoliES6ModuleFile.js | function (filePath) {
var name = ES6ModuleFile.prototype.getModuleName.apply(this, arguments);
if (_.isFunction(this.opts.moduleName)) {
name = this.opts.moduleName(name, filePath);
}
return name;
} | javascript | function (filePath) {
var name = ES6ModuleFile.prototype.getModuleName.apply(this, arguments);
if (_.isFunction(this.opts.moduleName)) {
name = this.opts.moduleName(name, filePath);
}
return name;
} | [
"function",
"(",
"filePath",
")",
"{",
"var",
"name",
"=",
"ES6ModuleFile",
".",
"prototype",
".",
"getModuleName",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"this",
".",
"opts",
".",
"moduleName",
"... | Broken out to let the moduleName options override | [
"Broken",
"out",
"to",
"let",
"the",
"moduleName",
"options",
"override"
] | ffbc9e66698f0a8399d63d7123a03c30808bf902 | https://github.com/jgable/broccoli-es6-import-validate/blob/ffbc9e66698f0a8399d63d7123a03c30808bf902/lib/BroccoliES6ModuleFile.js#L14-L22 | train | |
travism/solid-logger-js | lib/adapters/loggly.js | init | function init(config){
var logger = new LogglyLogger(config);
logger.validateConfig();
logger.config = config;
logger.client = loggly.createClient({
token: config.token,
subdomain: config.application,
auth: config.auth,
// TOOD: pushing more tags onto this array, or not... | javascript | function init(config){
var logger = new LogglyLogger(config);
logger.validateConfig();
logger.config = config;
logger.client = loggly.createClient({
token: config.token,
subdomain: config.application,
auth: config.auth,
// TOOD: pushing more tags onto this array, or not... | [
"function",
"init",
"(",
"config",
")",
"{",
"var",
"logger",
"=",
"new",
"LogglyLogger",
"(",
"config",
")",
";",
"logger",
".",
"validateConfig",
"(",
")",
";",
"logger",
".",
"config",
"=",
"config",
";",
"logger",
".",
"client",
"=",
"loggly",
".",... | The init function should be called at the beginning of the object life cycle. This method will be responsible
for doing all of the setup for the adapter.
@param config Object that will contain the path to write the log file and the type of adapter. | [
"The",
"init",
"function",
"should",
"be",
"called",
"at",
"the",
"beginning",
"of",
"the",
"object",
"life",
"cycle",
".",
"This",
"method",
"will",
"be",
"responsible",
"for",
"doing",
"all",
"of",
"the",
"setup",
"for",
"the",
"adapter",
"."
] | e5287dcfc680fcfa3eb449dd29bc8c92106184a9 | https://github.com/travism/solid-logger-js/blob/e5287dcfc680fcfa3eb449dd29bc8c92106184a9/lib/adapters/loggly.js#L33-L54 | train |
travism/solid-logger-js | lib/adapters/loggly.js | writeLog | function writeLog(type, category){
return function(messages) {
var funcs = [];
_.each(messages, function(message){
funcs.push(this.client.logAsync(message, [type, category]));
}.bind(this));
return BB.all(funcs);
};
} | javascript | function writeLog(type, category){
return function(messages) {
var funcs = [];
_.each(messages, function(message){
funcs.push(this.client.logAsync(message, [type, category]));
}.bind(this));
return BB.all(funcs);
};
} | [
"function",
"writeLog",
"(",
"type",
",",
"category",
")",
"{",
"return",
"function",
"(",
"messages",
")",
"{",
"var",
"funcs",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"messages",
",",
"function",
"(",
"message",
")",
"{",
"funcs",
".",
"push",
... | Internal method to append our log entry to loggly.
@param type Type of entry (debug, info, error, warn, trace)
@param category User defined label for the entry
@returns {function} | [
"Internal",
"method",
"to",
"append",
"our",
"log",
"entry",
"to",
"loggly",
"."
] | e5287dcfc680fcfa3eb449dd29bc8c92106184a9 | https://github.com/travism/solid-logger-js/blob/e5287dcfc680fcfa3eb449dd29bc8c92106184a9/lib/adapters/loggly.js#L86-L97 | train |
trevorparscal/node-palo | lib/resources/FileResource.js | FileResource | function FileResource( pkg, config ) {
var key,
resource = this,
dir = pkg.getDirectory(),
cfg = { files: [] };
// Normalize configuration
if ( typeof config === 'string' ) {
cfg.files.push( config );
} else if ( Array.isArray( config ) ) {
cfg.files = cfg.files.concat( config );
} else {
for ( key in... | javascript | function FileResource( pkg, config ) {
var key,
resource = this,
dir = pkg.getDirectory(),
cfg = { files: [] };
// Normalize configuration
if ( typeof config === 'string' ) {
cfg.files.push( config );
} else if ( Array.isArray( config ) ) {
cfg.files = cfg.files.concat( config );
} else {
for ( key in... | [
"function",
"FileResource",
"(",
"pkg",
",",
"config",
")",
"{",
"var",
"key",
",",
"resource",
"=",
"this",
",",
"dir",
"=",
"pkg",
".",
"getDirectory",
"(",
")",
",",
"cfg",
"=",
"{",
"files",
":",
"[",
"]",
"}",
";",
"// Normalize configuration",
... | File resource.
Resources can be configured with either a string, an array of strings, or an object with a `file`
or `files` properties, each a string or array of strings. The normalized configuration will
never have a `file` property and always have a `files` property which is an array of file paths.
If the configurat... | [
"File",
"resource",
"."
] | 425efdcf027c71296c732765afdf5cacae6a1a3e | https://github.com/trevorparscal/node-palo/blob/425efdcf027c71296c732765afdf5cacae6a1a3e/lib/resources/FileResource.js#L25-L66 | 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.