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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
enquirer/readline-ui | index.js | UI | function UI(options) {
if (!(this instanceof UI)) {
var ui = Object.create(UI.prototype);
UI.apply(ui, arguments);
return ui;
}
debug('initializing from <%s>', __filename);
this.options = utils.createOptions(options);
this.appendedLines = 0;
this.height = 0;
this.initInterface();
} | javascript | function UI(options) {
if (!(this instanceof UI)) {
var ui = Object.create(UI.prototype);
UI.apply(ui, arguments);
return ui;
}
debug('initializing from <%s>', __filename);
this.options = utils.createOptions(options);
this.appendedLines = 0;
this.height = 0;
this.initInterface();
} | [
"function",
"UI",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"UI",
")",
")",
"{",
"var",
"ui",
"=",
"Object",
".",
"create",
"(",
"UI",
".",
"prototype",
")",
";",
"UI",
".",
"apply",
"(",
"ui",
",",
"arguments",
")",
... | Create a readline interface to use in prompts | [
"Create",
"a",
"readline",
"interface",
"to",
"use",
"in",
"prompts"
] | 38e682c1f17d6b299c67d01caac651e0de98417e | https://github.com/enquirer/readline-ui/blob/38e682c1f17d6b299c67d01caac651e0de98417e/index.js#L14-L25 | train |
waigo/waigo | src/models/cron.js | function(crontab) {
let _config = this[$EXTRA];
_config.logger.info(`Setting up cron schedule ${crontab}`);
_config.job = new CronJob({
cronTime: crontab,
onTick: _.bind(co.wrap(this._cronCallback), this),
start: true,
});
/* calculate and save time between runs */
... | javascript | function(crontab) {
let _config = this[$EXTRA];
_config.logger.info(`Setting up cron schedule ${crontab}`);
_config.job = new CronJob({
cronTime: crontab,
onTick: _.bind(co.wrap(this._cronCallback), this),
start: true,
});
/* calculate and save time between runs */
... | [
"function",
"(",
"crontab",
")",
"{",
"let",
"_config",
"=",
"this",
"[",
"$EXTRA",
"]",
";",
"_config",
".",
"logger",
".",
"info",
"(",
"`",
"${",
"crontab",
"}",
"`",
")",
";",
"_config",
".",
"job",
"=",
"new",
"CronJob",
"(",
"{",
"cronTime",
... | Start the cron scheduler for this job. | [
"Start",
"the",
"cron",
"scheduler",
"for",
"this",
"job",
"."
] | b2f50cd66b8b19016e2c7de75733330c791c76ff | https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/models/cron.js#L105-L124 | train | |
alexindigo/deeply | extra/arrays_append_unique.js | arraysAppendUniqueAdapter | function arraysAppendUniqueAdapter(to, from, merge)
{
// transfer actual values
from.reduce(function(target, value)
{
// append only if new element isn't present yet
if (target.indexOf(value) == -1)
{
target.push(merge(undefined, value));
}
return target;
}, to);
return to;
} | javascript | function arraysAppendUniqueAdapter(to, from, merge)
{
// transfer actual values
from.reduce(function(target, value)
{
// append only if new element isn't present yet
if (target.indexOf(value) == -1)
{
target.push(merge(undefined, value));
}
return target;
}, to);
return to;
} | [
"function",
"arraysAppendUniqueAdapter",
"(",
"to",
",",
"from",
",",
"merge",
")",
"{",
"// transfer actual values",
"from",
".",
"reduce",
"(",
"function",
"(",
"target",
",",
"value",
")",
"{",
"// append only if new element isn't present yet",
"if",
"(",
"target... | Adapter to merge arrays
by appending cloned elements
of the second array to the first
unless they already exist in the target array
@param {array} to - target array to update
@param {array} from - array to clone
@param {function} merge - iterator to merge sub elements
@returns {array} - modified target object | [
"Adapter",
"to",
"merge",
"arrays",
"by",
"appending",
"cloned",
"elements",
"of",
"the",
"second",
"array",
"to",
"the",
"first",
"unless",
"they",
"already",
"exist",
"in",
"the",
"target",
"array"
] | d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1 | https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/extra/arrays_append_unique.js#L15-L30 | train |
bvalosek/sticky | util/fieldPicker.js | fieldPicker | function fieldPicker(fields)
{
var map = {};
if (fields instanceof Array) {
fields.forEach(function(f) { map[f] = f; });
} else if (typeof fields === 'object') {
for (var key in fields) {
map[key] = fields[key];
}
}
return function(input, output) {
var target = output || input;
for... | javascript | function fieldPicker(fields)
{
var map = {};
if (fields instanceof Array) {
fields.forEach(function(f) { map[f] = f; });
} else if (typeof fields === 'object') {
for (var key in fields) {
map[key] = fields[key];
}
}
return function(input, output) {
var target = output || input;
for... | [
"function",
"fieldPicker",
"(",
"fields",
")",
"{",
"var",
"map",
"=",
"{",
"}",
";",
"if",
"(",
"fields",
"instanceof",
"Array",
")",
"{",
"fields",
".",
"forEach",
"(",
"function",
"(",
"f",
")",
"{",
"map",
"[",
"f",
"]",
"=",
"f",
";",
"}",
... | Map fields from a provider exclusively | [
"Map",
"fields",
"from",
"a",
"provider",
"exclusively"
] | 8cb5fdba05be161e5936f7208558bc4702aae59a | https://github.com/bvalosek/sticky/blob/8cb5fdba05be161e5936f7208558bc4702aae59a/util/fieldPicker.js#L6-L25 | train |
magne4000/node-libquassel | src/libquassel.js | splitOnce | function splitOnce(str, character) {
const i = str.indexOf(character);
return [ str.slice(0, i), str.slice(i+1) ];
} | javascript | function splitOnce(str, character) {
const i = str.indexOf(character);
return [ str.slice(0, i), str.slice(i+1) ];
} | [
"function",
"splitOnce",
"(",
"str",
",",
"character",
")",
"{",
"const",
"i",
"=",
"str",
".",
"indexOf",
"(",
"character",
")",
";",
"return",
"[",
"str",
".",
"slice",
"(",
"0",
",",
"i",
")",
",",
"str",
".",
"slice",
"(",
"i",
"+",
"1",
")... | This event is fired when quasselcore information are received
@typedef {Event} Event:coreinfoinit
@property {Object} data
@property {boolean} data.Configured - Is the core configured
@property {number} data.CoreFeatures
@property {String} data.CoreInfo
@property {boolean} data.LoginEnabled
@property {boolean} data.MsgT... | [
"This",
"event",
"is",
"fired",
"when",
"quasselcore",
"information",
"are",
"received"
] | 0cf97378ebe170b0abf4bdcc112933009a84156f | https://github.com/magne4000/node-libquassel/blob/0cf97378ebe170b0abf4bdcc112933009a84156f/src/libquassel.js#L1601-L1604 | train |
azu/performance-mark-metadata | docs/index.js | getRndColor | function getRndColor() {
const r = (255 * Math.random()) | 0,
g = (255 * Math.random()) | 0,
b = (255 * Math.random()) | 0;
return "rgb(" + r + "," + g + "," + b + ")";
} | javascript | function getRndColor() {
const r = (255 * Math.random()) | 0,
g = (255 * Math.random()) | 0,
b = (255 * Math.random()) | 0;
return "rgb(" + r + "," + g + "," + b + ")";
} | [
"function",
"getRndColor",
"(",
")",
"{",
"const",
"r",
"=",
"(",
"255",
"*",
"Math",
".",
"random",
"(",
")",
")",
"|",
"0",
",",
"g",
"=",
"(",
"255",
"*",
"Math",
".",
"random",
"(",
")",
")",
"|",
"0",
",",
"b",
"=",
"(",
"255",
"*",
... | It is junk code | [
"It",
"is",
"junk",
"code"
] | a190d1cdb3b6b965f67ad8095c61e37aeb86bd9d | https://github.com/azu/performance-mark-metadata/blob/a190d1cdb3b6b965f67ad8095c61e37aeb86bd9d/docs/index.js#L78-L83 | train |
Soreine/prismjs-components-loader | src/componentDefinitions.js | getDependencies | function getDependencies(component, Prism) {
// Cast require to an Array
const deps = [].concat(component.require || []);
if (Prism) {
return deps.filter(
dep =>
// Remove dependencies that are already loaded
!Prism.languages[dep]
);
}
ret... | javascript | function getDependencies(component, Prism) {
// Cast require to an Array
const deps = [].concat(component.require || []);
if (Prism) {
return deps.filter(
dep =>
// Remove dependencies that are already loaded
!Prism.languages[dep]
);
}
ret... | [
"function",
"getDependencies",
"(",
"component",
",",
"Prism",
")",
"{",
"// Cast require to an Array",
"const",
"deps",
"=",
"[",
"]",
".",
"concat",
"(",
"component",
".",
"require",
"||",
"[",
"]",
")",
";",
"if",
"(",
"Prism",
")",
"{",
"return",
"de... | List the dependencies for a component. If Prism is provided, only returns
dependencies that are not present in `Prism.languages`
@param {Object} component Component definition
@param {Prism} Prism instance
@return {Array<String>} | [
"List",
"the",
"dependencies",
"for",
"a",
"component",
".",
"If",
"Prism",
"is",
"provided",
"only",
"returns",
"dependencies",
"that",
"are",
"not",
"present",
"in",
"Prism",
".",
"languages"
] | e9bbe31e9a407317c99e1fc3848fc7d8a7468f1b | https://github.com/Soreine/prismjs-components-loader/blob/e9bbe31e9a407317c99e1fc3848fc7d8a7468f1b/src/componentDefinitions.js#L59-L71 | train |
darsain/utilus | gulpfile.js | clean | function clean(done) {
var del = require('del');
del(cfg.destination).then(function () {
if (typeof done === 'function') done();
else process.exit();
});
} | javascript | function clean(done) {
var del = require('del');
del(cfg.destination).then(function () {
if (typeof done === 'function') done();
else process.exit();
});
} | [
"function",
"clean",
"(",
"done",
")",
"{",
"var",
"del",
"=",
"require",
"(",
"'del'",
")",
";",
"del",
"(",
"cfg",
".",
"destination",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"done",
"===",
"'function'",
")",
"done"... | cleanup after itself | [
"cleanup",
"after",
"itself"
] | 36b41f8581a12aa64e0d1d53b080674bf6a0f3c0 | https://github.com/darsain/utilus/blob/36b41f8581a12aa64e0d1d53b080674bf6a0f3c0/gulpfile.js#L25-L31 | train |
darsain/utilus | gulpfile.js | serve | function serve() {
var browserSync = require('browser-sync');
browserSync({
server: {
baseDir: cfg.destination
},
ui: false,
online: false,
open: false,
minify: false
});
gulp.watch(['*'], {cwd: cfg.destination}).on('change', browserSync.reload);
} | javascript | function serve() {
var browserSync = require('browser-sync');
browserSync({
server: {
baseDir: cfg.destination
},
ui: false,
online: false,
open: false,
minify: false
});
gulp.watch(['*'], {cwd: cfg.destination}).on('change', browserSync.reload);
} | [
"function",
"serve",
"(",
")",
"{",
"var",
"browserSync",
"=",
"require",
"(",
"'browser-sync'",
")",
";",
"browserSync",
"(",
"{",
"server",
":",
"{",
"baseDir",
":",
"cfg",
".",
"destination",
"}",
",",
"ui",
":",
"false",
",",
"online",
":",
"false"... | watch files for changes and reload | [
"watch",
"files",
"for",
"changes",
"and",
"reload"
] | 36b41f8581a12aa64e0d1d53b080674bf6a0f3c0 | https://github.com/darsain/utilus/blob/36b41f8581a12aa64e0d1d53b080674bf6a0f3c0/gulpfile.js#L65-L79 | train |
waigo/waigo | src/support/lodashMixins.js | function(type, obj) {
switch (type) {
case 'greet':
var name = _.get(obj, 'profile.displayName') || _.get(obj, 'username', '') || obj;
return _.get(name, 'length') ? name : 'Hey';
break;
}
return obj;
} | javascript | function(type, obj) {
switch (type) {
case 'greet':
var name = _.get(obj, 'profile.displayName') || _.get(obj, 'username', '') || obj;
return _.get(name, 'length') ? name : 'Hey';
break;
}
return obj;
} | [
"function",
"(",
"type",
",",
"obj",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"'greet'",
":",
"var",
"name",
"=",
"_",
".",
"get",
"(",
"obj",
",",
"'profile.displayName'",
")",
"||",
"_",
".",
"get",
"(",
"obj",
",",
"'username'",
",",
... | Format user name for display.
@param {String} type How to format.
@param {User|String} obj The user object or username string.
@return {*} | [
"Format",
"user",
"name",
"for",
"display",
"."
] | b2f50cd66b8b19016e2c7de75733330c791c76ff | https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/support/lodashMixins.js#L20-L30 | train | |
ngokevin/redux-localstorage-slicer | index.js | createSlicer | function createSlicer(version) {
if (version !== undefined) {
// For invalidation.
var currentVersion = localStorage.getItem(LS_VERSION_KEY);
if (version > currentVersion) {
localStorage.removeItem('redux');
localStorage.setItem(LS_VERSION_KEY, version);
}
}
return function (paths) {
... | javascript | function createSlicer(version) {
if (version !== undefined) {
// For invalidation.
var currentVersion = localStorage.getItem(LS_VERSION_KEY);
if (version > currentVersion) {
localStorage.removeItem('redux');
localStorage.setItem(LS_VERSION_KEY, version);
}
}
return function (paths) {
... | [
"function",
"createSlicer",
"(",
"version",
")",
"{",
"if",
"(",
"version",
"!==",
"undefined",
")",
"{",
"// For invalidation.",
"var",
"currentVersion",
"=",
"localStorage",
".",
"getItem",
"(",
"LS_VERSION_KEY",
")",
";",
"if",
"(",
"version",
">",
"current... | Slicer that allows each reducer to define their own persist configuration. | [
"Slicer",
"that",
"allows",
"each",
"reducer",
"to",
"define",
"their",
"own",
"persist",
"configuration",
"."
] | 50db9f8b7c1a74419534bedfcc7ce5f7f8bb4e51 | https://github.com/ngokevin/redux-localstorage-slicer/blob/50db9f8b7c1a74419534bedfcc7ce5f7f8bb4e51/index.js#L14-L75 | train |
shinout/FASTAReader | lib/FASTAReader.js | idx2pos | function idx2pos(idx, prelen, linelen) {
prelen = prelen || 0;
linelen = linelen || 50;
idx = Number(idx);
return Math.max(0, idx - prelen - Math.floor((idx - prelen)/(linelen + 1))) + 1;
} | javascript | function idx2pos(idx, prelen, linelen) {
prelen = prelen || 0;
linelen = linelen || 50;
idx = Number(idx);
return Math.max(0, idx - prelen - Math.floor((idx - prelen)/(linelen + 1))) + 1;
} | [
"function",
"idx2pos",
"(",
"idx",
",",
"prelen",
",",
"linelen",
")",
"{",
"prelen",
"=",
"prelen",
"||",
"0",
";",
"linelen",
"=",
"linelen",
"||",
"50",
";",
"idx",
"=",
"Number",
"(",
"idx",
")",
";",
"return",
"Math",
".",
"max",
"(",
"0",
"... | FASTAReader.idx2pos
convert charcter index to DNA base position
@param number idx : character index (leftside)
@param number prelen : header data length
@param number linelen : one line length
@return number : DNA base position | [
"FASTAReader",
".",
"idx2pos",
"convert",
"charcter",
"index",
"to",
"DNA",
"base",
"position"
] | f9b55f2f15e364804957569cfe60fc7305ff1543 | https://github.com/shinout/FASTAReader/blob/f9b55f2f15e364804957569cfe60fc7305ff1543/lib/FASTAReader.js#L288-L293 | train |
leesei/hkbus | helper.js | string2Boolean | function string2Boolean (string, defaultTrue) {
// console.log('2bool:', String(string).toLowerCase());
switch (String(string).toLowerCase()) {
case '':
return (defaultTrue === undefined) ? false : defaultTrue;
case 'true':
case '1':
case 'yes':
case 'y':
return true;
case 'false... | javascript | function string2Boolean (string, defaultTrue) {
// console.log('2bool:', String(string).toLowerCase());
switch (String(string).toLowerCase()) {
case '':
return (defaultTrue === undefined) ? false : defaultTrue;
case 'true':
case '1':
case 'yes':
case 'y':
return true;
case 'false... | [
"function",
"string2Boolean",
"(",
"string",
",",
"defaultTrue",
")",
"{",
"// console.log('2bool:', String(string).toLowerCase());",
"switch",
"(",
"String",
"(",
"string",
")",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"''",
":",
"return",
"(",
"defaultTru... | Convert sensible strings to Boolean, useful for parsing URL queries | [
"Convert",
"sensible",
"strings",
"to",
"Boolean",
"useful",
"for",
"parsing",
"URL",
"queries"
] | 5cafa725aa7412fc77d91f336a9d631c0da7616f | https://github.com/leesei/hkbus/blob/5cafa725aa7412fc77d91f336a9d631c0da7616f/helper.js#L2-L21 | train |
nikku/selection-update | index.js | calculateUpdate | function calculateUpdate(currentSelection, currentValue, newValue) {
var currentCursor = currentSelection.start,
newCursor = currentCursor,
diff = newValue.length - currentValue.length,
idx;
var lengthDelta = newValue.length - currentValue.length;
var currentTail = currentValue.substring(curr... | javascript | function calculateUpdate(currentSelection, currentValue, newValue) {
var currentCursor = currentSelection.start,
newCursor = currentCursor,
diff = newValue.length - currentValue.length,
idx;
var lengthDelta = newValue.length - currentValue.length;
var currentTail = currentValue.substring(curr... | [
"function",
"calculateUpdate",
"(",
"currentSelection",
",",
"currentValue",
",",
"newValue",
")",
"{",
"var",
"currentCursor",
"=",
"currentSelection",
".",
"start",
",",
"newCursor",
"=",
"currentCursor",
",",
"diff",
"=",
"newValue",
".",
"length",
"-",
"curr... | Calculate the selection update for the given
current and new input values.
@param {Object} currentSelection as {start, end}
@param {String} currentValue
@param {String} newValue
@return {Object} newSelection as {start, end} | [
"Calculate",
"the",
"selection",
"update",
"for",
"the",
"given",
"current",
"and",
"new",
"input",
"values",
"."
] | 22379d4b3fa4f23d76027eda978e0e6753bd37aa | https://github.com/nikku/selection-update/blob/22379d4b3fa4f23d76027eda978e0e6753bd37aa/index.js#L13-L48 | train |
basicdays/co-pg | lib/client-factory.js | buildNativeCoClientBuilder | function buildNativeCoClientBuilder(clientBuilder) {
return function nativeCoClientBuilder(config) {
var connection = clientBuilder(config);
connection.connectAsync = promissory(connection.connect);
connection.queryAsync = promissory(connection.query);
// for backwards compatibility
connection.connectPromi... | javascript | function buildNativeCoClientBuilder(clientBuilder) {
return function nativeCoClientBuilder(config) {
var connection = clientBuilder(config);
connection.connectAsync = promissory(connection.connect);
connection.queryAsync = promissory(connection.query);
// for backwards compatibility
connection.connectPromi... | [
"function",
"buildNativeCoClientBuilder",
"(",
"clientBuilder",
")",
"{",
"return",
"function",
"nativeCoClientBuilder",
"(",
"config",
")",
"{",
"var",
"connection",
"=",
"clientBuilder",
"(",
"config",
")",
";",
"connection",
".",
"connectAsync",
"=",
"promissory"... | Wrap the `pg` `clientBuilder` function to add co extensions.
Since the exposed `clientBuilder` function from `pg.native` is a simple function that wraps the
construction of a native client connection, we don't have easy access to the prototype to inherit
prior to construction of the connection. Instead, we call the `p... | [
"Wrap",
"the",
"pg",
"clientBuilder",
"function",
"to",
"add",
"co",
"extensions",
"."
] | 14924931b6fe0d14d7903d4917f0681bee874a37 | https://github.com/basicdays/co-pg/blob/14924931b6fe0d14d7903d4917f0681bee874a37/lib/client-factory.js#L35-L48 | train |
Kami/node-buildbot-github | lib/pollers.js | BuildbotPoller | function BuildbotPoller(options, interval) {
Poller.call(this, 'buildbot', options, interval);
this._host = this._options['host'];
this._port = this._options['port'];
this._username = this._options['username'];
this._password = this._options['password'];
this._numBuilds = this._options['num_builds'];
th... | javascript | function BuildbotPoller(options, interval) {
Poller.call(this, 'buildbot', options, interval);
this._host = this._options['host'];
this._port = this._options['port'];
this._username = this._options['username'];
this._password = this._options['password'];
this._numBuilds = this._options['num_builds'];
th... | [
"function",
"BuildbotPoller",
"(",
"options",
",",
"interval",
")",
"{",
"Poller",
".",
"call",
"(",
"this",
",",
"'buildbot'",
",",
"options",
",",
"interval",
")",
";",
"this",
".",
"_host",
"=",
"this",
".",
"_options",
"[",
"'host'",
"]",
";",
"thi... | Polls buildbot for new builds | [
"Polls",
"buildbot",
"for",
"new",
"builds"
] | 7cc457a11617ea4925d0782cd13a8f7789707199 | https://github.com/Kami/node-buildbot-github/blob/7cc457a11617ea4925d0782cd13a8f7789707199/lib/pollers.js#L49-L59 | train |
soajs/connect-mongo-soajs | lib/index.js | MongoStore | function MongoStore(options) {
options = options || {};
for (var property in defaultOptions) {
if (defaultOptions.hasOwnProperty(property)) {
if (!options.hasOwnProperty(property) || (typeof defaultOptions[property] !== typeof options[property]))
options[... | javascript | function MongoStore(options) {
options = options || {};
for (var property in defaultOptions) {
if (defaultOptions.hasOwnProperty(property)) {
if (!options.hasOwnProperty(property) || (typeof defaultOptions[property] !== typeof options[property]))
options[... | [
"function",
"MongoStore",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"property",
"in",
"defaultOptions",
")",
"{",
"if",
"(",
"defaultOptions",
".",
"hasOwnProperty",
"(",
"property",
")",
")",
"{",
"if",... | Initialize MongoStore with the given `options`.
@param {Object} options | [
"Initialize",
"MongoStore",
"with",
"the",
"given",
"options",
"."
] | 27b7b0b0f25e75168857fd9d2be83cc07a0da868 | https://github.com/soajs/connect-mongo-soajs/blob/27b7b0b0f25e75168857fd9d2be83cc07a0da868/lib/index.js#L52-L81 | train |
tmont/jarvis | src/stacktrace.js | function(e) {
var stack = e.stacktrace;
var lines = stack.split('\n'), ANON = '{anonymous}', lineRE = /.*line (\d+), column (\d+) in ((<anonymous function\:?\s*(\S+))|([^\(]+)\([^\)]*\))(?: in )?(.*)\s*$/i, i, j, len;
for (i = 2, j = 0, len = lines.length; i < len - 2; i++) {
if (lin... | javascript | function(e) {
var stack = e.stacktrace;
var lines = stack.split('\n'), ANON = '{anonymous}', lineRE = /.*line (\d+), column (\d+) in ((<anonymous function\:?\s*(\S+))|([^\(]+)\([^\)]*\))(?: in )?(.*)\s*$/i, i, j, len;
for (i = 2, j = 0, len = lines.length; i < len - 2; i++) {
if (lin... | [
"function",
"(",
"e",
")",
"{",
"var",
"stack",
"=",
"e",
".",
"stacktrace",
";",
"var",
"lines",
"=",
"stack",
".",
"split",
"(",
"'\\n'",
")",
",",
"ANON",
"=",
"'{anonymous}'",
",",
"lineRE",
"=",
"/",
".*line (\\d+), column (\\d+) in ((<anonymous functio... | Given an Error object, return a formatted Array based on Opera 10's stacktrace string.
@param e - Error object to inspect
@return Array<String> of function calls, files and line numbers | [
"Given",
"an",
"Error",
"object",
"return",
"a",
"formatted",
"Array",
"based",
"on",
"Opera",
"10",
"s",
"stacktrace",
"string",
"."
] | 8264b88904415f64310f0640937978867ca2d1b8 | https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L164-L178 | train | |
tmont/jarvis | src/stacktrace.js | function(e) {
var lines = e.message.split('\n'), ANON = '{anonymous}', lineRE = /Line\s+(\d+).*script\s+(http\S+)(?:.*in\s+function\s+(\S+))?/i, i, j, len;
for (i = 4, j = 0, len = lines.length; i < len; i += 2) {
//TODO: RegExp.exec() would probably be cleaner here
if (lineRE.t... | javascript | function(e) {
var lines = e.message.split('\n'), ANON = '{anonymous}', lineRE = /Line\s+(\d+).*script\s+(http\S+)(?:.*in\s+function\s+(\S+))?/i, i, j, len;
for (i = 4, j = 0, len = lines.length; i < len; i += 2) {
//TODO: RegExp.exec() would probably be cleaner here
if (lineRE.t... | [
"function",
"(",
"e",
")",
"{",
"var",
"lines",
"=",
"e",
".",
"message",
".",
"split",
"(",
"'\\n'",
")",
",",
"ANON",
"=",
"'{anonymous}'",
",",
"lineRE",
"=",
"/",
"Line\\s+(\\d+).*script\\s+(http\\S+)(?:.*in\\s+function\\s+(\\S+))?",
"/",
"i",
",",
"i",
... | Opera 7.x-9.x only! | [
"Opera",
"7",
".",
"x",
"-",
"9",
".",
"x",
"only!"
] | 8264b88904415f64310f0640937978867ca2d1b8 | https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L181-L193 | train | |
tmont/jarvis | src/stacktrace.js | function(curr) {
var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], fn, args, maxStackSize = 10;
while (curr && stack.length < maxStackSize) {
fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON;
args = Array.prototype.slice.call(curr['arguments']... | javascript | function(curr) {
var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], fn, args, maxStackSize = 10;
while (curr && stack.length < maxStackSize) {
fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON;
args = Array.prototype.slice.call(curr['arguments']... | [
"function",
"(",
"curr",
")",
"{",
"var",
"ANON",
"=",
"'{anonymous}'",
",",
"fnRE",
"=",
"/",
"function\\s*([\\w\\-$]+)?\\s*\\(",
"/",
"i",
",",
"stack",
"=",
"[",
"]",
",",
"fn",
",",
"args",
",",
"maxStackSize",
"=",
"10",
";",
"while",
"(",
"curr",... | Safari, IE, and others | [
"Safari",
"IE",
"and",
"others"
] | 8264b88904415f64310f0640937978867ca2d1b8 | https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L196-L205 | train | |
tmont/jarvis | src/stacktrace.js | function(args) {
for (var i = 0; i < args.length; ++i) {
var arg = args[i];
if (arg === undefined) {
args[i] = 'undefined';
} else if (arg === null) {
args[i] = 'null';
} else if (arg.constructor) {
if (arg.construct... | javascript | function(args) {
for (var i = 0; i < args.length; ++i) {
var arg = args[i];
if (arg === undefined) {
args[i] = 'undefined';
} else if (arg === null) {
args[i] = 'null';
} else if (arg.constructor) {
if (arg.construct... | [
"function",
"(",
"args",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"arg",
"=",
"args",
"[",
"i",
"]",
";",
"if",
"(",
"arg",
"===",
"undefined",
")",
"{",
"args",
"[",... | Given arguments array as a String, subsituting type names for non-string types.
@param {Arguments} object
@return {Array} of Strings with stringified arguments | [
"Given",
"arguments",
"array",
"as",
"a",
"String",
"subsituting",
"type",
"names",
"for",
"non",
"-",
"string",
"types",
"."
] | 8264b88904415f64310f0640937978867ca2d1b8 | https://github.com/tmont/jarvis/blob/8264b88904415f64310f0640937978867ca2d1b8/src/stacktrace.js#L213-L237 | train | |
liquidlight/postcss-pseudo-content-insert | index.js | arrayHasValue | function arrayHasValue(arr, value) {
var idx = arr.indexOf(value);
if (idx !== -1) {
return true;
}
return false;
} | javascript | function arrayHasValue(arr, value) {
var idx = arr.indexOf(value);
if (idx !== -1) {
return true;
}
return false;
} | [
"function",
"arrayHasValue",
"(",
"arr",
",",
"value",
")",
"{",
"var",
"idx",
"=",
"arr",
".",
"indexOf",
"(",
"value",
")",
";",
"if",
"(",
"idx",
"!==",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks to see if a value exists in an array | [
"Checks",
"to",
"see",
"if",
"a",
"value",
"exists",
"in",
"an",
"array"
] | 51fd77d93a0cfb6a718a19d311f8e0b7108b82e5 | https://github.com/liquidlight/postcss-pseudo-content-insert/blob/51fd77d93a0cfb6a718a19d311f8e0b7108b82e5/index.js#L19-L25 | train |
lakenen/wrap-range-text | index.js | getTextNodes | function getTextNodes(el) {
el = el || document.body
var doc = el.ownerDocument || document
, walker = doc.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false)
, textNodes = []
, node
while (node = walker.nextNode()) {
textNodes.push(node)
}
return textNodes
} | javascript | function getTextNodes(el) {
el = el || document.body
var doc = el.ownerDocument || document
, walker = doc.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false)
, textNodes = []
, node
while (node = walker.nextNode()) {
textNodes.push(node)
}
return textNodes
} | [
"function",
"getTextNodes",
"(",
"el",
")",
"{",
"el",
"=",
"el",
"||",
"document",
".",
"body",
"var",
"doc",
"=",
"el",
".",
"ownerDocument",
"||",
"document",
",",
"walker",
"=",
"doc",
".",
"createTreeWalker",
"(",
"el",
",",
"NodeFilter",
".",
"SH... | return all text nodes that are contained within `el` | [
"return",
"all",
"text",
"nodes",
"that",
"are",
"contained",
"within",
"el"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L3-L15 | train |
lakenen/wrap-range-text | index.js | rangesIntersect | function rangesIntersect(rangeA, rangeB) {
return rangeA.compareBoundaryPoints(Range.END_TO_START, rangeB) === -1 &&
rangeA.compareBoundaryPoints(Range.START_TO_END, rangeB) === 1
} | javascript | function rangesIntersect(rangeA, rangeB) {
return rangeA.compareBoundaryPoints(Range.END_TO_START, rangeB) === -1 &&
rangeA.compareBoundaryPoints(Range.START_TO_END, rangeB) === 1
} | [
"function",
"rangesIntersect",
"(",
"rangeA",
",",
"rangeB",
")",
"{",
"return",
"rangeA",
".",
"compareBoundaryPoints",
"(",
"Range",
".",
"END_TO_START",
",",
"rangeB",
")",
"===",
"-",
"1",
"&&",
"rangeA",
".",
"compareBoundaryPoints",
"(",
"Range",
".",
... | return true if `rangeA` intersects `rangeB` | [
"return",
"true",
"if",
"rangeA",
"intersects",
"rangeB"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L18-L21 | train |
lakenen/wrap-range-text | index.js | createRangeFromNode | function createRangeFromNode(node) {
var range = node.ownerDocument.createRange()
try {
range.selectNode(node)
} catch (e) {
range.selectNodeContents(node)
}
return range
} | javascript | function createRangeFromNode(node) {
var range = node.ownerDocument.createRange()
try {
range.selectNode(node)
} catch (e) {
range.selectNodeContents(node)
}
return range
} | [
"function",
"createRangeFromNode",
"(",
"node",
")",
"{",
"var",
"range",
"=",
"node",
".",
"ownerDocument",
".",
"createRange",
"(",
")",
"try",
"{",
"range",
".",
"selectNode",
"(",
"node",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"range",
".",
"select... | create and return a range that selects `node` | [
"create",
"and",
"return",
"a",
"range",
"that",
"selects",
"node"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L24-L32 | train |
lakenen/wrap-range-text | index.js | rangeIntersectsNode | function rangeIntersectsNode(range, node) {
if (range.intersectsNode) {
return range.intersectsNode(node)
} else {
return rangesIntersect(range, createRangeFromNode(node))
}
} | javascript | function rangeIntersectsNode(range, node) {
if (range.intersectsNode) {
return range.intersectsNode(node)
} else {
return rangesIntersect(range, createRangeFromNode(node))
}
} | [
"function",
"rangeIntersectsNode",
"(",
"range",
",",
"node",
")",
"{",
"if",
"(",
"range",
".",
"intersectsNode",
")",
"{",
"return",
"range",
".",
"intersectsNode",
"(",
"node",
")",
"}",
"else",
"{",
"return",
"rangesIntersect",
"(",
"range",
",",
"crea... | return true if `node` is fully or partially selected by `range` | [
"return",
"true",
"if",
"node",
"is",
"fully",
"or",
"partially",
"selected",
"by",
"range"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L35-L41 | train |
lakenen/wrap-range-text | index.js | getRangeTextNodes | function getRangeTextNodes(range) {
var container = range.commonAncestorContainer
, nodes = getTextNodes(container.parentNode || container)
return nodes.filter(function (node) {
return rangeIntersectsNode(range, node) && isNonEmptyTextNode(node)
})
} | javascript | function getRangeTextNodes(range) {
var container = range.commonAncestorContainer
, nodes = getTextNodes(container.parentNode || container)
return nodes.filter(function (node) {
return rangeIntersectsNode(range, node) && isNonEmptyTextNode(node)
})
} | [
"function",
"getRangeTextNodes",
"(",
"range",
")",
"{",
"var",
"container",
"=",
"range",
".",
"commonAncestorContainer",
",",
"nodes",
"=",
"getTextNodes",
"(",
"container",
".",
"parentNode",
"||",
"container",
")",
"return",
"nodes",
".",
"filter",
"(",
"f... | return all non-empty text nodes fully or partially selected by `range` | [
"return",
"all",
"non",
"-",
"empty",
"text",
"nodes",
"fully",
"or",
"partially",
"selected",
"by",
"range"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L44-L51 | train |
lakenen/wrap-range-text | index.js | replaceNode | function replaceNode(replacementNode, node) {
remove(replacementNode)
node.parentNode.insertBefore(replacementNode, node)
remove(node)
} | javascript | function replaceNode(replacementNode, node) {
remove(replacementNode)
node.parentNode.insertBefore(replacementNode, node)
remove(node)
} | [
"function",
"replaceNode",
"(",
"replacementNode",
",",
"node",
")",
"{",
"remove",
"(",
"replacementNode",
")",
"node",
".",
"parentNode",
".",
"insertBefore",
"(",
"replacementNode",
",",
"node",
")",
"remove",
"(",
"node",
")",
"}"
] | replace `node` with `replacementNode` | [
"replace",
"node",
"with",
"replacementNode"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L66-L70 | train |
lakenen/wrap-range-text | index.js | unwrap | function unwrap(el) {
var range = document.createRange()
range.selectNodeContents(el)
replaceNode(range.extractContents(), el)
} | javascript | function unwrap(el) {
var range = document.createRange()
range.selectNodeContents(el)
replaceNode(range.extractContents(), el)
} | [
"function",
"unwrap",
"(",
"el",
")",
"{",
"var",
"range",
"=",
"document",
".",
"createRange",
"(",
")",
"range",
".",
"selectNodeContents",
"(",
"el",
")",
"replaceNode",
"(",
"range",
".",
"extractContents",
"(",
")",
",",
"el",
")",
"}"
] | unwrap `el` by replacing itself with its contents | [
"unwrap",
"el",
"by",
"replacing",
"itself",
"with",
"its",
"contents"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L73-L77 | train |
lakenen/wrap-range-text | index.js | undo | function undo(nodes) {
nodes.forEach(function (node) {
var parent = node.parentNode
unwrap(node)
parent.normalize()
})
} | javascript | function undo(nodes) {
nodes.forEach(function (node) {
var parent = node.parentNode
unwrap(node)
parent.normalize()
})
} | [
"function",
"undo",
"(",
"nodes",
")",
"{",
"nodes",
".",
"forEach",
"(",
"function",
"(",
"node",
")",
"{",
"var",
"parent",
"=",
"node",
".",
"parentNode",
"unwrap",
"(",
"node",
")",
"parent",
".",
"normalize",
"(",
")",
"}",
")",
"}"
] | undo the effect of `wrapRangeText`, given a resulting array of wrapper `nodes` | [
"undo",
"the",
"effect",
"of",
"wrapRangeText",
"given",
"a",
"resulting",
"array",
"of",
"wrapper",
"nodes"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L80-L86 | train |
lakenen/wrap-range-text | index.js | createWrapperFunction | function createWrapperFunction(wrapperEl, range) {
var startNode = range.startContainer
, endNode = range.endContainer
, startOffset = range.startOffset
, endOffset = range.endOffset
return function wrapNode(node) {
var currentRange = document.createRange()
, currentWrapper = wrapperE... | javascript | function createWrapperFunction(wrapperEl, range) {
var startNode = range.startContainer
, endNode = range.endContainer
, startOffset = range.startOffset
, endOffset = range.endOffset
return function wrapNode(node) {
var currentRange = document.createRange()
, currentWrapper = wrapperE... | [
"function",
"createWrapperFunction",
"(",
"wrapperEl",
",",
"range",
")",
"{",
"var",
"startNode",
"=",
"range",
".",
"startContainer",
",",
"endNode",
"=",
"range",
".",
"endContainer",
",",
"startOffset",
"=",
"range",
".",
"startOffset",
",",
"endOffset",
"... | create a node wrapper function | [
"create",
"a",
"node",
"wrapper",
"function"
] | b71282c935ba2412e1662b7e77f8b954e3033196 | https://github.com/lakenen/wrap-range-text/blob/b71282c935ba2412e1662b7e77f8b954e3033196/index.js#L89-L115 | train |
constgen/cross-channel | src/types/message.js | Message | function Message(data, source){
source = source || {}
this.data = data
this.key = source.key
this.sourceChannel = source.name
} | javascript | function Message(data, source){
source = source || {}
this.data = data
this.key = source.key
this.sourceChannel = source.name
} | [
"function",
"Message",
"(",
"data",
",",
"source",
")",
"{",
"source",
"=",
"source",
"||",
"{",
"}",
"this",
".",
"data",
"=",
"data",
"this",
".",
"key",
"=",
"source",
".",
"key",
"this",
".",
"sourceChannel",
"=",
"source",
".",
"name",
"}"
] | Message entity constructor
@param {*} data - any data to be transfered
@param {Object} [source] - source sent from | [
"Message",
"entity",
"constructor"
] | 0dc0f57827aca6496721d6e20bd1b9d87e9c8fbe | https://github.com/constgen/cross-channel/blob/0dc0f57827aca6496721d6e20bd1b9d87e9c8fbe/src/types/message.js#L10-L15 | train |
PersonifyJS/personify.js | util/watson.js | function(options, content, res) {
return function (/*function*/ callback) {
// create the post data to send to the User Modeling service
var post_data = {
'contentItems' : [{
'userid' : 'dummy',
'id' : 'dummyUuid',
'sourceid' : 'freetext',
'contenttype' : 'text/plain',
... | javascript | function(options, content, res) {
return function (/*function*/ callback) {
// create the post data to send to the User Modeling service
var post_data = {
'contentItems' : [{
'userid' : 'dummy',
'id' : 'dummyUuid',
'sourceid' : 'freetext',
'contenttype' : 'text/plain',
... | [
"function",
"(",
"options",
",",
"content",
",",
"res",
")",
"{",
"return",
"function",
"(",
"/*function*/",
"callback",
")",
"{",
"// create the post data to send to the User Modeling service",
"var",
"post_data",
"=",
"{",
"'contentItems'",
":",
"[",
"{",
"'userid... | creates a request function using the https options and the text in content the function that return receives a callback | [
"creates",
"a",
"request",
"function",
"using",
"the",
"https",
"options",
"and",
"the",
"text",
"in",
"content",
"the",
"function",
"that",
"return",
"receives",
"a",
"callback"
] | 2308690d7567fe1f22796e91956f74e729e95670 | https://github.com/PersonifyJS/personify.js/blob/2308690d7567fe1f22796e91956f74e729e95670/util/watson.js#L74-L113 | train | |
waigo/waigo | src/config/index.js | function(name) {
try {
debug(`Loading ${name} configuration`);
return waigo.load(`config/${name}`);
} catch (e) {
debug(`Error loading config: ${name}`);
debug(e);
return null;
}
} | javascript | function(name) {
try {
debug(`Loading ${name} configuration`);
return waigo.load(`config/${name}`);
} catch (e) {
debug(`Error loading config: ${name}`);
debug(e);
return null;
}
} | [
"function",
"(",
"name",
")",
"{",
"try",
"{",
"debug",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"return",
"waigo",
".",
"load",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"debug",
"(",
"`",
"${",
"name... | Load config module.
@param {String} name Config module name.
@return {Function} `null` if module not found. | [
"Load",
"config",
"module",
"."
] | b2f50cd66b8b19016e2c7de75733330c791c76ff | https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/config/index.js#L16-L27 | train | |
mkay581/build-tools | src/browserify.js | function (destPath, srcPaths, options) {
let stream,
b,
finalPaths = [];
return new Promise(function (resolve, reject) {
_.each(srcPaths, function (path) {
// deal with file globs
if (glob.hasMagic(path)) {
glob.sync(path).forEach((p) => {
... | javascript | function (destPath, srcPaths, options) {
let stream,
b,
finalPaths = [];
return new Promise(function (resolve, reject) {
_.each(srcPaths, function (path) {
// deal with file globs
if (glob.hasMagic(path)) {
glob.sync(path).forEach((p) => {
... | [
"function",
"(",
"destPath",
",",
"srcPaths",
",",
"options",
")",
"{",
"let",
"stream",
",",
"b",
",",
"finalPaths",
"=",
"[",
"]",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"_",
".",
"each",
"(",
"... | Browserifies a single file bundle.
@param destPath
@param srcPaths
@param options
@param {Object|Array} [options.requires] - Required files
@returns {Promise} | [
"Browserifies",
"a",
"single",
"file",
"bundle",
"."
] | 005cb840b5db017a33597a8d44d941d156a7a000 | https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/browserify.js#L18-L95 | train | |
mkay581/build-tools | src/browserify.js | function (stream, destPath) {
let data = '';
return new Promise(function (resolve, reject) {
stream.on('error', reject);
stream.on('data', function (d) {
data += d.toString();
});
stream.on('end', function () {
fs.outputFile(destPath, data, function (err) ... | javascript | function (stream, destPath) {
let data = '';
return new Promise(function (resolve, reject) {
stream.on('error', reject);
stream.on('data', function (d) {
data += d.toString();
});
stream.on('end', function () {
fs.outputFile(destPath, data, function (err) ... | [
"function",
"(",
"stream",
",",
"destPath",
")",
"{",
"let",
"data",
"=",
"''",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"stream",
".",
"on",
"(",
"'error'",
",",
"reject",
")",
";",
"stream",
".",
... | Handles writing the browserify bundle stream to the destination file.
@param {EventEmitter} stream - The bundle stream
@param {string} destPath - The destination file
@private | [
"Handles",
"writing",
"the",
"browserify",
"bundle",
"stream",
"to",
"the",
"destination",
"file",
"."
] | 005cb840b5db017a33597a8d44d941d156a7a000 | https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/browserify.js#L103-L120 | train | |
iraycd/brickwork | brickwork.js | fillMatrix | function fillMatrix(id, t, l, w, h) {
for (var y = t; y < t + h;) {
for (var x = l; x < l + w;) {
matrix[y + '-' + x] = id;
++x > maxX && (maxX = x);
}
++y > maxY && (maxY = y);
}
... | javascript | function fillMatrix(id, t, l, w, h) {
for (var y = t; y < t + h;) {
for (var x = l; x < l + w;) {
matrix[y + '-' + x] = id;
++x > maxX && (maxX = x);
}
++y > maxY && (maxY = y);
}
... | [
"function",
"fillMatrix",
"(",
"id",
",",
"t",
",",
"l",
",",
"w",
",",
"h",
")",
"{",
"for",
"(",
"var",
"y",
"=",
"t",
";",
"y",
"<",
"t",
"+",
"h",
";",
")",
"{",
"for",
"(",
"var",
"x",
"=",
"l",
";",
"x",
"<",
"l",
"+",
"w",
";",... | fill area with top, left, width, height; | [
"fill",
"area",
"with",
"top",
"left",
"width",
"height",
";"
] | d6805e7601b7ee43760aa37e68a127b1723fadfa | https://github.com/iraycd/brickwork/blob/d6805e7601b7ee43760aa37e68a127b1723fadfa/brickwork.js#L569-L577 | train |
kogarashisan/LiquidLava | dependencies/jison/lib/jison/json2jison.js | json2jison | function json2jison (grammar, options) {
options = options || {};
var s = "";
s += genDecls(grammar, options);
s += genBNF(grammar.bnf, options);
return s;
} | javascript | function json2jison (grammar, options) {
options = options || {};
var s = "";
s += genDecls(grammar, options);
s += genBNF(grammar.bnf, options);
return s;
} | [
"function",
"json2jison",
"(",
"grammar",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"s",
"=",
"\"\"",
";",
"s",
"+=",
"genDecls",
"(",
"grammar",
",",
"options",
")",
";",
"s",
"+=",
"genBNF",
"(",
"grammar",
... | converts json grammar format to Jison grammar format | [
"converts",
"json",
"grammar",
"format",
"to",
"Jison",
"grammar",
"format"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/dependencies/jison/lib/jison/json2jison.js#L3-L11 | train |
kogarashisan/LiquidLava | dependencies/jison/lib/jison/json2jison.js | genLex | function genLex (lex) {
var s = [];
if (lex.macros) {
for (var macro in lex.macros) if (lex.macros.hasOwnProperty(macro)) {
s.push(macro, ' ', lex.macros[macro], '\n');
}
}
if (lex.actionInclude) {
s.push('\n%{\n', lex.actionInclude, '\n%}\n');
}
s.pu... | javascript | function genLex (lex) {
var s = [];
if (lex.macros) {
for (var macro in lex.macros) if (lex.macros.hasOwnProperty(macro)) {
s.push(macro, ' ', lex.macros[macro], '\n');
}
}
if (lex.actionInclude) {
s.push('\n%{\n', lex.actionInclude, '\n%}\n');
}
s.pu... | [
"function",
"genLex",
"(",
"lex",
")",
"{",
"var",
"s",
"=",
"[",
"]",
";",
"if",
"(",
"lex",
".",
"macros",
")",
"{",
"for",
"(",
"var",
"macro",
"in",
"lex",
".",
"macros",
")",
"if",
"(",
"lex",
".",
"macros",
".",
"hasOwnProperty",
"(",
"ma... | Generate lex format from lex JSON | [
"Generate",
"lex",
"format",
"from",
"lex",
"JSON"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/dependencies/jison/lib/jison/json2jison.js#L102-L122 | train |
tunnckoCore/fs-readdir | index.js | fsReaddirSync | function fsReaddirSync(root, files, fp) {
if (typeof root !== 'string') {
throw new TypeError('fsReaddir.sync: expect `root` to be string');
}
fp = fp || '';
files = files || [];
var dir = path.join(root, fp);
if (fs.statSync(dir).isDirectory()) {
fs.readdirSync(dir).forEach(function(name) {
... | javascript | function fsReaddirSync(root, files, fp) {
if (typeof root !== 'string') {
throw new TypeError('fsReaddir.sync: expect `root` to be string');
}
fp = fp || '';
files = files || [];
var dir = path.join(root, fp);
if (fs.statSync(dir).isDirectory()) {
fs.readdirSync(dir).forEach(function(name) {
... | [
"function",
"fsReaddirSync",
"(",
"root",
",",
"files",
",",
"fp",
")",
"{",
"if",
"(",
"typeof",
"root",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'fsReaddir.sync: expect `root` to be string'",
")",
";",
"}",
"fp",
"=",
"fp",
"||",
"... | `fs-readdir-recursive` without filter feature
@param {String} `root`
@param {Array} `files`
@param {String} `fp`
@return {Array} | [
"fs",
"-",
"readdir",
"-",
"recursive",
"without",
"filter",
"feature"
] | f864015898e3f0215f25eeac75d8315bcd55639a | https://github.com/tunnckoCore/fs-readdir/blob/f864015898e3f0215f25eeac75d8315bcd55639a/index.js#L132-L150 | train |
mkay581/build-tools | src/copy.js | copyFileIntoDirectory | function copyFileIntoDirectory(srcPath, destPath) {
return ensureDestinationDirectory(destPath).then(function () {
return new Promise(function (resolve, reject) {
fs.readFile(srcPath, 'utf8', function (err, contents) {
if (!err) {
resolve()... | javascript | function copyFileIntoDirectory(srcPath, destPath) {
return ensureDestinationDirectory(destPath).then(function () {
return new Promise(function (resolve, reject) {
fs.readFile(srcPath, 'utf8', function (err, contents) {
if (!err) {
resolve()... | [
"function",
"copyFileIntoDirectory",
"(",
"srcPath",
",",
"destPath",
")",
"{",
"return",
"ensureDestinationDirectory",
"(",
"destPath",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject... | Copies a file into a directory.
@param {String} srcPath - source path
@param {String} destPath - destination path
@returns {Promise} Returns a promise when completed | [
"Copies",
"a",
"file",
"into",
"a",
"directory",
"."
] | 005cb840b5db017a33597a8d44d941d156a7a000 | https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/copy.js#L46-L65 | train |
mkay581/build-tools | src/copy.js | copyFile | function copyFile(srcPath, destPath) {
let srcFileInfo = path.parse(srcPath) || {};
if (!path.extname(destPath) && srcFileInfo.ext) {
// destination is a directory!
return copyFileIntoDirectory(srcPath, destPath);
} else {
return new Promise(function (resolve,... | javascript | function copyFile(srcPath, destPath) {
let srcFileInfo = path.parse(srcPath) || {};
if (!path.extname(destPath) && srcFileInfo.ext) {
// destination is a directory!
return copyFileIntoDirectory(srcPath, destPath);
} else {
return new Promise(function (resolve,... | [
"function",
"copyFile",
"(",
"srcPath",
",",
"destPath",
")",
"{",
"let",
"srcFileInfo",
"=",
"path",
".",
"parse",
"(",
"srcPath",
")",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"path",
".",
"extname",
"(",
"destPath",
")",
"&&",
"srcFileInfo",
".",
"ext... | Copies one path to another one.
@param {String} srcPath - source path
@param {String} destPath - destination path
@returns {Promise} Returns a promise when done | [
"Copies",
"one",
"path",
"to",
"another",
"one",
"."
] | 005cb840b5db017a33597a8d44d941d156a7a000 | https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/copy.js#L73-L89 | train |
mkay581/build-tools | src/copy.js | getSourceDestinationPath | function getSourceDestinationPath (srcPath) {
let dests = _.keys(options.files);
return _.find(dests, function (destPath) {
let paths = options.files[destPath];
return _.find(paths, function (p) {
return p === srcPath || srcPath.indexOf(p) !== -1;
});
... | javascript | function getSourceDestinationPath (srcPath) {
let dests = _.keys(options.files);
return _.find(dests, function (destPath) {
let paths = options.files[destPath];
return _.find(paths, function (p) {
return p === srcPath || srcPath.indexOf(p) !== -1;
});
... | [
"function",
"getSourceDestinationPath",
"(",
"srcPath",
")",
"{",
"let",
"dests",
"=",
"_",
".",
"keys",
"(",
"options",
".",
"files",
")",
";",
"return",
"_",
".",
"find",
"(",
"dests",
",",
"function",
"(",
"destPath",
")",
"{",
"let",
"paths",
"=",
... | Gets the destination path for a source file.
@param srcPath
@returns {string} Returns the matching destination path | [
"Gets",
"the",
"destination",
"path",
"for",
"a",
"source",
"file",
"."
] | 005cb840b5db017a33597a8d44d941d156a7a000 | https://github.com/mkay581/build-tools/blob/005cb840b5db017a33597a8d44d941d156a7a000/src/copy.js#L96-L104 | train |
andrewfhart/openassets | lib/protocol/ColoringEngine.js | function (tx) {
var outs = [];
tx.outputs.forEach(function (o) {
outs.push(new TransactionOutput(o.satoshis,o.script.toBuffer()));
});
return outs;
} | javascript | function (tx) {
var outs = [];
tx.outputs.forEach(function (o) {
outs.push(new TransactionOutput(o.satoshis,o.script.toBuffer()));
});
return outs;
} | [
"function",
"(",
"tx",
")",
"{",
"var",
"outs",
"=",
"[",
"]",
";",
"tx",
".",
"outputs",
".",
"forEach",
"(",
"function",
"(",
"o",
")",
"{",
"outs",
".",
"push",
"(",
"new",
"TransactionOutput",
"(",
"o",
".",
"satoshis",
",",
"o",
".",
"script... | Helper function to make the appropriate response in the case where no valid asset ids were found in a transaction. In this case all of the transaction outputs are considered uncolored. | [
"Helper",
"function",
"to",
"make",
"the",
"appropriate",
"response",
"in",
"the",
"case",
"where",
"no",
"valid",
"asset",
"ids",
"were",
"found",
"in",
"a",
"transaction",
".",
"In",
"this",
"case",
"all",
"of",
"the",
"transaction",
"outputs",
"are",
"c... | e61f238e159ae5584d28bb2e911f2995c14d45e0 | https://github.com/andrewfhart/openassets/blob/e61f238e159ae5584d28bb2e911f2995c14d45e0/lib/protocol/ColoringEngine.js#L116-L122 | train | |
greg-js/hexo-easy-edit | lib/edit.js | filterTitle | function filterTitle(posts) {
var reTitle = title.map(function makeRE(word) {
return new RegExp(word, 'i');
});
return posts.filter(function filterPosts(post) {
return reTitle.every(function checkRE(regex) {
return regex.test(post.title) || regex.test(post.slug);
});... | javascript | function filterTitle(posts) {
var reTitle = title.map(function makeRE(word) {
return new RegExp(word, 'i');
});
return posts.filter(function filterPosts(post) {
return reTitle.every(function checkRE(regex) {
return regex.test(post.title) || regex.test(post.slug);
});... | [
"function",
"filterTitle",
"(",
"posts",
")",
"{",
"var",
"reTitle",
"=",
"title",
".",
"map",
"(",
"function",
"makeRE",
"(",
"word",
")",
"{",
"return",
"new",
"RegExp",
"(",
"word",
",",
"'i'",
")",
";",
"}",
")",
";",
"return",
"posts",
".",
"f... | filter the posts with the supplied regular expression | [
"filter",
"the",
"posts",
"with",
"the",
"supplied",
"regular",
"expression"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L93-L103 | train |
greg-js/hexo-easy-edit | lib/edit.js | filterFolder | function filterFolder(posts) {
var reFolder = new RegExp(folder);
return posts.filter(function filterPosts(post) {
return reFolder.test(post.source.substr(0, post.source.lastIndexOf(path.sep)));
});
} | javascript | function filterFolder(posts) {
var reFolder = new RegExp(folder);
return posts.filter(function filterPosts(post) {
return reFolder.test(post.source.substr(0, post.source.lastIndexOf(path.sep)));
});
} | [
"function",
"filterFolder",
"(",
"posts",
")",
"{",
"var",
"reFolder",
"=",
"new",
"RegExp",
"(",
"folder",
")",
";",
"return",
"posts",
".",
"filter",
"(",
"function",
"filterPosts",
"(",
"post",
")",
"{",
"return",
"reFolder",
".",
"test",
"(",
"post",... | filter the posts using a subfolder if supplied | [
"filter",
"the",
"posts",
"using",
"a",
"subfolder",
"if",
"supplied"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L106-L111 | train |
greg-js/hexo-easy-edit | lib/edit.js | filterTag | function filterTag(posts) {
var reTag = new RegExp(tag);
return posts.filter(function filterPosts(post) {
return post.tags.data.some(function checkRe(postTag) {
return reTag.test(postTag.name);
});
});
} | javascript | function filterTag(posts) {
var reTag = new RegExp(tag);
return posts.filter(function filterPosts(post) {
return post.tags.data.some(function checkRe(postTag) {
return reTag.test(postTag.name);
});
});
} | [
"function",
"filterTag",
"(",
"posts",
")",
"{",
"var",
"reTag",
"=",
"new",
"RegExp",
"(",
"tag",
")",
";",
"return",
"posts",
".",
"filter",
"(",
"function",
"filterPosts",
"(",
"post",
")",
"{",
"return",
"post",
".",
"tags",
".",
"data",
".",
"so... | filter the posts using a tag if supplied | [
"filter",
"the",
"posts",
"using",
"a",
"tag",
"if",
"supplied"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L114-L121 | train |
greg-js/hexo-easy-edit | lib/edit.js | filterCategory | function filterCategory(posts) {
var reCat = new RegExp(cat);
return posts.filter(function filterPosts(post) {
return post.categories.data.some(function checkRe(postCat) {
return reCat.test(postCat.name);
});
});
} | javascript | function filterCategory(posts) {
var reCat = new RegExp(cat);
return posts.filter(function filterPosts(post) {
return post.categories.data.some(function checkRe(postCat) {
return reCat.test(postCat.name);
});
});
} | [
"function",
"filterCategory",
"(",
"posts",
")",
"{",
"var",
"reCat",
"=",
"new",
"RegExp",
"(",
"cat",
")",
";",
"return",
"posts",
".",
"filter",
"(",
"function",
"filterPosts",
"(",
"post",
")",
"{",
"return",
"post",
".",
"categories",
".",
"data",
... | filter the posts using a category if supplied | [
"filter",
"the",
"posts",
"using",
"a",
"category",
"if",
"supplied"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L124-L131 | train |
greg-js/hexo-easy-edit | lib/edit.js | filterLayout | function filterLayout(posts) {
var reLayout = new RegExp(layout, 'i');
return posts.filter(function filterPosts(post) {
return reLayout.test(post.layout);
});
} | javascript | function filterLayout(posts) {
var reLayout = new RegExp(layout, 'i');
return posts.filter(function filterPosts(post) {
return reLayout.test(post.layout);
});
} | [
"function",
"filterLayout",
"(",
"posts",
")",
"{",
"var",
"reLayout",
"=",
"new",
"RegExp",
"(",
"layout",
",",
"'i'",
")",
";",
"return",
"posts",
".",
"filter",
"(",
"function",
"filterPosts",
"(",
"post",
")",
"{",
"return",
"reLayout",
".",
"test",
... | filter the posts using a layout if supplied | [
"filter",
"the",
"posts",
"using",
"a",
"layout",
"if",
"supplied"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L134-L140 | train |
greg-js/hexo-easy-edit | lib/edit.js | filterBefore | function filterBefore(posts) {
before = moment(before.replace(/\//g, '-'), 'MM-DD-YYYY', true);
if (!before.isValid()) {
console.log(chalk.red('Before date is not valid (expecting `MM-DD-YYYY`), ignoring argument.'));
return posts;
}
return posts.filter(function filterPosts(post... | javascript | function filterBefore(posts) {
before = moment(before.replace(/\//g, '-'), 'MM-DD-YYYY', true);
if (!before.isValid()) {
console.log(chalk.red('Before date is not valid (expecting `MM-DD-YYYY`), ignoring argument.'));
return posts;
}
return posts.filter(function filterPosts(post... | [
"function",
"filterBefore",
"(",
"posts",
")",
"{",
"before",
"=",
"moment",
"(",
"before",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"'-'",
")",
",",
"'MM-DD-YYYY'",
",",
"true",
")",
";",
"if",
"(",
"!",
"before",
".",
"isValid",
"(",
")",
... | filter the posts using a before date if supplied | [
"filter",
"the",
"posts",
"using",
"a",
"before",
"date",
"if",
"supplied"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L150-L160 | train |
greg-js/hexo-easy-edit | lib/edit.js | filterAfter | function filterAfter(posts) {
after = moment(after.replace(/\//g, '-'), 'MM-DD-YYYY', true);
if (!after.isValid()) {
console.log(chalk.red('After date is not valid (expecting `MM-DD-YYYY`), ignoring argument.'));
return posts;
}
return posts.filter(function filterPosts(post) {
... | javascript | function filterAfter(posts) {
after = moment(after.replace(/\//g, '-'), 'MM-DD-YYYY', true);
if (!after.isValid()) {
console.log(chalk.red('After date is not valid (expecting `MM-DD-YYYY`), ignoring argument.'));
return posts;
}
return posts.filter(function filterPosts(post) {
... | [
"function",
"filterAfter",
"(",
"posts",
")",
"{",
"after",
"=",
"moment",
"(",
"after",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"'-'",
")",
",",
"'MM-DD-YYYY'",
",",
"true",
")",
";",
"if",
"(",
"!",
"after",
".",
"isValid",
"(",
")",
")... | filter the posts using an after date if supplied | [
"filter",
"the",
"posts",
"using",
"an",
"after",
"date",
"if",
"supplied"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L163-L173 | train |
greg-js/hexo-easy-edit | lib/edit.js | openFile | function openFile(file) {
var edit;
if (!editor || gui) {
open(file);
} else {
edit = spawn(editor, [file], {stdio: 'inherit'});
edit.on('exit', process.exit);
}
} | javascript | function openFile(file) {
var edit;
if (!editor || gui) {
open(file);
} else {
edit = spawn(editor, [file], {stdio: 'inherit'});
edit.on('exit', process.exit);
}
} | [
"function",
"openFile",
"(",
"file",
")",
"{",
"var",
"edit",
";",
"if",
"(",
"!",
"editor",
"||",
"gui",
")",
"{",
"open",
"(",
"file",
")",
";",
"}",
"else",
"{",
"edit",
"=",
"spawn",
"(",
"editor",
",",
"[",
"file",
"]",
",",
"{",
"stdio",
... | spawn process and open with associated gui or terminal editor | [
"spawn",
"process",
"and",
"open",
"with",
"associated",
"gui",
"or",
"terminal",
"editor"
] | a2686184de47bc0c8024f40816e637bb671b280f | https://github.com/greg-js/hexo-easy-edit/blob/a2686184de47bc0c8024f40816e637bb671b280f/lib/edit.js#L176-L184 | train |
porkchop/bitid-js | lib/bitid.js | Bitid | function Bitid(params) {
params = params || {};
var self = this;
this._nonce = params.nonce;
this.callback = url.parse(params.callback, true);
this.signature = params.signature;
this.address = params.address;
this.unsecure = params.unsecure;
this._uri = !params.uri ? buildURI() : url.parse(params.uri, ... | javascript | function Bitid(params) {
params = params || {};
var self = this;
this._nonce = params.nonce;
this.callback = url.parse(params.callback, true);
this.signature = params.signature;
this.address = params.address;
this.unsecure = params.unsecure;
this._uri = !params.uri ? buildURI() : url.parse(params.uri, ... | [
"function",
"Bitid",
"(",
"params",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_nonce",
"=",
"params",
".",
"nonce",
";",
"this",
".",
"callback",
"=",
"url",
".",
"parse",
"(",
"params",
... | Initialize a new `Bitid` with the given `params`
@param {JSON} params
@api public | [
"Initialize",
"a",
"new",
"Bitid",
"with",
"the",
"given",
"params"
] | 994d468c624e6bc816a73cce108daa303eb09c4e | https://github.com/porkchop/bitid-js/blob/994d468c624e6bc816a73cce108daa303eb09c4e/lib/bitid.js#L32-L54 | train |
mini-eggs/cra-babel-extend | src/index.js | getPresetsString | function getPresetsString(presetArray) {
if (!presetArray.includes("react-app")) {
presetArray.push("react-app");
}
return presetArray.map(attachRequestResolve("preset")).join(",");
} | javascript | function getPresetsString(presetArray) {
if (!presetArray.includes("react-app")) {
presetArray.push("react-app");
}
return presetArray.map(attachRequestResolve("preset")).join(",");
} | [
"function",
"getPresetsString",
"(",
"presetArray",
")",
"{",
"if",
"(",
"!",
"presetArray",
".",
"includes",
"(",
"\"react-app\"",
")",
")",
"{",
"presetArray",
".",
"push",
"(",
"\"react-app\"",
")",
";",
"}",
"return",
"presetArray",
".",
"map",
"(",
"a... | Build string to insert from presets array. | [
"Build",
"string",
"to",
"insert",
"from",
"presets",
"array",
"."
] | 39bce9a446f1fd380b661d787cab5928fa6ecc86 | https://github.com/mini-eggs/cra-babel-extend/blob/39bce9a446f1fd380b661d787cab5928fa6ecc86/src/index.js#L22-L27 | train |
soajs/connect-mongo-soajs | lib/mongo.js | connect | function connect(obj, cb) {
if (obj.db) {
return cb();
}
if (obj.pending) {
return setImmediate(function () {
connect(obj, cb);
});
}
obj.pending = true;
var url = constructMongoLink(obj.config.name, obj.config.prefix, obj.config.servers, obj.config.URLParam,... | javascript | function connect(obj, cb) {
if (obj.db) {
return cb();
}
if (obj.pending) {
return setImmediate(function () {
connect(obj, cb);
});
}
obj.pending = true;
var url = constructMongoLink(obj.config.name, obj.config.prefix, obj.config.servers, obj.config.URLParam,... | [
"function",
"connect",
"(",
"obj",
",",
"cb",
")",
"{",
"if",
"(",
"obj",
".",
"db",
")",
"{",
"return",
"cb",
"(",
")",
";",
"}",
"if",
"(",
"obj",
".",
"pending",
")",
"{",
"return",
"setImmediate",
"(",
"function",
"(",
")",
"{",
"connect",
... | Ensure a connection to mongo without any race condition problem
@param {Object} obj
@param {Function} cb
@returns {*} | [
"Ensure",
"a",
"connection",
"to",
"mongo",
"without",
"any",
"race",
"condition",
"problem"
] | 27b7b0b0f25e75168857fd9d2be83cc07a0da868 | https://github.com/soajs/connect-mongo-soajs/blob/27b7b0b0f25e75168857fd9d2be83cc07a0da868/lib/mongo.js#L212-L285 | train |
dtudury/discontinuous-range | index.js | _SubRange | function _SubRange(low, high) {
this.low = low;
this.high = high;
this.length = 1 + high - low;
} | javascript | function _SubRange(low, high) {
this.low = low;
this.high = high;
this.length = 1 + high - low;
} | [
"function",
"_SubRange",
"(",
"low",
",",
"high",
")",
"{",
"this",
".",
"low",
"=",
"low",
";",
"this",
".",
"high",
"=",
"high",
";",
"this",
".",
"length",
"=",
"1",
"+",
"high",
"-",
"low",
";",
"}"
] | protected helper class | [
"protected",
"helper",
"class"
] | 8c9a05039f09ad795fa7aea1da5e75fa3a6a949a | https://github.com/dtudury/discontinuous-range/blob/8c9a05039f09ad795fa7aea1da5e75fa3a6a949a/index.js#L2-L6 | train |
makenova/nodeginx | nodeginx.js | manageNginx | function manageNginx (action, callback) {
// TODO: research if sending signals is better
// i.e. sudo nginx -s stop|quit|reload
exec(`sudo service nginx ${action}`, (err, stdout, stderr) => {
if (err) return callback(err)
return callback()
})
} | javascript | function manageNginx (action, callback) {
// TODO: research if sending signals is better
// i.e. sudo nginx -s stop|quit|reload
exec(`sudo service nginx ${action}`, (err, stdout, stderr) => {
if (err) return callback(err)
return callback()
})
} | [
"function",
"manageNginx",
"(",
"action",
",",
"callback",
")",
"{",
"// TODO: research if sending signals is better",
"// i.e. sudo nginx -s stop|quit|reload",
"exec",
"(",
"`",
"${",
"action",
"}",
"`",
",",
"(",
"err",
",",
"stdout",
",",
"stderr",
")",
"=>",
"... | Nginx process functions | [
"Nginx",
"process",
"functions"
] | 8c5d0c53780fbd4c94e4a15782f14cb0ab92498d | https://github.com/makenova/nodeginx/blob/8c5d0c53780fbd4c94e4a15782f14cb0ab92498d/nodeginx.js#L62-L69 | train |
hkjels/ntask | lib/project.js | Project | function Project(path) {
path = path || PWD;
this.root = '';
this.storage = '';
this.ignore = [];
this.resolvePaths(path);
} | javascript | function Project(path) {
path = path || PWD;
this.root = '';
this.storage = '';
this.ignore = [];
this.resolvePaths(path);
} | [
"function",
"Project",
"(",
"path",
")",
"{",
"path",
"=",
"path",
"||",
"PWD",
";",
"this",
".",
"root",
"=",
"''",
";",
"this",
".",
"storage",
"=",
"''",
";",
"this",
".",
"ignore",
"=",
"[",
"]",
";",
"this",
".",
"resolvePaths",
"(",
"path",... | Locates & sets up project
Path is only needed for testing, usual case `pwd` by default
@param {String}
@api private | [
"Locates",
"&",
"sets",
"up",
"project",
"Path",
"is",
"only",
"needed",
"for",
"testing",
"usual",
"case",
"pwd",
"by",
"default"
] | e0552042e743ef9584bc0f911245635df7acd634 | https://github.com/hkjels/ntask/blob/e0552042e743ef9584bc0f911245635df7acd634/lib/project.js#L47-L53 | train |
dpjanes/iotdb-homestar | bin/commands/install.js | function (module_name, module_folder) {
var module_path = path.resolve(module_folder);
// load current keystore
let keystored = {};
const filename = ".iotdb/keystore.json";
_.cfg.load.json([ filename ], docd => keystored = _.d.compose.deep(keystored, docd.doc));
// change it
_.d.set(keysto... | javascript | function (module_name, module_folder) {
var module_path = path.resolve(module_folder);
// load current keystore
let keystored = {};
const filename = ".iotdb/keystore.json";
_.cfg.load.json([ filename ], docd => keystored = _.d.compose.deep(keystored, docd.doc));
// change it
_.d.set(keysto... | [
"function",
"(",
"module_name",
",",
"module_folder",
")",
"{",
"var",
"module_path",
"=",
"path",
".",
"resolve",
"(",
"module_folder",
")",
";",
"// load current keystore",
"let",
"keystored",
"=",
"{",
"}",
";",
"const",
"filename",
"=",
"\".iotdb/keystore.js... | Add module info to the keystore | [
"Add",
"module",
"info",
"to",
"the",
"keystore"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/bin/commands/install.js#L217-L234 | train | |
dpjanes/iotdb-homestar | bin/commands/install.js | function (module_name, module_folder) {
var iotdb_dir = path.join(process.cwd(), module_folder, "node_modules", "iotdb");
console.log("- cleanup");
console.log(" path:", iotdb_dir);
try {
_rmdirSync(iotdb_dir);
} catch (x) {
}
} | javascript | function (module_name, module_folder) {
var iotdb_dir = path.join(process.cwd(), module_folder, "node_modules", "iotdb");
console.log("- cleanup");
console.log(" path:", iotdb_dir);
try {
_rmdirSync(iotdb_dir);
} catch (x) {
}
} | [
"function",
"(",
"module_name",
",",
"module_folder",
")",
"{",
"var",
"iotdb_dir",
"=",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"module_folder",
",",
"\"node_modules\"",
",",
"\"iotdb\"",
")",
";",
"console",
".",
"log",
"(",
"\"... | We don't need to have many copies of IOTDB laying about | [
"We",
"don",
"t",
"need",
"to",
"have",
"many",
"copies",
"of",
"IOTDB",
"laying",
"about"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/bin/commands/install.js#L239-L248 | train | |
dpjanes/iotdb-homestar | bin/commands/install.js | function (module_name, module_folder, callback) {
var module_folder = path.resolve(module_folder)
var module_packaged = _load_package(module_folder);
var module_dependencies = _.d.get(module_packaged, "/dependencies");
if (!module_dependencies) {
return callback();
}
module_dependencie... | javascript | function (module_name, module_folder, callback) {
var module_folder = path.resolve(module_folder)
var module_packaged = _load_package(module_folder);
var module_dependencies = _.d.get(module_packaged, "/dependencies");
if (!module_dependencies) {
return callback();
}
module_dependencie... | [
"function",
"(",
"module_name",
",",
"module_folder",
",",
"callback",
")",
"{",
"var",
"module_folder",
"=",
"path",
".",
"resolve",
"(",
"module_folder",
")",
"var",
"module_packaged",
"=",
"_load_package",
"(",
"module_folder",
")",
";",
"var",
"module_depend... | homestar.dependencies can allow more things to be installed into homestar,
essentially recursively | [
"homestar",
".",
"dependencies",
"can",
"allow",
"more",
"things",
"to",
"be",
"installed",
"into",
"homestar",
"essentially",
"recursively"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/bin/commands/install.js#L254-L293 | train | |
dpjanes/iotdb-homestar | bin/commands/install.js | function() {
try {
var statbuf = fs.statSync(folder);
if (statbuf.isDirectory()) {
return;
}
}
catch (x) {
}
try {
fs.mkdirSync("node_modules");
} catch (x) {
}
statbuf = fs.statSync(folder);
if (statbuf.isDirectory()) {
return;
... | javascript | function() {
try {
var statbuf = fs.statSync(folder);
if (statbuf.isDirectory()) {
return;
}
}
catch (x) {
}
try {
fs.mkdirSync("node_modules");
} catch (x) {
}
statbuf = fs.statSync(folder);
if (statbuf.isDirectory()) {
return;
... | [
"function",
"(",
")",
"{",
"try",
"{",
"var",
"statbuf",
"=",
"fs",
".",
"statSync",
"(",
"folder",
")",
";",
"if",
"(",
"statbuf",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
";",
"}",
"}",
"catch",
"(",
"x",
")",
"{",
"}",
"try",
"{",
... | The node_modules directory always goes in the current directory
so that NPM doesn't start placing things in parent directories | [
"The",
"node_modules",
"directory",
"always",
"goes",
"in",
"the",
"current",
"directory",
"so",
"that",
"NPM",
"doesn",
"t",
"start",
"placing",
"things",
"in",
"parent",
"directories"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/bin/commands/install.js#L299-L318 | train | |
creationix/git-node-fs | lib/node-fs.js | readFile | function readFile(path, callback) {
nodeFs.readFile(path, function (err, binary) {
if (err) {
if (err.code === "ENOENT") return callback();
return callback(err);
}
return callback(null, binary);
});
} | javascript | function readFile(path, callback) {
nodeFs.readFile(path, function (err, binary) {
if (err) {
if (err.code === "ENOENT") return callback();
return callback(err);
}
return callback(null, binary);
});
} | [
"function",
"readFile",
"(",
"path",
",",
"callback",
")",
"{",
"nodeFs",
".",
"readFile",
"(",
"path",
",",
"function",
"(",
"err",
",",
"binary",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"code",
"===",
"\"ENOENT\"",
")",
"retu... | Reads all bytes for given path. => binary => undefined if file does not exist | [
"Reads",
"all",
"bytes",
"for",
"given",
"path",
".",
"=",
">",
"binary",
"=",
">",
"undefined",
"if",
"file",
"does",
"not",
"exist"
] | 7c691d7281b49b1be77426701c2bf0535e1abcc9 | https://github.com/creationix/git-node-fs/blob/7c691d7281b49b1be77426701c2bf0535e1abcc9/lib/node-fs.js#L17-L25 | train |
creationix/git-node-fs | lib/node-fs.js | readChunk | function readChunk(path, start, end, callback) {
if (end < 0) {
return readLastChunk(path, start, end, callback);
}
var stream = nodeFs.createReadStream(path, {
start: start,
end: end - 1
});
var chunks = [];
stream.on("readable", function () {
var chunk = stream.read();
if (chunk === nu... | javascript | function readChunk(path, start, end, callback) {
if (end < 0) {
return readLastChunk(path, start, end, callback);
}
var stream = nodeFs.createReadStream(path, {
start: start,
end: end - 1
});
var chunks = [];
stream.on("readable", function () {
var chunk = stream.read();
if (chunk === nu... | [
"function",
"readChunk",
"(",
"path",
",",
"start",
",",
"end",
",",
"callback",
")",
"{",
"if",
"(",
"end",
"<",
"0",
")",
"{",
"return",
"readLastChunk",
"(",
"path",
",",
"start",
",",
"end",
",",
"callback",
")",
";",
"}",
"var",
"stream",
"=",... | Reads bytes from inclusive [start, end) exclusive for given path. => binary => undefined if file does not exist | [
"Reads",
"bytes",
"from",
"inclusive",
"[",
"start",
"end",
")",
"exclusive",
"for",
"given",
"path",
".",
"=",
">",
"binary",
"=",
">",
"undefined",
"if",
"file",
"does",
"not",
"exist"
] | 7c691d7281b49b1be77426701c2bf0535e1abcc9 | https://github.com/creationix/git-node-fs/blob/7c691d7281b49b1be77426701c2bf0535e1abcc9/lib/node-fs.js#L30-L48 | train |
creationix/git-node-fs | lib/node-fs.js | readLastChunk | function readLastChunk(path, start, end, callback) {
nodeFs.open(path, "r", function (err, fd) {
if (err) {
if (err.code === "EACCES") return callback();
return callback(err);
}
var buffer = new Buffer(4096);
var length = 0;
read();
// Only the first read needs to seek.
// All ... | javascript | function readLastChunk(path, start, end, callback) {
nodeFs.open(path, "r", function (err, fd) {
if (err) {
if (err.code === "EACCES") return callback();
return callback(err);
}
var buffer = new Buffer(4096);
var length = 0;
read();
// Only the first read needs to seek.
// All ... | [
"function",
"readLastChunk",
"(",
"path",
",",
"start",
",",
"end",
",",
"callback",
")",
"{",
"nodeFs",
".",
"open",
"(",
"path",
",",
"\"r\"",
",",
"function",
"(",
"err",
",",
"fd",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
... | Node.js readable streams do not support reading from a position to the end of the file, but we can roll our own using the lower-level fs.open and fs.read on a file descriptor, which allows read to seek. | [
"Node",
".",
"js",
"readable",
"streams",
"do",
"not",
"support",
"reading",
"from",
"a",
"position",
"to",
"the",
"end",
"of",
"the",
"file",
"but",
"we",
"can",
"roll",
"our",
"own",
"using",
"the",
"lower",
"-",
"level",
"fs",
".",
"open",
"and",
... | 7c691d7281b49b1be77426701c2bf0535e1abcc9 | https://github.com/creationix/git-node-fs/blob/7c691d7281b49b1be77426701c2bf0535e1abcc9/lib/node-fs.js#L53-L88 | train |
creationix/git-node-fs | lib/node-fs.js | writeFile | function writeFile(path, binary, callback) {
mkdirp(nodePath.dirname(path), function (err) {
if (err) return callback(err);
nodeFs.writeFile(path, binary, callback);
});
} | javascript | function writeFile(path, binary, callback) {
mkdirp(nodePath.dirname(path), function (err) {
if (err) return callback(err);
nodeFs.writeFile(path, binary, callback);
});
} | [
"function",
"writeFile",
"(",
"path",
",",
"binary",
",",
"callback",
")",
"{",
"mkdirp",
"(",
"nodePath",
".",
"dirname",
"(",
"path",
")",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"... | Writes all bytes over file at given path. Creates all necessary parent directories. => undefined | [
"Writes",
"all",
"bytes",
"over",
"file",
"at",
"given",
"path",
".",
"Creates",
"all",
"necessary",
"parent",
"directories",
".",
"=",
">",
"undefined"
] | 7c691d7281b49b1be77426701c2bf0535e1abcc9 | https://github.com/creationix/git-node-fs/blob/7c691d7281b49b1be77426701c2bf0535e1abcc9/lib/node-fs.js#L93-L98 | train |
creationix/git-node-fs | lib/node-fs.js | rename | function rename(oldPath, newPath, callback) {
var oldBase = nodePath.dirname(oldPath);
var newBase = nodePath.dirname(newPath);
if (oldBase === newBase) {
return nodeFs.rename(oldPath, newPath, callback);
}
mkdirp(nodePath.dirname(path), function (err) {
if (err) return callback(err);
nodeFs.renam... | javascript | function rename(oldPath, newPath, callback) {
var oldBase = nodePath.dirname(oldPath);
var newBase = nodePath.dirname(newPath);
if (oldBase === newBase) {
return nodeFs.rename(oldPath, newPath, callback);
}
mkdirp(nodePath.dirname(path), function (err) {
if (err) return callback(err);
nodeFs.renam... | [
"function",
"rename",
"(",
"oldPath",
",",
"newPath",
",",
"callback",
")",
"{",
"var",
"oldBase",
"=",
"nodePath",
".",
"dirname",
"(",
"oldPath",
")",
";",
"var",
"newBase",
"=",
"nodePath",
".",
"dirname",
"(",
"newPath",
")",
";",
"if",
"(",
"oldBa... | Renames the given file. Creates all necessary parent directories. => undefined | [
"Renames",
"the",
"given",
"file",
".",
"Creates",
"all",
"necessary",
"parent",
"directories",
".",
"=",
">",
"undefined"
] | 7c691d7281b49b1be77426701c2bf0535e1abcc9 | https://github.com/creationix/git-node-fs/blob/7c691d7281b49b1be77426701c2bf0535e1abcc9/lib/node-fs.js#L103-L113 | train |
IonicaBizau/emoji-logger | lib/index.js | emojiLogger | function emojiLogger(msg, type, override) {
// Get the type
var _type = emojiLogger.types[type || "info"];
if (!_type) {
throw new Err(`There is no such logger type: ${type}`, "NO_SUCH_LOGGER_TYPE");
}
emojiLogger.log(msg, _type, override);
} | javascript | function emojiLogger(msg, type, override) {
// Get the type
var _type = emojiLogger.types[type || "info"];
if (!_type) {
throw new Err(`There is no such logger type: ${type}`, "NO_SUCH_LOGGER_TYPE");
}
emojiLogger.log(msg, _type, override);
} | [
"function",
"emojiLogger",
"(",
"msg",
",",
"type",
",",
"override",
")",
"{",
"// Get the type",
"var",
"_type",
"=",
"emojiLogger",
".",
"types",
"[",
"type",
"||",
"\"info\"",
"]",
";",
"if",
"(",
"!",
"_type",
")",
"{",
"throw",
"new",
"Err",
"(",
... | emojiLogger
Logs the specified message.
@name emojiLogger
@function
@param {String} msg The message to log.
@param {String} type The message type (default: `"info"`).
@param {Object} override An object to override the type object fields. | [
"emojiLogger",
"Logs",
"the",
"specified",
"message",
"."
] | 50f33240f31059642a805badd018e1bf0ec90bff | https://github.com/IonicaBizau/emoji-logger/blob/50f33240f31059642a805badd018e1bf0ec90bff/lib/index.js#L22-L31 | train |
ghosert/grunt-applymin | tasks/applymin.js | function (targetFilePath, abspaths) {
// Change 'assets/mdeditor.min.js' to 'assets/' and 'mdeditor.min.js'
var pathFilename = _splitPathAndFilename(targetFilePath);
var targetPath = pathFilename[0];
var targetFilename = pathFilename[1];
// bug fix: assets/xxxxxxxx.mdeditor.min.js, xxxxxxxx can't c... | javascript | function (targetFilePath, abspaths) {
// Change 'assets/mdeditor.min.js' to 'assets/' and 'mdeditor.min.js'
var pathFilename = _splitPathAndFilename(targetFilePath);
var targetPath = pathFilename[0];
var targetFilename = pathFilename[1];
// bug fix: assets/xxxxxxxx.mdeditor.min.js, xxxxxxxx can't c... | [
"function",
"(",
"targetFilePath",
",",
"abspaths",
")",
"{",
"// Change 'assets/mdeditor.min.js' to 'assets/' and 'mdeditor.min.js'",
"var",
"pathFilename",
"=",
"_splitPathAndFilename",
"(",
"targetFilePath",
")",
";",
"var",
"targetPath",
"=",
"pathFilename",
"[",
"0",
... | Get the revTargetFilePath based on targetFilePath. | [
"Get",
"the",
"revTargetFilePath",
"based",
"on",
"targetFilePath",
"."
] | 2e8e0a7cb0c92ae12f1440dea1675dea5c7f1490 | https://github.com/ghosert/grunt-applymin/blob/2e8e0a7cb0c92ae12f1440dea1675dea5c7f1490/tasks/applymin.js#L132-L167 | train | |
zuren/catdown | lib/codemirror/keymap/sublime.js | findPosSubword | function findPosSubword(doc, start, dir) {
if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));
var line = doc.getLine(start.line);
if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));
var state = "start", type;
for (var pos = start.ch, e = dir < 0 ? ... | javascript | function findPosSubword(doc, start, dir) {
if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));
var line = doc.getLine(start.line);
if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));
var state = "start", type;
for (var pos = start.ch, e = dir < 0 ? ... | [
"function",
"findPosSubword",
"(",
"doc",
",",
"start",
",",
"dir",
")",
"{",
"if",
"(",
"dir",
"<",
"0",
"&&",
"start",
".",
"ch",
"==",
"0",
")",
"return",
"doc",
".",
"clipPos",
"(",
"Pos",
"(",
"start",
".",
"line",
"-",
"1",
")",
")",
";",... | This is not exactly Sublime's algorithm. I couldn't make heads or tails of that. | [
"This",
"is",
"not",
"exactly",
"Sublime",
"s",
"algorithm",
".",
"I",
"couldn",
"t",
"make",
"heads",
"or",
"tails",
"of",
"that",
"."
] | c45d6e3ca365c5f73cd9903a4ed6ef1369475327 | https://github.com/zuren/catdown/blob/c45d6e3ca365c5f73cd9903a4ed6ef1369475327/lib/codemirror/keymap/sublime.js#L17-L37 | train |
hkjels/ntask | lib/task.js | Task | function Task(task) {
_.extend(this, task);
if (task != undefined) this.createId();
// Short id
this.__defineGetter__('id', function () {
return this.__uuid__.substr(0, 8).toString();
});
// Keyword
this.__defineGetter__('keyword', function () {
return this.labels[0].replace('#', '').toUpperCase... | javascript | function Task(task) {
_.extend(this, task);
if (task != undefined) this.createId();
// Short id
this.__defineGetter__('id', function () {
return this.__uuid__.substr(0, 8).toString();
});
// Keyword
this.__defineGetter__('keyword', function () {
return this.labels[0].replace('#', '').toUpperCase... | [
"function",
"Task",
"(",
"task",
")",
"{",
"_",
".",
"extend",
"(",
"this",
",",
"task",
")",
";",
"if",
"(",
"task",
"!=",
"undefined",
")",
"this",
".",
"createId",
"(",
")",
";",
"// Short id",
"this",
".",
"__defineGetter__",
"(",
"'id'",
",",
... | Task
Model used by Barricane | [
"Task",
"Model",
"used",
"by",
"Barricane"
] | e0552042e743ef9584bc0f911245635df7acd634 | https://github.com/hkjels/ntask/blob/e0552042e743ef9584bc0f911245635df7acd634/lib/task.js#L27-L51 | train |
dpjanes/iotdb-homestar | bin/commands/old/model-to-jsonld.js | function (v, paramd) {
var nd = {};
var _add = function(v) {
if (!_.is.String(v)) {
return false;
}
var vmatch = v.match(/^([-a-z0-9]*):.+/);
if (!vmatch) {
return false;
}
var nshort = vmatch[1];
var nurl = _namespace[ns... | javascript | function (v, paramd) {
var nd = {};
var _add = function(v) {
if (!_.is.String(v)) {
return false;
}
var vmatch = v.match(/^([-a-z0-9]*):.+/);
if (!vmatch) {
return false;
}
var nshort = vmatch[1];
var nurl = _namespace[ns... | [
"function",
"(",
"v",
",",
"paramd",
")",
"{",
"var",
"nd",
"=",
"{",
"}",
";",
"var",
"_add",
"=",
"function",
"(",
"v",
")",
"{",
"if",
"(",
"!",
"_",
".",
"is",
".",
"String",
"(",
"v",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
... | This make sure all name spaces and @id types
we are aware of are properly represented
in the @context | [
"This",
"make",
"sure",
"all",
"name",
"spaces",
"and"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/bin/commands/old/model-to-jsonld.js#L169-L234 | train | |
urosjarc/gitbook-plugin-build | src/index.js | function () { // eslint-disable-line object-shorthand
// Inits helper
helper.init(this);
// Check cli args for output format, and override on existance of string.
if (typeof pluginBuildFlag === 'string' || pluginBuildFlag instanceof String) {
helper.config.format = pluginBuildFlag;
}
// Fill sum... | javascript | function () { // eslint-disable-line object-shorthand
// Inits helper
helper.init(this);
// Check cli args for output format, and override on existance of string.
if (typeof pluginBuildFlag === 'string' || pluginBuildFlag instanceof String) {
helper.config.format = pluginBuildFlag;
}
// Fill sum... | [
"function",
"(",
")",
"{",
"// eslint-disable-line object-shorthand",
"// Inits helper",
"helper",
".",
"init",
"(",
"this",
")",
";",
"// Check cli args for output format, and override on existance of string.",
"if",
"(",
"typeof",
"pluginBuildFlag",
"===",
"'string'",
"||",... | Gitbook hook on initilization.
@memberOf module:index~hooks | [
"Gitbook",
"hook",
"on",
"initilization",
"."
] | 0a77829ab81a65c70bea57f72a7256e60a1004b1 | https://github.com/urosjarc/gitbook-plugin-build/blob/0a77829ab81a65c70bea57f72a7256e60a1004b1/src/index.js#L28-L41 | train | |
urosjarc/gitbook-plugin-build | src/index.js | function () { // eslint-disable-line object-shorthand
const self = this;
const outputPath = helper.getOutput();
// Render template.
const rawContent = helper.renderTemp({summary: helper.summary});
// Create output dir.
mkdirp.sync(path.parse(outputPath).dir);
// Compile rendered main file
ret... | javascript | function () { // eslint-disable-line object-shorthand
const self = this;
const outputPath = helper.getOutput();
// Render template.
const rawContent = helper.renderTemp({summary: helper.summary});
// Create output dir.
mkdirp.sync(path.parse(outputPath).dir);
// Compile rendered main file
ret... | [
"function",
"(",
")",
"{",
"// eslint-disable-line object-shorthand",
"const",
"self",
"=",
"this",
";",
"const",
"outputPath",
"=",
"helper",
".",
"getOutput",
"(",
")",
";",
"// Render template.",
"const",
"rawContent",
"=",
"helper",
".",
"renderTemp",
"(",
"... | Gitbook hook on finishing.
@memberOf module:index~hooks
@returns {Promise} | [
"Gitbook",
"hook",
"on",
"finishing",
"."
] | 0a77829ab81a65c70bea57f72a7256e60a1004b1 | https://github.com/urosjarc/gitbook-plugin-build/blob/0a77829ab81a65c70bea57f72a7256e60a1004b1/src/index.js#L48-L67 | train | |
urosjarc/gitbook-plugin-build | src/index.js | function (page) { // eslint-disable-line object-shorthand
// Fill summary with compiled page content
helper.summary.forEach((article, i, array) => {
if (article.path === page.path) {
array[i].content = page.content;
}
});
// Returns unchanged page.
return page;
} | javascript | function (page) { // eslint-disable-line object-shorthand
// Fill summary with compiled page content
helper.summary.forEach((article, i, array) => {
if (article.path === page.path) {
array[i].content = page.content;
}
});
// Returns unchanged page.
return page;
} | [
"function",
"(",
"page",
")",
"{",
"// eslint-disable-line object-shorthand",
"// Fill summary with compiled page content",
"helper",
".",
"summary",
".",
"forEach",
"(",
"(",
"article",
",",
"i",
",",
"array",
")",
"=>",
"{",
"if",
"(",
"article",
".",
"path",
... | Gitbook hook for page. Function will be executed
after markdown is processed with other plugins.
@memberOf module:index~hooks
@param page
@returns {page} The same as page parameter. | [
"Gitbook",
"hook",
"for",
"page",
".",
"Function",
"will",
"be",
"executed",
"after",
"markdown",
"is",
"processed",
"with",
"other",
"plugins",
"."
] | 0a77829ab81a65c70bea57f72a7256e60a1004b1 | https://github.com/urosjarc/gitbook-plugin-build/blob/0a77829ab81a65c70bea57f72a7256e60a1004b1/src/index.js#L76-L86 | train | |
itajaja/websocket-monkeypatch | lib/index.js | sendJson | function sendJson(data, options, callback) {
var jsonData = JSON.stringify(data);
return this.send(jsonData, options, callback);
} | javascript | function sendJson(data, options, callback) {
var jsonData = JSON.stringify(data);
return this.send(jsonData, options, callback);
} | [
"function",
"sendJson",
"(",
"data",
",",
"options",
",",
"callback",
")",
"{",
"var",
"jsonData",
"=",
"JSON",
".",
"stringify",
"(",
"data",
")",
";",
"return",
"this",
".",
"send",
"(",
"jsonData",
",",
"options",
",",
"callback",
")",
";",
"}"
] | send a json message serialized to string | [
"send",
"a",
"json",
"message",
"serialized",
"to",
"string"
] | 7dc97366f6b863b73241a2a2f092938a8236a64e | https://github.com/itajaja/websocket-monkeypatch/blob/7dc97366f6b863b73241a2a2f092938a8236a64e/lib/index.js#L10-L13 | train |
weisjohn/mongoose-csv | index.js | find_props | function find_props(schema) {
var props = _(schema.paths).keys().without('_id', 'id')
// transform the schema tree into an array for filtering
.map(function(key) { return { name : key, value : _.get(schema.tree, key) }; })
// remove paths that are annotated with csv: false
.filter... | javascript | function find_props(schema) {
var props = _(schema.paths).keys().without('_id', 'id')
// transform the schema tree into an array for filtering
.map(function(key) { return { name : key, value : _.get(schema.tree, key) }; })
// remove paths that are annotated with csv: false
.filter... | [
"function",
"find_props",
"(",
"schema",
")",
"{",
"var",
"props",
"=",
"_",
"(",
"schema",
".",
"paths",
")",
".",
"keys",
"(",
")",
".",
"without",
"(",
"'_id'",
",",
"'id'",
")",
"// transform the schema tree into an array for filtering",
".",
"map",
"(",... | walk the paths, rejecting those that opt-out | [
"walk",
"the",
"paths",
"rejecting",
"those",
"that",
"opt",
"-",
"out"
] | b87f1dc906ef0521a68942bfcd8b304ae274fa3b | https://github.com/weisjohn/mongoose-csv/blob/b87f1dc906ef0521a68942bfcd8b304ae274fa3b/index.js#L59-L93 | train |
weisjohn/mongoose-csv | index.js | prop_to_csv | function prop_to_csv(prop) {
var val = String(prop);
if (val === 'undefined') val = '';
return '"' + val.toString().replace(/"/g, '""') + '"';
} | javascript | function prop_to_csv(prop) {
var val = String(prop);
if (val === 'undefined') val = '';
return '"' + val.toString().replace(/"/g, '""') + '"';
} | [
"function",
"prop_to_csv",
"(",
"prop",
")",
"{",
"var",
"val",
"=",
"String",
"(",
"prop",
")",
";",
"if",
"(",
"val",
"===",
"'undefined'",
")",
"val",
"=",
"''",
";",
"return",
"'\"'",
"+",
"val",
".",
"toString",
"(",
")",
".",
"replace",
"(",
... | return empty string if not truthy, escape quotes | [
"return",
"empty",
"string",
"if",
"not",
"truthy",
"escape",
"quotes"
] | b87f1dc906ef0521a68942bfcd8b304ae274fa3b | https://github.com/weisjohn/mongoose-csv/blob/b87f1dc906ef0521a68942bfcd8b304ae274fa3b/index.js#L102-L108 | train |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(view_config, raw_hash) {
for (var name in raw_hash) {
if (Lava.schema.DEBUG && this._allowed_hash_options.indexOf(name) == -1) Lava.t("Hash option is not supported: " + name);
if (name in this._view_config_property_setters) {
this[this._view_config_property_setters[name]](view_config, raw_hash[na... | javascript | function(view_config, raw_hash) {
for (var name in raw_hash) {
if (Lava.schema.DEBUG && this._allowed_hash_options.indexOf(name) == -1) Lava.t("Hash option is not supported: " + name);
if (name in this._view_config_property_setters) {
this[this._view_config_property_setters[name]](view_config, raw_hash[na... | [
"function",
"(",
"view_config",
",",
"raw_hash",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"raw_hash",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"this",
".",
"_allowed_hash_options",
".",
"indexOf",
"(",
"name",
")",
"==",
"-",
... | Store values from view's hash as config properties
@param {_cView} view_config
@param {Object} raw_hash | [
"Store",
"values",
"from",
"view",
"s",
"hash",
"as",
"config",
"properties"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L102-L115 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(result, raw_expression) {
if (raw_expression.arguments.length != 1) Lava.t("Expression block requires exactly one argument");
var config = {
type: 'view',
"class": 'Expression',
argument: raw_expression.arguments[0]
};
if (raw_expression.prefix == '$') {
config.container = {type: 'Morph... | javascript | function(result, raw_expression) {
if (raw_expression.arguments.length != 1) Lava.t("Expression block requires exactly one argument");
var config = {
type: 'view',
"class": 'Expression',
argument: raw_expression.arguments[0]
};
if (raw_expression.prefix == '$') {
config.container = {type: 'Morph... | [
"function",
"(",
"result",
",",
"raw_expression",
")",
"{",
"if",
"(",
"raw_expression",
".",
"arguments",
".",
"length",
"!=",
"1",
")",
"Lava",
".",
"t",
"(",
"\"Expression block requires exactly one argument\"",
")",
";",
"var",
"config",
"=",
"{",
"type",
... | Compile raw expression view. Will produce a view config with class="Expression"
@param {_tTemplate} result
@param {_cRawExpression} raw_expression | [
"Compile",
"raw",
"expression",
"view",
".",
"Will",
"produce",
"a",
"view",
"config",
"with",
"class",
"=",
"Expression"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L335-L353 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(result, tag) {
var is_void = Lava.isVoidTag(tag.name),
tag_start_text = "<" + tag.name
+ this.renderTagAttributes(tag.attributes)
+ (is_void ? '/>' : '>'),
inner_template,
count;
this. _compileString(result, tag_start_text);
if (Lava.schema.DEBUG && is_void && tag.content) Lava.t("Voi... | javascript | function(result, tag) {
var is_void = Lava.isVoidTag(tag.name),
tag_start_text = "<" + tag.name
+ this.renderTagAttributes(tag.attributes)
+ (is_void ? '/>' : '>'),
inner_template,
count;
this. _compileString(result, tag_start_text);
if (Lava.schema.DEBUG && is_void && tag.content) Lava.t("Voi... | [
"function",
"(",
"result",
",",
"tag",
")",
"{",
"var",
"is_void",
"=",
"Lava",
".",
"isVoidTag",
"(",
"tag",
".",
"name",
")",
",",
"tag_start_text",
"=",
"\"<\"",
"+",
"tag",
".",
"name",
"+",
"this",
".",
"renderTagAttributes",
"(",
"tag",
".",
"a... | Serialize the tag back into text
@param {_tTemplate} result
@param {_cRawTag} tag | [
"Serialize",
"the",
"tag",
"back",
"into",
"text"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L360-L399 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_tag) {
var container_config = {
type: 'Element',
tag_name: raw_tag.name
};
if ('attributes' in raw_tag) this._parseContainerStaticAttributes(container_config, raw_tag.attributes);
if ('x' in raw_tag) this._parseContainerControlAttributes(container_config, raw_tag.x);
return /** @type ... | javascript | function(raw_tag) {
var container_config = {
type: 'Element',
tag_name: raw_tag.name
};
if ('attributes' in raw_tag) this._parseContainerStaticAttributes(container_config, raw_tag.attributes);
if ('x' in raw_tag) this._parseContainerControlAttributes(container_config, raw_tag.x);
return /** @type ... | [
"function",
"(",
"raw_tag",
")",
"{",
"var",
"container_config",
"=",
"{",
"type",
":",
"'Element'",
",",
"tag_name",
":",
"raw_tag",
".",
"name",
"}",
";",
"if",
"(",
"'attributes'",
"in",
"raw_tag",
")",
"this",
".",
"_parseContainerStaticAttributes",
"(",... | Convert raw tag to an Element container config
@param {_cRawTag} raw_tag
@returns {_cElementContainer} | [
"Convert",
"raw",
"tag",
"to",
"an",
"Element",
"container",
"config"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L656-L668 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(container_config, x) {
var i,
count,
name;
if ('event' in x) {
if (typeof(x.event) != 'object') Lava.t("Malformed x:event attribute");
container_config.events = {};
for (name in x.event) {
container_config.events[name] = Lava.parsers.Common.parseTargets(x.event[name]);
}
}
... | javascript | function(container_config, x) {
var i,
count,
name;
if ('event' in x) {
if (typeof(x.event) != 'object') Lava.t("Malformed x:event attribute");
container_config.events = {};
for (name in x.event) {
container_config.events[name] = Lava.parsers.Common.parseTargets(x.event[name]);
}
}
... | [
"function",
"(",
"container_config",
",",
"x",
")",
"{",
"var",
"i",
",",
"count",
",",
"name",
";",
"if",
"(",
"'event'",
"in",
"x",
")",
"{",
"if",
"(",
"typeof",
"(",
"x",
".",
"event",
")",
"!=",
"'object'",
")",
"Lava",
".",
"t",
"(",
"\"M... | Take raw control attributes, parse them, and store in `container_config`
@param {_cElementContainer} container_config
@param {_cRawX} x | [
"Take",
"raw",
"control",
"attributes",
"parse",
"them",
"and",
"store",
"in",
"container_config"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L675-L733 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(blocks, view_config) {
var current_block,
result = [],
type,
i = 0,
count = blocks.length,
x;
for (; i < count; i++) {
current_block = blocks[i];
type = (typeof(current_block) == 'string') ? 'string' : current_block.type;
if (type == 'tag') {
x = current_block.x;
if (x... | javascript | function(blocks, view_config) {
var current_block,
result = [],
type,
i = 0,
count = blocks.length,
x;
for (; i < count; i++) {
current_block = blocks[i];
type = (typeof(current_block) == 'string') ? 'string' : current_block.type;
if (type == 'tag') {
x = current_block.x;
if (x... | [
"function",
"(",
"blocks",
",",
"view_config",
")",
"{",
"var",
"current_block",
",",
"result",
"=",
"[",
"]",
",",
"type",
",",
"i",
"=",
"0",
",",
"count",
"=",
"blocks",
".",
"length",
",",
"x",
";",
"for",
"(",
";",
"i",
"<",
"count",
";",
... | Compile raw template config
@param {_tRawTemplate} blocks
@param {_cView} [view_config]
@returns {_tTemplate} | [
"Compile",
"raw",
"template",
"config"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L863-L917 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_blocks) {
var result = this.asBlocks(this.compileTemplate(raw_blocks));
if (result.length != 1) Lava.t("Expected: exactly one view, got either several or none.");
if (result[0].type != 'view' && result[0].type != 'widget') Lava.t("Expected: view, got: " + result[0].type);
return result[0];
} | javascript | function(raw_blocks) {
var result = this.asBlocks(this.compileTemplate(raw_blocks));
if (result.length != 1) Lava.t("Expected: exactly one view, got either several or none.");
if (result[0].type != 'view' && result[0].type != 'widget') Lava.t("Expected: view, got: " + result[0].type);
return result[0];
} | [
"function",
"(",
"raw_blocks",
")",
"{",
"var",
"result",
"=",
"this",
".",
"asBlocks",
"(",
"this",
".",
"compileTemplate",
"(",
"raw_blocks",
")",
")",
";",
"if",
"(",
"result",
".",
"length",
"!=",
"1",
")",
"Lava",
".",
"t",
"(",
"\"Expected: exact... | Compile template as usual and assert that it contains single view inside. Return that view
@param {_tRawTemplate} raw_blocks
@returns {_cView} | [
"Compile",
"template",
"as",
"usual",
"and",
"assert",
"that",
"it",
"contains",
"single",
"view",
"inside",
".",
"Return",
"that",
"view"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L925-L932 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(template) {
var i = 0,
count = template.length,
result = [];
for (; i < count; i++) {
if (typeof(template[i]) == 'string') {
if (!Lava.EMPTY_REGEX.test(template[i])) Lava.t("Text between tags is not allowed in this context. You may want to use a lava-style comment ({* ... *})");
} else... | javascript | function(template) {
var i = 0,
count = template.length,
result = [];
for (; i < count; i++) {
if (typeof(template[i]) == 'string') {
if (!Lava.EMPTY_REGEX.test(template[i])) Lava.t("Text between tags is not allowed in this context. You may want to use a lava-style comment ({* ... *})");
} else... | [
"function",
"(",
"template",
")",
"{",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"template",
".",
"length",
",",
"result",
"=",
"[",
"]",
";",
"for",
"(",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"if",
"(",
"typeof",
"(",
"template",
... | Remove strings from template and assert they are empty
@param {(_tRawTemplate|_tTemplate)} template
@returns {Array} | [
"Remove",
"strings",
"from",
"template",
"and",
"assert",
"they",
"are",
"empty"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L939-L961 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function() {
return {
type: 'widget',
"class": Lava.schema.widget.DEFAULT_EXTENSION_GATEWAY,
extender_type: Lava.schema.widget.DEFAULT_EXTENDER
}
} | javascript | function() {
return {
type: 'widget',
"class": Lava.schema.widget.DEFAULT_EXTENSION_GATEWAY,
extender_type: Lava.schema.widget.DEFAULT_EXTENDER
}
} | [
"function",
"(",
")",
"{",
"return",
"{",
"type",
":",
"'widget'",
",",
"\"class\"",
":",
"Lava",
".",
"schema",
".",
"widget",
".",
"DEFAULT_EXTENSION_GATEWAY",
",",
"extender_type",
":",
"Lava",
".",
"schema",
".",
"widget",
".",
"DEFAULT_EXTENDER",
"}",
... | Create an empty widget config with default class and extender from schema
@returns {_cWidget} | [
"Create",
"an",
"empty",
"widget",
"config",
"with",
"default",
"class",
"and",
"extender",
"from",
"schema"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1150-L1158 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_string) {
var map = Firestorm.String.quote_escape_map,
result;
try {
result = eval("(" + raw_string.replace(this.UNQUOTE_ESCAPE_REGEX, function (a) {
var c = map[a];
return typeof c == 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + ")");
} catch (e) ... | javascript | function(raw_string) {
var map = Firestorm.String.quote_escape_map,
result;
try {
result = eval("(" + raw_string.replace(this.UNQUOTE_ESCAPE_REGEX, function (a) {
var c = map[a];
return typeof c == 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + ")");
} catch (e) ... | [
"function",
"(",
"raw_string",
")",
"{",
"var",
"map",
"=",
"Firestorm",
".",
"String",
".",
"quote_escape_map",
",",
"result",
";",
"try",
"{",
"result",
"=",
"eval",
"(",
"\"(\"",
"+",
"raw_string",
".",
"replace",
"(",
"this",
".",
"UNQUOTE_ESCAPE_REGEX... | Turn a serialized and quoted string back into it's JavaScript representation.
Assume that everything that follows a backslash is a valid escape sequence
(all backslashes are prefixed with another backslash).
Quotes inside string: lexer's regex will match all escaped quotes
@param {string} raw_string
@returns {string... | [
"Turn",
"a",
"serialized",
"and",
"quoted",
"string",
"back",
"into",
"it",
"s",
"JavaScript",
"representation",
"."
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1171-L1187 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_directive, view_config, is_top_directive) {
var directive_name = raw_directive.name,
config = this._directives_schema[directive_name];
if (!config) Lava.t("Unknown directive: " + directive_name);
if (config.view_config_presence) {
if (view_config && !config.view_config_presence) Lava.t('Dire... | javascript | function(raw_directive, view_config, is_top_directive) {
var directive_name = raw_directive.name,
config = this._directives_schema[directive_name];
if (!config) Lava.t("Unknown directive: " + directive_name);
if (config.view_config_presence) {
if (view_config && !config.view_config_presence) Lava.t('Dire... | [
"function",
"(",
"raw_directive",
",",
"view_config",
",",
"is_top_directive",
")",
"{",
"var",
"directive_name",
"=",
"raw_directive",
".",
"name",
",",
"config",
"=",
"this",
".",
"_directives_schema",
"[",
"directive_name",
"]",
";",
"if",
"(",
"!",
"config... | Handle directive tag
@param {_cRawDirective} raw_directive Raw directive tag
@param {(_cView|_cWidget)} view_config Config of the directive's parent view
@param {boolean} is_top_directive Code style validation switch. Some directives must be at the top of templates
@returns {*} Compiled template item or nothing | [
"Handle",
"directive",
"tag"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1295-L1311 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(destination, source, name_list) {
for (var i = 0, count = name_list.length; i < count; i++) {
var name = name_list[i];
if (name in source) destination[name] = source[name];
}
} | javascript | function(destination, source, name_list) {
for (var i = 0, count = name_list.length; i < count; i++) {
var name = name_list[i];
if (name in source) destination[name] = source[name];
}
} | [
"function",
"(",
"destination",
",",
"source",
",",
"name_list",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"name_list",
".",
"length",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"var",
"name",
"=",
"name_list",
"[",
"i... | Helper method to copy properties from `source` to `destination`, if they exist
@param {Object} destination
@param {Object} source
@param {Array.<string>} name_list List of properties to copy from `source` to `destination` | [
"Helper",
"method",
"to",
"copy",
"properties",
"from",
"source",
"to",
"destination",
"if",
"they",
"exist"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1319-L1324 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_tag) {
if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1 || raw_tag.content[0] == '')) Lava.t("Malformed resources options tag");
return {
type: 'options',
value: Lava.parseOptions(raw_tag.content[0])
};
} | javascript | function(raw_tag) {
if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1 || raw_tag.content[0] == '')) Lava.t("Malformed resources options tag");
return {
type: 'options',
value: Lava.parseOptions(raw_tag.content[0])
};
} | [
"function",
"(",
"raw_tag",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"(",
"!",
"raw_tag",
".",
"content",
"||",
"raw_tag",
".",
"content",
".",
"length",
"!=",
"1",
"||",
"raw_tag",
".",
"content",
"[",
"0",
"]",
"==",
"''",
... | Parse resource value as any JavaScript type, including arrays, objects and literals
@param {_cRawTag} raw_tag | [
"Parse",
"resource",
"value",
"as",
"any",
"JavaScript",
"type",
"including",
"arrays",
"objects",
"and",
"literals"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1519-L1528 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_tag) {
if (Lava.schema.DEBUG && raw_tag.content && raw_tag.content.length != 1) Lava.t("Malformed resources string tag");
var result = {
type: 'string',
value: raw_tag.content ? raw_tag.content[0].trim() : ''
};
if (raw_tag.attributes.description) result.description = raw_tag.attributes.de... | javascript | function(raw_tag) {
if (Lava.schema.DEBUG && raw_tag.content && raw_tag.content.length != 1) Lava.t("Malformed resources string tag");
var result = {
type: 'string',
value: raw_tag.content ? raw_tag.content[0].trim() : ''
};
if (raw_tag.attributes.description) result.description = raw_tag.attributes.de... | [
"function",
"(",
"raw_tag",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"raw_tag",
".",
"content",
"&&",
"raw_tag",
".",
"content",
".",
"length",
"!=",
"1",
")",
"Lava",
".",
"t",
"(",
"\"Malformed resources string tag\"",
")",
";",
... | Parse a translatable string
@param {_cRawTag} raw_tag | [
"Parse",
"a",
"translatable",
"string"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1534-L1547 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_tag) {
if (Lava.schema.DEBUG && (!raw_tag.content)) Lava.t("Malformed resources plural string tag");
var plural_tags = Lava.parsers.Common.asBlockType(raw_tag.content, 'tag'),
i = 0,
count = plural_tags.length,
plurals = [],
result;
if (Lava.schema.DEBUG && count == 0) Lava.t("Malforme... | javascript | function(raw_tag) {
if (Lava.schema.DEBUG && (!raw_tag.content)) Lava.t("Malformed resources plural string tag");
var plural_tags = Lava.parsers.Common.asBlockType(raw_tag.content, 'tag'),
i = 0,
count = plural_tags.length,
plurals = [],
result;
if (Lava.schema.DEBUG && count == 0) Lava.t("Malforme... | [
"function",
"(",
"raw_tag",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"(",
"!",
"raw_tag",
".",
"content",
")",
")",
"Lava",
".",
"t",
"(",
"\"Malformed resources plural string tag\"",
")",
";",
"var",
"plural_tags",
"=",
"Lava",
".... | Parse translatable plural string
@param {_cRawTag} raw_tag | [
"Parse",
"translatable",
"plural",
"string"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1553-L1581 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_directive) {
if (Lava.schema.DEBUG) {
if (!raw_directive.attributes || !raw_directive.attributes.title) Lava.t("define: missing 'title' attribute");
if (raw_directive.attributes.title.indexOf(' ') != -1) Lava.t("Widget title must not contain spaces");
if ('resource_id' in raw_directive.attribut... | javascript | function(raw_directive) {
if (Lava.schema.DEBUG) {
if (!raw_directive.attributes || !raw_directive.attributes.title) Lava.t("define: missing 'title' attribute");
if (raw_directive.attributes.title.indexOf(' ') != -1) Lava.t("Widget title must not contain spaces");
if ('resource_id' in raw_directive.attribut... | [
"function",
"(",
"raw_directive",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
")",
"{",
"if",
"(",
"!",
"raw_directive",
".",
"attributes",
"||",
"!",
"raw_directive",
".",
"attributes",
".",
"title",
")",
"Lava",
".",
"t",
"(",
"\"define... | Define a widget
@param {_cRawDirective} raw_directive | [
"Define",
"a",
"widget"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1788-L1806 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_directive) {
var widget_config = this._parseWidgetDefinition(raw_directive);
if (Lava.schema.DEBUG && ('sugar' in widget_config)) Lava.t("Inline widgets must not have sugar");
if (Lava.schema.DEBUG && !widget_config['class'] && !widget_config['extends']) Lava.t("x:define: widget definition is missi... | javascript | function(raw_directive) {
var widget_config = this._parseWidgetDefinition(raw_directive);
if (Lava.schema.DEBUG && ('sugar' in widget_config)) Lava.t("Inline widgets must not have sugar");
if (Lava.schema.DEBUG && !widget_config['class'] && !widget_config['extends']) Lava.t("x:define: widget definition is missi... | [
"function",
"(",
"raw_directive",
")",
"{",
"var",
"widget_config",
"=",
"this",
".",
"_parseWidgetDefinition",
"(",
"raw_directive",
")",
";",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"(",
"'sugar'",
"in",
"widget_config",
")",
")",
"Lava",
"... | Inline widget definition
@param {_cRawDirective} raw_directive | [
"Inline",
"widget",
"definition"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1812-L1823 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(config, raw_tag, config_property_name) {
if (Lava.schema.DEBUG && !('attributes' in raw_tag)) Lava.t("option: missing attributes");
if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1)) Lava.t("Malformed option: " + raw_tag.attributes.name);
var option_type = raw_tag.attributes.ty... | javascript | function(config, raw_tag, config_property_name) {
if (Lava.schema.DEBUG && !('attributes' in raw_tag)) Lava.t("option: missing attributes");
if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1)) Lava.t("Malformed option: " + raw_tag.attributes.name);
var option_type = raw_tag.attributes.ty... | [
"function",
"(",
"config",
",",
"raw_tag",
",",
"config_property_name",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"!",
"(",
"'attributes'",
"in",
"raw_tag",
")",
")",
"Lava",
".",
"t",
"(",
"\"option: missing attributes\"",
")",
";",
... | Perform parsing of a tag with serialized JavaScript object inside it
@param {(_cView|_cWidget)} config
@param {(_cRawDirective|_cRawTag)} raw_tag
@param {string} config_property_name Name of the config member, which holds target JavaScript object | [
"Perform",
"parsing",
"of",
"a",
"tag",
"with",
"serialized",
"JavaScript",
"object",
"inside",
"it"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L1879-L1911 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(config, name, raw_tag) {
if (Lava.schema.DEBUG && (name in config)) Lava.t("Object already exists: " + name + ". Ensure, that x:options and x:properties directives appear before x:option and x:property.");
if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1)) Lava.t("Malformed direct... | javascript | function(config, name, raw_tag) {
if (Lava.schema.DEBUG && (name in config)) Lava.t("Object already exists: " + name + ". Ensure, that x:options and x:properties directives appear before x:option and x:property.");
if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1)) Lava.t("Malformed direct... | [
"function",
"(",
"config",
",",
"name",
",",
"raw_tag",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"(",
"name",
"in",
"config",
")",
")",
"Lava",
".",
"t",
"(",
"\"Object already exists: \"",
"+",
"name",
"+",
"\". Ensure, that x:opt... | Parse a tag with JavaScript object inside
@param {(_cView|_cWidget)} config
@param {string} name
@param {(_cRawDirective|_cRawTag)} raw_tag | [
"Parse",
"a",
"tag",
"with",
"JavaScript",
"object",
"inside"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L2032-L2038 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(widget_config, raw_directive, config_property_name) {
if (Lava.schema.DEBUG && !('attributes' in raw_directive)) Lava.t("option: missing attributes");
if (Lava.schema.DEBUG && (!raw_directive.content || raw_directive.content.length != 1)) Lava.t("Malformed property: " + raw_directive.attributes.name);
L... | javascript | function(widget_config, raw_directive, config_property_name) {
if (Lava.schema.DEBUG && !('attributes' in raw_directive)) Lava.t("option: missing attributes");
if (Lava.schema.DEBUG && (!raw_directive.content || raw_directive.content.length != 1)) Lava.t("Malformed property: " + raw_directive.attributes.name);
L... | [
"function",
"(",
"widget_config",
",",
"raw_directive",
",",
"config_property_name",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"!",
"(",
"'attributes'",
"in",
"raw_directive",
")",
")",
"Lava",
".",
"t",
"(",
"\"option: missing attributes... | Helper method for widget directives
@param {_cWidget} widget_config
@param {_cRawDirective} raw_directive
@param {string} config_property_name | [
"Helper",
"method",
"for",
"widget",
"directives"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L2083-L2089 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_directive) {
if (Lava.schema.DEBUG && (!raw_directive.attributes || !raw_directive.attributes['locale'] || !raw_directive.attributes['for']))
Lava.t("Malformed x:resources definition. 'locale' and 'for' are required");
Lava.resources.addWidgetResource(
raw_directive.attributes['for'],
raw_di... | javascript | function(raw_directive) {
if (Lava.schema.DEBUG && (!raw_directive.attributes || !raw_directive.attributes['locale'] || !raw_directive.attributes['for']))
Lava.t("Malformed x:resources definition. 'locale' and 'for' are required");
Lava.resources.addWidgetResource(
raw_directive.attributes['for'],
raw_di... | [
"function",
"(",
"raw_directive",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"(",
"!",
"raw_directive",
".",
"attributes",
"||",
"!",
"raw_directive",
".",
"attributes",
"[",
"'locale'",
"]",
"||",
"!",
"raw_directive",
".",
"attribute... | Standalone resources definition for global widget
@param {_cRawDirective} raw_directive | [
"Standalone",
"resources",
"definition",
"for",
"global",
"widget"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L2119-L2130 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(raw_directive) {
if (Lava.schema.DEBUG && !raw_directive.content) Lava.t("empty attach_directives");
var blocks = Lava.parsers.Common.asBlocks(raw_directive.content),
sugar = blocks[0],
directives = blocks.slice(1),
i,
count;
if (Lava.schema.DEBUG) {
if (sugar.type != 'tag' || sugar.con... | javascript | function(raw_directive) {
if (Lava.schema.DEBUG && !raw_directive.content) Lava.t("empty attach_directives");
var blocks = Lava.parsers.Common.asBlocks(raw_directive.content),
sugar = blocks[0],
directives = blocks.slice(1),
i,
count;
if (Lava.schema.DEBUG) {
if (sugar.type != 'tag' || sugar.con... | [
"function",
"(",
"raw_directive",
")",
"{",
"if",
"(",
"Lava",
".",
"schema",
".",
"DEBUG",
"&&",
"!",
"raw_directive",
".",
"content",
")",
"Lava",
".",
"t",
"(",
"\"empty attach_directives\"",
")",
";",
"var",
"blocks",
"=",
"Lava",
".",
"parsers",
"."... | Wrapper, used to apply directives to a void tag
@param {_cRawDirective} raw_directive | [
"Wrapper",
"used",
"to",
"apply",
"directives",
"to",
"a",
"void",
"tag"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L2195-L2215 | 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.