id int32 0 58k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
55,400 | phun-ky/patsy | lib/patsy.js | function(how){
var _child, _cfg, patsy = this;
var _execCmd = [];
if(typeof this.project_cfg.project === 'undefined'){
/**
* Require config from the library
*
* @var Object
* @source patsy
*/
var config = require('./config')({
app_path : opts.app_path,
verbose : opts.verbose,
project_path : ''
});
this.project_cfg = config.load();
}
process.chdir(this.project_cfg.project.environment.abs_path);
_cfg = this.project_cfg || this.config.load();
process.chdir(opts.app_path);
if(patsy.utils.isWin){
_execCmd.push('cmd');
// New args will go to cmd.exe, then we append the args passed in to the list
// the /c part tells it to run the command. Thanks, Windows...
_execCmd.push('/c');
_execCmd.push('node_modules\\.bin\\grunt');
} else {
_execCmd.push('node_modules/.bin/grunt');
}
// Append needed arguments for grunt
_execCmd.push('--path');
_execCmd.push(_cfg.project.environment.abs_path);
_execCmd.push(opts.verbose ? '-v' : '');
_execCmd.push(opts.force ? '--force' : '');
_execCmd.push(how);
_child = exec(_execCmd.join(' '),
function (error, stdout, stderr) {
util.print(stdout);
if(stderr){
console.log(stderr);
}
if (error !== null) {
patsy.scripture.print('\n[Patsy]'.yellow + ': The grunt died!');
if(opts.verbose){
console.log('>> ERROR'.red + ':' , error);
}
process.exit(1);
}
});
} | javascript | function(how){
var _child, _cfg, patsy = this;
var _execCmd = [];
if(typeof this.project_cfg.project === 'undefined'){
/**
* Require config from the library
*
* @var Object
* @source patsy
*/
var config = require('./config')({
app_path : opts.app_path,
verbose : opts.verbose,
project_path : ''
});
this.project_cfg = config.load();
}
process.chdir(this.project_cfg.project.environment.abs_path);
_cfg = this.project_cfg || this.config.load();
process.chdir(opts.app_path);
if(patsy.utils.isWin){
_execCmd.push('cmd');
// New args will go to cmd.exe, then we append the args passed in to the list
// the /c part tells it to run the command. Thanks, Windows...
_execCmd.push('/c');
_execCmd.push('node_modules\\.bin\\grunt');
} else {
_execCmd.push('node_modules/.bin/grunt');
}
// Append needed arguments for grunt
_execCmd.push('--path');
_execCmd.push(_cfg.project.environment.abs_path);
_execCmd.push(opts.verbose ? '-v' : '');
_execCmd.push(opts.force ? '--force' : '');
_execCmd.push(how);
_child = exec(_execCmd.join(' '),
function (error, stdout, stderr) {
util.print(stdout);
if(stderr){
console.log(stderr);
}
if (error !== null) {
patsy.scripture.print('\n[Patsy]'.yellow + ': The grunt died!');
if(opts.verbose){
console.log('>> ERROR'.red + ':' , error);
}
process.exit(1);
}
});
} | [
"function",
"(",
"how",
")",
"{",
"var",
"_child",
",",
"_cfg",
",",
"patsy",
"=",
"this",
";",
"var",
"_execCmd",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"this",
".",
"project_cfg",
".",
"project",
"===",
"'undefined'",
")",
"{",
"/**\n * Req... | Runs grunt tasks
@param String how | [
"Runs",
"grunt",
"tasks"
] | b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5 | https://github.com/phun-ky/patsy/blob/b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5/lib/patsy.js#L768-L843 | |
55,401 | syaning/zhimg | index.js | Image | function Image(src) {
if (!(this instanceof Image)) {
return new Image(src)
}
if (typeof src !== 'string') {
throw new Error('param `src` must be a string')
}
var ret = reg.exec(src)
if (!ret) {
throw new Error('invalid param `src`')
}
this.src = src
this.host = ret[1] || defaultHost
this.version = ret[2] ? ret[2].slice(0, -1) : ''
this.hash = ret[3]
this.ext = ret[4]
} | javascript | function Image(src) {
if (!(this instanceof Image)) {
return new Image(src)
}
if (typeof src !== 'string') {
throw new Error('param `src` must be a string')
}
var ret = reg.exec(src)
if (!ret) {
throw new Error('invalid param `src`')
}
this.src = src
this.host = ret[1] || defaultHost
this.version = ret[2] ? ret[2].slice(0, -1) : ''
this.hash = ret[3]
this.ext = ret[4]
} | [
"function",
"Image",
"(",
"src",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Image",
")",
")",
"{",
"return",
"new",
"Image",
"(",
"src",
")",
"}",
"if",
"(",
"typeof",
"src",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"... | Initialize `Image` with given `src`.
@param {String} src
@public | [
"Initialize",
"Image",
"with",
"given",
"src",
"."
] | d63658f67a39ee0804ab61a6890c997a58e3c38e | https://github.com/syaning/zhimg/blob/d63658f67a39ee0804ab61a6890c997a58e3c38e/index.js#L12-L32 |
55,402 | skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function ($placeholder, file, that) {
$.ajax({
type: "post",
url: that.options.imagesUploadScript,
xhr: function () {
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = that.updateProgressBar;
return xhr;
},
cache: false,
contentType: false,
complete: function (jqxhr) {
that.uploadCompleted(jqxhr, $placeholder);
},
processData: false,
data: that.options.formatData(file)
});
} | javascript | function ($placeholder, file, that) {
$.ajax({
type: "post",
url: that.options.imagesUploadScript,
xhr: function () {
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = that.updateProgressBar;
return xhr;
},
cache: false,
contentType: false,
complete: function (jqxhr) {
that.uploadCompleted(jqxhr, $placeholder);
},
processData: false,
data: that.options.formatData(file)
});
} | [
"function",
"(",
"$placeholder",
",",
"file",
",",
"that",
")",
"{",
"$",
".",
"ajax",
"(",
"{",
"type",
":",
"\"post\"",
",",
"url",
":",
"that",
".",
"options",
".",
"imagesUploadScript",
",",
"xhr",
":",
"function",
"(",
")",
"{",
"var",
"xhr",
... | Upload single file
@param {element} $placeholder Placeholder to add image to
@param {File} file File to upload
@param {object} that Context
@param {void} | [
"Upload",
"single",
"file"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L45-L62 | |
55,403 | skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (file, that) {
$.ajax({
type: "post",
url: that.options.imagesDeleteScript,
data: {
file: file
}
});
} | javascript | function (file, that) {
$.ajax({
type: "post",
url: that.options.imagesDeleteScript,
data: {
file: file
}
});
} | [
"function",
"(",
"file",
",",
"that",
")",
"{",
"$",
".",
"ajax",
"(",
"{",
"type",
":",
"\"post\"",
",",
"url",
":",
"that",
".",
"options",
".",
"imagesDeleteScript",
",",
"data",
":",
"{",
"file",
":",
"file",
"}",
"}",
")",
";",
"}"
] | Makes ajax call for deleting a file on a server
@param {string} file File name
@param {object} that Context
@return {void} | [
"Makes",
"ajax",
"call",
"for",
"deleting",
"a",
"file",
"on",
"a",
"server"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L71-L79 | |
55,404 | skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (options) {
if (options && options.$el) {
this.$el = options.$el;
}
this.options = $.extend(this.defaults, options);
this.setImageEvents();
if (this.options.useDragAndDrop === true){
this.setDragAndDropEvents();
}
this.preparePreviousImages();
} | javascript | function (options) {
if (options && options.$el) {
this.$el = options.$el;
}
this.options = $.extend(this.defaults, options);
this.setImageEvents();
if (this.options.useDragAndDrop === true){
this.setDragAndDropEvents();
}
this.preparePreviousImages();
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"$el",
")",
"{",
"this",
".",
"$el",
"=",
"options",
".",
"$el",
";",
"}",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"this",
".",
"defaults",
",",
"opti... | Images initial function
@param {object} options Options to overide defaults
@return {void} | [
"Images",
"initial",
"function"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L90-L104 | |
55,405 | skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function(buttonLabels){
var label = 'Img';
if (buttonLabels === 'fontawesome' || typeof buttonLabels === 'object' && !!(buttonLabels.fontawesome)) {
label = '<i class="fa fa-picture-o"></i>';
}
if (typeof buttonLabels === 'object' && buttonLabels.img) {
label = buttonLabels.img;
}
return '<button data-addon="images" data-action="add" class="medium-editor-action mediumInsert-action">'+label+'</button>';
} | javascript | function(buttonLabels){
var label = 'Img';
if (buttonLabels === 'fontawesome' || typeof buttonLabels === 'object' && !!(buttonLabels.fontawesome)) {
label = '<i class="fa fa-picture-o"></i>';
}
if (typeof buttonLabels === 'object' && buttonLabels.img) {
label = buttonLabels.img;
}
return '<button data-addon="images" data-action="add" class="medium-editor-action mediumInsert-action">'+label+'</button>';
} | [
"function",
"(",
"buttonLabels",
")",
"{",
"var",
"label",
"=",
"'Img'",
";",
"if",
"(",
"buttonLabels",
"===",
"'fontawesome'",
"||",
"typeof",
"buttonLabels",
"===",
"'object'",
"&&",
"!",
"!",
"(",
"buttonLabels",
".",
"fontawesome",
")",
")",
"{",
"lab... | Returns insert button
@param {string} buttonLabels
@return {string} | [
"Returns",
"insert",
"button"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L114-L125 | |
55,406 | skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function ($placeholder) {
var that = this,
$selectFile, files;
$selectFile = $('<input type="file" multiple="multiple">').click();
$selectFile.change(function () {
files = this.files;
that.uploadFiles($placeholder, files, that);
});
$.fn.mediumInsert.insert.deselect();
return $selectFile;
} | javascript | function ($placeholder) {
var that = this,
$selectFile, files;
$selectFile = $('<input type="file" multiple="multiple">').click();
$selectFile.change(function () {
files = this.files;
that.uploadFiles($placeholder, files, that);
});
$.fn.mediumInsert.insert.deselect();
return $selectFile;
} | [
"function",
"(",
"$placeholder",
")",
"{",
"var",
"that",
"=",
"this",
",",
"$selectFile",
",",
"files",
";",
"$selectFile",
"=",
"$",
"(",
"'<input type=\"file\" multiple=\"multiple\">'",
")",
".",
"click",
"(",
")",
";",
"$selectFile",
".",
"change",
"(",
... | Add image to placeholder
@param {element} $placeholder Placeholder to add image to
@return {element} $selectFile <input type="file"> element | [
"Add",
"image",
"to",
"placeholder"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L149-L162 | |
55,407 | skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (e) {
var $progress = $('.progress:first', this.$el),
complete;
if (e.lengthComputable) {
complete = e.loaded / e.total * 100;
complete = complete ? complete : 0;
$progress.attr('value', complete);
$progress.html(complete);
}
} | javascript | function (e) {
var $progress = $('.progress:first', this.$el),
complete;
if (e.lengthComputable) {
complete = e.loaded / e.total * 100;
complete = complete ? complete : 0;
$progress.attr('value', complete);
$progress.html(complete);
}
} | [
"function",
"(",
"e",
")",
"{",
"var",
"$progress",
"=",
"$",
"(",
"'.progress:first'",
",",
"this",
".",
"$el",
")",
",",
"complete",
";",
"if",
"(",
"e",
".",
"lengthComputable",
")",
"{",
"complete",
"=",
"e",
".",
"loaded",
"/",
"e",
".",
"tota... | Update progressbar while upload
@param {event} e XMLHttpRequest.upload.onprogress event
@return {void} | [
"Update",
"progressbar",
"while",
"upload"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L171-L181 | |
55,408 | skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (jqxhr, $placeholder) {
var $progress = $('.progress:first', $placeholder),
$img;
$progress.attr('value', 100);
$progress.html(100);
if (jqxhr.responseText) {
$progress.before('<figure class="mediumInsert-images"><img src="'+ jqxhr.responseText +'" draggable="true" alt=""></figure>');
$img = $progress.siblings('img');
$img.load(function () {
$img.parent().mouseleave().mouseenter();
});
} else {
$progress.before('<div class="mediumInsert-error">There was a problem uploading the file.</div>');
setTimeout(function () {
$('.mediumInsert-error:first', $placeholder).fadeOut(function () {
$(this).remove();
});
}, 3000);
}
$progress.remove();
$placeholder.closest('[data-medium-element]').trigger('keyup').trigger('input');
} | javascript | function (jqxhr, $placeholder) {
var $progress = $('.progress:first', $placeholder),
$img;
$progress.attr('value', 100);
$progress.html(100);
if (jqxhr.responseText) {
$progress.before('<figure class="mediumInsert-images"><img src="'+ jqxhr.responseText +'" draggable="true" alt=""></figure>');
$img = $progress.siblings('img');
$img.load(function () {
$img.parent().mouseleave().mouseenter();
});
} else {
$progress.before('<div class="mediumInsert-error">There was a problem uploading the file.</div>');
setTimeout(function () {
$('.mediumInsert-error:first', $placeholder).fadeOut(function () {
$(this).remove();
});
}, 3000);
}
$progress.remove();
$placeholder.closest('[data-medium-element]').trigger('keyup').trigger('input');
} | [
"function",
"(",
"jqxhr",
",",
"$placeholder",
")",
"{",
"var",
"$progress",
"=",
"$",
"(",
"'.progress:first'",
",",
"$placeholder",
")",
",",
"$img",
";",
"$progress",
".",
"attr",
"(",
"'value'",
",",
"100",
")",
";",
"$progress",
".",
"html",
"(",
... | Show uploaded image after upload completed
@param {jqXHR} jqxhr jqXHR object
@return {void} | [
"Show",
"uploaded",
"image",
"after",
"upload",
"completed"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L190-L217 | |
55,409 | mgesmundo/authorify-client | lib/class/Store.js | function(key, callback) {
if (key) {
this.store.proxy.remove(this.prefix + key);
if (callback) {
callback(null, key);
}
} else {
if (callback) {
callback('missing key');
}
}
} | javascript | function(key, callback) {
if (key) {
this.store.proxy.remove(this.prefix + key);
if (callback) {
callback(null, key);
}
} else {
if (callback) {
callback('missing key');
}
}
} | [
"function",
"(",
"key",
",",
"callback",
")",
"{",
"if",
"(",
"key",
")",
"{",
"this",
".",
"store",
".",
"proxy",
".",
"remove",
"(",
"this",
".",
"prefix",
"+",
"key",
")",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
"null",
",",
"... | Destroy a stored item
@param {String} key The key of the item
@param {Function} callback Function called when the operation is done
@return {callback(err, key)} The callback to execute as result
@param {String} callback.err Error if occurred
@param {String} callback.key The key of the destroyed item | [
"Destroy",
"a",
"stored",
"item"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Store.js#L53-L64 | |
55,410 | mgesmundo/authorify-client | lib/class/Store.js | function(key, callback) {
if (key) {
var _data = this.store.proxy.get(this.prefix + key),
data;
if ('undefined' !== typeof window) {
// browser
try {
data = JSON.parse(_data);
} catch (e) {
data = _data;
}
} else {
data = _data;
}
callback(null, data);
} else {
callback('missing key');
}
} | javascript | function(key, callback) {
if (key) {
var _data = this.store.proxy.get(this.prefix + key),
data;
if ('undefined' !== typeof window) {
// browser
try {
data = JSON.parse(_data);
} catch (e) {
data = _data;
}
} else {
data = _data;
}
callback(null, data);
} else {
callback('missing key');
}
} | [
"function",
"(",
"key",
",",
"callback",
")",
"{",
"if",
"(",
"key",
")",
"{",
"var",
"_data",
"=",
"this",
".",
"store",
".",
"proxy",
".",
"get",
"(",
"this",
".",
"prefix",
"+",
"key",
")",
",",
"data",
";",
"if",
"(",
"'undefined'",
"!==",
... | Load stored item
@param {String} key The key of the item
@param {Function} callback Function called when the item is loaded
@return {callback(err, data)} The callback to execute as result
@param {String} callback.err Error if occurred
@param {Object} callback.data The loaded item | [
"Load",
"stored",
"item"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Store.js#L74-L92 | |
55,411 | mgesmundo/authorify-client | lib/class/Store.js | function(key, data, callback) {
if (key) {
if (data) {
var _data = data;
if ('undefined' !== typeof window && 'object' === typeof data) {
_data = JSON.stringify(_data);
}
this.store.proxy.set(this.prefix + key, _data);
callback(null);
} else {
callback('missing data');
}
} else {
callback('missing key');
}
} | javascript | function(key, data, callback) {
if (key) {
if (data) {
var _data = data;
if ('undefined' !== typeof window && 'object' === typeof data) {
_data = JSON.stringify(_data);
}
this.store.proxy.set(this.prefix + key, _data);
callback(null);
} else {
callback('missing data');
}
} else {
callback('missing key');
}
} | [
"function",
"(",
"key",
",",
"data",
",",
"callback",
")",
"{",
"if",
"(",
"key",
")",
"{",
"if",
"(",
"data",
")",
"{",
"var",
"_data",
"=",
"data",
";",
"if",
"(",
"'undefined'",
"!==",
"typeof",
"window",
"&&",
"'object'",
"===",
"typeof",
"data... | Save an item
@param {String} key The key of the item
@param {Object} data The item
@param {Function} callback Function called when the session is saved
@return {callback(err)} The callback to execute as result
@param {String} callback.status Result from Redis query | [
"Save",
"an",
"item"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Store.js#L102-L117 | |
55,412 | docvy/plugin-installer | lib/cli.js | list | function list() {
return installer.listPlugins(function(listErr, plugins) {
if (listErr) {
return out.error("error listing installed plugins: %s", listErr);
}
if (plugins.length === 0) {
return out.success("no plugins found");
}
var string = "";
for (var idx = 0; idx < plugins.length; idx++) {
string += " " + (idx + 1) + ". " + plugins[idx].name +
" - " + plugins[idx].description + "\n";
}
return out.success("installed plugins:\n%s", string);
});
} | javascript | function list() {
return installer.listPlugins(function(listErr, plugins) {
if (listErr) {
return out.error("error listing installed plugins: %s", listErr);
}
if (plugins.length === 0) {
return out.success("no plugins found");
}
var string = "";
for (var idx = 0; idx < plugins.length; idx++) {
string += " " + (idx + 1) + ". " + plugins[idx].name +
" - " + plugins[idx].description + "\n";
}
return out.success("installed plugins:\n%s", string);
});
} | [
"function",
"list",
"(",
")",
"{",
"return",
"installer",
".",
"listPlugins",
"(",
"function",
"(",
"listErr",
",",
"plugins",
")",
"{",
"if",
"(",
"listErr",
")",
"{",
"return",
"out",
".",
"error",
"(",
"\"error listing installed plugins: %s\"",
",",
"list... | listing installed plugins | [
"listing",
"installed",
"plugins"
] | eb645eb21f350a0fbbf783d83b25ab18feeee684 | https://github.com/docvy/plugin-installer/blob/eb645eb21f350a0fbbf783d83b25ab18feeee684/lib/cli.js#L36-L51 |
55,413 | pierrec/node-atok | lib/tokenizer.js | resolveId | function resolveId (prop) {
if (rule[prop] === null || typeof rule[prop] === 'number') return
// Resolve the property to an index
var j = self._getRuleIndex(rule.id)
if (j < 0)
self._error( new Error('Atok#_resolveRules: ' + prop + '() value not found: ' + rule.id) )
rule[prop] = i - j
} | javascript | function resolveId (prop) {
if (rule[prop] === null || typeof rule[prop] === 'number') return
// Resolve the property to an index
var j = self._getRuleIndex(rule.id)
if (j < 0)
self._error( new Error('Atok#_resolveRules: ' + prop + '() value not found: ' + rule.id) )
rule[prop] = i - j
} | [
"function",
"resolveId",
"(",
"prop",
")",
"{",
"if",
"(",
"rule",
"[",
"prop",
"]",
"===",
"null",
"||",
"typeof",
"rule",
"[",
"prop",
"]",
"===",
"'number'",
")",
"return",
"// Resolve the property to an index",
"var",
"j",
"=",
"self",
".",
"_getRuleIn... | Perform various checks on a continue type property | [
"Perform",
"various",
"checks",
"on",
"a",
"continue",
"type",
"property"
] | abe139e7fa8c092d87e528289b6abd9083df2323 | https://github.com/pierrec/node-atok/blob/abe139e7fa8c092d87e528289b6abd9083df2323/lib/tokenizer.js#L759-L768 |
55,414 | repetere/stylie.modals | lib/stylie.modals.js | function (options) {
events.EventEmitter.call(this);
// this.el = el;
this.options = extend(this.options, options);
// console.log(this.options);
this._init();
this.show = this._show;
this.hide = this._hide;
} | javascript | function (options) {
events.EventEmitter.call(this);
// this.el = el;
this.options = extend(this.options, options);
// console.log(this.options);
this._init();
this.show = this._show;
this.hide = this._hide;
} | [
"function",
"(",
"options",
")",
"{",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"// this.el = el;",
"this",
".",
"options",
"=",
"extend",
"(",
"this",
".",
"options",
",",
"options",
")",
";",
"// console.log(this.options);",
"this"... | A module that represents a StylieModals object, a componentTab is a page composition tool.
@{@link https://github.com/typesettin/stylie.modals}
@author Yaw Joseph Etse
@copyright Copyright (c) 2014 Typesettin. All rights reserved.
@license MIT
@constructor StylieModals
@requires module:util-extent
@requires module:util
@requires module:events
@param {object} el element of tab container
@param {object} options configuration options | [
"A",
"module",
"that",
"represents",
"a",
"StylieModals",
"object",
"a",
"componentTab",
"is",
"a",
"page",
"composition",
"tool",
"."
] | a27238e4a3c27fc7761e92d449fe6d1967f1fffb | https://github.com/repetere/stylie.modals/blob/a27238e4a3c27fc7761e92d449fe6d1967f1fffb/lib/stylie.modals.js#L28-L37 | |
55,415 | arpinum-oss/js-promising | benchmarks/compose.js | createFunctions | function createFunctions() {
const result = [];
for (let i = 0; i < count; i++) {
result.push(number => Promise.resolve(number + 1));
}
return result;
} | javascript | function createFunctions() {
const result = [];
for (let i = 0; i < count; i++) {
result.push(number => Promise.resolve(number + 1));
}
return result;
} | [
"function",
"createFunctions",
"(",
")",
"{",
"const",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"result",
".",
"push",
"(",
"number",
"=>",
"Promise",
".",
"resolve",
"(",
... | 100000 functions handled in 267 ms | [
"100000",
"functions",
"handled",
"in",
"267",
"ms"
] | 710712e7d2b1429bda92d21c420d79d16cc6160a | https://github.com/arpinum-oss/js-promising/blob/710712e7d2b1429bda92d21c420d79d16cc6160a/benchmarks/compose.js#L13-L19 |
55,416 | willmark/http-handler | index.js | function(filepath, req, res) {
var path = require("path"),
config = module.exports.config,
result = false,
parentdir;
do {
var defaultdir = path.resolve(path.join(config.responsesdefault, filepath));
parentdir = path.resolve(path.join(config.responses, filepath));
if (isValidDir(parentdir) && isValidFile(path.join(parentdir, "index.js"))) {
//Parent module response handler exists.
require(parentdir)(req, res);
result = true;
} else if (isValidDir(defaultdir) && isValidFile(path.join(defaultdir, "index.js"))) {
//Default response handler
require(defaultdir)(req, res);
result = true;
}
if (filepath === path.sep) break;
filepath = path.dirname(filepath);
} while (result === false && parentdir !== filepath);
return result;
} | javascript | function(filepath, req, res) {
var path = require("path"),
config = module.exports.config,
result = false,
parentdir;
do {
var defaultdir = path.resolve(path.join(config.responsesdefault, filepath));
parentdir = path.resolve(path.join(config.responses, filepath));
if (isValidDir(parentdir) && isValidFile(path.join(parentdir, "index.js"))) {
//Parent module response handler exists.
require(parentdir)(req, res);
result = true;
} else if (isValidDir(defaultdir) && isValidFile(path.join(defaultdir, "index.js"))) {
//Default response handler
require(defaultdir)(req, res);
result = true;
}
if (filepath === path.sep) break;
filepath = path.dirname(filepath);
} while (result === false && parentdir !== filepath);
return result;
} | [
"function",
"(",
"filepath",
",",
"req",
",",
"res",
")",
"{",
"var",
"path",
"=",
"require",
"(",
"\"path\"",
")",
",",
"config",
"=",
"module",
".",
"exports",
".",
"config",
",",
"result",
"=",
"false",
",",
"parentdir",
";",
"do",
"{",
"var",
"... | Join responses root folder to requested sub-directory
id - sub-folder path
req - http request http.IncomingMessage
res - http response http.ServerResponse | [
"Join",
"responses",
"root",
"folder",
"to",
"requested",
"sub",
"-",
"directory",
"id",
"-",
"sub",
"-",
"folder",
"path",
"req",
"-",
"http",
"request",
"http",
".",
"IncomingMessage",
"res",
"-",
"http",
"response",
"http",
".",
"ServerResponse"
] | 63defe72de0214f34500d3d9db75807014f5d134 | https://github.com/willmark/http-handler/blob/63defe72de0214f34500d3d9db75807014f5d134/index.js#L36-L57 | |
55,417 | psastras/swag2blue | index.js | convert | function convert(swagger, done) {
fury.parse({source: swagger}, function (parseErr, res) {
if (parseErr) {
return done(parseErr);
}
fury.serialize({api: res.api}, function (serializeErr, blueprint) {
if (serializeErr) {
return done(serializeErr);
}
done(null, blueprint);
});
});
} | javascript | function convert(swagger, done) {
fury.parse({source: swagger}, function (parseErr, res) {
if (parseErr) {
return done(parseErr);
}
fury.serialize({api: res.api}, function (serializeErr, blueprint) {
if (serializeErr) {
return done(serializeErr);
}
done(null, blueprint);
});
});
} | [
"function",
"convert",
"(",
"swagger",
",",
"done",
")",
"{",
"fury",
".",
"parse",
"(",
"{",
"source",
":",
"swagger",
"}",
",",
"function",
"(",
"parseErr",
",",
"res",
")",
"{",
"if",
"(",
"parseErr",
")",
"{",
"return",
"done",
"(",
"parseErr",
... | Take a loaded Swagger object and converts it to API Blueprint | [
"Take",
"a",
"loaded",
"Swagger",
"object",
"and",
"converts",
"it",
"to",
"API",
"Blueprint"
] | 443f0703a6b60ed3da9b5cebfa4a9c1f167a9718 | https://github.com/psastras/swag2blue/blob/443f0703a6b60ed3da9b5cebfa4a9c1f167a9718/index.js#L25-L38 |
55,418 | psastras/swag2blue | index.js | run | function run(argv, done) {
if (!argv) {
argv = parser.argv;
}
if (argv.h) {
parser.showHelp();
return done(null);
}
if (!argv._.length) {
return done(new Error('Requires an input argument'));
} else if (argv._.length > 2) {
return done(new Error('Too many arguments given!'));
}
var input = argv._[0];
if (input.indexOf('http://') === 0 || input.indexOf('https://') === 0) {
request(input, function (err, res, body) {
if (err) {
return done(err);
}
convert(body, done);
});
} else {
if (!fs.existsSync(input)) {
return done(new Error('`' + input + '` does not exist!'));
}
fs.readFile(input, 'utf-8', function (err, content) {
if (err) {
return done(err);
}
convert(content, done);
});
}
} | javascript | function run(argv, done) {
if (!argv) {
argv = parser.argv;
}
if (argv.h) {
parser.showHelp();
return done(null);
}
if (!argv._.length) {
return done(new Error('Requires an input argument'));
} else if (argv._.length > 2) {
return done(new Error('Too many arguments given!'));
}
var input = argv._[0];
if (input.indexOf('http://') === 0 || input.indexOf('https://') === 0) {
request(input, function (err, res, body) {
if (err) {
return done(err);
}
convert(body, done);
});
} else {
if (!fs.existsSync(input)) {
return done(new Error('`' + input + '` does not exist!'));
}
fs.readFile(input, 'utf-8', function (err, content) {
if (err) {
return done(err);
}
convert(content, done);
});
}
} | [
"function",
"run",
"(",
"argv",
",",
"done",
")",
"{",
"if",
"(",
"!",
"argv",
")",
"{",
"argv",
"=",
"parser",
".",
"argv",
";",
"}",
"if",
"(",
"argv",
".",
"h",
")",
"{",
"parser",
".",
"showHelp",
"(",
")",
";",
"return",
"done",
"(",
"nu... | Run the command with the given arguments. | [
"Run",
"the",
"command",
"with",
"the",
"given",
"arguments",
"."
] | 443f0703a6b60ed3da9b5cebfa4a9c1f167a9718 | https://github.com/psastras/swag2blue/blob/443f0703a6b60ed3da9b5cebfa4a9c1f167a9718/index.js#L41-L78 |
55,419 | trevorparscal/node-palo | lib/resources/ModuleResource.js | ModuleResource | function ModuleResource( pkg, config ) {
// Parent constructor
ModuleResource.super.call( this, pkg, config );
// Properties
this.imports = config.imports || null;
this.exports = config.exports || null;
this.propertyNamePattern = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
} | javascript | function ModuleResource( pkg, config ) {
// Parent constructor
ModuleResource.super.call( this, pkg, config );
// Properties
this.imports = config.imports || null;
this.exports = config.exports || null;
this.propertyNamePattern = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
} | [
"function",
"ModuleResource",
"(",
"pkg",
",",
"config",
")",
"{",
"// Parent constructor",
"ModuleResource",
".",
"super",
".",
"call",
"(",
"this",
",",
"pkg",
",",
"config",
")",
";",
"// Properties",
"this",
".",
"imports",
"=",
"config",
".",
"imports",... | JavaScript module resource.
@class
@extends {FileResource}
@constructor
@param {Package} pkg Package this resource is part of
@param {Object|string[]|string} config Resource configuration or one or more resource file paths | [
"JavaScript",
"module",
"resource",
"."
] | 425efdcf027c71296c732765afdf5cacae6a1a3e | https://github.com/trevorparscal/node-palo/blob/425efdcf027c71296c732765afdf5cacae6a1a3e/lib/resources/ModuleResource.js#L15-L23 |
55,420 | kaelzhang/node-commonjs-walker | lib/walker.js | init | function init (done) {
var node = tools.match_ext(filename, 'node')
var json = tools.match_ext(filename, 'json')
done(null, {
content: content,
json: json,
node: node,
// all other files are considered as javascript files.
js: !node && !json,
})
} | javascript | function init (done) {
var node = tools.match_ext(filename, 'node')
var json = tools.match_ext(filename, 'json')
done(null, {
content: content,
json: json,
node: node,
// all other files are considered as javascript files.
js: !node && !json,
})
} | [
"function",
"init",
"(",
"done",
")",
"{",
"var",
"node",
"=",
"tools",
".",
"match_ext",
"(",
"filename",
",",
"'node'",
")",
"var",
"json",
"=",
"tools",
".",
"match_ext",
"(",
"filename",
",",
"'json'",
")",
"done",
"(",
"null",
",",
"{",
"content... | If no registered compilers, just return | [
"If",
"no",
"registered",
"compilers",
"just",
"return"
] | d96b3b56ffa9efb2eaa33e67c91d32622f79ea37 | https://github.com/kaelzhang/node-commonjs-walker/blob/d96b3b56ffa9efb2eaa33e67c91d32622f79ea37/lib/walker.js#L242-L253 |
55,421 | medic/couchdb-audit | couchdb-audit/kanso.js | function(db, auditDb) {
var dbWrapper = getDbWrapper(db);
var auditDbWrapper;
if (auditDb) {
auditDbWrapper = getDbWrapper(auditDb);
} else {
auditDbWrapper = dbWrapper;
}
var clientWrapper = {
uuids: function(count, callback) {
db.newUUID.call(db, 100, function(err, id) {
callback(err, {uuids: [id]});
});
}
};
return log.init(appname, clientWrapper, dbWrapper, auditDbWrapper, function(callback) {
session.info(function(err, result) {
if (err) {
return callback(err);
}
callback(null, result.userCtx.name);
});
});
} | javascript | function(db, auditDb) {
var dbWrapper = getDbWrapper(db);
var auditDbWrapper;
if (auditDb) {
auditDbWrapper = getDbWrapper(auditDb);
} else {
auditDbWrapper = dbWrapper;
}
var clientWrapper = {
uuids: function(count, callback) {
db.newUUID.call(db, 100, function(err, id) {
callback(err, {uuids: [id]});
});
}
};
return log.init(appname, clientWrapper, dbWrapper, auditDbWrapper, function(callback) {
session.info(function(err, result) {
if (err) {
return callback(err);
}
callback(null, result.userCtx.name);
});
});
} | [
"function",
"(",
"db",
",",
"auditDb",
")",
"{",
"var",
"dbWrapper",
"=",
"getDbWrapper",
"(",
"db",
")",
";",
"var",
"auditDbWrapper",
";",
"if",
"(",
"auditDb",
")",
"{",
"auditDbWrapper",
"=",
"getDbWrapper",
"(",
"auditDb",
")",
";",
"}",
"else",
"... | Sets up auditing to work with the kanso db module.
@name withKanso(db)
@param {Object} db The kanso db instance to use.
@param {Object} auditDb Optionally the kanso db instance to use for auditing.
@api public | [
"Sets",
"up",
"auditing",
"to",
"work",
"with",
"the",
"kanso",
"db",
"module",
"."
] | 88a2fde06830e91966fc82c7356ec46da043fc01 | https://github.com/medic/couchdb-audit/blob/88a2fde06830e91966fc82c7356ec46da043fc01/couchdb-audit/kanso.js#L35-L60 | |
55,422 | mattma/gulp-htmlbars | bower_components/ember/ember-template-compiler.js | domIndexOf | function domIndexOf(nodes, domNode) {
var index = -1;
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.type !== 'TextNode' && node.type !== 'ElementNode') {
continue;
} else {
index++;
}
if (node === domNode) {
return index;
}
}
return -1;
} | javascript | function domIndexOf(nodes, domNode) {
var index = -1;
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.type !== 'TextNode' && node.type !== 'ElementNode') {
continue;
} else {
index++;
}
if (node === domNode) {
return index;
}
}
return -1;
} | [
"function",
"domIndexOf",
"(",
"nodes",
",",
"domNode",
")",
"{",
"var",
"index",
"=",
"-",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"node",
"=",
"nodes",
"[",
"i",
"]... | Returns the index of `domNode` in the `nodes` array, skipping over any nodes which do not represent DOM nodes. | [
"Returns",
"the",
"index",
"of",
"domNode",
"in",
"the",
"nodes",
"array",
"skipping",
"over",
"any",
"nodes",
"which",
"do",
"not",
"represent",
"DOM",
"nodes",
"."
] | c9e6bcf32023825efc34a93ecf8555b3f98b2bcf | https://github.com/mattma/gulp-htmlbars/blob/c9e6bcf32023825efc34a93ecf8555b3f98b2bcf/bower_components/ember/ember-template-compiler.js#L1891-L1909 |
55,423 | mattma/gulp-htmlbars | bower_components/ember/ember-template-compiler.js | parseComponentBlockParams | function parseComponentBlockParams(element, program) {
var l = element.attributes.length;
var attrNames = [];
for (var i = 0; i < l; i++) {
attrNames.push(element.attributes[i].name);
}
var asIndex = attrNames.indexOf('as');
if (asIndex !== -1 && l > asIndex && attrNames[asIndex + 1].charAt(0) === '|') {
// Some basic validation, since we're doing the parsing ourselves
var paramsString = attrNames.slice(asIndex).join(' ');
if (paramsString.charAt(paramsString.length - 1) !== '|' || paramsString.match(/\|/g).length !== 2) {
throw new Error('Invalid block parameters syntax: \'' + paramsString + '\'');
}
var params = [];
for (i = asIndex + 1; i < l; i++) {
var param = attrNames[i].replace(/\|/g, '');
if (param !== '') {
if (ID_INVERSE_PATTERN.test(param)) {
throw new Error('Invalid identifier for block parameters: \'' + param + '\' in \'' + paramsString + '\'');
}
params.push(param);
}
}
if (params.length === 0) {
throw new Error('Cannot use zero block parameters: \'' + paramsString + '\'');
}
element.attributes = element.attributes.slice(0, asIndex);
program.blockParams = params;
}
} | javascript | function parseComponentBlockParams(element, program) {
var l = element.attributes.length;
var attrNames = [];
for (var i = 0; i < l; i++) {
attrNames.push(element.attributes[i].name);
}
var asIndex = attrNames.indexOf('as');
if (asIndex !== -1 && l > asIndex && attrNames[asIndex + 1].charAt(0) === '|') {
// Some basic validation, since we're doing the parsing ourselves
var paramsString = attrNames.slice(asIndex).join(' ');
if (paramsString.charAt(paramsString.length - 1) !== '|' || paramsString.match(/\|/g).length !== 2) {
throw new Error('Invalid block parameters syntax: \'' + paramsString + '\'');
}
var params = [];
for (i = asIndex + 1; i < l; i++) {
var param = attrNames[i].replace(/\|/g, '');
if (param !== '') {
if (ID_INVERSE_PATTERN.test(param)) {
throw new Error('Invalid identifier for block parameters: \'' + param + '\' in \'' + paramsString + '\'');
}
params.push(param);
}
}
if (params.length === 0) {
throw new Error('Cannot use zero block parameters: \'' + paramsString + '\'');
}
element.attributes = element.attributes.slice(0, asIndex);
program.blockParams = params;
}
} | [
"function",
"parseComponentBlockParams",
"(",
"element",
",",
"program",
")",
"{",
"var",
"l",
"=",
"element",
".",
"attributes",
".",
"length",
";",
"var",
"attrNames",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
... | Checks the component's attributes to see if it uses block params. If it does, registers the block params with the program and removes the corresponding attributes from the element. | [
"Checks",
"the",
"component",
"s",
"attributes",
"to",
"see",
"if",
"it",
"uses",
"block",
"params",
".",
"If",
"it",
"does",
"registers",
"the",
"block",
"params",
"with",
"the",
"program",
"and",
"removes",
"the",
"corresponding",
"attributes",
"from",
"th... | c9e6bcf32023825efc34a93ecf8555b3f98b2bcf | https://github.com/mattma/gulp-htmlbars/blob/c9e6bcf32023825efc34a93ecf8555b3f98b2bcf/bower_components/ember/ember-template-compiler.js#L3889-L3924 |
55,424 | AndreasMadsen/piccolo | lib/client/link.js | onLinkClick | function onLinkClick(event) {
// Resolve anchor link
var page = url.format( url.resolve(location, this.getAttribute('href')) );
// Load new page
piccolo.loadPage( page );
event.preventDefault();
return false;
} | javascript | function onLinkClick(event) {
// Resolve anchor link
var page = url.format( url.resolve(location, this.getAttribute('href')) );
// Load new page
piccolo.loadPage( page );
event.preventDefault();
return false;
} | [
"function",
"onLinkClick",
"(",
"event",
")",
"{",
"// Resolve anchor link",
"var",
"page",
"=",
"url",
".",
"format",
"(",
"url",
".",
"resolve",
"(",
"location",
",",
"this",
".",
"getAttribute",
"(",
"'href'",
")",
")",
")",
";",
"// Load new page",
"pi... | Add handlers to anchor tag | [
"Add",
"handlers",
"to",
"anchor",
"tag"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L23-L31 |
55,425 | AndreasMadsen/piccolo | lib/client/link.js | renderPage | function renderPage(state) {
// Get presenter object
piccolo.require(state.resolved.name, function (error, Resource) {
if (error) return piccolo.emit('error', error);
var presenter = new Resource(state.query.href, document);
presenter[state.resolved.method].apply(presenter, state.resolved.args);
});
} | javascript | function renderPage(state) {
// Get presenter object
piccolo.require(state.resolved.name, function (error, Resource) {
if (error) return piccolo.emit('error', error);
var presenter = new Resource(state.query.href, document);
presenter[state.resolved.method].apply(presenter, state.resolved.args);
});
} | [
"function",
"renderPage",
"(",
"state",
")",
"{",
"// Get presenter object",
"piccolo",
".",
"require",
"(",
"state",
".",
"resolved",
".",
"name",
",",
"function",
"(",
"error",
",",
"Resource",
")",
"{",
"if",
"(",
"error",
")",
"return",
"piccolo",
".",... | Render page change | [
"Render",
"page",
"change"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L49-L57 |
55,426 | AndreasMadsen/piccolo | lib/client/link.js | createStateObject | function createStateObject(page, callback) {
// This callback function will create a change table state object
var create = function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace': 'piccolo',
'query': query
};
callback(state);
};
piccolo.once('ready.router', create);
} | javascript | function createStateObject(page, callback) {
// This callback function will create a change table state object
var create = function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace': 'piccolo',
'query': query
};
callback(state);
};
piccolo.once('ready.router', create);
} | [
"function",
"createStateObject",
"(",
"page",
",",
"callback",
")",
"{",
"// This callback function will create a change table state object",
"var",
"create",
"=",
"function",
"(",
")",
"{",
"var",
"query",
"=",
"url",
".",
"parse",
"(",
"page",
")",
";",
"var",
... | Parse a page path and return state object | [
"Parse",
"a",
"page",
"path",
"and",
"return",
"state",
"object"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L60-L77 |
55,427 | AndreasMadsen/piccolo | lib/client/link.js | function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace': 'piccolo',
'query': query
};
callback(state);
} | javascript | function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace': 'piccolo',
'query': query
};
callback(state);
} | [
"function",
"(",
")",
"{",
"var",
"query",
"=",
"url",
".",
"parse",
"(",
"page",
")",
";",
"var",
"presenter",
"=",
"piccolo",
".",
"build",
".",
"router",
".",
"parse",
"(",
"query",
".",
"pathname",
")",
";",
"var",
"state",
"=",
"{",
"'resolved... | This callback function will create a change table state object | [
"This",
"callback",
"function",
"will",
"create",
"a",
"change",
"table",
"state",
"object"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L63-L74 | |
55,428 | jwoudenberg/chain-args | lib/createChain.js | createChain | function createChain(descriptor, callback) {
if (typeof descriptor !== 'object') {
throw new TypeError('createChain: descriptor is not an object: ' +
descriptor);
}
//Create the Chain class.
function CustomChain(callback) {
if (!(this instanceof CustomChain)) {
return new CustomChain(callback);
}
CustomChain.super_.call(this, callback);
CustomChain._lists.forEach(function(listName) {
this._result[listName] = [];
}, this);
}
util.inherits(CustomChain, Chain);
if (callback) {
CustomChain.prototype._callback = callback;
}
//This will come to contain the names of all lists in the chain.
CustomChain._lists = [];
//Add descriptor properties to Chain prototype.
var keys = Object.keys(descriptor);
keys.forEach(function(key) {
var property = descriptor[key];
//When a chain method is called, a number of actions need to take place.
var actionList = [
//1. Decide what item to store from the arguments.
getArgumentInterpreter(property.elem),
//2. Decide whether to set or push the item to store to an array.
getPropertySetter(CustomChain, key, property.plural),
//3. End the chain or return `this` for further chaining.
getChainEnder(CustomChain, property.end)
].reverse();
CustomChain.prototype[key] = _.compose.apply(null, actionList);
});
return CustomChain;
} | javascript | function createChain(descriptor, callback) {
if (typeof descriptor !== 'object') {
throw new TypeError('createChain: descriptor is not an object: ' +
descriptor);
}
//Create the Chain class.
function CustomChain(callback) {
if (!(this instanceof CustomChain)) {
return new CustomChain(callback);
}
CustomChain.super_.call(this, callback);
CustomChain._lists.forEach(function(listName) {
this._result[listName] = [];
}, this);
}
util.inherits(CustomChain, Chain);
if (callback) {
CustomChain.prototype._callback = callback;
}
//This will come to contain the names of all lists in the chain.
CustomChain._lists = [];
//Add descriptor properties to Chain prototype.
var keys = Object.keys(descriptor);
keys.forEach(function(key) {
var property = descriptor[key];
//When a chain method is called, a number of actions need to take place.
var actionList = [
//1. Decide what item to store from the arguments.
getArgumentInterpreter(property.elem),
//2. Decide whether to set or push the item to store to an array.
getPropertySetter(CustomChain, key, property.plural),
//3. End the chain or return `this` for further chaining.
getChainEnder(CustomChain, property.end)
].reverse();
CustomChain.prototype[key] = _.compose.apply(null, actionList);
});
return CustomChain;
} | [
"function",
"createChain",
"(",
"descriptor",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"descriptor",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'createChain: descriptor is not an object: '",
"+",
"descriptor",
")",
";",
"}",
"//Create t... | Take a descriptor object and return a Chain constructor.
An optional default callback for this type of Chain. | [
"Take",
"a",
"descriptor",
"object",
"and",
"return",
"a",
"Chain",
"constructor",
".",
"An",
"optional",
"default",
"callback",
"for",
"this",
"type",
"of",
"Chain",
"."
] | 8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228 | https://github.com/jwoudenberg/chain-args/blob/8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228/lib/createChain.js#L9-L50 |
55,429 | jwoudenberg/chain-args | lib/createChain.js | CustomChain | function CustomChain(callback) {
if (!(this instanceof CustomChain)) {
return new CustomChain(callback);
}
CustomChain.super_.call(this, callback);
CustomChain._lists.forEach(function(listName) {
this._result[listName] = [];
}, this);
} | javascript | function CustomChain(callback) {
if (!(this instanceof CustomChain)) {
return new CustomChain(callback);
}
CustomChain.super_.call(this, callback);
CustomChain._lists.forEach(function(listName) {
this._result[listName] = [];
}, this);
} | [
"function",
"CustomChain",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"CustomChain",
")",
")",
"{",
"return",
"new",
"CustomChain",
"(",
"callback",
")",
";",
"}",
"CustomChain",
".",
"super_",
".",
"call",
"(",
"this",
",",
... | Create the Chain class. | [
"Create",
"the",
"Chain",
"class",
"."
] | 8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228 | https://github.com/jwoudenberg/chain-args/blob/8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228/lib/createChain.js#L16-L24 |
55,430 | jisbruzzi/file-combiner | index.js | includedFiles | function includedFiles(name){
let includes=this.getIncludes(this.getFile(name));
let ret=includes.map(include => {
let ret = {
absolute:path.join(name,"../",include.relPath),
relative:include.relPath,
match:include.match
}
return ret;
})
return ret;
} | javascript | function includedFiles(name){
let includes=this.getIncludes(this.getFile(name));
let ret=includes.map(include => {
let ret = {
absolute:path.join(name,"../",include.relPath),
relative:include.relPath,
match:include.match
}
return ret;
})
return ret;
} | [
"function",
"includedFiles",
"(",
"name",
")",
"{",
"let",
"includes",
"=",
"this",
".",
"getIncludes",
"(",
"this",
".",
"getFile",
"(",
"name",
")",
")",
";",
"let",
"ret",
"=",
"includes",
".",
"map",
"(",
"include",
"=>",
"{",
"let",
"ret",
"=",
... | Returns the paths of the included files, relative to cwd
@param {String} name | [
"Returns",
"the",
"paths",
"of",
"the",
"included",
"files",
"relative",
"to",
"cwd"
] | f5f4135628de75e55aee3dab0d48e58160113d06 | https://github.com/jisbruzzi/file-combiner/blob/f5f4135628de75e55aee3dab0d48e58160113d06/index.js#L25-L36 |
55,431 | mauroc/passport-squiddio | lib/errors/squiddiotokenerror.js | SquiddioTokenError | function SquiddioTokenError(message, type, code, subcode) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'SquiddioTokenError';
this.message = message;
this.type = type;
this.code = code;
this.subcode = subcode;
this.status = 500;
} | javascript | function SquiddioTokenError(message, type, code, subcode) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'SquiddioTokenError';
this.message = message;
this.type = type;
this.code = code;
this.subcode = subcode;
this.status = 500;
} | [
"function",
"SquiddioTokenError",
"(",
"message",
",",
"type",
",",
"code",
",",
"subcode",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"... | `SquiddioTokenError` error.
SquiddioTokenError represents an error received from a Squiddio's token
endpoint. Note that these responses don't conform to the OAuth 2.0
specification.
References:
- https://developers.Squiddio.com/docs/reference/api/errors/
@constructor
@param {String} [message]
@param {String} [type]
@param {Number} [code]
@param {Number} [subcode]
@api public | [
"SquiddioTokenError",
"error",
"."
] | f2a7b1defde5b82240a53817c42327a6e9a7ca5b | https://github.com/mauroc/passport-squiddio/blob/f2a7b1defde5b82240a53817c42327a6e9a7ca5b/lib/errors/squiddiotokenerror.js#L18-L27 |
55,432 | mcdonnelldean/metalsmith-move-up | lib/plugin.js | onNextTransform | function onNextTransform (transform, next) {
// check if we should handle this filePath
function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
}
// transform the path
function process (filePath, complete) {
var filename = path.basename(filePath),
pathParts = path.dirname(filePath).split(path.sep)
// we'll get an empty arrary if we overslice
pathParts = pathParts.slice(transform.by)
pathParts.push(filename)
var newPath = pathParts.join(path.sep),
fileData = files[filePath]
// don't need the old fileData anymore,
// since we are re-adding with the new path
delete files[filePath]
files[newPath] = fileData
complete()
}
// we do this for each option as the last may have modified the collection
async.filter(Object.keys(files), shouldProcess, function (results) {
async.each(results, process, next)
})
} | javascript | function onNextTransform (transform, next) {
// check if we should handle this filePath
function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
}
// transform the path
function process (filePath, complete) {
var filename = path.basename(filePath),
pathParts = path.dirname(filePath).split(path.sep)
// we'll get an empty arrary if we overslice
pathParts = pathParts.slice(transform.by)
pathParts.push(filename)
var newPath = pathParts.join(path.sep),
fileData = files[filePath]
// don't need the old fileData anymore,
// since we are re-adding with the new path
delete files[filePath]
files[newPath] = fileData
complete()
}
// we do this for each option as the last may have modified the collection
async.filter(Object.keys(files), shouldProcess, function (results) {
async.each(results, process, next)
})
} | [
"function",
"onNextTransform",
"(",
"transform",
",",
"next",
")",
"{",
"// check if we should handle this filePath\r",
"function",
"shouldProcess",
"(",
"filePath",
",",
"done",
")",
"{",
"done",
"(",
"!",
"!",
"multimatch",
"(",
"filePath",
",",
"transform",
"."... | will be called once per transform | [
"will",
"be",
"called",
"once",
"per",
"transform"
] | 32457e76fe8736318e6edda2172fa7721068d827 | https://github.com/mcdonnelldean/metalsmith-move-up/blob/32457e76fe8736318e6edda2172fa7721068d827/lib/plugin.js#L64-L94 |
55,433 | mcdonnelldean/metalsmith-move-up | lib/plugin.js | shouldProcess | function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
} | javascript | function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
} | [
"function",
"shouldProcess",
"(",
"filePath",
",",
"done",
")",
"{",
"done",
"(",
"!",
"!",
"multimatch",
"(",
"filePath",
",",
"transform",
".",
"pattern",
",",
"transform",
".",
"opts",
")",
".",
"length",
")",
"}"
] | check if we should handle this filePath | [
"check",
"if",
"we",
"should",
"handle",
"this",
"filePath"
] | 32457e76fe8736318e6edda2172fa7721068d827 | https://github.com/mcdonnelldean/metalsmith-move-up/blob/32457e76fe8736318e6edda2172fa7721068d827/lib/plugin.js#L66-L68 |
55,434 | mcdonnelldean/metalsmith-move-up | lib/plugin.js | process | function process (filePath, complete) {
var filename = path.basename(filePath),
pathParts = path.dirname(filePath).split(path.sep)
// we'll get an empty arrary if we overslice
pathParts = pathParts.slice(transform.by)
pathParts.push(filename)
var newPath = pathParts.join(path.sep),
fileData = files[filePath]
// don't need the old fileData anymore,
// since we are re-adding with the new path
delete files[filePath]
files[newPath] = fileData
complete()
} | javascript | function process (filePath, complete) {
var filename = path.basename(filePath),
pathParts = path.dirname(filePath).split(path.sep)
// we'll get an empty arrary if we overslice
pathParts = pathParts.slice(transform.by)
pathParts.push(filename)
var newPath = pathParts.join(path.sep),
fileData = files[filePath]
// don't need the old fileData anymore,
// since we are re-adding with the new path
delete files[filePath]
files[newPath] = fileData
complete()
} | [
"function",
"process",
"(",
"filePath",
",",
"complete",
")",
"{",
"var",
"filename",
"=",
"path",
".",
"basename",
"(",
"filePath",
")",
",",
"pathParts",
"=",
"path",
".",
"dirname",
"(",
"filePath",
")",
".",
"split",
"(",
"path",
".",
"sep",
")",
... | transform the path | [
"transform",
"the",
"path"
] | 32457e76fe8736318e6edda2172fa7721068d827 | https://github.com/mcdonnelldean/metalsmith-move-up/blob/32457e76fe8736318e6edda2172fa7721068d827/lib/plugin.js#L71-L88 |
55,435 | byu-oit/sans-server | bin/server/response.js | Response | function Response(request, key) {
// define private store
const store = {
body: '',
cookies: [],
headers: {},
key: key,
sent: false,
statusCode: 0
};
this[STORE] = store;
/**
* The request that is tied to this response.
* @name Response#req
* @type {Request}
*/
Object.defineProperty(this, 'req', {
configurable: false,
enumerable: true,
value: request
});
/**
* Determine if the response has already been sent.
* @name Response#sent
* @type {boolean}
*/
Object.defineProperty(this, 'sent', {
enumerable: true,
get: () => store.sent
});
/**
* Get the server instance that initialized this response.
* @name Request#server
* @type {SansServer}
*/
Object.defineProperty(this, 'server', {
enumerable: true,
configurable: false,
value: request.server
});
/**
* Get a copy of the current response state.
* @name Response#state
* @type {ResponseState}
*/
Object.defineProperty(this, 'state', {
configurable: false,
enumerable: true,
get: () => {
return {
body: store.body,
cookies: store.cookies.concat(),
headers: Object.assign({}, store.headers),
rawHeaders: rawHeaders(store.headers, store.cookies),
statusCode: store.statusCode
}
}
});
/**
* Get or set the status code.
* @name Response#statusCode
* @type {number}
*/
Object.defineProperty(this, 'statusCode', {
configurable: false,
enumerable: true,
get: () => store.statusCode,
set: v => this.status(v)
});
/**
* Produce a log event.
* @param {string} message
* @param {...*} [arg]
* @returns {Response}
* @fires Response#log
*/
this.log = request.logger('sans-server', 'response', this);
} | javascript | function Response(request, key) {
// define private store
const store = {
body: '',
cookies: [],
headers: {},
key: key,
sent: false,
statusCode: 0
};
this[STORE] = store;
/**
* The request that is tied to this response.
* @name Response#req
* @type {Request}
*/
Object.defineProperty(this, 'req', {
configurable: false,
enumerable: true,
value: request
});
/**
* Determine if the response has already been sent.
* @name Response#sent
* @type {boolean}
*/
Object.defineProperty(this, 'sent', {
enumerable: true,
get: () => store.sent
});
/**
* Get the server instance that initialized this response.
* @name Request#server
* @type {SansServer}
*/
Object.defineProperty(this, 'server', {
enumerable: true,
configurable: false,
value: request.server
});
/**
* Get a copy of the current response state.
* @name Response#state
* @type {ResponseState}
*/
Object.defineProperty(this, 'state', {
configurable: false,
enumerable: true,
get: () => {
return {
body: store.body,
cookies: store.cookies.concat(),
headers: Object.assign({}, store.headers),
rawHeaders: rawHeaders(store.headers, store.cookies),
statusCode: store.statusCode
}
}
});
/**
* Get or set the status code.
* @name Response#statusCode
* @type {number}
*/
Object.defineProperty(this, 'statusCode', {
configurable: false,
enumerable: true,
get: () => store.statusCode,
set: v => this.status(v)
});
/**
* Produce a log event.
* @param {string} message
* @param {...*} [arg]
* @returns {Response}
* @fires Response#log
*/
this.log = request.logger('sans-server', 'response', this);
} | [
"function",
"Response",
"(",
"request",
",",
"key",
")",
"{",
"// define private store",
"const",
"store",
"=",
"{",
"body",
":",
"''",
",",
"cookies",
":",
"[",
"]",
",",
"headers",
":",
"{",
"}",
",",
"key",
":",
"key",
",",
"sent",
":",
"false",
... | Create a response instance.
@param {Request} request The request that is relying on this response that is being created.
@param {Symbol} key
@returns {Response}
@constructor | [
"Create",
"a",
"response",
"instance",
"."
] | 022bcf7b47321e6e8aa20467cd96a6a84a457ec8 | https://github.com/byu-oit/sans-server/blob/022bcf7b47321e6e8aa20467cd96a6a84a457ec8/bin/server/response.js#L33-L118 |
55,436 | bfontaine/tp.js | lib/mocha.js | text | function text(el, str) {
if (el.textContent) {
el.textContent = str;
} else {
el.innerText = str;
}
} | javascript | function text(el, str) {
if (el.textContent) {
el.textContent = str;
} else {
el.innerText = str;
}
} | [
"function",
"text",
"(",
"el",
",",
"str",
")",
"{",
"if",
"(",
"el",
".",
"textContent",
")",
"{",
"el",
".",
"textContent",
"=",
"str",
";",
"}",
"else",
"{",
"el",
".",
"innerText",
"=",
"str",
";",
"}",
"}"
] | Set `el` text to `str`. | [
"Set",
"el",
"text",
"to",
"str",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L2451-L2457 |
55,437 | bfontaine/tp.js | lib/mocha.js | map | function map(cov) {
var ret = {
instrumentation: 'node-jscoverage'
, sloc: 0
, hits: 0
, misses: 0
, coverage: 0
, files: []
};
for (var filename in cov) {
var data = coverage(filename, cov[filename]);
ret.files.push(data);
ret.hits += data.hits;
ret.misses += data.misses;
ret.sloc += data.sloc;
}
ret.files.sort(function(a, b) {
return a.filename.localeCompare(b.filename);
});
if (ret.sloc > 0) {
ret.coverage = (ret.hits / ret.sloc) * 100;
}
return ret;
} | javascript | function map(cov) {
var ret = {
instrumentation: 'node-jscoverage'
, sloc: 0
, hits: 0
, misses: 0
, coverage: 0
, files: []
};
for (var filename in cov) {
var data = coverage(filename, cov[filename]);
ret.files.push(data);
ret.hits += data.hits;
ret.misses += data.misses;
ret.sloc += data.sloc;
}
ret.files.sort(function(a, b) {
return a.filename.localeCompare(b.filename);
});
if (ret.sloc > 0) {
ret.coverage = (ret.hits / ret.sloc) * 100;
}
return ret;
} | [
"function",
"map",
"(",
"cov",
")",
"{",
"var",
"ret",
"=",
"{",
"instrumentation",
":",
"'node-jscoverage'",
",",
"sloc",
":",
"0",
",",
"hits",
":",
"0",
",",
"misses",
":",
"0",
",",
"coverage",
":",
"0",
",",
"files",
":",
"[",
"]",
"}",
";",... | Map jscoverage data to a JSON structure
suitable for reporting.
@param {Object} cov
@return {Object}
@api private | [
"Map",
"jscoverage",
"data",
"to",
"a",
"JSON",
"structure",
"suitable",
"for",
"reporting",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L2561-L2588 |
55,438 | bfontaine/tp.js | lib/mocha.js | coverage | function coverage(filename, data) {
var ret = {
filename: filename,
coverage: 0,
hits: 0,
misses: 0,
sloc: 0,
source: {}
};
data.source.forEach(function(line, num){
num++;
if (data[num] === 0) {
ret.misses++;
ret.sloc++;
} else if (data[num] !== undefined) {
ret.hits++;
ret.sloc++;
}
ret.source[num] = {
source: line
, coverage: data[num] === undefined
? ''
: data[num]
};
});
ret.coverage = ret.hits / ret.sloc * 100;
return ret;
} | javascript | function coverage(filename, data) {
var ret = {
filename: filename,
coverage: 0,
hits: 0,
misses: 0,
sloc: 0,
source: {}
};
data.source.forEach(function(line, num){
num++;
if (data[num] === 0) {
ret.misses++;
ret.sloc++;
} else if (data[num] !== undefined) {
ret.hits++;
ret.sloc++;
}
ret.source[num] = {
source: line
, coverage: data[num] === undefined
? ''
: data[num]
};
});
ret.coverage = ret.hits / ret.sloc * 100;
return ret;
} | [
"function",
"coverage",
"(",
"filename",
",",
"data",
")",
"{",
"var",
"ret",
"=",
"{",
"filename",
":",
"filename",
",",
"coverage",
":",
"0",
",",
"hits",
":",
"0",
",",
"misses",
":",
"0",
",",
"sloc",
":",
"0",
",",
"source",
":",
"{",
"}",
... | Map jscoverage data for a single source file
to a JSON structure suitable for reporting.
@param {String} filename name of the source file
@param {Object} data jscoverage coverage data
@return {Object}
@api private | [
"Map",
"jscoverage",
"data",
"for",
"a",
"single",
"source",
"file",
"to",
"a",
"JSON",
"structure",
"suitable",
"for",
"reporting",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L2600-L2632 |
55,439 | bfontaine/tp.js | lib/mocha.js | TAP | function TAP(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, n = 1
, passes = 0
, failures = 0;
runner.on('start', function(){
var total = runner.grepTotal(runner.suite);
console.log('%d..%d', 1, total);
});
runner.on('test end', function(){
++n;
});
runner.on('pending', function(test){
console.log('ok %d %s # SKIP -', n, title(test));
});
runner.on('pass', function(test){
passes++;
console.log('ok %d %s', n, title(test));
});
runner.on('fail', function(test, err){
failures++;
console.log('not ok %d %s', n, title(test));
if (err.stack) console.log(err.stack.replace(/^/gm, ' '));
});
runner.on('end', function(){
console.log('# tests ' + (passes + failures));
console.log('# pass ' + passes);
console.log('# fail ' + failures);
});
} | javascript | function TAP(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, n = 1
, passes = 0
, failures = 0;
runner.on('start', function(){
var total = runner.grepTotal(runner.suite);
console.log('%d..%d', 1, total);
});
runner.on('test end', function(){
++n;
});
runner.on('pending', function(test){
console.log('ok %d %s # SKIP -', n, title(test));
});
runner.on('pass', function(test){
passes++;
console.log('ok %d %s', n, title(test));
});
runner.on('fail', function(test, err){
failures++;
console.log('not ok %d %s', n, title(test));
if (err.stack) console.log(err.stack.replace(/^/gm, ' '));
});
runner.on('end', function(){
console.log('# tests ' + (passes + failures));
console.log('# pass ' + passes);
console.log('# fail ' + failures);
});
} | [
"function",
"TAP",
"(",
"runner",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
")",
";",
"var",
"self",
"=",
"this",
",",
"stats",
"=",
"this",
".",
"stats",
",",
"n",
"=",
"1",
",",
"passes",
"=",
"0",
",",
"failures",
"=",
"0",
... | Initialize a new `TAP` reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"TAP",
"reporter",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L3584-L3622 |
55,440 | bfontaine/tp.js | lib/mocha.js | Teamcity | function Teamcity(runner) {
Base.call(this, runner);
var stats = this.stats;
runner.on('start', function() {
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']");
});
runner.on('fail', function(test, err) {
console.log("##teamcity[testFailed name='" + escape(test.fullTitle()) + "' message='" + escape(err.message) + "']");
});
runner.on('pending', function(test) {
console.log("##teamcity[testIgnored name='" + escape(test.fullTitle()) + "' message='pending']");
});
runner.on('test end', function(test) {
console.log("##teamcity[testFinished name='" + escape(test.fullTitle()) + "' duration='" + test.duration + "']");
});
runner.on('end', function() {
console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + stats.duration + "']");
});
} | javascript | function Teamcity(runner) {
Base.call(this, runner);
var stats = this.stats;
runner.on('start', function() {
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']");
});
runner.on('fail', function(test, err) {
console.log("##teamcity[testFailed name='" + escape(test.fullTitle()) + "' message='" + escape(err.message) + "']");
});
runner.on('pending', function(test) {
console.log("##teamcity[testIgnored name='" + escape(test.fullTitle()) + "' message='pending']");
});
runner.on('test end', function(test) {
console.log("##teamcity[testFinished name='" + escape(test.fullTitle()) + "' duration='" + test.duration + "']");
});
runner.on('end', function() {
console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + stats.duration + "']");
});
} | [
"function",
"Teamcity",
"(",
"runner",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
")",
";",
"var",
"stats",
"=",
"this",
".",
"stats",
";",
"runner",
".",
"on",
"(",
"'start'",
",",
"function",
"(",
")",
"{",
"console",
".",
"log",
... | Initialize a new `Teamcity` reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"Teamcity",
"reporter",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L3659-L3686 |
55,441 | bfontaine/tp.js | lib/mocha.js | XUnit | function XUnit(runner) {
Base.call(this, runner);
var stats = this.stats
, tests = []
, self = this;
runner.on('pass', function(test){
tests.push(test);
});
runner.on('fail', function(test){
tests.push(test);
});
runner.on('end', function(){
console.log(tag('testsuite', {
name: 'Mocha Tests'
, tests: stats.tests
, failures: stats.failures
, errors: stats.failures
, skip: stats.tests - stats.failures - stats.passes
, timestamp: (new Date).toUTCString()
, time: stats.duration / 1000
}, false));
tests.forEach(test);
console.log('</testsuite>');
});
} | javascript | function XUnit(runner) {
Base.call(this, runner);
var stats = this.stats
, tests = []
, self = this;
runner.on('pass', function(test){
tests.push(test);
});
runner.on('fail', function(test){
tests.push(test);
});
runner.on('end', function(){
console.log(tag('testsuite', {
name: 'Mocha Tests'
, tests: stats.tests
, failures: stats.failures
, errors: stats.failures
, skip: stats.tests - stats.failures - stats.passes
, timestamp: (new Date).toUTCString()
, time: stats.duration / 1000
}, false));
tests.forEach(test);
console.log('</testsuite>');
});
} | [
"function",
"XUnit",
"(",
"runner",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
")",
";",
"var",
"stats",
"=",
"this",
".",
"stats",
",",
"tests",
"=",
"[",
"]",
",",
"self",
"=",
"this",
";",
"runner",
".",
"on",
"(",
"'pass'",
... | Initialize a new `XUnit` reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"XUnit",
"reporter",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L3740-L3768 |
55,442 | bfontaine/tp.js | lib/mocha.js | Runner | function Runner(suite) {
var self = this;
this._globals = [];
this.suite = suite;
this.total = suite.total();
this.failures = 0;
this.on('test end', function(test){ self.checkGlobals(test); });
this.on('hook end', function(hook){ self.checkGlobals(hook); });
this.grep(/.*/);
this.globals(this.globalProps().concat(['errno']));
} | javascript | function Runner(suite) {
var self = this;
this._globals = [];
this.suite = suite;
this.total = suite.total();
this.failures = 0;
this.on('test end', function(test){ self.checkGlobals(test); });
this.on('hook end', function(hook){ self.checkGlobals(hook); });
this.grep(/.*/);
this.globals(this.globalProps().concat(['errno']));
} | [
"function",
"Runner",
"(",
"suite",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_globals",
"=",
"[",
"]",
";",
"this",
".",
"suite",
"=",
"suite",
";",
"this",
".",
"total",
"=",
"suite",
".",
"total",
"(",
")",
";",
"this",
".",
"... | Initialize a `Runner` for the given `suite`.
Events:
- `start` execution started
- `end` execution complete
- `suite` (suite) test suite execution started
- `suite end` (suite) all tests (and sub-suites) have finished
- `test` (test) test execution started
- `test end` (test) test completed
- `hook` (hook) hook execution started
- `hook end` (hook) hook complete
- `pass` (test) test passed
- `fail` (test, err) test failed
@api public | [
"Initialize",
"a",
"Runner",
"for",
"the",
"given",
"suite",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L4109-L4119 |
55,443 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/comment.js | function( filter, context ) {
var comment = this.value;
if ( !( comment = filter.onComment( context, comment, this ) ) ) {
this.remove();
return false;
}
if ( typeof comment != 'string' ) {
this.replaceWith( comment );
return false;
}
this.value = comment;
return true;
} | javascript | function( filter, context ) {
var comment = this.value;
if ( !( comment = filter.onComment( context, comment, this ) ) ) {
this.remove();
return false;
}
if ( typeof comment != 'string' ) {
this.replaceWith( comment );
return false;
}
this.value = comment;
return true;
} | [
"function",
"(",
"filter",
",",
"context",
")",
"{",
"var",
"comment",
"=",
"this",
".",
"value",
";",
"if",
"(",
"!",
"(",
"comment",
"=",
"filter",
".",
"onComment",
"(",
"context",
",",
"comment",
",",
"this",
")",
")",
")",
"{",
"this",
".",
... | Filter this comment with given filter.
@since 4.1
@param {CKEDITOR.htmlParser.filter} filter
@returns {Boolean} Method returns `false` when this comment has
been removed or replaced with other node. This is an information for
{@link CKEDITOR.htmlParser.element#filterChildren} that it has
to repeat filter on current position in parent's children array. | [
"Filter",
"this",
"comment",
"with",
"given",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/comment.js#L49-L65 | |
55,444 | techhead/mmm | mmm.js | getExistsSync | function getExistsSync(path, exts) {
for (var i=0,len=exts.length; i<len; i++) {
if (fs.existsSync(path + exts[i])) {
return path + exts[i];
}
}
return false;
} | javascript | function getExistsSync(path, exts) {
for (var i=0,len=exts.length; i<len; i++) {
if (fs.existsSync(path + exts[i])) {
return path + exts[i];
}
}
return false;
} | [
"function",
"getExistsSync",
"(",
"path",
",",
"exts",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"exts",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"path",
"+",
"... | Takes a path and array of file extensions
and returns the first path + extension that exists
or returns false. | [
"Takes",
"a",
"path",
"and",
"array",
"of",
"file",
"extensions",
"and",
"returns",
"the",
"first",
"path",
"+",
"extension",
"that",
"exists",
"or",
"returns",
"false",
"."
] | 0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46 | https://github.com/techhead/mmm/blob/0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46/mmm.js#L75-L82 |
55,445 | techhead/mmm | mmm.js | extend | function extend(a,b) {
var c = clone(a);
for (var key in b) {
c[key] = b[key];
}
return c;
} | javascript | function extend(a,b) {
var c = clone(a);
for (var key in b) {
c[key] = b[key];
}
return c;
} | [
"function",
"extend",
"(",
"a",
",",
"b",
")",
"{",
"var",
"c",
"=",
"clone",
"(",
"a",
")",
";",
"for",
"(",
"var",
"key",
"in",
"b",
")",
"{",
"c",
"[",
"key",
"]",
"=",
"b",
"[",
"key",
"]",
";",
"}",
"return",
"c",
";",
"}"
] | Return a new object that inherits from `a`
and also contains the properties of `b`. | [
"Return",
"a",
"new",
"object",
"that",
"inherits",
"from",
"a",
"and",
"also",
"contains",
"the",
"properties",
"of",
"b",
"."
] | 0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46 | https://github.com/techhead/mmm/blob/0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46/mmm.js#L129-L135 |
55,446 | dominikwilkowski/grunt-wakeup | tasks/wakeup.js | randomize | function randomize( obj ) {
var j = 0,
i = Math.floor(Math.random() * (Object.keys(obj).length)),
result;
for(var property in obj) {
if(j === i) {
result = property;
break;
}
j++;
}
return result;
} | javascript | function randomize( obj ) {
var j = 0,
i = Math.floor(Math.random() * (Object.keys(obj).length)),
result;
for(var property in obj) {
if(j === i) {
result = property;
break;
}
j++;
}
return result;
} | [
"function",
"randomize",
"(",
"obj",
")",
"{",
"var",
"j",
"=",
"0",
",",
"i",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"(",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"length",
")",
")",
",",
"result",
";",
"fo... | get random value off of an object | [
"get",
"random",
"value",
"off",
"of",
"an",
"object"
] | 0558a2853316630b2793215fe5dd560abbac045a | https://github.com/dominikwilkowski/grunt-wakeup/blob/0558a2853316630b2793215fe5dd560abbac045a/tasks/wakeup.js#L18-L33 |
55,447 | beyo/events | lib/events.js | _createEventRangeValidator | function _createEventRangeValidator(range) {
var ctxRange = _createRangeArray(range);
return function rangeValidator(range) {
var leftIndex = 0;
var rightIndex = 0;
var left;
var right;
for (; leftIndex < ctxRange.length && rightIndex < range.length; ) {
left = ctxRange[leftIndex];
right = range[rightIndex];
if (left.max < right.min) {
++leftIndex;
} else if ((left.min <= right.min || left.max >= right.max) &&
((left.min > right.min && (right.min !== Number.MIN_VALUE)) ||
(left.max < right.max) && (right.max !== Infinity))) {
return false;
} else {
++rightIndex;
}
}
return (rightIndex >= range.length);
};
} | javascript | function _createEventRangeValidator(range) {
var ctxRange = _createRangeArray(range);
return function rangeValidator(range) {
var leftIndex = 0;
var rightIndex = 0;
var left;
var right;
for (; leftIndex < ctxRange.length && rightIndex < range.length; ) {
left = ctxRange[leftIndex];
right = range[rightIndex];
if (left.max < right.min) {
++leftIndex;
} else if ((left.min <= right.min || left.max >= right.max) &&
((left.min > right.min && (right.min !== Number.MIN_VALUE)) ||
(left.max < right.max) && (right.max !== Infinity))) {
return false;
} else {
++rightIndex;
}
}
return (rightIndex >= range.length);
};
} | [
"function",
"_createEventRangeValidator",
"(",
"range",
")",
"{",
"var",
"ctxRange",
"=",
"_createRangeArray",
"(",
"range",
")",
";",
"return",
"function",
"rangeValidator",
"(",
"range",
")",
"{",
"var",
"leftIndex",
"=",
"0",
";",
"var",
"rightIndex",
"=",
... | Create a range validator. The returned value is a function validating if
a given range matches this range | [
"Create",
"a",
"range",
"validator",
".",
"The",
"returned",
"value",
"is",
"a",
"function",
"validating",
"if",
"a",
"given",
"range",
"matches",
"this",
"range"
] | a5d82b1e3dc5cff012ec15dd0bf0a593ce316bf6 | https://github.com/beyo/events/blob/a5d82b1e3dc5cff012ec15dd0bf0a593ce316bf6/lib/events.js#L258-L284 |
55,448 | tgolen/skelenode-swagger | respond.js | sendSPrintFError | function sendSPrintFError(res, errorArray, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = errorArray;
return sendError(res, obj, code, internalCode);
} | javascript | function sendSPrintFError(res, errorArray, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = errorArray;
return sendError(res, obj, code, internalCode);
} | [
"function",
"sendSPrintFError",
"(",
"res",
",",
"errorArray",
",",
"code",
",",
"internalCode",
")",
"{",
"var",
"obj",
"=",
"{",
"success",
":",
"false",
"}",
";",
"obj",
"[",
"res",
"?",
"'description'",
":",
"'reason'",
"]",
"=",
"errorArray",
";",
... | Sends a SPrintF formatted error to the user. Otherwise, behaves the same as sendStringError.
@param res Optional Express Response object.
@param errorArray The first element should be a string; subsequent args are formatted in to the first string.
@param code The HTTP Status code to send (like 404, 403, etc).
@param internalCode An optional internal code to also send to the client. This is useful for programmatic use of the API so we can do non-string-based comparisons.
@return {*} If no res is provided, the error JSON object will be returned; otherwise, the results of res.send are returned. | [
"Sends",
"a",
"SPrintF",
"formatted",
"error",
"to",
"the",
"user",
".",
"Otherwise",
"behaves",
"the",
"same",
"as",
"sendStringError",
"."
] | 9b8caa81d32b492b26d1bec34ce49ab015afd8bd | https://github.com/tgolen/skelenode-swagger/blob/9b8caa81d32b492b26d1bec34ce49ab015afd8bd/respond.js#L128-L132 |
55,449 | tgolen/skelenode-swagger | respond.js | sendStringError | function sendStringError(res, error, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = error;
return sendError(res, obj, code, internalCode);
} | javascript | function sendStringError(res, error, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = error;
return sendError(res, obj, code, internalCode);
} | [
"function",
"sendStringError",
"(",
"res",
",",
"error",
",",
"code",
",",
"internalCode",
")",
"{",
"var",
"obj",
"=",
"{",
"success",
":",
"false",
"}",
";",
"obj",
"[",
"res",
"?",
"'description'",
":",
"'reason'",
"]",
"=",
"error",
";",
"return",
... | Sends a string error to the user. Attempts to localize it.
@param res Optional Express Response object.
@param error The error to send to the user. If it's a string, it will be localized.
@param code The HTTP Status code to send (like 404, 403, etc).
@param internalCode An optional internal code to also send to the client. This is useful for programmatic use of the API so we can do non-string-based comparisons. | [
"Sends",
"a",
"string",
"error",
"to",
"the",
"user",
".",
"Attempts",
"to",
"localize",
"it",
"."
] | 9b8caa81d32b492b26d1bec34ce49ab015afd8bd | https://github.com/tgolen/skelenode-swagger/blob/9b8caa81d32b492b26d1bec34ce49ab015afd8bd/respond.js#L141-L145 |
55,450 | TempoIQ/tempoiq-node-js | lib/models/device.js | Device | function Device(key, params) {
var p = params || {};
// The primary key of the device [String]
this.key = key;
// Human readable name of the device [String] EG - "My Device"
this.name = p.name || "";
// Indexable attributes. Useful for grouping related Devices.
// EG - {location: '445-w-Erie', model: 'TX75', region: 'Southwest'}
this.attributes = p.attributes || {};
this.sensors = p.sensors || [];
} | javascript | function Device(key, params) {
var p = params || {};
// The primary key of the device [String]
this.key = key;
// Human readable name of the device [String] EG - "My Device"
this.name = p.name || "";
// Indexable attributes. Useful for grouping related Devices.
// EG - {location: '445-w-Erie', model: 'TX75', region: 'Southwest'}
this.attributes = p.attributes || {};
this.sensors = p.sensors || [];
} | [
"function",
"Device",
"(",
"key",
",",
"params",
")",
"{",
"var",
"p",
"=",
"params",
"||",
"{",
"}",
";",
"// The primary key of the device [String]",
"this",
".",
"key",
"=",
"key",
";",
"// Human readable name of the device [String] EG - \"My Device\"",
"this",
"... | The top level container for a group of sensors. | [
"The",
"top",
"level",
"container",
"for",
"a",
"group",
"of",
"sensors",
"."
] | b3ab72f9d7760a54df9ef75093d349b28a29864c | https://github.com/TempoIQ/tempoiq-node-js/blob/b3ab72f9d7760a54df9ef75093d349b28a29864c/lib/models/device.js#L4-L16 |
55,451 | benzhou1/iod | lib/send.js | function(err, httpRes, body) {
if (err) _callback(err)
else {
try { var res = JSON.parse(body) }
catch(err) { _callback(null, body) }
if (httpRes && httpRes.statusCode !== 200) {
maybeRetry(res, IOD, IODOpts, apiType, _callback)
}
else _callback(null, res)
}
} | javascript | function(err, httpRes, body) {
if (err) _callback(err)
else {
try { var res = JSON.parse(body) }
catch(err) { _callback(null, body) }
if (httpRes && httpRes.statusCode !== 200) {
maybeRetry(res, IOD, IODOpts, apiType, _callback)
}
else _callback(null, res)
}
} | [
"function",
"(",
"err",
",",
"httpRes",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"_callback",
"(",
"err",
")",
"else",
"{",
"try",
"{",
"var",
"res",
"=",
"JSON",
".",
"parse",
"(",
"body",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"_callba... | Callback for handling request.
Errors if response from IOD server is not 200.
Attempts to JSON parse response body on success, returns original body if
fail to parse.
@param {*} err - Request error
@param {Object} httpRes - Request http response object
@param {*} body - Request body | [
"Callback",
"for",
"handling",
"request",
".",
"Errors",
"if",
"response",
"from",
"IOD",
"server",
"is",
"not",
"200",
".",
"Attempts",
"to",
"JSON",
"parse",
"response",
"body",
"on",
"success",
"returns",
"original",
"body",
"if",
"fail",
"to",
"parse",
... | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L48-L59 | |
55,452 | benzhou1/iod | lib/send.js | maybeRetry | function maybeRetry(err, IOD, IODOpts, apiType, callback) {
var retryApiReq = apiType !== IOD.TYPES.SYNC &&
apiType !== IOD.TYPES.RESULT &&
apiType !== IOD.TYPES.DISCOVERY
if (IODOpts.retries == null || retryApiReq) callback(err)
else if (!--IODOpts.retries) callback(err)
var reqTypeDontRetry = apiType !== IOD.TYPES.SYNC &&
apiType !== IOD.TYPES.DISCOVERY &&
apiType !== IOD.TYPES.RESULT
if (IODOpts.retries == null || reqTypeDontRetry) callback(err)
else if (!IODOpts.retries--) callback(err)
else {
var errCode = err.error
var errCodeList = T.maybeToArray(IODOpts.errorCodes)
// Backend request failed or timed out
if (errCode === 5000 || errCode === 7000 || _.contains(errCodeList, errCode)) {
exports.send(IOD, IODOpts, apiType, callback)
}
else callback(err)
}
} | javascript | function maybeRetry(err, IOD, IODOpts, apiType, callback) {
var retryApiReq = apiType !== IOD.TYPES.SYNC &&
apiType !== IOD.TYPES.RESULT &&
apiType !== IOD.TYPES.DISCOVERY
if (IODOpts.retries == null || retryApiReq) callback(err)
else if (!--IODOpts.retries) callback(err)
var reqTypeDontRetry = apiType !== IOD.TYPES.SYNC &&
apiType !== IOD.TYPES.DISCOVERY &&
apiType !== IOD.TYPES.RESULT
if (IODOpts.retries == null || reqTypeDontRetry) callback(err)
else if (!IODOpts.retries--) callback(err)
else {
var errCode = err.error
var errCodeList = T.maybeToArray(IODOpts.errorCodes)
// Backend request failed or timed out
if (errCode === 5000 || errCode === 7000 || _.contains(errCodeList, errCode)) {
exports.send(IOD, IODOpts, apiType, callback)
}
else callback(err)
}
} | [
"function",
"maybeRetry",
"(",
"err",
",",
"IOD",
",",
"IODOpts",
",",
"apiType",
",",
"callback",
")",
"{",
"var",
"retryApiReq",
"=",
"apiType",
"!==",
"IOD",
".",
"TYPES",
".",
"SYNC",
"&&",
"apiType",
"!==",
"IOD",
".",
"TYPES",
".",
"RESULT",
"&&"... | If retries is specified on `IODOpts` and is greater than one,
retry request if it is either a Backend failure or time out.
@param {*} err - Error
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {String} apiType - Api type
@param {Function} callback - callback(err | res) | [
"If",
"retries",
"is",
"specified",
"on",
"IODOpts",
"and",
"is",
"greater",
"than",
"one",
"retry",
"request",
"if",
"it",
"is",
"either",
"a",
"Backend",
"failure",
"or",
"time",
"out",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L91-L114 |
55,453 | benzhou1/iod | lib/send.js | makeOptions | function makeOptions(IOD, IODOpts, apiType, reqOpts) {
var path = IodU.makePath(IOD, IODOpts, apiType)
var method = apiType === IOD.TYPES.JOB || !_.isEmpty(IODOpts.files) ?
'post' : IODOpts.method.toLowerCase()
return _.defaults({
url: IOD.host + ':' + IOD.port + path,
path: path,
method: method,
// For 'get' request use request `qs` property.
qs: method === 'get' ?
_.defaults({ apiKey: IOD.apiKey }, exports.prepareParams(IODOpts.params)) : undefined,
// For 'post' request with no files use `form` property
form: method === 'post' && !IODOpts.files ?
_.defaults({ apiKey: IOD.apiKey }, exports.prepareParams(IODOpts.params)) : undefined
}, reqOpts, IOD.reqOpts)
} | javascript | function makeOptions(IOD, IODOpts, apiType, reqOpts) {
var path = IodU.makePath(IOD, IODOpts, apiType)
var method = apiType === IOD.TYPES.JOB || !_.isEmpty(IODOpts.files) ?
'post' : IODOpts.method.toLowerCase()
return _.defaults({
url: IOD.host + ':' + IOD.port + path,
path: path,
method: method,
// For 'get' request use request `qs` property.
qs: method === 'get' ?
_.defaults({ apiKey: IOD.apiKey }, exports.prepareParams(IODOpts.params)) : undefined,
// For 'post' request with no files use `form` property
form: method === 'post' && !IODOpts.files ?
_.defaults({ apiKey: IOD.apiKey }, exports.prepareParams(IODOpts.params)) : undefined
}, reqOpts, IOD.reqOpts)
} | [
"function",
"makeOptions",
"(",
"IOD",
",",
"IODOpts",
",",
"apiType",
",",
"reqOpts",
")",
"{",
"var",
"path",
"=",
"IodU",
".",
"makePath",
"(",
"IOD",
",",
"IODOpts",
",",
"apiType",
")",
"var",
"method",
"=",
"apiType",
"===",
"IOD",
".",
"TYPES",
... | Creates a request options object with.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {String} apiType - IOD request type
@param {Object} reqOpts - Request options for current request
@returns {Object} Request options object | [
"Creates",
"a",
"request",
"options",
"object",
"with",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L125-L143 |
55,454 | benzhou1/iod | lib/send.js | addParamsToData | function addParamsToData(IOD, IODOpts, form) {
form.append('apiKey', IOD.apiKey)
_.each(exports.prepareParams(IODOpts.params), function(paramVal, paramName) {
_.each(T.maybeToArray(paramVal), function(val) {
form.append(paramName, val)
})
})
} | javascript | function addParamsToData(IOD, IODOpts, form) {
form.append('apiKey', IOD.apiKey)
_.each(exports.prepareParams(IODOpts.params), function(paramVal, paramName) {
_.each(T.maybeToArray(paramVal), function(val) {
form.append(paramName, val)
})
})
} | [
"function",
"addParamsToData",
"(",
"IOD",
",",
"IODOpts",
",",
"form",
")",
"{",
"form",
".",
"append",
"(",
"'apiKey'",
",",
"IOD",
".",
"apiKey",
")",
"_",
".",
"each",
"(",
"exports",
".",
"prepareParams",
"(",
"IODOpts",
".",
"params",
")",
",",
... | Add parameters to FormData object.
Automatically append api key.
Modifies `IODOpts` in place.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {FormData} form - FormData object | [
"Add",
"parameters",
"to",
"FormData",
"object",
".",
"Automatically",
"append",
"api",
"key",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L155-L163 |
55,455 | benzhou1/iod | lib/send.js | addFilesToData | function addFilesToData(IOD, IODOpts, apiType, form) {
_.each(T.maybeToArray(IODOpts.files), function(file) {
if (apiType === IOD.TYPES.JOB) {
form.append(file.name, fs.createReadStream(file.path))
}
else form.append('file', fs.createReadStream(file))
})
} | javascript | function addFilesToData(IOD, IODOpts, apiType, form) {
_.each(T.maybeToArray(IODOpts.files), function(file) {
if (apiType === IOD.TYPES.JOB) {
form.append(file.name, fs.createReadStream(file.path))
}
else form.append('file', fs.createReadStream(file))
})
} | [
"function",
"addFilesToData",
"(",
"IOD",
",",
"IODOpts",
",",
"apiType",
",",
"form",
")",
"{",
"_",
".",
"each",
"(",
"T",
".",
"maybeToArray",
"(",
"IODOpts",
".",
"files",
")",
",",
"function",
"(",
"file",
")",
"{",
"if",
"(",
"apiType",
"===",
... | Add files to FormData object.
Modifies `IODOpts` in place.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {String} apiType - IOD request type
@param {FormData} form - FormData object | [
"Add",
"files",
"to",
"FormData",
"object",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L175-L182 |
55,456 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/fakeobjects/plugin.js | replaceCssLength | function replaceCssLength( length1, length2 ) {
var parts1 = cssLengthRegex.exec( length1 ),
parts2 = cssLengthRegex.exec( length2 );
// Omit pixel length unit when necessary,
// e.g. replaceCssLength( 10, '20px' ) -> 20
if ( parts1 ) {
if ( !parts1[ 2 ] && parts2[ 2 ] == 'px' )
return parts2[ 1 ];
if ( parts1[ 2 ] == 'px' && !parts2[ 2 ] )
return parts2[ 1 ] + 'px';
}
return length2;
} | javascript | function replaceCssLength( length1, length2 ) {
var parts1 = cssLengthRegex.exec( length1 ),
parts2 = cssLengthRegex.exec( length2 );
// Omit pixel length unit when necessary,
// e.g. replaceCssLength( 10, '20px' ) -> 20
if ( parts1 ) {
if ( !parts1[ 2 ] && parts2[ 2 ] == 'px' )
return parts2[ 1 ];
if ( parts1[ 2 ] == 'px' && !parts2[ 2 ] )
return parts2[ 1 ] + 'px';
}
return length2;
} | [
"function",
"replaceCssLength",
"(",
"length1",
",",
"length2",
")",
"{",
"var",
"parts1",
"=",
"cssLengthRegex",
".",
"exec",
"(",
"length1",
")",
",",
"parts2",
"=",
"cssLengthRegex",
".",
"exec",
"(",
"length2",
")",
";",
"// Omit pixel length unit when neces... | Replacing the former CSS length value with the later one, with adjustment to the length unit. | [
"Replacing",
"the",
"former",
"CSS",
"length",
"value",
"with",
"the",
"later",
"one",
"with",
"adjustment",
"to",
"the",
"length",
"unit",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/fakeobjects/plugin.js#L14-L28 |
55,457 | phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/UiComponent.js | function() {
var results = [];
for (var i=0, cs=this.controls, c; c=cs[i]; i++) {
if (!c.isChrome) {
results.push(c);
}
}
return results;
} | javascript | function() {
var results = [];
for (var i=0, cs=this.controls, c; c=cs[i]; i++) {
if (!c.isChrome) {
results.push(c);
}
}
return results;
} | [
"function",
"(",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"cs",
"=",
"this",
".",
"controls",
",",
"c",
";",
"c",
"=",
"cs",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"c",
"."... | Returns all non-chrome controls. | [
"Returns",
"all",
"non",
"-",
"chrome",
"controls",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/UiComponent.js#L121-L129 | |
55,458 | phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/UiComponent.js | function() {
var c$ = this.getClientControls();
for (var i=0, c; c=c$[i]; i++) {
c.destroy();
}
} | javascript | function() {
var c$ = this.getClientControls();
for (var i=0, c; c=c$[i]; i++) {
c.destroy();
}
} | [
"function",
"(",
")",
"{",
"var",
"c$",
"=",
"this",
".",
"getClientControls",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"c",
";",
"c",
"=",
"c$",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"c",
".",
"destroy",
"(",
")",
";",
"}... | Destroys "client controls", the same set of controls returned by
_getClientControls_. | [
"Destroys",
"client",
"controls",
"the",
"same",
"set",
"of",
"controls",
"returned",
"by",
"_getClientControls_",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/UiComponent.js#L134-L139 | |
55,459 | phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/UiComponent.js | function(inMessage, inPayload, inSender) {
// Note: Controls will generally be both in a $ hash and a child list somewhere.
// Attempt to avoid duplicated messages by sending only to components that are not
// UiComponent, as those components are guaranteed not to be in a child list.
// May cause a problem if there is a scenario where a UiComponent owns a pure
// Component that in turn owns Controls.
//
// waterfall to all pure components
for (var n in this.$) {
if (!(this.$[n] instanceof enyo.UiComponent)) {
this.$[n].waterfall(inMessage, inPayload, inSender);
}
}
// waterfall to my children
for (var i=0, cs=this.children, c; c=cs[i]; i++) {
// Do not send {showingOnly: true} events to hidden controls. This flag is set for resize events
// which are broadcast from within the framework. This saves a *lot* of unnecessary layout.
// TODO: Maybe remember that we did this, and re-send those messages on setShowing(true)?
// No obvious problems with it as-is, though
if (c.showing || !(inPayload && inPayload.showingOnly)) {
c.waterfall(inMessage, inPayload, inSender);
}
}
} | javascript | function(inMessage, inPayload, inSender) {
// Note: Controls will generally be both in a $ hash and a child list somewhere.
// Attempt to avoid duplicated messages by sending only to components that are not
// UiComponent, as those components are guaranteed not to be in a child list.
// May cause a problem if there is a scenario where a UiComponent owns a pure
// Component that in turn owns Controls.
//
// waterfall to all pure components
for (var n in this.$) {
if (!(this.$[n] instanceof enyo.UiComponent)) {
this.$[n].waterfall(inMessage, inPayload, inSender);
}
}
// waterfall to my children
for (var i=0, cs=this.children, c; c=cs[i]; i++) {
// Do not send {showingOnly: true} events to hidden controls. This flag is set for resize events
// which are broadcast from within the framework. This saves a *lot* of unnecessary layout.
// TODO: Maybe remember that we did this, and re-send those messages on setShowing(true)?
// No obvious problems with it as-is, though
if (c.showing || !(inPayload && inPayload.showingOnly)) {
c.waterfall(inMessage, inPayload, inSender);
}
}
} | [
"function",
"(",
"inMessage",
",",
"inPayload",
",",
"inSender",
")",
"{",
"// Note: Controls will generally be both in a $ hash and a child list somewhere.",
"// Attempt to avoid duplicated messages by sending only to components that are not",
"// UiComponent, as those components are guarante... | Sends a message to all my descendents. | [
"Sends",
"a",
"message",
"to",
"all",
"my",
"descendents",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/UiComponent.js#L246-L269 | |
55,460 | 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]) {
ext = ext.slice(1);
}
return urljoin(stub, options.buildFileName(name, ext, stamp));
} | 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]) {
ext = ext.slice(1);
}
return urljoin(stub, options.buildFileName(name, ext, stamp));
} | [
"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 | |
55,461 | 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 realm = '_default';
if (typeof opts.realm !== 'undefined') {
if (typeof opts.realm !== 'string') { throw new TypeError('opts.realm must be a string'); }
realm = opts.realm;
}
if (typeof opts.debug !== 'undefined' && typeof opts.debug !== 'boolean') { throw new TypeError('opts.debug must be a boolean'); }
if (typeof opts.hide !== 'undefined' && typeof opts.hide !== 'boolean') { throw new TypeError('opts.hide must be a boolean'); }
if (username.length < 2) { throw new Error('username must be at least 2 characters'); }
if (username.length > 128) { throw new Error('username can not exceed 128 characters'); }
if (realm.length < 1) { throw new Error('opts.realm must be at least 1 character'); }
if (realm.length > 128) { throw new Error('opts.realm can not exceed 128 characters'); }
this._db = db;
this._username = username;
this._realm = realm;
this._debug = opts.debug || false;
this._hide = opts.hide || false;
// keys that should be mapped from the user object that is stored in the user db
this._protectedDbKeys = {
realm: true,
username: true,
password: true
};
// keys that can not be used in the user object that is stored in the user db
this._illegalDbKeys = {
_protectedDbKeys: true,
_illegalDbKeys: true,
_db: true,
_debug: true,
_hide: true
};
} | 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 realm = '_default';
if (typeof opts.realm !== 'undefined') {
if (typeof opts.realm !== 'string') { throw new TypeError('opts.realm must be a string'); }
realm = opts.realm;
}
if (typeof opts.debug !== 'undefined' && typeof opts.debug !== 'boolean') { throw new TypeError('opts.debug must be a boolean'); }
if (typeof opts.hide !== 'undefined' && typeof opts.hide !== 'boolean') { throw new TypeError('opts.hide must be a boolean'); }
if (username.length < 2) { throw new Error('username must be at least 2 characters'); }
if (username.length > 128) { throw new Error('username can not exceed 128 characters'); }
if (realm.length < 1) { throw new Error('opts.realm must be at least 1 character'); }
if (realm.length > 128) { throw new Error('opts.realm can not exceed 128 characters'); }
this._db = db;
this._username = username;
this._realm = realm;
this._debug = opts.debug || false;
this._hide = opts.hide || false;
// keys that should be mapped from the user object that is stored in the user db
this._protectedDbKeys = {
realm: true,
username: true,
password: true
};
// keys that can not be used in the user object that is stored in the user db
this._illegalDbKeys = {
_protectedDbKeys: true,
_illegalDbKeys: true,
_db: true,
_debug: true,
_hide: true
};
} | [
"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 parameters
opts:
realm {String, default "_default"} optional realm the user belongs to
debug {Boolean, default false} whether to do extra console logging or not
hide {Boolean, default false} whether to suppress errors or not (for testing)
Three functions db must support:
find should accept: lookup, callback
lookup {Object}:
realm {String}
username {String}
callback {Function} should call back with:
err {Object} error object or null
user {Object} user object
updateHash should accept: lookup, hash, callback
lookup {Object}:
realm {String}
username {String}
hash {String} bcrypt hash
callback {Function} should call back with:
err {Object} error object or null
insert should accept: user, callback
user {Object}:
realm {String}
username {String}
callback {Function} should call back with:
err {Object} error object or null | [
"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 |
55,462 | 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 | |
55,463 | 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 |
55,464 | 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 ) {
proc.stdout.on( 'data', function onStdout( data ) {
stdo += data.toString();
} );
}
proc.on( 'error', function( err ) {
unpipe();
if ( options.ignoreError ) {
resolve( { out: stdo, code: 0 } );
} else {
printError( err, args );
reject( err );
}
} );
proc.on( 'exit', function( code ) {
unpipe();
} );
proc.on( 'close', function( code ) {
unpipe();
if ( code !== 0 && !options.ignoreError ) {
if ( !options.quiet ) {
printError( '', args );
}
reject( new Error( "Error running git" ) );
} else {
resolve( { out: stdo, code: code } );
}
} );
} );
} | 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 ) {
proc.stdout.on( 'data', function onStdout( data ) {
stdo += data.toString();
} );
}
proc.on( 'error', function( err ) {
unpipe();
if ( options.ignoreError ) {
resolve( { out: stdo, code: 0 } );
} else {
printError( err, args );
reject( err );
}
} );
proc.on( 'exit', function( code ) {
unpipe();
} );
proc.on( 'close', function( code ) {
unpipe();
if ( code !== 0 && !options.ignoreError ) {
if ( !options.quiet ) {
printError( '', args );
}
reject( new Error( "Error running git" ) );
} else {
resolve( { out: stdo, code: code } );
}
} );
} );
} | [
"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 |
55,465 | 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 found.');
return;
}
buf.unshift(filepath);
if(filepath.indexOf('.css') != -1){ //if depend a css file
buf.unshift(CSSFILE_HOLDER);
return;
}
var dependencies = parseDependencies(grunt.file.read(filepath));
if (dependencies.length) {
var i = dependencies.length;
while (i--) {
parse(dependencies[i], filepath, data);
}
}
}
filepath.forEach(function(filepath){
var fileContent = grunt.file.read(filepath);
parseDependencies(fileContent).forEach(function(id){
parse(id, filepath, data);
})
})
//filter the same file
return buf.filter(function(value, index, self){
return self.indexOf(value) === index;
});
} | 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 found.');
return;
}
buf.unshift(filepath);
if(filepath.indexOf('.css') != -1){ //if depend a css file
buf.unshift(CSSFILE_HOLDER);
return;
}
var dependencies = parseDependencies(grunt.file.read(filepath));
if (dependencies.length) {
var i = dependencies.length;
while (i--) {
parse(dependencies[i], filepath, data);
}
}
}
filepath.forEach(function(filepath){
var fileContent = grunt.file.read(filepath);
parseDependencies(fileContent).forEach(function(id){
parse(id, filepath, data);
})
})
//filter the same file
return buf.filter(function(value, index, self){
return self.indexOf(value) === index;
});
} | [
"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 | |
55,466 | 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]);
}
}
return results;
} | 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]);
}
}
return results;
} | [
"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 |
55,467 | 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 |
55,468 | 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 |
55,469 | 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 html = [],
requiredClass = elementDefinition.required ? ' cke_required' : '';
if ( elementDefinition.labelLayout != 'horizontal' ) {
html.push(
'<label class="cke_dialog_ui_labeled_label' + requiredClass + '" ', ' id="' + _.labelId + '"',
( _.inputId ? ' for="' + _.inputId + '"' : '' ),
( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) + '>',
elementDefinition.label,
'</label>',
'<div class="cke_dialog_ui_labeled_content"',
( elementDefinition.controlStyle ? ' style="' + elementDefinition.controlStyle + '"' : '' ),
' role="presentation">',
contentHtml.call( this, dialog, elementDefinition ),
'</div>' );
} else {
var hboxDefinition = {
type: 'hbox',
widths: elementDefinition.widths,
padding: 0,
children: [
{
type: 'html',
html: '<label class="cke_dialog_ui_labeled_label' + requiredClass + '"' +
' id="' + _.labelId + '"' +
' for="' + _.inputId + '"' +
( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) + '>' +
CKEDITOR.tools.htmlEncode( elementDefinition.label ) +
'</span>'
},
{
type: 'html',
html: '<span class="cke_dialog_ui_labeled_content"' + ( elementDefinition.controlStyle ? ' style="' + elementDefinition.controlStyle + '"' : '' ) + '>' +
contentHtml.call( this, dialog, elementDefinition ) +
'</span>'
}
]
};
CKEDITOR.dialog._.uiElementBuilders.hbox.build( dialog, hboxDefinition, html );
}
return html.join( '' );
};
var attributes = { role: elementDefinition.role || 'presentation' };
if ( elementDefinition.includeLabel )
attributes[ 'aria-labelledby' ] = _.labelId;
CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'div', null, attributes, innerHTML );
} | 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 html = [],
requiredClass = elementDefinition.required ? ' cke_required' : '';
if ( elementDefinition.labelLayout != 'horizontal' ) {
html.push(
'<label class="cke_dialog_ui_labeled_label' + requiredClass + '" ', ' id="' + _.labelId + '"',
( _.inputId ? ' for="' + _.inputId + '"' : '' ),
( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) + '>',
elementDefinition.label,
'</label>',
'<div class="cke_dialog_ui_labeled_content"',
( elementDefinition.controlStyle ? ' style="' + elementDefinition.controlStyle + '"' : '' ),
' role="presentation">',
contentHtml.call( this, dialog, elementDefinition ),
'</div>' );
} else {
var hboxDefinition = {
type: 'hbox',
widths: elementDefinition.widths,
padding: 0,
children: [
{
type: 'html',
html: '<label class="cke_dialog_ui_labeled_label' + requiredClass + '"' +
' id="' + _.labelId + '"' +
' for="' + _.inputId + '"' +
( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) + '>' +
CKEDITOR.tools.htmlEncode( elementDefinition.label ) +
'</span>'
},
{
type: 'html',
html: '<span class="cke_dialog_ui_labeled_content"' + ( elementDefinition.controlStyle ? ' style="' + elementDefinition.controlStyle + '"' : '' ) + '>' +
contentHtml.call( this, dialog, elementDefinition ) +
'</span>'
}
]
};
CKEDITOR.dialog._.uiElementBuilders.hbox.build( dialog, hboxDefinition, html );
}
return html.join( '' );
};
var attributes = { role: elementDefinition.role || 'presentation' };
if ( elementDefinition.includeLabel )
attributes[ 'aria-labelledby' ] = _.labelId;
CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'div', null, attributes, innerHTML );
} | [
"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} elementDefinition
The element definition. Accepted fields:
* `label` (Required) The label string.
* `labelLayout` (Optional) Put 'horizontal' here if the
label element is to be laid out horizontally. Otherwise a vertical
layout will be used.
* `widths` (Optional) This applies only to horizontal
layouts — a two-element array of lengths to specify the widths of the
label and the content element.
* `role` (Optional) Value for the `role` attribute.
* `includeLabel` (Optional) If set to `true`, the `aria-labelledby` attribute
will be included.
@param {Array} htmlList The list of HTML code to output to.
@param {Function} contentHtml
A function returning the HTML code string to be added inside the content
cell. | [
"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 | |
55,470 | 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, type: elementDefinition.type },
i;
// Set the validator, if any.
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
// Set the max length and size.
if ( elementDefinition.maxLength )
attributes.maxlength = elementDefinition.maxLength;
if ( elementDefinition.size )
attributes.size = elementDefinition.size;
if ( elementDefinition.inputStyle )
attributes.style = elementDefinition.inputStyle;
// If user presses Enter in a text box, it implies clicking OK for the dialog.
var me = this,
keyPressedOnMe = false;
dialog.on( 'load', function() {
me.getInputElement().on( 'keydown', function( evt ) {
if ( evt.data.getKeystroke() == 13 )
keyPressedOnMe = true;
} );
// Lower the priority this 'keyup' since 'ok' will close the dialog.(#3749)
me.getInputElement().on( 'keyup', function( evt ) {
if ( evt.data.getKeystroke() == 13 && keyPressedOnMe ) {
dialog.getButton( 'ok' ) && setTimeout( function() {
dialog.getButton( 'ok' ).click();
}, 0 );
keyPressedOnMe = false;
}
}, null, null, 1000 );
} );
var innerHTML = function() {
// IE BUG: Text input fields in IE at 100% would exceed a <td> or inline
// container's width, so need to wrap it inside a <div>.
var html = [ '<div class="cke_dialog_ui_input_', elementDefinition.type, '" role="presentation"' ];
if ( elementDefinition.width )
html.push( 'style="width:' + elementDefinition.width + '" ' );
html.push( '><input ' );
attributes[ 'aria-labelledby' ] = this._.labelId;
this._.required && ( attributes[ 'aria-required' ] = this._.required );
for ( var i in attributes )
html.push( i + '="' + attributes[ i ] + '" ' );
html.push( ' /></div>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | 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, type: elementDefinition.type },
i;
// Set the validator, if any.
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
// Set the max length and size.
if ( elementDefinition.maxLength )
attributes.maxlength = elementDefinition.maxLength;
if ( elementDefinition.size )
attributes.size = elementDefinition.size;
if ( elementDefinition.inputStyle )
attributes.style = elementDefinition.inputStyle;
// If user presses Enter in a text box, it implies clicking OK for the dialog.
var me = this,
keyPressedOnMe = false;
dialog.on( 'load', function() {
me.getInputElement().on( 'keydown', function( evt ) {
if ( evt.data.getKeystroke() == 13 )
keyPressedOnMe = true;
} );
// Lower the priority this 'keyup' since 'ok' will close the dialog.(#3749)
me.getInputElement().on( 'keyup', function( evt ) {
if ( evt.data.getKeystroke() == 13 && keyPressedOnMe ) {
dialog.getButton( 'ok' ) && setTimeout( function() {
dialog.getButton( 'ok' ).click();
}, 0 );
keyPressedOnMe = false;
}
}, null, null, 1000 );
} );
var innerHTML = function() {
// IE BUG: Text input fields in IE at 100% would exceed a <td> or inline
// container's width, so need to wrap it inside a <div>.
var html = [ '<div class="cke_dialog_ui_input_', elementDefinition.type, '" role="presentation"' ];
if ( elementDefinition.width )
html.push( 'style="width:' + elementDefinition.width + '" ' );
html.push( '><input ' );
attributes[ 'aria-labelledby' ] = this._.labelId;
this._.required && ( attributes[ 'aria-required' ] = this._.required );
for ( var i in attributes )
html.push( i + '="' + attributes[ i ] + '" ' );
html.push( ' /></div>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | [
"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.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element definition. Accepted fields:
* `default` (Optional) The default value.
* `validate` (Optional) The validation function.
* `maxLength` (Optional) The maximum length of text box contents.
* `size` (Optional) The size of the text box. This is
usually overridden by the size defined by the skin, though.
@param {Array} htmlList List of HTML code to output to. | [
"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 | |
55,471 | 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 )
this.validate = elementDefinition.validate;
// Generates the essential attributes for the textarea tag.
attributes.rows = elementDefinition.rows || 5;
attributes.cols = elementDefinition.cols || 20;
attributes[ 'class' ] = 'cke_dialog_ui_input_textarea ' + ( elementDefinition[ 'class' ] || '' );
if ( typeof elementDefinition.inputStyle != 'undefined' )
attributes.style = elementDefinition.inputStyle;
if ( elementDefinition.dir )
attributes.dir = elementDefinition.dir;
var innerHTML = function() {
attributes[ 'aria-labelledby' ] = this._.labelId;
this._.required && ( attributes[ 'aria-required' ] = this._.required );
var html = [ '<div class="cke_dialog_ui_input_textarea" role="presentation"><textarea id="', domId, '" ' ];
for ( var i in attributes )
html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[ i ] ) + '" ' );
html.push( '>', CKEDITOR.tools.htmlEncode( me._[ 'default' ] ), '</textarea></div>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | 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 )
this.validate = elementDefinition.validate;
// Generates the essential attributes for the textarea tag.
attributes.rows = elementDefinition.rows || 5;
attributes.cols = elementDefinition.cols || 20;
attributes[ 'class' ] = 'cke_dialog_ui_input_textarea ' + ( elementDefinition[ 'class' ] || '' );
if ( typeof elementDefinition.inputStyle != 'undefined' )
attributes.style = elementDefinition.inputStyle;
if ( elementDefinition.dir )
attributes.dir = elementDefinition.dir;
var innerHTML = function() {
attributes[ 'aria-labelledby' ] = this._.labelId;
this._.required && ( attributes[ 'aria-required' ] = this._.required );
var html = [ '<div class="cke_dialog_ui_input_textarea" role="presentation"><textarea id="', domId, '" ' ];
for ( var i in attributes )
html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[ i ] ) + '" ' );
html.push( '>', CKEDITOR.tools.htmlEncode( me._[ 'default' ] ), '</textarea></div>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | [
"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 definition. Accepted fields:
* `rows` (Optional) The number of rows displayed.
Defaults to 5 if not defined.
* `cols` (Optional) The number of cols displayed.
Defaults to 20 if not defined. Usually overridden by skins.
* `default` (Optional) The default value.
* `validate` (Optional) The validation function.
@param {Array} htmlList List of HTML code to output to. | [
"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 | |
55,472 | 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 innerHTML = function() {
var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition, {
id: elementDefinition.id ? elementDefinition.id + '_checkbox' : CKEDITOR.tools.getNextId() + '_checkbox'
}, true ),
html = [];
var labelId = CKEDITOR.tools.getNextId() + '_label';
var attributes = { 'class': 'cke_dialog_ui_checkbox_input', type: 'checkbox', 'aria-labelledby': labelId };
cleanInnerDefinition( myDefinition );
if ( elementDefinition[ 'default' ] )
attributes.checked = 'checked';
if ( typeof myDefinition.inputStyle != 'undefined' )
myDefinition.style = myDefinition.inputStyle;
_.checkbox = new CKEDITOR.ui.dialog.uiElement( dialog, myDefinition, html, 'input', null, attributes );
html.push( ' <label id="', labelId, '" for="', attributes.id, '"' + ( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) + '>', CKEDITOR.tools.htmlEncode( elementDefinition.label ), '</label>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'span', null, null, innerHTML );
} | 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 innerHTML = function() {
var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition, {
id: elementDefinition.id ? elementDefinition.id + '_checkbox' : CKEDITOR.tools.getNextId() + '_checkbox'
}, true ),
html = [];
var labelId = CKEDITOR.tools.getNextId() + '_label';
var attributes = { 'class': 'cke_dialog_ui_checkbox_input', type: 'checkbox', 'aria-labelledby': labelId };
cleanInnerDefinition( myDefinition );
if ( elementDefinition[ 'default' ] )
attributes.checked = 'checked';
if ( typeof myDefinition.inputStyle != 'undefined' )
myDefinition.style = myDefinition.inputStyle;
_.checkbox = new CKEDITOR.ui.dialog.uiElement( dialog, myDefinition, html, 'input', null, attributes );
html.push( ' <label id="', labelId, '" for="', attributes.id, '"' + ( elementDefinition.labelStyle ? ' style="' + elementDefinition.labelStyle + '"' : '' ) + '>', CKEDITOR.tools.htmlEncode( elementDefinition.label ), '</label>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'span', null, null, innerHTML );
} | [
"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. Accepted fields:
* `checked` (Optional) Whether the checkbox is checked
on instantiation. Defaults to `false`.
* `validate` (Optional) The validation function.
* `label` (Optional) The checkbox label.
@param {Array} htmlList List of HTML code to output to. | [
"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 | |
55,473 | 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 )
this.validate = elementDefinition.valdiate;
var children = [],
me = this;
var innerHTML = function() {
var inputHtmlList = [],
html = [],
commonName = ( elementDefinition.id ? elementDefinition.id : CKEDITOR.tools.getNextId() ) + '_radio';
for ( var i = 0; i < elementDefinition.items.length; i++ ) {
var item = elementDefinition.items[ i ],
title = item[ 2 ] !== undefined ? item[ 2 ] : item[ 0 ],
value = item[ 1 ] !== undefined ? item[ 1 ] : item[ 0 ],
inputId = CKEDITOR.tools.getNextId() + '_radio_input',
labelId = inputId + '_label',
inputDefinition = CKEDITOR.tools.extend( {}, elementDefinition, {
id: inputId,
title: null,
type: null
}, true ),
labelDefinition = CKEDITOR.tools.extend( {}, inputDefinition, {
title: title
}, true ),
inputAttributes = {
type: 'radio',
'class': 'cke_dialog_ui_radio_input',
name: commonName,
value: value,
'aria-labelledby': labelId
},
inputHtml = [];
if ( me._[ 'default' ] == value )
inputAttributes.checked = 'checked';
cleanInnerDefinition( inputDefinition );
cleanInnerDefinition( labelDefinition );
if ( typeof inputDefinition.inputStyle != 'undefined' )
inputDefinition.style = inputDefinition.inputStyle;
// Make inputs of radio type focusable (#10866).
inputDefinition.keyboardFocusable = true;
children.push( new CKEDITOR.ui.dialog.uiElement( dialog, inputDefinition, inputHtml, 'input', null, inputAttributes ) );
inputHtml.push( ' ' );
new CKEDITOR.ui.dialog.uiElement( dialog, labelDefinition, inputHtml, 'label', null, {
id: labelId,
'for': inputAttributes.id
}, item[ 0 ] );
inputHtmlList.push( inputHtml.join( '' ) );
}
new CKEDITOR.ui.dialog.hbox( dialog, children, inputHtmlList, html );
return html.join( '' );
};
// Adding a role="radiogroup" to definition used for wrapper.
elementDefinition.role = 'radiogroup';
elementDefinition.includeLabel = true;
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
this._.children = children;
} | 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 )
this.validate = elementDefinition.valdiate;
var children = [],
me = this;
var innerHTML = function() {
var inputHtmlList = [],
html = [],
commonName = ( elementDefinition.id ? elementDefinition.id : CKEDITOR.tools.getNextId() ) + '_radio';
for ( var i = 0; i < elementDefinition.items.length; i++ ) {
var item = elementDefinition.items[ i ],
title = item[ 2 ] !== undefined ? item[ 2 ] : item[ 0 ],
value = item[ 1 ] !== undefined ? item[ 1 ] : item[ 0 ],
inputId = CKEDITOR.tools.getNextId() + '_radio_input',
labelId = inputId + '_label',
inputDefinition = CKEDITOR.tools.extend( {}, elementDefinition, {
id: inputId,
title: null,
type: null
}, true ),
labelDefinition = CKEDITOR.tools.extend( {}, inputDefinition, {
title: title
}, true ),
inputAttributes = {
type: 'radio',
'class': 'cke_dialog_ui_radio_input',
name: commonName,
value: value,
'aria-labelledby': labelId
},
inputHtml = [];
if ( me._[ 'default' ] == value )
inputAttributes.checked = 'checked';
cleanInnerDefinition( inputDefinition );
cleanInnerDefinition( labelDefinition );
if ( typeof inputDefinition.inputStyle != 'undefined' )
inputDefinition.style = inputDefinition.inputStyle;
// Make inputs of radio type focusable (#10866).
inputDefinition.keyboardFocusable = true;
children.push( new CKEDITOR.ui.dialog.uiElement( dialog, inputDefinition, inputHtml, 'input', null, inputAttributes ) );
inputHtml.push( ' ' );
new CKEDITOR.ui.dialog.uiElement( dialog, labelDefinition, inputHtml, 'label', null, {
id: labelId,
'for': inputAttributes.id
}, item[ 0 ] );
inputHtmlList.push( inputHtml.join( '' ) );
}
new CKEDITOR.ui.dialog.hbox( dialog, children, inputHtmlList, html );
return html.join( '' );
};
// Adding a role="radiogroup" to definition used for wrapper.
elementDefinition.role = 'radiogroup';
elementDefinition.includeLabel = true;
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
this._.children = children;
} | [
"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:
* `default` (Required) The default value.
* `validate` (Optional) The validation function.
* `items` (Required) An array of options. Each option
is a one- or two-item array of format `[ 'Description', 'Value' ]`. If `'Value'`
is missing, then the value would be assumed to be the same as the description.
@param {Array} htmlList List of HTML code to output to. | [
"A",
"group",
"of",
"radio",
"buttons",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L387-L469 | |
55,474 | 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 || false } );
// Add OnClick event to this input.
CKEDITOR.event.implementOn( this );
var me = this;
// Register an event handler for processing button clicks.
dialog.on( 'load', function( eventInfo ) {
var element = this.getElement();
( function() {
element.on( 'click', function( evt ) {
me.click();
// #9958
evt.data.preventDefault();
} );
element.on( 'keydown', function( evt ) {
if ( evt.data.getKeystroke() in { 32: 1 } ) {
me.click();
evt.data.preventDefault();
}
} );
} )();
element.unselectable();
}, this );
var outerDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
delete outerDefinition.style;
var labelId = CKEDITOR.tools.getNextId() + '_label';
CKEDITOR.ui.dialog.uiElement.call( this, dialog, outerDefinition, htmlList, 'a', null, {
style: elementDefinition.style,
href: 'javascript:void(0)',
title: elementDefinition.label,
hidefocus: 'true',
'class': elementDefinition[ 'class' ],
role: 'button',
'aria-labelledby': labelId
}, '<span id="' + labelId + '" class="cke_dialog_ui_button">' +
CKEDITOR.tools.htmlEncode( elementDefinition.label ) +
'</span>' );
} | javascript | function( dialog, elementDefinition, htmlList ) {
if ( !arguments.length )
return;
if ( typeof elementDefinition == 'function' )
elementDefinition = elementDefinition( dialog.getParentEditor() );
initPrivateObject.call( this, elementDefinition, { disabled: elementDefinition.disabled || false } );
// Add OnClick event to this input.
CKEDITOR.event.implementOn( this );
var me = this;
// Register an event handler for processing button clicks.
dialog.on( 'load', function( eventInfo ) {
var element = this.getElement();
( function() {
element.on( 'click', function( evt ) {
me.click();
// #9958
evt.data.preventDefault();
} );
element.on( 'keydown', function( evt ) {
if ( evt.data.getKeystroke() in { 32: 1 } ) {
me.click();
evt.data.preventDefault();
}
} );
} )();
element.unselectable();
}, this );
var outerDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
delete outerDefinition.style;
var labelId = CKEDITOR.tools.getNextId() + '_label';
CKEDITOR.ui.dialog.uiElement.call( this, dialog, outerDefinition, htmlList, 'a', null, {
style: elementDefinition.style,
href: 'javascript:void(0)',
title: elementDefinition.label,
hidefocus: 'true',
'class': elementDefinition[ 'class' ],
role: 'button',
'aria-labelledby': labelId
}, '<span id="' + labelId + '" class="cke_dialog_ui_button">' +
CKEDITOR.tools.htmlEncode( elementDefinition.label ) +
'</span>' );
} | [
"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:
* `label` (Required) The button label.
* `disabled` (Optional) Set to `true` if you want the
button to appear in the disabled state.
@param {Array} htmlList List of HTML code to output to. | [
"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 | |
55,475 | 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';
var innerHTML = function() {
var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition, {
id: elementDefinition.id ? elementDefinition.id + '_select' : CKEDITOR.tools.getNextId() + '_select'
}, true ),
html = [],
innerHTML = [],
attributes = { 'id': _.inputId, 'class': 'cke_dialog_ui_input_select', 'aria-labelledby': this._.labelId };
html.push( '<div class="cke_dialog_ui_input_', elementDefinition.type, '" role="presentation"' );
if ( elementDefinition.width )
html.push( 'style="width:' + elementDefinition.width + '" ' );
html.push( '>' );
// Add multiple and size attributes from element definition.
if ( elementDefinition.size != undefined )
attributes.size = elementDefinition.size;
if ( elementDefinition.multiple != undefined )
attributes.multiple = elementDefinition.multiple;
cleanInnerDefinition( myDefinition );
for ( var i = 0, item; i < elementDefinition.items.length && ( item = elementDefinition.items[ i ] ); i++ ) {
innerHTML.push( '<option value="', CKEDITOR.tools.htmlEncode( item[ 1 ] !== undefined ? item[ 1 ] : item[ 0 ] ).replace( /"/g, '"' ), '" /> ', CKEDITOR.tools.htmlEncode( item[ 0 ] ) );
}
if ( typeof myDefinition.inputStyle != 'undefined' )
myDefinition.style = myDefinition.inputStyle;
_.select = new CKEDITOR.ui.dialog.uiElement( dialog, myDefinition, html, 'select', null, attributes, innerHTML.join( '' ) );
html.push( '</div>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | 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';
var innerHTML = function() {
var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition, {
id: elementDefinition.id ? elementDefinition.id + '_select' : CKEDITOR.tools.getNextId() + '_select'
}, true ),
html = [],
innerHTML = [],
attributes = { 'id': _.inputId, 'class': 'cke_dialog_ui_input_select', 'aria-labelledby': this._.labelId };
html.push( '<div class="cke_dialog_ui_input_', elementDefinition.type, '" role="presentation"' );
if ( elementDefinition.width )
html.push( 'style="width:' + elementDefinition.width + '" ' );
html.push( '>' );
// Add multiple and size attributes from element definition.
if ( elementDefinition.size != undefined )
attributes.size = elementDefinition.size;
if ( elementDefinition.multiple != undefined )
attributes.multiple = elementDefinition.multiple;
cleanInnerDefinition( myDefinition );
for ( var i = 0, item; i < elementDefinition.items.length && ( item = elementDefinition.items[ i ] ); i++ ) {
innerHTML.push( '<option value="', CKEDITOR.tools.htmlEncode( item[ 1 ] !== undefined ? item[ 1 ] : item[ 0 ] ).replace( /"/g, '"' ), '" /> ', CKEDITOR.tools.htmlEncode( item[ 0 ] ) );
}
if ( typeof myDefinition.inputStyle != 'undefined' )
myDefinition.style = myDefinition.inputStyle;
_.select = new CKEDITOR.ui.dialog.uiElement( dialog, myDefinition, html, 'select', null, attributes, innerHTML.join( '' ) );
html.push( '</div>' );
return html.join( '' );
};
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | [
"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) The default value.
* `validate` (Optional) The validation function.
* `items` (Required) An array of options. Each option
is a one- or two-item array of format `[ 'Description', 'Value' ]`. If `'Value'`
is missing, then the value would be assumed to be the same as the
description.
* `multiple` (Optional) Set this to `true` if you would like
to have a multiple-choice select box.
* `size` (Optional) The number of items to display in
the select box.
@param {Array} htmlList List of HTML code to output to. | [
"A",
"select",
"box",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L563-L609 | |
55,476 | 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, buttons: [] } );
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
/** @ignore */
var innerHTML = function() {
_.frameId = CKEDITOR.tools.getNextId() + '_fileInput';
var html = [
'<iframe' +
' frameborder="0"' +
' allowtransparency="0"' +
' class="cke_dialog_ui_input_file"' +
' role="presentation"' +
' id="', _.frameId, '"' +
' title="', elementDefinition.label, '"' +
' src="javascript:void(' ];
// Support for custom document.domain on IE. (#10165)
html.push( CKEDITOR.env.ie ?
'(function(){' + encodeURIComponent(
'document.open();' +
'(' + CKEDITOR.tools.fixDomain + ')();' +
'document.close();'
) + '})()'
:
'0' );
html.push( ')">' +
'</iframe>' );
return html.join( '' );
};
// IE BUG: Parent container does not resize to contain the iframe automatically.
dialog.on( 'load', function() {
var iframe = CKEDITOR.document.getById( _.frameId ),
contentDiv = iframe.getParent();
contentDiv.addClass( 'cke_dialog_ui_input_file' );
} );
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | 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, buttons: [] } );
if ( elementDefinition.validate )
this.validate = elementDefinition.validate;
/** @ignore */
var innerHTML = function() {
_.frameId = CKEDITOR.tools.getNextId() + '_fileInput';
var html = [
'<iframe' +
' frameborder="0"' +
' allowtransparency="0"' +
' class="cke_dialog_ui_input_file"' +
' role="presentation"' +
' id="', _.frameId, '"' +
' title="', elementDefinition.label, '"' +
' src="javascript:void(' ];
// Support for custom document.domain on IE. (#10165)
html.push( CKEDITOR.env.ie ?
'(function(){' + encodeURIComponent(
'document.open();' +
'(' + CKEDITOR.tools.fixDomain + ')();' +
'document.close();'
) + '})()'
:
'0' );
html.push( ')">' +
'</iframe>' );
return html.join( '' );
};
// IE BUG: Parent container does not resize to contain the iframe automatically.
dialog.on( 'load', function() {
var iframe = CKEDITOR.document.getById( _.frameId ),
contentDiv = iframe.getParent();
contentDiv.addClass( 'cke_dialog_ui_input_file' );
} );
CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
} | [
"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` (Optional) The validation function.
@param {Array} htmlList List of HTML code to output to. | [
"A",
"file",
"upload",
"input",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialogui/plugin.js#L625-L675 | |
55,477 | 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( {}, elementDefinition );
var onClick = myDefinition.onClick;
myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button';
myDefinition.onClick = function( evt ) {
var target = elementDefinition[ 'for' ]; // [ pageId, elementId ]
if ( !onClick || onClick.call( this, evt ) !== false ) {
dialog.getContentElement( target[ 0 ], target[ 1 ] ).submit();
this.disable();
}
};
dialog.on( 'load', function() {
dialog.getContentElement( elementDefinition[ 'for' ][ 0 ], elementDefinition[ 'for' ][ 1 ] )._.buttons.push( me );
} );
CKEDITOR.ui.dialog.button.call( this, dialog, myDefinition, htmlList );
} | 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( {}, elementDefinition );
var onClick = myDefinition.onClick;
myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button';
myDefinition.onClick = function( evt ) {
var target = elementDefinition[ 'for' ]; // [ pageId, elementId ]
if ( !onClick || onClick.call( this, evt ) !== false ) {
dialog.getContentElement( target[ 0 ], target[ 1 ] ).submit();
this.disable();
}
};
dialog.on( 'load', function() {
dialog.getContentElement( elementDefinition[ 'for' ][ 0 ], elementDefinition[ 'for' ][ 1 ] )._.buttons.push( me );
} );
CKEDITOR.ui.dialog.button.call( this, dialog, myDefinition, htmlList );
} | [
"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 definition. Accepted fields:
* `for` (Required) The file input's page and element ID
to associate with, in a two-item array format: `[ 'page_id', 'element_id' ]`.
* `validate` (Optional) The validation function.
@param {Array} htmlList List of HTML code to output to. | [
"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 | |
55,478 | 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.labelStyle + '"' : '' ) +
'>' + legendLabel + '</legend>' );
for ( var i = 0; i < childHtmlList.length; i++ )
html.push( childHtmlList[ i ] );
return html.join( '' );
};
this._ = { children: childObjList };
CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'fieldset', null, null, innerHTML );
} | 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.labelStyle + '"' : '' ) +
'>' + legendLabel + '</legend>' );
for ( var i = 0; i < childHtmlList.length; i++ )
html.push( childHtmlList[ i ] );
return html.join( '' );
};
this._ = { children: childObjList };
CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, htmlList, 'fieldset', null, null, innerHTML );
} | [
"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 this container.
@param {Array} childHtmlList Array of HTML code that corresponds to the HTML output of all the
objects in childObjList.
@param {Array} htmlList Array of HTML code that this element will output to.
@param {CKEDITOR.dialog.definition.uiElement} elementDefinition
The element definition. Accepted fields:
* `label` (Optional) The legend of the this fieldset.
* `children` (Required) An array of dialog window field definitions which will be grouped inside this fieldset. | [
"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 | |
55,479 | 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 | |
55,480 | 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 | |
55,481 | 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 | |
55,482 | 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 | |
55,483 | 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 === undefined || index === null ) {
if ( CKEDITOR.env.ie )
selectElement.add( option.$ );
else
selectElement.add( option.$, null );
} else
selectElement.add( option.$, index );
return this;
} | 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 === undefined || index === null ) {
if ( CKEDITOR.env.ie )
selectElement.add( option.$ );
else
selectElement.add( option.$, null );
} else
selectElement.add( option.$, index );
return this;
} | [
"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 list.
@returns {CKEDITOR.ui.dialog.select} The current select UI element. | [
"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 | |
55,484 | 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 | |
55,485 | 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 | |
55,486 | 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 | |
55,487 | 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 definition ) {
if ( !( match = i.match( regex ) ) )
continue;
if ( this.eventProcessors[ i ] )
this.eventProcessors[ i ].call( this, this._.dialog, definition[ i ] );
else
registerDomEvent( this, this._.dialog, match[ 1 ].toLowerCase(), definition[ i ] );
}
return this;
} | 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 definition ) {
if ( !( match = i.match( regex ) ) )
continue;
if ( this.eventProcessors[ i ] )
this.eventProcessors[ i ].call( this, this._.dialog, definition[ i ] );
else
registerDomEvent( this, this._.dialog, match[ 1 ].toLowerCase(), definition[ i ] );
}
return this;
} | [
"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 | |
55,488 | 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.call(context, arg1, arg2, arg3); return
default:
callback.apply(context, args); return
}
} | 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.call(context, arg1, arg2, arg3); return
default:
callback.apply(context, args); return
}
} | [
"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 | |
55,489 | 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, this.environment);
appSettings.overrides = (options && options.overrides) || window.ADLIB_OVERRIDES || null;
this.deviceDetails = deviceDetector.getDeviceDetails();
// If the script include is placed in the <head> of the page,
// document.body is not ready yet, and we need it to retrieve the token
if (document.body) {
page.preloadToken(this.environment);
}
page.addDomReadyListener(this.environment);
if (options && options.setupGlobalApi) {
//Only when this option is specified, setup the API on the global window
this._setUpGlobalAPI();
}
} | 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, this.environment);
appSettings.overrides = (options && options.overrides) || window.ADLIB_OVERRIDES || null;
this.deviceDetails = deviceDetector.getDeviceDetails();
// If the script include is placed in the <head> of the page,
// document.body is not ready yet, and we need it to retrieve the token
if (document.body) {
page.preloadToken(this.environment);
}
page.addDomReadyListener(this.environment);
if (options && options.setupGlobalApi) {
//Only when this option is specified, setup the API on the global window
this._setUpGlobalAPI();
}
} | [
"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 | |
55,490 | 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 |
55,491 | 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 |
55,492 | 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(anchorToken.type === 'footnote_anchor');
const content = md.renderer.render([inlineToken], md.options, {});
const id = anchorToken.meta.id + 1;
const meta = Object.assign({}, anchorToken.meta, { id });
return Object.assign({}, { content }, meta);
});
} | 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(anchorToken.type === 'footnote_anchor');
const content = md.renderer.render([inlineToken], md.options, {});
const id = anchorToken.meta.id + 1;
const meta = Object.assign({}, anchorToken.meta, { id });
return Object.assign({}, { content }, meta);
});
} | [
"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 |
55,493 | 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: undefined type \'' + typeName + '\'');
}
}
}
else {
// import *
for (let typeName in namespace.names){
if (namespace.names.hasOwnProperty(typeName)){
this.names[typeName] = namespace.names[typeName];
}
}
}
return this;
} | 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: undefined type \'' + typeName + '\'');
}
}
}
else {
// import *
for (let typeName in namespace.names){
if (namespace.names.hasOwnProperty(typeName)){
this.names[typeName] = namespace.names[typeName];
}
}
}
return this;
} | [
"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 | |
55,494 | 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 | |
55,495 | 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 = template;
}
validate(value, options){
return this.template.validate(value, options);
}
}
this.names[typeName] = UserDefinedTemplate;
return this;
} | 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 = template;
}
validate(value, options){
return this.template.validate(value, options);
}
}
this.names[typeName] = UserDefinedTemplate;
return this;
} | [
"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 | |
55,496 | 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 | |
55,497 | 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 | |
55,498 | 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 >= 2) {
min = args[0];
max = args[1];
if (min > max) {
min = args[1];
max = args[0];
}
}
return min + Math.floor(Math.random() * (max - min));
} | 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 >= 2) {
min = args[0];
max = args[1];
if (min > max) {
min = args[1];
max = args[0];
}
}
return min + Math.floor(Math.random() * (max - min));
} | [
"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 | |
55,499 | 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');
}
return thrift.createServer(this.service, this.methods,
{transport: thrift.TBufferedTransport, protocol: thrift.TBinaryProtocol});
} | 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');
}
return thrift.createServer(this.service, this.methods,
{transport: thrift.TBufferedTransport, protocol: thrift.TBinaryProtocol});
} | [
"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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.