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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bigpipe/bootstrap-pagelet | index.js | flush | function flush(done) {
this.once('done', done);
if (this._res.finished) {
this.emit('done', new Error('Response was closed, unable to flush content'));
}
if (!this._queue.length) this.emit('done');
var data = new Buffer(this.join(), this.charset);
if (data.length) {
this.debug('Wr... | javascript | function flush(done) {
this.once('done', done);
if (this._res.finished) {
this.emit('done', new Error('Response was closed, unable to flush content'));
}
if (!this._queue.length) this.emit('done');
var data = new Buffer(this.join(), this.charset);
if (data.length) {
this.debug('Wr... | [
"function",
"flush",
"(",
"done",
")",
"{",
"this",
".",
"once",
"(",
"'done'",
",",
"done",
")",
";",
"if",
"(",
"this",
".",
"_res",
".",
"finished",
")",
"{",
"this",
".",
"emit",
"(",
"'done'",
",",
"new",
"Error",
"(",
"'Response was closed, una... | Flush all queued rendered pagelets to the request object.
@returns {Pagelet} this
@api private | [
"Flush",
"all",
"queued",
"rendered",
"pagelets",
"to",
"the",
"request",
"object",
"."
] | cf03e008aca36e413edd067ff8d83e2f1f59ed9f | https://github.com/bigpipe/bootstrap-pagelet/blob/cf03e008aca36e413edd067ff8d83e2f1f59ed9f/index.js#L216-L237 | train |
bigpipe/bootstrap-pagelet | index.js | constructor | function constructor(options) {
Pagelet.prototype.constructor.call(this, options = options || {});
//
// Store the provided global dependencies.
//
this.dependencies = this._bigpipe._compiler.page(this).concat(
options.dependencies
);
var req = options.req || {}
, uri = req.uri... | javascript | function constructor(options) {
Pagelet.prototype.constructor.call(this, options = options || {});
//
// Store the provided global dependencies.
//
this.dependencies = this._bigpipe._compiler.page(this).concat(
options.dependencies
);
var req = options.req || {}
, uri = req.uri... | [
"function",
"constructor",
"(",
"options",
")",
"{",
"Pagelet",
".",
"prototype",
".",
"constructor",
".",
"call",
"(",
"this",
",",
"options",
"=",
"options",
"||",
"{",
"}",
")",
";",
"//",
"// Store the provided global dependencies.",
"//",
"this",
".",
"... | Extend the default constructor of the pagelet to set additional defaults
based on the provided options.
@param {Object} options Optional options.
@api public | [
"Extend",
"the",
"default",
"constructor",
"of",
"the",
"pagelet",
"to",
"set",
"additional",
"defaults",
"based",
"on",
"the",
"provided",
"options",
"."
] | cf03e008aca36e413edd067ff8d83e2f1f59ed9f | https://github.com/bigpipe/bootstrap-pagelet/blob/cf03e008aca36e413edd067ff8d83e2f1f59ed9f/index.js#L315-L354 | train |
vkiding/jud-vue-render | src/render/browser/bridge/sender.js | function (callbackId, data, keepAlive) {
const args = [callbackId]
data && args.push(data)
keepAlive && args.push(keepAlive)
_send(this.instanceId, {
method: 'callback',
args: args
})
} | javascript | function (callbackId, data, keepAlive) {
const args = [callbackId]
data && args.push(data)
keepAlive && args.push(keepAlive)
_send(this.instanceId, {
method: 'callback',
args: args
})
} | [
"function",
"(",
"callbackId",
",",
"data",
",",
"keepAlive",
")",
"{",
"const",
"args",
"=",
"[",
"callbackId",
"]",
"data",
"&&",
"args",
".",
"push",
"(",
"data",
")",
"keepAlive",
"&&",
"args",
".",
"push",
"(",
"keepAlive",
")",
"_send",
"(",
"t... | perform a callback to jsframework. | [
"perform",
"a",
"callback",
"to",
"jsframework",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/bridge/sender.js#L27-L35 | train | |
benderjs/benderjs-jasmine | lib/adapter.js | BenderReporter | function BenderReporter() {
var timer = new jasmine.Timer(),
current = new Suite(),
passed = 0,
failed = 0,
errors = 0,
ignored = 0,
total = 0;
function buildError( result ) {
var pattern = /\n.*jasmine.js.*/gi,
error = [],
exp,
i;
for ( i = 0; i < result.failedExpectations.len... | javascript | function BenderReporter() {
var timer = new jasmine.Timer(),
current = new Suite(),
passed = 0,
failed = 0,
errors = 0,
ignored = 0,
total = 0;
function buildError( result ) {
var pattern = /\n.*jasmine.js.*/gi,
error = [],
exp,
i;
for ( i = 0; i < result.failedExpectations.len... | [
"function",
"BenderReporter",
"(",
")",
"{",
"var",
"timer",
"=",
"new",
"jasmine",
".",
"Timer",
"(",
")",
",",
"current",
"=",
"new",
"Suite",
"(",
")",
",",
"passed",
"=",
"0",
",",
"failed",
"=",
"0",
",",
"errors",
"=",
"0",
",",
"ignored",
... | custom reporter that will pass the results to bender | [
"custom",
"reporter",
"that",
"will",
"pass",
"the",
"results",
"to",
"bender"
] | d02ffb927e1e3be3f7ec57c7cd37546fcbb6d162 | https://github.com/benderjs/benderjs-jasmine/blob/d02ffb927e1e3be3f7ec57c7cd37546fcbb6d162/lib/adapter.js#L66-L162 | train |
intesso/hidden-server | lib/hidden.js | HiddenServer | function HiddenServer(opts) {
if (!(this instanceof HiddenServer)) return new HiddenServer(opts);
this.set(require('../settings.json'));
this.set(opts);
this.uri = this.get('publicServer') + this.get('pingUri').replace(':hiddenServerName', this.get('hiddenServerName'));
debug('uri', this.uri);
this.init();... | javascript | function HiddenServer(opts) {
if (!(this instanceof HiddenServer)) return new HiddenServer(opts);
this.set(require('../settings.json'));
this.set(opts);
this.uri = this.get('publicServer') + this.get('pingUri').replace(':hiddenServerName', this.get('hiddenServerName'));
debug('uri', this.uri);
this.init();... | [
"function",
"HiddenServer",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"HiddenServer",
")",
")",
"return",
"new",
"HiddenServer",
"(",
"opts",
")",
";",
"this",
".",
"set",
"(",
"require",
"(",
"'../settings.json'",
")",
")",
";",
... | `HiddenServer` Constructor function. | [
"HiddenServer",
"Constructor",
"function",
"."
] | 827336a77f43555b14bc204aa542e91e7296e0cf | https://github.com/intesso/hidden-server/blob/827336a77f43555b14bc204aa542e91e7296e0cf/lib/hidden.js#L16-L24 | train |
NicolaOrritos/progenic | lib/utils.js | function(options)
{
return new Promise( (resolve, reject) =>
{
if (options)
{
options.logger.info('[PROGENIC] Starting "%s" daemon with %s workers...', options.name, options.workers);
options.logger.info('[PROGENIC] [from "%s"]', options.main);... | javascript | function(options)
{
return new Promise( (resolve, reject) =>
{
if (options)
{
options.logger.info('[PROGENIC] Starting "%s" daemon with %s workers...', options.name, options.workers);
options.logger.info('[PROGENIC] [from "%s"]', options.main);... | [
"function",
"(",
"options",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"options",
")",
"{",
"options",
".",
"logger",
".",
"info",
"(",
"'[PROGENIC] Starting \"%s\" daemon with %s workers...'",
",",
"... | Creates the children workers when running as cluster master.
Runs the HTTP server otherwise.
@param {Number} count Number of workers to create. | [
"Creates",
"the",
"children",
"workers",
"when",
"running",
"as",
"cluster",
"master",
".",
"Runs",
"the",
"HTTP",
"server",
"otherwise",
"."
] | eee85a2d9375a2930216ccbb7f03d254fb35a2e7 | https://github.com/NicolaOrritos/progenic/blob/eee85a2d9375a2930216ccbb7f03d254fb35a2e7/lib/utils.js#L404-L443 | train | |
NicolaOrritos/progenic | lib/utils.js | function(signal)
{
return new Promise( resolve =>
{
for (let uniqueID in cluster.workers)
{
if (cluster.workers.hasOwnProperty(uniqueID))
{
const worker = cluster.workers[uniqueID];
worker.kill(signal);
... | javascript | function(signal)
{
return new Promise( resolve =>
{
for (let uniqueID in cluster.workers)
{
if (cluster.workers.hasOwnProperty(uniqueID))
{
const worker = cluster.workers[uniqueID];
worker.kill(signal);
... | [
"function",
"(",
"signal",
")",
"{",
"return",
"new",
"Promise",
"(",
"resolve",
"=>",
"{",
"for",
"(",
"let",
"uniqueID",
"in",
"cluster",
".",
"workers",
")",
"{",
"if",
"(",
"cluster",
".",
"workers",
".",
"hasOwnProperty",
"(",
"uniqueID",
")",
")"... | Kills all workers with the given signal.
@param {Number} signal | [
"Kills",
"all",
"workers",
"with",
"the",
"given",
"signal",
"."
] | eee85a2d9375a2930216ccbb7f03d254fb35a2e7 | https://github.com/NicolaOrritos/progenic/blob/eee85a2d9375a2930216ccbb7f03d254fb35a2e7/lib/utils.js#L449-L465 | train | |
aureooms/js-grammar | lib/ast/map.js | map | function map(callable, children) {
var iterator = (0, _cmap.default)(callable, children)[Symbol.asyncIterator]();
return new _Children.default(iterator, undefined);
} | javascript | function map(callable, children) {
var iterator = (0, _cmap.default)(callable, children)[Symbol.asyncIterator]();
return new _Children.default(iterator, undefined);
} | [
"function",
"map",
"(",
"callable",
",",
"children",
")",
"{",
"var",
"iterator",
"=",
"(",
"0",
",",
"_cmap",
".",
"default",
")",
"(",
"callable",
",",
"children",
")",
"[",
"Symbol",
".",
"asyncIterator",
"]",
"(",
")",
";",
"return",
"new",
"_Chi... | Applies a given callable to each of the child of a given children async iterable.
@param {Function} callable - The callable to use.
@param {AsyncIterable} children - The input children.
@returns {AsyncIterator} | [
"Applies",
"a",
"given",
"callable",
"to",
"each",
"of",
"the",
"child",
"of",
"a",
"given",
"children",
"async",
"iterable",
"."
] | 28c4d1a3175327b33766c34539eab317303e26c5 | https://github.com/aureooms/js-grammar/blob/28c4d1a3175327b33766c34539eab317303e26c5/lib/ast/map.js#L21-L24 | train |
gethuman/pancakes-recipe | batch/reactor.cleanup/reactor.cleanup.batch.js | cleanupPrep | function cleanupPrep(options) {
var sourceResource = options.source;
var targetResource = options.target;
var targetReactor = options.reactor;
var reactor;
// if there is a target reactor, just use that cleanupPrep
if (targetReactor) {
reactor = reactors[targ... | javascript | function cleanupPrep(options) {
var sourceResource = options.source;
var targetResource = options.target;
var targetReactor = options.reactor;
var reactor;
// if there is a target reactor, just use that cleanupPrep
if (targetReactor) {
reactor = reactors[targ... | [
"function",
"cleanupPrep",
"(",
"options",
")",
"{",
"var",
"sourceResource",
"=",
"options",
".",
"source",
";",
"var",
"targetResource",
"=",
"options",
".",
"target",
";",
"var",
"targetReactor",
"=",
"options",
".",
"reactor",
";",
"var",
"reactor",
";",... | Loop through reactors and clean them up
@param options
@returns {*} | [
"Loop",
"through",
"reactors",
"and",
"clean",
"them",
"up"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/reactor.cleanup/reactor.cleanup.batch.js#L54-L78 | train |
gethuman/pancakes-recipe | batch/reactor.cleanup/reactor.cleanup.batch.js | getCleanupData | function getCleanupData(options) {
var sourceResource = options.source;
var targetResource = options.target === 'all' ? null : options.target;
var targetReactor = options.reactor;
var targetField = options.field;
var cleanupData = [];
// if source resource an option, we ... | javascript | function getCleanupData(options) {
var sourceResource = options.source;
var targetResource = options.target === 'all' ? null : options.target;
var targetReactor = options.reactor;
var targetField = options.field;
var cleanupData = [];
// if source resource an option, we ... | [
"function",
"getCleanupData",
"(",
"options",
")",
"{",
"var",
"sourceResource",
"=",
"options",
".",
"source",
";",
"var",
"targetResource",
"=",
"options",
".",
"target",
"===",
"'all'",
"?",
"null",
":",
"options",
".",
"target",
";",
"var",
"targetReacto... | Get the cleanup data based on the batch options
@param options | [
"Get",
"the",
"cleanup",
"data",
"based",
"on",
"the",
"batch",
"options"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/reactor.cleanup/reactor.cleanup.batch.js#L84-L112 | train |
alexpods/ClazzJS | src/components/meta/Property/Default.js | function(object, defaultValue, property) {
if (!_.isUndefined(defaultValue)) {
object.__setPropertyParam(property, 'default', defaultValue);
}
} | javascript | function(object, defaultValue, property) {
if (!_.isUndefined(defaultValue)) {
object.__setPropertyParam(property, 'default', defaultValue);
}
} | [
"function",
"(",
"object",
",",
"defaultValue",
",",
"property",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isUndefined",
"(",
"defaultValue",
")",
")",
"{",
"object",
".",
"__setPropertyParam",
"(",
"property",
",",
"'default'",
",",
"defaultValue",
")",
";",
... | Set default value for object property
@param {object} object Some object
@param {*} defaultValue Default value
@param {string} property Property name
@this {metaProcessor} | [
"Set",
"default",
"value",
"for",
"object",
"property"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Default.js#L16-L20 | train | |
JavaScriptDude/ps-sync | lib/main.js | function(psRec,sProcId){
if(!sProcId){throw new Error("No Proc Id found in data");}
var iFind,sArgs
iFind=psRec.CommandLine.indexOf(psRec.Name);
sArgs = psRec.CommandLine.substring(iFind+psRec.Name.length+1);
psRecs[sProcId]={
pid: psRec.Proces... | javascript | function(psRec,sProcId){
if(!sProcId){throw new Error("No Proc Id found in data");}
var iFind,sArgs
iFind=psRec.CommandLine.indexOf(psRec.Name);
sArgs = psRec.CommandLine.substring(iFind+psRec.Name.length+1);
psRecs[sProcId]={
pid: psRec.Proces... | [
"function",
"(",
"psRec",
",",
"sProcId",
")",
"{",
"if",
"(",
"!",
"sProcId",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"No Proc Id found in data\"",
")",
";",
"}",
"var",
"iFind",
",",
"sArgs",
"iFind",
"=",
"psRec",
".",
"CommandLine",
".",
"indexOf",... | Now parse the WMIC return | [
"Now",
"parse",
"the",
"WMIC",
"return"
] | 0e909e50d1555bdaa567cccd27ced6b69aec7c4c | https://github.com/JavaScriptDude/ps-sync/blob/0e909e50d1555bdaa567cccd27ced6b69aec7c4c/lib/main.js#L50-L62 | train | |
inviqa/deck-task-registry | src/other/watch.js | watch | function watch(conf, undertaker) {
const root = conf.themeConfig.root;
/**
* STYLE WATCHING.
*/
undertaker.watch(
path.join(root, conf.themeConfig.sass.src, '**', '*.scss'),
undertaker.series(
require('../styles/lintStyles').bind(null, conf, undertaker),
require('../styles/buildStyles'... | javascript | function watch(conf, undertaker) {
const root = conf.themeConfig.root;
/**
* STYLE WATCHING.
*/
undertaker.watch(
path.join(root, conf.themeConfig.sass.src, '**', '*.scss'),
undertaker.series(
require('../styles/lintStyles').bind(null, conf, undertaker),
require('../styles/buildStyles'... | [
"function",
"watch",
"(",
"conf",
",",
"undertaker",
")",
"{",
"const",
"root",
"=",
"conf",
".",
"themeConfig",
".",
"root",
";",
"/**\n * STYLE WATCHING.\n */",
"undertaker",
".",
"watch",
"(",
"path",
".",
"join",
"(",
"root",
",",
"conf",
".",
"the... | Watch project files.
@param {ConfigParser} conf A configuration parser object.
@param {Undertaker} undertaker An Undertaker instance. | [
"Watch",
"project",
"files",
"."
] | 4c31787b978e9d99a47052e090d4589a50cd3015 | https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/other/watch.js#L11-L58 | train |
fullstackers/bus.io-common | lib/builder.js | Builder | function Builder (data) {
if (!(this instanceof Builder)) return new Builder(data);
debug('new builder', data);
events.EventEmitter.call(this);
this.message = Message(data);
} | javascript | function Builder (data) {
if (!(this instanceof Builder)) return new Builder(data);
debug('new builder', data);
events.EventEmitter.call(this);
this.message = Message(data);
} | [
"function",
"Builder",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Builder",
")",
")",
"return",
"new",
"Builder",
"(",
"data",
")",
";",
"debug",
"(",
"'new builder'",
",",
"data",
")",
";",
"events",
".",
"EventEmitter",
".",
... | Builds a Message instance and provides a way to deliver the built message
@param {object} data | [
"Builds",
"a",
"Message",
"instance",
"and",
"provides",
"a",
"way",
"to",
"deliver",
"the",
"built",
"message"
] | 9e081a15ba40c4233a936d4105465277da8578fd | https://github.com/fullstackers/bus.io-common/blob/9e081a15ba40c4233a936d4105465277da8578fd/lib/builder.js#L16-L26 | train |
TheOrbitals/angle-functions | dist/index.js | rounddeg | function rounddeg(angle) {
var result = 360.0 * (angle / 360.0 - Math.floor(angle / 360.0));
if (result < 0.0) {
result += 360.0;
}
if (result >= 360.0) {
result -= 360.0;
}
return result;
} | javascript | function rounddeg(angle) {
var result = 360.0 * (angle / 360.0 - Math.floor(angle / 360.0));
if (result < 0.0) {
result += 360.0;
}
if (result >= 360.0) {
result -= 360.0;
}
return result;
} | [
"function",
"rounddeg",
"(",
"angle",
")",
"{",
"var",
"result",
"=",
"360.0",
"*",
"(",
"angle",
"/",
"360.0",
"-",
"Math",
".",
"floor",
"(",
"angle",
"/",
"360.0",
")",
")",
";",
"if",
"(",
"result",
"<",
"0.0",
")",
"{",
"result",
"+=",
"360.... | Rounds the degree angle between 0 and 360
@param {number} angle
@return {number} | [
"Rounds",
"the",
"degree",
"angle",
"between",
"0",
"and",
"360"
] | dee45ac051a1c245639718cb8936cccfd94d325f | https://github.com/TheOrbitals/angle-functions/blob/dee45ac051a1c245639718cb8936cccfd94d325f/dist/index.js#L54-L63 | train |
ionut-botizan/external-jsx-loader | index.js | getViewRoot | function getViewRoot(source) {
const tokens = parse(source);
let position = tokens.length;
let tagDepth = 0;
let tagName;
let token;
/**
* Loop backwards through the view's source and find the last closing tag
* and its matching opening tag to determine the view's root node position.
*/
while (token = to... | javascript | function getViewRoot(source) {
const tokens = parse(source);
let position = tokens.length;
let tagDepth = 0;
let tagName;
let token;
/**
* Loop backwards through the view's source and find the last closing tag
* and its matching opening tag to determine the view's root node position.
*/
while (token = to... | [
"function",
"getViewRoot",
"(",
"source",
")",
"{",
"const",
"tokens",
"=",
"parse",
"(",
"source",
")",
";",
"let",
"position",
"=",
"tokens",
".",
"length",
";",
"let",
"tagDepth",
"=",
"0",
";",
"let",
"tagName",
";",
"let",
"token",
";",
"/**\n\t *... | Finds the position of the opening JSX tag in the source code. | [
"Finds",
"the",
"position",
"of",
"the",
"opening",
"JSX",
"tag",
"in",
"the",
"source",
"code",
"."
] | 6d9a9044c7a38fa1bb98710b8a381083ab7ece8f | https://github.com/ionut-botizan/external-jsx-loader/blob/6d9a9044c7a38fa1bb98710b8a381083ab7ece8f/index.js#L93-L148 | train |
seelang2/imapper-storage-s3ses | lib/storage.js | function(next) {
S3.getObject({
Bucket: S3Handler.options.S3BucketName,
Key: S3Handler.options.mboxName + S3Handler.options.S3MessageListKeySuffix
},
next
);
} | javascript | function(next) {
S3.getObject({
Bucket: S3Handler.options.S3BucketName,
Key: S3Handler.options.mboxName + S3Handler.options.S3MessageListKeySuffix
},
next
);
} | [
"function",
"(",
"next",
")",
"{",
"S3",
".",
"getObject",
"(",
"{",
"Bucket",
":",
"S3Handler",
".",
"options",
".",
"S3BucketName",
",",
"Key",
":",
"S3Handler",
".",
"options",
".",
"mboxName",
"+",
"S3Handler",
".",
"options",
".",
"S3MessageListKeySuf... | get the messagelist data | [
"get",
"the",
"messagelist",
"data"
] | 1755b12f84744b8d45aff123ac17ead5fbc3f09c | https://github.com/seelang2/imapper-storage-s3ses/blob/1755b12f84744b8d45aff123ac17ead5fbc3f09c/lib/storage.js#L60-L67 | train | |
seelang2/imapper-storage-s3ses | lib/storage.js | function(messagelist, next) {
var keyList = JSON.parse(messagelist.Body);
if (CONSOLE_MESSAGES) console.log(new Date().toISOString(),'Raw messageList object:',keyList);
// update last modified timestamp
// also reset message list count
// not using yet so don't modify a... | javascript | function(messagelist, next) {
var keyList = JSON.parse(messagelist.Body);
if (CONSOLE_MESSAGES) console.log(new Date().toISOString(),'Raw messageList object:',keyList);
// update last modified timestamp
// also reset message list count
// not using yet so don't modify a... | [
"function",
"(",
"messagelist",
",",
"next",
")",
"{",
"var",
"keyList",
"=",
"JSON",
".",
"parse",
"(",
"messagelist",
".",
"Body",
")",
";",
"if",
"(",
"CONSOLE_MESSAGES",
")",
"console",
".",
"log",
"(",
"new",
"Date",
"(",
")",
".",
"toISOString",
... | process messagelist data | [
"process",
"messagelist",
"data"
] | 1755b12f84744b8d45aff123ac17ead5fbc3f09c | https://github.com/seelang2/imapper-storage-s3ses/blob/1755b12f84744b8d45aff123ac17ead5fbc3f09c/lib/storage.js#L69-L95 | train | |
seelang2/imapper-storage-s3ses | lib/storage.js | function(callback) {
var params = {
Bucket: S3Handler.options.S3BucketName,
Key: S3Handler.options.mboxName + S3Handler.options.S3MboxKeySuffix,
Body: JSON.stringify(data)
};
s3.upload(params, function(err, response) {
if (err) {
if (CONSOLE_MESSAGES) console.log(new D... | javascript | function(callback) {
var params = {
Bucket: S3Handler.options.S3BucketName,
Key: S3Handler.options.mboxName + S3Handler.options.S3MboxKeySuffix,
Body: JSON.stringify(data)
};
s3.upload(params, function(err, response) {
if (err) {
if (CONSOLE_MESSAGES) console.log(new D... | [
"function",
"(",
"callback",
")",
"{",
"var",
"params",
"=",
"{",
"Bucket",
":",
"S3Handler",
".",
"options",
".",
"S3BucketName",
",",
"Key",
":",
"S3Handler",
".",
"options",
".",
"mboxName",
"+",
"S3Handler",
".",
"options",
".",
"S3MboxKeySuffix",
",",... | listObjects
Saves the data file to the user mailbox | [
"listObjects",
"Saves",
"the",
"data",
"file",
"to",
"the",
"user",
"mailbox"
] | 1755b12f84744b8d45aff123ac17ead5fbc3f09c | https://github.com/seelang2/imapper-storage-s3ses/blob/1755b12f84744b8d45aff123ac17ead5fbc3f09c/lib/storage.js#L163-L176 | train | |
cconstantine/NoDevent | assets/js/eventemitter.js | Event | function Event(type, listener, scope, once, instance) {
// Store arguments
this.type = type;
this.listener = listener;
this.scope = scope;
this.once = once;
this.instance = instance;
} | javascript | function Event(type, listener, scope, once, instance) {
// Store arguments
this.type = type;
this.listener = listener;
this.scope = scope;
this.once = once;
this.instance = instance;
} | [
"function",
"Event",
"(",
"type",
",",
"listener",
",",
"scope",
",",
"once",
",",
"instance",
")",
"{",
"// Store arguments",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"listener",
"=",
"listener",
";",
"this",
".",
"scope",
"=",
"scope",
";"... | Event class
Contains Event methods and property storage
@param {String} type Event type name
@param {Function} listener Function to be called when the event is fired
@param {Object} scope Object that this should be set to when the listener is called
@param {Boolean} once If true then the listener will be removed after... | [
"Event",
"class",
"Contains",
"Event",
"methods",
"and",
"property",
"storage"
] | d17e5bdad2a6bf7006dc4291b44a705ce5b08c47 | https://github.com/cconstantine/NoDevent/blob/d17e5bdad2a6bf7006dc4291b44a705ce5b08c47/assets/js/eventemitter.js#L36-L43 | train |
iteam-consulting/graphql-form-handler | src/index.js | render | function render(form, template) {
const compiledRowTemplate = handlebars.compile(
'<tr class="form-element">' +
'<td class="key">{{key}}</td>' +
'<td class="value">{{value}}</td>' +
'</tr>');
const compiledTable = handlebars.compile(
'<table><tbody>{{{rows}}}</tbody></table>');
const compi... | javascript | function render(form, template) {
const compiledRowTemplate = handlebars.compile(
'<tr class="form-element">' +
'<td class="key">{{key}}</td>' +
'<td class="value">{{value}}</td>' +
'</tr>');
const compiledTable = handlebars.compile(
'<table><tbody>{{{rows}}}</tbody></table>');
const compi... | [
"function",
"render",
"(",
"form",
",",
"template",
")",
"{",
"const",
"compiledRowTemplate",
"=",
"handlebars",
".",
"compile",
"(",
"'<tr class=\"form-element\">'",
"+",
"'<td class=\"key\">{{key}}</td>'",
"+",
"'<td class=\"value\">{{value}}</td>'",
"+",
"'</tr>'",
")"... | Function that returns the html to be rendered in the email
@param {array} form an array of key value pairs
@param {string} template The template to compile.
@return {string} The rendered template. | [
"Function",
"that",
"returns",
"the",
"html",
"to",
"be",
"rendered",
"in",
"the",
"email"
] | 56e11599b1872ae9d6c95b2d8ea1125f858c06f6 | https://github.com/iteam-consulting/graphql-form-handler/blob/56e11599b1872ae9d6c95b2d8ea1125f858c06f6/src/index.js#L50-L71 | train |
hypergroup/hyper-uri-format | index.js | encode | function encode(cache, API_URL, obj) {
if (!obj) return null;
if (!obj.href) return obj;
var href = API_URL ?
pack(obj.href, API_URL) :
obj.href;
var cached = cache.get(href);
if (cached) return cached;
var encoded = base64.encode(new Buffer(href)).toString();
cache.set(href, encoded);
return... | javascript | function encode(cache, API_URL, obj) {
if (!obj) return null;
if (!obj.href) return obj;
var href = API_URL ?
pack(obj.href, API_URL) :
obj.href;
var cached = cache.get(href);
if (cached) return cached;
var encoded = base64.encode(new Buffer(href)).toString();
cache.set(href, encoded);
return... | [
"function",
"encode",
"(",
"cache",
",",
"API_URL",
",",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"return",
"null",
";",
"if",
"(",
"!",
"obj",
".",
"href",
")",
"return",
"obj",
";",
"var",
"href",
"=",
"API_URL",
"?",
"pack",
"(",
"obj",
... | Encode an href object | [
"Encode",
"an",
"href",
"object"
] | e2d56f205604684bd5805ae6c460fe50f41c0dfe | https://github.com/hypergroup/hyper-uri-format/blob/e2d56f205604684bd5805ae6c460fe50f41c0dfe/index.js#L63-L77 | train |
hypergroup/hyper-uri-format | index.js | encodeParams | function encodeParams(cache, API_URL, params) {
var obj = {}, v;
for (var k in params) {
if (!params.hasOwnProperty(k)) continue;
v = obj[k] = encode(cache, API_URL, params[k]);
if (!v) return;
}
return obj;
} | javascript | function encodeParams(cache, API_URL, params) {
var obj = {}, v;
for (var k in params) {
if (!params.hasOwnProperty(k)) continue;
v = obj[k] = encode(cache, API_URL, params[k]);
if (!v) return;
}
return obj;
} | [
"function",
"encodeParams",
"(",
"cache",
",",
"API_URL",
",",
"params",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
",",
"v",
";",
"for",
"(",
"var",
"k",
"in",
"params",
")",
"{",
"if",
"(",
"!",
"params",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
... | Encode a set of params | [
"Encode",
"a",
"set",
"of",
"params"
] | e2d56f205604684bd5805ae6c460fe50f41c0dfe | https://github.com/hypergroup/hyper-uri-format/blob/e2d56f205604684bd5805ae6c460fe50f41c0dfe/index.js#L83-L91 | train |
hypergroup/hyper-uri-format | index.js | decode | function decode(cache, API_URL, str) {
var cached = cache.get(str);
if (typeof cached !== 'undefined') return cached;
if (typeof str !== 'string') return null;
var decoded = base64.decode(str).toString().replace(/\0/g, '');
var out = validate(decoded) ?
{href: unpack(decoded, API_URL)} :
str;
// ... | javascript | function decode(cache, API_URL, str) {
var cached = cache.get(str);
if (typeof cached !== 'undefined') return cached;
if (typeof str !== 'string') return null;
var decoded = base64.decode(str).toString().replace(/\0/g, '');
var out = validate(decoded) ?
{href: unpack(decoded, API_URL)} :
str;
// ... | [
"function",
"decode",
"(",
"cache",
",",
"API_URL",
",",
"str",
")",
"{",
"var",
"cached",
"=",
"cache",
".",
"get",
"(",
"str",
")",
";",
"if",
"(",
"typeof",
"cached",
"!==",
"'undefined'",
")",
"return",
"cached",
";",
"if",
"(",
"typeof",
"str",
... | Decode an encoded uri component | [
"Decode",
"an",
"encoded",
"uri",
"component"
] | e2d56f205604684bd5805ae6c460fe50f41c0dfe | https://github.com/hypergroup/hyper-uri-format/blob/e2d56f205604684bd5805ae6c460fe50f41c0dfe/index.js#L97-L112 | train |
hypergroup/hyper-uri-format | index.js | decodeParams | function decodeParams(cache, API_URL, params) {
var obj = {}, v;
for (var k in params) {
if (!params.hasOwnProperty(k)) continue;
obj[k] = decode(cache, API_URL, params[k]);
}
return obj;
} | javascript | function decodeParams(cache, API_URL, params) {
var obj = {}, v;
for (var k in params) {
if (!params.hasOwnProperty(k)) continue;
obj[k] = decode(cache, API_URL, params[k]);
}
return obj;
} | [
"function",
"decodeParams",
"(",
"cache",
",",
"API_URL",
",",
"params",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
",",
"v",
";",
"for",
"(",
"var",
"k",
"in",
"params",
")",
"{",
"if",
"(",
"!",
"params",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
... | Decode a set of params | [
"Decode",
"a",
"set",
"of",
"params"
] | e2d56f205604684bd5805ae6c460fe50f41c0dfe | https://github.com/hypergroup/hyper-uri-format/blob/e2d56f205604684bd5805ae6c460fe50f41c0dfe/index.js#L118-L125 | train |
hypergroup/hyper-uri-format | index.js | pack | function pack(href, API_URL) {
var parts = url.parse(href);
var pn = API_URL.pathname || '/';
if (parts.host !== API_URL.host || parts.pathname.indexOf(pn) !== 0) return href;
if (pn === '/') pn = '';
return parts.pathname.replace(pn, '~') + (parts.search || '');
} | javascript | function pack(href, API_URL) {
var parts = url.parse(href);
var pn = API_URL.pathname || '/';
if (parts.host !== API_URL.host || parts.pathname.indexOf(pn) !== 0) return href;
if (pn === '/') pn = '';
return parts.pathname.replace(pn, '~') + (parts.search || '');
} | [
"function",
"pack",
"(",
"href",
",",
"API_URL",
")",
"{",
"var",
"parts",
"=",
"url",
".",
"parse",
"(",
"href",
")",
";",
"var",
"pn",
"=",
"API_URL",
".",
"pathname",
"||",
"'/'",
";",
"if",
"(",
"parts",
".",
"host",
"!==",
"API_URL",
".",
"h... | replace the API_URL with ~ | [
"replace",
"the",
"API_URL",
"with",
"~"
] | e2d56f205604684bd5805ae6c460fe50f41c0dfe | https://github.com/hypergroup/hyper-uri-format/blob/e2d56f205604684bd5805ae6c460fe50f41c0dfe/index.js#L142-L148 | train |
vkiding/jud-vue-render | src/render/browser/bridge/receiver.js | callNativeComponent | function callNativeComponent (instanceId, ref, method, args, options) {
return processCall(instanceId, {
component: options.component,
ref,
method,
args
})
} | javascript | function callNativeComponent (instanceId, ref, method, args, options) {
return processCall(instanceId, {
component: options.component,
ref,
method,
args
})
} | [
"function",
"callNativeComponent",
"(",
"instanceId",
",",
"ref",
",",
"method",
",",
"args",
",",
"options",
")",
"{",
"return",
"processCall",
"(",
"instanceId",
",",
"{",
"component",
":",
"options",
".",
"component",
",",
"ref",
",",
"method",
",",
"ar... | sync call native component method. | [
"sync",
"call",
"native",
"component",
"method",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/bridge/receiver.js#L9-L16 | train |
vkiding/jud-vue-render | src/render/browser/bridge/receiver.js | callNativeModule | function callNativeModule (instanceId, module, method, args, options) {
return processCall(instanceId, { module, method, args })
} | javascript | function callNativeModule (instanceId, module, method, args, options) {
return processCall(instanceId, { module, method, args })
} | [
"function",
"callNativeModule",
"(",
"instanceId",
",",
"module",
",",
"method",
",",
"args",
",",
"options",
")",
"{",
"return",
"processCall",
"(",
"instanceId",
",",
"{",
"module",
",",
"method",
",",
"args",
"}",
")",
"}"
] | sync call native module api. | [
"sync",
"call",
"native",
"module",
"api",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/bridge/receiver.js#L19-L21 | train |
nanowizard/vec23 | src/Vec2.js | function(v) {
if(v instanceof Vec3){
return this.toVec3()._cross(v);
}
return new Vec3(0,0, this.x * v.y - this.y * v.x);
} | javascript | function(v) {
if(v instanceof Vec3){
return this.toVec3()._cross(v);
}
return new Vec3(0,0, this.x * v.y - this.y * v.x);
} | [
"function",
"(",
"v",
")",
"{",
"if",
"(",
"v",
"instanceof",
"Vec3",
")",
"{",
"return",
"this",
".",
"toVec3",
"(",
")",
".",
"_cross",
"(",
"v",
")",
";",
"}",
"return",
"new",
"Vec3",
"(",
"0",
",",
"0",
",",
"this",
".",
"x",
"*",
"v",
... | Computes the cross product with a Vec2 or Vec3. Note that by definition the cross product of two 2D vectors is a 3D vector with x = y = 0
@memberof Vec2#
@param {Vec2|Vec3} v
@returns {Vec3} | [
"Computes",
"the",
"cross",
"product",
"with",
"a",
"Vec2",
"or",
"Vec3",
".",
"Note",
"that",
"by",
"definition",
"the",
"cross",
"product",
"of",
"two",
"2D",
"vectors",
"is",
"a",
"3D",
"vector",
"with",
"x",
"=",
"y",
"=",
"0"
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec2.js#L239-L244 | train | |
nanowizard/vec23 | src/Vec2.js | function(m){
return new Vec2(
this.x*m[0][0]+this.y*m[0][1],
this.x*m[1][0]+this.y*m[1][1]
);
} | javascript | function(m){
return new Vec2(
this.x*m[0][0]+this.y*m[0][1],
this.x*m[1][0]+this.y*m[1][1]
);
} | [
"function",
"(",
"m",
")",
"{",
"return",
"new",
"Vec2",
"(",
"this",
".",
"x",
"*",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
"+",
"this",
".",
"y",
"*",
"m",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"this",
".",
"x",
"*",
"m",
"[",
"1",
"]",
"["... | Creates a new vector converting the vector to a new coordinate frame at the same origin.
@memberof Vec2#
@param {Array} m - Coordinate system matrix of the form [[Xx,Xy],[Yx,Yy]]
@returns {Vec2} | [
"Creates",
"a",
"new",
"vector",
"converting",
"the",
"vector",
"to",
"a",
"new",
"coordinate",
"frame",
"at",
"the",
"same",
"origin",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec2.js#L391-L396 | train | |
nanowizard/vec23 | src/Vec2.js | function(theta){
return new Vec2(
this.x*Math.cos(theta)-this.y*Math.sin(theta),
this.x*Math.sin(theta)+this.y*Math.cos(theta)
);
} | javascript | function(theta){
return new Vec2(
this.x*Math.cos(theta)-this.y*Math.sin(theta),
this.x*Math.sin(theta)+this.y*Math.cos(theta)
);
} | [
"function",
"(",
"theta",
")",
"{",
"return",
"new",
"Vec2",
"(",
"this",
".",
"x",
"*",
"Math",
".",
"cos",
"(",
"theta",
")",
"-",
"this",
".",
"y",
"*",
"Math",
".",
"sin",
"(",
"theta",
")",
",",
"this",
".",
"x",
"*",
"Math",
".",
"sin",... | Rotates the vector in radians counterclockwise and returns a new vector.
@memberof Vec2#
@param {Number} theta - rotation angle (in radians)
@returns {Vec2} | [
"Rotates",
"the",
"vector",
"in",
"radians",
"counterclockwise",
"and",
"returns",
"a",
"new",
"vector",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec2.js#L416-L421 | train | |
nanowizard/vec23 | src/Vec2.js | function(p){
this.x = Math.pow(this.x, p);
this.y = Math.pow(this.y, p);
return this;
} | javascript | function(p){
this.x = Math.pow(this.x, p);
this.y = Math.pow(this.y, p);
return this;
} | [
"function",
"(",
"p",
")",
"{",
"this",
".",
"x",
"=",
"Math",
".",
"pow",
"(",
"this",
".",
"x",
",",
"p",
")",
";",
"this",
".",
"y",
"=",
"Math",
".",
"pow",
"(",
"this",
".",
"y",
",",
"p",
")",
";",
"return",
"this",
";",
"}"
] | Raises each component of the vector to the power p.
@memberof Vec2#
@returns {Vec2} | [
"Raises",
"each",
"component",
"of",
"the",
"vector",
"to",
"the",
"power",
"p",
"."
] | e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364 | https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec2.js#L448-L452 | train | |
scijs/ndarray-select | select.js | permuteOrder | function permuteOrder(order) {
var norder = order.slice()
norder.splice(order.indexOf(0), 1)
norder.unshift(0)
return norder
} | javascript | function permuteOrder(order) {
var norder = order.slice()
norder.splice(order.indexOf(0), 1)
norder.unshift(0)
return norder
} | [
"function",
"permuteOrder",
"(",
"order",
")",
"{",
"var",
"norder",
"=",
"order",
".",
"slice",
"(",
")",
"norder",
".",
"splice",
"(",
"order",
".",
"indexOf",
"(",
"0",
")",
",",
"1",
")",
"norder",
".",
"unshift",
"(",
"0",
")",
"return",
"nord... | Create new order where index 0 is slowest index | [
"Create",
"new",
"order",
"where",
"index",
"0",
"is",
"slowest",
"index"
] | 1e6eacb5d8ef8f40e11638f9d494f20e5856c526 | https://github.com/scijs/ndarray-select/blob/1e6eacb5d8ef8f40e11638f9d494f20e5856c526/select.js#L40-L45 | train |
perfectapi/node-paas-machine-proxy | bin/proxy.js | function() {
var config = {}
registry.listServices(config, function(err, result) {
if (err) return console.log(err);
main.poll(registry, result, function(err) {
if (err) return console.log(err);
});
})
} | javascript | function() {
var config = {}
registry.listServices(config, function(err, result) {
if (err) return console.log(err);
main.poll(registry, result, function(err) {
if (err) return console.log(err);
});
})
} | [
"function",
"(",
")",
"{",
"var",
"config",
"=",
"{",
"}",
"registry",
".",
"listServices",
"(",
"config",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"return",
"console",
".",
"log",
"(",
"err",
")",
";",
"main",
... | now we have a reference to the registry running on the same machine | [
"now",
"we",
"have",
"a",
"reference",
"to",
"the",
"registry",
"running",
"on",
"the",
"same",
"machine"
] | ad286fe05ef11ac060a4303ce07b664fad8155bf | https://github.com/perfectapi/node-paas-machine-proxy/blob/ad286fe05ef11ac060a4303ce07b664fad8155bf/bin/proxy.js#L32-L41 | train | |
jeswin-unmaintained/isotropy-koa-context-in-browser | lib/context.js | function(){
return {
request: this.request.toJSON(),
response: this.response.toJSON(),
app: this.app.toJSON(),
originalUrl: this.originalUrl,
req: '<original node req>',
res: '<original node res>',
... | javascript | function(){
return {
request: this.request.toJSON(),
response: this.response.toJSON(),
app: this.app.toJSON(),
originalUrl: this.originalUrl,
req: '<original node req>',
res: '<original node res>',
... | [
"function",
"(",
")",
"{",
"return",
"{",
"request",
":",
"this",
".",
"request",
".",
"toJSON",
"(",
")",
",",
"response",
":",
"this",
".",
"response",
".",
"toJSON",
"(",
")",
",",
"app",
":",
"this",
".",
"app",
".",
"toJSON",
"(",
")",
",",
... | Return JSON representation.
Here we explicitly invoke .toJSON() on each
object, as iteration will otherwise fail due
to the getters and cause utilities such as
clone() to fail.
@return {Object}
@api public | [
"Return",
"JSON",
"representation",
"."
] | 033a3ac0fd65ba6ac2b4ce715b3da54f873eed6f | https://github.com/jeswin-unmaintained/isotropy-koa-context-in-browser/blob/033a3ac0fd65ba6ac2b4ce715b3da54f873eed6f/lib/context.js#L40-L50 | train | |
K15t/webpack-build | webpack-build.js | mergeDefaultConfig | function mergeDefaultConfig(opts) {
let devModeEnabled = isDevelopMode();
let debugModeEnabled = isDebugMode();
console.log('------------------------------------------------------------------------------------');
console.log(`Executing build for ` + (devModeEnabled ? ENV_DEVELOPMENT : ENV_PROD));
... | javascript | function mergeDefaultConfig(opts) {
let devModeEnabled = isDevelopMode();
let debugModeEnabled = isDebugMode();
console.log('------------------------------------------------------------------------------------');
console.log(`Executing build for ` + (devModeEnabled ? ENV_DEVELOPMENT : ENV_PROD));
... | [
"function",
"mergeDefaultConfig",
"(",
"opts",
")",
"{",
"let",
"devModeEnabled",
"=",
"isDevelopMode",
"(",
")",
";",
"let",
"debugModeEnabled",
"=",
"isDebugMode",
"(",
")",
";",
"console",
".",
"log",
"(",
"'---------------------------------------------------------... | Module defining the common build configuration for webpack-based projects.
@param opts Customized options which allows to override the defaults configuration. | [
"Module",
"defining",
"the",
"common",
"build",
"configuration",
"for",
"webpack",
"-",
"based",
"projects",
"."
] | d5921b8c5abbc92159aabd6379c7c2b1a9d7fe27 | https://github.com/K15t/webpack-build/blob/d5921b8c5abbc92159aabd6379c7c2b1a9d7fe27/webpack-build.js#L23-L77 | train |
Lindurion/closure-pro-build | lib/file-matcher.js | resolveAnyGlobPatternsAsync | function resolveAnyGlobPatternsAsync(filesAndPatterns, rootSrcDir) {
return resolveGlobsAsync(filesAndPatterns, rootSrcDir)
.then(function(resolvedFiles) {
var allFiles = insertResolvedFiles(filesAndPatterns, resolvedFiles);
return allFiles.map(convertBackslashes);
});
} | javascript | function resolveAnyGlobPatternsAsync(filesAndPatterns, rootSrcDir) {
return resolveGlobsAsync(filesAndPatterns, rootSrcDir)
.then(function(resolvedFiles) {
var allFiles = insertResolvedFiles(filesAndPatterns, resolvedFiles);
return allFiles.map(convertBackslashes);
});
} | [
"function",
"resolveAnyGlobPatternsAsync",
"(",
"filesAndPatterns",
",",
"rootSrcDir",
")",
"{",
"return",
"resolveGlobsAsync",
"(",
"filesAndPatterns",
",",
"rootSrcDir",
")",
".",
"then",
"(",
"function",
"(",
"resolvedFiles",
")",
"{",
"var",
"allFiles",
"=",
"... | Uses glob library to resolve any file patterns in input list. Removes any
duplicate file paths and converts any path backslashes into forward slashes.
@param {!Array.<string>} filesAndPatterns List of files and file patterns,
e.g. ['my/single/file.js', 'dir/of/*.js'].
@param {string} rootSrcDir Root source directory th... | [
"Uses",
"glob",
"library",
"to",
"resolve",
"any",
"file",
"patterns",
"in",
"input",
"list",
".",
"Removes",
"any",
"duplicate",
"file",
"paths",
"and",
"converts",
"any",
"path",
"backslashes",
"into",
"forward",
"slashes",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/lib/file-matcher.js#L36-L42 | train |
Lindurion/closure-pro-build | lib/file-matcher.js | resolveGlobsAsync | function resolveGlobsAsync(filesAndPatterns, rootSrcDir) {
var options = {cwd: rootSrcDir};
var tasks = {};
filesAndPatterns.forEach(function(fileOrPattern) {
if (isGlobPattern(fileOrPattern)) {
tasks[fileOrPattern] =
underscore.partial(resolveGlobAsync, fileOrPattern, options);
}
});
... | javascript | function resolveGlobsAsync(filesAndPatterns, rootSrcDir) {
var options = {cwd: rootSrcDir};
var tasks = {};
filesAndPatterns.forEach(function(fileOrPattern) {
if (isGlobPattern(fileOrPattern)) {
tasks[fileOrPattern] =
underscore.partial(resolveGlobAsync, fileOrPattern, options);
}
});
... | [
"function",
"resolveGlobsAsync",
"(",
"filesAndPatterns",
",",
"rootSrcDir",
")",
"{",
"var",
"options",
"=",
"{",
"cwd",
":",
"rootSrcDir",
"}",
";",
"var",
"tasks",
"=",
"{",
"}",
";",
"filesAndPatterns",
".",
"forEach",
"(",
"function",
"(",
"fileOrPatter... | Does the glob resolution for all glob file patterns in input.
@param {!Array.<string>} filesAndPatterns
@param {string} rootSrcDir
@return {!Promise.<!Object.<string, !Array.<string>>>} A future map from
file pattern to list of resolved files (on success). | [
"Does",
"the",
"glob",
"resolution",
"for",
"all",
"glob",
"file",
"patterns",
"in",
"input",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/lib/file-matcher.js#L52-L68 | train |
JosePedroDias/level1 | libClient/level1_http.js | function() {
if (xhr.readyState === 4 && xhr.status === 200) {
return cb(null, JSON.parse(xhr.response));
}
cb('error requesting ' + uri);
} | javascript | function() {
if (xhr.readyState === 4 && xhr.status === 200) {
return cb(null, JSON.parse(xhr.response));
}
cb('error requesting ' + uri);
} | [
"function",
"(",
")",
"{",
"if",
"(",
"xhr",
".",
"readyState",
"===",
"4",
"&&",
"xhr",
".",
"status",
"===",
"200",
")",
"{",
"return",
"cb",
"(",
"null",
",",
"JSON",
".",
"parse",
"(",
"xhr",
".",
"response",
")",
")",
";",
"}",
"cb",
"(",
... | setup callback to handle result | [
"setup",
"callback",
"to",
"handle",
"result"
] | cabd26c85e4c4e3131863c1bb1eaac8e17d1ec22 | https://github.com/JosePedroDias/level1/blob/cabd26c85e4c4e3131863c1bb1eaac8e17d1ec22/libClient/level1_http.js#L68-L73 | train | |
espadrine/travel-scrapper | uk.js | extractTravelPlan | function extractTravelPlan(data) {
let tickets = data.fullJourneys[0].cheapestTickets
if (!tickets || tickets.length === 0) { return [] }
let secondClass = tickets[0].tickets
let firstClass = tickets[1].tickets
let journeys = data.fullJourneys[0].journeys
let date = data.fullJourneys[0].date // "25 Sep 201... | javascript | function extractTravelPlan(data) {
let tickets = data.fullJourneys[0].cheapestTickets
if (!tickets || tickets.length === 0) { return [] }
let secondClass = tickets[0].tickets
let firstClass = tickets[1].tickets
let journeys = data.fullJourneys[0].journeys
let date = data.fullJourneys[0].date // "25 Sep 201... | [
"function",
"extractTravelPlan",
"(",
"data",
")",
"{",
"let",
"tickets",
"=",
"data",
".",
"fullJourneys",
"[",
"0",
"]",
".",
"cheapestTickets",
"if",
"(",
"!",
"tickets",
"||",
"tickets",
".",
"length",
"===",
"0",
")",
"{",
"return",
"[",
"]",
"}",... | Get raw scrapping data Return data conforming to the common travel plan format. | [
"Get",
"raw",
"scrapping",
"data",
"Return",
"data",
"conforming",
"to",
"the",
"common",
"travel",
"plan",
"format",
"."
] | 5ed137e967a8a2de67f988922ec66222f464ea96 | https://github.com/espadrine/travel-scrapper/blob/5ed137e967a8a2de67f988922ec66222f464ea96/uk.js#L81-L128 | train |
espadrine/travel-scrapper | uk.js | getCookies | function getCookies() {
return new Promise((resolve, reject) => {
request.get(rootUrl, function(err, res, body) {
if (err != null && res.statusCode !== 200) {
reject(err || new Error('Accessing UK information failed'))
return
}
resolve()
})
})
} | javascript | function getCookies() {
return new Promise((resolve, reject) => {
request.get(rootUrl, function(err, res, body) {
if (err != null && res.statusCode !== 200) {
reject(err || new Error('Accessing UK information failed'))
return
}
resolve()
})
})
} | [
"function",
"getCookies",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
".",
"get",
"(",
"rootUrl",
",",
"function",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
"!=",
... | Return a promise. | [
"Return",
"a",
"promise",
"."
] | 5ed137e967a8a2de67f988922ec66222f464ea96 | https://github.com/espadrine/travel-scrapper/blob/5ed137e967a8a2de67f988922ec66222f464ea96/uk.js#L150-L160 | train |
markhuge/aws-sdk-sugar | lib/ec2.js | WTFAmazon | function WTFAmazon (array) {
var result = {};
array.map(function (item) { result[item.Key] = item.Value; });
return result;
} | javascript | function WTFAmazon (array) {
var result = {};
array.map(function (item) { result[item.Key] = item.Value; });
return result;
} | [
"function",
"WTFAmazon",
"(",
"array",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"array",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"result",
"[",
"item",
".",
"Key",
"]",
"=",
"item",
".",
"Value",
";",
"}",
")",
";",
"return",
... | Convert AWW's batshit map arrays to an object | [
"Convert",
"AWW",
"s",
"batshit",
"map",
"arrays",
"to",
"an",
"object"
] | 16f8c1275b3f730c57d06aece6ebb0a34e492163 | https://github.com/markhuge/aws-sdk-sugar/blob/16f8c1275b3f730c57d06aece6ebb0a34e492163/lib/ec2.js#L29-L33 | train |
milojs/ml-check | lib/check.js | _prependPath | function _prependPath(key, base) {
if ((typeof key) === "number" || key.match(/^[0-9]+$/))
key = "[" + key + "]";
else if (!key.match(Match.IdentifierString) || _jsKeywords.indexOf(key) !== -1)
key = JSON.stringify([key]);
if (base && base[0] !== "[")
return key + '.' + base;
re... | javascript | function _prependPath(key, base) {
if ((typeof key) === "number" || key.match(/^[0-9]+$/))
key = "[" + key + "]";
else if (!key.match(Match.IdentifierString) || _jsKeywords.indexOf(key) !== -1)
key = JSON.stringify([key]);
if (base && base[0] !== "[")
return key + '.' + base;
re... | [
"function",
"_prependPath",
"(",
"key",
",",
"base",
")",
"{",
"if",
"(",
"(",
"typeof",
"key",
")",
"===",
"\"number\"",
"||",
"key",
".",
"match",
"(",
"/",
"^[0-9]+$",
"/",
")",
")",
"key",
"=",
"\"[\"",
"+",
"key",
"+",
"\"]\"",
";",
"else",
... | Assumes the base of path is already escaped properly returns key + base | [
"Assumes",
"the",
"base",
"of",
"path",
"is",
"already",
"escaped",
"properly",
"returns",
"key",
"+",
"base"
] | 1b61af65796ddbfd8cfba0fdcc37769fab7e768f | https://github.com/milojs/ml-check/blob/1b61af65796ddbfd8cfba0fdcc37769fab7e768f/lib/check.js#L291-L300 | train |
shama/dom-tilemap | index.js | detach | function detach(el) {
var parent = el.parentNode
var next = el.nextSibling
parent.removeChild(el)
return function() {
if (next) parent.insertBefore(el, next)
else parent.appendChild(el)
}
} | javascript | function detach(el) {
var parent = el.parentNode
var next = el.nextSibling
parent.removeChild(el)
return function() {
if (next) parent.insertBefore(el, next)
else parent.appendChild(el)
}
} | [
"function",
"detach",
"(",
"el",
")",
"{",
"var",
"parent",
"=",
"el",
".",
"parentNode",
"var",
"next",
"=",
"el",
".",
"nextSibling",
"parent",
".",
"removeChild",
"(",
"el",
")",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"next",
")",
"parent... | for faster DOM manipulation - not faster in this case | [
"for",
"faster",
"DOM",
"manipulation",
"-",
"not",
"faster",
"in",
"this",
"case"
] | cd4af98e9066606717f04a1978cd162867eab160 | https://github.com/shama/dom-tilemap/blob/cd4af98e9066606717f04a1978cd162867eab160/index.js#L85-L93 | train |
psalaets/pie-slice | index.js | function(sliceCount, options) {
validateSliceCount(sliceCount)
options = options || {}
var slices = []
var step = 360 / sliceCount
var halfStep = step / 2
var min = 0
var max = min + step
var sliceNumber = 0
if (options.firstSliceFacesUp) {
// first slice straddles angle 0 a... | javascript | function(sliceCount, options) {
validateSliceCount(sliceCount)
options = options || {}
var slices = []
var step = 360 / sliceCount
var halfStep = step / 2
var min = 0
var max = min + step
var sliceNumber = 0
if (options.firstSliceFacesUp) {
// first slice straddles angle 0 a... | [
"function",
"(",
"sliceCount",
",",
"options",
")",
"{",
"validateSliceCount",
"(",
"sliceCount",
")",
"options",
"=",
"options",
"||",
"{",
"}",
"var",
"slices",
"=",
"[",
"]",
"var",
"step",
"=",
"360",
"/",
"sliceCount",
"var",
"halfStep",
"=",
"step"... | Create a pie with certain number of slices.
@param sliceCount Number of slices. Must be between 2 and 360, inclusive.
@param options Hash of extra options. Options:
- firstSliceFacesUp - true to make first slice point straight up so it's
bissected by angle 0. Otherwise first slice *begins* at angle 0.
Defaults to fals... | [
"Create",
"a",
"pie",
"with",
"certain",
"number",
"of",
"slices",
"."
] | ca119bb63ccefc09cc66ebfdf0bc19ebce364b88 | https://github.com/psalaets/pie-slice/blob/ca119bb63ccefc09cc66ebfdf0bc19ebce364b88/index.js#L21-L49 | train | |
vweevers/doctap | lib/transform.js | parseComment | function parseComment (comment) {
const body = j('[' + comment + ']').nodes()[0].program.body
const array = body[0].expression
return array.elements
} | javascript | function parseComment (comment) {
const body = j('[' + comment + ']').nodes()[0].program.body
const array = body[0].expression
return array.elements
} | [
"function",
"parseComment",
"(",
"comment",
")",
"{",
"const",
"body",
"=",
"j",
"(",
"'['",
"+",
"comment",
"+",
"']'",
")",
".",
"nodes",
"(",
")",
"[",
"0",
"]",
".",
"program",
".",
"body",
"const",
"array",
"=",
"body",
"[",
"0",
"]",
".",
... | Because we take the comment as JavaScript source code, it can reference variables and do all sorts of crazy stuff. | [
"Because",
"we",
"take",
"the",
"comment",
"as",
"JavaScript",
"source",
"code",
"it",
"can",
"reference",
"variables",
"and",
"do",
"all",
"sorts",
"of",
"crazy",
"stuff",
"."
] | 3c93981e2c7dc4db3245e44495a2f8e841008f5c | https://github.com/vweevers/doctap/blob/3c93981e2c7dc4db3245e44495a2f8e841008f5c/lib/transform.js#L308-L312 | train |
vweevers/doctap | lib/transform.js | identifierFactory | function identifierFactory (ast, reserved) {
reserved = reserved || new Set
ast.find(j.Identifier).forEach(path => {
reserved.add(path.node.name)
})
ast.find(j.FunctionDeclaration).forEach(path => {
reserved.add(path.node.id.name)
})
function identifier (name, suffix) {
return j.identifier(id... | javascript | function identifierFactory (ast, reserved) {
reserved = reserved || new Set
ast.find(j.Identifier).forEach(path => {
reserved.add(path.node.name)
})
ast.find(j.FunctionDeclaration).forEach(path => {
reserved.add(path.node.id.name)
})
function identifier (name, suffix) {
return j.identifier(id... | [
"function",
"identifierFactory",
"(",
"ast",
",",
"reserved",
")",
"{",
"reserved",
"=",
"reserved",
"||",
"new",
"Set",
"ast",
".",
"find",
"(",
"j",
".",
"Identifier",
")",
".",
"forEach",
"(",
"path",
"=>",
"{",
"reserved",
".",
"add",
"(",
"path",
... | Make identifiers with unique names | [
"Make",
"identifiers",
"with",
"unique",
"names"
] | 3c93981e2c7dc4db3245e44495a2f8e841008f5c | https://github.com/vweevers/doctap/blob/3c93981e2c7dc4db3245e44495a2f8e841008f5c/lib/transform.js#L315-L343 | train |
rudiculous/node-function-signature | index.js | getFunctionSignature | function getFunctionSignature(fn) {
let str = fn.toString()
// Strip comments.
str = str.replace(/\/\/[^\r\n]*|\/\*[\s\S]*?\*\//g, '')
const match = str.match(/\(([^)]*)\)/)
if (match) {
let res = match[1]
// Strip leading and trailing whitespace.
res = res.replace(/^\s+|\s+$/g, '')
let s... | javascript | function getFunctionSignature(fn) {
let str = fn.toString()
// Strip comments.
str = str.replace(/\/\/[^\r\n]*|\/\*[\s\S]*?\*\//g, '')
const match = str.match(/\(([^)]*)\)/)
if (match) {
let res = match[1]
// Strip leading and trailing whitespace.
res = res.replace(/^\s+|\s+$/g, '')
let s... | [
"function",
"getFunctionSignature",
"(",
"fn",
")",
"{",
"let",
"str",
"=",
"fn",
".",
"toString",
"(",
")",
"// Strip comments.",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\/\\/[^\\r\\n]*|\\/\\*[\\s\\S]*?\\*\\/",
"/",
"g",
",",
"''",
")",
"const",
"mat... | Parses a function to get its parameters.
@param {Function} fn The function to parse.
@return {Array} A list of the function arguments.
@public | [
"Parses",
"a",
"function",
"to",
"get",
"its",
"parameters",
"."
] | 16edab38d4bb2db26ed5bbfbaafd2b46d93dd438 | https://github.com/rudiculous/node-function-signature/blob/16edab38d4bb2db26ed5bbfbaafd2b46d93dd438/index.js#L11-L60 | train |
gethuman/pancakes-angular | lib/ngapp/focus.js | blur | function blur(selector) {
$timeout(function blurFocus() {
// fix for iOS
if (document && document.activeElement && document.activeElement.blur) {
document.activeElement.blur();
}
var el = jQuery(selector);
if (el && el.length) {
... | javascript | function blur(selector) {
$timeout(function blurFocus() {
// fix for iOS
if (document && document.activeElement && document.activeElement.blur) {
document.activeElement.blur();
}
var el = jQuery(selector);
if (el && el.length) {
... | [
"function",
"blur",
"(",
"selector",
")",
"{",
"$timeout",
"(",
"function",
"blurFocus",
"(",
")",
"{",
"// fix for iOS",
"if",
"(",
"document",
"&&",
"document",
".",
"activeElement",
"&&",
"document",
".",
"activeElement",
".",
"blur",
")",
"{",
"document"... | Blur an element
@param selector | [
"Blur",
"an",
"element"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/focus.js#L29-L42 | train |
Wiredcraft/carcass | lib/proto/register.js | function() {
var lib, name, names, _i, _len;
lib = arguments[0], names = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = names.length; _i < _len; _i++) {
name = names[_i];
if (lib[name] == null) {
return;
}
if (this[name] == null) {
this[n... | javascript | function() {
var lib, name, names, _i, _len;
lib = arguments[0], names = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = names.length; _i < _len; _i++) {
name = names[_i];
if (lib[name] == null) {
return;
}
if (this[name] == null) {
this[n... | [
"function",
"(",
")",
"{",
"var",
"lib",
",",
"name",
",",
"names",
",",
"_i",
",",
"_len",
";",
"lib",
"=",
"arguments",
"[",
"0",
"]",
",",
"names",
"=",
"2",
"<=",
"arguments",
".",
"length",
"?",
"__slice",
".",
"call",
"(",
"arguments",
",",... | Extend with another register.
@param lib
@param *name
@return {this} | [
"Extend",
"with",
"another",
"register",
"."
] | 3527ec0253f55abba8e6b255e7bf3412b3ca7501 | https://github.com/Wiredcraft/carcass/blob/3527ec0253f55abba8e6b255e7bf3412b3ca7501/lib/proto/register.js#L57-L74 | train | |
tolokoban/ToloFrameWork | lib/init.js | menu | function menu( items, nextStep ) {
const rl = RL.createInterface( {
input: process.stdin,
output: process.stdout
} );
console.log();
items.forEach( function ( item, idx ) {
var out = idx < 10 ? ' ' : '';
out += ( "" + ( 1 + idx ) + ") " ).yellow;
out += item;
... | javascript | function menu( items, nextStep ) {
const rl = RL.createInterface( {
input: process.stdin,
output: process.stdout
} );
console.log();
items.forEach( function ( item, idx ) {
var out = idx < 10 ? ' ' : '';
out += ( "" + ( 1 + idx ) + ") " ).yellow;
out += item;
... | [
"function",
"menu",
"(",
"items",
",",
"nextStep",
")",
"{",
"const",
"rl",
"=",
"RL",
".",
"createInterface",
"(",
"{",
"input",
":",
"process",
".",
"stdin",
",",
"output",
":",
"process",
".",
"stdout",
"}",
")",
";",
"console",
".",
"log",
"(",
... | Display a list of items and ask the user to select one.
Each item is numbered and the menu is displayed again if the user
enter a non-existing value.
The function `nextStep` is called with the choice as a number. | [
"Display",
"a",
"list",
"of",
"items",
"and",
"ask",
"the",
"user",
"to",
"select",
"one",
".",
"Each",
"item",
"is",
"numbered",
"and",
"the",
"menu",
"is",
"displayed",
"again",
"if",
"the",
"user",
"enter",
"a",
"non",
"-",
"existing",
"value",
".",... | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/init.js#L229-L252 | train |
tolokoban/ToloFrameWork | lib/init.js | isInEmptyFolder | function isInEmptyFolder() {
var files = FS.readdirSync( '.' );
try {
if ( files.length == 0 ) return true;
console.log( Fatal.format(
"You should be in an empty folder to create a new project!\n" +
"If you continue, all the files in this folder will be DELETED!"
... | javascript | function isInEmptyFolder() {
var files = FS.readdirSync( '.' );
try {
if ( files.length == 0 ) return true;
console.log( Fatal.format(
"You should be in an empty folder to create a new project!\n" +
"If you continue, all the files in this folder will be DELETED!"
... | [
"function",
"isInEmptyFolder",
"(",
")",
"{",
"var",
"files",
"=",
"FS",
".",
"readdirSync",
"(",
"'.'",
")",
";",
"try",
"{",
"if",
"(",
"files",
".",
"length",
"==",
"0",
")",
"return",
"true",
";",
"console",
".",
"log",
"(",
"Fatal",
".",
"form... | Check if we are in an empty folder. | [
"Check",
"if",
"we",
"are",
"in",
"an",
"empty",
"folder",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/init.js#L331-L347 | train |
tolokoban/ToloFrameWork | lib/init.js | isGitInstalled | function isGitInstalled() {
var result = exec( "git --version", true );
try {
if ( !result || result.indexOf( "git" ) < 0 || result.indexOf( "version" ) < 0 ) {
console.log( Fatal.format(
"`git` is required by the ToloFrameWork!\n" +
"Please install it:" ) );
... | javascript | function isGitInstalled() {
var result = exec( "git --version", true );
try {
if ( !result || result.indexOf( "git" ) < 0 || result.indexOf( "version" ) < 0 ) {
console.log( Fatal.format(
"`git` is required by the ToloFrameWork!\n" +
"Please install it:" ) );
... | [
"function",
"isGitInstalled",
"(",
")",
"{",
"var",
"result",
"=",
"exec",
"(",
"\"git --version\"",
",",
"true",
")",
";",
"try",
"{",
"if",
"(",
"!",
"result",
"||",
"result",
".",
"indexOf",
"(",
"\"git\"",
")",
"<",
"0",
"||",
"result",
".",
"ind... | Check if `git` is installed on this system. | [
"Check",
"if",
"git",
"is",
"installed",
"on",
"this",
"system",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/init.js#L352-L366 | train |
tolokoban/ToloFrameWork | lib/init.js | cleanDir | function cleanDir( path ) {
var files = FS.readdirSync( path );
try {
files.forEach( function ( file ) {
var fullpath = Path.join( path, file );
if ( !FS.existsSync( fullpath ) ) return;
var stat = FS.statSync( fullpath );
try {
if ( stat.i... | javascript | function cleanDir( path ) {
var files = FS.readdirSync( path );
try {
files.forEach( function ( file ) {
var fullpath = Path.join( path, file );
if ( !FS.existsSync( fullpath ) ) return;
var stat = FS.statSync( fullpath );
try {
if ( stat.i... | [
"function",
"cleanDir",
"(",
"path",
")",
"{",
"var",
"files",
"=",
"FS",
".",
"readdirSync",
"(",
"path",
")",
";",
"try",
"{",
"files",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"fullpath",
"=",
"Path",
".",
"join",
"(",
"pat... | Remove all the files and folder in `path`, but not `path` itself. | [
"Remove",
"all",
"the",
"files",
"and",
"folder",
"in",
"path",
"but",
"not",
"path",
"itself",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/init.js#L396-L414 | train |
closealert/async-lru-cache | example.js | checkHost | function checkHost(host,callback) {
if(hostCache.get(host,callback)) {
console.log('checkHost: Resolved %s from hostCache...',host);
return true;
}
console.log('checkHost: Looking up %s...',host);
var options = {
host: host,
port: 80,
path: '/',
method: 'GET'
};
var req = http.request(options, fun... | javascript | function checkHost(host,callback) {
if(hostCache.get(host,callback)) {
console.log('checkHost: Resolved %s from hostCache...',host);
return true;
}
console.log('checkHost: Looking up %s...',host);
var options = {
host: host,
port: 80,
path: '/',
method: 'GET'
};
var req = http.request(options, fun... | [
"function",
"checkHost",
"(",
"host",
",",
"callback",
")",
"{",
"if",
"(",
"hostCache",
".",
"get",
"(",
"host",
",",
"callback",
")",
")",
"{",
"console",
".",
"log",
"(",
"'checkHost: Resolved %s from hostCache...'",
",",
"host",
")",
";",
"return",
"tr... | Function with single argument callback
Connects to a host and returns true or false wether a connection was made
@param key Hostname
@param Function Callback | [
"Function",
"with",
"single",
"argument",
"callback",
"Connects",
"to",
"a",
"host",
"and",
"returns",
"true",
"or",
"false",
"wether",
"a",
"connection",
"was",
"made"
] | ba15c1c4f64ba841a97b8946b71c004ea6b20b22 | https://github.com/closealert/async-lru-cache/blob/ba15c1c4f64ba841a97b8946b71c004ea6b20b22/example.js#L14-L48 | train |
Digznav/bilberry | git-current-branch.js | gitCurrentBranch | function gitCurrentBranch() {
return git('status --porcelain -b', stdout => {
const status = gitUtil.extractStatus(stdout);
return status.branch.split('...')[0];
});
} | javascript | function gitCurrentBranch() {
return git('status --porcelain -b', stdout => {
const status = gitUtil.extractStatus(stdout);
return status.branch.split('...')[0];
});
} | [
"function",
"gitCurrentBranch",
"(",
")",
"{",
"return",
"git",
"(",
"'status --porcelain -b'",
",",
"stdout",
"=>",
"{",
"const",
"status",
"=",
"gitUtil",
".",
"extractStatus",
"(",
"stdout",
")",
";",
"return",
"status",
".",
"branch",
".",
"split",
"(",
... | Get the current branch.
@return {promise} A promise get the current branch, | [
"Get",
"the",
"current",
"branch",
"."
] | ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4 | https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/git-current-branch.js#L8-L13 | train |
reklatsmasters/trace-inline-parse | index.js | node | function node(name, accessor) {
if (!name) {
return false
}
return {
name: name,
accessor: accessor ? accessor : false
}
} | javascript | function node(name, accessor) {
if (!name) {
return false
}
return {
name: name,
accessor: accessor ? accessor : false
}
} | [
"function",
"node",
"(",
"name",
",",
"accessor",
")",
"{",
"if",
"(",
"!",
"name",
")",
"{",
"return",
"false",
"}",
"return",
"{",
"name",
":",
"name",
",",
"accessor",
":",
"accessor",
"?",
"accessor",
":",
"false",
"}",
"}"
] | create `target` or `caller` nodes | [
"create",
"target",
"or",
"caller",
"nodes"
] | e029463fd6a08d7849c823ed1c3379878b30e8f2 | https://github.com/reklatsmasters/trace-inline-parse/blob/e029463fd6a08d7849c823ed1c3379878b30e8f2/index.js#L67-L76 | train |
redisjs/jsr-server | lib/command/connection/select.js | execute | function execute(req, res) {
// if we have a sparse db store we need
// to ensure a database exists
if(!this.store.databases[req.args[0]]) {
this.store.getDatabase(req.args[0], {pattern: this.pattern});
}
// update the connection with their selected db index
req.conn.db = req.args[0];
res.send(null... | javascript | function execute(req, res) {
// if we have a sparse db store we need
// to ensure a database exists
if(!this.store.databases[req.args[0]]) {
this.store.getDatabase(req.args[0], {pattern: this.pattern});
}
// update the connection with their selected db index
req.conn.db = req.args[0];
res.send(null... | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"// if we have a sparse db store we need",
"// to ensure a database exists",
"if",
"(",
"!",
"this",
".",
"store",
".",
"databases",
"[",
"req",
".",
"args",
"[",
"0",
"]",
"]",
")",
"{",
"this",
".",
... | Respond to the SELECT command. | [
"Respond",
"to",
"the",
"SELECT",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/connection/select.js#L21-L33 | train |
redisjs/jsr-server | lib/command/connection/select.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var index = parseInt(args[0]);
if(isNaN(index) || index < 0 || index >= info.conf.databases) {
throw DatabaseIndex;
}
// update the index with the integer value
// connection expects an integer
args[0] = in... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var index = parseInt(args[0]);
if(isNaN(index) || index < 0 || index >= info.conf.databases) {
throw DatabaseIndex;
}
// update the index with the integer value
// connection expects an integer
args[0] = in... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"index",
"=",
"parseInt",
"(",
"args",
"[",
"0",
"]",
")",
";"... | Validate the SELECT command. | [
"Validate",
"the",
"SELECT",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/connection/select.js#L38-L47 | train |
feedhenry/fh-mbaas-middleware | lib/models/appEnv.js | getOpenshiftEnvVars | function getOpenshiftEnvVars(params){
var appMbaas = params.appMbaas;
var mbaasUrl = _parseMbaasUrl(appMbaas.mbaasUrl);
var appEnvs = {};
appEnvs.FH_MBAAS_PROTOCOL = mbaasUrl.protocol;
//App Mbaas Host. Used for apps calling mbaas hosts.
appEnvs.FH_MBAAS_HOST = mbaasUrl.host;
//Access key to verify apps... | javascript | function getOpenshiftEnvVars(params){
var appMbaas = params.appMbaas;
var mbaasUrl = _parseMbaasUrl(appMbaas.mbaasUrl);
var appEnvs = {};
appEnvs.FH_MBAAS_PROTOCOL = mbaasUrl.protocol;
//App Mbaas Host. Used for apps calling mbaas hosts.
appEnvs.FH_MBAAS_HOST = mbaasUrl.host;
//Access key to verify apps... | [
"function",
"getOpenshiftEnvVars",
"(",
"params",
")",
"{",
"var",
"appMbaas",
"=",
"params",
".",
"appMbaas",
";",
"var",
"mbaasUrl",
"=",
"_parseMbaasUrl",
"(",
"appMbaas",
".",
"mbaasUrl",
")",
";",
"var",
"appEnvs",
"=",
"{",
"}",
";",
"appEnvs",
".",
... | Getting Environment Variables For Openshift Apps.
@param params | [
"Getting",
"Environment",
"Variables",
"For",
"Openshift",
"Apps",
"."
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/models/appEnv.js#L18-L37 | train |
docvy/utils | lib/index.js | getPath | function getPath(pathname) {
var _paths = { };
_paths["app.home"] = path.join(process.env.HOME, ".docvy");
_paths["app.cache"] = path.join(_paths["app.home"], "cache");
_paths["app.cache.plugins"] = path.join(_paths["app.cache"], "plugins");
_paths["app.logs"] = path.join(_paths["app.home"], "logs")... | javascript | function getPath(pathname) {
var _paths = { };
_paths["app.home"] = path.join(process.env.HOME, ".docvy");
_paths["app.cache"] = path.join(_paths["app.home"], "cache");
_paths["app.cache.plugins"] = path.join(_paths["app.cache"], "plugins");
_paths["app.logs"] = path.join(_paths["app.home"], "logs")... | [
"function",
"getPath",
"(",
"pathname",
")",
"{",
"var",
"_paths",
"=",
"{",
"}",
";",
"_paths",
"[",
"\"app.home\"",
"]",
"=",
"path",
".",
"join",
"(",
"process",
".",
"env",
".",
"HOME",
",",
"\".docvy\"",
")",
";",
"_paths",
"[",
"\"app.cache\"",
... | Returns application-specific paths
@param {String} pathname - name of path
@return {String} absolute path | [
"Returns",
"application",
"-",
"specific",
"paths"
] | 9bdf093238feff6fb1741d85f7d6a443adc882ac | https://github.com/docvy/utils/blob/9bdf093238feff6fb1741d85f7d6a443adc882ac/lib/index.js#L64-L76 | train |
docvy/utils | lib/index.js | defineError | function defineError(code, message) {
var ErrorClass = errors.helpers.generateClass(code);
function ExportedError(err) {
ErrorClass.call(this, message, err);
return this;
}
util.inherits(ExportedError, ErrorClass);
return ExportedError;
} | javascript | function defineError(code, message) {
var ErrorClass = errors.helpers.generateClass(code);
function ExportedError(err) {
ErrorClass.call(this, message, err);
return this;
}
util.inherits(ExportedError, ErrorClass);
return ExportedError;
} | [
"function",
"defineError",
"(",
"code",
",",
"message",
")",
"{",
"var",
"ErrorClass",
"=",
"errors",
".",
"helpers",
".",
"generateClass",
"(",
"code",
")",
";",
"function",
"ExportedError",
"(",
"err",
")",
"{",
"ErrorClass",
".",
"call",
"(",
"this",
... | Defines an error | [
"Defines",
"an",
"error"
] | 9bdf093238feff6fb1741d85f7d6a443adc882ac | https://github.com/docvy/utils/blob/9bdf093238feff6fb1741d85f7d6a443adc882ac/lib/index.js#L82-L90 | train |
philipbordallo/eslint-config | version.js | updateVersion | async function updateVersion(file) {
const { default: config } = await import(`${CONFIGS_PATH}/${file}`);
const { packageName } = config;
const packageInfoFile = `${PACKAGES_PATH}/${packageName}/package.json`;
const { default: packageInfo } = await import(packageInfoFile);
if (info.version !== packageInfo.v... | javascript | async function updateVersion(file) {
const { default: config } = await import(`${CONFIGS_PATH}/${file}`);
const { packageName } = config;
const packageInfoFile = `${PACKAGES_PATH}/${packageName}/package.json`;
const { default: packageInfo } = await import(packageInfoFile);
if (info.version !== packageInfo.v... | [
"async",
"function",
"updateVersion",
"(",
"file",
")",
"{",
"const",
"{",
"default",
":",
"config",
"}",
"=",
"await",
"import",
"(",
"`",
"${",
"CONFIGS_PATH",
"}",
"${",
"file",
"}",
"`",
")",
";",
"const",
"{",
"packageName",
"}",
"=",
"config",
... | Update all packages to latest version
@param {string} file | [
"Update",
"all",
"packages",
"to",
"latest",
"version"
] | a2f1bff442fdb8ee622f842f075fa10d555302a4 | https://github.com/philipbordallo/eslint-config/blob/a2f1bff442fdb8ee622f842f075fa10d555302a4/version.js#L15-L34 | train |
appcelerator-archive/appc-connector-utils | lib/model/api.js | createFromMetadata | function createFromMetadata (connector, modelsMetadata) {
if (!connector || !modelsMetadata) {
throw new Error('Please provide both connector and metadata so Arrow could create models')
}
const loadModels = connector.config.generateModels
return Object.keys(modelsMetadata).reduce(function (previ... | javascript | function createFromMetadata (connector, modelsMetadata) {
if (!connector || !modelsMetadata) {
throw new Error('Please provide both connector and metadata so Arrow could create models')
}
const loadModels = connector.config.generateModels
return Object.keys(modelsMetadata).reduce(function (previ... | [
"function",
"createFromMetadata",
"(",
"connector",
",",
"modelsMetadata",
")",
"{",
"if",
"(",
"!",
"connector",
"||",
"!",
"modelsMetadata",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please provide both connector and metadata so Arrow could create models'",
")",
"}",
... | Create models in memory on persist them on disk depending on the configured strategy.
@param {object} connector
@param {object} modelsMetadata
@return object that holds all the models or empty object in case we use persistence strategy | [
"Create",
"models",
"in",
"memory",
"on",
"persist",
"them",
"on",
"disk",
"depending",
"on",
"the",
"configured",
"strategy",
"."
] | 4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8 | https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/model/api.js#L26-L53 | train |
appcelerator-archive/appc-connector-utils | lib/model/api.js | getRootModelName | function getRootModelName (model) {
if (!model) {
throw new Error('Please provide Arrow Model')
}
const namespaceDelimiter = '/'
var parent = model
while (parent._parent && parent._parent.name) {
parent = parent._parent
}
if (!parent.name) {
throw new Error('The provided m... | javascript | function getRootModelName (model) {
if (!model) {
throw new Error('Please provide Arrow Model')
}
const namespaceDelimiter = '/'
var parent = model
while (parent._parent && parent._parent.name) {
parent = parent._parent
}
if (!parent.name) {
throw new Error('The provided m... | [
"function",
"getRootModelName",
"(",
"model",
")",
"{",
"if",
"(",
"!",
"model",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please provide Arrow Model'",
")",
"}",
"const",
"namespaceDelimiter",
"=",
"'/'",
"var",
"parent",
"=",
"model",
"while",
"(",
"parent... | Gets parent model name or if the model has no parent the model name itself.
@param {Arrow.Model} model the model which name must be evaluated
@return {Object} object literal that contains the clean and namespaced model name | [
"Gets",
"parent",
"model",
"name",
"or",
"if",
"the",
"model",
"has",
"no",
"parent",
"the",
"model",
"name",
"itself",
"."
] | 4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8 | https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/model/api.js#L61-L80 | train |
lotaris/api-copilot | lib/client.js | function(options) {
if (!_.isString(options.method)) {
throw new Error('"method" must be a string, got ' + options.method);
} else if (!_.isString(options.url)) {
throw new Error('"url" must be a string, got ' + options.url);
}
return options;
} | javascript | function(options) {
if (!_.isString(options.method)) {
throw new Error('"method" must be a string, got ' + options.method);
} else if (!_.isString(options.url)) {
throw new Error('"url" must be a string, got ' + options.url);
}
return options;
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"options",
".",
"method",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'\"method\" must be a string, got '",
"+",
"options",
".",
"method",
")",
";",
"}",
"else",
"if",
"... | An error is thrown if either the `method` or the `url` option is not a string. Note that this error is caught by the promise chain and causes the returned promise to be rejected. | [
"An",
"error",
"is",
"thrown",
"if",
"either",
"the",
"method",
"or",
"the",
"url",
"option",
"is",
"not",
"a",
"string",
".",
"Note",
"that",
"this",
"error",
"is",
"caught",
"by",
"the",
"promise",
"chain",
"and",
"causes",
"the",
"returned",
"promise"... | 7df124602c79b8528b7fdbda1fd962e6763f2408 | https://github.com/lotaris/api-copilot/blob/7df124602c79b8528b7fdbda1fd962e6763f2408/lib/client.js#L156-L164 | train | |
lotaris/api-copilot | lib/client.js | function(filterIndex, options) {
if (options === undefined) {
throw new Error('Request filter at index ' + filterIndex + ' returned nothing; it must return the filtered request options');
} else if (!_.isObject(options)) {
throw new Error('Expected request filter at index ' + filterIndex + '... | javascript | function(filterIndex, options) {
if (options === undefined) {
throw new Error('Request filter at index ' + filterIndex + ' returned nothing; it must return the filtered request options');
} else if (!_.isObject(options)) {
throw new Error('Expected request filter at index ' + filterIndex + '... | [
"function",
"(",
"filterIndex",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"undefined",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Request filter at index '",
"+",
"filterIndex",
"+",
"' returned nothing; it must return the filtered request options'",
")",
... | After each filter, this check ensures that the returned request options are valid. Again, any error is caught by the promise chain and causes the returned promise to be rejected. | [
"After",
"each",
"filter",
"this",
"check",
"ensures",
"that",
"the",
"returned",
"request",
"options",
"are",
"valid",
".",
"Again",
"any",
"error",
"is",
"caught",
"by",
"the",
"promise",
"chain",
"and",
"causes",
"the",
"returned",
"promise",
"to",
"be",
... | 7df124602c79b8528b7fdbda1fd962e6763f2408 | https://github.com/lotaris/api-copilot/blob/7df124602c79b8528b7fdbda1fd962e6763f2408/lib/client.js#L199-L207 | train | |
billinghamj/resilient-mailer-mailjet | lib/mailjet-provider.js | MailjetProvider | function MailjetProvider(apiKey, apiSecret, options) {
if (typeof apiKey !== 'string'
|| typeof apiSecret !== 'string') {
throw new Error('Invalid parameters');
}
options = options || {};
if (typeof options.apiSecure === 'undefined')
options.apiSecure = true;
options.apiHostname = options.apiHostname || '... | javascript | function MailjetProvider(apiKey, apiSecret, options) {
if (typeof apiKey !== 'string'
|| typeof apiSecret !== 'string') {
throw new Error('Invalid parameters');
}
options = options || {};
if (typeof options.apiSecure === 'undefined')
options.apiSecure = true;
options.apiHostname = options.apiHostname || '... | [
"function",
"MailjetProvider",
"(",
"apiKey",
",",
"apiSecret",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"apiKey",
"!==",
"'string'",
"||",
"typeof",
"apiSecret",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid parameters'",
")",
"... | Creates an instance of the Mailjet email provider.
@constructor
@this {MailjetProvider}
@param {string} apiKey API Key for the Mailjet account.
@param {string} apiSecret API Key for the Mailjet account.
@param {object} [options] Additional optional configuration.
@param {boolean} [options.apiSecure=true] API connectio... | [
"Creates",
"an",
"instance",
"of",
"the",
"Mailjet",
"email",
"provider",
"."
] | b02d7eeae020b83db8468f214870ba9b9207f994 | https://github.com/billinghamj/resilient-mailer-mailjet/blob/b02d7eeae020b83db8468f214870ba9b9207f994/lib/mailjet-provider.js#L19-L36 | train |
gethuman/pancakes-recipe | utils/date.formater.js | getFormattedDate | function getFormattedDate(date, lang, type) {
date = date || new Date();
lang = lang || 'en';
type = type || 'long';
// set the language for en
if (lang === 'en' && type === 'short') { lang = 'enshort'; }
if (lang === 'en' && type === 'medium') { lang = 'enmedium'; }
... | javascript | function getFormattedDate(date, lang, type) {
date = date || new Date();
lang = lang || 'en';
type = type || 'long';
// set the language for en
if (lang === 'en' && type === 'short') { lang = 'enshort'; }
if (lang === 'en' && type === 'medium') { lang = 'enmedium'; }
... | [
"function",
"getFormattedDate",
"(",
"date",
",",
"lang",
",",
"type",
")",
"{",
"date",
"=",
"date",
"||",
"new",
"Date",
"(",
")",
";",
"lang",
"=",
"lang",
"||",
"'en'",
";",
"type",
"=",
"type",
"||",
"'long'",
";",
"// set the language for en",
"i... | Use moment to format the date
@param date
@param lang
@param type
@returns {*} | [
"Use",
"moment",
"to",
"format",
"the",
"date"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/date.formater.js#L100-L111 | train |
Insorum/hubot-youtube-feed | src/lib/notification-list.js | function (username, channel) {
var userChannels = this.getUserNotifications(username);
// if the user doesn't already have an entry add one
if (userChannels === null) {
userChannels = [];
// update the user to add them to the latest videos list
this.latestVi... | javascript | function (username, channel) {
var userChannels = this.getUserNotifications(username);
// if the user doesn't already have an entry add one
if (userChannels === null) {
userChannels = [];
// update the user to add them to the latest videos list
this.latestVi... | [
"function",
"(",
"username",
",",
"channel",
")",
"{",
"var",
"userChannels",
"=",
"this",
".",
"getUserNotifications",
"(",
"username",
")",
";",
"// if the user doesn't already have an entry add one",
"if",
"(",
"userChannels",
"===",
"null",
")",
"{",
"userChanne... | Adds the given username to the list of names for notifications
@param {string} username - The account name to check for
@param {string} channel - The channel to send the notification to
@returns {boolean} true if added, false if already in the list | [
"Adds",
"the",
"given",
"username",
"to",
"the",
"list",
"of",
"names",
"for",
"notifications"
] | 6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b | https://github.com/Insorum/hubot-youtube-feed/blob/6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b/src/lib/notification-list.js#L45-L70 | train | |
Insorum/hubot-youtube-feed | src/lib/notification-list.js | function (username, channel) {
var userChannels = this.getUserNotifications(username);
// dont remove if they dont exist
if (userChannels === null) {
return false;
}
var index = userChannels.indexOf(channel);
// dont remove if the channel doesnt exist
... | javascript | function (username, channel) {
var userChannels = this.getUserNotifications(username);
// dont remove if they dont exist
if (userChannels === null) {
return false;
}
var index = userChannels.indexOf(channel);
// dont remove if the channel doesnt exist
... | [
"function",
"(",
"username",
",",
"channel",
")",
"{",
"var",
"userChannels",
"=",
"this",
".",
"getUserNotifications",
"(",
"username",
")",
";",
"// dont remove if they dont exist",
"if",
"(",
"userChannels",
"===",
"null",
")",
"{",
"return",
"false",
";",
... | Removes the given username from the list of names for notifications
@param {string} username - The account name to check for
@param {string} channel - The channel to send notifications to
@returns {boolean} true if removed, false if didn't exist | [
"Removes",
"the",
"given",
"username",
"from",
"the",
"list",
"of",
"names",
"for",
"notifications"
] | 6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b | https://github.com/Insorum/hubot-youtube-feed/blob/6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b/src/lib/notification-list.js#L79-L114 | train | |
Insorum/hubot-youtube-feed | src/lib/notification-list.js | function (username, channel) {
var list = this.getUserNotifications(username);
// if we are not tracking the user there is no notifications
if (list === null) {
return false;
}
// return if the channel is in the users list
return list.indexOf(channel) >= 0;
... | javascript | function (username, channel) {
var list = this.getUserNotifications(username);
// if we are not tracking the user there is no notifications
if (list === null) {
return false;
}
// return if the channel is in the users list
return list.indexOf(channel) >= 0;
... | [
"function",
"(",
"username",
",",
"channel",
")",
"{",
"var",
"list",
"=",
"this",
".",
"getUserNotifications",
"(",
"username",
")",
";",
"// if we are not tracking the user there is no notifications",
"if",
"(",
"list",
"===",
"null",
")",
"{",
"return",
"false"... | Is the username setup for notifications?
@param {string} username - The account name to check for
@param {string} channel - The channel to notify in
@returns {boolean} true if in list, false otherwise | [
"Is",
"the",
"username",
"setup",
"for",
"notifications?"
] | 6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b | https://github.com/Insorum/hubot-youtube-feed/blob/6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b/src/lib/notification-list.js#L122-L131 | train | |
Insorum/hubot-youtube-feed | src/lib/notification-list.js | function (username) {
var channels = null;
// get the user's object
this.notifications.some(function (element) {
if (element.username === username) {
channels = element.channels;
return true;
}
return false;
});
... | javascript | function (username) {
var channels = null;
// get the user's object
this.notifications.some(function (element) {
if (element.username === username) {
channels = element.channels;
return true;
}
return false;
});
... | [
"function",
"(",
"username",
")",
"{",
"var",
"channels",
"=",
"null",
";",
"// get the user's object",
"this",
".",
"notifications",
".",
"some",
"(",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"username",
"===",
"username",
")",
"{"... | Returns a list of channels the user is notifying for or null if not found
@param {string} username
@returns {string[]|null} | [
"Returns",
"a",
"list",
"of",
"channels",
"the",
"user",
"is",
"notifying",
"for",
"or",
"null",
"if",
"not",
"found"
] | 6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b | https://github.com/Insorum/hubot-youtube-feed/blob/6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b/src/lib/notification-list.js#L138-L149 | train | |
savushkin-yauheni/our-connect | lib/connect.js | createServer | function createServer() {
function app(req, res, next){ app.handle(req, res, function(){
res.end("", 'utf8');
}); }
merge(app, proto);
merge(app, EventEmitter.prototype);
app.route = '/';
app.stack = [];
return app;
} | javascript | function createServer() {
function app(req, res, next){ app.handle(req, res, function(){
res.end("", 'utf8');
}); }
merge(app, proto);
merge(app, EventEmitter.prototype);
app.route = '/';
app.stack = [];
return app;
} | [
"function",
"createServer",
"(",
")",
"{",
"function",
"app",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"app",
".",
"handle",
"(",
"req",
",",
"res",
",",
"function",
"(",
")",
"{",
"res",
".",
"end",
"(",
"\"\"",
",",
"'utf8'",
")",
";",
... | Create a new connect server.
@return {Function}
@api public | [
"Create",
"a",
"new",
"connect",
"server",
"."
] | aa327a2a87a788535b1e5f6be5503a4419d3aabf | https://github.com/savushkin-yauheni/our-connect/blob/aa327a2a87a788535b1e5f6be5503a4419d3aabf/lib/connect.js#L27-L36 | train |
AndreasMadsen/thintalk | lib/core/abstract.js | Request | function Request(method, args, callback) {
this.handle.send('layer', [method, args], function (content) {
callback.apply({}, content);
});
} | javascript | function Request(method, args, callback) {
this.handle.send('layer', [method, args], function (content) {
callback.apply({}, content);
});
} | [
"function",
"Request",
"(",
"method",
",",
"args",
",",
"callback",
")",
"{",
"this",
".",
"handle",
".",
"send",
"(",
"'layer'",
",",
"[",
"method",
",",
"args",
"]",
",",
"function",
"(",
"content",
")",
"{",
"callback",
".",
"apply",
"(",
"{",
"... | Internal RPC - used by transport layers | [
"Internal",
"RPC",
"-",
"used",
"by",
"transport",
"layers"
] | 1ea0c2703d303874fc50d8efb2013ee4d7dadeb1 | https://github.com/AndreasMadsen/thintalk/blob/1ea0c2703d303874fc50d8efb2013ee4d7dadeb1/lib/core/abstract.js#L24-L28 | train |
jgnewman/brightsocket.io | bin/socketpool.js | runAsyncMiddleware | function runAsyncMiddleware(wares, event, payload, callback) {
if (wares.length) {
var ware = wares[0];
var restWares = wares.slice(1);
ware(event, payload, function () {
runAsyncMiddleware(restWares, event, payload, callback);
});
} else {
callback && callback(payload);
}
} | javascript | function runAsyncMiddleware(wares, event, payload, callback) {
if (wares.length) {
var ware = wares[0];
var restWares = wares.slice(1);
ware(event, payload, function () {
runAsyncMiddleware(restWares, event, payload, callback);
});
} else {
callback && callback(payload);
}
} | [
"function",
"runAsyncMiddleware",
"(",
"wares",
",",
"event",
",",
"payload",
",",
"callback",
")",
"{",
"if",
"(",
"wares",
".",
"length",
")",
"{",
"var",
"ware",
"=",
"wares",
"[",
"0",
"]",
";",
"var",
"restWares",
"=",
"wares",
".",
"slice",
"("... | Executes each function in a list of asynchronous functions. Each one
is given an argument we call `next`. The only way to get to the next
function in the list is to call `next`. If you don't, the process is
halted.
@param {Array} wares A list of possibly asynchronous functions.
@param {String} event The n... | [
"Executes",
"each",
"function",
"in",
"a",
"list",
"of",
"asynchronous",
"functions",
".",
"Each",
"one",
"is",
"given",
"an",
"argument",
"we",
"call",
"next",
".",
"The",
"only",
"way",
"to",
"get",
"to",
"the",
"next",
"function",
"in",
"the",
"list",... | 19ec67d69946ab09ca389143ebbdcb0a7f22f950 | https://github.com/jgnewman/brightsocket.io/blob/19ec67d69946ab09ca389143ebbdcb0a7f22f950/bin/socketpool.js#L95-L105 | train |
mridevteam/validity_checks | src/isEmptyObject.js | isEmptyObject | function isEmptyObject(item) {
if (item === undefined || item === null) {
return false;
}
return (Object.keys(item).length === 0 && JSON.stringify(item) === JSON.stringify({}));
} | javascript | function isEmptyObject(item) {
if (item === undefined || item === null) {
return false;
}
return (Object.keys(item).length === 0 && JSON.stringify(item) === JSON.stringify({}));
} | [
"function",
"isEmptyObject",
"(",
"item",
")",
"{",
"if",
"(",
"item",
"===",
"undefined",
"||",
"item",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"Object",
".",
"keys",
"(",
"item",
")",
".",
"length",
"===",
"0",
"&&",
... | Checks to see if a passed in item is an empty
http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
@param {*} item
@returns {boolean} isEmptyObject - is this value a pojo | [
"Checks",
"to",
"see",
"if",
"a",
"passed",
"in",
"item",
"is",
"an",
"empty"
] | e4990c7bbba23f5def0917f80990825748d054a1 | https://github.com/mridevteam/validity_checks/blob/e4990c7bbba23f5def0917f80990825748d054a1/src/isEmptyObject.js#L9-L15 | train |
redisjs/jsr-server | lib/command/server/info.js | execute | function execute(req, res) {
res.send(null, this.info.toString(req.args[0] ? '' + req.args[0] : null));
} | javascript | function execute(req, res) {
res.send(null, this.info.toString(req.args[0] ? '' + req.args[0] : null));
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"send",
"(",
"null",
",",
"this",
".",
"info",
".",
"toString",
"(",
"req",
".",
"args",
"[",
"0",
"]",
"?",
"''",
"+",
"req",
".",
"args",
"[",
"0",
"]",
":",
"null",
")",
... | Respond to the INFO command. | [
"Respond",
"to",
"the",
"INFO",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/info.js#L17-L19 | train |
tolokoban/ToloFrameWork | ker/mod/dom.fx.js | next | function next( session ) {
if ( session !== this._session ) return;
if ( this._index >= this._tasks.length ) {
this._index = 0;
this._started = false;
delete this._session;
this._onEnd( this );
return;
}
const
that = this,
tsk = this._tasks[ this.... | javascript | function next( session ) {
if ( session !== this._session ) return;
if ( this._index >= this._tasks.length ) {
this._index = 0;
this._started = false;
delete this._session;
this._onEnd( this );
return;
}
const
that = this,
tsk = this._tasks[ this.... | [
"function",
"next",
"(",
"session",
")",
"{",
"if",
"(",
"session",
"!==",
"this",
".",
"_session",
")",
"return",
";",
"if",
"(",
"this",
".",
"_index",
">=",
"this",
".",
"_tasks",
".",
"length",
")",
"{",
"this",
".",
"_index",
"=",
"0",
";",
... | Next step of the animation.
@this Fx
@param {object} session - ``{ $id }
@returns {undefined} | [
"Next",
"step",
"of",
"the",
"animation",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/dom.fx.js#L70-L92 | train |
tjmonsi/littleq-router | demo/script/main.js | combineReducers | function combineReducers(reducers) {
var reducerKeys = Object.keys(reducers);
var finalReducers = {};
for (var i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i];
if (process.env.NODE_ENV !== 'production') {
if (typeof reducers[key] === 'undefined') {
(0, _warning2.default)('No ... | javascript | function combineReducers(reducers) {
var reducerKeys = Object.keys(reducers);
var finalReducers = {};
for (var i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i];
if (process.env.NODE_ENV !== 'production') {
if (typeof reducers[key] === 'undefined') {
(0, _warning2.default)('No ... | [
"function",
"combineReducers",
"(",
"reducers",
")",
"{",
"var",
"reducerKeys",
"=",
"Object",
".",
"keys",
"(",
"reducers",
")",
";",
"var",
"finalReducers",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"reducerKeys",
".",
"l... | Turns an object whose values are different reducer functions, into a single
reducer function. It will call every child reducer, and gather their results
into a single state object, whose keys correspond to the keys of the passed
reducer functions.
@param {Object} reducers An object whose values correspond to different... | [
"Turns",
"an",
"object",
"whose",
"values",
"are",
"different",
"reducer",
"functions",
"into",
"a",
"single",
"reducer",
"function",
".",
"It",
"will",
"call",
"every",
"child",
"reducer",
"and",
"gather",
"their",
"results",
"into",
"a",
"single",
"state",
... | 38c766a6de8e3e061c7c3d359c995ec06336b4db | https://github.com/tjmonsi/littleq-router/blob/38c766a6de8e3e061c7c3d359c995ec06336b4db/demo/script/main.js#L2823-L2884 | train |
tjmonsi/littleq-router | demo/script/main.js | bind | function bind(element, properties) {
var bindings = Object.keys(properties).filter(function (name) {
var property = properties[name];
if (Object.prototype.hasOwnProperty.call(property, 'statePath')) {
if (!property.readOnly && property.notify) {
console.warn('PolymerRedux: <' + element... | javascript | function bind(element, properties) {
var bindings = Object.keys(properties).filter(function (name) {
var property = properties[name];
if (Object.prototype.hasOwnProperty.call(property, 'statePath')) {
if (!property.readOnly && property.notify) {
console.warn('PolymerRedux: <' + element... | [
"function",
"bind",
"(",
"element",
",",
"properties",
")",
"{",
"var",
"bindings",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
".",
"filter",
"(",
"function",
"(",
"name",
")",
"{",
"var",
"property",
"=",
"properties",
"[",
"name",
"]",
";",
... | Binds element's properties to state changes from the Redux store.
@example
const update = bind(el, props) // set bindings
update(state) // manual update
@private
@param {HTMLElement} element
@param {Object} properties
@return {Function} Update function. | [
"Binds",
"element",
"s",
"properties",
"to",
"state",
"changes",
"from",
"the",
"Redux",
"store",
"."
] | 38c766a6de8e3e061c7c3d359c995ec06336b4db | https://github.com/tjmonsi/littleq-router/blob/38c766a6de8e3e061c7c3d359c995ec06336b4db/demo/script/main.js#L3082-L3127 | train |
tjmonsi/littleq-router | demo/script/main.js | update | function update(state) {
var propertiesChanged = false;
bindings.forEach(function (name) {
// Perhaps .reduce() to a boolean?
var statePath = properties[name].statePath;
var value = typeof statePath === 'function' ? statePath.call(element, state) : (0, _path.get)(state, statePath);
... | javascript | function update(state) {
var propertiesChanged = false;
bindings.forEach(function (name) {
// Perhaps .reduce() to a boolean?
var statePath = properties[name].statePath;
var value = typeof statePath === 'function' ? statePath.call(element, state) : (0, _path.get)(state, statePath);
... | [
"function",
"update",
"(",
"state",
")",
"{",
"var",
"propertiesChanged",
"=",
"false",
";",
"bindings",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"// Perhaps .reduce() to a boolean?",
"var",
"statePath",
"=",
"properties",
"[",
"name",
"]",
".",... | Updates an element's properties with the given state.
@private
@param {Object} state | [
"Updates",
"an",
"element",
"s",
"properties",
"with",
"the",
"given",
"state",
"."
] | 38c766a6de8e3e061c7c3d359c995ec06336b4db | https://github.com/tjmonsi/littleq-router/blob/38c766a6de8e3e061c7c3d359c995ec06336b4db/demo/script/main.js#L3100-L3114 | train |
tjmonsi/littleq-router | demo/script/main.js | collect | function collect(what, which) {
var res = {};
while (what) {
res = Object.assign({}, what[which], res); // Respect prototype priority
what = Object.getPrototypeOf(what);
}
return res;
} | javascript | function collect(what, which) {
var res = {};
while (what) {
res = Object.assign({}, what[which], res); // Respect prototype priority
what = Object.getPrototypeOf(what);
}
return res;
} | [
"function",
"collect",
"(",
"what",
",",
"which",
")",
"{",
"var",
"res",
"=",
"{",
"}",
";",
"while",
"(",
"what",
")",
"{",
"res",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"what",
"[",
"which",
"]",
",",
"res",
")",
";",
"// Respect ... | Merges a property's object value using the defaults way.
@private
@param {Object} what Initial prototype
@param {String} which Property to collect.
@return {Object} the collected values | [
"Merges",
"a",
"property",
"s",
"object",
"value",
"using",
"the",
"defaults",
"way",
"."
] | 38c766a6de8e3e061c7c3d359c995ec06336b4db | https://github.com/tjmonsi/littleq-router/blob/38c766a6de8e3e061c7c3d359c995ec06336b4db/demo/script/main.js#L3150-L3157 | train |
vesln/r...e | lib/range.js | Range | function Range(min, max, step) {
var scope = null
, re = /^([A-Za-z]|\d+)\.{2}([A-Za-z]|\d+)$/;
if (typeof min === 'string' && min.match(re)) {
step = max;
scope = min.split('..');
min = cast(scope[0]);
max = cast(scope[1]);
}
this.min(min);
this.max(max);
this.step(step);
} | javascript | function Range(min, max, step) {
var scope = null
, re = /^([A-Za-z]|\d+)\.{2}([A-Za-z]|\d+)$/;
if (typeof min === 'string' && min.match(re)) {
step = max;
scope = min.split('..');
min = cast(scope[0]);
max = cast(scope[1]);
}
this.min(min);
this.max(max);
this.step(step);
} | [
"function",
"Range",
"(",
"min",
",",
"max",
",",
"step",
")",
"{",
"var",
"scope",
"=",
"null",
",",
"re",
"=",
"/",
"^([A-Za-z]|\\d+)\\.{2}([A-Za-z]|\\d+)$",
"/",
";",
"if",
"(",
"typeof",
"min",
"===",
"'string'",
"&&",
"min",
".",
"match",
"(",
"re... | Range constructor.
@param {Number|String} min
@param {Number|String} max
@param {Number} step
@constructor | [
"Range",
"constructor",
"."
] | e252b3b6341934d43571318ddaea0634a366a4bd | https://github.com/vesln/r...e/blob/e252b3b6341934d43571318ddaea0634a366a4bd/lib/range.js#L20-L34 | train |
rqt/ip | build/index.js | ip | async function ip(options = {}) {
const {
host = 'https://api.ipify.org',
} = options
const res = await rqt(host)
return res
} | javascript | async function ip(options = {}) {
const {
host = 'https://api.ipify.org',
} = options
const res = await rqt(host)
return res
} | [
"async",
"function",
"ip",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"{",
"host",
"=",
"'https://api.ipify.org'",
",",
"}",
"=",
"options",
"const",
"res",
"=",
"await",
"rqt",
"(",
"host",
")",
"return",
"res",
"}"
] | Returns a public IP address of the host.
@param {Options} options Options for the request.
@param {string} [options.host="https://api.ipify.org"] The address from which to get the IP address. Default `https://api.ipify.org`. | [
"Returns",
"a",
"public",
"IP",
"address",
"of",
"the",
"host",
"."
] | a4c927896e7718137c3bfdc1a39d83339e97a821 | https://github.com/rqt/ip/blob/a4c927896e7718137c3bfdc1a39d83339e97a821/build/index.js#L8-L14 | train |
b-heilman/bmoor | src/string.js | trim | function trim( str, chr ){
if ( !chr ){
chr = '\\s';
}
return str.replace( new RegExp('^'+chr+'+|'+chr+'+$','g'), '' );
} | javascript | function trim( str, chr ){
if ( !chr ){
chr = '\\s';
}
return str.replace( new RegExp('^'+chr+'+|'+chr+'+$','g'), '' );
} | [
"function",
"trim",
"(",
"str",
",",
"chr",
")",
"{",
"if",
"(",
"!",
"chr",
")",
"{",
"chr",
"=",
"'\\\\s'",
";",
"}",
"return",
"str",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"'^'",
"+",
"chr",
"+",
"'+|'",
"+",
"chr",
"+",
"'+$'",
",",
... | Array helper functions
@module bmoor.string | [
"Array",
"helper",
"functions"
] | b21a315b477093c14e5f32d857b4644a5a0a36fd | https://github.com/b-heilman/bmoor/blob/b21a315b477093c14e5f32d857b4644a5a0a36fd/src/string.js#L8-L13 | train |
robojones/better-events | lib/shareEvent.js | shareEvent | function shareEvent(eventName, source, target, once = false) {
verifyEventEmitter(source, 'source')
verifyEventEmitter(target, 'target')
const cb = target.emit.bind(target, eventName)
source[once ? 'once' : 'on'](eventName, cb)
return cb
} | javascript | function shareEvent(eventName, source, target, once = false) {
verifyEventEmitter(source, 'source')
verifyEventEmitter(target, 'target')
const cb = target.emit.bind(target, eventName)
source[once ? 'once' : 'on'](eventName, cb)
return cb
} | [
"function",
"shareEvent",
"(",
"eventName",
",",
"source",
",",
"target",
",",
"once",
"=",
"false",
")",
"{",
"verifyEventEmitter",
"(",
"source",
",",
"'source'",
")",
"verifyEventEmitter",
"(",
"target",
",",
"'target'",
")",
"const",
"cb",
"=",
"target",... | Share an event from the source with the target.
@param {string} eventName - The name of the event.
@param {*} source - The EventEmitter that emits the event.
@param {*} target - The EventEmitter that should also emit the event.
@param {boolean} [once] - Share the event only once.
@returns {function} - The callback that... | [
"Share",
"an",
"event",
"from",
"the",
"source",
"with",
"the",
"target",
"."
] | 78934b6f8506327b332325158a9bf83e8b541601 | https://github.com/robojones/better-events/blob/78934b6f8506327b332325158a9bf83e8b541601/lib/shareEvent.js#L11-L20 | train |
capsela/testpilot | lib/FileSystem.js | stat | function stat(p) {
var def = Q.defer();
fs.stat(p, def.makeNodeResolver());
return def.promise;
} | javascript | function stat(p) {
var def = Q.defer();
fs.stat(p, def.makeNodeResolver());
return def.promise;
} | [
"function",
"stat",
"(",
"p",
")",
"{",
"var",
"def",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"fs",
".",
"stat",
"(",
"p",
",",
"def",
".",
"makeNodeResolver",
"(",
")",
")",
";",
"return",
"def",
".",
"promise",
";",
"}"
] | Promise wrapper for fs.stat
@param p | [
"Promise",
"wrapper",
"for",
"fs",
".",
"stat"
] | 44f9527e6444236406fc0deac9b84ac420db3c1b | https://github.com/capsela/testpilot/blob/44f9527e6444236406fc0deac9b84ac420db3c1b/lib/FileSystem.js#L35-L39 | train |
capsela/testpilot | lib/FileSystem.js | list | function list(p) {
var def = Q.defer();
fs.readdir(p, def.makeNodeResolver());
return def.promise;
} | javascript | function list(p) {
var def = Q.defer();
fs.readdir(p, def.makeNodeResolver());
return def.promise;
} | [
"function",
"list",
"(",
"p",
")",
"{",
"var",
"def",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"fs",
".",
"readdir",
"(",
"p",
",",
"def",
".",
"makeNodeResolver",
"(",
")",
")",
";",
"return",
"def",
".",
"promise",
";",
"}"
] | Promise wrapper for fs.list
@param p | [
"Promise",
"wrapper",
"for",
"fs",
".",
"list"
] | 44f9527e6444236406fc0deac9b84ac420db3c1b | https://github.com/capsela/testpilot/blob/44f9527e6444236406fc0deac9b84ac420db3c1b/lib/FileSystem.js#L48-L52 | train |
capsela/testpilot | lib/FileSystem.js | writeFile | function writeFile(p, data, encoding) {
var def = Q.defer();
fs.writeFile(p, data, encoding, def.makeNodeResolver());
return def.promise
} | javascript | function writeFile(p, data, encoding) {
var def = Q.defer();
fs.writeFile(p, data, encoding, def.makeNodeResolver());
return def.promise
} | [
"function",
"writeFile",
"(",
"p",
",",
"data",
",",
"encoding",
")",
"{",
"var",
"def",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"fs",
".",
"writeFile",
"(",
"p",
",",
"data",
",",
"encoding",
",",
"def",
".",
"makeNodeResolver",
"(",
")",
")",
";... | Promise wrapper for fs.writeFile
@param p | [
"Promise",
"wrapper",
"for",
"fs",
".",
"writeFile"
] | 44f9527e6444236406fc0deac9b84ac420db3c1b | https://github.com/capsela/testpilot/blob/44f9527e6444236406fc0deac9b84ac420db3c1b/lib/FileSystem.js#L61-L65 | train |
capsela/testpilot | lib/FileSystem.js | readFile | function readFile(p, encoding) {
var def = Q.defer();
fs.readFile(p, encoding, def.makeNodeResolver());
return def.promise
} | javascript | function readFile(p, encoding) {
var def = Q.defer();
fs.readFile(p, encoding, def.makeNodeResolver());
return def.promise
} | [
"function",
"readFile",
"(",
"p",
",",
"encoding",
")",
"{",
"var",
"def",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"fs",
".",
"readFile",
"(",
"p",
",",
"encoding",
",",
"def",
".",
"makeNodeResolver",
"(",
")",
")",
";",
"return",
"def",
".",
"pr... | Promise wrapper for fs.readFile
@param p | [
"Promise",
"wrapper",
"for",
"fs",
".",
"readFile"
] | 44f9527e6444236406fc0deac9b84ac420db3c1b | https://github.com/capsela/testpilot/blob/44f9527e6444236406fc0deac9b84ac420db3c1b/lib/FileSystem.js#L74-L78 | train |
capsela/testpilot | lib/FileSystem.js | listTree | function listTree(basePath, guard) {
basePath = path.resolve(basePath);
return stat(basePath).then(
function(topStat) {
var results = [];
if (!guard || guard(basePath, topStat)) {
results.push(basePath);
}
if (topStat.isDirectory()) {
... | javascript | function listTree(basePath, guard) {
basePath = path.resolve(basePath);
return stat(basePath).then(
function(topStat) {
var results = [];
if (!guard || guard(basePath, topStat)) {
results.push(basePath);
}
if (topStat.isDirectory()) {
... | [
"function",
"listTree",
"(",
"basePath",
",",
"guard",
")",
"{",
"basePath",
"=",
"path",
".",
"resolve",
"(",
"basePath",
")",
";",
"return",
"stat",
"(",
"basePath",
")",
".",
"then",
"(",
"function",
"(",
"topStat",
")",
"{",
"var",
"results",
"=",
... | Independent implementation of Kris Kowal's Q-fs listTree method. Here
to avoid depending on the whole of Q-fs for one little function.
@param basePath
@param guard | [
"Independent",
"implementation",
"of",
"Kris",
"Kowal",
"s",
"Q",
"-",
"fs",
"listTree",
"method",
".",
"Here",
"to",
"avoid",
"depending",
"on",
"the",
"whole",
"of",
"Q",
"-",
"fs",
"for",
"one",
"little",
"function",
"."
] | 44f9527e6444236406fc0deac9b84ac420db3c1b | https://github.com/capsela/testpilot/blob/44f9527e6444236406fc0deac9b84ac420db3c1b/lib/FileSystem.js#L90-L126 | train |
ActiveObject/immutable-trie | src/common.js | popcount | function popcount(i) {
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
} | javascript | function popcount(i) {
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
} | [
"function",
"popcount",
"(",
"i",
")",
"{",
"i",
"=",
"i",
"-",
"(",
"(",
"i",
">>",
"1",
")",
"&",
"0x55555555",
")",
";",
"i",
"=",
"(",
"i",
"&",
"0x33333333",
")",
"+",
"(",
"(",
"i",
">>",
"2",
")",
"&",
"0x33333333",
")",
";",
"return... | Calculate Hamming weight for a given bitmap. Also known as 'population count'
operation.
@link http://stackoverflow.com/questions/109023/how-to-count-the-number-of-set-bits-in-a-32-bit-integer/109025#109025 | [
"Calculate",
"Hamming",
"weight",
"for",
"a",
"given",
"bitmap",
".",
"Also",
"known",
"as",
"population",
"count",
"operation",
"."
] | 11ced2a0d480eeb2f6dc89626f2a77798bb5cb58 | https://github.com/ActiveObject/immutable-trie/blob/11ced2a0d480eeb2f6dc89626f2a77798bb5cb58/src/common.js#L6-L10 | train |
ActiveObject/immutable-trie | src/common.js | insertAt | function insertAt(items, item, index) {
var copy = items.slice();
copy.splice(index, 0, item);
return copy;
} | javascript | function insertAt(items, item, index) {
var copy = items.slice();
copy.splice(index, 0, item);
return copy;
} | [
"function",
"insertAt",
"(",
"items",
",",
"item",
",",
"index",
")",
"{",
"var",
"copy",
"=",
"items",
".",
"slice",
"(",
")",
";",
"copy",
".",
"splice",
"(",
"index",
",",
"0",
",",
"item",
")",
";",
"return",
"copy",
";",
"}"
] | Insert item into position at given index.
Doesn't modify source array.
@param {Array} items
@param {*} item
@param {Number} index
@return {Array} | [
"Insert",
"item",
"into",
"position",
"at",
"given",
"index",
".",
"Doesn",
"t",
"modify",
"source",
"array",
"."
] | 11ced2a0d480eeb2f6dc89626f2a77798bb5cb58 | https://github.com/ActiveObject/immutable-trie/blob/11ced2a0d480eeb2f6dc89626f2a77798bb5cb58/src/common.js#L34-L38 | train |
ActiveObject/immutable-trie | src/common.js | replaceAt | function replaceAt(items, item, index) {
var copy = items.slice();
copy.splice(index, 1, item);
return copy;
} | javascript | function replaceAt(items, item, index) {
var copy = items.slice();
copy.splice(index, 1, item);
return copy;
} | [
"function",
"replaceAt",
"(",
"items",
",",
"item",
",",
"index",
")",
"{",
"var",
"copy",
"=",
"items",
".",
"slice",
"(",
")",
";",
"copy",
".",
"splice",
"(",
"index",
",",
"1",
",",
"item",
")",
";",
"return",
"copy",
";",
"}"
] | Replace array element at given index with new item.
Doesn't modify source array.
@param {Array} items
@param {*} item
@param {Number} index
@return {Array} | [
"Replace",
"array",
"element",
"at",
"given",
"index",
"with",
"new",
"item",
".",
"Doesn",
"t",
"modify",
"source",
"array",
"."
] | 11ced2a0d480eeb2f6dc89626f2a77798bb5cb58 | https://github.com/ActiveObject/immutable-trie/blob/11ced2a0d480eeb2f6dc89626f2a77798bb5cb58/src/common.js#L48-L52 | train |
ActiveObject/immutable-trie | src/common.js | removeAt | function removeAt(items, index) {
var copy = items.slice();
copy.splice(index, 1);
return copy;
} | javascript | function removeAt(items, index) {
var copy = items.slice();
copy.splice(index, 1);
return copy;
} | [
"function",
"removeAt",
"(",
"items",
",",
"index",
")",
"{",
"var",
"copy",
"=",
"items",
".",
"slice",
"(",
")",
";",
"copy",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"return",
"copy",
";",
"}"
] | Remove element from array at given index.
Doesn't modify source array.
@param {Array} items
@param {Number} index
@return {Array} | [
"Remove",
"element",
"from",
"array",
"at",
"given",
"index",
".",
"Doesn",
"t",
"modify",
"source",
"array",
"."
] | 11ced2a0d480eeb2f6dc89626f2a77798bb5cb58 | https://github.com/ActiveObject/immutable-trie/blob/11ced2a0d480eeb2f6dc89626f2a77798bb5cb58/src/common.js#L61-L65 | train |
ActiveObject/immutable-trie | src/common.js | find | function find(items, pred) {
var len = items.length,
i = -1;
while(++i < len) {
if (pred(items[i], i)) {
return items[i];
}
}
return null;
} | javascript | function find(items, pred) {
var len = items.length,
i = -1;
while(++i < len) {
if (pred(items[i], i)) {
return items[i];
}
}
return null;
} | [
"function",
"find",
"(",
"items",
",",
"pred",
")",
"{",
"var",
"len",
"=",
"items",
".",
"length",
",",
"i",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"i",
"<",
"len",
")",
"{",
"if",
"(",
"pred",
"(",
"items",
"[",
"i",
"]",
",",
"i",
")",
... | Find first element for which predicate is true
@param {Array} items
@param {Function} pred
@return {*} | [
"Find",
"first",
"element",
"for",
"which",
"predicate",
"is",
"true"
] | 11ced2a0d480eeb2f6dc89626f2a77798bb5cb58 | https://github.com/ActiveObject/immutable-trie/blob/11ced2a0d480eeb2f6dc89626f2a77798bb5cb58/src/common.js#L73-L84 | train |
AckerApple/ack-webpack | webpacker.js | watchCompiler | function watchCompiler(compiler, options={}){
let watching = false
log('Watch Building')
const startWatchTime = Date.now()
const watchConfig = { // watch options:
//aggregateTimeout: 300, // wait so long for more changes
//poll: true // use polling instead of native watchers
// pass a number to set ... | javascript | function watchCompiler(compiler, options={}){
let watching = false
log('Watch Building')
const startWatchTime = Date.now()
const watchConfig = { // watch options:
//aggregateTimeout: 300, // wait so long for more changes
//poll: true // use polling instead of native watchers
// pass a number to set ... | [
"function",
"watchCompiler",
"(",
"compiler",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"watching",
"=",
"false",
"log",
"(",
"'Watch Building'",
")",
"const",
"startWatchTime",
"=",
"Date",
".",
"now",
"(",
")",
"const",
"watchConfig",
"=",
"{",
"... | use npm watch for file watching
@options{
onRebuild
} | [
"use",
"npm",
"watch",
"for",
"file",
"watching"
] | 6c0a49dea358c992f18002deec430ef371ba5a95 | https://github.com/AckerApple/ack-webpack/blob/6c0a49dea358c992f18002deec430ef371ba5a95/webpacker.js#L111-L138 | train |
wunderbyte/grunt-spiritual-dox | src/js/guidox@wunderbyte.com/spirits/output/dox.TreeOutputSpirit.js | step4 | function step4 ( folder ) {
while ( folder.nodes.length === 1 && folder.nodes [ 0 ].nodes ) {
//folder.hidden = true;
folder = folder.nodes [ 0 ];
}
return folder;
} | javascript | function step4 ( folder ) {
while ( folder.nodes.length === 1 && folder.nodes [ 0 ].nodes ) {
//folder.hidden = true;
folder = folder.nodes [ 0 ];
}
return folder;
} | [
"function",
"step4",
"(",
"folder",
")",
"{",
"while",
"(",
"folder",
".",
"nodes",
".",
"length",
"===",
"1",
"&&",
"folder",
".",
"nodes",
"[",
"0",
"]",
".",
"nodes",
")",
"{",
"//folder.hidden = true;",
"folder",
"=",
"folder",
".",
"nodes",
"[",
... | Reduce to minimum viable root folder. | [
"Reduce",
"to",
"minimum",
"viable",
"root",
"folder",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/output/dox.TreeOutputSpirit.js#L86-L92 | train |
wunderbyte/grunt-spiritual-dox | src/js/guidox@wunderbyte.com/spirits/output/dox.TreeOutputSpirit.js | step5 | function step5 ( folder ) {
folder.filenames = folder.filenames || folder.nodes.map ( function ( node ) {
return node.nodes ? step5 ( node ).filenames : node.name.toLowerCase ();
}).join ( " " );
return folder;
} | javascript | function step5 ( folder ) {
folder.filenames = folder.filenames || folder.nodes.map ( function ( node ) {
return node.nodes ? step5 ( node ).filenames : node.name.toLowerCase ();
}).join ( " " );
return folder;
} | [
"function",
"step5",
"(",
"folder",
")",
"{",
"folder",
".",
"filenames",
"=",
"folder",
".",
"filenames",
"||",
"folder",
".",
"nodes",
".",
"map",
"(",
"function",
"(",
"node",
")",
"{",
"return",
"node",
".",
"nodes",
"?",
"step5",
"(",
"node",
")... | Preoptimize search by stamping descendant filenames onto folders. | [
"Preoptimize",
"search",
"by",
"stamping",
"descendant",
"filenames",
"onto",
"folders",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/output/dox.TreeOutputSpirit.js#L96-L101 | 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.