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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
redisjs/jsr-server | lib/command/connection/ping.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(args.length > 1) {
throw new CommandArgLength(cmd);
}
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(args.length > 1) {
throw new CommandArgLength(cmd);
}
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"args",
".",
"length",
">",
"1",
")",
"{",
"throw",
"new",... | Validate the PING command. | [
"Validate",
"the",
"PING",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/connection/ping.js#L19-L24 | train |
redisjs/jsr-server | lib/command/connection/ping.js | execute | function execute(req, res) {
if(req.args.length) return res.send(null, req.args[0]);
res.send(null, Constants.PONG);
} | javascript | function execute(req, res) {
if(req.args.length) return res.send(null, req.args[0]);
res.send(null, Constants.PONG);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"req",
".",
"args",
".",
"length",
")",
"return",
"res",
".",
"send",
"(",
"null",
",",
"req",
".",
"args",
"[",
"0",
"]",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Co... | Respond to the PING command. | [
"Respond",
"to",
"the",
"PING",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/connection/ping.js#L29-L32 | train |
olivoil/migrate-js | lib/migrate.js | defaultMigrationLoader | function defaultMigrationLoader(dir) {
let list = new List;
return new Promise((resolve, reject) => {
fs.readdir(dir, function(err, files) {
if (err) return reject(err);
const migrationFiles = files.filter((file) => file.match(/^\d+.*\.js$/)).sort();
... | javascript | function defaultMigrationLoader(dir) {
let list = new List;
return new Promise((resolve, reject) => {
fs.readdir(dir, function(err, files) {
if (err) return reject(err);
const migrationFiles = files.filter((file) => file.match(/^\d+.*\.js$/)).sort();
... | [
"function",
"defaultMigrationLoader",
"(",
"dir",
")",
"{",
"let",
"list",
"=",
"new",
"List",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"readdir",
"(",
"dir",
",",
"function",
"(",
"err",
",",
"f... | default migration loader.
load files from disk. | [
"default",
"migration",
"loader",
".",
"load",
"files",
"from",
"disk",
"."
] | 130b1afe7715696df2a7841769a19dbfb4966b78 | https://github.com/olivoil/migrate-js/blob/130b1afe7715696df2a7841769a19dbfb4966b78/lib/migrate.js#L16-L40 | train |
Tennu/tennu-admin | plugin.js | checkHostmask | function checkHostmask (hostmask, admin) {
return names.every(function (name) {
const result = admin[name].test(hostmask[name]);
client.debug("PluginAdmin", format("%s: %s, %s (%s)",
name, hostmask[name], admin[name], result));
return res... | javascript | function checkHostmask (hostmask, admin) {
return names.every(function (name) {
const result = admin[name].test(hostmask[name]);
client.debug("PluginAdmin", format("%s: %s, %s (%s)",
name, hostmask[name], admin[name], result));
return res... | [
"function",
"checkHostmask",
"(",
"hostmask",
",",
"admin",
")",
"{",
"return",
"names",
".",
"every",
"(",
"function",
"(",
"name",
")",
"{",
"const",
"result",
"=",
"admin",
"[",
"name",
"]",
".",
"test",
"(",
"hostmask",
"[",
"name",
"]",
")",
";"... | tennu.Client! -> Hostmask -> Admin -> boolean | [
"tennu",
".",
"Client!",
"-",
">",
"Hostmask",
"-",
">",
"Admin",
"-",
">",
"boolean"
] | 19d68570a0db845251877ee6f3b29f74678f7bbb | https://github.com/Tennu/tennu-admin/blob/19d68570a0db845251877ee6f3b29f74678f7bbb/plugin.js#L69-L78 | train |
Tennu/tennu-admin | plugin.js | function (hostmask, opts) {
return Promise.try(function () {
if (opts && opts.allowAll === true) {
return true;
}
const customAdmins = opts && opts.customAdmins;
const memoizationKey = opts && opts.memoizeOver;
... | javascript | function (hostmask, opts) {
return Promise.try(function () {
if (opts && opts.allowAll === true) {
return true;
}
const customAdmins = opts && opts.customAdmins;
const memoizationKey = opts && opts.memoizeOver;
... | [
"function",
"(",
"hostmask",
",",
"opts",
")",
"{",
"return",
"Promise",
".",
"try",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"opts",
"&&",
"opts",
".",
"allowAll",
"===",
"true",
")",
"{",
"return",
"true",
";",
"}",
"const",
"customAdmins",
"=",
... | Hostmask -> Promise boolean | [
"Hostmask",
"-",
">",
"Promise",
"boolean"
] | 19d68570a0db845251877ee6f3b29f74678f7bbb | https://github.com/Tennu/tennu-admin/blob/19d68570a0db845251877ee6f3b29f74678f7bbb/plugin.js#L84-L126 | train | |
vesln/obsessed | lib/obsessed-error.js | ObsessedError | function ObsessedError(message, errors) {
Error.captureStackTrace(this, ObsessedError);
this.message = this.combine(message, errors);
} | javascript | function ObsessedError(message, errors) {
Error.captureStackTrace(this, ObsessedError);
this.message = this.combine(message, errors);
} | [
"function",
"ObsessedError",
"(",
"message",
",",
"errors",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"ObsessedError",
")",
";",
"this",
".",
"message",
"=",
"this",
".",
"combine",
"(",
"message",
",",
"errors",
")",
";",
"}"
] | Custom error. Includes all error messages.
@param {String} message
@param {Array} errors
@constructor | [
"Custom",
"error",
".",
"Includes",
"all",
"error",
"messages",
"."
] | 4878dfafdea241bff9ad5c57acc2395a4f3487a6 | https://github.com/vesln/obsessed/blob/4878dfafdea241bff9ad5c57acc2395a4f3487a6/lib/obsessed-error.js#L10-L13 | train |
vkiding/judpack-lib | src/cordova/prepare.js | preparePlatforms | function preparePlatforms (platformList, projectRoot, options) {
return Q.all(platformList.map(function(platform) {
// TODO: this need to be replaced by real projectInfo
// instance for current project.
var project = {
root: projectRoot,
projectConfig: new ConfigParse... | javascript | function preparePlatforms (platformList, projectRoot, options) {
return Q.all(platformList.map(function(platform) {
// TODO: this need to be replaced by real projectInfo
// instance for current project.
var project = {
root: projectRoot,
projectConfig: new ConfigParse... | [
"function",
"preparePlatforms",
"(",
"platformList",
",",
"projectRoot",
",",
"options",
")",
"{",
"return",
"Q",
".",
"all",
"(",
"platformList",
".",
"map",
"(",
"function",
"(",
"platform",
")",
"{",
"// TODO: this need to be replaced by real projectInfo",
"// in... | Calls `platformApi.prepare` for each platform in project
@param {string[]} platformList List of platforms, added to current project
@param {string} projectRoot Project root directory
@return {Promise} | [
"Calls",
"platformApi",
".",
"prepare",
"for",
"each",
"platform",
"in",
"project"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/prepare.js#L80-L131 | train |
rowanmanning/mocha-srv | lib/mocha-srv.js | defaultOpts | function defaultOpts (opts) {
opts = opts || {};
opts.title = opts.title || 'Test Suite';
opts.ui = (opts.ui && opts.ui.toLowerCase() === 'tdd' ? 'tdd' : 'bdd');
opts.path = path.resolve(opts.path || '.');
opts.host = opts.host || 'localhost';
opts.port = opts.port || 3000;
return opts;
} | javascript | function defaultOpts (opts) {
opts = opts || {};
opts.title = opts.title || 'Test Suite';
opts.ui = (opts.ui && opts.ui.toLowerCase() === 'tdd' ? 'tdd' : 'bdd');
opts.path = path.resolve(opts.path || '.');
opts.host = opts.host || 'localhost';
opts.port = opts.port || 3000;
return opts;
} | [
"function",
"defaultOpts",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"opts",
".",
"title",
"=",
"opts",
".",
"title",
"||",
"'Test Suite'",
";",
"opts",
".",
"ui",
"=",
"(",
"opts",
".",
"ui",
"&&",
"opts",
".",
"ui",
".",
... | Default server options | [
"Default",
"server",
"options"
] | 47af5e5bc91bb37ba5ccdb0ea7cf1771748fdff2 | https://github.com/rowanmanning/mocha-srv/blob/47af5e5bc91bb37ba5ccdb0ea7cf1771748fdff2/lib/mocha-srv.js#L7-L15 | train |
AVVS/callback-queue | index.js | cleanup | function cleanup(key) {
callbackQueue[key] = null;
if (++nulls > nullThreshold) {
callbackQueue = omit(callbackQueue, function removeNulls(datum) {
return datum === null;
});
}
} | javascript | function cleanup(key) {
callbackQueue[key] = null;
if (++nulls > nullThreshold) {
callbackQueue = omit(callbackQueue, function removeNulls(datum) {
return datum === null;
});
}
} | [
"function",
"cleanup",
"(",
"key",
")",
"{",
"callbackQueue",
"[",
"key",
"]",
"=",
"null",
";",
"if",
"(",
"++",
"nulls",
">",
"nullThreshold",
")",
"{",
"callbackQueue",
"=",
"omit",
"(",
"callbackQueue",
",",
"function",
"removeNulls",
"(",
"datum",
"... | Performs cleanup on queue object
@param {String} key | [
"Performs",
"cleanup",
"on",
"queue",
"object"
] | 3edc65093812dd713f0a24c951dbfdd9e8ca6135 | https://github.com/AVVS/callback-queue/blob/3edc65093812dd713f0a24c951dbfdd9e8ca6135/index.js#L29-L36 | train |
AVVS/callback-queue | index.js | iterateOverCallbacks | function iterateOverCallbacks(bucket, args) {
bucket.forEach(function iterator(callback) {
nextTick(function queuedCallback() {
callback.apply(null, args);
});
});
} | javascript | function iterateOverCallbacks(bucket, args) {
bucket.forEach(function iterator(callback) {
nextTick(function queuedCallback() {
callback.apply(null, args);
});
});
} | [
"function",
"iterateOverCallbacks",
"(",
"bucket",
",",
"args",
")",
"{",
"bucket",
".",
"forEach",
"(",
"function",
"iterator",
"(",
"callback",
")",
"{",
"nextTick",
"(",
"function",
"queuedCallback",
"(",
")",
"{",
"callback",
".",
"apply",
"(",
"null",
... | Iterates over callbacks and calls them with passed args
@param {Array} bucket
@param {Array} args | [
"Iterates",
"over",
"callbacks",
"and",
"calls",
"them",
"with",
"passed",
"args"
] | 3edc65093812dd713f0a24c951dbfdd9e8ca6135 | https://github.com/AVVS/callback-queue/blob/3edc65093812dd713f0a24c951dbfdd9e8ca6135/index.js#L43-L49 | train |
vkiding/jud-vue-render | src/render/browser/render/gesture.js | touchstartHandler | function touchstartHandler(event) {
if (Object.keys(gestures).length === 0) {
docEl.addEventListener('touchmove', touchmoveHandler, false)
docEl.addEventListener('touchend', touchendHandler, false)
docEl.addEventListener('touchcancel', touchcancelHandler, false)
}
// record every touch
for (var i ... | javascript | function touchstartHandler(event) {
if (Object.keys(gestures).length === 0) {
docEl.addEventListener('touchmove', touchmoveHandler, false)
docEl.addEventListener('touchend', touchendHandler, false)
docEl.addEventListener('touchcancel', touchcancelHandler, false)
}
// record every touch
for (var i ... | [
"function",
"touchstartHandler",
"(",
"event",
")",
"{",
"if",
"(",
"Object",
".",
"keys",
"(",
"gestures",
")",
".",
"length",
"===",
"0",
")",
"{",
"docEl",
".",
"addEventListener",
"(",
"'touchmove'",
",",
"touchmoveHandler",
",",
"false",
")",
"docEl",... | take over the touchstart events. Add new touches to the gestures.
If there is no previous records, then bind touchmove, tochend
and touchcancel events.
new touches initialized with state 'tapping', and within 500 milliseconds
if the state is still tapping, then trigger gesture 'press'.
If there are two touche points, t... | [
"take",
"over",
"the",
"touchstart",
"events",
".",
"Add",
"new",
"touches",
"to",
"the",
"gestures",
".",
"If",
"there",
"is",
"no",
"previous",
"records",
"then",
"bind",
"touchmove",
"tochend",
"and",
"touchcancel",
"events",
".",
"new",
"touches",
"initi... | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/render/gesture.js#L121-L177 | train |
vkiding/jud-vue-render | src/render/browser/render/gesture.js | touchendHandler | function touchendHandler(event) {
if (Object.keys(gestures).length == 2) {
var elements = []
for (var p in gestures) {
elements.push(gestures[p].element)
}
fireEvent(getCommonAncestor(elements[0], elements[1]), 'dualtouchend', {
touches: slice.call(event.touches),
touchEvent: event
... | javascript | function touchendHandler(event) {
if (Object.keys(gestures).length == 2) {
var elements = []
for (var p in gestures) {
elements.push(gestures[p].element)
}
fireEvent(getCommonAncestor(elements[0], elements[1]), 'dualtouchend', {
touches: slice.call(event.touches),
touchEvent: event
... | [
"function",
"touchendHandler",
"(",
"event",
")",
"{",
"if",
"(",
"Object",
".",
"keys",
"(",
"gestures",
")",
".",
"length",
"==",
"2",
")",
"{",
"var",
"elements",
"=",
"[",
"]",
"for",
"(",
"var",
"p",
"in",
"gestures",
")",
"{",
"elements",
"."... | handle touchend event
1. if there are tow touch points, then trigger 'dualtouchend'如
2. traverse every touch piont:
> if tapping, then trigger 'tap'.
If there is a tap 300 milliseconds before, then it's a 'doubletap'.
> if padding, then decide to trigger 'panend' or 'swipe'
> if pressing, then trigger 'pressend'.
3.... | [
"handle",
"touchend",
"event"
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/render/gesture.js#L333-L422 | train |
fernandofranca/launchpod | lib/repl-utils.js | replWriter | function replWriter(output) {
if (output){
if (output.constructor && output.constructor.name !== "String"){
return util.inspect(output, {colors:true}) + '\n';
}
}
return output + '\n';
} | javascript | function replWriter(output) {
if (output){
if (output.constructor && output.constructor.name !== "String"){
return util.inspect(output, {colors:true}) + '\n';
}
}
return output + '\n';
} | [
"function",
"replWriter",
"(",
"output",
")",
"{",
"if",
"(",
"output",
")",
"{",
"if",
"(",
"output",
".",
"constructor",
"&&",
"output",
".",
"constructor",
".",
"name",
"!==",
"\"String\"",
")",
"{",
"return",
"util",
".",
"inspect",
"(",
"output",
... | Can I haz colorz?
Does objects pretty printing | [
"Can",
"I",
"haz",
"colorz?",
"Does",
"objects",
"pretty",
"printing"
] | 882d614a4271846e17b3ba0ca319340a607580bc | https://github.com/fernandofranca/launchpod/blob/882d614a4271846e17b3ba0ca319340a607580bc/lib/repl-utils.js#L9-L17 | train |
hiproxy/conf-parser | src/input.js | function (msg, line, column) {
this._info(line || this.line, column || this.column, msg, true, true);
} | javascript | function (msg, line, column) {
this._info(line || this.line, column || this.column, msg, true, true);
} | [
"function",
"(",
"msg",
",",
"line",
",",
"column",
")",
"{",
"this",
".",
"_info",
"(",
"line",
"||",
"this",
".",
"line",
",",
"column",
"||",
"this",
".",
"column",
",",
"msg",
",",
"true",
",",
"true",
")",
";",
"}"
] | print error message | [
"print",
"error",
"message"
] | fcfdde3b933afdbb573eb5f9e01baec7e489e7dc | https://github.com/hiproxy/conf-parser/blob/fcfdde3b933afdbb573eb5f9e01baec7e489e7dc/src/input.js#L56-L58 | train | |
tolokoban/ToloFrameWork | ker/mod/tfw.view.slider.js | xToValue | function xToValue(x) {
const
rect = this.$.getBoundingClientRect(),
percent = x / rect.width,
range = this.max - this.min,
value = Math.floor(percent * range + 0.5);
return this.min + this.step * Math.floor(value / this.step);
} | javascript | function xToValue(x) {
const
rect = this.$.getBoundingClientRect(),
percent = x / rect.width,
range = this.max - this.min,
value = Math.floor(percent * range + 0.5);
return this.min + this.step * Math.floor(value / this.step);
} | [
"function",
"xToValue",
"(",
"x",
")",
"{",
"const",
"rect",
"=",
"this",
".",
"$",
".",
"getBoundingClientRect",
"(",
")",
",",
"percent",
"=",
"x",
"/",
"rect",
".",
"width",
",",
"range",
"=",
"this",
".",
"max",
"-",
"this",
".",
"min",
",",
... | Convert a X position into the nearest value.
@this ViewXJS
@param {float} x - X position relative to the View.
@returns {integer} The nearest integer value. | [
"Convert",
"a",
"X",
"position",
"into",
"the",
"nearest",
"value",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.slider.js#L48-L55 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.view.slider.js | valueToX | function valueToX(value) {
const
rect = this.$.getBoundingClientRect(),
percent = (value - this.min) / (this.max - this.min);
return rect.width * percent;
} | javascript | function valueToX(value) {
const
rect = this.$.getBoundingClientRect(),
percent = (value - this.min) / (this.max - this.min);
return rect.width * percent;
} | [
"function",
"valueToX",
"(",
"value",
")",
"{",
"const",
"rect",
"=",
"this",
".",
"$",
".",
"getBoundingClientRect",
"(",
")",
",",
"percent",
"=",
"(",
"value",
"-",
"this",
".",
"min",
")",
"/",
"(",
"this",
".",
"max",
"-",
"this",
".",
"min",
... | Convert a value into X position relative to View.
@this ViewXJS
@param {integer} value - Current value.
@returns {float} X position. | [
"Convert",
"a",
"value",
"into",
"X",
"position",
"relative",
"to",
"View",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.slider.js#L64-L69 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.view.slider.js | onDrag | function onDrag(evt) {
const
rect = this._rect,
x = valueToX.call(this, this._value),
min = -x,
max = rect.width - x,
tx = clamp(evt.x - evt.x0, min, max),
value = xToValue.call(this, x + tx);
Dom.css(this.$elements.button, { transform: `translateX(${tx}px)` });
... | javascript | function onDrag(evt) {
const
rect = this._rect,
x = valueToX.call(this, this._value),
min = -x,
max = rect.width - x,
tx = clamp(evt.x - evt.x0, min, max),
value = xToValue.call(this, x + tx);
Dom.css(this.$elements.button, { transform: `translateX(${tx}px)` });
... | [
"function",
"onDrag",
"(",
"evt",
")",
"{",
"const",
"rect",
"=",
"this",
".",
"_rect",
",",
"x",
"=",
"valueToX",
".",
"call",
"(",
"this",
",",
"this",
".",
"_value",
")",
",",
"min",
"=",
"-",
"x",
",",
"max",
"=",
"rect",
".",
"width",
"-",... | Drag the button.
@this ViewXJS
@param {object} evt - `{ x, ... }`
@returns {undefined} | [
"Drag",
"the",
"button",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.slider.js#L90-L104 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.view.slider.js | onDragEnd | function onDragEnd(evt) {
this._dragging = false;
const
rect = this._rect,
x = valueToX.call(this, this._value),
min = -x,
max = rect.width - x,
tx = clamp(evt.x - evt.x0, min, max);
Dom.css(this.$elements.button, { transform: `translateX(0px)` });
this.value = x... | javascript | function onDragEnd(evt) {
this._dragging = false;
const
rect = this._rect,
x = valueToX.call(this, this._value),
min = -x,
max = rect.width - x,
tx = clamp(evt.x - evt.x0, min, max);
Dom.css(this.$elements.button, { transform: `translateX(0px)` });
this.value = x... | [
"function",
"onDragEnd",
"(",
"evt",
")",
"{",
"this",
".",
"_dragging",
"=",
"false",
";",
"const",
"rect",
"=",
"this",
".",
"_rect",
",",
"x",
"=",
"valueToX",
".",
"call",
"(",
"this",
",",
"this",
".",
"_value",
")",
",",
"min",
"=",
"-",
"x... | Enf of grag for the button. We can remove the temporaty translation.
@this ViewXJS
@param {object} evt - `{ x, ... }`
@returns {undefined} | [
"Enf",
"of",
"grag",
"for",
"the",
"button",
".",
"We",
"can",
"remove",
"the",
"temporaty",
"translation",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.slider.js#L113-L124 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.view.slider.js | moveToValue | function moveToValue(value) {
const left = 100 * (value - this.min) / (this.max - this.min);
Dom.css(this.$elements.button, { left: `${left}%` });
} | javascript | function moveToValue(value) {
const left = 100 * (value - this.min) / (this.max - this.min);
Dom.css(this.$elements.button, { left: `${left}%` });
} | [
"function",
"moveToValue",
"(",
"value",
")",
"{",
"const",
"left",
"=",
"100",
"*",
"(",
"value",
"-",
"this",
".",
"min",
")",
"/",
"(",
"this",
".",
"max",
"-",
"this",
".",
"min",
")",
";",
"Dom",
".",
"css",
"(",
"this",
".",
"$elements",
... | Move button to a position mapping the value.
@this ViewXJS
@param {integer} value - Value.
@returns {undefined} | [
"Move",
"button",
"to",
"a",
"position",
"mapping",
"the",
"value",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.slider.js#L144-L147 | train |
pattern-library/pattern-library-utilities | lib/get-category-path.js | categoryPathPlain | function categoryPathPlain(patternObject) {
'use strict';
// check for subcategory
if (patternObject.subcategory) {
return path.join(patternObject.category, patternObject.subcategory);
}
else {
return patternObject.category;
}
} | javascript | function categoryPathPlain(patternObject) {
'use strict';
// check for subcategory
if (patternObject.subcategory) {
return path.join(patternObject.category, patternObject.subcategory);
}
else {
return patternObject.category;
}
} | [
"function",
"categoryPathPlain",
"(",
"patternObject",
")",
"{",
"'use strict'",
";",
"// check for subcategory",
"if",
"(",
"patternObject",
".",
"subcategory",
")",
"{",
"return",
"path",
".",
"join",
"(",
"patternObject",
".",
"category",
",",
"patternObject",
... | Determines the category directory structure without any conversion
@param {Object} patternObject individual pattern's data (from /pattern-name/pattern.yml)
@return {String} categoryPath internal path url to category | [
"Determines",
"the",
"category",
"directory",
"structure",
"without",
"any",
"conversion"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/get-category-path.js#L58-L68 | train |
pattern-library/pattern-library-utilities | lib/get-category-path.js | categoryPathConverted | function categoryPathConverted(categoryObject, patternObject) {
'use strict';
// convert our category path using the categoryObject
var categoryPath = utility.categoryNameConverter(categoryObject.categories, patternObject.category);
// check for subcategory
if (patternObject.subcategory) {
var subcatego... | javascript | function categoryPathConverted(categoryObject, patternObject) {
'use strict';
// convert our category path using the categoryObject
var categoryPath = utility.categoryNameConverter(categoryObject.categories, patternObject.category);
// check for subcategory
if (patternObject.subcategory) {
var subcatego... | [
"function",
"categoryPathConverted",
"(",
"categoryObject",
",",
"patternObject",
")",
"{",
"'use strict'",
";",
"// convert our category path using the categoryObject",
"var",
"categoryPath",
"=",
"utility",
".",
"categoryNameConverter",
"(",
"categoryObject",
".",
"categori... | Determines the category directory structure by converting names according to a category object
@param {Object} categoryObject object of category names and their conversion titles
@param {Object} patternObject individual pattern's data (from /pattern-name/pattern.yml)
@return {String} categoryPath internal path url... | [
"Determines",
"the",
"category",
"directory",
"structure",
"by",
"converting",
"names",
"according",
"to",
"a",
"category",
"object"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/get-category-path.js#L79-L93 | train |
humanise-ai/botmaster-humanise-ware | examples/watson-fb-messenger/botmaster/middleware/wrapped/humanise.js | getHandoffFromUpdate | async function getHandoffFromUpdate (update) {
if (!has(update, 'message.text')) {
return
}
// having to do own request as watson-developer-cloud package is broken for
// Tone analyzer
const toneAnalyzerUrl = 'https://gateway.watsonplatform.net/tone-analyzer/api'
const params = {
// Get the text f... | javascript | async function getHandoffFromUpdate (update) {
if (!has(update, 'message.text')) {
return
}
// having to do own request as watson-developer-cloud package is broken for
// Tone analyzer
const toneAnalyzerUrl = 'https://gateway.watsonplatform.net/tone-analyzer/api'
const params = {
// Get the text f... | [
"async",
"function",
"getHandoffFromUpdate",
"(",
"update",
")",
"{",
"if",
"(",
"!",
"has",
"(",
"update",
",",
"'message.text'",
")",
")",
"{",
"return",
"}",
"// having to do own request as watson-developer-cloud package is broken for",
"// Tone analyzer",
"const",
"... | This is an example implementation of the getHandoffFromUpdate optional
parameter. In this example, we determine wether an update should be handed off
to a human based on the tone of a certain message | [
"This",
"is",
"an",
"example",
"implementation",
"of",
"the",
"getHandoffFromUpdate",
"optional",
"parameter",
".",
"In",
"this",
"example",
"we",
"determine",
"wether",
"an",
"update",
"should",
"be",
"handed",
"off",
"to",
"a",
"human",
"based",
"on",
"the",... | a94af55ace6a4c90f7f795d84d08ac7f2a920f82 | https://github.com/humanise-ai/botmaster-humanise-ware/blob/a94af55ace6a4c90f7f795d84d08ac7f2a920f82/examples/watson-fb-messenger/botmaster/middleware/wrapped/humanise.js#L28-L71 | train |
christkv/vitesse-jsonspec | lib/json_schema.js | function(path, obj) {
if(path == '#') return obj;
path = path.substr(1);
var parts = path.split('/');
parts.shift();
// Locate object
for(var i = 0; i < parts.length; i++) {
obj = obj[parts[i]];
}
return obj;
} | javascript | function(path, obj) {
if(path == '#') return obj;
path = path.substr(1);
var parts = path.split('/');
parts.shift();
// Locate object
for(var i = 0; i < parts.length; i++) {
obj = obj[parts[i]];
}
return obj;
} | [
"function",
"(",
"path",
",",
"obj",
")",
"{",
"if",
"(",
"path",
"==",
"'#'",
")",
"return",
"obj",
";",
"path",
"=",
"path",
".",
"substr",
"(",
"1",
")",
";",
"var",
"parts",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
";",
"parts",
".",
"... | Let's resolve the path | [
"Let",
"s",
"resolve",
"the",
"path"
] | 7c95dfac43b258b1a7ad6afb5bfe90eb95ef90b1 | https://github.com/christkv/vitesse-jsonspec/blob/7c95dfac43b258b1a7ad6afb5bfe90eb95ef90b1/lib/json_schema.js#L512-L524 | train | |
christkv/vitesse-jsonspec | lib/json_schema.js | function(reference, callback) {
var url = reference.url;
var uri = reference.uri;
var schema = reference.schema;
// Execute the request
request(url, function(error, response, body) {
// We have an error
if(error) return callback(error);
// Got the body, parse it
var obj = JS... | javascript | function(reference, callback) {
var url = reference.url;
var uri = reference.uri;
var schema = reference.schema;
// Execute the request
request(url, function(error, response, body) {
// We have an error
if(error) return callback(error);
// Got the body, parse it
var obj = JS... | [
"function",
"(",
"reference",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"reference",
".",
"url",
";",
"var",
"uri",
"=",
"reference",
".",
"uri",
";",
"var",
"schema",
"=",
"reference",
".",
"schema",
";",
"// Execute the request",
"request",
"(",
"u... | Grab the url | [
"Grab",
"the",
"url"
] | 7c95dfac43b258b1a7ad6afb5bfe90eb95ef90b1 | https://github.com/christkv/vitesse-jsonspec/blob/7c95dfac43b258b1a7ad6afb5bfe90eb95ef90b1/lib/json_schema.js#L527-L559 | train | |
christkv/vitesse-jsonspec | lib/json_schema.js | function(schema, field, reference, seenObjects, path, options) {
// Don't resolve recursive relation
if(reference == '#') return {$ref: '#'}
// Get the path
var path = reference.substr(1).split('/').slice(1);
path = path.map(function(x) {
x = x.replace(/~1/g, '/').replace(/~0/g, '~');
return decodeUR... | javascript | function(schema, field, reference, seenObjects, path, options) {
// Don't resolve recursive relation
if(reference == '#') return {$ref: '#'}
// Get the path
var path = reference.substr(1).split('/').slice(1);
path = path.map(function(x) {
x = x.replace(/~1/g, '/').replace(/~0/g, '~');
return decodeUR... | [
"function",
"(",
"schema",
",",
"field",
",",
"reference",
",",
"seenObjects",
",",
"path",
",",
"options",
")",
"{",
"// Don't resolve recursive relation",
"if",
"(",
"reference",
"==",
"'#'",
")",
"return",
"{",
"$ref",
":",
"'#'",
"}",
"// Get the path",
... | De-reference | [
"De",
"-",
"reference"
] | 7c95dfac43b258b1a7ad6afb5bfe90eb95ef90b1 | https://github.com/christkv/vitesse-jsonspec/blob/7c95dfac43b258b1a7ad6afb5bfe90eb95ef90b1/lib/json_schema.js#L610-L648 | train | |
csbun/grunt-cmd | lib/cmd.js | pathToId | function pathToId(file, base, rel) {
var id = rel ? path.resolve(rel, '..', file) : file;
id = path.relative(base, id);
// replace \ with / in windows' path and remove extname in path
id = id.replace(BACKLASH_RE, '/').replace(JS_EXT_RE, '');
return id;
} | javascript | function pathToId(file, base, rel) {
var id = rel ? path.resolve(rel, '..', file) : file;
id = path.relative(base, id);
// replace \ with / in windows' path and remove extname in path
id = id.replace(BACKLASH_RE, '/').replace(JS_EXT_RE, '');
return id;
} | [
"function",
"pathToId",
"(",
"file",
",",
"base",
",",
"rel",
")",
"{",
"var",
"id",
"=",
"rel",
"?",
"path",
".",
"resolve",
"(",
"rel",
",",
"'..'",
",",
"file",
")",
":",
"file",
";",
"id",
"=",
"path",
".",
"relative",
"(",
"base",
",",
"id... | Convert filepath to toplevel module id
@param {String} file - filepath to convert
@param {String} base - basepath of seajs
@param {String} [rel] - relative path of file
@returns {String} id | [
"Convert",
"filepath",
"to",
"toplevel",
"module",
"id"
] | a806eb8b890e4e6d218341fc4bd45fdd080375ca | https://github.com/csbun/grunt-cmd/blob/a806eb8b890e4e6d218341fc4bd45fdd080375ca/lib/cmd.js#L23-L29 | train |
csbun/grunt-cmd | lib/cmd.js | idToPath | function idToPath(id, config) {
var alias = config.alias || {};
return alias.hasOwnProperty(id) ?
path.resolve(alias[id]) :
path.resolve(config.base, id) + '.js';
} | javascript | function idToPath(id, config) {
var alias = config.alias || {};
return alias.hasOwnProperty(id) ?
path.resolve(alias[id]) :
path.resolve(config.base, id) + '.js';
} | [
"function",
"idToPath",
"(",
"id",
",",
"config",
")",
"{",
"var",
"alias",
"=",
"config",
".",
"alias",
"||",
"{",
"}",
";",
"return",
"alias",
".",
"hasOwnProperty",
"(",
"id",
")",
"?",
"path",
".",
"resolve",
"(",
"alias",
"[",
"id",
"]",
")",
... | Convert toplevel module id to filepath
@private | [
"Convert",
"toplevel",
"module",
"id",
"to",
"filepath"
] | a806eb8b890e4e6d218341fc4bd45fdd080375ca | https://github.com/csbun/grunt-cmd/blob/a806eb8b890e4e6d218341fc4bd45fdd080375ca/lib/cmd.js#L35-L40 | train |
writetome51/array-replace-adjacent-at | dist/index.js | replaceAdjacentAt | function replaceAdjacentAt(index, newValues, array) {
error_if_not_array_1.errorIfNotArray(newValues);
// The other parameters, index and array, are type-checked here:
array_replace_adjacent_items_1._replaceAdjacentItems(index, newValues.length, newValues, array);
} | javascript | function replaceAdjacentAt(index, newValues, array) {
error_if_not_array_1.errorIfNotArray(newValues);
// The other parameters, index and array, are type-checked here:
array_replace_adjacent_items_1._replaceAdjacentItems(index, newValues.length, newValues, array);
} | [
"function",
"replaceAdjacentAt",
"(",
"index",
",",
"newValues",
",",
"array",
")",
"{",
"error_if_not_array_1",
".",
"errorIfNotArray",
"(",
"newValues",
")",
";",
"// The other parameters, index and array, are type-checked here:",
"array_replace_adjacent_items_1",
".",
"_re... | Replaces adjacent items, beginning at `index`, with the same number of `newValues`, in `array`. `index` can be negative or positive. The number of adjacent items that get replaced equals `newValues.length`. | [
"Replaces",
"adjacent",
"items",
"beginning",
"at",
"index",
"with",
"the",
"same",
"number",
"of",
"newValues",
"in",
"array",
".",
"index",
"can",
"be",
"negative",
"or",
"positive",
".",
"The",
"number",
"of",
"adjacent",
"items",
"that",
"get",
"replaced... | 06d86d3b28adbd3ab2d82616beb7824f475c322e | https://github.com/writetome51/array-replace-adjacent-at/blob/06d86d3b28adbd3ab2d82616beb7824f475c322e/dist/index.js#L8-L12 | train |
integreat-io/great-uri-template | lib/filters/append.js | append | function append (value, string) {
if (
value === null || value === undefined || value === '' ||
string === null || string === undefined
) {
return value
}
return value + string
} | javascript | function append (value, string) {
if (
value === null || value === undefined || value === '' ||
string === null || string === undefined
) {
return value
}
return value + string
} | [
"function",
"append",
"(",
"value",
",",
"string",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
"||",
"value",
"===",
"''",
"||",
"string",
"===",
"null",
"||",
"string",
"===",
"undefined",
")",
"{",
"return",
"value... | Append the given string to the value, unless the value is empty.
@param {string} value - The value to append to
@returns {string} The appended result | [
"Append",
"the",
"given",
"string",
"to",
"the",
"value",
"unless",
"the",
"value",
"is",
"empty",
"."
] | 0e896ead0567737cf31a4a8b76a26cfa6ce60759 | https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/filters/append.js#L6-L14 | train |
WebArtWork/derer | lib/parser.js | TokenParser | function TokenParser(tokens, filters, autoescape, line, filename) {
this.out = [];
this.state = [];
this.filterApplyIdx = [];
this._parsers = {};
this.line = line;
this.filename = filename;
this.filters = filters;
this.escape = autoescape;
this.parse = function () {
var self = this;
if (self... | javascript | function TokenParser(tokens, filters, autoescape, line, filename) {
this.out = [];
this.state = [];
this.filterApplyIdx = [];
this._parsers = {};
this.line = line;
this.filename = filename;
this.filters = filters;
this.escape = autoescape;
this.parse = function () {
var self = this;
if (self... | [
"function",
"TokenParser",
"(",
"tokens",
",",
"filters",
",",
"autoescape",
",",
"line",
",",
"filename",
")",
"{",
"this",
".",
"out",
"=",
"[",
"]",
";",
"this",
".",
"state",
"=",
"[",
"]",
";",
"this",
".",
"filterApplyIdx",
"=",
"[",
"]",
";"... | Parse strings of variables and tags into tokens for future compilation.
@class
@param {array} tokens Pre-split tokens read by the Lexer.
@param {object} filters Keyed object of filters that may be applied to variables.
@param {boolean} autoescape Whether or not this should be autoescaped.
@param {number} lin... | [
"Parse",
"strings",
"of",
"variables",
"and",
"tags",
"into",
"tokens",
"for",
"future",
"compilation",
"."
] | edf9f82c8042b543e6f291f605430fac84702b2d | https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/parser.js#L60-L106 | train |
WebArtWork/derer | lib/parser.js | function (token, match, lastState) {
var self = this;
match = match.split('.');
if (_reserved.indexOf(match[0]) !== -1) {
utils.throwError('Reserved keyword "' + match[0] + '" attempted to be used as a variable', self.line, self.filename);
}
self.filterApplyIdx.push(self.out.length);
if... | javascript | function (token, match, lastState) {
var self = this;
match = match.split('.');
if (_reserved.indexOf(match[0]) !== -1) {
utils.throwError('Reserved keyword "' + match[0] + '" attempted to be used as a variable', self.line, self.filename);
}
self.filterApplyIdx.push(self.out.length);
if... | [
"function",
"(",
"token",
",",
"match",
",",
"lastState",
")",
"{",
"var",
"self",
"=",
"this",
";",
"match",
"=",
"match",
".",
"split",
"(",
"'.'",
")",
";",
"if",
"(",
"_reserved",
".",
"indexOf",
"(",
"match",
"[",
"0",
"]",
")",
"!==",
"-",
... | Parse variable token
@param {{match: string, type: number, line: number}} token Lexer token object.
@param {string} match Shortcut for token.match
@param {number} lastState Lexer token type state.
@return {undefined}
@private | [
"Parse",
"variable",
"token"
] | edf9f82c8042b543e6f291f605430fac84702b2d | https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/parser.js#L368-L387 | train | |
WebArtWork/derer | lib/parser.js | function (match) {
var temp = match[0], result;
function checkDot(ctx) {
var c = ctx + temp,
m = match,
build = '';
build = '(typeof ' + c + ' !== "undefined" && ' + c + ' !== null';
utils.each(m, function (v, i) {
if (i === 0) {
return;
}
bu... | javascript | function (match) {
var temp = match[0], result;
function checkDot(ctx) {
var c = ctx + temp,
m = match,
build = '';
build = '(typeof ' + c + ' !== "undefined" && ' + c + ' !== null';
utils.each(m, function (v, i) {
if (i === 0) {
return;
}
bu... | [
"function",
"(",
"match",
")",
"{",
"var",
"temp",
"=",
"match",
"[",
"0",
"]",
",",
"result",
";",
"function",
"checkDot",
"(",
"ctx",
")",
"{",
"var",
"c",
"=",
"ctx",
"+",
"temp",
",",
"m",
"=",
"match",
",",
"build",
"=",
"''",
";",
"build"... | Return contextual dot-check string for a match
@param {string} match Shortcut for token.match
@private | [
"Return",
"contextual",
"dot",
"-",
"check",
"string",
"for",
"a",
"match"
] | edf9f82c8042b543e6f291f605430fac84702b2d | https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/parser.js#L394-L420 | train | |
WebArtWork/derer | lib/parser.js | parseVariable | function parseVariable(str, line) {
var tokens = lexer.read(utils.strip(str)),
parser,
out;
parser = new TokenParser(tokens, filters, escape, line, opts.filename);
out = parser.parse().join('');
if (parser.state.length) {
utils.throwError('Unable to parse "' + str + '"', line, opts.f... | javascript | function parseVariable(str, line) {
var tokens = lexer.read(utils.strip(str)),
parser,
out;
parser = new TokenParser(tokens, filters, escape, line, opts.filename);
out = parser.parse().join('');
if (parser.state.length) {
utils.throwError('Unable to parse "' + str + '"', line, opts.f... | [
"function",
"parseVariable",
"(",
"str",
",",
"line",
")",
"{",
"var",
"tokens",
"=",
"lexer",
".",
"read",
"(",
"utils",
".",
"strip",
"(",
"str",
")",
")",
",",
"parser",
",",
"out",
";",
"parser",
"=",
"new",
"TokenParser",
"(",
"tokens",
",",
"... | Parse a variable.
@param {string} str String contents of the variable, between <i>{{</i> and <i>}}</i>
@param {number} line The line number that this variable starts on.
@return {VarToken} Parsed variable token object.
@private | [
"Parse",
"a",
"variable",
"."
] | edf9f82c8042b543e6f291f605430fac84702b2d | https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/parser.js#L481-L503 | train |
WebArtWork/derer | lib/parser.js | parseTag | function parseTag(str, line) {
var tokens, parser, chunks, tagName, tag, args, last;
if (utils.startsWith(str, 'end')) {
last = stack[stack.length - 1];
if (last && last.name === str.split(/\s+/)[0].replace(/^end/, '') && last.ends) {
switch (last.name) {
case 'autoescape':
... | javascript | function parseTag(str, line) {
var tokens, parser, chunks, tagName, tag, args, last;
if (utils.startsWith(str, 'end')) {
last = stack[stack.length - 1];
if (last && last.name === str.split(/\s+/)[0].replace(/^end/, '') && last.ends) {
switch (last.name) {
case 'autoescape':
... | [
"function",
"parseTag",
"(",
"str",
",",
"line",
")",
"{",
"var",
"tokens",
",",
"parser",
",",
"chunks",
",",
"tagName",
",",
"tag",
",",
"args",
",",
"last",
";",
"if",
"(",
"utils",
".",
"startsWith",
"(",
"str",
",",
"'end'",
")",
")",
"{",
"... | Parse a tag.
@param {string} str String contents of the tag, between <i>{%</i> and <i>%}</i>
@param {number} line The line number that this tag starts on.
@return {TagToken} Parsed token object.
@private | [
"Parse",
"a",
"tag",
"."
] | edf9f82c8042b543e6f291f605430fac84702b2d | https://github.com/WebArtWork/derer/blob/edf9f82c8042b543e6f291f605430fac84702b2d/lib/parser.js#L513-L606 | train |
vkiding/judpack-lib | src/platforms/PlatformApiPoly.js | getBuildArgs | function getBuildArgs(options) {
// if no options passed, empty object will be returned
if (!options) return [];
var downstreamArgs = [];
var argNames =[
'debug',
'release',
'device',
'emulator',
'nobuild',
'list'
];
argNames.forEach(function(fla... | javascript | function getBuildArgs(options) {
// if no options passed, empty object will be returned
if (!options) return [];
var downstreamArgs = [];
var argNames =[
'debug',
'release',
'device',
'emulator',
'nobuild',
'list'
];
argNames.forEach(function(fla... | [
"function",
"getBuildArgs",
"(",
"options",
")",
"{",
"// if no options passed, empty object will be returned",
"if",
"(",
"!",
"options",
")",
"return",
"[",
"]",
";",
"var",
"downstreamArgs",
"=",
"[",
"]",
";",
"var",
"argNames",
"=",
"[",
"'debug'",
",",
"... | Reconstructs the buildOptions tat will be passed along to platform scripts.
This is an ugly temporary fix. The code spawning or otherwise calling into
platform code should be dealing with this based on the parsed args object.
@param {Object} options A build options set, passed to `build` method
@return {String[]... | [
"Reconstructs",
"the",
"buildOptions",
"tat",
"will",
"be",
"passed",
"along",
"to",
"platform",
"scripts",
".",
"This",
"is",
"an",
"ugly",
"temporary",
"fix",
".",
"The",
"code",
"spawning",
"or",
"otherwise",
"calling",
"into",
"platform",
"code",
"should",... | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/platforms/PlatformApiPoly.js#L519-L551 | train |
vkiding/judpack-lib | src/platforms/PlatformApiPoly.js | getPlatformVersion | function getPlatformVersion (platformRoot) {
var versionFile = path.join(platformRoot, 'cordova/version');
if (!fs.existsSync(versionFile)) {
return null;
}
var version = shell.cat(versionFile).match(/VERSION\s=\s["'](.*)["'];/m);
return version && version[1];
} | javascript | function getPlatformVersion (platformRoot) {
var versionFile = path.join(platformRoot, 'cordova/version');
if (!fs.existsSync(versionFile)) {
return null;
}
var version = shell.cat(versionFile).match(/VERSION\s=\s["'](.*)["'];/m);
return version && version[1];
} | [
"function",
"getPlatformVersion",
"(",
"platformRoot",
")",
"{",
"var",
"versionFile",
"=",
"path",
".",
"join",
"(",
"platformRoot",
",",
"'cordova/version'",
")",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"versionFile",
")",
")",
"{",
"return",
... | Gets platform version from 'version' file
@param {String} platformRoot Platform location
@return {String|null} Stringified version of platform or null
if it is not possible to retrieve version | [
"Gets",
"platform",
"version",
"from",
"version",
"file"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/platforms/PlatformApiPoly.js#L732-L741 | train |
robojones/functs | functs.js | functs | function functs(...f) {
/**
* execute all included functions
* @param {...*} [args] - arguments passed to all included functions
* @returns {*[]}
*/
function functs(...args) {
return functs.run(this, args);
}
if(Array.isArray(f[0])) {
f = f[0];
}
functs.... | javascript | function functs(...f) {
/**
* execute all included functions
* @param {...*} [args] - arguments passed to all included functions
* @returns {*[]}
*/
function functs(...args) {
return functs.run(this, args);
}
if(Array.isArray(f[0])) {
f = f[0];
}
functs.... | [
"function",
"functs",
"(",
"...",
"f",
")",
"{",
"/**\n * execute all included functions\n * @param {...*} [args] - arguments passed to all included functions\n * @returns {*[]}\n */",
"function",
"functs",
"(",
"...",
"args",
")",
"{",
"return",
"functs",
".",
"r... | merge multiple functions into one
@param {...function} [f] - functions to merge
@returns {function} | [
"merge",
"multiple",
"functions",
"into",
"one"
] | ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6 | https://github.com/robojones/functs/blob/ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6/functs.js#L9-L30 | train |
robojones/functs | functs.js | add | function add(...f) {
if(Array.isArray(f[0])) {
f = f[0];
}
f = f.filter((f) => {
return typeof f === 'function';
});
this._f.push.apply(this._f, f);
return f;
} | javascript | function add(...f) {
if(Array.isArray(f[0])) {
f = f[0];
}
f = f.filter((f) => {
return typeof f === 'function';
});
this._f.push.apply(this._f, f);
return f;
} | [
"function",
"add",
"(",
"...",
"f",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"f",
"[",
"0",
"]",
")",
")",
"{",
"f",
"=",
"f",
"[",
"0",
"]",
";",
"}",
"f",
"=",
"f",
".",
"filter",
"(",
"(",
"f",
")",
"=>",
"{",
"return",
"ty... | add functions to the functs-object
@param {...function|function[]} f - functions to be added
@returns {function[]} | [
"add",
"functions",
"to",
"the",
"functs",
"-",
"object"
] | ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6 | https://github.com/robojones/functs/blob/ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6/functs.js#L38-L47 | train |
robojones/functs | functs.js | remove | function remove(...key) {
const self = this;
if(Array.isArray(key[0])) {
key = key[0];
}
key.forEach(k => {
self._f = self._f.filter(f => {
return f !== k;
});
});
} | javascript | function remove(...key) {
const self = this;
if(Array.isArray(key[0])) {
key = key[0];
}
key.forEach(k => {
self._f = self._f.filter(f => {
return f !== k;
});
});
} | [
"function",
"remove",
"(",
"...",
"key",
")",
"{",
"const",
"self",
"=",
"this",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"key",
"[",
"0",
"]",
")",
")",
"{",
"key",
"=",
"key",
"[",
"0",
"]",
";",
"}",
"key",
".",
"forEach",
"(",
"k",
... | remove functions from the functs-object
@param {...function|function[]} f - functions to be removed | [
"remove",
"functions",
"from",
"the",
"functs",
"-",
"object"
] | ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6 | https://github.com/robojones/functs/blob/ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6/functs.js#L54-L65 | train |
robojones/functs | functs.js | run | function run(thisArg, args) {
var end = -1;
const r = this._f.map((f, i) => {
if(end === -1) {
return f.apply(thisArg, args.concat(abort));
}
function abort() {
end = i;
}
});
if(end === -1) {
return r;
}
return r.slice(0, end);
} | javascript | function run(thisArg, args) {
var end = -1;
const r = this._f.map((f, i) => {
if(end === -1) {
return f.apply(thisArg, args.concat(abort));
}
function abort() {
end = i;
}
});
if(end === -1) {
return r;
}
return r.slice(0, end);
} | [
"function",
"run",
"(",
"thisArg",
",",
"args",
")",
"{",
"var",
"end",
"=",
"-",
"1",
";",
"const",
"r",
"=",
"this",
".",
"_f",
".",
"map",
"(",
"(",
"f",
",",
"i",
")",
"=>",
"{",
"if",
"(",
"end",
"===",
"-",
"1",
")",
"{",
"return",
... | execute all included functions
@param {*} thisArg - thisArg to be applied on all included functions
@param {*[]} args - array of arguments passed to all included functions | [
"execute",
"all",
"included",
"functions"
] | ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6 | https://github.com/robojones/functs/blob/ecb2d92f79cc1352a1f5ab90eb78c1c958295fe6/functs.js#L73-L88 | train |
wunderbyte/grunt-spiritual-edbml | tasks/things/outliner.js | parse | function parse(script, options, macros) {
var name = script.attr('id');
var text = script.text();
var atts = assistant.directives(script);
return compile(name, text, options, macros, atts);
} | javascript | function parse(script, options, macros) {
var name = script.attr('id');
var text = script.text();
var atts = assistant.directives(script);
return compile(name, text, options, macros, atts);
} | [
"function",
"parse",
"(",
"script",
",",
"options",
",",
"macros",
")",
"{",
"var",
"name",
"=",
"script",
".",
"attr",
"(",
"'id'",
")",
";",
"var",
"text",
"=",
"script",
".",
"text",
"(",
")",
";",
"var",
"atts",
"=",
"assistant",
".",
"directiv... | Parse single script.
@param {$} script
@param {???} macros
@returns {string} | [
"Parse",
"single",
"script",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/outliner.js#L120-L125 | train |
wunderbyte/grunt-spiritual-edbml | tasks/things/outliner.js | compile | function compile(name, edbml, options, macros, directives) {
var result = compiler.compile(edbml, options, macros, directives);
return assistant.declare(name, result);
} | javascript | function compile(name, edbml, options, macros, directives) {
var result = compiler.compile(edbml, options, macros, directives);
return assistant.declare(name, result);
} | [
"function",
"compile",
"(",
"name",
",",
"edbml",
",",
"options",
",",
"macros",
",",
"directives",
")",
"{",
"var",
"result",
"=",
"compiler",
".",
"compile",
"(",
"edbml",
",",
"options",
",",
"macros",
",",
"directives",
")",
";",
"return",
"assistant... | Compile EDBML to JS with directives.
@param {string} name
@param {string} edbml
@param {Map<string,object>} options
@param {Map<string,object>} options | [
"Compile",
"EDBML",
"to",
"JS",
"with",
"directives",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/outliner.js#L134-L137 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | addParams | function addParams(name,command,key,tag,emphasis)
{
var thisCssNo = buttons.length+1;
return buttons.push({name:name, cls:thisCssNo, command:command, key:key, tag:tag, emphasis:emphasis});
} | javascript | function addParams(name,command,key,tag,emphasis)
{
var thisCssNo = buttons.length+1;
return buttons.push({name:name, cls:thisCssNo, command:command, key:key, tag:tag, emphasis:emphasis});
} | [
"function",
"addParams",
"(",
"name",
",",
"command",
",",
"key",
",",
"tag",
",",
"emphasis",
")",
"{",
"var",
"thisCssNo",
"=",
"buttons",
".",
"length",
"+",
"1",
";",
"return",
"buttons",
".",
"push",
"(",
"{",
"name",
":",
"name",
",",
"cls",
... | insertion function for parameters to toolbar | [
"insertion",
"function",
"for",
"parameters",
"to",
"toolbar"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L118-L122 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selectionGet | function selectionGet()
{
// for webkit, mozilla, opera
if (window.getSelection)
return window.getSelection();
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
return document.selection.createRange();
} | javascript | function selectionGet()
{
// for webkit, mozilla, opera
if (window.getSelection)
return window.getSelection();
// for ie
else if (document.selection && document.selection.createRange && document.selection.type != "None")
return document.selection.createRange();
} | [
"function",
"selectionGet",
"(",
")",
"{",
"// for webkit, mozilla, opera\r",
"if",
"(",
"window",
".",
"getSelection",
")",
"return",
"window",
".",
"getSelection",
"(",
")",
";",
"// for ie\r",
"else",
"if",
"(",
"document",
".",
"selection",
"&&",
"document",... | get the selected text as plain format | [
"get",
"the",
"selected",
"text",
"as",
"plain",
"format"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L391-L399 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selectionSet | function selectionSet(addCommand,thirdParam)
{
var range,
sel = selectionGet();
// for webkit, mozilla, opera
if (window.getSelection)
{
if (sel.anchorNode && sel.getRangeAt)
range = sel.getRangeAt(0);
if(range)
{
sel.removeAllRanges();
sel.... | javascript | function selectionSet(addCommand,thirdParam)
{
var range,
sel = selectionGet();
// for webkit, mozilla, opera
if (window.getSelection)
{
if (sel.anchorNode && sel.getRangeAt)
range = sel.getRangeAt(0);
if(range)
{
sel.removeAllRanges();
sel.... | [
"function",
"selectionSet",
"(",
"addCommand",
",",
"thirdParam",
")",
"{",
"var",
"range",
",",
"sel",
"=",
"selectionGet",
"(",
")",
";",
"// for webkit, mozilla, opera\r",
"if",
"(",
"window",
".",
"getSelection",
")",
"{",
"if",
"(",
"sel",
".",
"anchorN... | the function of changing to the selected text with "execCommand" method | [
"the",
"function",
"of",
"changing",
"to",
"the",
"selected",
"text",
"with",
"execCommand",
"method"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L402-L434 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | replaceSelection | function replaceSelection(tTag,tAttr,tVal) {
// first, prevent to conflict of different jqte editors
if(editor.not(":focus"))
editor.focus();
// for webkit, mozilla, opera
if (window.getSelection)
{
var selObj = selectionGet(), selRange, newElement, documentFragment;
... | javascript | function replaceSelection(tTag,tAttr,tVal) {
// first, prevent to conflict of different jqte editors
if(editor.not(":focus"))
editor.focus();
// for webkit, mozilla, opera
if (window.getSelection)
{
var selObj = selectionGet(), selRange, newElement, documentFragment;
... | [
"function",
"replaceSelection",
"(",
"tTag",
",",
"tAttr",
",",
"tVal",
")",
"{",
"// first, prevent to conflict of different jqte editors\r",
"if",
"(",
"editor",
".",
"not",
"(",
"\":focus\"",
")",
")",
"editor",
".",
"focus",
"(",
")",
";",
"// for webkit, mozi... | the function of changing to the selected text with tags and tags's attributes | [
"the",
"function",
"of",
"changing",
"to",
"the",
"selected",
"text",
"with",
"tags",
"and",
"tags",
"s",
"attributes"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L437-L485 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | function() {
var node,selection;
if(window.getSelection) {
selection = getSelection();
node = selection.anchorNode;
}
if(!node && document.selection && document.selection.createRange && document.selection.type != "None")
{
selection = document.selection;
var range = sele... | javascript | function() {
var node,selection;
if(window.getSelection) {
selection = getSelection();
node = selection.anchorNode;
}
if(!node && document.selection && document.selection.createRange && document.selection.type != "None")
{
selection = document.selection;
var range = sele... | [
"function",
"(",
")",
"{",
"var",
"node",
",",
"selection",
";",
"if",
"(",
"window",
".",
"getSelection",
")",
"{",
"selection",
"=",
"getSelection",
"(",
")",
";",
"node",
"=",
"selection",
".",
"anchorNode",
";",
"}",
"if",
"(",
"!",
"node",
"&&",... | the function of getting to the parent tag | [
"the",
"function",
"of",
"getting",
"to",
"the",
"parent",
"tag"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L488-L506 | train | |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selectText | function selectText(element)
{
if(element)
{
var element = element[0];
if (document.body.createTextRange)
{
var range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
}
else if (window.getSelection)
{
... | javascript | function selectText(element)
{
if(element)
{
var element = element[0];
if (document.body.createTextRange)
{
var range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
}
else if (window.getSelection)
{
... | [
"function",
"selectText",
"(",
"element",
")",
"{",
"if",
"(",
"element",
")",
"{",
"var",
"element",
"=",
"element",
"[",
"0",
"]",
";",
"if",
"(",
"document",
".",
"body",
".",
"createTextRange",
")",
"{",
"var",
"range",
"=",
"document",
".",
"bod... | the function of making selected to a element | [
"the",
"function",
"of",
"making",
"selected",
"to",
"a",
"element"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L543-L575 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | selected2link | function selected2link()
{
if(!toolbar.data("sourceOpened"))
{
var selectedTag = getSelectedNode(); // the selected node
var thisHrefLink = "http://"; // default the input value of the link-form-field
// display the link-form-field
linkAreaSwitch(true);
if(selectedTag)
... | javascript | function selected2link()
{
if(!toolbar.data("sourceOpened"))
{
var selectedTag = getSelectedNode(); // the selected node
var thisHrefLink = "http://"; // default the input value of the link-form-field
// display the link-form-field
linkAreaSwitch(true);
if(selectedTag)
... | [
"function",
"selected2link",
"(",
")",
"{",
"if",
"(",
"!",
"toolbar",
".",
"data",
"(",
"\"sourceOpened\"",
")",
")",
"{",
"var",
"selectedTag",
"=",
"getSelectedNode",
"(",
")",
";",
"// the selected node\r",
"var",
"thisHrefLink",
"=",
"\"http://\"",
";",
... | the function of converting text to link | [
"the",
"function",
"of",
"converting",
"text",
"to",
"link"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L578-L656 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | linkAreaSwitch | function linkAreaSwitch(status)
{
// remove all pre-link attribute (mark as "link will be added")
clearSetElement("["+setdatalink+"]:not([href])");
jQTE.find("["+setdatalink+"][href]").removeAttr(setdatalink);
if(status)
{
toolbar.data("linkOpened",true);
linkform.show();
... | javascript | function linkAreaSwitch(status)
{
// remove all pre-link attribute (mark as "link will be added")
clearSetElement("["+setdatalink+"]:not([href])");
jQTE.find("["+setdatalink+"][href]").removeAttr(setdatalink);
if(status)
{
toolbar.data("linkOpened",true);
linkform.show();
... | [
"function",
"linkAreaSwitch",
"(",
"status",
")",
"{",
"// remove all pre-link attribute (mark as \"link will be added\")\r",
"clearSetElement",
"(",
"\"[\"",
"+",
"setdatalink",
"+",
"\"]:not([href])\"",
")",
";",
"jQTE",
".",
"find",
"(",
"\"[\"",
"+",
"setdatalink",
... | the function of switching link-form-field | [
"the",
"function",
"of",
"switching",
"link",
"-",
"form",
"-",
"field"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L698-L716 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | linkInputSet | function linkInputSet(thisHrefLink)
{
var currentType = linktypes.data("linktype");
// if selected type of e-mail
if(currentType=="1" && (linkinput.val()=="http://" || linkinput.is("[value^=http://]") || !linkinput.is("[value^=mailto]")))
linkinput.val("mailto:");
else if(currentTyp... | javascript | function linkInputSet(thisHrefLink)
{
var currentType = linktypes.data("linktype");
// if selected type of e-mail
if(currentType=="1" && (linkinput.val()=="http://" || linkinput.is("[value^=http://]") || !linkinput.is("[value^=mailto]")))
linkinput.val("mailto:");
else if(currentTyp... | [
"function",
"linkInputSet",
"(",
"thisHrefLink",
")",
"{",
"var",
"currentType",
"=",
"linktypes",
".",
"data",
"(",
"\"linktype\"",
")",
";",
"// if selected type of e-mail\r",
"if",
"(",
"currentType",
"==",
"\"1\"",
"&&",
"(",
"linkinput",
".",
"val",
"(",
... | the function of updating the link-input according to the link-type | [
"the",
"function",
"of",
"updating",
"the",
"link",
"-",
"input",
"according",
"to",
"the",
"link",
"-",
"type"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L728-L739 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | refuseStyle | function refuseStyle(refStyle)
{
var selectedTag = getSelectedNode(); // the selected node
// if the selected node have attribute of "style" and it have unwanted style
if(selectedTag && selectedTag.is("[style]") && selectedTag.css(refStyle)!="")
{
var refValue = selectedTag.css(refSt... | javascript | function refuseStyle(refStyle)
{
var selectedTag = getSelectedNode(); // the selected node
// if the selected node have attribute of "style" and it have unwanted style
if(selectedTag && selectedTag.is("[style]") && selectedTag.css(refStyle)!="")
{
var refValue = selectedTag.css(refSt... | [
"function",
"refuseStyle",
"(",
"refStyle",
")",
"{",
"var",
"selectedTag",
"=",
"getSelectedNode",
"(",
")",
";",
"// the selected node\r",
"// if the selected node have attribute of \"style\" and it have unwanted style\r",
"if",
"(",
"selectedTag",
"&&",
"selectedTag",
".",... | the function of refusing some styles | [
"the",
"function",
"of",
"refusing",
"some",
"styles"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L853-L872 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | formatLabelView | function formatLabelView(str)
{
var formatLabel = formatbar.closest("."+vars.css+"_tool").find("."+vars.css+"_tool_label").find("."+vars.css+"_tool_text");
if(str.length > 10)
str = str.substr(0,7) + "...";
// change format label of button
formatLabel.html(str);
} | javascript | function formatLabelView(str)
{
var formatLabel = formatbar.closest("."+vars.css+"_tool").find("."+vars.css+"_tool_label").find("."+vars.css+"_tool_text");
if(str.length > 10)
str = str.substr(0,7) + "...";
// change format label of button
formatLabel.html(str);
} | [
"function",
"formatLabelView",
"(",
"str",
")",
"{",
"var",
"formatLabel",
"=",
"formatbar",
".",
"closest",
"(",
"\".\"",
"+",
"vars",
".",
"css",
"+",
"\"_tool\"",
")",
".",
"find",
"(",
"\".\"",
"+",
"vars",
".",
"css",
"+",
"\"_tool_label\"",
")",
... | change format label | [
"change",
"format",
"label"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L912-L921 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | extractToText | function extractToText(strings)
{
var $htmlContent, $htmlPattern, $htmlReplace;
// first remove to unnecessary gaps
$htmlContent = strings.replace(/\n/gim,'').replace(/\r/gim,'').replace(/\t/gim,'').replace(/ /gim,' ');
$htmlPattern = [
/\<span(|\s+.*?)><span(|\s+.*?)>(.*?)<\/spa... | javascript | function extractToText(strings)
{
var $htmlContent, $htmlPattern, $htmlReplace;
// first remove to unnecessary gaps
$htmlContent = strings.replace(/\n/gim,'').replace(/\r/gim,'').replace(/\t/gim,'').replace(/ /gim,' ');
$htmlPattern = [
/\<span(|\s+.*?)><span(|\s+.*?)>(.*?)<\/spa... | [
"function",
"extractToText",
"(",
"strings",
")",
"{",
"var",
"$htmlContent",
",",
"$htmlPattern",
",",
"$htmlReplace",
";",
"// first remove to unnecessary gaps\r",
"$htmlContent",
"=",
"strings",
".",
"replace",
"(",
"/",
"\\n",
"/",
"gim",
",",
"''",
")",
"."... | the function of insertion a specific form to texts | [
"the",
"function",
"of",
"insertion",
"a",
"specific",
"form",
"to",
"texts"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L924-L985 | train |
epeios-q37/xdhelcq | js/jqte/uncompressed/jquery-te-1.4.0.js | buttonEmphasize | function buttonEmphasize(e)
{
for(var n = 0; n < buttons.length; n++)
{
if(vars[buttons[n].name] && buttons[n].emphasis && buttons[n].tag!='')
detectElement(buttons[n].tag) ? toolbar.find('.'+vars.css+'_tool_'+buttons[n].cls).addClass(emphasize) : $('.'+vars.css+'_tool_'+buttons[n].cls).r... | javascript | function buttonEmphasize(e)
{
for(var n = 0; n < buttons.length; n++)
{
if(vars[buttons[n].name] && buttons[n].emphasis && buttons[n].tag!='')
detectElement(buttons[n].tag) ? toolbar.find('.'+vars.css+'_tool_'+buttons[n].cls).addClass(emphasize) : $('.'+vars.css+'_tool_'+buttons[n].cls).r... | [
"function",
"buttonEmphasize",
"(",
"e",
")",
"{",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"buttons",
".",
"length",
";",
"n",
"++",
")",
"{",
"if",
"(",
"vars",
"[",
"buttons",
"[",
"n",
"]",
".",
"name",
"]",
"&&",
"buttons",
"[",
... | the function of highlighting the toolbar buttons according to the cursor position in jqte editor | [
"the",
"function",
"of",
"highlighting",
"the",
"toolbar",
"buttons",
"according",
"to",
"the",
"cursor",
"position",
"in",
"jqte",
"editor"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/jqte/uncompressed/jquery-te-1.4.0.js#L1031-L1064 | train |
glo-js/glo-shader | index.js | update | function update (opt) {
// remove old shaders
disposeShaders()
var quiet = opt.quiet
var attributeBindings = opt.attributes
var vertSrc = opt.vertex || defaultVertex
var fragSrc = opt.fragment || defaultFragment
// re-compile source
vertexShader = compileShader(gl, gl.VERTEX_SHADER, v... | javascript | function update (opt) {
// remove old shaders
disposeShaders()
var quiet = opt.quiet
var attributeBindings = opt.attributes
var vertSrc = opt.vertex || defaultVertex
var fragSrc = opt.fragment || defaultFragment
// re-compile source
vertexShader = compileShader(gl, gl.VERTEX_SHADER, v... | [
"function",
"update",
"(",
"opt",
")",
"{",
"// remove old shaders",
"disposeShaders",
"(",
")",
"var",
"quiet",
"=",
"opt",
".",
"quiet",
"var",
"attributeBindings",
"=",
"opt",
".",
"attributes",
"var",
"vertSrc",
"=",
"opt",
".",
"vertex",
"||",
"defaultV... | reload shader with new source code | [
"reload",
"shader",
"with",
"new",
"source",
"code"
] | 618a5c7b59dcafe9992656e22bb5aa8b69083e01 | https://github.com/glo-js/glo-shader/blob/618a5c7b59dcafe9992656e22bb5aa8b69083e01/index.js#L73-L134 | train |
GLcadet/react-webpack | utils/index.js | runCommand | function runCommand(cmd, args, options) {
return new Promise((resolve, reject) => {
const spwan = spawn(
cmd,
args,
Object.assign(
{
cwd: process.cwd(),
stdio: 'inherit',
shell: true,
},
options
)
)
spwan.on('exit', () => {
... | javascript | function runCommand(cmd, args, options) {
return new Promise((resolve, reject) => {
const spwan = spawn(
cmd,
args,
Object.assign(
{
cwd: process.cwd(),
stdio: 'inherit',
shell: true,
},
options
)
)
spwan.on('exit', () => {
... | [
"function",
"runCommand",
"(",
"cmd",
",",
"args",
",",
"options",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"spwan",
"=",
"spawn",
"(",
"cmd",
",",
"args",
",",
"Object",
".",
"assign",
"(",
... | Spawns a child process and runs the specified command
By default, runs in the CWD and inherits stdio
Options are the same as node's child_process.spawn
@param {string} cmd
@param {array<string>} args
@param {object} options | [
"Spawns",
"a",
"child",
"process",
"and",
"runs",
"the",
"specified",
"command",
"By",
"default",
"runs",
"in",
"the",
"CWD",
"and",
"inherits",
"stdio",
"Options",
"are",
"the",
"same",
"as",
"node",
"s",
"child_process",
".",
"spawn"
] | 7fe018edbee94350c532be979aee9cd6b4683d96 | https://github.com/GLcadet/react-webpack/blob/7fe018edbee94350c532be979aee9cd6b4683d96/utils/index.js#L116-L135 | train |
360fy/plugin-boilerplate | src/PluginLoader.js | existsFile | function existsFile(file, permission) {
return Promise.resolve(fsPromise.accessAsync(file, permission))
.then(() => true)
.catch(() => false);
} | javascript | function existsFile(file, permission) {
return Promise.resolve(fsPromise.accessAsync(file, permission))
.then(() => true)
.catch(() => false);
} | [
"function",
"existsFile",
"(",
"file",
",",
"permission",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"fsPromise",
".",
"accessAsync",
"(",
"file",
",",
"permission",
")",
")",
".",
"then",
"(",
"(",
")",
"=>",
"true",
")",
".",
"catch",
"(",
... | eslint-disable-line no-bitwise | [
"eslint",
"-",
"disable",
"-",
"line",
"no",
"-",
"bitwise"
] | 0145f099e68242ed38f7c385584b107e2ff5084f | https://github.com/360fy/plugin-boilerplate/blob/0145f099e68242ed38f7c385584b107e2ff5084f/src/PluginLoader.js#L46-L50 | train |
MaximTovstashev/brest | lib/utils/generate_returnable_error.js | generateReturnableError | function generateReturnableError(error) {
if (_.isError(error)) {
return {
body: {error: error.message},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
if (_.isString(error)) {
return {
body: {error},
options: {code: httpCodes.IN... | javascript | function generateReturnableError(error) {
if (_.isError(error)) {
return {
body: {error: error.message},
options: {code: httpCodes.INTERNAL_SERVER_ERROR}
};
}
if (_.isString(error)) {
return {
body: {error},
options: {code: httpCodes.IN... | [
"function",
"generateReturnableError",
"(",
"error",
")",
"{",
"if",
"(",
"_",
".",
"isError",
"(",
"error",
")",
")",
"{",
"return",
"{",
"body",
":",
"{",
"error",
":",
"error",
".",
"message",
"}",
",",
"options",
":",
"{",
"code",
":",
"httpCodes... | Generate proper returnable object according to received error type
@param {*} error
@return {Object} | [
"Generate",
"proper",
"returnable",
"object",
"according",
"to",
"received",
"error",
"type"
] | 9b0bd6ee452e55b86cd01d1647f0dff460ad191f | https://github.com/MaximTovstashev/brest/blob/9b0bd6ee452e55b86cd01d1647f0dff460ad191f/lib/utils/generate_returnable_error.js#L12-L49 | train |
vlad-zhukov/jepa | scripts/build.js | build | async function build() {
const clientConfig = await webpackConfig({target: 'web', env: 'prod'});
const serverConfig = await webpackConfig({target: 'node', env: 'prod'});
return new Promise((resolve, reject) => {
console.log('Compiling client...');
// eslint-disable-next-line consistent-ret... | javascript | async function build() {
const clientConfig = await webpackConfig({target: 'web', env: 'prod'});
const serverConfig = await webpackConfig({target: 'node', env: 'prod'});
return new Promise((resolve, reject) => {
console.log('Compiling client...');
// eslint-disable-next-line consistent-ret... | [
"async",
"function",
"build",
"(",
")",
"{",
"const",
"clientConfig",
"=",
"await",
"webpackConfig",
"(",
"{",
"target",
":",
"'web'",
",",
"env",
":",
"'prod'",
"}",
")",
";",
"const",
"serverConfig",
"=",
"await",
"webpackConfig",
"(",
"{",
"target",
"... | First compile the client. We need it to properly output assets.json (asset manifest file with the correct hashes on file names BEFORE we can start the server compiler. | [
"First",
"compile",
"the",
"client",
".",
"We",
"need",
"it",
"to",
"properly",
"output",
"assets",
".",
"json",
"(",
"asset",
"manifest",
"file",
"with",
"the",
"correct",
"hashes",
"on",
"file",
"names",
"BEFORE",
"we",
"can",
"start",
"the",
"server",
... | 356a23f1838ef27adeca003adec2dd3b8c25343e | https://github.com/vlad-zhukov/jepa/blob/356a23f1838ef27adeca003adec2dd3b8c25343e/scripts/build.js#L10-L76 | train |
jaredhanson/connect-lrdd | lib/link.js | Link | function Link(href, rel, type) {
if (typeof href == 'object') {
var options = href;
this.href = options.href;
this.template = options.template;
this.rel = options.rel;
this.type = options.type;
} else {
this.href = href;
this.rel = rel;
this.type = type;
}
this.titles = new Mu... | javascript | function Link(href, rel, type) {
if (typeof href == 'object') {
var options = href;
this.href = options.href;
this.template = options.template;
this.rel = options.rel;
this.type = options.type;
} else {
this.href = href;
this.rel = rel;
this.type = type;
}
this.titles = new Mu... | [
"function",
"Link",
"(",
"href",
",",
"rel",
",",
"type",
")",
"{",
"if",
"(",
"typeof",
"href",
"==",
"'object'",
")",
"{",
"var",
"options",
"=",
"href",
";",
"this",
".",
"href",
"=",
"options",
".",
"href",
";",
"this",
".",
"template",
"=",
... | `Link` constructor.
Constructs a new `Link` with the given `href`, `rel`, and `type`.
Alternatively, the link properties can be given as `options`.
Options:
- `href` uri reference
- `template` uri template
- `rel` link relation
- `type` media type
Examples:
new Link('http://services.example.com/aut... | [
"Link",
"constructor",
"."
] | 6d1f1f9b98cdd1ebc5fb3f048c4eddf5ef034ec1 | https://github.com/jaredhanson/connect-lrdd/blob/6d1f1f9b98cdd1ebc5fb3f048c4eddf5ef034ec1/lib/link.js#L32-L47 | train |
photokandyStudios/yasmf-emitter | lib/index.js | on | function on(evt, handler) {
var _this = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// if multiple events are passed, call our utility method `eachEvt` to deal with this.
// if it returns `true`, we should exit, because we're actually being cal... | javascript | function on(evt, handler) {
var _this = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// if multiple events are passed, call our utility method `eachEvt` to deal with this.
// if it returns `true`, we should exit, because we're actually being cal... | [
"function",
"on",
"(",
"evt",
",",
"handler",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"var",
"thisArg",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"null",
":",
"arguments",
"[",
"2",
"]",
";",
"// if multiple events are passed, call our ... | Registers a handler for one or more events bound to `thisArg`.
@param {string|Array<string>|Object} evt
@param {function} [handler]
@param {Object} [thisArg]
@throws {TypeError}
@returns {Emitter} | [
"Registers",
"a",
"handler",
"for",
"one",
"or",
"more",
"events",
"bound",
"to",
"thisArg",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L132-L177 | train |
photokandyStudios/yasmf-emitter | lib/index.js | off | function off(evt, handler) {
var _this2 = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// handle multiple events appropriately.
if (eachEvt(evt, handler, thisArg, function () {
for (var _len3 = arguments.length, _ = Array(_len3),... | javascript | function off(evt, handler) {
var _this2 = this;
var thisArg = arguments[2] === undefined ? null : arguments[2];
// handle multiple events appropriately.
if (eachEvt(evt, handler, thisArg, function () {
for (var _len3 = arguments.length, _ = Array(_len3),... | [
"function",
"off",
"(",
"evt",
",",
"handler",
")",
"{",
"var",
"_this2",
"=",
"this",
";",
"var",
"thisArg",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"null",
":",
"arguments",
"[",
"2",
"]",
";",
"// handle multiple events appropriately."... | Removes handlers from an event. This one is a bit complicated, because it supports various
overloads that do slightly different things.
* If `evt`, `handler`, and `thisArg` are supplied, the handler is removed as would be expected.
If no `thisArg` is supplied, the `handler` is removed from the `null` category.
* If `h... | [
"Removes",
"handlers",
"from",
"an",
"event",
".",
"This",
"one",
"is",
"a",
"bit",
"complicated",
"because",
"it",
"supports",
"various",
"overloads",
"that",
"do",
"slightly",
"different",
"things",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L197-L245 | train |
photokandyStudios/yasmf-emitter | lib/index.js | once | function once(evt, handler) {
var thisArg = arguments[2] === undefined ? null : arguments[2];
var wrapper = undefined,
self = this;
// add a wrapper around the handler and listen to the requested event
this.on(evt, wrapper = function () {
... | javascript | function once(evt, handler) {
var thisArg = arguments[2] === undefined ? null : arguments[2];
var wrapper = undefined,
self = this;
// add a wrapper around the handler and listen to the requested event
this.on(evt, wrapper = function () {
... | [
"function",
"once",
"(",
"evt",
",",
"handler",
")",
"{",
"var",
"thisArg",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"null",
":",
"arguments",
"[",
"2",
"]",
";",
"var",
"wrapper",
"=",
"undefined",
",",
"self",
"=",
"this",
";",
"... | Register a handler that will execute once for an event. Otherwise the same as `on`.
@param {string|Array<string>|Object} evt
@param {function} handler
@param {Object} [thisArg] | [
"Register",
"a",
"handler",
"that",
"will",
"execute",
"once",
"for",
"an",
"event",
".",
"Otherwise",
"the",
"same",
"as",
"on",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L255-L275 | train |
photokandyStudios/yasmf-emitter | lib/index.js | emitSyncFlag | function emitSyncFlag(evt, args) {
var _this3 = this;
var async = arguments[2] === undefined ? true : arguments[2];
var sender = this,
eH = this[_eventHandlers];
// emit locally first to onEvent handlers
try {
(function () {
... | javascript | function emitSyncFlag(evt, args) {
var _this3 = this;
var async = arguments[2] === undefined ? true : arguments[2];
var sender = this,
eH = this[_eventHandlers];
// emit locally first to onEvent handlers
try {
(function () {
... | [
"function",
"emitSyncFlag",
"(",
"evt",
",",
"args",
")",
"{",
"var",
"_this3",
"=",
"this",
";",
"var",
"async",
"=",
"arguments",
"[",
"2",
"]",
"===",
"undefined",
"?",
"true",
":",
"arguments",
"[",
"2",
"]",
";",
"var",
"sender",
"=",
"this",
... | Emit an event, specifying whether or not the event is synchronous or async.
@param {string} evt
@param {Array<*>} args
@param {boolean} [async] | [
"Emit",
"an",
"event",
"specifying",
"whether",
"or",
"not",
"the",
"event",
"is",
"synchronous",
"or",
"async",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L286-L370 | train |
photokandyStudios/yasmf-emitter | lib/index.js | allOffFor | function allOffFor(o) {
var eH = this[_eventHandlers];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = eH[Symbol.iterator](), _step; !(_iteratorNormalCompletion = ... | javascript | function allOffFor(o) {
var eH = this[_eventHandlers];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = eH[Symbol.iterator](), _step; !(_iteratorNormalCompletion = ... | [
"function",
"allOffFor",
"(",
"o",
")",
"{",
"var",
"eH",
"=",
"this",
"[",
"_eventHandlers",
"]",
";",
"var",
"_iteratorNormalCompletion",
"=",
"true",
";",
"var",
"_didIteratorError",
"=",
"false",
";",
"var",
"_iteratorError",
"=",
"undefined",
";",
"try"... | Removes all handlers for all events for the supplied object.
@param {Object} o
@returns {Emitter} | [
"Removes",
"all",
"handlers",
"for",
"all",
"events",
"for",
"the",
"supplied",
"object",
"."
] | f972cb6f0304a54a8c16626f2a850a2371384c18 | https://github.com/photokandyStudios/yasmf-emitter/blob/f972cb6f0304a54a8c16626f2a850a2371384c18/lib/index.js#L409-L442 | train |
novadiscovery/nway | lib/buildTree.js | builder | function builder(fromUID, node) {
debug('builder fromUID:%s',fromUID);
// Create a node (or use the provided one)
var node = node || new DepNode((packageId++).toString(), options);
// Get the entry point module object
var fromModule = findModule(fromUID);
// Add entry point to the module
node.addMod... | javascript | function builder(fromUID, node) {
debug('builder fromUID:%s',fromUID);
// Create a node (or use the provided one)
var node = node || new DepNode((packageId++).toString(), options);
// Get the entry point module object
var fromModule = findModule(fromUID);
// Add entry point to the module
node.addMod... | [
"function",
"builder",
"(",
"fromUID",
",",
"node",
")",
"{",
"debug",
"(",
"'builder fromUID:%s'",
",",
"fromUID",
")",
";",
"// Create a node (or use the provided one)",
"var",
"node",
"=",
"node",
"||",
"new",
"DepNode",
"(",
"(",
"packageId",
"++",
")",
".... | Build a module dependency tree
@param {string} fromUID Entry point module uniq id
@param {DepNode|null} node parent DepNode
@return {DepNode} A DepNode object (traversable as a DepNode tree)
@api public | [
"Build",
"a",
"module",
"dependency",
"tree"
] | fa31c6fe56f2305721e581ac25e8ac9a87e15dda | https://github.com/novadiscovery/nway/blob/fa31c6fe56f2305721e581ac25e8ac9a87e15dda/lib/buildTree.js#L73-L111 | train |
mattfenwick/clojarse-js | lib/ast.js | extract | function extract(token) {
var obj = {};
Object.keys(token).map(function(k) {
if ( !ignore.has(k) ) {
obj[k] = token[k];
}
});
return obj;
} | javascript | function extract(token) {
var obj = {};
Object.keys(token).map(function(k) {
if ( !ignore.has(k) ) {
obj[k] = token[k];
}
});
return obj;
} | [
"function",
"extract",
"(",
"token",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"token",
")",
".",
"map",
"(",
"function",
"(",
"k",
")",
"{",
"if",
"(",
"!",
"ignore",
".",
"has",
"(",
"k",
")",
")",
"{",
"obj",
... | make a copy of an object, minus certain keys | [
"make",
"a",
"copy",
"of",
"an",
"object",
"minus",
"certain",
"keys"
] | 750321d5b80bb4c1c4aeedf2b994699d2cdfb979 | https://github.com/mattfenwick/clojarse-js/blob/750321d5b80bb4c1c4aeedf2b994699d2cdfb979/lib/ast.js#L46-L54 | train |
MostlyJS/mostly-poplarjs | src/poplar.js | mergeListeners | function mergeListeners(emitter) {
var events = emitter._events;
_.each(events, function (fns, type) {
if (Array.isArray(fns)) {
_.each(fns, function (fn) {
if (_.isFunction(fn)) {
self.on(type, fn);
}
});
} else if (_.isFunction(fns)... | javascript | function mergeListeners(emitter) {
var events = emitter._events;
_.each(events, function (fns, type) {
if (Array.isArray(fns)) {
_.each(fns, function (fn) {
if (_.isFunction(fn)) {
self.on(type, fn);
}
});
} else if (_.isFunction(fns)... | [
"function",
"mergeListeners",
"(",
"emitter",
")",
"{",
"var",
"events",
"=",
"emitter",
".",
"_events",
";",
"_",
".",
"each",
"(",
"events",
",",
"function",
"(",
"fns",
",",
"type",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"fns",
")",
... | look up all ApiBuilder listeners then add it to api | [
"look",
"up",
"all",
"ApiBuilder",
"listeners",
"then",
"add",
"it",
"to",
"api"
] | bda12a72891e8c8d338e7560e7fe9e11ad74a2d9 | https://github.com/MostlyJS/mostly-poplarjs/blob/bda12a72891e8c8d338e7560e7fe9e11ad74a2d9/src/poplar.js#L87-L100 | train |
MostlyJS/mostly-poplarjs | src/poplar.js | mergeMethods | function mergeMethods(builder) {
var methods = builder.methods();
_.each(methods, function (fn, methodName) {
// e.g.: users.getUserInfo
self._methods[util.format('%s.%s', name, methodName)] = fn;
});
} | javascript | function mergeMethods(builder) {
var methods = builder.methods();
_.each(methods, function (fn, methodName) {
// e.g.: users.getUserInfo
self._methods[util.format('%s.%s', name, methodName)] = fn;
});
} | [
"function",
"mergeMethods",
"(",
"builder",
")",
"{",
"var",
"methods",
"=",
"builder",
".",
"methods",
"(",
")",
";",
"_",
".",
"each",
"(",
"methods",
",",
"function",
"(",
"fn",
",",
"methodName",
")",
"{",
"// e.g.: users.getUserInfo",
"self",
".",
"... | look up all ApiBuilder methods then add it to api | [
"look",
"up",
"all",
"ApiBuilder",
"methods",
"then",
"add",
"it",
"to",
"api"
] | bda12a72891e8c8d338e7560e7fe9e11ad74a2d9 | https://github.com/MostlyJS/mostly-poplarjs/blob/bda12a72891e8c8d338e7560e7fe9e11ad74a2d9/src/poplar.js#L103-L109 | train |
vesln/surround | lib/surround.js | Surround | function Surround(obj, pattern) {
var self = this;
var regEX = new RegExp(pattern);
for(var fn in obj) {
var orig = obj[fn];
if (typeof(orig) != "function" || !regEX.test(fn))
continue;
// Already surrouneded.
if (obj[fn].__stacks) {
this.stacks = obj[fn].__stacks;
return thi... | javascript | function Surround(obj, pattern) {
var self = this;
var regEX = new RegExp(pattern);
for(var fn in obj) {
var orig = obj[fn];
if (typeof(orig) != "function" || !regEX.test(fn))
continue;
// Already surrouneded.
if (obj[fn].__stacks) {
this.stacks = obj[fn].__stacks;
return thi... | [
"function",
"Surround",
"(",
"obj",
",",
"pattern",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"regEX",
"=",
"new",
"RegExp",
"(",
"pattern",
")",
";",
"for",
"(",
"var",
"fn",
"in",
"obj",
")",
"{",
"var",
"orig",
"=",
"obj",
"[",
"fn",
... | Surround constructor.
@param {Object} Object
@param {Pattern} pattern
@constructor | [
"Surround",
"constructor",
"."
] | 665c261c0929610b3133a6746341522b59c5065f | https://github.com/vesln/surround/blob/665c261c0929610b3133a6746341522b59c5065f/lib/surround.js#L10-L47 | train |
raincatcher-beta/raincatcher-file | lib/cloud/services/fileService.js | createTemporaryStorageFolder | function createTemporaryStorageFolder() {
fs.mkdir(imageDir, '0775', function(err) {
if (err && err.code !== 'EEXIST') {
console.log(err);
throw new Error(err);
}
});
} | javascript | function createTemporaryStorageFolder() {
fs.mkdir(imageDir, '0775', function(err) {
if (err && err.code !== 'EEXIST') {
console.log(err);
throw new Error(err);
}
});
} | [
"function",
"createTemporaryStorageFolder",
"(",
")",
"{",
"fs",
".",
"mkdir",
"(",
"imageDir",
",",
"'0775'",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"&&",
"err",
".",
"code",
"!==",
"'EEXIST'",
")",
"{",
"console",
".",
"log",
"(",
... | Create temporary storage folder used by mutler to store files before
uploading to permanent storage | [
"Create",
"temporary",
"storage",
"folder",
"used",
"by",
"mutler",
"to",
"store",
"files",
"before",
"uploading",
"to",
"permanent",
"storage"
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/cloud/services/fileService.js#L15-L22 | train |
raincatcher-beta/raincatcher-file | lib/cloud/services/fileService.js | writeStreamToFile | function writeStreamToFile(fileMeta, stream) {
var deferred = q.defer();
stream.on('end', function() {
deferred.resolve(fileMeta);
});
stream.on('error', function(error) {
deferred.reject(error);
});
var filename = imageDir + '/' + fileMeta.uid;
stream.pipe(fs.createWriteStream(filename));
retur... | javascript | function writeStreamToFile(fileMeta, stream) {
var deferred = q.defer();
stream.on('end', function() {
deferred.resolve(fileMeta);
});
stream.on('error', function(error) {
deferred.reject(error);
});
var filename = imageDir + '/' + fileMeta.uid;
stream.pipe(fs.createWriteStream(filename));
retur... | [
"function",
"writeStreamToFile",
"(",
"fileMeta",
",",
"stream",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"stream",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"deferred",
".",
"resolve",
"(",
"fileMeta",
")",
... | Utility function for saving file in temp folder
@param fileMeta
@param stream | [
"Utility",
"function",
"for",
"saving",
"file",
"in",
"temp",
"folder"
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/cloud/services/fileService.js#L29-L40 | train |
raincatcher-beta/raincatcher-file | lib/cloud/services/fileService.js | parseBase64Stream | function parseBase64Stream(req) {
var passthrough = false;
var accumulation = '';
var stream = req.pipe(through(function(chunk, enc, callback) {
if (!passthrough) {
accumulation += chunk;
var test = ';base64,';
var index = accumulation.indexOf(test);
if (index > -1) {
passthrou... | javascript | function parseBase64Stream(req) {
var passthrough = false;
var accumulation = '';
var stream = req.pipe(through(function(chunk, enc, callback) {
if (!passthrough) {
accumulation += chunk;
var test = ';base64,';
var index = accumulation.indexOf(test);
if (index > -1) {
passthrou... | [
"function",
"parseBase64Stream",
"(",
"req",
")",
"{",
"var",
"passthrough",
"=",
"false",
";",
"var",
"accumulation",
"=",
"''",
";",
"var",
"stream",
"=",
"req",
".",
"pipe",
"(",
"through",
"(",
"function",
"(",
"chunk",
",",
"enc",
",",
"callback",
... | Parse Base64 URL into stream that can be saved as file.
@param req | [
"Parse",
"Base64",
"URL",
"into",
"stream",
"that",
"can",
"be",
"saved",
"as",
"file",
"."
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/cloud/services/fileService.js#L47-L67 | train |
dgeorges/modeljs | src/model.js | function (thisProperty, callbackArgs) {
return function (callback) {
function notifyListener() {
if (Model.asyncEvents) {
setTimeout(function () {
callback.apply(thisProperty, callbackArgs);
... | javascript | function (thisProperty, callbackArgs) {
return function (callback) {
function notifyListener() {
if (Model.asyncEvents) {
setTimeout(function () {
callback.apply(thisProperty, callbackArgs);
... | [
"function",
"(",
"thisProperty",
",",
"callbackArgs",
")",
"{",
"return",
"function",
"(",
"callback",
")",
"{",
"function",
"notifyListener",
"(",
")",
"{",
"if",
"(",
"Model",
".",
"asyncEvents",
")",
"{",
"setTimeout",
"(",
"function",
"(",
")",
"{",
... | This weird executeCallback function is a bit more complicated than it needs to be but is used to get around the JSLint warning of creating a function within the while loop below | [
"This",
"weird",
"executeCallback",
"function",
"is",
"a",
"bit",
"more",
"complicated",
"than",
"it",
"needs",
"to",
"be",
"but",
"is",
"used",
"to",
"get",
"around",
"the",
"JSLint",
"warning",
"of",
"creating",
"a",
"function",
"within",
"the",
"while",
... | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L218-L255 | train | |
dgeorges/modeljs | src/model.js | Property | function Property (name, value, parent, metadata) {
var myName = "/" + name;
if (parent) {
myName = parent.getName() + myName;
}
Object.defineProperty(this, "_name", {
value: myName,
enumerable: false
});
Object.definePro... | javascript | function Property (name, value, parent, metadata) {
var myName = "/" + name;
if (parent) {
myName = parent.getName() + myName;
}
Object.defineProperty(this, "_name", {
value: myName,
enumerable: false
});
Object.definePro... | [
"function",
"Property",
"(",
"name",
",",
"value",
",",
"parent",
",",
"metadata",
")",
"{",
"var",
"myName",
"=",
"\"/\"",
"+",
"name",
";",
"if",
"(",
"parent",
")",
"{",
"myName",
"=",
"parent",
".",
"getName",
"(",
")",
"+",
"myName",
";",
"}",... | A Property is a name value pair belonging to a Model.
@class Property
@constructor
@private used internally by the Model.prototype.createProperty method.
@param {[String]} name The name of the property
@param {[String, Boolean, Number, null, Date, Function, Object]} value The Property Value
@param {[Model]} pare... | [
"A",
"Property",
"is",
"a",
"name",
"value",
"pair",
"belonging",
"to",
"a",
"Model",
"."
] | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L441-L494 | train |
dgeorges/modeljs | src/model.js | Model | function Model(json, metadata, parent) {
var jsonModel = json || {},
modelMetadata = metadata || {},
modelName = modelMetadata.name !== undefined? modelMetadata.name : "root",
modelParent = parent || null;
if (modelMetadata.name) { // name is not part of the me... | javascript | function Model(json, metadata, parent) {
var jsonModel = json || {},
modelMetadata = metadata || {},
modelName = modelMetadata.name !== undefined? modelMetadata.name : "root",
modelParent = parent || null;
if (modelMetadata.name) { // name is not part of the me... | [
"function",
"Model",
"(",
"json",
",",
"metadata",
",",
"parent",
")",
"{",
"var",
"jsonModel",
"=",
"json",
"||",
"{",
"}",
",",
"modelMetadata",
"=",
"metadata",
"||",
"{",
"}",
",",
"modelName",
"=",
"modelMetadata",
".",
"name",
"!==",
"undefined",
... | The model Object that wraps the JSON.
@example
For examples see: <b>testPrimitiveSaveLoad</b>, <b>testObjectsSaveLoad</b>, <b>testComplexSaveLoad</b>
<b>testGetNameMethod</b> and <b>testSaveLoadWithMetaData</b>
@class Model
@constructor
@extends Property
@param {Object} json? The json object to be modeled.
@para... | [
"The",
"model",
"Object",
"that",
"wraps",
"the",
"JSON",
"."
] | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L1010-L1038 | train |
dgeorges/modeljs | src/model.js | propergateEvent | function propergateEvent (isAtoB, property /*, ... other event callback arguments */) {
var eventName = arguments[arguments.length-1]; //Since this is registered on the all event the last argument is the orginal Event name.
if (eventName === Model.Event.CHILD_DESTROYED) { //we listen to he des... | javascript | function propergateEvent (isAtoB, property /*, ... other event callback arguments */) {
var eventName = arguments[arguments.length-1]; //Since this is registered on the all event the last argument is the orginal Event name.
if (eventName === Model.Event.CHILD_DESTROYED) { //we listen to he des... | [
"function",
"propergateEvent",
"(",
"isAtoB",
",",
"property",
"/*, ... other event callback arguments */",
")",
"{",
"var",
"eventName",
"=",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
";",
"//Since this is registered on the all event the last argument is... | This function is registered on the ALL event to propagate its events to the
connected property. FYI 'this' is bound to the source linked property.
@param {Boolean} isAtoB [description]
@param {[type]} property On any event the first argument is the property the event was triggered on.
@return {[type]} [... | [
"This",
"function",
"is",
"registered",
"on",
"the",
"ALL",
"event",
"to",
"propagate",
"its",
"events",
"to",
"the",
"connected",
"property",
".",
"FYI",
"this",
"is",
"bound",
"to",
"the",
"source",
"linked",
"property",
"."
] | 9a4f40a1c75c3a42cfeb451f9041a8186885f7b0 | https://github.com/dgeorges/modeljs/blob/9a4f40a1c75c3a42cfeb451f9041a8186885f7b0/src/model.js#L1542-L1599 | train |
Canop/file-archive | index.js | writeNewAsync | function writeNewAsync(filepath, data){
return new Promise((resolve, reject)=>{
fs.writeFile(filepath, data ,{ flag: "wx" }, function(err){
if (!err) resolve(true)
else reject(err)
})
})
} | javascript | function writeNewAsync(filepath, data){
return new Promise((resolve, reject)=>{
fs.writeFile(filepath, data ,{ flag: "wx" }, function(err){
if (!err) resolve(true)
else reject(err)
})
})
} | [
"function",
"writeNewAsync",
"(",
"filepath",
",",
"data",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"writeFile",
"(",
"filepath",
",",
"data",
",",
"{",
"flag",
":",
"\"wx\"",
"}",
",",
"fun... | return a promise, fail with "EEXIST" when the file already exists | [
"return",
"a",
"promise",
"fail",
"with",
"EEXIST",
"when",
"the",
"file",
"already",
"exists"
] | 0b0aa383964f2dab78655a22a2e53683d79067c0 | https://github.com/Canop/file-archive/blob/0b0aa383964f2dab78655a22a2e53683d79067c0/index.js#L6-L13 | train |
Canop/file-archive | index.js | readdirAsync | function readdirAsync(filepath){
return new Promise((resolve, reject)=>{
fs.readdir(filepath, (err, items)=>{
if (err) reject(err)
else resolve(items)
})
})
} | javascript | function readdirAsync(filepath){
return new Promise((resolve, reject)=>{
fs.readdir(filepath, (err, items)=>{
if (err) reject(err)
else resolve(items)
})
})
} | [
"function",
"readdirAsync",
"(",
"filepath",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"readdir",
"(",
"filepath",
",",
"(",
"err",
",",
"items",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"rej... | simple promisification of fs.readdir | [
"simple",
"promisification",
"of",
"fs",
".",
"readdir"
] | 0b0aa383964f2dab78655a22a2e53683d79067c0 | https://github.com/Canop/file-archive/blob/0b0aa383964f2dab78655a22a2e53683d79067c0/index.js#L16-L23 | train |
cli-kit/cli-middleware | index.js | raise | function raise(err, parameters, cause) {
if(!(err instanceof Error)) {
err = wrap(err, parameters, cause);
}
throw err;
} | javascript | function raise(err, parameters, cause) {
if(!(err instanceof Error)) {
err = wrap(err, parameters, cause);
}
throw err;
} | [
"function",
"raise",
"(",
"err",
",",
"parameters",
",",
"cause",
")",
"{",
"if",
"(",
"!",
"(",
"err",
"instanceof",
"Error",
")",
")",
"{",
"err",
"=",
"wrap",
"(",
"err",
",",
"parameters",
",",
"cause",
")",
";",
"}",
"throw",
"err",
";",
"}"... | Default raise implementation.
@param err Error instance or string.
@param parameters Message replacement parameters.
@param cause An error that caused this error. | [
"Default",
"raise",
"implementation",
"."
] | 9ade9f64b2995940e2341df92a824b2f93df0228 | https://github.com/cli-kit/cli-middleware/blob/9ade9f64b2995940e2341df92a824b2f93df0228/index.js#L42-L47 | train |
KyleBanks/cluster-utils | lib/Timeout.js | _runIfLocked | function _runIfLocked() {
var self = this;
self._clusterUtils._setLock(self.lockKey, function(err, lock) {
if (err) {
throw err;
} else if (!lock) {
return;
}
process.nextTick(self._func);
});
} | javascript | function _runIfLocked() {
var self = this;
self._clusterUtils._setLock(self.lockKey, function(err, lock) {
if (err) {
throw err;
} else if (!lock) {
return;
}
process.nextTick(self._func);
});
} | [
"function",
"_runIfLocked",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_clusterUtils",
".",
"_setLock",
"(",
"self",
".",
"lockKey",
",",
"function",
"(",
"err",
",",
"lock",
")",
"{",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
... | Attempts to run the function provided if a lock can be achieved on the lock key. | [
"Attempts",
"to",
"run",
"the",
"function",
"provided",
"if",
"a",
"lock",
"can",
"be",
"achieved",
"on",
"the",
"lock",
"key",
"."
] | b24814ae413768b4bc671ee71dcc912c999bd20b | https://github.com/KyleBanks/cluster-utils/blob/b24814ae413768b4bc671ee71dcc912c999bd20b/lib/Timeout.js#L37-L49 | train |
gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | registerCookieJar | function registerCookieJar(server) {
var deferred = Q.defer();
server.register({
register: require('yar'),
options: {
cache: {
expiresIn: cookieConfig.ttl
},
cookieOptions: {
clearInvalid: t... | javascript | function registerCookieJar(server) {
var deferred = Q.defer();
server.register({
register: require('yar'),
options: {
cache: {
expiresIn: cookieConfig.ttl
},
cookieOptions: {
clearInvalid: t... | [
"function",
"registerCookieJar",
"(",
"server",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"server",
".",
"register",
"(",
"{",
"register",
":",
"require",
"(",
"'yar'",
")",
",",
"options",
":",
"{",
"cache",
":",
"{",
"expi... | Register the cookie jar using the Hapi yar library
@param server | [
"Register",
"the",
"cookie",
"jar",
"using",
"the",
"Hapi",
"yar",
"library"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L14-L35 | train |
gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | registerJwtCookie | function registerJwtCookie(server) {
server.state('jwt', {
ttl: cookieConfig.ttl,
domain: cookieConfig.domain,
isSecure: cookieConfig.isSecure,
path: '/'
});
} | javascript | function registerJwtCookie(server) {
server.state('jwt', {
ttl: cookieConfig.ttl,
domain: cookieConfig.domain,
isSecure: cookieConfig.isSecure,
path: '/'
});
} | [
"function",
"registerJwtCookie",
"(",
"server",
")",
"{",
"server",
".",
"state",
"(",
"'jwt'",
",",
"{",
"ttl",
":",
"cookieConfig",
".",
"ttl",
",",
"domain",
":",
"cookieConfig",
".",
"domain",
",",
"isSecure",
":",
"cookieConfig",
".",
"isSecure",
",",... | Register the cookie used for the JSON web token.
This is only used on the webserver since the API
will get the token in the header of the request.
@param server | [
"Register",
"the",
"cookie",
"used",
"for",
"the",
"JSON",
"web",
"token",
".",
"This",
"is",
"only",
"used",
"on",
"the",
"webserver",
"since",
"the",
"API",
"will",
"get",
"the",
"token",
"in",
"the",
"header",
"of",
"the",
"request",
"."
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L44-L51 | train |
gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | getJwtFromCookie | function getJwtFromCookie(req, reply) {
var jwt = req.state && req.state.jwt;
if (jwt) {
req.headers = req.headers || {};
req.headers.authorization = jwt;
}
reply.continue();
} | javascript | function getJwtFromCookie(req, reply) {
var jwt = req.state && req.state.jwt;
if (jwt) {
req.headers = req.headers || {};
req.headers.authorization = jwt;
}
reply.continue();
} | [
"function",
"getJwtFromCookie",
"(",
"req",
",",
"reply",
")",
"{",
"var",
"jwt",
"=",
"req",
".",
"state",
"&&",
"req",
".",
"state",
".",
"jwt",
";",
"if",
"(",
"jwt",
")",
"{",
"req",
".",
"headers",
"=",
"req",
".",
"headers",
"||",
"{",
"}",... | Get the JWT token from the cookie and stick it into the request
@param req
@param reply | [
"Get",
"the",
"JWT",
"token",
"from",
"the",
"cookie",
"and",
"stick",
"it",
"into",
"the",
"request"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L58-L66 | train |
gethuman/pancakes-recipe | middleware/mw.auth.cookie.js | init | function init(ctx) {
var server = ctx.server;
return registerCookieJar(server)
.then(function () {
registerJwtCookie(server);
server.ext('onPreAuth', getJwtFromCookie);
return new Q(ctx);
});
} | javascript | function init(ctx) {
var server = ctx.server;
return registerCookieJar(server)
.then(function () {
registerJwtCookie(server);
server.ext('onPreAuth', getJwtFromCookie);
return new Q(ctx);
});
} | [
"function",
"init",
"(",
"ctx",
")",
"{",
"var",
"server",
"=",
"ctx",
".",
"server",
";",
"return",
"registerCookieJar",
"(",
"server",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"registerJwtCookie",
"(",
"server",
")",
";",
"server",
".",
"ext... | Register the cookie jar and move the token from the cookie to the request auth
@param ctx | [
"Register",
"the",
"cookie",
"jar",
"and",
"move",
"the",
"token",
"from",
"the",
"cookie",
"to",
"the",
"request",
"auth"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.cookie.js#L72-L82 | train |
ticup/tokepi | index.js | startsWithAny | function startsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.startsWith(string, e); }));
} | javascript | function startsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.startsWith(string, e); }));
} | [
"function",
"startsWithAny",
"(",
"string",
",",
"vector",
")",
"{",
"return",
"_",
".",
"any",
"(",
"vector",
".",
"map",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"_str",
".",
"startsWith",
"(",
"string",
",",
"e",
")",
";",
"}",
")",
")",
... | True if the string starts with any element of given vector | [
"True",
"if",
"the",
"string",
"starts",
"with",
"any",
"element",
"of",
"given",
"vector"
] | af2aa446e76f03d32e1fe6833b0397d5915e5521 | https://github.com/ticup/tokepi/blob/af2aa446e76f03d32e1fe6833b0397d5915e5521/index.js#L252-L254 | train |
ticup/tokepi | index.js | endsWithAny | function endsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.endsWith(string, e); }));
} | javascript | function endsWithAny(string, vector) {
return _.any(vector.map(function (e) { return _str.endsWith(string, e); }));
} | [
"function",
"endsWithAny",
"(",
"string",
",",
"vector",
")",
"{",
"return",
"_",
".",
"any",
"(",
"vector",
".",
"map",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"_str",
".",
"endsWith",
"(",
"string",
",",
"e",
")",
";",
"}",
")",
")",
";"... | True if the string ends with any element of given vector | [
"True",
"if",
"the",
"string",
"ends",
"with",
"any",
"element",
"of",
"given",
"vector"
] | af2aa446e76f03d32e1fe6833b0397d5915e5521 | https://github.com/ticup/tokepi/blob/af2aa446e76f03d32e1fe6833b0397d5915e5521/index.js#L256-L258 | train |
demmer/validate-options | browser/specs/validate-options.spec.js | createReduce | function createReduce(dir) {
// Optimized iterator function as using arguments.length
// in the main function will deoptimize the, see #1991.
function iterator(obj, iteratee, memo, keys, index, length) {
for (; index >= 0 && index < len... | javascript | function createReduce(dir) {
// Optimized iterator function as using arguments.length
// in the main function will deoptimize the, see #1991.
function iterator(obj, iteratee, memo, keys, index, length) {
for (; index >= 0 && index < len... | [
"function",
"createReduce",
"(",
"dir",
")",
"{",
"// Optimized iterator function as using arguments.length",
"// in the main function will deoptimize the, see #1991.",
"function",
"iterator",
"(",
"obj",
",",
"iteratee",
",",
"memo",
",",
"keys",
",",
"index",
",",
"length... | Create a reducing function iterating left or right. Create a reducing function iterating left or right. | [
"Create",
"a",
"reducing",
"function",
"iterating",
"left",
"or",
"right",
".",
"Create",
"a",
"reducing",
"function",
"iterating",
"left",
"or",
"right",
"."
] | af18816366adca0b6da7347dcb31b9336b862a6d | https://github.com/demmer/validate-options/blob/af18816366adca0b6da7347dcb31b9336b862a6d/browser/specs/validate-options.spec.js#L295-L315 | train |
skerit/alchemy | lib/app/helper/socket_helper.js | onResponse | function onResponse(packet) {
if (typeof that.callbacks[packet.respond_to] === 'function') {
try {
if (packet.data) {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err);
return;
}
if (packet.noData) {
that.callbacks[packet.respon... | javascript | function onResponse(packet) {
if (typeof that.callbacks[packet.respond_to] === 'function') {
try {
if (packet.data) {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err);
return;
}
if (packet.noData) {
that.callbacks[packet.respon... | [
"function",
"onResponse",
"(",
"packet",
")",
"{",
"if",
"(",
"typeof",
"that",
".",
"callbacks",
"[",
"packet",
".",
"respond_to",
"]",
"===",
"'function'",
")",
"{",
"try",
"{",
"if",
"(",
"packet",
".",
"data",
")",
"{",
"packet",
".",
"data",
"="... | The function that handles responses | [
"The",
"function",
"that",
"handles",
"responses"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/app/helper/socket_helper.js#L450-L473 | train |
skerit/alchemy | lib/app/helper/socket_helper.js | onPacket | function onPacket(packet) {
var respond;
try {
if (packet.data && typeof packet.data == 'object') {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err, packet);
return;
}
if (packet.respond) {
respond = function respond(err, data) {
var... | javascript | function onPacket(packet) {
var respond;
try {
if (packet.data && typeof packet.data == 'object') {
packet.data = JSON.undry(packet.data);
}
} catch (err) {
console.log('ERROR UNDRYING PACKET:', err, packet);
return;
}
if (packet.respond) {
respond = function respond(err, data) {
var... | [
"function",
"onPacket",
"(",
"packet",
")",
"{",
"var",
"respond",
";",
"try",
"{",
"if",
"(",
"packet",
".",
"data",
"&&",
"typeof",
"packet",
".",
"data",
"==",
"'object'",
")",
"{",
"packet",
".",
"data",
"=",
"JSON",
".",
"undry",
"(",
"packet",
... | The function that handles packets | [
"The",
"function",
"that",
"handles",
"packets"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/app/helper/socket_helper.js#L476-L519 | train |
christophehurpeau/springbokjs-dom | vendor/web-animations.js | function(inheritedTime) {
this._inheritedTime = inheritedTime;
this._updateTimeMarkers();
// The polyfill uses a sampling model whereby time values are propagated
// down the tree at each sample. However, for the media item, we need to use
// play() and pause().
// Handle the case of being out... | javascript | function(inheritedTime) {
this._inheritedTime = inheritedTime;
this._updateTimeMarkers();
// The polyfill uses a sampling model whereby time values are propagated
// down the tree at each sample. However, for the media item, we need to use
// play() and pause().
// Handle the case of being out... | [
"function",
"(",
"inheritedTime",
")",
"{",
"this",
".",
"_inheritedTime",
"=",
"inheritedTime",
";",
"this",
".",
"_updateTimeMarkers",
"(",
")",
";",
"// The polyfill uses a sampling model whereby time values are propagated",
"// down the tree at each sample. However, for the m... | This is called by the polyfill on each tick when our AnimationPlayer's tree is active. | [
"This",
"is",
"called",
"by",
"the",
"polyfill",
"on",
"each",
"tick",
"when",
"our",
"AnimationPlayer",
"s",
"tree",
"is",
"active",
"."
] | 6e14a87fbe71124a0cbb68d1cb8626689c3b18a1 | https://github.com/christophehurpeau/springbokjs-dom/blob/6e14a87fbe71124a0cbb68d1cb8626689c3b18a1/vendor/web-animations.js#L1574-L1643 | train | |
christophehurpeau/springbokjs-dom | vendor/web-animations.js | function(offset, composite, easing) {
ASSERT_ENABLED && assert(
typeof offset === 'number' || offset === null,
'Invalid offset value');
ASSERT_ENABLED && assert(
composite === 'add' || composite === 'replace' || composite === null,
'Invalid composite value');
this.offset = offset;
this.c... | javascript | function(offset, composite, easing) {
ASSERT_ENABLED && assert(
typeof offset === 'number' || offset === null,
'Invalid offset value');
ASSERT_ENABLED && assert(
composite === 'add' || composite === 'replace' || composite === null,
'Invalid composite value');
this.offset = offset;
this.c... | [
"function",
"(",
"offset",
",",
"composite",
",",
"easing",
")",
"{",
"ASSERT_ENABLED",
"&&",
"assert",
"(",
"typeof",
"offset",
"===",
"'number'",
"||",
"offset",
"===",
"null",
",",
"'Invalid offset value'",
")",
";",
"ASSERT_ENABLED",
"&&",
"assert",
"(",
... | An internal representation of a keyframe. The Keyframe type from the spec is
just a dictionary and is not exposed.
@constructor | [
"An",
"internal",
"representation",
"of",
"a",
"keyframe",
".",
"The",
"Keyframe",
"type",
"from",
"the",
"spec",
"is",
"just",
"a",
"dictionary",
"and",
"is",
"not",
"exposed",
"."
] | 6e14a87fbe71124a0cbb68d1cb8626689c3b18a1 | https://github.com/christophehurpeau/springbokjs-dom/blob/6e14a87fbe71124a0cbb68d1cb8626689c3b18a1/vendor/web-animations.js#L2278-L2289 | train | |
christophehurpeau/springbokjs-dom | vendor/web-animations.js | function(property, value, svgMode) {
if (value === 'inherit') {
return value;
}
return getType(property).toCssValue(value, svgMode);
} | javascript | function(property, value, svgMode) {
if (value === 'inherit') {
return value;
}
return getType(property).toCssValue(value, svgMode);
} | [
"function",
"(",
"property",
",",
"value",
",",
"svgMode",
")",
"{",
"if",
"(",
"value",
"===",
"'inherit'",
")",
"{",
"return",
"value",
";",
"}",
"return",
"getType",
"(",
"property",
")",
".",
"toCssValue",
"(",
"value",
",",
"svgMode",
")",
";",
... | Convert the provided interpolable value for the provided property to a CSS
value string. Note that SVG transforms do not require units for translate
or rotate values while CSS properties require 'px' or 'deg' units. | [
"Convert",
"the",
"provided",
"interpolable",
"value",
"for",
"the",
"provided",
"property",
"to",
"a",
"CSS",
"value",
"string",
".",
"Note",
"that",
"SVG",
"transforms",
"do",
"not",
"require",
"units",
"for",
"translate",
"or",
"rotate",
"values",
"while",
... | 6e14a87fbe71124a0cbb68d1cb8626689c3b18a1 | https://github.com/christophehurpeau/springbokjs-dom/blob/6e14a87fbe71124a0cbb68d1cb8626689c3b18a1/vendor/web-animations.js#L4715-L4720 | train | |
Nazariglez/perenquen | lib/pixi/src/filters/pixelate/PixelateFilter.js | PixelateFilter | function PixelateFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/pixelate.frag', 'utf8'),
// custom uniforms
{
dimensions: { type: '4fv', value: new Float32Array([0, 0, 0, 0]) },
... | javascript | function PixelateFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/pixelate.frag', 'utf8'),
// custom uniforms
{
dimensions: { type: '4fv', value: new Float32Array([0, 0, 0, 0]) },
... | [
"function",
"PixelateFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"null",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/pixelate.frag'",
",",
"'utf8'",
")",
",",
"//... | This filter applies a pixelate effect making display objects appear 'blocky'.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"This",
"filter",
"applies",
"a",
"pixelate",
"effect",
"making",
"display",
"objects",
"appear",
"blocky",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/pixelate/PixelateFilter.js#L12-L25 | train |
markuz-gj/marked-middleware | index.js | getUrl | function getUrl (url) {
var opt = {
url: url
, timeout: 10000 // 10 seconds
}
;
return new Promise(function(resolve, reject){
request(opt, function(err, res, body){
if (err) { return reject(err); }
resolve(body)
});
});
} | javascript | function getUrl (url) {
var opt = {
url: url
, timeout: 10000 // 10 seconds
}
;
return new Promise(function(resolve, reject){
request(opt, function(err, res, body){
if (err) { return reject(err); }
resolve(body)
});
});
} | [
"function",
"getUrl",
"(",
"url",
")",
"{",
"var",
"opt",
"=",
"{",
"url",
":",
"url",
",",
"timeout",
":",
"10000",
"// 10 seconds",
"}",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"request",
"(",
"opt... | A promise wrapper arount `request`. It timeout the request after 10 sec
@private
@param {String} url
@return {Promise} - resolve {String} with the request's body. Could be an `html` or `css`. | [
"A",
"promise",
"wrapper",
"arount",
"request",
".",
"It",
"timeout",
"the",
"request",
"after",
"10",
"sec"
] | 808d475faedef82eb958bfb8097bbcef00e0ff31 | https://github.com/markuz-gj/marked-middleware/blob/808d475faedef82eb958bfb8097bbcef00e0ff31/index.js#L49-L61 | train |
markuz-gj/marked-middleware | index.js | readCss | function readCss () {
return new Promise(function(resolve, reject){
readFile(SRC, {encoding: 'utf8'}, function(err, str){
if (err) { return reject(err); }
resolve(str)
});
});
} | javascript | function readCss () {
return new Promise(function(resolve, reject){
readFile(SRC, {encoding: 'utf8'}, function(err, str){
if (err) { return reject(err); }
resolve(str)
});
});
} | [
"function",
"readCss",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"readFile",
"(",
"SRC",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
",",
"function",
"(",
"err",
",",
"str",
")",
"{",
"if",
"... | Read local github's css
@private
@return {Promise} - resolves to a {String} with the local github's css | [
"Read",
"local",
"github",
"s",
"css"
] | 808d475faedef82eb958bfb8097bbcef00e0ff31 | https://github.com/markuz-gj/marked-middleware/blob/808d475faedef82eb958bfb8097bbcef00e0ff31/index.js#L125-L132 | train |
markuz-gj/marked-middleware | index.js | getCss | function getCss () {
return checkTime().then(function(isOld){
if (isOld){
return writeCss().then(function(str){
if (!str) return readCss()
return str
})
}
return readCss()
})
} | javascript | function getCss () {
return checkTime().then(function(isOld){
if (isOld){
return writeCss().then(function(str){
if (!str) return readCss()
return str
})
}
return readCss()
})
} | [
"function",
"getCss",
"(",
")",
"{",
"return",
"checkTime",
"(",
")",
".",
"then",
"(",
"function",
"(",
"isOld",
")",
"{",
"if",
"(",
"isOld",
")",
"{",
"return",
"writeCss",
"(",
")",
".",
"then",
"(",
"function",
"(",
"str",
")",
"{",
"if",
"(... | It gets the css local or remote.
@private
@return {Promise} - it passes {String} with github's css to the next `then`. | [
"It",
"gets",
"the",
"css",
"local",
"or",
"remote",
"."
] | 808d475faedef82eb958bfb8097bbcef00e0ff31 | https://github.com/markuz-gj/marked-middleware/blob/808d475faedef82eb958bfb8097bbcef00e0ff31/index.js#L140-L151 | train |
gethuman/pancakes-recipe | batch/db.archive/db.archive.batch.js | archiveResource | function archiveResource(resource, primary, archive) {
if (!resource.archive) { return true; }
var name = resource.name;
primary.bind(name);
archive.bind(name);
// get the archive criteria
var criteria = resource.archive();
log.info('Getting archive docs for '... | javascript | function archiveResource(resource, primary, archive) {
if (!resource.archive) { return true; }
var name = resource.name;
primary.bind(name);
archive.bind(name);
// get the archive criteria
var criteria = resource.archive();
log.info('Getting archive docs for '... | [
"function",
"archiveResource",
"(",
"resource",
",",
"primary",
",",
"archive",
")",
"{",
"if",
"(",
"!",
"resource",
".",
"archive",
")",
"{",
"return",
"true",
";",
"}",
"var",
"name",
"=",
"resource",
".",
"name",
";",
"primary",
".",
"bind",
"(",
... | Archive a particular resource
@param resource
@param primary
@param archive | [
"Archive",
"a",
"particular",
"resource"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/db.archive/db.archive.batch.js#L55-L96 | train |
gethuman/pancakes-recipe | batch/db.archive/db.archive.batch.js | getDocsToArchive | function getDocsToArchive(criteria, primaryCollection) {
var deferred = Q.defer();
primaryCollection.find(criteria).toArray(function (err, items) {
err ? deferred.reject(err) : deferred.resolve(items);
});
return deferred.promise;
} | javascript | function getDocsToArchive(criteria, primaryCollection) {
var deferred = Q.defer();
primaryCollection.find(criteria).toArray(function (err, items) {
err ? deferred.reject(err) : deferred.resolve(items);
});
return deferred.promise;
} | [
"function",
"getDocsToArchive",
"(",
"criteria",
",",
"primaryCollection",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"primaryCollection",
".",
"find",
"(",
"criteria",
")",
".",
"toArray",
"(",
"function",
"(",
"err",
",",
"items"... | Get the documents to archive
@param criteria
@param primaryCollection | [
"Get",
"the",
"documents",
"to",
"archive"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/db.archive/db.archive.batch.js#L103-L111 | 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.