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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
yanni4night/grunt-web-stamp | tasks/stamp.js | function(path, stamp) {
var name = sysPath.basename(path);
var ext = sysPath.extname(name);
var stub = path.slice(0, name ? (-name.length) : path.length - 1);
if (ext.length) {
name = name.slice(0, -ext.length);
}
//Ignore leading dot
if ('.' === ext[0]... | javascript | function(path, stamp) {
var name = sysPath.basename(path);
var ext = sysPath.extname(name);
var stub = path.slice(0, name ? (-name.length) : path.length - 1);
if (ext.length) {
name = name.slice(0, -ext.length);
}
//Ignore leading dot
if ('.' === ext[0]... | [
"function",
"(",
"path",
",",
"stamp",
")",
"{",
"var",
"name",
"=",
"sysPath",
".",
"basename",
"(",
"path",
")",
";",
"var",
"ext",
"=",
"sysPath",
".",
"extname",
"(",
"name",
")",
";",
"var",
"stub",
"=",
"path",
".",
"slice",
"(",
"0",
",",
... | Merge stamp into filename
@param {String} path
@param {String} stamp | [
"Merge",
"stamp",
"into",
"filename"
] | e7040f9c7ebe5ac29be72790297019d417ba9fc7 | https://github.com/yanni4night/grunt-web-stamp/blob/e7040f9c7ebe5ac29be72790297019d417ba9fc7/tasks/stamp.js#L93-L107 | train | |
timkuijsten/node-bcrypt-user | index.js | User | function User(db, username, opts) {
if (typeof db !== 'object') { throw new TypeError('db must be an object'); }
if (typeof username !== 'string') { throw new TypeError('username must be a string'); }
opts = opts || {};
if (typeof opts !== 'object') { throw new TypeError('opts must be an object'); }
var rea... | javascript | function User(db, username, opts) {
if (typeof db !== 'object') { throw new TypeError('db must be an object'); }
if (typeof username !== 'string') { throw new TypeError('username must be a string'); }
opts = opts || {};
if (typeof opts !== 'object') { throw new TypeError('opts must be an object'); }
var rea... | [
"function",
"User",
"(",
"db",
",",
"username",
",",
"opts",
")",
"{",
"if",
"(",
"typeof",
"db",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'db must be an object'",
")",
";",
"}",
"if",
"(",
"typeof",
"username",
"!==",
"'string'",
... | Create a new User object. Either for maintenance, verification or registration.
A user may be bound to a realm.
@param {Object} db object that implements find, updateHash and insert methods
@param {String} username the name of the user to bind this instance to
@param {Object} [opts] object containing optional param... | [
"Create",
"a",
"new",
"User",
"object",
".",
"Either",
"for",
"maintenance",
"verification",
"or",
"registration",
".",
"A",
"user",
"may",
"be",
"bound",
"to",
"a",
"realm",
"."
] | bd39885107d5bb4b95a70d4983e893f9a1f5ff8a | https://github.com/timkuijsten/node-bcrypt-user/blob/bd39885107d5bb4b95a70d4983e893f9a1f5ff8a/index.js#L58-L100 | train |
lastboy/require-mapper | src/Mapper.js | function(data) {
var map = _map,
key;
if (map && data) {
for (key in data) {
if (key && data.hasOwnProperty(key)) {
_map[key] = data[key];
}
}
}
} | javascript | function(data) {
var map = _map,
key;
if (map && data) {
for (key in data) {
if (key && data.hasOwnProperty(key)) {
_map[key] = data[key];
}
}
}
} | [
"function",
"(",
"data",
")",
"{",
"var",
"map",
"=",
"_map",
",",
"key",
";",
"if",
"(",
"map",
"&&",
"data",
")",
"{",
"for",
"(",
"key",
"in",
"data",
")",
"{",
"if",
"(",
"key",
"&&",
"data",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"... | Set the data to the mapper
Behaves like a Map object, if the key already exists
the last will override the existing
@param data | [
"Set",
"the",
"data",
"to",
"the",
"mapper"
] | 201d047d2aade143e64d96b2a7bfddf2b52298fb | https://github.com/lastboy/require-mapper/blob/201d047d2aade143e64d96b2a7bfddf2b52298fb/src/Mapper.js#L83-L96 | train | |
esatterwhite/skyring-scylladown | lib/index.js | ScyllaDown | function ScyllaDown(location) {
if (!(this instanceof ScyllaDown)) return new ScyllaDown(location)
AbstractLevelDOWN.call(this, location)
this.keyspace = null
this.client = null
this.table = slugify(location)
this[kQuery] = {
insert: null
, update: null
, get: null
, del: null
}
} | javascript | function ScyllaDown(location) {
if (!(this instanceof ScyllaDown)) return new ScyllaDown(location)
AbstractLevelDOWN.call(this, location)
this.keyspace = null
this.client = null
this.table = slugify(location)
this[kQuery] = {
insert: null
, update: null
, get: null
, del: null
}
} | [
"function",
"ScyllaDown",
"(",
"location",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ScyllaDown",
")",
")",
"return",
"new",
"ScyllaDown",
"(",
"location",
")",
"AbstractLevelDOWN",
".",
"call",
"(",
"this",
",",
"location",
")",
"this",
".",
... | ScyllaDB Leveldown backend for levelup
@class ScyllaDown
@extends AbstractLevelDOWN
@alias module:@skyring/scylladown
@params {String} location The name of a the database table
the db instance is responsible for | [
"ScyllaDB",
"Leveldown",
"backend",
"for",
"levelup"
] | c51ea78a21db4da05314c2f5216e005a420feec8 | https://github.com/esatterwhite/skyring-scylladown/blob/c51ea78a21db4da05314c2f5216e005a420feec8/lib/index.js#L52-L66 | train |
peteward44/git-svn-interface | lib/git.js | executeGit | function executeGit( args, options ) {
options = options || {};
return new Promise( function( resolve, reject ) {
var stdo = '';
var proc = doSpawn( 'git', args, { cwd: options.cwd ? options.cwd : process.cwd(), stdio: [ 'ignore', 'pipe', 'ignore' ] } );
function unpipe() {
}
if ( options.captureStdout ) ... | javascript | function executeGit( args, options ) {
options = options || {};
return new Promise( function( resolve, reject ) {
var stdo = '';
var proc = doSpawn( 'git', args, { cwd: options.cwd ? options.cwd : process.cwd(), stdio: [ 'ignore', 'pipe', 'ignore' ] } );
function unpipe() {
}
if ( options.captureStdout ) ... | [
"function",
"executeGit",
"(",
"args",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"stdo",
"=",
"''",
";",
"var",
"proc",
"=",
... | used if the git library doesn't support what we need to do | [
"used",
"if",
"the",
"git",
"library",
"doesn",
"t",
"support",
"what",
"we",
"need",
"to",
"do"
] | 16a874912fdfd69654d1d84a22d2e3838ea2ae8a | https://github.com/peteward44/git-svn-interface/blob/16a874912fdfd69654d1d84a22d2e3838ea2ae8a/lib/git.js#L29-L67 | train |
tgideas/grunt-motion-build | tasks/motion_build.js | function(filepath, data){
filepath = [].concat(filepath);
var buf=[].concat(filepath);
function parse(fileId, refUri, data) {
var filepath = id2Uri(fileId, refUri, data);
if(!grunt.file.exists(filepath)){ //file not found
grunt.log.warn('Source file "' + filepath + '" not fou... | javascript | function(filepath, data){
filepath = [].concat(filepath);
var buf=[].concat(filepath);
function parse(fileId, refUri, data) {
var filepath = id2Uri(fileId, refUri, data);
if(!grunt.file.exists(filepath)){ //file not found
grunt.log.warn('Source file "' + filepath + '" not fou... | [
"function",
"(",
"filepath",
",",
"data",
")",
"{",
"filepath",
"=",
"[",
"]",
".",
"concat",
"(",
"filepath",
")",
";",
"var",
"buf",
"=",
"[",
"]",
".",
"concat",
"(",
"filepath",
")",
";",
"function",
"parse",
"(",
"fileId",
",",
"refUri",
",",
... | get all dependencies by one file path
@param {String} filepath file path
@return {Array} dependencies list | [
"get",
"all",
"dependencies",
"by",
"one",
"file",
"path"
] | 57d9b2a8725ae22c98f7150cae9a85badbd2c9cb | https://github.com/tgideas/grunt-motion-build/blob/57d9b2a8725ae22c98f7150cae9a85badbd2c9cb/tasks/motion_build.js#L197-L230 | train | |
genjs/gutil | lib/util/and.js | and | function and(values, values2) {
var results = [];
if(values instanceof Array) {
for(var i=0; i<values.length; i++) {
results.push(values[i]);
}
}
if(values2 instanceof Array) {
for(var i=0; i<values2.length; i++) {
results.push(values2[i]);
}
}... | javascript | function and(values, values2) {
var results = [];
if(values instanceof Array) {
for(var i=0; i<values.length; i++) {
results.push(values[i]);
}
}
if(values2 instanceof Array) {
for(var i=0; i<values2.length; i++) {
results.push(values2[i]);
}
}... | [
"function",
"and",
"(",
"values",
",",
"values2",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"values",
"instanceof",
"Array",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")... | Merge two arrays.
@param values array 1
@param values2 array 2
@returns {Array} | [
"Merge",
"two",
"arrays",
"."
] | c2890fdd030bb9f0cad9f5c7c9da442411c3903a | https://github.com/genjs/gutil/blob/c2890fdd030bb9f0cad9f5c7c9da442411c3903a/lib/util/and.js#L7-L20 | train |
david4096/ga4gh-node-gateway | src/rpc.js | getMethod | function getMethod(methodname) {
if (controllers[methodname]) {
return function(call, callback) {
console.log(call);
return controllers[methodname](call, callback);
};
} else {
return function(call, callback) {
// By default we print an empty response.
callback(null, {});
};
... | javascript | function getMethod(methodname) {
if (controllers[methodname]) {
return function(call, callback) {
console.log(call);
return controllers[methodname](call, callback);
};
} else {
return function(call, callback) {
// By default we print an empty response.
callback(null, {});
};
... | [
"function",
"getMethod",
"(",
"methodname",
")",
"{",
"if",
"(",
"controllers",
"[",
"methodname",
"]",
")",
"{",
"return",
"function",
"(",
"call",
",",
"callback",
")",
"{",
"console",
".",
"log",
"(",
"call",
")",
";",
"return",
"controllers",
"[",
... | Allows us to define methods as we go and hook them up by name to the schemas. It should be possible to determine if a method is streaming or not and get it from a different controller. No maintaining key-value maps! | [
"Allows",
"us",
"to",
"define",
"methods",
"as",
"we",
"go",
"and",
"hook",
"them",
"up",
"by",
"name",
"to",
"the",
"schemas",
".",
"It",
"should",
"be",
"possible",
"to",
"determine",
"if",
"a",
"method",
"is",
"streaming",
"or",
"not",
"and",
"get",... | 3864c10503c9273ea2697d1754bef775ec6ad536 | https://github.com/david4096/ga4gh-node-gateway/blob/3864c10503c9273ea2697d1754bef775ec6ad536/src/rpc.js#L12-L24 | train |
MaiaVictor/dattata | Vector3.js | scale | function scale(s, v){
return Vector3(v.x*s, v.y*s, v.z*s);
} | javascript | function scale(s, v){
return Vector3(v.x*s, v.y*s, v.z*s);
} | [
"function",
"scale",
"(",
"s",
",",
"v",
")",
"{",
"return",
"Vector3",
"(",
"v",
".",
"x",
"*",
"s",
",",
"v",
".",
"y",
"*",
"s",
",",
"v",
".",
"z",
"*",
"s",
")",
";",
"}"
] | Double, Vector -> Vector | [
"Double",
"Vector",
"-",
">",
"Vector"
] | 890d83b89b7193ce8863bb9ac9b296b3510e8db9 | https://github.com/MaiaVictor/dattata/blob/890d83b89b7193ce8863bb9ac9b296b3510e8db9/Vector3.js#L44-L46 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList, contentHtml ) {
if ( arguments.length < 4 )
return;
var _ = initPrivateObject.call( this, elementDefinition );
_.labelId = CKEDITOR.tools.getNextId() + '_label';
var children = this._.children = [];
var innerHTML = function() {
var... | javascript | function( dialog, elementDefinition, htmlList, contentHtml ) {
if ( arguments.length < 4 )
return;
var _ = initPrivateObject.call( this, elementDefinition );
_.labelId = CKEDITOR.tools.getNextId() + '_label';
var children = this._.children = [];
var innerHTML = function() {
var... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
",",
"contentHtml",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"4",
")",
"return",
";",
"var",
"_",
"=",
"initPrivateObject",
".",
"call",
"(",
"this",
",",
"elementDefinition... | Base class for all dialog window elements with a textual label on the left.
@class CKEDITOR.ui.dialog.labeledElement
@extends CKEDITOR.ui.dialog.uiElement
@constructor Creates a labeledElement class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} ele... | [
"Base",
"class",
"for",
"all",
"dialog",
"window",
"elements",
"with",
"a",
"textual",
"label",
"on",
"the",
"left",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L125-L181 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
initPrivateObject.call( this, elementDefinition );
var domId = this._.inputId = CKEDITOR.tools.getNextId() + '_textInput',
attributes = { 'class': 'cke_dialog_ui_input_' + elementDefinition.type, id: domId... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
initPrivateObject.call( this, elementDefinition );
var domId = this._.inputId = CKEDITOR.tools.getNextId() + '_textInput',
attributes = { 'class': 'cke_dialog_ui_input_' + elementDefinition.type, id: domId... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"return",
";",
"initPrivateObject",
".",
"call",
"(",
"this",
",",
"elementDefinition",
")",
";",
"var",
"domId",
"=",
"... | A text input with a label. This UI element class represents both the
single-line text inputs and password inputs in dialog boxes.
@class CKEDITOR.ui.dialog.textInput
@extends CKEDITOR.ui.dialog.labeledElement
@constructor Creates a textInput class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
... | [
"A",
"text",
"input",
"with",
"a",
"label",
".",
"This",
"UI",
"element",
"class",
"represents",
"both",
"the",
"single",
"-",
"line",
"text",
"inputs",
"and",
"password",
"inputs",
"in",
"dialog",
"boxes",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L202-L262 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
initPrivateObject.call( this, elementDefinition );
var me = this,
domId = this._.inputId = CKEDITOR.tools.getNextId() + '_textarea',
attributes = {};
if ( elementDefinition.validate )
th... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
initPrivateObject.call( this, elementDefinition );
var me = this,
domId = this._.inputId = CKEDITOR.tools.getNextId() + '_textarea',
attributes = {};
if ( elementDefinition.validate )
th... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"return",
";",
"initPrivateObject",
".",
"call",
"(",
"this",
",",
"elementDefinition",
")",
";",
"var",
"me",
"=",
"thi... | A text area with a label at the top or on the left.
@class CKEDITOR.ui.dialog.textarea
@extends CKEDITOR.ui.dialog.labeledElement
@constructor Creates a textarea class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element def... | [
"A",
"text",
"area",
"with",
"a",
"label",
"at",
"the",
"top",
"or",
"on",
"the",
"left",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L284-L318 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
var _ = initPrivateObject.call( this, elementDefinition, { 'default': !!elementDefinition[ 'default' ] } );
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
var innerH... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
var _ = initPrivateObject.call( this, elementDefinition, { 'default': !!elementDefinition[ 'default' ] } );
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
var innerH... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"return",
";",
"var",
"_",
"=",
"initPrivateObject",
".",
"call",
"(",
"this",
",",
"elementDefinition",
",",
"{",
"'def... | A single checkbox with a label on the right.
@class CKEDITOR.ui.dialog.checkbox
@extends CKEDITOR.ui.dialog.uiElement
@constructor Creates a checkbox class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element definition. Acce... | [
"A",
"single",
"checkbox",
"with",
"a",
"label",
"on",
"the",
"right",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L337-L367 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
initPrivateObject.call( this, elementDefinition );
if ( !this._[ 'default' ] )
this._[ 'default' ] = this._.initValue = elementDefinition.items[ 0 ][ 1 ];
if ( elementDefinition.validate )
t... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
initPrivateObject.call( this, elementDefinition );
if ( !this._[ 'default' ] )
this._[ 'default' ] = this._.initValue = elementDefinition.items[ 0 ][ 1 ];
if ( elementDefinition.validate )
t... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"return",
";",
"initPrivateObject",
".",
"call",
"(",
"this",
",",
"elementDefinition",
")",
";",
"if",
"(",
"!",
"this"... | A group of radio buttons.
@class CKEDITOR.ui.dialog.radio
@extends CKEDITOR.ui.dialog.labeledElement
@constructor Creates a radio class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element definition. Accepted fields:
* `def... | [
"A",
"group",
"of",
"radio",
"buttons",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L387-L469 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( !arguments.length )
return;
if ( typeof elementDefinition == 'function' )
elementDefinition = elementDefinition( dialog.getParentEditor() );
initPrivateObject.call( this, elementDefinition, { disabled: elementDefinition.disabled || fa... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( !arguments.length )
return;
if ( typeof elementDefinition == 'function' )
elementDefinition = elementDefinition( dialog.getParentEditor() );
initPrivateObject.call( this, elementDefinition, { disabled: elementDefinition.disabled || fa... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"!",
"arguments",
".",
"length",
")",
"return",
";",
"if",
"(",
"typeof",
"elementDefinition",
"==",
"'function'",
")",
"elementDefinition",
"=",
"elementDefinition",
"(... | A button with a label inside.
@class CKEDITOR.ui.dialog.button
@extends CKEDITOR.ui.dialog.uiElement
@constructor Creates a button class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element definition. Accepted fields:
* `la... | [
"A",
"button",
"with",
"a",
"label",
"inside",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L487-L538 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
var _ = initPrivateObject.call( this, elementDefinition );
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
_.inputId = CKEDITOR.tools.getNextId() + '_select';
... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
var _ = initPrivateObject.call( this, elementDefinition );
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
_.inputId = CKEDITOR.tools.getNextId() + '_select';
... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"return",
";",
"var",
"_",
"=",
"initPrivateObject",
".",
"call",
"(",
"this",
",",
"elementDefinition",
")",
";",
"if",... | A select box.
@class CKEDITOR.ui.dialog.select
@extends CKEDITOR.ui.dialog.uiElement
@constructor Creates a button class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element definition. Accepted fields:
* `default` (Required... | [
"A",
"select",
"box",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L563-L609 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
if ( elementDefinition[ 'default' ] === undefined )
elementDefinition[ 'default' ] = '';
var _ = CKEDITOR.tools.extend( initPrivateObject.call( this, elementDefinition ), { definition: elementDefinition,... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
if ( elementDefinition[ 'default' ] === undefined )
elementDefinition[ 'default' ] = '';
var _ = CKEDITOR.tools.extend( initPrivateObject.call( this, elementDefinition ), { definition: elementDefinition,... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"return",
";",
"if",
"(",
"elementDefinition",
"[",
"'default'",
"]",
"===",
"undefined",
")",
"elementDefinition",
"[",
"... | A file upload input.
@class CKEDITOR.ui.dialog.file
@extends CKEDITOR.ui.dialog.labeledElement
@constructor Creates a file class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element definition. Accepted fields:
* `validate` ... | [
"A",
"file",
"upload",
"input",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L625-L675 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
var _ = initPrivateObject.call( this, elementDefinition ),
me = this;
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
var myDefinition = CKEDITOR.tools.extend( ... | javascript | function( dialog, elementDefinition, htmlList ) {
if ( arguments.length < 3 )
return;
var _ = initPrivateObject.call( this, elementDefinition ),
me = this;
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
var myDefinition = CKEDITOR.tools.extend( ... | [
"function",
"(",
"dialog",
",",
"elementDefinition",
",",
"htmlList",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"3",
")",
"return",
";",
"var",
"_",
"=",
"initPrivateObject",
".",
"call",
"(",
"this",
",",
"elementDefinition",
")",
",",
"me",... | A button for submitting the file in a file upload input.
@class CKEDITOR.ui.dialog.fileButton
@extends CKEDITOR.ui.dialog.button
@constructor Creates a fileButton class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element def... | [
"A",
"button",
"for",
"submitting",
"the",
"file",
"in",
"a",
"file",
"upload",
"input",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L693-L719 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) {
var legendLabel = elementDefinition.label;
/** @ignore */
var innerHTML = function() {
var html = [];
legendLabel && html.push( '<legend' +
( elementDefinition.labelStyle ? ' style="' + elementDefinition.... | javascript | function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) {
var legendLabel = elementDefinition.label;
/** @ignore */
var innerHTML = function() {
var html = [];
legendLabel && html.push( '<legend' +
( elementDefinition.labelStyle ? ' style="' + elementDefinition.... | [
"function",
"(",
"dialog",
",",
"childObjList",
",",
"childHtmlList",
",",
"htmlList",
",",
"elementDefinition",
")",
"{",
"var",
"legendLabel",
"=",
"elementDefinition",
".",
"label",
";",
"/** @ignore */",
"var",
"innerHTML",
"=",
"function",
"(",
")",
"{",
... | Form fieldset for grouping dialog UI elements.
@class CKEDITOR.ui.dialog.fieldset
@extends CKEDITOR.ui.dialog.uiElement
@constructor Creates a fieldset class instance.
@param {CKEDITOR.dialog} dialog Parent dialog window object.
@param {Array} childObjList
Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside t... | [
"Form",
"fieldset",
"for",
"grouping",
"dialog",
"UI",
"elements",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L802-L817 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( label ) {
var node = CKEDITOR.document.getById( this._.labelId );
if ( node.getChildCount() < 1 )
( new CKEDITOR.dom.text( label, CKEDITOR.document ) ).appendTo( node );
else
node.getChild( 0 ).$.nodeValue = label;
return this;
} | javascript | function( label ) {
var node = CKEDITOR.document.getById( this._.labelId );
if ( node.getChildCount() < 1 )
( new CKEDITOR.dom.text( label, CKEDITOR.document ) ).appendTo( node );
else
node.getChild( 0 ).$.nodeValue = label;
return this;
} | [
"function",
"(",
"label",
")",
"{",
"var",
"node",
"=",
"CKEDITOR",
".",
"document",
".",
"getById",
"(",
"this",
".",
"_",
".",
"labelId",
")",
";",
"if",
"(",
"node",
".",
"getChildCount",
"(",
")",
"<",
"1",
")",
"(",
"new",
"CKEDITOR",
".",
"... | Sets the label text of the element.
@param {String} label The new label text.
@returns {CKEDITOR.ui.dialog.labeledElement} The current labeled element. | [
"Sets",
"the",
"label",
"text",
"of",
"the",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L831-L838 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function() {
var node = CKEDITOR.document.getById( this._.labelId );
if ( !node || node.getChildCount() < 1 )
return '';
else
return node.getChild( 0 ).getText();
} | javascript | function() {
var node = CKEDITOR.document.getById( this._.labelId );
if ( !node || node.getChildCount() < 1 )
return '';
else
return node.getChild( 0 ).getText();
} | [
"function",
"(",
")",
"{",
"var",
"node",
"=",
"CKEDITOR",
".",
"document",
".",
"getById",
"(",
"this",
".",
"_",
".",
"labelId",
")",
";",
"if",
"(",
"!",
"node",
"||",
"node",
".",
"getChildCount",
"(",
")",
"<",
"1",
")",
"return",
"''",
";",... | Retrieves the current label text of the elment.
@returns {String} The current label text. | [
"Retrieves",
"the",
"current",
"label",
"text",
"of",
"the",
"elment",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L845-L851 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function() {
var me = this.selectParentTab();
// GECKO BUG: setTimeout() is needed to workaround invisible selections.
setTimeout( function() {
var e = me.getInputElement();
if ( e ) {
e.$.focus();
e.$.select();
}
}, 0 );
} | javascript | function() {
var me = this.selectParentTab();
// GECKO BUG: setTimeout() is needed to workaround invisible selections.
setTimeout( function() {
var e = me.getInputElement();
if ( e ) {
e.$.focus();
e.$.select();
}
}, 0 );
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
".",
"selectParentTab",
"(",
")",
";",
"// GECKO BUG: setTimeout() is needed to workaround invisible selections.\r",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"e",
"=",
"me",
".",
"getInputElement",
"... | Selects all the text in the text input. | [
"Selects",
"all",
"the",
"text",
"in",
"the",
"text",
"input",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L968-L979 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( value ) {
!value && ( value = '' );
return CKEDITOR.ui.dialog.uiElement.prototype.setValue.apply( this, arguments );
} | javascript | function( value ) {
!value && ( value = '' );
return CKEDITOR.ui.dialog.uiElement.prototype.setValue.apply( this, arguments );
} | [
"function",
"(",
"value",
")",
"{",
"!",
"value",
"&&",
"(",
"value",
"=",
"''",
")",
";",
"return",
"CKEDITOR",
".",
"ui",
".",
"dialog",
".",
"uiElement",
".",
"prototype",
".",
"setValue",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"... | Sets the value of this text input object.
uiElement.setValue( 'Blamo' );
@param {Object} value The new value.
@returns {CKEDITOR.ui.dialog.textInput} The current UI element. | [
"Sets",
"the",
"value",
"of",
"this",
"text",
"input",
"object",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L997-L1000 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( label, value, index ) {
var option = new CKEDITOR.dom.element( 'option', this.getDialog().getParentEditor().document ),
selectElement = this.getInputElement().$;
option.$.text = label;
option.$.value = ( value === undefined || value === null ) ? label : value;
if ( index === undefine... | javascript | function( label, value, index ) {
var option = new CKEDITOR.dom.element( 'option', this.getDialog().getParentEditor().document ),
selectElement = this.getInputElement().$;
option.$.text = label;
option.$.value = ( value === undefined || value === null ) ? label : value;
if ( index === undefine... | [
"function",
"(",
"label",
",",
"value",
",",
"index",
")",
"{",
"var",
"option",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"'option'",
",",
"this",
".",
"getDialog",
"(",
")",
".",
"getParentEditor",
"(",
")",
".",
"document",
")",
","... | Adds an option to the select box.
@param {String} label Option label.
@param {String} value (Optional) Option value, if not defined it will be
assumed to be the same as the label.
@param {Number} index (Optional) Position of the option to be inserted
to. If not defined, the new option will be inserted to the end of li... | [
"Adds",
"an",
"option",
"to",
"the",
"select",
"box",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L1028-L1041 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( value, noChangeEvent ) {
var children = this._.children,
item;
for ( var i = 0;
( i < children.length ) && ( item = children[ i ] ); i++ )
item.getElement().$.checked = ( item.getValue() == value );
!noChangeEvent && this.fire( 'change', { value: value } );
} | javascript | function( value, noChangeEvent ) {
var children = this._.children,
item;
for ( var i = 0;
( i < children.length ) && ( item = children[ i ] ); i++ )
item.getElement().$.checked = ( item.getValue() == value );
!noChangeEvent && this.fire( 'change', { value: value } );
} | [
"function",
"(",
"value",
",",
"noChangeEvent",
")",
"{",
"var",
"children",
"=",
"this",
".",
"_",
".",
"children",
",",
"item",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"(",
"i",
"<",
"children",
".",
"length",
")",
"&&",
"(",
"item",
"=",
... | Selects one of the radio buttons in this button group.
@param {String} value The value of the button to be chcked.
@param {Boolean} noChangeEvent Internal commit, to supress the `change` event on this element. | [
"Selects",
"one",
"of",
"the",
"radio",
"buttons",
"in",
"this",
"button",
"group",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L1143-L1150 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function() {
var children = this._.children;
for ( var i = 0; i < children.length; i++ ) {
if ( children[ i ].getElement().$.checked )
return children[ i ].getValue();
}
return null;
} | javascript | function() {
var children = this._.children;
for ( var i = 0; i < children.length; i++ ) {
if ( children[ i ].getElement().$.checked )
return children[ i ].getValue();
}
return null;
} | [
"function",
"(",
")",
"{",
"var",
"children",
"=",
"this",
".",
"_",
".",
"children",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"children",
"[",
"i",
"]",
".",
"getEl... | Gets the value of the currently selected radio button.
@returns {String} The currently selected button's value. | [
"Gets",
"the",
"value",
"of",
"the",
"currently",
"selected",
"radio",
"button",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L1157-L1164 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function() {
var children = this._.children,
i;
for ( i = 0; i < children.length; i++ ) {
if ( children[ i ].getElement().$.checked ) {
children[ i ].getElement().focus();
return;
}
}
children[ 0 ].getElement().focus();
} | javascript | function() {
var children = this._.children,
i;
for ( i = 0; i < children.length; i++ ) {
if ( children[ i ].getElement().$.checked ) {
children[ i ].getElement().focus();
return;
}
}
children[ 0 ].getElement().focus();
} | [
"function",
"(",
")",
"{",
"var",
"children",
"=",
"this",
".",
"_",
".",
"children",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"children",
"[",
"i",
"]",
".",
"... | Handler for the access key up event. Focuses the currently
selected radio button, or the first radio button if none is selected. | [
"Handler",
"for",
"the",
"access",
"key",
"up",
"event",
".",
"Focuses",
"the",
"currently",
"selected",
"radio",
"button",
"or",
"the",
"first",
"radio",
"button",
"if",
"none",
"is",
"selected",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L1170-L1180 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/dialogui/plugin.js | function( definition ) {
var regex = /^on([A-Z]\w+)/,
match;
var registerDomEvent = function( uiElement, dialog, eventName, func ) {
uiElement.on( 'formLoaded', function() {
uiElement.getInputElement().on( eventName, func, uiElement );
} );
};
for ( var i in definiti... | javascript | function( definition ) {
var regex = /^on([A-Z]\w+)/,
match;
var registerDomEvent = function( uiElement, dialog, eventName, func ) {
uiElement.on( 'formLoaded', function() {
uiElement.getInputElement().on( eventName, func, uiElement );
} );
};
for ( var i in definiti... | [
"function",
"(",
"definition",
")",
"{",
"var",
"regex",
"=",
"/",
"^on([A-Z]\\w+)",
"/",
",",
"match",
";",
"var",
"registerDomEvent",
"=",
"function",
"(",
"uiElement",
",",
"dialog",
",",
"eventName",
",",
"func",
")",
"{",
"uiElement",
".",
"on",
"("... | The events must be applied to the inner input element, and
this must be done when the iframe and form have been loaded. | [
"The",
"events",
"must",
"be",
"applied",
"to",
"the",
"inner",
"input",
"element",
"and",
"this",
"must",
"be",
"done",
"when",
"the",
"iframe",
"and",
"form",
"have",
"been",
"loaded",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L1246-L1267 | train | |
jhooky/events | events.js | function (callback, context, args) {
var arg1, arg2, arg3
arg1 = args[0]
arg2 = args[1]
arg3 = args[2]
switch (args.length) {
case 0:
callback.call(context); return
case 1:
callback.call(context, arg1); return
case 2:
callback.call(arg1, arg2); return
case 3:
callback.c... | javascript | function (callback, context, args) {
var arg1, arg2, arg3
arg1 = args[0]
arg2 = args[1]
arg3 = args[2]
switch (args.length) {
case 0:
callback.call(context); return
case 1:
callback.call(context, arg1); return
case 2:
callback.call(arg1, arg2); return
case 3:
callback.c... | [
"function",
"(",
"callback",
",",
"context",
",",
"args",
")",
"{",
"var",
"arg1",
",",
"arg2",
",",
"arg3",
"arg1",
"=",
"args",
"[",
"0",
"]",
"arg2",
"=",
"args",
"[",
"1",
"]",
"arg3",
"=",
"args",
"[",
"2",
"]",
"switch",
"(",
"args",
".",... | This is probably overkill... but what the hell, why not? | [
"This",
"is",
"probably",
"overkill",
"...",
"but",
"what",
"the",
"hell",
"why",
"not?"
] | ed74b0ca5a333c889e8a9291c8c24e813c950e86 | https://github.com/jhooky/events/blob/ed74b0ca5a333c889e8a9291c8c24e813c950e86/events.js#L27-L44 | train | |
Pocketbrain/native-ads-web-ad-library | src/adLib.js | function (environment, options) {
this.applicationId = options && options.applicationId;
this.environment = environment;
this.page = page;
this.adManager = null;
this.path = window.location.pathname;
this.events = events;
this.adManager = new AdManager(this.applicationId, this.deviceDetails,... | javascript | function (environment, options) {
this.applicationId = options && options.applicationId;
this.environment = environment;
this.page = page;
this.adManager = null;
this.path = window.location.pathname;
this.events = events;
this.adManager = new AdManager(this.applicationId, this.deviceDetails,... | [
"function",
"(",
"environment",
",",
"options",
")",
"{",
"this",
".",
"applicationId",
"=",
"options",
"&&",
"options",
".",
"applicationId",
";",
"this",
".",
"environment",
"=",
"environment",
";",
"this",
".",
"page",
"=",
"page",
";",
"this",
".",
"... | Constructor that creates an instance of the AdLibrary object
@param environment - The environment object containing environment specific functions
@param [options] - Optional options to initialize the ad library with
@constructor | [
"Constructor",
"that",
"creates",
"an",
"instance",
"of",
"the",
"AdLibrary",
"object"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/adLib.js#L18-L40 | train | |
pvorb/node-pub | pub.js | exp | function exp(cmd, confdir) {
return function (files, opt) {
var defaultOpt = {
cwd: process.cwd()
};
opt = append(defaultOpt, opt);
if (typeof files == 'string')
files = [ files ];
require(path.resolve(confdir, cmd + '.js'))(files, opt);
};
} | javascript | function exp(cmd, confdir) {
return function (files, opt) {
var defaultOpt = {
cwd: process.cwd()
};
opt = append(defaultOpt, opt);
if (typeof files == 'string')
files = [ files ];
require(path.resolve(confdir, cmd + '.js'))(files, opt);
};
} | [
"function",
"exp",
"(",
"cmd",
",",
"confdir",
")",
"{",
"return",
"function",
"(",
"files",
",",
"opt",
")",
"{",
"var",
"defaultOpt",
"=",
"{",
"cwd",
":",
"process",
".",
"cwd",
"(",
")",
"}",
";",
"opt",
"=",
"append",
"(",
"defaultOpt",
",",
... | exports a command | [
"exports",
"a",
"command"
] | d1caf1b8e5b9d4dd43bbedf7a112646108653b02 | https://github.com/pvorb/node-pub/blob/d1caf1b8e5b9d4dd43bbedf7a112646108653b02/pub.js#L24-L36 | train |
christophercrouzet/pillr | lib/components/render_content.js | popFootnoteTokens | function popFootnoteTokens(tokens) {
const from = tokens.findIndex(token => token.type === 'footnote_block_open');
const to = tokens.findIndex(token => token.type === 'footnote_block_close');
if (from === -1 || to === -1) {
return [];
}
return tokens.splice(from, (to - from) + 1);
} | javascript | function popFootnoteTokens(tokens) {
const from = tokens.findIndex(token => token.type === 'footnote_block_open');
const to = tokens.findIndex(token => token.type === 'footnote_block_close');
if (from === -1 || to === -1) {
return [];
}
return tokens.splice(from, (to - from) + 1);
} | [
"function",
"popFootnoteTokens",
"(",
"tokens",
")",
"{",
"const",
"from",
"=",
"tokens",
".",
"findIndex",
"(",
"token",
"=>",
"token",
".",
"type",
"===",
"'footnote_block_open'",
")",
";",
"const",
"to",
"=",
"tokens",
".",
"findIndex",
"(",
"token",
"=... | Remove the footnote tokens from within a token list. | [
"Remove",
"the",
"footnote",
"tokens",
"from",
"within",
"a",
"token",
"list",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/components/render_content.js#L15-L23 | train |
christophercrouzet/pillr | lib/components/render_content.js | footnoteTokensToMeta | function footnoteTokensToMeta(tokens, md) {
return tokens
.map((token, i) => { return token.type === 'footnote_open' ? i : -1; })
.filter(i => i >= 0)
.map((i) => {
const inlineToken = tokens[i + 2];
assert(inlineToken.type === 'inline');
const anchorToken = tokens[i + 3];
assert(a... | javascript | function footnoteTokensToMeta(tokens, md) {
return tokens
.map((token, i) => { return token.type === 'footnote_open' ? i : -1; })
.filter(i => i >= 0)
.map((i) => {
const inlineToken = tokens[i + 2];
assert(inlineToken.type === 'inline');
const anchorToken = tokens[i + 3];
assert(a... | [
"function",
"footnoteTokensToMeta",
"(",
"tokens",
",",
"md",
")",
"{",
"return",
"tokens",
".",
"map",
"(",
"(",
"token",
",",
"i",
")",
"=>",
"{",
"return",
"token",
".",
"type",
"===",
"'footnote_open'",
"?",
"i",
":",
"-",
"1",
";",
"}",
")",
"... | Convert the footnote tokens into metadata. | [
"Convert",
"the",
"footnote",
"tokens",
"into",
"metadata",
"."
] | 411ccd344a03478776c4e8d2e2f9bdc45dc8ee45 | https://github.com/christophercrouzet/pillr/blob/411ccd344a03478776c4e8d2e2f9bdc45dc8ee45/lib/components/render_content.js#L27-L42 | train |
amooj/node-xcheck | lib/namespace.js | function (namespace, names){
if (names){
for (let i = 0, n = names.length; i < n; ++i){
let typeName = names[i];
if (namespace.names.hasOwnProperty(typeName)){
this.names[typeName] = namespace.names[typeName];
}
else {
throw new ReferenceError('import error:... | javascript | function (namespace, names){
if (names){
for (let i = 0, n = names.length; i < n; ++i){
let typeName = names[i];
if (namespace.names.hasOwnProperty(typeName)){
this.names[typeName] = namespace.names[typeName];
}
else {
throw new ReferenceError('import error:... | [
"function",
"(",
"namespace",
",",
"names",
")",
"{",
"if",
"(",
"names",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"n",
"=",
"names",
".",
"length",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"let",
"typeName",
"=",
"names",
"[",
... | Import type names from another namespace.
@param {TemplateNamespace} namespace
@param {Array<String>} [names] - names to import
@returns {TemplateNamespace} | [
"Import",
"type",
"names",
"from",
"another",
"namespace",
"."
] | 33b2b59f7d81a8e0421a468a405f15a19126bedf | https://github.com/amooj/node-xcheck/blob/33b2b59f7d81a8e0421a468a405f15a19126bedf/lib/namespace.js#L28-L49 | train | |
amooj/node-xcheck | lib/namespace.js | function(alias, typeName){
let template = this.resolve(typeName);
if (!template){
throw new ReferenceError('bad alias \'' + alias + '\': type \'' + typeName + '\' is undefined');
}
this.names[alias] = template;
} | javascript | function(alias, typeName){
let template = this.resolve(typeName);
if (!template){
throw new ReferenceError('bad alias \'' + alias + '\': type \'' + typeName + '\' is undefined');
}
this.names[alias] = template;
} | [
"function",
"(",
"alias",
",",
"typeName",
")",
"{",
"let",
"template",
"=",
"this",
".",
"resolve",
"(",
"typeName",
")",
";",
"if",
"(",
"!",
"template",
")",
"{",
"throw",
"new",
"ReferenceError",
"(",
"'bad alias \\''",
"+",
"alias",
"+",
"'\\': type... | Defines an typename alias.
@param {String} alias
@param {String} typeName - existing template type, may be a built-in type. | [
"Defines",
"an",
"typename",
"alias",
"."
] | 33b2b59f7d81a8e0421a468a405f15a19126bedf | https://github.com/amooj/node-xcheck/blob/33b2b59f7d81a8e0421a468a405f15a19126bedf/lib/namespace.js#L56-L62 | train | |
amooj/node-xcheck | lib/namespace.js | function(typeName, template){
if (!(template instanceof ValueTemplate)){
template = ValueTemplate.parse(template, {namespace:this});
}
class UserDefinedTemplate extends ValueTemplate{
constructor(defaultValue, validator){
super(typeName, defaultValue, validator);
this.template = ... | javascript | function(typeName, template){
if (!(template instanceof ValueTemplate)){
template = ValueTemplate.parse(template, {namespace:this});
}
class UserDefinedTemplate extends ValueTemplate{
constructor(defaultValue, validator){
super(typeName, defaultValue, validator);
this.template = ... | [
"function",
"(",
"typeName",
",",
"template",
")",
"{",
"if",
"(",
"!",
"(",
"template",
"instanceof",
"ValueTemplate",
")",
")",
"{",
"template",
"=",
"ValueTemplate",
".",
"parse",
"(",
"template",
",",
"{",
"namespace",
":",
"this",
"}",
")",
";",
"... | Defines a template type.
@param {String} typeName - name of the new type.
@param {*|ValueTemplate} template - base template of the new type. | [
"Defines",
"a",
"template",
"type",
"."
] | 33b2b59f7d81a8e0421a468a405f15a19126bedf | https://github.com/amooj/node-xcheck/blob/33b2b59f7d81a8e0421a468a405f15a19126bedf/lib/namespace.js#L69-L85 | train | |
royriojas/grunt-r3m | lib/lib.js | function(lastValue) {
//var currentItem
if (current === len) {
cb && cb(lastValue);
return;
}
var item = items[current++];
setTimeout(function() {
fn(item, function(val) {
process(val && lastValue);
});
}, 20);
} | javascript | function(lastValue) {
//var currentItem
if (current === len) {
cb && cb(lastValue);
return;
}
var item = items[current++];
setTimeout(function() {
fn(item, function(val) {
process(val && lastValue);
});
}, 20);
} | [
"function",
"(",
"lastValue",
")",
"{",
"//var currentItem",
"if",
"(",
"current",
"===",
"len",
")",
"{",
"cb",
"&&",
"cb",
"(",
"lastValue",
")",
";",
"return",
";",
"}",
"var",
"item",
"=",
"items",
"[",
"current",
"++",
"]",
";",
"setTimeout",
"(... | closure function to iterate over the items async | [
"closure",
"function",
"to",
"iterate",
"over",
"the",
"items",
"async"
] | bfe1ab877bcfd12df9503a1911aa0aeb08c09b96 | https://github.com/royriojas/grunt-r3m/blob/bfe1ab877bcfd12df9503a1911aa0aeb08c09b96/lib/lib.js#L96-L108 | train | |
royriojas/grunt-r3m | lib/lib.js | function(ns, root){
if (!ns) {
return null;
}
var nsParts = ns.split(".");
root = root || this;
for (var i = 0, len = nsParts.length; i < len; i++) {
if (typeof root[nsParts[i]] === "undefined") {
root[nsParts[i]] = {};
}
root = root[nsParts[i]];
}
return root... | javascript | function(ns, root){
if (!ns) {
return null;
}
var nsParts = ns.split(".");
root = root || this;
for (var i = 0, len = nsParts.length; i < len; i++) {
if (typeof root[nsParts[i]] === "undefined") {
root[nsParts[i]] = {};
}
root = root[nsParts[i]];
}
return root... | [
"function",
"(",
"ns",
",",
"root",
")",
"{",
"if",
"(",
"!",
"ns",
")",
"{",
"return",
"null",
";",
"}",
"var",
"nsParts",
"=",
"ns",
".",
"split",
"(",
"\".\"",
")",
";",
"root",
"=",
"root",
"||",
"this",
";",
"for",
"(",
"var",
"i",
"=",
... | define a namespace object
@param {Object} ns | [
"define",
"a",
"namespace",
"object"
] | bfe1ab877bcfd12df9503a1911aa0aeb08c09b96 | https://github.com/royriojas/grunt-r3m/blob/bfe1ab877bcfd12df9503a1911aa0aeb08c09b96/lib/lib.js#L220-L233 | train | |
royriojas/grunt-r3m | lib/lib.js | function() {
var min, max, args = arguments;
//if only one argument is provided we are expecting to have a value between 0 and max
if (args.length === 1) {
max = args[0];
min = 0;
}
//two arguments provided mean we are expecting to have a number between min and max
if (args.length >=... | javascript | function() {
var min, max, args = arguments;
//if only one argument is provided we are expecting to have a value between 0 and max
if (args.length === 1) {
max = args[0];
min = 0;
}
//two arguments provided mean we are expecting to have a number between min and max
if (args.length >=... | [
"function",
"(",
")",
"{",
"var",
"min",
",",
"max",
",",
"args",
"=",
"arguments",
";",
"//if only one argument is provided we are expecting to have a value between 0 and max",
"if",
"(",
"args",
".",
"length",
"===",
"1",
")",
"{",
"max",
"=",
"args",
"[",
"0"... | return a random number between a min and a max value | [
"return",
"a",
"random",
"number",
"between",
"a",
"min",
"and",
"a",
"max",
"value"
] | bfe1ab877bcfd12df9503a1911aa0aeb08c09b96 | https://github.com/royriojas/grunt-r3m/blob/bfe1ab877bcfd12df9503a1911aa0aeb08c09b96/lib/lib.js#L240-L258 | train | |
sazze/node-thrift | lib/_thriftServer.js | Server | function Server(service, methods) {
this.service = service;
this.methods = methods;
if (typeof service === 'undefined') {
throw new Error('Thrift Service is required');
}
if (typeof methods !== 'object' || Object.keys(methods).length === 0) {
throw new Error('Thrift Methods Handlers are required');
... | javascript | function Server(service, methods) {
this.service = service;
this.methods = methods;
if (typeof service === 'undefined') {
throw new Error('Thrift Service is required');
}
if (typeof methods !== 'object' || Object.keys(methods).length === 0) {
throw new Error('Thrift Methods Handlers are required');
... | [
"function",
"Server",
"(",
"service",
",",
"methods",
")",
"{",
"this",
".",
"service",
"=",
"service",
";",
"this",
".",
"methods",
"=",
"methods",
";",
"if",
"(",
"typeof",
"service",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Th... | Create a New thrift Server
@param {object} service the thrift service
@param {object} methods the function handlers for the thrift calls
@fires thrift/Server#listening
@fires thrift/Server#connection
@fires thrift/Server#close
@fires thrift/Server#error
@class thrift/Server | [
"Create",
"a",
"New",
"thrift",
"Server"
] | 458d1829813cbd2d50dae610bc7210b75140e58f | https://github.com/sazze/node-thrift/blob/458d1829813cbd2d50dae610bc7210b75140e58f/lib/_thriftServer.js#L17-L31 | train |
infonl/delegator | index.js | Delegator | function Delegator(id, events, capture, bubble, contextDocument) {
this.bubble = bubble;
this.capture = capture;
this.document = contextDocument;
this.documentElement = contextDocument.documentElement;
this.events = events;
this.id = id;
this.registry = {};
} | javascript | function Delegator(id, events, capture, bubble, contextDocument) {
this.bubble = bubble;
this.capture = capture;
this.document = contextDocument;
this.documentElement = contextDocument.documentElement;
this.events = events;
this.id = id;
this.registry = {};
} | [
"function",
"Delegator",
"(",
"id",
",",
"events",
",",
"capture",
",",
"bubble",
",",
"contextDocument",
")",
"{",
"this",
".",
"bubble",
"=",
"bubble",
";",
"this",
".",
"capture",
"=",
"capture",
";",
"this",
".",
"document",
"=",
"contextDocument",
"... | Generic delegator for user interaction events,
intended to be consumed by an encapsulation module
that exposes an API that addresses concerns like
proper usage, privacy, sensible defaults and such.
@param {String} id
@param {Array} events
@param {Array} capture
@param {Array} bubble
@param {Document} contextDocument
@... | [
"Generic",
"delegator",
"for",
"user",
"interaction",
"events",
"intended",
"to",
"be",
"consumed",
"by",
"an",
"encapsulation",
"module",
"that",
"exposes",
"an",
"API",
"that",
"addresses",
"concerns",
"like",
"proper",
"usage",
"privacy",
"sensible",
"defaults"... | 3ed07c189109ec7f6e1475cca3313ded9a72a75a | https://github.com/infonl/delegator/blob/3ed07c189109ec7f6e1475cca3313ded9a72a75a/index.js#L16-L24 | train |
infonl/delegator | index.js | function (event) {
var trigger = event.target;
var probe = function (type) {
if ((type !== event.type) || (1 !== trigger.nodeType)) {
return false;
}
var attribute = ['data', this.id, type].join('-');
var key = trigger.getAttribute(attribu... | javascript | function (event) {
var trigger = event.target;
var probe = function (type) {
if ((type !== event.type) || (1 !== trigger.nodeType)) {
return false;
}
var attribute = ['data', this.id, type].join('-');
var key = trigger.getAttribute(attribu... | [
"function",
"(",
"event",
")",
"{",
"var",
"trigger",
"=",
"event",
".",
"target",
";",
"var",
"probe",
"=",
"function",
"(",
"type",
")",
"{",
"if",
"(",
"(",
"type",
"!==",
"event",
".",
"type",
")",
"||",
"(",
"1",
"!==",
"trigger",
".",
"node... | Delegate the event.
@param {Event} event | [
"Delegate",
"the",
"event",
"."
] | 3ed07c189109ec7f6e1475cca3313ded9a72a75a | https://github.com/infonl/delegator/blob/3ed07c189109ec7f6e1475cca3313ded9a72a75a/index.js#L33-L62 | train | |
infonl/delegator | index.js | function (map) {
Object.keys(map).forEach(function (key) {
if (!this.registry.hasOwnProperty(key)) {
this.registry[key] = map[key];
}
}, this);
return this;
} | javascript | function (map) {
Object.keys(map).forEach(function (key) {
if (!this.registry.hasOwnProperty(key)) {
this.registry[key] = map[key];
}
}, this);
return this;
} | [
"function",
"(",
"map",
")",
"{",
"Object",
".",
"keys",
"(",
"map",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"this",
".",
"registry",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"this",
".",
"registry",
"... | Add handlers to the registry.
@param {Object} map
@returns {Delegator} | [
"Add",
"handlers",
"to",
"the",
"registry",
"."
] | 3ed07c189109ec7f6e1475cca3313ded9a72a75a | https://github.com/infonl/delegator/blob/3ed07c189109ec7f6e1475cca3313ded9a72a75a/index.js#L83-L90 | train | |
LOKE/loke-config | lib/loke-config.js | LokeConfig | function LokeConfig(appName, options) {
options = options || {};
// check args
if (typeof appName !== 'string' || appName === '') {
throw new Error('LokeConfig requires appName to be provided');
}
if (Array.isArray(options)) {
// Support original argument format:
if (options.length === 0) {
... | javascript | function LokeConfig(appName, options) {
options = options || {};
// check args
if (typeof appName !== 'string' || appName === '') {
throw new Error('LokeConfig requires appName to be provided');
}
if (Array.isArray(options)) {
// Support original argument format:
if (options.length === 0) {
... | [
"function",
"LokeConfig",
"(",
"appName",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// check args",
"if",
"(",
"typeof",
"appName",
"!==",
"'string'",
"||",
"appName",
"===",
"''",
")",
"{",
"throw",
"new",
"Error",
"(",
... | Creates a new LOKE config instance
@param {String} appName The application name or ID.
Should match where the config files are placed/
@param {String} [options.appPath]
@param {[String]} [options.paths] An array of full paths to search for files.
The first file on the list should be the defaults and specify all values. | [
"Creates",
"a",
"new",
"LOKE",
"config",
"instance"
] | 84c207b2724c919bc6dde5efd7e7328591908cce | https://github.com/LOKE/loke-config/blob/84c207b2724c919bc6dde5efd7e7328591908cce/lib/loke-config.js#L18-L66 | train |
adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/bbcode/plugin.js | function (s) {
s = Tools.trim(s);
function rep(re, str) {
s = s.replace(re, str);
}
// example: <strong> to [b]
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi, "[url=$1]$2[/url]");
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi... | javascript | function (s) {
s = Tools.trim(s);
function rep(re, str) {
s = s.replace(re, str);
}
// example: <strong> to [b]
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi, "[url=$1]$2[/url]");
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi... | [
"function",
"(",
"s",
")",
"{",
"s",
"=",
"Tools",
".",
"trim",
"(",
"s",
")",
";",
"function",
"rep",
"(",
"re",
",",
"str",
")",
"{",
"s",
"=",
"s",
".",
"replace",
"(",
"re",
",",
"str",
")",
";",
"}",
"// example: <strong> to [b]",
"rep",
"... | Private methods HTML -> BBCode in PunBB dialect | [
"Private",
"methods",
"HTML",
"-",
">",
"BBCode",
"in",
"PunBB",
"dialect"
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/bbcode/plugin.js#L182-L229 | train | |
adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/bbcode/plugin.js | function (s) {
s = Tools.trim(s);
function rep(re, str) {
s = s.replace(re, str);
}
// example: [b] to <strong>
rep(/\n/gi, "<br />");
rep(/\[b\]/gi, "<strong>");
rep(/\[\/b\]/gi, "</strong>");
rep(/\[i\]/gi, "<em>");
... | javascript | function (s) {
s = Tools.trim(s);
function rep(re, str) {
s = s.replace(re, str);
}
// example: [b] to <strong>
rep(/\n/gi, "<br />");
rep(/\[b\]/gi, "<strong>");
rep(/\[\/b\]/gi, "</strong>");
rep(/\[i\]/gi, "<em>");
... | [
"function",
"(",
"s",
")",
"{",
"s",
"=",
"Tools",
".",
"trim",
"(",
"s",
")",
";",
"function",
"rep",
"(",
"re",
",",
"str",
")",
"{",
"s",
"=",
"s",
".",
"replace",
"(",
"re",
",",
"str",
")",
";",
"}",
"// example: [b] to <strong>",
"rep",
"... | BBCode -> HTML from PunBB dialect | [
"BBCode",
"-",
">",
"HTML",
"from",
"PunBB",
"dialect"
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/bbcode/plugin.js#L232-L255 | train | |
Ma3Route/node-sdk | lib/auth.js | addSignature | function addSignature(key, secret, uri, body, options) {
if (!_.isString(key) || !_.isString(secret)) {
throw new errors.AuthenticationRequiredError("key and secret must be provided for signing requests");
}
options = options || {};
// remove signature if it exists in URI object
uri.removeS... | javascript | function addSignature(key, secret, uri, body, options) {
if (!_.isString(key) || !_.isString(secret)) {
throw new errors.AuthenticationRequiredError("key and secret must be provided for signing requests");
}
options = options || {};
// remove signature if it exists in URI object
uri.removeS... | [
"function",
"addSignature",
"(",
"key",
",",
"secret",
",",
"uri",
",",
"body",
",",
"options",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"key",
")",
"||",
"!",
"_",
".",
"isString",
"(",
"secret",
")",
")",
"{",
"throw",
"new",
"error... | Add signature to URI instance for use in authenticating against the API.
The request body will be stringified using JSON.stringify if its not
a string.
@private
@memberof auth
@param {String} key - used to identify the client
@param {String} secret - used to sign the request
@param {URIjs} uri - an instance of URIjs
... | [
"Add",
"signature",
"to",
"URI",
"instance",
"for",
"use",
"in",
"authenticating",
"against",
"the",
"API",
".",
"The",
"request",
"body",
"will",
"be",
"stringified",
"using",
"JSON",
".",
"stringify",
"if",
"its",
"not",
"a",
"string",
"."
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/auth.js#L49-L112 | train |
Ma3Route/node-sdk | lib/auth.js | sign | function sign(key, secret, uri, body, options) {
// add timestamp
uri.addQuery("timestamp", utils.createTimestamp());
// add signature
addSignature(key, secret, uri, body, options);
return uri;
} | javascript | function sign(key, secret, uri, body, options) {
// add timestamp
uri.addQuery("timestamp", utils.createTimestamp());
// add signature
addSignature(key, secret, uri, body, options);
return uri;
} | [
"function",
"sign",
"(",
"key",
",",
"secret",
",",
"uri",
",",
"body",
",",
"options",
")",
"{",
"// add timestamp",
"uri",
".",
"addQuery",
"(",
"\"timestamp\"",
",",
"utils",
".",
"createTimestamp",
"(",
")",
")",
";",
"// add signature",
"addSignature",
... | Sign a URI instance.
Automatically adds a timestamp to the URI instance.
@public
@param {String} key - key used to sign
@param {String} secret - used to sign the request
@param {URIjs} uri - an instance of URIjs
@param {*} body - body to used in request
@param {Object} [options] - options
@param {Number} [options.api... | [
"Sign",
"a",
"URI",
"instance",
".",
"Automatically",
"adds",
"a",
"timestamp",
"to",
"the",
"URI",
"instance",
"."
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/auth.js#L130-L138 | train |
ozinc/node-restify-links | lib/links.js | makeLink | function makeLink(rel, ldo) {
var i, key, keys, result;
if (typeof ldo === 'string') {
return '<' + ldo + '>; rel="' + rel + '"';
}
result = '<' + ldo.href + '>; rel="' + rel + '"';
keys = Object.keys(ldo);
for (i = 0; i < keys.length; i += 1) {
key = keys[i];
if (key !== 'href' && key !== '... | javascript | function makeLink(rel, ldo) {
var i, key, keys, result;
if (typeof ldo === 'string') {
return '<' + ldo + '>; rel="' + rel + '"';
}
result = '<' + ldo.href + '>; rel="' + rel + '"';
keys = Object.keys(ldo);
for (i = 0; i < keys.length; i += 1) {
key = keys[i];
if (key !== 'href' && key !== '... | [
"function",
"makeLink",
"(",
"rel",
",",
"ldo",
")",
"{",
"var",
"i",
",",
"key",
",",
"keys",
",",
"result",
";",
"if",
"(",
"typeof",
"ldo",
"===",
"'string'",
")",
"{",
"return",
"'<'",
"+",
"ldo",
"+",
"'>; rel=\"'",
"+",
"rel",
"+",
"'\"'",
... | Set Link header field with the given `links`.
Examples:
res.links({
next: 'http://api.example.com/users?page=2',
last: 'http://api.example.com/users?page=5'
});
@param {Object} links
@return {ServerResponse}
@api public | [
"Set",
"Link",
"header",
"field",
"with",
"the",
"given",
"links",
"."
] | 68213903fa4ff8d9e55697bff1e8cd2fa348089f | https://github.com/ozinc/node-restify-links/blob/68213903fa4ff8d9e55697bff1e8cd2fa348089f/lib/links.js#L18-L37 | train |
hpcloud/hpcloud-js | lib/objectstorage/index.js | newFromIdentity | function newFromIdentity(identity, region) {
var service = identity.serviceByName('object-store', region);
var endpoint = service.publicURL;
var os = new ObjectStorage(identity.token(), endpoint);
return os;
} | javascript | function newFromIdentity(identity, region) {
var service = identity.serviceByName('object-store', region);
var endpoint = service.publicURL;
var os = new ObjectStorage(identity.token(), endpoint);
return os;
} | [
"function",
"newFromIdentity",
"(",
"identity",
",",
"region",
")",
"{",
"var",
"service",
"=",
"identity",
".",
"serviceByName",
"(",
"'object-store'",
",",
"region",
")",
";",
"var",
"endpoint",
"=",
"service",
".",
"publicURL",
";",
"var",
"os",
"=",
"n... | Create a new ObjectStorage instance from an IdentityServices
Identity.
@param {Identity} identity
An identity with a service catalog.
@param {string} region
The availability zone. e.g. 'az-1.region-a.geo-1'. If this is
omitted, the first available object storage will be used.
@param {Function} fn
A callback, which wil... | [
"Create",
"a",
"new",
"ObjectStorage",
"instance",
"from",
"an",
"IdentityServices",
"Identity",
"."
] | c457ea3ee6a21e361d1af0af70d64622b6910208 | https://github.com/hpcloud/hpcloud-js/blob/c457ea3ee6a21e361d1af0af70d64622b6910208/lib/objectstorage/index.js#L57-L63 | train |
d08ble/livecomment | public/js/main.js | modifyState | function modifyState($n) {
var state = self.state;
function selectByStateRecursive(name) {
if (state.recursive) {
return $n.find(name);
} else {
return $n.children(name)
}
}
var a;
var b;
if (state.mode == 'code') {
a = selectByStateRecursive('pre:visibl... | javascript | function modifyState($n) {
var state = self.state;
function selectByStateRecursive(name) {
if (state.recursive) {
return $n.find(name);
} else {
return $n.children(name)
}
}
var a;
var b;
if (state.mode == 'code') {
a = selectByStateRecursive('pre:visibl... | [
"function",
"modifyState",
"(",
"$n",
")",
"{",
"var",
"state",
"=",
"self",
".",
"state",
";",
"function",
"selectByStateRecursive",
"(",
"name",
")",
"{",
"if",
"(",
"state",
".",
"recursive",
")",
"{",
"return",
"$n",
".",
"find",
"(",
"name",
")",
... | DOM UPDATE STATE [ | [
"DOM",
"UPDATE",
"STATE",
"["
] | 9c4a00878101501411668070b4f6e7719e10d1fd | https://github.com/d08ble/livecomment/blob/9c4a00878101501411668070b4f6e7719e10d1fd/public/js/main.js#L204-L257 | train |
UXFoundry/hashdo | lib/packs.js | function (baseUrl, cardsDirectory) {
var packs = _.filter(FS.readdirSync(cardsDirectory), function (dir) { return _.startsWith(dir, 'hashdo-'); });
console.log('PACKS: Cards will be loaded from %s.', cardsDirectory);
var packCounter = 0,
cardCounter = 0,
hiddenCounter = 0;
for (... | javascript | function (baseUrl, cardsDirectory) {
var packs = _.filter(FS.readdirSync(cardsDirectory), function (dir) { return _.startsWith(dir, 'hashdo-'); });
console.log('PACKS: Cards will be loaded from %s.', cardsDirectory);
var packCounter = 0,
cardCounter = 0,
hiddenCounter = 0;
for (... | [
"function",
"(",
"baseUrl",
",",
"cardsDirectory",
")",
"{",
"var",
"packs",
"=",
"_",
".",
"filter",
"(",
"FS",
".",
"readdirSync",
"(",
"cardsDirectory",
")",
",",
"function",
"(",
"dir",
")",
"{",
"return",
"_",
".",
"startsWith",
"(",
"dir",
",",
... | Initializes and caches the packs and card data.
This function should be called before any other functions in the packs API.
@method init
@param {String} baseUrl The protocol and host name where your cards are being hosted. Eg: https://hashdo.com
@param {String} cardsDirectory The directory where you packs a... | [
"Initializes",
"and",
"caches",
"the",
"packs",
"and",
"card",
"data",
".",
"This",
"function",
"should",
"be",
"called",
"before",
"any",
"other",
"functions",
"in",
"the",
"packs",
"API",
"."
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/packs.js#L48-L109 | train | |
UXFoundry/hashdo | lib/packs.js | function (filter) {
if (cardCount > 0) {
return cardCount;
}
else {
cardCount = 0;
if (filter) {
filter = filter.toLowerCase();
_.each(_.keys(cardPacks), function (packKey) {
_.each(_.keys(cardPacks[packKey].cards), function (cardKey) {
var card ... | javascript | function (filter) {
if (cardCount > 0) {
return cardCount;
}
else {
cardCount = 0;
if (filter) {
filter = filter.toLowerCase();
_.each(_.keys(cardPacks), function (packKey) {
_.each(_.keys(cardPacks[packKey].cards), function (cardKey) {
var card ... | [
"function",
"(",
"filter",
")",
"{",
"if",
"(",
"cardCount",
">",
"0",
")",
"{",
"return",
"cardCount",
";",
"}",
"else",
"{",
"cardCount",
"=",
"0",
";",
"if",
"(",
"filter",
")",
"{",
"filter",
"=",
"filter",
".",
"toLowerCase",
"(",
")",
";",
... | Get the number of cards matching an optional filter.
@method count
@param {String} [filter] Optional filter for card names. The filter will use fuzzy matching.
@returns {Number} The number of cards found matching the filter. | [
"Get",
"the",
"number",
"of",
"cards",
"matching",
"an",
"optional",
"filter",
"."
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/packs.js#L119-L147 | train | |
UXFoundry/hashdo | lib/packs.js | function (pack, card) {
if (cardPacks[pack] && cardPacks[pack].cards[card]) {
return cardPacks[pack].cards[card];
}
} | javascript | function (pack, card) {
if (cardPacks[pack] && cardPacks[pack].cards[card]) {
return cardPacks[pack].cards[card];
}
} | [
"function",
"(",
"pack",
",",
"card",
")",
"{",
"if",
"(",
"cardPacks",
"[",
"pack",
"]",
"&&",
"cardPacks",
"[",
"pack",
"]",
".",
"cards",
"[",
"card",
"]",
")",
"{",
"return",
"cardPacks",
"[",
"pack",
"]",
".",
"cards",
"[",
"card",
"]",
";",... | Get a specific card object.
@method card
@param {String} pack The pack name.
@param {String} card The card name.
@returns {Object} The card object macthing the pack and name provided, undefined if not found. | [
"Get",
"a",
"specific",
"card",
"object",
"."
] | c2a0adcba0cca26d6ebe56bba17017b177609057 | https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/packs.js#L199-L203 | train | |
jias/eoraptor.js | build/eoraptor.js | compile | function compile (str, options) {
var id;
var render;
str = str || EMPTY;
options = options || {};
id = options.id || str;
render = eoraptor[id];
if (render) {
return render;
}
var oTag = options.oTag || OTAG;
var cTag = options.cTag || CTAG;
var code = build(par... | javascript | function compile (str, options) {
var id;
var render;
str = str || EMPTY;
options = options || {};
id = options.id || str;
render = eoraptor[id];
if (render) {
return render;
}
var oTag = options.oTag || OTAG;
var cTag = options.cTag || CTAG;
var code = build(par... | [
"function",
"compile",
"(",
"str",
",",
"options",
")",
"{",
"var",
"id",
";",
"var",
"render",
";",
"str",
"=",
"str",
"||",
"EMPTY",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"id",
"=",
"options",
".",
"id",
"||",
"str",
";",
"render... | to compile a template string to callable render @param {string} str a template string @param {object} options optional @param {string} options.id the unique name for the template @param {string} options.oTag set a one-off opening tag TODO oTag cTag | [
"to",
"compile",
"a",
"template",
"string",
"to",
"callable",
"render"
] | 65483f3c6c001d75de3f5c240d999351f73d1fc1 | https://github.com/jias/eoraptor.js/blob/65483f3c6c001d75de3f5c240d999351f73d1fc1/build/eoraptor.js#L100-L135 | train |
jias/eoraptor.js | build/eoraptor.js | isOTag | function isOTag (str, oTag, index) {
var l = oTag.length, s = str.substr(index, l), sign = str.charAt(index+l);
// NOTE 要保证sign有值 如果当前的index已经是字符串尾部 如'foo{{' sign为空
if (oTag === s && sign && SIGN.indexOf(sign) > -1) {
return {
str: s + sign,
index: index,
// sign:... | javascript | function isOTag (str, oTag, index) {
var l = oTag.length, s = str.substr(index, l), sign = str.charAt(index+l);
// NOTE 要保证sign有值 如果当前的index已经是字符串尾部 如'foo{{' sign为空
if (oTag === s && sign && SIGN.indexOf(sign) > -1) {
return {
str: s + sign,
index: index,
// sign:... | [
"function",
"isOTag",
"(",
"str",
",",
"oTag",
",",
"index",
")",
"{",
"var",
"l",
"=",
"oTag",
".",
"length",
",",
"s",
"=",
"str",
".",
"substr",
"(",
"index",
",",
"l",
")",
",",
"sign",
"=",
"str",
".",
"charAt",
"(",
"index",
"+",
"l",
"... | Is it the first char of an opening tag? | [
"Is",
"it",
"the",
"first",
"char",
"of",
"an",
"opening",
"tag?"
] | 65483f3c6c001d75de3f5c240d999351f73d1fc1 | https://github.com/jias/eoraptor.js/blob/65483f3c6c001d75de3f5c240d999351f73d1fc1/build/eoraptor.js#L238-L252 | train |
jias/eoraptor.js | build/eoraptor.js | isCTag | function isCTag (str, cTag, index) {
var l = cTag.length, s = str.substr(index, l);
if (cTag === s) {
return {
str: s,
index: index,
type: 1,
jump: l - 1
};
}
} | javascript | function isCTag (str, cTag, index) {
var l = cTag.length, s = str.substr(index, l);
if (cTag === s) {
return {
str: s,
index: index,
type: 1,
jump: l - 1
};
}
} | [
"function",
"isCTag",
"(",
"str",
",",
"cTag",
",",
"index",
")",
"{",
"var",
"l",
"=",
"cTag",
".",
"length",
",",
"s",
"=",
"str",
".",
"substr",
"(",
"index",
",",
"l",
")",
";",
"if",
"(",
"cTag",
"===",
"s",
")",
"{",
"return",
"{",
"str... | Is it the first char of a closing tag? | [
"Is",
"it",
"the",
"first",
"char",
"of",
"a",
"closing",
"tag?"
] | 65483f3c6c001d75de3f5c240d999351f73d1fc1 | https://github.com/jias/eoraptor.js/blob/65483f3c6c001d75de3f5c240d999351f73d1fc1/build/eoraptor.js#L255-L265 | train |
jias/eoraptor.js | build/eoraptor.js | isOSB | function isOSB (str, index) {
var quote = str.charAt(index+1);
if (quote === DQ || quote === SQ) {
return {
str: LSB + quote,
index: index,
quote: quote,
jump: 1
};
}
} | javascript | function isOSB (str, index) {
var quote = str.charAt(index+1);
if (quote === DQ || quote === SQ) {
return {
str: LSB + quote,
index: index,
quote: quote,
jump: 1
};
}
} | [
"function",
"isOSB",
"(",
"str",
",",
"index",
")",
"{",
"var",
"quote",
"=",
"str",
".",
"charAt",
"(",
"index",
"+",
"1",
")",
";",
"if",
"(",
"quote",
"===",
"DQ",
"||",
"quote",
"===",
"SQ",
")",
"{",
"return",
"{",
"str",
":",
"LSB",
"+",
... | Is it the first char of an opening square bracket expression? | [
"Is",
"it",
"the",
"first",
"char",
"of",
"an",
"opening",
"square",
"bracket",
"expression?"
] | 65483f3c6c001d75de3f5c240d999351f73d1fc1 | https://github.com/jias/eoraptor.js/blob/65483f3c6c001d75de3f5c240d999351f73d1fc1/build/eoraptor.js#L272-L282 | train |
jias/eoraptor.js | build/eoraptor.js | isCSB | function isCSB (str, index, quote) {
if (str.charAt(index+1) === RSB) {
return {
str: quote + RSB,
index: index,
quote: quote,
jump: 1
};
}
} | javascript | function isCSB (str, index, quote) {
if (str.charAt(index+1) === RSB) {
return {
str: quote + RSB,
index: index,
quote: quote,
jump: 1
};
}
} | [
"function",
"isCSB",
"(",
"str",
",",
"index",
",",
"quote",
")",
"{",
"if",
"(",
"str",
".",
"charAt",
"(",
"index",
"+",
"1",
")",
"===",
"RSB",
")",
"{",
"return",
"{",
"str",
":",
"quote",
"+",
"RSB",
",",
"index",
":",
"index",
",",
"quote... | Is it the first char of a closing square bracket expression? | [
"Is",
"it",
"the",
"first",
"char",
"of",
"a",
"closing",
"square",
"bracket",
"expression?"
] | 65483f3c6c001d75de3f5c240d999351f73d1fc1 | https://github.com/jias/eoraptor.js/blob/65483f3c6c001d75de3f5c240d999351f73d1fc1/build/eoraptor.js#L285-L294 | train |
melvincarvalho/rdf-shell | lib/ws.js | ws | function ws(argv, callback) {
if (!argv[2]) {
console.error("url is required");
console.error("Usage : ws <url>");
process.exit(-1);
}
var uri = argv[2];
var updatesVia = 'wss://' + uri.split('/')[2] + '/';
var s;
var connect = function(){
s = new wss(updatesVia, {
origin: 'http://we... | javascript | function ws(argv, callback) {
if (!argv[2]) {
console.error("url is required");
console.error("Usage : ws <url>");
process.exit(-1);
}
var uri = argv[2];
var updatesVia = 'wss://' + uri.split('/')[2] + '/';
var s;
var connect = function(){
s = new wss(updatesVia, {
origin: 'http://we... | [
"function",
"ws",
"(",
"argv",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"argv",
"[",
"2",
"]",
")",
"{",
"console",
".",
"error",
"(",
"\"url is required\"",
")",
";",
"console",
".",
"error",
"(",
"\"Usage : ws <url>\"",
")",
";",
"process",
".",
... | ws runs a websocket against a URI
@param {String} argv[2] url
@callback {bin~cb} callback | [
"ws",
"runs",
"a",
"websocket",
"against",
"a",
"URI"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/lib/ws.js#L18-L59 | train |
melvincarvalho/rdf-shell | lib/ws.js | bin | function bin(argv) {
ws(argv, function(err, res) {
if (err) {
console.err(err);
} else {
console.log(res);
}
});
} | javascript | function bin(argv) {
ws(argv, function(err, res) {
if (err) {
console.err(err);
} else {
console.log(res);
}
});
} | [
"function",
"bin",
"(",
"argv",
")",
"{",
"ws",
"(",
"argv",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"err",
"(",
"err",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"res",
")",... | ws as a command
@param {String} argv[2] login
@callback {bin~cb} callback | [
"ws",
"as",
"a",
"command"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/lib/ws.js#L68-L76 | train |
Ma3Route/node-sdk | example/init.js | init | function init() {
/**
* Get API key and secret.
*/
var auth = utils.getAuth();
/**
* Set up the SDK.
*/
sdk.utils.setup({
key: auth.key,
secret: auth.secret,
});
return {
out: out,
sdk: sdk,
};
} | javascript | function init() {
/**
* Get API key and secret.
*/
var auth = utils.getAuth();
/**
* Set up the SDK.
*/
sdk.utils.setup({
key: auth.key,
secret: auth.secret,
});
return {
out: out,
sdk: sdk,
};
} | [
"function",
"init",
"(",
")",
"{",
"/**\n * Get API key and secret.\n */",
"var",
"auth",
"=",
"utils",
".",
"getAuth",
"(",
")",
";",
"/**\n * Set up the SDK.\n */",
"sdk",
".",
"utils",
".",
"setup",
"(",
"{",
"key",
":",
"auth",
".",
"key",
",... | Initialize. This has placed in this separate file so as to
avoid duplicate code all over.
It simply does the following:
1. `require()` the modules we will be using frequently (already done above)
2. get API key and secret
3. setup the SDK so we can use it immediately
4. return an object containing modules from (1) abo... | [
"Initialize",
".",
"This",
"has",
"placed",
"in",
"this",
"separate",
"file",
"so",
"as",
"to",
"avoid",
"duplicate",
"code",
"all",
"over",
"."
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/example/init.js#L23-L41 | train |
bionikspoon/unipath | src/index.js | unipath | function unipath(...bases) {
return partial;
/**
* Resolve base with paths.
*
* @param {...string} paths - Paths to join to base
* @returns {string} Resolved path
*/
function partial(...paths) {
const baseList = bases.length ? bases : [ '.' ];
const pathList = paths.length ? paths : [ '.' ... | javascript | function unipath(...bases) {
return partial;
/**
* Resolve base with paths.
*
* @param {...string} paths - Paths to join to base
* @returns {string} Resolved path
*/
function partial(...paths) {
const baseList = bases.length ? bases : [ '.' ];
const pathList = paths.length ? paths : [ '.' ... | [
"function",
"unipath",
"(",
"...",
"bases",
")",
"{",
"return",
"partial",
";",
"/**\n * Resolve base with paths.\n *\n * @param {...string} paths - Paths to join to base\n * @returns {string} Resolved path\n */",
"function",
"partial",
"(",
"...",
"paths",
")",
"{",
"c... | Create a path.join partial.
@param {...string} bases - Base paths
@returns {partial} Path join partial | [
"Create",
"a",
"path",
".",
"join",
"partial",
"."
] | 91d196b902f66f85ffb8b9a37ae9bb51b86507e7 | https://github.com/bionikspoon/unipath/blob/91d196b902f66f85ffb8b9a37ae9bb51b86507e7/src/index.js#L11-L26 | train |
gtriggiano/dnsmq-messagebus | src/MasterBroker.js | startHeartbeats | function startHeartbeats () {
_isMaster = true
if (_hearbeatInterval) return
debug('starting heartbeats')
_sendHeartbeat()
_hearbeatInterval = setInterval(_sendHeartbeat, HEARTBEAT_INTERVAL)
} | javascript | function startHeartbeats () {
_isMaster = true
if (_hearbeatInterval) return
debug('starting heartbeats')
_sendHeartbeat()
_hearbeatInterval = setInterval(_sendHeartbeat, HEARTBEAT_INTERVAL)
} | [
"function",
"startHeartbeats",
"(",
")",
"{",
"_isMaster",
"=",
"true",
"if",
"(",
"_hearbeatInterval",
")",
"return",
"debug",
"(",
"'starting heartbeats'",
")",
"_sendHeartbeat",
"(",
")",
"_hearbeatInterval",
"=",
"setInterval",
"(",
"_sendHeartbeat",
",",
"HEA... | starts the emission of heartbeats at regular intervals | [
"starts",
"the",
"emission",
"of",
"heartbeats",
"at",
"regular",
"intervals"
] | ab935cae537f8a7e61a6ed6fba247661281c9374 | https://github.com/gtriggiano/dnsmq-messagebus/blob/ab935cae537f8a7e61a6ed6fba247661281c9374/src/MasterBroker.js#L114-L120 | train |
digiaonline/generator-nord-backbone | app/templates/_Gruntfile.js | findBowerMainFiles | function findBowerMainFiles(componentsPath) {
var files = [];
fs.readdirSync(componentsPath).filter(function (file) {
return fs.statSync(componentsPath + '/' + file).isDirectory();
}).forEach(function (packageName) {
var bowerJsonPath = componentsPath + '/' + packageName... | javascript | function findBowerMainFiles(componentsPath) {
var files = [];
fs.readdirSync(componentsPath).filter(function (file) {
return fs.statSync(componentsPath + '/' + file).isDirectory();
}).forEach(function (packageName) {
var bowerJsonPath = componentsPath + '/' + packageName... | [
"function",
"findBowerMainFiles",
"(",
"componentsPath",
")",
"{",
"var",
"files",
"=",
"[",
"]",
";",
"fs",
".",
"readdirSync",
"(",
"componentsPath",
")",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"return",
"fs",
".",
"statSync",
"(",
"com... | Parses the given components path and returns a list with the main file for each bower dependency.
@param {string} componentsPath path to Bower components
@returns {Array} list of files | [
"Parses",
"the",
"given",
"components",
"path",
"and",
"returns",
"a",
"list",
"with",
"the",
"main",
"file",
"for",
"each",
"bower",
"dependency",
"."
] | bc962e16b6354c7a4034ce09cf4030b9d300202e | https://github.com/digiaonline/generator-nord-backbone/blob/bc962e16b6354c7a4034ce09cf4030b9d300202e/app/templates/_Gruntfile.js#L10-L24 | train |
brianloveswords/gogo | lib/base.js | extraction | function extraction(o) {
return _.map(o, function (spec, field) {
var fn = _.extract(spec, ['mutators', direction]) || _.identity;
return [field, fn];
});
} | javascript | function extraction(o) {
return _.map(o, function (spec, field) {
var fn = _.extract(spec, ['mutators', direction]) || _.identity;
return [field, fn];
});
} | [
"function",
"extraction",
"(",
"o",
")",
"{",
"return",
"_",
".",
"map",
"(",
"o",
",",
"function",
"(",
"spec",
",",
"field",
")",
"{",
"var",
"fn",
"=",
"_",
".",
"extract",
"(",
"spec",
",",
"[",
"'mutators'",
",",
"direction",
"]",
")",
"||",... | make a zipped array of field, mutator | [
"make",
"a",
"zipped",
"array",
"of",
"field",
"mutator"
] | f17ee794e0439ed961907f52b91bcb74dcca351a | https://github.com/brianloveswords/gogo/blob/f17ee794e0439ed961907f52b91bcb74dcca351a/lib/base.js#L97-L102 | train |
brianloveswords/gogo | lib/base.js | cleanup | function cleanup(a) {
return _.filter(a, function (a) {
var field = a[0];
return attr[field];
});
} | javascript | function cleanup(a) {
return _.filter(a, function (a) {
var field = a[0];
return attr[field];
});
} | [
"function",
"cleanup",
"(",
"a",
")",
"{",
"return",
"_",
".",
"filter",
"(",
"a",
",",
"function",
"(",
"a",
")",
"{",
"var",
"field",
"=",
"a",
"[",
"0",
"]",
";",
"return",
"attr",
"[",
"field",
"]",
";",
"}",
")",
";",
"}"
] | drop all fields that aren't found in the attributes array | [
"drop",
"all",
"fields",
"that",
"aren",
"t",
"found",
"in",
"the",
"attributes",
"array"
] | f17ee794e0439ed961907f52b91bcb74dcca351a | https://github.com/brianloveswords/gogo/blob/f17ee794e0439ed961907f52b91bcb74dcca351a/lib/base.js#L105-L110 | train |
brianloveswords/gogo | lib/base.js | getMutations | function getMutations(spec, attr) {
var fns = compose(extraction, cleanup, stitch)(spec);
return _.callmap(fns, attr);
} | javascript | function getMutations(spec, attr) {
var fns = compose(extraction, cleanup, stitch)(spec);
return _.callmap(fns, attr);
} | [
"function",
"getMutations",
"(",
"spec",
",",
"attr",
")",
"{",
"var",
"fns",
"=",
"compose",
"(",
"extraction",
",",
"cleanup",
",",
"stitch",
")",
"(",
"spec",
")",
";",
"return",
"_",
".",
"callmap",
"(",
"fns",
",",
"attr",
")",
";",
"}"
] | call of the functions in the mutators fn object with the values of the attributes object | [
"call",
"of",
"the",
"functions",
"in",
"the",
"mutators",
"fn",
"object",
"with",
"the",
"values",
"of",
"the",
"attributes",
"object"
] | f17ee794e0439ed961907f52b91bcb74dcca351a | https://github.com/brianloveswords/gogo/blob/f17ee794e0439ed961907f52b91bcb74dcca351a/lib/base.js#L117-L120 | train |
muttr/libmuttr | lib/connection.js | Connection | function Connection(options) {
if (!(this instanceof Connection)) {
return new Connection(options);
}
events.EventEmitter.call(this);
this.options = merge(Object.create(Connection.DEFAULTS), options);
this._log = new kademlia.Logger(this.options.logLevel);
this._natClient = nat.createClient();
} | javascript | function Connection(options) {
if (!(this instanceof Connection)) {
return new Connection(options);
}
events.EventEmitter.call(this);
this.options = merge(Object.create(Connection.DEFAULTS), options);
this._log = new kademlia.Logger(this.options.logLevel);
this._natClient = nat.createClient();
} | [
"function",
"Connection",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Connection",
")",
")",
"{",
"return",
"new",
"Connection",
"(",
"options",
")",
";",
"}",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",... | Creates a connection the the Muttr DHT
@constructor
@param {object} options
@param {string} options.address
@param {number} options.port
@param {array} options.seeds
@param {object} options.seeds[]
@param {string} options.seeds[].address
@param {number} options.seeds[].port
@param {object} options.stor... | [
"Creates",
"a",
"connection",
"the",
"the",
"Muttr",
"DHT"
] | 2e4fda9cb2b47b8febe30585f54196d39d79e2e5 | https://github.com/muttr/libmuttr/blob/2e4fda9cb2b47b8febe30585f54196d39d79e2e5/lib/connection.js#L60-L71 | train |
redisjs/jsr-validate | lib/validators/auth.js | auth | function auth(cmd, args, info) {
var pass = args[0];
if(pass instanceof Buffer) {
pass = pass.toString();
}
if(!info.conf.requirepass) {
throw AuthNotSet;
}else if(pass !== info.conf.requirepass) {
throw InvalidPassword;
}
return true;
} | javascript | function auth(cmd, args, info) {
var pass = args[0];
if(pass instanceof Buffer) {
pass = pass.toString();
}
if(!info.conf.requirepass) {
throw AuthNotSet;
}else if(pass !== info.conf.requirepass) {
throw InvalidPassword;
}
return true;
} | [
"function",
"auth",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"var",
"pass",
"=",
"args",
"[",
"0",
"]",
";",
"if",
"(",
"pass",
"instanceof",
"Buffer",
")",
"{",
"pass",
"=",
"pass",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"!",
... | Authentication validation.
@param cmd The command name - always AUTH.
@param args The command arguments.
@param info The server information. | [
"Authentication",
"validation",
"."
] | 2e0dddafb32c019ef9293a35b96cdd78dd8e4ae5 | https://github.com/redisjs/jsr-validate/blob/2e0dddafb32c019ef9293a35b96cdd78dd8e4ae5/lib/validators/auth.js#L13-L24 | train |
jurca/idb-entity | es2015/equals.js | equals | function equals(value1, value2, traversedValues) {
if (!(value1 instanceof Object)) {
return value1 === value2
}
for (let wrappedType of WRAPPED_TYPES) {
if (value1 instanceof wrappedType) {
return (value2 instanceof wrappedType) &&
(value1.valueOf() === value2.valueOf())
}
}
... | javascript | function equals(value1, value2, traversedValues) {
if (!(value1 instanceof Object)) {
return value1 === value2
}
for (let wrappedType of WRAPPED_TYPES) {
if (value1 instanceof wrappedType) {
return (value2 instanceof wrappedType) &&
(value1.valueOf() === value2.valueOf())
}
}
... | [
"function",
"equals",
"(",
"value1",
",",
"value2",
",",
"traversedValues",
")",
"{",
"if",
"(",
"!",
"(",
"value1",
"instanceof",
"Object",
")",
")",
"{",
"return",
"value1",
"===",
"value2",
"}",
"for",
"(",
"let",
"wrappedType",
"of",
"WRAPPED_TYPES",
... | Compares the provided values to determine whether they are equal.
@param {*} value1 The 1st value to compare.
@param {*} value2 The 2nd value to compare.
@param {Map<Object, Object>} traversedValues A map of non-primitive values
traversed in the first structure to their equal counterparts in the
second structure.
@ret... | [
"Compares",
"the",
"provided",
"values",
"to",
"determine",
"whether",
"they",
"are",
"equal",
"."
] | 361ef8482872d9fc9a0d83b86970d49d391dc276 | https://github.com/jurca/idb-entity/blob/361ef8482872d9fc9a0d83b86970d49d391dc276/es2015/equals.js#L47-L118 | train |
jurca/idb-entity | es2015/equals.js | objectEquals | function objectEquals(object1, object2, traversedValues) {
let keys1 = Object.keys(object1)
let keys2 = Object.keys(object2)
return structureEquals(
object1,
object2,
keys1,
keys2,
(object, key) => object[key],
traversedValues
)
} | javascript | function objectEquals(object1, object2, traversedValues) {
let keys1 = Object.keys(object1)
let keys2 = Object.keys(object2)
return structureEquals(
object1,
object2,
keys1,
keys2,
(object, key) => object[key],
traversedValues
)
} | [
"function",
"objectEquals",
"(",
"object1",
",",
"object2",
",",
"traversedValues",
")",
"{",
"let",
"keys1",
"=",
"Object",
".",
"keys",
"(",
"object1",
")",
"let",
"keys2",
"=",
"Object",
".",
"keys",
"(",
"object2",
")",
"return",
"structureEquals",
"("... | Compares the two provided plain objects.
@param {Object<string, *>} object1 The 1st object to compare.
@param {Object<string, *>} object2 The 2nd object to compare.
@param {Map<Object, Object>} traversedValues A map of non-primitive values
traversed in the first structure to their equal counterparts in the
second stru... | [
"Compares",
"the",
"two",
"provided",
"plain",
"objects",
"."
] | 361ef8482872d9fc9a0d83b86970d49d391dc276 | https://github.com/jurca/idb-entity/blob/361ef8482872d9fc9a0d83b86970d49d391dc276/es2015/equals.js#L130-L142 | train |
jurca/idb-entity | es2015/equals.js | setEquals | function setEquals(set1, set2, traversedValues) {
if (set1.size !== set2.size) {
return false
}
return structureEquals(
set1,
set2,
iteratorToArray(set1.values()),
iteratorToArray(set2.values()),
() => undefined,
traversedValues
)
} | javascript | function setEquals(set1, set2, traversedValues) {
if (set1.size !== set2.size) {
return false
}
return structureEquals(
set1,
set2,
iteratorToArray(set1.values()),
iteratorToArray(set2.values()),
() => undefined,
traversedValues
)
} | [
"function",
"setEquals",
"(",
"set1",
",",
"set2",
",",
"traversedValues",
")",
"{",
"if",
"(",
"set1",
".",
"size",
"!==",
"set2",
".",
"size",
")",
"{",
"return",
"false",
"}",
"return",
"structureEquals",
"(",
"set1",
",",
"set2",
",",
"iteratorToArra... | Compares the two provided sets.
@param {Set<*>} set1 The 1st set to compare.
@param {Set<*>} set2 The 2nd set to compare.
@param {Map<Object, Object>} traversedValues A map of non-primitive values
traversed in the first structure to their equal counterparts in the
second structure.
@return {boolean} {@code true} if th... | [
"Compares",
"the",
"two",
"provided",
"sets",
"."
] | 361ef8482872d9fc9a0d83b86970d49d391dc276 | https://github.com/jurca/idb-entity/blob/361ef8482872d9fc9a0d83b86970d49d391dc276/es2015/equals.js#L154-L167 | train |
jurca/idb-entity | es2015/equals.js | mapEquals | function mapEquals(map1, map2, traversedValues) {
if (map1.size !== map2.size) {
return false
}
return structureEquals(
map1,
map2,
iteratorToArray(map1.keys()),
iteratorToArray(map2.keys()),
(map, key) => map.get(key),
traversedValues
)
} | javascript | function mapEquals(map1, map2, traversedValues) {
if (map1.size !== map2.size) {
return false
}
return structureEquals(
map1,
map2,
iteratorToArray(map1.keys()),
iteratorToArray(map2.keys()),
(map, key) => map.get(key),
traversedValues
)
} | [
"function",
"mapEquals",
"(",
"map1",
",",
"map2",
",",
"traversedValues",
")",
"{",
"if",
"(",
"map1",
".",
"size",
"!==",
"map2",
".",
"size",
")",
"{",
"return",
"false",
"}",
"return",
"structureEquals",
"(",
"map1",
",",
"map2",
",",
"iteratorToArra... | Compares the two provided maps.
@param {Map<*, *>} map1 The 1st map to compare.
@param {Map<*, *>} map2 The 2nd map to compare.
@param {Map<Object, Object>} traversedValues A map of non-primitive values
traversed in the first structure to their equal counterparts in the
second structure.
@return {boolean} {@code true}... | [
"Compares",
"the",
"two",
"provided",
"maps",
"."
] | 361ef8482872d9fc9a0d83b86970d49d391dc276 | https://github.com/jurca/idb-entity/blob/361ef8482872d9fc9a0d83b86970d49d391dc276/es2015/equals.js#L179-L192 | train |
jurca/idb-entity | es2015/equals.js | arrayEquals | function arrayEquals(array1, array2, traversedValues) {
if (array1.length !== array2.length) {
return false
}
return structureEquals(
array1,
array2,
iteratorToArray(array1.keys()),
iteratorToArray(array2.keys()),
(array, key) => array[key],
traversedValues
)
} | javascript | function arrayEquals(array1, array2, traversedValues) {
if (array1.length !== array2.length) {
return false
}
return structureEquals(
array1,
array2,
iteratorToArray(array1.keys()),
iteratorToArray(array2.keys()),
(array, key) => array[key],
traversedValues
)
} | [
"function",
"arrayEquals",
"(",
"array1",
",",
"array2",
",",
"traversedValues",
")",
"{",
"if",
"(",
"array1",
".",
"length",
"!==",
"array2",
".",
"length",
")",
"{",
"return",
"false",
"}",
"return",
"structureEquals",
"(",
"array1",
",",
"array2",
",",... | Compares the two provided arrays.
@param {*[]} array1 The 1st array to compare.
@param {*[]} array2 The 2nd array to compare.
@param {Map<Object, Object>} traversedValues A map of non-primitive values
traversed in the first structure to their equal counterparts in the
second structure.
@return {boolean} {@code true} i... | [
"Compares",
"the",
"two",
"provided",
"arrays",
"."
] | 361ef8482872d9fc9a0d83b86970d49d391dc276 | https://github.com/jurca/idb-entity/blob/361ef8482872d9fc9a0d83b86970d49d391dc276/es2015/equals.js#L204-L217 | train |
jurca/idb-entity | es2015/equals.js | structureEquals | function structureEquals(structure1, structure2, keys1, keys2, getter,
traversedValues) {
if (keys1.length !== keys2.length) {
return false
}
traversedValues.set(structure1, structure2)
for (let i = keys1.length; i--;) {
let key1 = keys1[i]
let key2 = keys2[i]
if ((key1 instan... | javascript | function structureEquals(structure1, structure2, keys1, keys2, getter,
traversedValues) {
if (keys1.length !== keys2.length) {
return false
}
traversedValues.set(structure1, structure2)
for (let i = keys1.length; i--;) {
let key1 = keys1[i]
let key2 = keys2[i]
if ((key1 instan... | [
"function",
"structureEquals",
"(",
"structure1",
",",
"structure2",
",",
"keys1",
",",
"keys2",
",",
"getter",
",",
"traversedValues",
")",
"{",
"if",
"(",
"keys1",
".",
"length",
"!==",
"keys2",
".",
"length",
")",
"{",
"return",
"false",
"}",
"traversed... | Performs a structured comparison of two structures, determining their
equality.
@param {Object} structure1 The first structure to compare.
@param {Object} structure2 The second structure to compare.
@param {*[]} keys1 The keys of the properties to compare in the first
structure.
@param {*[]} keys2 The keys of the prop... | [
"Performs",
"a",
"structured",
"comparison",
"of",
"two",
"structures",
"determining",
"their",
"equality",
"."
] | 361ef8482872d9fc9a0d83b86970d49d391dc276 | https://github.com/jurca/idb-entity/blob/361ef8482872d9fc9a0d83b86970d49d391dc276/es2015/equals.js#L238-L287 | train |
jurca/idb-entity | es2015/equals.js | iteratorToArray | function iteratorToArray(iterator) {
let elements = []
for (let element of iterator) {
elements.push(element)
}
return elements
} | javascript | function iteratorToArray(iterator) {
let elements = []
for (let element of iterator) {
elements.push(element)
}
return elements
} | [
"function",
"iteratorToArray",
"(",
"iterator",
")",
"{",
"let",
"elements",
"=",
"[",
"]",
"for",
"(",
"let",
"element",
"of",
"iterator",
")",
"{",
"elements",
".",
"push",
"(",
"element",
")",
"}",
"return",
"elements",
"}"
] | Traverses the provided finite iterator or iterable object and returns an
array of generated values.
@param {({[Symbol.iterator]: function(): {next: function(): {value: *, done: boolean}}}|{next: function(): {value: *, done: boolean}})} iterator
The iterator or iterable object.
@return {*[]} The elements generated by t... | [
"Traverses",
"the",
"provided",
"finite",
"iterator",
"or",
"iterable",
"object",
"and",
"returns",
"an",
"array",
"of",
"generated",
"values",
"."
] | 361ef8482872d9fc9a0d83b86970d49d391dc276 | https://github.com/jurca/idb-entity/blob/361ef8482872d9fc9a0d83b86970d49d391dc276/es2015/equals.js#L297-L305 | train |
fosrias/apiql-express | lib/api.js | jsonDescription | function jsonDescription(format, description) {
switch (format) {
case 'application/openapi+json':
if (typeof description == object) {
return description;
} else {
throw new Error(`application/openapi+json description ${description} is not an object`);
}
case 'application/ope... | javascript | function jsonDescription(format, description) {
switch (format) {
case 'application/openapi+json':
if (typeof description == object) {
return description;
} else {
throw new Error(`application/openapi+json description ${description} is not an object`);
}
case 'application/ope... | [
"function",
"jsonDescription",
"(",
"format",
",",
"description",
")",
"{",
"switch",
"(",
"format",
")",
"{",
"case",
"'application/openapi+json'",
":",
"if",
"(",
"typeof",
"description",
"==",
"object",
")",
"{",
"return",
"description",
";",
"}",
"else",
... | private helper methods | [
"private",
"helper",
"methods"
] | 1bbfc5049f036d6311ade6c7486c63404f59af43 | https://github.com/fosrias/apiql-express/blob/1bbfc5049f036d6311ade6c7486c63404f59af43/lib/api.js#L119-L132 | train |
torworx/well | well.js | well | function well(promiseOrValue, onFulfilled, onRejected, onProgress) {
// Get a trusted promise for the input promiseOrValue, and then
// register promise handlers
return resolve(promiseOrValue).then(onFulfilled, onRejected, onProgress);
} | javascript | function well(promiseOrValue, onFulfilled, onRejected, onProgress) {
// Get a trusted promise for the input promiseOrValue, and then
// register promise handlers
return resolve(promiseOrValue).then(onFulfilled, onRejected, onProgress);
} | [
"function",
"well",
"(",
"promiseOrValue",
",",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
")",
"{",
"// Get a trusted promise for the input promiseOrValue, and then",
"// register promise handlers",
"return",
"resolve",
"(",
"promiseOrValue",
")",
".",
"then",
"(... | Determine if a thing is a promise
Register an observer for a promise or immediate value.
@param {*} promiseOrValue
@param {function?} [onFulfilled] callback to be called when promiseOrValue is
successfully fulfilled. If promiseOrValue is an immediate value, callback
will be invoked immediately.
@param {function?} [o... | [
"Determine",
"if",
"a",
"thing",
"is",
"a",
"promise",
"Register",
"an",
"observer",
"for",
"a",
"promise",
"or",
"immediate",
"value",
"."
] | 45a1724a0a4192628c80b3c4ae541d6de28ac7da | https://github.com/torworx/well/blob/45a1724a0a4192628c80b3c4ae541d6de28ac7da/well.js#L51-L55 | train |
torworx/well | well.js | chain | function chain(promiseOrValue, resolver, resolveValue) {
var useResolveValue = arguments.length > 2;
return well(promiseOrValue,
function (val) {
val = useResolveValue ? resolveValue : val;
resolver.resolve(val);
return... | javascript | function chain(promiseOrValue, resolver, resolveValue) {
var useResolveValue = arguments.length > 2;
return well(promiseOrValue,
function (val) {
val = useResolveValue ? resolveValue : val;
resolver.resolve(val);
return... | [
"function",
"chain",
"(",
"promiseOrValue",
",",
"resolver",
",",
"resolveValue",
")",
"{",
"var",
"useResolveValue",
"=",
"arguments",
".",
"length",
">",
"2",
";",
"return",
"well",
"(",
"promiseOrValue",
",",
"function",
"(",
"val",
")",
"{",
"val",
"="... | Ensure that resolution of promiseOrValue will trigger resolver with the
value or reason of promiseOrValue, or instead with resolveValue if it is provided.
@param promiseOrValue
@param {Object} resolver
@param {function} resolver.resolve
@param {function} resolver.reject
@param {*} [resolveValue]
@returns {Promise} | [
"Ensure",
"that",
"resolution",
"of",
"promiseOrValue",
"will",
"trigger",
"resolver",
"with",
"the",
"value",
"or",
"reason",
"of",
"promiseOrValue",
"or",
"instead",
"with",
"resolveValue",
"if",
"it",
"is",
"provided",
"."
] | 45a1724a0a4192628c80b3c4ae541d6de28ac7da | https://github.com/torworx/well/blob/45a1724a0a4192628c80b3c4ae541d6de28ac7da/well.js#L771-L789 | train |
torworx/well | well.js | processQueue | function processQueue(queue, value) {
if (!queue || queue.length === 0) return;
var handler, i = 0;
while (handler = queue[i++]) {
handler(value);
}
} | javascript | function processQueue(queue, value) {
if (!queue || queue.length === 0) return;
var handler, i = 0;
while (handler = queue[i++]) {
handler(value);
}
} | [
"function",
"processQueue",
"(",
"queue",
",",
"value",
")",
"{",
"if",
"(",
"!",
"queue",
"||",
"queue",
".",
"length",
"===",
"0",
")",
"return",
";",
"var",
"handler",
",",
"i",
"=",
"0",
";",
"while",
"(",
"handler",
"=",
"queue",
"[",
"i",
"... | Utility functions
Apply all functions in queue to value
@param {Array} queue array of functions to execute
@param {*} value argument passed to each function | [
"Utility",
"functions",
"Apply",
"all",
"functions",
"in",
"queue",
"to",
"value"
] | 45a1724a0a4192628c80b3c4ae541d6de28ac7da | https://github.com/torworx/well/blob/45a1724a0a4192628c80b3c4ae541d6de28ac7da/well.js#L800-L807 | train |
torworx/well | well.js | checkCallbacks | function checkCallbacks(start, arrayOfCallbacks) {
// TODO: Promises/A+ update type checking and docs
var arg, i = arrayOfCallbacks.length;
while (i > start) {
arg = arrayOfCallbacks[--i];
if (arg != null && typeof arg != 'function') {
... | javascript | function checkCallbacks(start, arrayOfCallbacks) {
// TODO: Promises/A+ update type checking and docs
var arg, i = arrayOfCallbacks.length;
while (i > start) {
arg = arrayOfCallbacks[--i];
if (arg != null && typeof arg != 'function') {
... | [
"function",
"checkCallbacks",
"(",
"start",
",",
"arrayOfCallbacks",
")",
"{",
"// TODO: Promises/A+ update type checking and docs",
"var",
"arg",
",",
"i",
"=",
"arrayOfCallbacks",
".",
"length",
";",
"while",
"(",
"i",
">",
"start",
")",
"{",
"arg",
"=",
"arra... | Helper that checks arrayOfCallbacks to ensure that each element is either
a function, or null or undefined.
@private
@param {number} start index at which to start checking items in arrayOfCallbacks
@param {Array} arrayOfCallbacks array to check
@throws {Error} if any element of arrayOfCallbacks is something other than
... | [
"Helper",
"that",
"checks",
"arrayOfCallbacks",
"to",
"ensure",
"that",
"each",
"element",
"is",
"either",
"a",
"function",
"or",
"null",
"or",
"undefined",
"."
] | 45a1724a0a4192628c80b3c4ae541d6de28ac7da | https://github.com/torworx/well/blob/45a1724a0a4192628c80b3c4ae541d6de28ac7da/well.js#L818-L829 | train |
TJkrusinski/git-sha | index.js | git | function git(cb) {
which('git', function(err, data){
if (err) return cb(err, data);
child.exec('git rev-parse HEAD', cb);
});
} | javascript | function git(cb) {
which('git', function(err, data){
if (err) return cb(err, data);
child.exec('git rev-parse HEAD', cb);
});
} | [
"function",
"git",
"(",
"cb",
")",
"{",
"which",
"(",
"'git'",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
",",
"data",
")",
";",
"child",
".",
"exec",
"(",
"'git rev-parse HEAD'",
",",
"... | Get the git sha of the current commit
@param {Function} cb | [
"Get",
"the",
"git",
"sha",
"of",
"the",
"current",
"commit"
] | 12e7c077989beb40931144f0c8abba2165292ad5 | https://github.com/TJkrusinski/git-sha/blob/12e7c077989beb40931144f0c8abba2165292ad5/index.js#L18-L24 | train |
CyclicMaterials/util-combine-class-names | src/index.js | combineClassNames | function combineClassNames(...classNames) {
return classNames.map((value) => {
if (!value) {
return value;
}
return Array.isArray(value) ?
combineClassNames.apply(void 0, value) :
value;
}).join(` `).replace(/ +/g, ` `).trim();
} | javascript | function combineClassNames(...classNames) {
return classNames.map((value) => {
if (!value) {
return value;
}
return Array.isArray(value) ?
combineClassNames.apply(void 0, value) :
value;
}).join(` `).replace(/ +/g, ` `).trim();
} | [
"function",
"combineClassNames",
"(",
"...",
"classNames",
")",
"{",
"return",
"classNames",
".",
"map",
"(",
"(",
"value",
")",
"=>",
"{",
"if",
"(",
"!",
"value",
")",
"{",
"return",
"value",
";",
"}",
"return",
"Array",
".",
"isArray",
"(",
"value",... | Returns a trimmed string of the combined class names.
Class names can be either strings or arrays of strings.
Example:
combineClassNames(`my-class`, `my-other-class`, [`first`, `second`])
// `myclass my-other-class first second`
Arrays can be nested.
@param {Array|String} classNames Any number of arguments of class ... | [
"Returns",
"a",
"trimmed",
"string",
"of",
"the",
"combined",
"class",
"names",
".",
"Class",
"names",
"can",
"be",
"either",
"strings",
"or",
"arrays",
"of",
"strings",
"."
] | 9fc0473b9640830861cd8f4cefb78109c2bd6b81 | https://github.com/CyclicMaterials/util-combine-class-names/blob/9fc0473b9640830861cd8f4cefb78109c2bd6b81/src/index.js#L14-L24 | train |
campsi/campsi-service-auth | lib/handlers.js | initAuth | function initAuth (req, res, next) {
const params = {
session: false,
state: state.serialize(req),
scope: req.authProvider.scope
};
// noinspection JSUnresolvedFunction
passport.authenticate(
req.params.provider,
params
)(req, res, next);
} | javascript | function initAuth (req, res, next) {
const params = {
session: false,
state: state.serialize(req),
scope: req.authProvider.scope
};
// noinspection JSUnresolvedFunction
passport.authenticate(
req.params.provider,
params
)(req, res, next);
} | [
"function",
"initAuth",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"const",
"params",
"=",
"{",
"session",
":",
"false",
",",
"state",
":",
"state",
".",
"serialize",
"(",
"req",
")",
",",
"scope",
":",
"req",
".",
"authProvider",
".",
"scope",
... | Entry point of the authentification workflow.
There's no req.user yet.
@param req
@param res
@param next | [
"Entry",
"point",
"of",
"the",
"authentification",
"workflow",
".",
"There",
"s",
"no",
"req",
".",
"user",
"yet",
"."
] | f877626496de2288f9cfb50024accca2a88e179d | https://github.com/campsi/campsi-service-auth/blob/f877626496de2288f9cfb50024accca2a88e179d/lib/handlers.js#L124-L136 | train |
chunksnbits/grunt-template-render | tasks/template.js | function(filename) {
var filepath = options.cwd + filename;
var template = readTemplateFile({ src: [ filepath ] });
return grunt.template.process(template, options);
} | javascript | function(filename) {
var filepath = options.cwd + filename;
var template = readTemplateFile({ src: [ filepath ] });
return grunt.template.process(template, options);
} | [
"function",
"(",
"filename",
")",
"{",
"var",
"filepath",
"=",
"options",
".",
"cwd",
"+",
"filename",
";",
"var",
"template",
"=",
"readTemplateFile",
"(",
"{",
"src",
":",
"[",
"filepath",
"]",
"}",
")",
";",
"return",
"grunt",
".",
"template",
".",
... | Render helper method. Allows to render partials within template files. | [
"Render",
"helper",
"method",
".",
"Allows",
"to",
"render",
"partials",
"within",
"template",
"files",
"."
] | 0e3c0b3e646a2d37e13f30eaee7baa433435f2a7 | https://github.com/chunksnbits/grunt-template-render/blob/0e3c0b3e646a2d37e13f30eaee7baa433435f2a7/tasks/template.js#L42-L46 | train | |
chunksnbits/grunt-template-render | tasks/template.js | function(key) {
var translation = options.translations[key];
if (!translation) {
grunt.fail.warn('No translation found for key:', key);
}
return translation;
} | javascript | function(key) {
var translation = options.translations[key];
if (!translation) {
grunt.fail.warn('No translation found for key:', key);
}
return translation;
} | [
"function",
"(",
"key",
")",
"{",
"var",
"translation",
"=",
"options",
".",
"translations",
"[",
"key",
"]",
";",
"if",
"(",
"!",
"translation",
")",
"{",
"grunt",
".",
"fail",
".",
"warn",
"(",
"'No translation found for key:'",
",",
"key",
")",
";",
... | Translation helper method. Allows resolving keys within a translation file. | [
"Translation",
"helper",
"method",
".",
"Allows",
"resolving",
"keys",
"within",
"a",
"translation",
"file",
"."
] | 0e3c0b3e646a2d37e13f30eaee7baa433435f2a7 | https://github.com/chunksnbits/grunt-template-render/blob/0e3c0b3e646a2d37e13f30eaee7baa433435f2a7/tasks/template.js#L50-L57 | train | |
chunksnbits/grunt-template-render | tasks/template.js | function(options) {
var recurse = function(options) {
_.each(options, function(value, key) {
if (_.isFunction(value)) {
options[key] = value();
}
else if (_.isObject(value)) {
options[key] = recurse(value);
}
});
return options;
};
retur... | javascript | function(options) {
var recurse = function(options) {
_.each(options, function(value, key) {
if (_.isFunction(value)) {
options[key] = value();
}
else if (_.isObject(value)) {
options[key] = recurse(value);
}
});
return options;
};
retur... | [
"function",
"(",
"options",
")",
"{",
"var",
"recurse",
"=",
"function",
"(",
"options",
")",
"{",
"_",
".",
"each",
"(",
"options",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"value",
")",
")",
"... | Iterates recursively over all provided options executes them in case the option was provided as a function. | [
"Iterates",
"recursively",
"over",
"all",
"provided",
"options",
"executes",
"them",
"in",
"case",
"the",
"option",
"was",
"provided",
"as",
"a",
"function",
"."
] | 0e3c0b3e646a2d37e13f30eaee7baa433435f2a7 | https://github.com/chunksnbits/grunt-template-render/blob/0e3c0b3e646a2d37e13f30eaee7baa433435f2a7/tasks/template.js#L64-L78 | train | |
zzolo/github-collect | index.js | qG | function qG(options) {
var defer = q.defer();
var compiledData = [];
// Recursive call to paginate
function qGCall(pageLink) {
var methodCall;
// Callback
function callback(error, data) {
if (error) {
defer.reject(new Error(error));
}
else {
compiledData = compile... | javascript | function qG(options) {
var defer = q.defer();
var compiledData = [];
// Recursive call to paginate
function qGCall(pageLink) {
var methodCall;
// Callback
function callback(error, data) {
if (error) {
defer.reject(new Error(error));
}
else {
compiledData = compile... | [
"function",
"qG",
"(",
"options",
")",
"{",
"var",
"defer",
"=",
"q",
".",
"defer",
"(",
")",
";",
"var",
"compiledData",
"=",
"[",
"]",
";",
"// Recursive call to paginate",
"function",
"qGCall",
"(",
"pageLink",
")",
"{",
"var",
"methodCall",
";",
"// ... | Wrap github calls in to promises | [
"Wrap",
"github",
"calls",
"in",
"to",
"promises"
] | 8b28add17a3fbd6e18d7532bf5dc42d898cd625e | https://github.com/zzolo/github-collect/blob/8b28add17a3fbd6e18d7532bf5dc42d898cd625e/index.js#L28-L63 | train |
zzolo/github-collect | index.js | getObjects | function getObjects(user) {
var username = (_.isObject(user)) ? user.login : user;
var isOrg = (_.isObject(user) && user.type === 'Organization');
var defers = [];
// Get repos
defers.push(qG({
obj: 'repos', method: 'getFromUser', user: username,
sort: 'created', per_page: 100
}));
// Get gists
... | javascript | function getObjects(user) {
var username = (_.isObject(user)) ? user.login : user;
var isOrg = (_.isObject(user) && user.type === 'Organization');
var defers = [];
// Get repos
defers.push(qG({
obj: 'repos', method: 'getFromUser', user: username,
sort: 'created', per_page: 100
}));
// Get gists
... | [
"function",
"getObjects",
"(",
"user",
")",
"{",
"var",
"username",
"=",
"(",
"_",
".",
"isObject",
"(",
"user",
")",
")",
"?",
"user",
".",
"login",
":",
"user",
";",
"var",
"isOrg",
"=",
"(",
"_",
".",
"isObject",
"(",
"user",
")",
"&&",
"user"... | Get objects for a specific username | [
"Get",
"objects",
"for",
"a",
"specific",
"username"
] | 8b28add17a3fbd6e18d7532bf5dc42d898cd625e | https://github.com/zzolo/github-collect/blob/8b28add17a3fbd6e18d7532bf5dc42d898cd625e/index.js#L66-L92 | train |
zzolo/github-collect | index.js | get | function get(usernames, options) {
usernames = usernames || '';
usernames = (_.isArray(usernames)) ? usernames : usernames.split(',');
options = options || {};
var defers = [];
var collection = {};
_.each(usernames, function(u) {
var defer = q.defer();
u = u.toLowerCase();
if (u.length === 0) ... | javascript | function get(usernames, options) {
usernames = usernames || '';
usernames = (_.isArray(usernames)) ? usernames : usernames.split(',');
options = options || {};
var defers = [];
var collection = {};
_.each(usernames, function(u) {
var defer = q.defer();
u = u.toLowerCase();
if (u.length === 0) ... | [
"function",
"get",
"(",
"usernames",
",",
"options",
")",
"{",
"usernames",
"=",
"usernames",
"||",
"''",
";",
"usernames",
"=",
"(",
"_",
".",
"isArray",
"(",
"usernames",
")",
")",
"?",
"usernames",
":",
"usernames",
".",
"split",
"(",
"','",
")",
... | Get data from usernames, which can be an array of usernames or a string of usernames separated by commas. | [
"Get",
"data",
"from",
"usernames",
"which",
"can",
"be",
"an",
"array",
"of",
"usernames",
"or",
"a",
"string",
"of",
"usernames",
"separated",
"by",
"commas",
"."
] | 8b28add17a3fbd6e18d7532bf5dc42d898cd625e | https://github.com/zzolo/github-collect/blob/8b28add17a3fbd6e18d7532bf5dc42d898cd625e/index.js#L96-L134 | train |
Ma3Route/node-sdk | lib/poller.js | Poller | function Poller(getRequest, options) {
options = options || { };
events.EventEmitter.call(this);
this._pollerOptions = utils.getPollerOptions([utils.setup().poller, options]);
this._get = getRequest;
this._params = options.params || { };
this._lastreadId = this._params.lastreadId || null;
th... | javascript | function Poller(getRequest, options) {
options = options || { };
events.EventEmitter.call(this);
this._pollerOptions = utils.getPollerOptions([utils.setup().poller, options]);
this._get = getRequest;
this._params = options.params || { };
this._lastreadId = this._params.lastreadId || null;
th... | [
"function",
"Poller",
"(",
"getRequest",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_pollerOptions",
"=",
"utils",
".",
"getPollerOptions",
"(... | Poller Class. Inherits from events.EventEmitter. This poller
is designed in that it polls for new items automatically
without having you implement `lastreadId` logic.
@example
// create a new poller that keeps retrieiving traffic updates
var poller = new sdk.Poller(sdk.trafficUpdates.get, {
interval: 5000, // 5 second... | [
"Poller",
"Class",
".",
"Inherits",
"from",
"events",
".",
"EventEmitter",
".",
"This",
"poller",
"is",
"designed",
"in",
"that",
"it",
"polls",
"for",
"new",
"items",
"automatically",
"without",
"having",
"you",
"implement",
"lastreadId",
"logic",
"."
] | a2769d97d77d6f762d23e743bf4c749e2bad0d8a | https://github.com/Ma3Route/node-sdk/blob/a2769d97d77d6f762d23e743bf4c749e2bad0d8a/lib/poller.js#L65-L76 | train |
altshift/altshift | lib/altshift/promise.js | function (array) {
var self = this,
deferred = new Deferred(),
fulfilled = 0,
length,
results = [],
hasError = false;
if (!isArray(array)) {
array = slice.call(arguments);
}
l... | javascript | function (array) {
var self = this,
deferred = new Deferred(),
fulfilled = 0,
length,
results = [],
hasError = false;
if (!isArray(array)) {
array = slice.call(arguments);
}
l... | [
"function",
"(",
"array",
")",
"{",
"var",
"self",
"=",
"this",
",",
"deferred",
"=",
"new",
"Deferred",
"(",
")",
",",
"fulfilled",
"=",
"0",
",",
"length",
",",
"results",
"=",
"[",
"]",
",",
"hasError",
"=",
"false",
";",
"if",
"(",
"!",
"isAr... | Takes an array of promises and returns a promise that is fulfilled once all
the promises in the array are fulfilled
@param {Array} array The array of promises
@return {Promise} the promise that is fulfilled when all the array is fulfilled, resolved to the array of results | [
"Takes",
"an",
"array",
"of",
"promises",
"and",
"returns",
"a",
"promise",
"that",
"is",
"fulfilled",
"once",
"all",
"the",
"promises",
"in",
"the",
"array",
"are",
"fulfilled"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L120-L165 | train | |
altshift/altshift | lib/altshift/promise.js | function (array) {
var self = this,
deferred = new Deferred(),
fulfilled = false,
index, length,
onSuccess = function (value) {
if (!fulfilled) {
fulfilled = true;
deferred.emi... | javascript | function (array) {
var self = this,
deferred = new Deferred(),
fulfilled = false,
index, length,
onSuccess = function (value) {
if (!fulfilled) {
fulfilled = true;
deferred.emi... | [
"function",
"(",
"array",
")",
"{",
"var",
"self",
"=",
"this",
",",
"deferred",
"=",
"new",
"Deferred",
"(",
")",
",",
"fulfilled",
"=",
"false",
",",
"index",
",",
"length",
",",
"onSuccess",
"=",
"function",
"(",
"value",
")",
"{",
"if",
"(",
"!... | Takes an array of promises and returns a promise that is fulfilled when the
first promise in the array of promises is fulfilled
@param {Array} array The array of promises
@return {Promise} a promise that is fulfilled with the value of the value of first
promise to be fulfilled | [
"Takes",
"an",
"array",
"of",
"promises",
"and",
"returns",
"a",
"promise",
"that",
"is",
"fulfilled",
"when",
"the",
"first",
"promise",
"in",
"the",
"array",
"of",
"promises",
"is",
"fulfilled"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L175-L200 | train | |
altshift/altshift | lib/altshift/promise.js | function (value) {
var nextAction = array.shift();
if (nextAction) {
self.when(nextAction(value), next, deferred.reject);
} else {
deferred.emitSuccess(value);
}
} | javascript | function (value) {
var nextAction = array.shift();
if (nextAction) {
self.when(nextAction(value), next, deferred.reject);
} else {
deferred.emitSuccess(value);
}
} | [
"function",
"(",
"value",
")",
"{",
"var",
"nextAction",
"=",
"array",
".",
"shift",
"(",
")",
";",
"if",
"(",
"nextAction",
")",
"{",
"self",
".",
"when",
"(",
"nextAction",
"(",
"value",
")",
",",
"next",
",",
"deferred",
".",
"reject",
")",
";",... | make a copy | [
"make",
"a",
"copy"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L215-L222 | train | |
altshift/altshift | lib/altshift/promise.js | function (milliseconds) {
var deferred,
timer = setTimeout(function () {
deferred.emitSuccess();
}, milliseconds),
canceller = function () {
clearTimeout(timer);
};
deferred = new Deferred(can... | javascript | function (milliseconds) {
var deferred,
timer = setTimeout(function () {
deferred.emitSuccess();
}, milliseconds),
canceller = function () {
clearTimeout(timer);
};
deferred = new Deferred(can... | [
"function",
"(",
"milliseconds",
")",
"{",
"var",
"deferred",
",",
"timer",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"deferred",
".",
"emitSuccess",
"(",
")",
";",
"}",
",",
"milliseconds",
")",
",",
"canceller",
"=",
"function",
"(",
")",
"{... | Delays for a given amount of time and then fulfills the returned promise.
@param {int} milliseconds The number of milliseconds to delay
@return {Promise} A promise that will be fulfilled after the delay | [
"Delays",
"for",
"a",
"given",
"amount",
"of",
"time",
"and",
"then",
"fulfills",
"the",
"returned",
"promise",
"."
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L233-L243 | train | |
altshift/altshift | lib/altshift/promise.js | function (resolvedCallback, errorCallback, progressCallback) {
var returnDeferred = new Deferred(this._canceller), //new Deferred(this.getPromise().cancel)
listener = {
resolved : resolvedCallback,
error : errorCallback,
progress : progressCallback,
... | javascript | function (resolvedCallback, errorCallback, progressCallback) {
var returnDeferred = new Deferred(this._canceller), //new Deferred(this.getPromise().cancel)
listener = {
resolved : resolvedCallback,
error : errorCallback,
progress : progressCallback,
... | [
"function",
"(",
"resolvedCallback",
",",
"errorCallback",
",",
"progressCallback",
")",
"{",
"var",
"returnDeferred",
"=",
"new",
"Deferred",
"(",
"this",
".",
"_canceller",
")",
",",
"//new Deferred(this.getPromise().cancel)",
"listener",
"=",
"{",
"resolved",
":"... | Return a new promise
@param {Function} resolvedCallback
@param {Function} errorCallback
@param {Function} progressCallback
@return {Promise} | [
"Return",
"a",
"new",
"promise"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L488-L503 | train | |
altshift/altshift | lib/altshift/promise.js | function (error, dontThrow) {
var self = this;
self.isError = true;
self._notifyAll(error);
if (!dontThrow) {
enqueue(function () {
if (!self.handled) {
throw error;
}
});
}
return self.handled;
... | javascript | function (error, dontThrow) {
var self = this;
self.isError = true;
self._notifyAll(error);
if (!dontThrow) {
enqueue(function () {
if (!self.handled) {
throw error;
}
});
}
return self.handled;
... | [
"function",
"(",
"error",
",",
"dontThrow",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"isError",
"=",
"true",
";",
"self",
".",
"_notifyAll",
"(",
"error",
")",
";",
"if",
"(",
"!",
"dontThrow",
")",
"{",
"enqueue",
"(",
"function",
"... | Calling emitError will indicate that the promise failed
@param {*} value send to all resolved callbacks
@return this | [
"Calling",
"emitError",
"will",
"indicate",
"that",
"the",
"promise",
"failed"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L531-L544 | train | |
altshift/altshift | lib/altshift/promise.js | function (update) {
var waiting = this.waiting,
length = waiting.length,
index,
progress;
for (index = 0; index < length; index += 1) {
progress = waiting[index].progress;
if (progress) {
progress(update);
}
... | javascript | function (update) {
var waiting = this.waiting,
length = waiting.length,
index,
progress;
for (index = 0; index < length; index += 1) {
progress = waiting[index].progress;
if (progress) {
progress(update);
}
... | [
"function",
"(",
"update",
")",
"{",
"var",
"waiting",
"=",
"this",
".",
"waiting",
",",
"length",
"=",
"waiting",
".",
"length",
",",
"index",
",",
"progress",
";",
"for",
"(",
"index",
"=",
"0",
";",
"index",
"<",
"length",
";",
"index",
"+=",
"1... | Call progress on every waiting function to notify that the promise was updated
@param {*} update
@return this | [
"Call",
"progress",
"on",
"every",
"waiting",
"function",
"to",
"notify",
"that",
"the",
"promise",
"was",
"updated"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L558-L571 | train | |
altshift/altshift | lib/altshift/promise.js | function () {
if (!this.finished && this._canceller) {
var error = this._canceller();
if (!(error instanceof Error)) {
error = new Error(error);
}
return this.emitError(error);
}
return false;
} | javascript | function () {
if (!this.finished && this._canceller) {
var error = this._canceller();
if (!(error instanceof Error)) {
error = new Error(error);
}
return this.emitError(error);
}
return false;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"finished",
"&&",
"this",
".",
"_canceller",
")",
"{",
"var",
"error",
"=",
"this",
".",
"_canceller",
"(",
")",
";",
"if",
"(",
"!",
"(",
"error",
"instanceof",
"Error",
")",
")",
"{",
"err... | Cancel the promise
@return {boolean} true if error was handled | [
"Cancel",
"the",
"promise"
] | 5c051157e6f558636c8e12081b6707caa66249de | https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/promise.js#L578-L587 | 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.