repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
thii/abbajs | index.js | function(zCriticalValue) {
var baselineValue = this.baseline.pEstimate(zCriticalValue).value;
var ratio = this.differenceEstimate(zCriticalValue).value / baselineValue;
var error = this.differenceEstimate(zCriticalValue).error / baselineValue;
return new Abba.ValueWithError(ratio, error)... | javascript | function(zCriticalValue) {
var baselineValue = this.baseline.pEstimate(zCriticalValue).value;
var ratio = this.differenceEstimate(zCriticalValue).value / baselineValue;
var error = this.differenceEstimate(zCriticalValue).error / baselineValue;
return new Abba.ValueWithError(ratio, error)... | [
"function",
"(",
"zCriticalValue",
")",
"{",
"var",
"baselineValue",
"=",
"this",
".",
"baseline",
".",
"pEstimate",
"(",
"zCriticalValue",
")",
".",
"value",
";",
"var",
"ratio",
"=",
"this",
".",
"differenceEstimate",
"(",
"zCriticalValue",
")",
".",
"valu... | Return the difference in sucess rates as a proportion of the baseline success rate. | [
"Return",
"the",
"difference",
"in",
"sucess",
"rates",
"as",
"a",
"proportion",
"of",
"the",
"baseline",
"success",
"rate",
"."
] | b75b5d4f0cb6bf920cdec36814b72be1e30cf908 | https://github.com/thii/abbajs/blob/b75b5d4f0cb6bf920cdec36814b72be1e30cf908/index.js#L184-L189 | train | |
DScheglov/merest | lib/controllers/instance-method.js | callInstanceMethod | function callInstanceMethod(methodName, req, res, next) {
res.__apiMethod = 'instanceMethod';
res.__apiInstanceMethod = methodName;
const self = this;
const id = req.params.id;
const methodOptions = this.apiOptions.expose[methodName];
const wrapper = (methodOptions.exec instanceof Function) ?
met... | javascript | function callInstanceMethod(methodName, req, res, next) {
res.__apiMethod = 'instanceMethod';
res.__apiInstanceMethod = methodName;
const self = this;
const id = req.params.id;
const methodOptions = this.apiOptions.expose[methodName];
const wrapper = (methodOptions.exec instanceof Function) ?
met... | [
"function",
"callInstanceMethod",
"(",
"methodName",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"__apiMethod",
"=",
"'instanceMethod'",
";",
"res",
".",
"__apiInstanceMethod",
"=",
"methodName",
";",
"const",
"self",
"=",
"this",
";",
"const"... | callInstanceMethod - calls specific method of model instance
@param {String} methodName the name of the method should be called
@param {express.Request} req the http(s) request
@param {express.Response} res the http(s) response
@param {Function} next the callback should be ca... | [
"callInstanceMethod",
"-",
"calls",
"specific",
"method",
"of",
"model",
"instance"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/controllers/instance-method.js#L16-L50 | train |
theboyWhoCriedWoolf/transition-manager | example/ViewManager.js | fetchView | function fetchView( data, id ) {
data.backgroundColor = randomCol();
data.fontColour = data.backgroundImage? '' : getContrastYIQ( data.backgroundColor );
let wrapper = document.createElement('div');
wrapper.className = 'section hidden';
wrapper.innerHTML = SimpleViewTemplate( data );
wrapper.dataset.id =... | javascript | function fetchView( data, id ) {
data.backgroundColor = randomCol();
data.fontColour = data.backgroundImage? '' : getContrastYIQ( data.backgroundColor );
let wrapper = document.createElement('div');
wrapper.className = 'section hidden';
wrapper.innerHTML = SimpleViewTemplate( data );
wrapper.dataset.id =... | [
"function",
"fetchView",
"(",
"data",
",",
"id",
")",
"{",
"data",
".",
"backgroundColor",
"=",
"randomCol",
"(",
")",
";",
"data",
".",
"fontColour",
"=",
"data",
".",
"backgroundImage",
"?",
"''",
":",
"getContrastYIQ",
"(",
"data",
".",
"backgroundColor... | create and apped a new View
to the DOM prepoppulating with
view data
@param {object} data
@param {int} id - incremented ID
@return {Node} | [
"create",
"and",
"apped",
"a",
"new",
"View",
"to",
"the",
"DOM",
"prepoppulating",
"with",
"view",
"data"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/example/ViewManager.js#L79-L91 | train |
socialally/air | lib/air/disabled.js | disabled | function disabled(val) {
// return whether the first element in the set
// is hidden
if(val === undefined) {
return this.hasClass(className);
// hide on truthy
}else if(val) {
this.addClass(className);
// show on falsey
}else{
this.removeClass(className);
}
return this;
} | javascript | function disabled(val) {
// return whether the first element in the set
// is hidden
if(val === undefined) {
return this.hasClass(className);
// hide on truthy
}else if(val) {
this.addClass(className);
// show on falsey
}else{
this.removeClass(className);
}
return this;
} | [
"function",
"disabled",
"(",
"val",
")",
"{",
"// return whether the first element in the set",
"// is hidden",
"if",
"(",
"val",
"===",
"undefined",
")",
"{",
"return",
"this",
".",
"hasClass",
"(",
"className",
")",
";",
"// hide on truthy",
"}",
"else",
"if",
... | Toggles the disabled class on an element.
A typical css rule might be:
.disabled{pointer-events: none; opacity: 0.8;} | [
"Toggles",
"the",
"disabled",
"class",
"on",
"an",
"element",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/disabled.js#L10-L23 | train |
Sobesednik/wrote | es5/src/write.js | write | function write(ws, source) {
return new Promise(function ($return, $error) {
if (!(ws instanceof Writable)) {
return $error(new Error('Writable stream expected'));
}
if (source instanceof Readable) {
if (!source.readable) {
return $error(new Error('Str... | javascript | function write(ws, source) {
return new Promise(function ($return, $error) {
if (!(ws instanceof Writable)) {
return $error(new Error('Writable stream expected'));
}
if (source instanceof Readable) {
if (!source.readable) {
return $error(new Error('Str... | [
"function",
"write",
"(",
"ws",
",",
"source",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"$return",
",",
"$error",
")",
"{",
"if",
"(",
"!",
"(",
"ws",
"instanceof",
"Writable",
")",
")",
"{",
"return",
"$error",
"(",
"new",
"Error"... | Write data to the stream, and resolve when it's ended.
@param {Writable} ws write stream
@param {string|Readable} source read source
@returns {Promise<Writable>} A promise resolved with the writable stream, or rejected
when an error occurred while reading or writing. | [
"Write",
"data",
"to",
"the",
"stream",
"and",
"resolve",
"when",
"it",
"s",
"ended",
"."
] | 24992ad3bba4e5959dfb617b6c1f22d9a1306ab9 | https://github.com/Sobesednik/wrote/blob/24992ad3bba4e5959dfb617b6c1f22d9a1306ab9/es5/src/write.js#L12-L42 | train |
OpenSmartEnvironment/ose | lib/space/index.js | init | function init() { // {{{2
/**
* Class constructor
*
* @method constructor
* @internal
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.peers = {};
this.shards = {};
} | javascript | function init() { // {{{2
/**
* Class constructor
*
* @method constructor
* @internal
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.peers = {};
this.shards = {};
} | [
"function",
"init",
"(",
")",
"{",
"// {{{2",
"/**\n * Class constructor\n *\n * @method constructor\n * @internal\n */",
"O",
".",
"inherited",
"(",
"this",
")",
"(",
")",
";",
"this",
".",
"setMaxListeners",
"(",
"Consts",
".",
"coreListeners",
")",
";",
"this",
... | shards {{{2
Object containing shards indexed by `sid`
@property shards
@type Object
@internal
Public {{{1 | [
"shards",
"{{{",
"2",
"Object",
"containing",
"shards",
"indexed",
"by",
"sid"
] | 2ab051d9db6e77341c40abb9cbdae6ce586917e0 | https://github.com/OpenSmartEnvironment/ose/blob/2ab051d9db6e77341c40abb9cbdae6ce586917e0/lib/space/index.js#L68-L84 | train |
vid/SenseBase | web/ext-lib/jqCron/jqCron.js | newSelector | function newSelector($block, multiple, type){
var selector = new jqCronSelector(_self, $block, multiple, type);
selector.$.bind('selector:open', function(){
// we close all opened selectors of all other jqCron
for(var n = jqCronInstances.length; n--; ){
if(jqCronInstances[n] != _self) {
jqCronI... | javascript | function newSelector($block, multiple, type){
var selector = new jqCronSelector(_self, $block, multiple, type);
selector.$.bind('selector:open', function(){
// we close all opened selectors of all other jqCron
for(var n = jqCronInstances.length; n--; ){
if(jqCronInstances[n] != _self) {
jqCronI... | [
"function",
"newSelector",
"(",
"$block",
",",
"multiple",
",",
"type",
")",
"{",
"var",
"selector",
"=",
"new",
"jqCronSelector",
"(",
"_self",
",",
"$block",
",",
"multiple",
",",
"type",
")",
";",
"selector",
".",
"$",
".",
"bind",
"(",
"'selector:ope... | instanciate a new selector | [
"instanciate",
"a",
"new",
"selector"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/ext-lib/jqCron/jqCron.js#L169-L205 | train |
vid/SenseBase | web/ext-lib/jqCron/jqCron.js | array_unique | function array_unique(l){
var i=0,n=l.length,k={},a=[];
while(i<n) {
k[l[i]] || (k[l[i]] = 1 && a.push(l[i]));
i++;
}
return a;
} | javascript | function array_unique(l){
var i=0,n=l.length,k={},a=[];
while(i<n) {
k[l[i]] || (k[l[i]] = 1 && a.push(l[i]));
i++;
}
return a;
} | [
"function",
"array_unique",
"(",
"l",
")",
"{",
"var",
"i",
"=",
"0",
",",
"n",
"=",
"l",
".",
"length",
",",
"k",
"=",
"{",
"}",
",",
"a",
"=",
"[",
"]",
";",
"while",
"(",
"i",
"<",
"n",
")",
"{",
"k",
"[",
"l",
"[",
"i",
"]",
"]",
... | return an array without doublon | [
"return",
"an",
"array",
"without",
"doublon"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/ext-lib/jqCron/jqCron.js#L522-L529 | train |
xudafeng/passme | demo/editor/rainyday.js | RainyDay | function RainyDay(options) {
this.img = document.getElementById(options.element);
this.opacity = options.opacity || 1;
this.blurRadius = options.blur || 10;
this.w = this.img.clientWidth;
this.h = this.img.clientHeight;
this.drops = [];
// prepare canvas elements
this.canvas = this.prep... | javascript | function RainyDay(options) {
this.img = document.getElementById(options.element);
this.opacity = options.opacity || 1;
this.blurRadius = options.blur || 10;
this.w = this.img.clientWidth;
this.h = this.img.clientHeight;
this.drops = [];
// prepare canvas elements
this.canvas = this.prep... | [
"function",
"RainyDay",
"(",
"options",
")",
"{",
"this",
".",
"img",
"=",
"document",
".",
"getElementById",
"(",
"options",
".",
"element",
")",
";",
"this",
".",
"opacity",
"=",
"options",
".",
"opacity",
"||",
"1",
";",
"this",
".",
"blurRadius",
"... | Defines a new instance of the rainyday.js.
@param options options element with script parameters | [
"Defines",
"a",
"new",
"instance",
"of",
"the",
"rainyday",
".",
"js",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/rainyday.js#L6-L33 | train |
xudafeng/passme | demo/editor/rainyday.js | Drop | function Drop(rainyday, centerX, centerY, min, base) {
this.x = Math.floor(centerX);
this.y = Math.floor(centerY);
this.r = (Math.random() * base) + min;
this.rainyday = rainyday;
this.context = rainyday.context;
this.reflection = rainyday.reflected;
} | javascript | function Drop(rainyday, centerX, centerY, min, base) {
this.x = Math.floor(centerX);
this.y = Math.floor(centerY);
this.r = (Math.random() * base) + min;
this.rainyday = rainyday;
this.context = rainyday.context;
this.reflection = rainyday.reflected;
} | [
"function",
"Drop",
"(",
"rainyday",
",",
"centerX",
",",
"centerY",
",",
"min",
",",
"base",
")",
"{",
"this",
".",
"x",
"=",
"Math",
".",
"floor",
"(",
"centerX",
")",
";",
"this",
".",
"y",
"=",
"Math",
".",
"floor",
"(",
"centerY",
")",
";",
... | Defines a new raindrop object.
@param rainyday reference to the parent object
@param centerX x position of the center of this drop
@param centerY y position of the center of this drop
@param min minimum size of a drop
@param base base value for randomizing drop size | [
"Defines",
"a",
"new",
"raindrop",
"object",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/rainyday.js#L252-L259 | train |
xudafeng/passme | demo/editor/rainyday.js | CollisionMatrix | function CollisionMatrix(x, y, r) {
this.resolution = r;
this.xc = x;
this.yc = y;
this.matrix = new Array(x);
for (var i = 0; i <= (x + 5); i++) {
this.matrix[i] = new Array(y);
for (var j = 0; j <= (y + 5); ++j) {
this.matrix[i][j] = new DropItem(null);
}
}
... | javascript | function CollisionMatrix(x, y, r) {
this.resolution = r;
this.xc = x;
this.yc = y;
this.matrix = new Array(x);
for (var i = 0; i <= (x + 5); i++) {
this.matrix[i] = new Array(y);
for (var j = 0; j <= (y + 5); ++j) {
this.matrix[i][j] = new DropItem(null);
}
}
... | [
"function",
"CollisionMatrix",
"(",
"x",
",",
"y",
",",
"r",
")",
"{",
"this",
".",
"resolution",
"=",
"r",
";",
"this",
".",
"xc",
"=",
"x",
";",
"this",
".",
"yc",
"=",
"y",
";",
"this",
".",
"matrix",
"=",
"new",
"Array",
"(",
"x",
")",
";... | Defines a gravity matrix object which handles collision detection.
@param x number of columns in the matrix
@param y number of rows in the matrix
@param r grid size | [
"Defines",
"a",
"gravity",
"matrix",
"object",
"which",
"handles",
"collision",
"detection",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/rainyday.js#L814-L825 | train |
theboyWhoCriedWoolf/transition-manager | src/core/transitionController.js | _transitionViews | function _transitionViews( transitionObj )
{
if( !transitionObj ){ return TransitionController.error('transition is not defined'); }
const transitionModule = _options.transitions[ transitionObj.transitionType ];
if( transitionModule ) {
const deferred = Deferred(),
views = transitionObj.views,... | javascript | function _transitionViews( transitionObj )
{
if( !transitionObj ){ return TransitionController.error('transition is not defined'); }
const transitionModule = _options.transitions[ transitionObj.transitionType ];
if( transitionModule ) {
const deferred = Deferred(),
views = transitionObj.views,... | [
"function",
"_transitionViews",
"(",
"transitionObj",
")",
"{",
"if",
"(",
"!",
"transitionObj",
")",
"{",
"return",
"TransitionController",
".",
"error",
"(",
"'transition is not defined'",
")",
";",
"}",
"const",
"transitionModule",
"=",
"_options",
".",
"transi... | transition the views, find the transition module if it
exists then pass in the linked views, data and settings
@param {onject} transitionObj - contains {transitionType, views, currentViewID, nextViewID}
@param {array} viewsToDispose - array to store the views passed to each module to dispatch on transition complet... | [
"transition",
"the",
"views",
"find",
"the",
"transition",
"module",
"if",
"it",
"exists",
"then",
"pass",
"in",
"the",
"linked",
"views",
"data",
"and",
"settings"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionController.js#L42-L73 | train |
socialally/air | lib/air/template.js | template | function template(source, target) {
source = source || {};
target = target || {};
for(var z in source) {
target[z] = $.partial(source[z]);
}
return target;
} | javascript | function template(source, target) {
source = source || {};
target = target || {};
for(var z in source) {
target[z] = $.partial(source[z]);
}
return target;
} | [
"function",
"template",
"(",
"source",
",",
"target",
")",
"{",
"source",
"=",
"source",
"||",
"{",
"}",
";",
"target",
"=",
"target",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"z",
"in",
"source",
")",
"{",
"target",
"[",
"z",
"]",
"=",
"$",
"."... | Get a map of template elements.
Source object is id => selector,
target object is id => elements(s). | [
"Get",
"a",
"map",
"of",
"template",
"elements",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/template.js#L10-L17 | train |
socialally/air | lib/air/template.js | swap | function swap(source, target) {
// wrap to allow string selectors, arrays etc.
source = $(source);
target = $(target);
source.each(function(el, index) {
var content = target.get(index);
if(el.parentNode && content) {
// deep clone template partial
content = content.cloneNode(true);
// ... | javascript | function swap(source, target) {
// wrap to allow string selectors, arrays etc.
source = $(source);
target = $(target);
source.each(function(el, index) {
var content = target.get(index);
if(el.parentNode && content) {
// deep clone template partial
content = content.cloneNode(true);
// ... | [
"function",
"swap",
"(",
"source",
",",
"target",
")",
"{",
"// wrap to allow string selectors, arrays etc.",
"source",
"=",
"$",
"(",
"source",
")",
";",
"target",
"=",
"$",
"(",
"target",
")",
";",
"source",
".",
"each",
"(",
"function",
"(",
"el",
",",
... | Swap a source list of element's with a target list of element's.
The target elements are cloned as they should be template partials, the
source element(s) should exist in the DOM. | [
"Swap",
"a",
"source",
"list",
"of",
"element",
"s",
"with",
"a",
"target",
"list",
"of",
"element",
"s",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/template.js#L39-L52 | train |
kbremner/grunt-dropbox | tasks/dropbox.js | createUploadPromise | function createUploadPromise(filepath, destination, options) {
return function () {
// get the name of the file and construct the url for uploading it
var filename = getFilename(filepath),
dropboxPath = destination + (options.version_name ? ("/" + options.version_name + "/") : "/") + filepath,
... | javascript | function createUploadPromise(filepath, destination, options) {
return function () {
// get the name of the file and construct the url for uploading it
var filename = getFilename(filepath),
dropboxPath = destination + (options.version_name ? ("/" + options.version_name + "/") : "/") + filepath,
... | [
"function",
"createUploadPromise",
"(",
"filepath",
",",
"destination",
",",
"options",
")",
"{",
"return",
"function",
"(",
")",
"{",
"// get the name of the file and construct the url for uploading it",
"var",
"filename",
"=",
"getFilename",
"(",
"filepath",
")",
",",... | returns a function that creates a promise to upload the file to the destination | [
"returns",
"a",
"function",
"that",
"creates",
"a",
"promise",
"to",
"upload",
"the",
"file",
"to",
"the",
"destination"
] | 3f3b354b9f5f2bd1a42bf1e3cbde382a9583db08 | https://github.com/kbremner/grunt-dropbox/blob/3f3b354b9f5f2bd1a42bf1e3cbde382a9583db08/tasks/dropbox.js#L46-L64 | train |
wunderbyte/grunt-spiritual-build | tasks/guibundles.js | process | function process(sources, options) {
sources = explodeall(sources);
if (!grunt.fail.errorcount) {
var content = extract(sources, options);
return enclose(content.join(SPACER));
}
} | javascript | function process(sources, options) {
sources = explodeall(sources);
if (!grunt.fail.errorcount) {
var content = extract(sources, options);
return enclose(content.join(SPACER));
}
} | [
"function",
"process",
"(",
"sources",
",",
"options",
")",
"{",
"sources",
"=",
"explodeall",
"(",
"sources",
")",
";",
"if",
"(",
"!",
"grunt",
".",
"fail",
".",
"errorcount",
")",
"{",
"var",
"content",
"=",
"extract",
"(",
"sources",
",",
"options"... | Process sources with options.
@param {Array<string>} sources
@param {object} options
@returns {string} | [
"Process",
"sources",
"with",
"options",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L60-L66 | train |
wunderbyte/grunt-spiritual-build | tasks/guibundles.js | extract | function extract(sources, options) {
return sources
.map(function(src) {
return [src, grunt.file.read(src)];
})
.filter(function(list) {
return syntax.valid(grunt, list[0], list[1]);
})
.map(function(list) {
return extras(list[0], list[1], options);
});
} | javascript | function extract(sources, options) {
return sources
.map(function(src) {
return [src, grunt.file.read(src)];
})
.filter(function(list) {
return syntax.valid(grunt, list[0], list[1]);
})
.map(function(list) {
return extras(list[0], list[1], options);
});
} | [
"function",
"extract",
"(",
"sources",
",",
"options",
")",
"{",
"return",
"sources",
".",
"map",
"(",
"function",
"(",
"src",
")",
"{",
"return",
"[",
"src",
",",
"grunt",
".",
"file",
".",
"read",
"(",
"src",
")",
"]",
";",
"}",
")",
".",
"filt... | Extract content from files and
parse through various options.
@param {Array<string>} sources
@param {object} options
@returns {Array<string>} | [
"Extract",
"content",
"from",
"files",
"and",
"parse",
"through",
"various",
"options",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L75-L86 | train |
wunderbyte/grunt-spiritual-build | tasks/guibundles.js | writefile | function writefile(filepath, filetext, options) {
var version = '-1.0.0';
var packag = filename('package.json', options);
var banner = filename('BANNER.txt', options);
if (grunt.file.exists(banner)) {
filetext = grunt.file.read(banner) + '\n' + filetext;
}
if (grunt.file.exists(packag)) {
var json = g... | javascript | function writefile(filepath, filetext, options) {
var version = '-1.0.0';
var packag = filename('package.json', options);
var banner = filename('BANNER.txt', options);
if (grunt.file.exists(banner)) {
filetext = grunt.file.read(banner) + '\n' + filetext;
}
if (grunt.file.exists(packag)) {
var json = g... | [
"function",
"writefile",
"(",
"filepath",
",",
"filetext",
",",
"options",
")",
"{",
"var",
"version",
"=",
"'-1.0.0'",
";",
"var",
"packag",
"=",
"filename",
"(",
"'package.json'",
",",
"options",
")",
";",
"var",
"banner",
"=",
"filename",
"(",
"'BANNER.... | Write file and report to console.
@param {String} filepath
@param {String} filetext | [
"Write",
"file",
"and",
"report",
"to",
"console",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L148-L168 | train |
wunderbyte/grunt-spiritual-build | tasks/guibundles.js | uglyfile | function uglyfile(prettyfile, sourcecode, options) {
var mintarget = prettyfile.replace('.js', '.min.js');
var maptarget = prettyfile.replace('.js', '.js.map');
var uglycodes = uglify(options.max ? prettyfile : sourcecode);
writefile(mintarget, uglycodes.code, options);
if (options.map) {
writefile(maptarg... | javascript | function uglyfile(prettyfile, sourcecode, options) {
var mintarget = prettyfile.replace('.js', '.min.js');
var maptarget = prettyfile.replace('.js', '.js.map');
var uglycodes = uglify(options.max ? prettyfile : sourcecode);
writefile(mintarget, uglycodes.code, options);
if (options.map) {
writefile(maptarg... | [
"function",
"uglyfile",
"(",
"prettyfile",
",",
"sourcecode",
",",
"options",
")",
"{",
"var",
"mintarget",
"=",
"prettyfile",
".",
"replace",
"(",
"'.js'",
",",
"'.min.js'",
")",
";",
"var",
"maptarget",
"=",
"prettyfile",
".",
"replace",
"(",
"'.js'",
",... | Write uglified file
@param {string} prettyfile
@param {object} options | [
"Write",
"uglified",
"file"
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L175-L183 | train |
wunderbyte/grunt-spiritual-build | tasks/guibundles.js | uglify | function uglify(prettyfile, sourcecode) {
console.warn(
'Not quite getting the right path to source in the map :/'
);
return ugli.minify(sourcecode || prettyfile, {
fromString: sourcecode !== undefined,
outSourceMap: path.basename(prettyfile) + '.map',
compress: {
warnings: false
}
});
} | javascript | function uglify(prettyfile, sourcecode) {
console.warn(
'Not quite getting the right path to source in the map :/'
);
return ugli.minify(sourcecode || prettyfile, {
fromString: sourcecode !== undefined,
outSourceMap: path.basename(prettyfile) + '.map',
compress: {
warnings: false
}
});
} | [
"function",
"uglify",
"(",
"prettyfile",
",",
"sourcecode",
")",
"{",
"console",
".",
"warn",
"(",
"'Not quite getting the right path to source in the map :/'",
")",
";",
"return",
"ugli",
".",
"minify",
"(",
"sourcecode",
"||",
"prettyfile",
",",
"{",
"fromString",... | Uglify file or sourcecode string.
@param {string} prettyfile
@param @optional {string} sourcecode | [
"Uglify",
"file",
"or",
"sourcecode",
"string",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/guibundles.js#L190-L201 | train |
leomp12/nodejs-rest-auto-router | main.js | function (obj, meta, status = 200, errorCode = -1, devMsg = null, usrMsg = null, moreInfo = null) {
if (res.finished) {
// request ended
return
}
// ref.: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
if (status < 300) {
// OK
// respond client and clos... | javascript | function (obj, meta, status = 200, errorCode = -1, devMsg = null, usrMsg = null, moreInfo = null) {
if (res.finished) {
// request ended
return
}
// ref.: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
if (status < 300) {
// OK
// respond client and clos... | [
"function",
"(",
"obj",
",",
"meta",
",",
"status",
"=",
"200",
",",
"errorCode",
"=",
"-",
"1",
",",
"devMsg",
"=",
"null",
",",
"usrMsg",
"=",
"null",
",",
"moreInfo",
"=",
"null",
")",
"{",
"if",
"(",
"res",
".",
"finished",
")",
"{",
"// requ... | respond client and close request | [
"respond",
"client",
"and",
"close",
"request"
] | eec413b9fd4565c5471f6eff11c316e6a984d110 | https://github.com/leomp12/nodejs-rest-auto-router/blob/eec413b9fd4565c5471f6eff11c316e6a984d110/main.js#L183-L251 | train | |
odogono/elsinore-js | src/query/without.js | without | function without(componentIDs) {
const context = this.readContext(this);
context.pushOp(WITHOUT);
// the preceeding command is used as the first argument
context.pushVal(componentIDs, true);
return context;
} | javascript | function without(componentIDs) {
const context = this.readContext(this);
context.pushOp(WITHOUT);
// the preceeding command is used as the first argument
context.pushVal(componentIDs, true);
return context;
} | [
"function",
"without",
"(",
"componentIDs",
")",
"{",
"const",
"context",
"=",
"this",
".",
"readContext",
"(",
"this",
")",
";",
"context",
".",
"pushOp",
"(",
"WITHOUT",
")",
";",
"// the preceeding command is used as the first argument",
"context",
".",
"pushVa... | Returns a value with componentsIDs with all of values excluded | [
"Returns",
"a",
"value",
"with",
"componentsIDs",
"with",
"all",
"of",
"values",
"excluded"
] | 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/query/without.js#L15-L23 | train |
CodeboxIDE/large-watcher | index.js | dualDiff | function dualDiff(a1, a2) {
var o1={}, o2={}, diff1=[], diff2=[], i, len, k;
for (i=0, len=a1.length; i<len; i++) { o1[a1[i]] = true; }
for (i=0, len=a2.length; i<len; i++) { o2[a2[i]] = true; }
for (k in o1) { if (!(k in o2)) { diff1.push(k); } }
for (k in o2) { if (!(k in o1)) { diff2.push(k); } }... | javascript | function dualDiff(a1, a2) {
var o1={}, o2={}, diff1=[], diff2=[], i, len, k;
for (i=0, len=a1.length; i<len; i++) { o1[a1[i]] = true; }
for (i=0, len=a2.length; i<len; i++) { o2[a2[i]] = true; }
for (k in o1) { if (!(k in o2)) { diff1.push(k); } }
for (k in o2) { if (!(k in o1)) { diff2.push(k); } }... | [
"function",
"dualDiff",
"(",
"a1",
",",
"a2",
")",
"{",
"var",
"o1",
"=",
"{",
"}",
",",
"o2",
"=",
"{",
"}",
",",
"diff1",
"=",
"[",
"]",
",",
"diff2",
"=",
"[",
"]",
",",
"i",
",",
"len",
",",
"k",
";",
"for",
"(",
"i",
"=",
"0",
",",... | Returns both the left and right diff seperately | [
"Returns",
"both",
"the",
"left",
"and",
"right",
"diff",
"seperately"
] | 876af5d8964b73348d5bcaaecff9b4d3fb7f8d03 | https://github.com/CodeboxIDE/large-watcher/blob/876af5d8964b73348d5bcaaecff9b4d3fb7f8d03/index.js#L228-L235 | train |
Notificare/notificare-live-api-node | lib/util/crypto.js | generateHmac | function generateHmac(data, key, encoding) {
var hmac = crypto.createHmac(HMAC_SHA256_ALGORITHM, key);
hmac.update(data);
return hmac.digest(encoding);
} | javascript | function generateHmac(data, key, encoding) {
var hmac = crypto.createHmac(HMAC_SHA256_ALGORITHM, key);
hmac.update(data);
return hmac.digest(encoding);
} | [
"function",
"generateHmac",
"(",
"data",
",",
"key",
",",
"encoding",
")",
"{",
"var",
"hmac",
"=",
"crypto",
".",
"createHmac",
"(",
"HMAC_SHA256_ALGORITHM",
",",
"key",
")",
";",
"hmac",
".",
"update",
"(",
"data",
")",
";",
"return",
"hmac",
".",
"d... | Generate a HMAC for the given data
@param {String} data
@param {String} key
@param {String} encoding
@returns {String|Buffer} will return a Buffer if no encoding given | [
"Generate",
"a",
"HMAC",
"for",
"the",
"given",
"data"
] | 98d17dcc1ae3f9d58d478f27e796222aa44c6eae | https://github.com/Notificare/notificare-live-api-node/blob/98d17dcc1ae3f9d58d478f27e796222aa44c6eae/lib/util/crypto.js#L15-L19 | train |
socialally/air | lib/air/css.js | css | function css(key, val) {
var style, props;
if(!this.length) {
return this;
}
if(key && typeof key === 'object') {
props = key;
}else if(key && val) {
props = {};
props[key] = val;
}
// get style object
if(key === undefined) {
style = window.getComputedStyle(this.dom[0], null);
... | javascript | function css(key, val) {
var style, props;
if(!this.length) {
return this;
}
if(key && typeof key === 'object') {
props = key;
}else if(key && val) {
props = {};
props[key] = val;
}
// get style object
if(key === undefined) {
style = window.getComputedStyle(this.dom[0], null);
... | [
"function",
"css",
"(",
"key",
",",
"val",
")",
"{",
"var",
"style",
",",
"props",
";",
"if",
"(",
"!",
"this",
".",
"length",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"key",
"&&",
"typeof",
"key",
"===",
"'object'",
")",
"{",
"props",
... | Get the value of a computed style property for the first element
in the set of matched elements or set one or more CSS properties
for every matched element. | [
"Get",
"the",
"value",
"of",
"a",
"computed",
"style",
"property",
"for",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"or",
"set",
"one",
"or",
"more",
"CSS",
"properties",
"for",
"every",
"matched",
"element",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/css.js#L6-L39 | train |
Whitebolt/require-extra | src/import.js | _filesInDirectory | async function _filesInDirectory(dirPath, options) {
const basedir = options.basedir || getCallingDir();
const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath;
let xExt = _getExtensionRegEx(options.extension || settings.get('extensions'));
try {
const files = (await readDir(resolvedDirPath... | javascript | async function _filesInDirectory(dirPath, options) {
const basedir = options.basedir || getCallingDir();
const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath;
let xExt = _getExtensionRegEx(options.extension || settings.get('extensions'));
try {
const files = (await readDir(resolvedDirPath... | [
"async",
"function",
"_filesInDirectory",
"(",
"dirPath",
",",
"options",
")",
"{",
"const",
"basedir",
"=",
"options",
".",
"basedir",
"||",
"getCallingDir",
"(",
")",
";",
"const",
"resolvedDirPath",
"=",
"basedir",
"?",
"path",
".",
"resolve",
"(",
"based... | Get a list of files in the directory.
@private
@param {string} dirPath Directory path to scan.
@param {Object} [options] Import options object.
@returns {Promise.<string[]>} Promise resolving to array of files. | [
"Get",
"a",
"list",
"of",
"files",
"in",
"the",
"directory",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L32-L59 | train |
Whitebolt/require-extra | src/import.js | filesInDirectories | async function filesInDirectories(dirPaths, options) {
let files = await Promise.all(makeArray(dirPaths).map(dirPath=>_filesInDirectory(dirPath, options)));
return flattenDeep(files);
} | javascript | async function filesInDirectories(dirPaths, options) {
let files = await Promise.all(makeArray(dirPaths).map(dirPath=>_filesInDirectory(dirPath, options)));
return flattenDeep(files);
} | [
"async",
"function",
"filesInDirectories",
"(",
"dirPaths",
",",
"options",
")",
"{",
"let",
"files",
"=",
"await",
"Promise",
".",
"all",
"(",
"makeArray",
"(",
"dirPaths",
")",
".",
"map",
"(",
"dirPath",
"=>",
"_filesInDirectory",
"(",
"dirPath",
",",
"... | Get all the files in a collection of directories.
@param {Array|Set|string} dirPaths Path(s) to get files from.
@param [options] Import options object. | [
"Get",
"all",
"the",
"files",
"in",
"a",
"collection",
"of",
"directories",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L67-L70 | train |
Whitebolt/require-extra | src/import.js | _getExtensionRegEx | function _getExtensionRegEx(ext=settings.get('extensions')) {
let _ext = '(?:' + makeArray(ext).join('|') + ')';
return new RegExp(_ext + '$');
} | javascript | function _getExtensionRegEx(ext=settings.get('extensions')) {
let _ext = '(?:' + makeArray(ext).join('|') + ')';
return new RegExp(_ext + '$');
} | [
"function",
"_getExtensionRegEx",
"(",
"ext",
"=",
"settings",
".",
"get",
"(",
"'extensions'",
")",
")",
"{",
"let",
"_ext",
"=",
"'(?:'",
"+",
"makeArray",
"(",
"ext",
")",
".",
"join",
"(",
"'|'",
")",
"+",
"')'",
";",
"return",
"new",
"RegExp",
"... | Get a regular expression for the given selection of file extensions, which
will then be able to match file paths, which have those extensions.
@private
@param {Array|string} [ext=config.get('extensions')] The extension(s).
@returns {RegExp} File path matcher. | [
"Get",
"a",
"regular",
"expression",
"for",
"the",
"given",
"selection",
"of",
"file",
"extensions",
"which",
"will",
"then",
"be",
"able",
"to",
"match",
"file",
"paths",
"which",
"have",
"those",
"extensions",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L93-L96 | train |
Whitebolt/require-extra | src/import.js | _canImport | function _canImport(fileName, callingFileName, options) {
if (callingFileName && (fileName === callingFileName)) return false;
let _fileName = _getFileTests(fileName, options);
if (options.includes) return (intersection(options.includes, _fileName).length > 0);
if (options.excludes) return (intersection(options... | javascript | function _canImport(fileName, callingFileName, options) {
if (callingFileName && (fileName === callingFileName)) return false;
let _fileName = _getFileTests(fileName, options);
if (options.includes) return (intersection(options.includes, _fileName).length > 0);
if (options.excludes) return (intersection(options... | [
"function",
"_canImport",
"(",
"fileName",
",",
"callingFileName",
",",
"options",
")",
"{",
"if",
"(",
"callingFileName",
"&&",
"(",
"fileName",
"===",
"callingFileName",
")",
")",
"return",
"false",
";",
"let",
"_fileName",
"=",
"_getFileTests",
"(",
"fileNa... | Can a filename be imported according to the rules the supplied options.
@private
@param {string} fileName Filename to test.
@param {string} callingFileName Calling filename (file doing the import).
@param {Object} options Import/Export options.
@returns {boolean} | [
"Can",
"a",
"filename",
"be",
"imported",
"according",
"to",
"the",
"rules",
"the",
"supplied",
"options",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L124-L130 | train |
Whitebolt/require-extra | src/import.js | _importDirectoryOptionsParser | function _importDirectoryOptionsParser(options={}) {
const _options = Object.assign({
imports: {},
onload: options.callback,
extension: makeArray(options.extensions || settings.get('extensions')),
useSyncRequire: settings.get('useSyncRequire'),
merge: settings.get('mergeImports'),
rescursive: ... | javascript | function _importDirectoryOptionsParser(options={}) {
const _options = Object.assign({
imports: {},
onload: options.callback,
extension: makeArray(options.extensions || settings.get('extensions')),
useSyncRequire: settings.get('useSyncRequire'),
merge: settings.get('mergeImports'),
rescursive: ... | [
"function",
"_importDirectoryOptionsParser",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"_options",
"=",
"Object",
".",
"assign",
"(",
"{",
"imports",
":",
"{",
"}",
",",
"onload",
":",
"options",
".",
"callback",
",",
"extension",
":",
"makeArray",... | Parse the input options, filling-in any defaults.
@private
@param {Object} [options={}] The options to parse.
@returns {Object} | [
"Parse",
"the",
"input",
"options",
"filling",
"-",
"in",
"any",
"defaults",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L157-L174 | train |
Whitebolt/require-extra | src/import.js | importDirectory | function importDirectory(dirPath, options, callback) {
if (!callback) return _importDirectory(dirPath, options);
_importDirectory(dirPath, options).then(
imports=>setImmediate(()=>callback(null, imports)),
err=>setImmediate(()=>callback(err, undefined))
);
} | javascript | function importDirectory(dirPath, options, callback) {
if (!callback) return _importDirectory(dirPath, options);
_importDirectory(dirPath, options).then(
imports=>setImmediate(()=>callback(null, imports)),
err=>setImmediate(()=>callback(err, undefined))
);
} | [
"function",
"importDirectory",
"(",
"dirPath",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
")",
"return",
"_importDirectory",
"(",
"dirPath",
",",
"options",
")",
";",
"_importDirectory",
"(",
"dirPath",
",",
"options",
")",
".",
... | Import all the modules in a set of given paths,according to the supplied options.
@public
@param {string|Array.<string>} dirPath The path(s) to import from.
@param {Object} [options=''] The option to use in the import.
@param {Function} [callback] Node-style callback to fire, use if you do no... | [
"Import",
"all",
"the",
"modules",
"in",
"a",
"set",
"of",
"given",
"paths",
"according",
"to",
"the",
"supplied",
"options",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/import.js#L243-L249 | train |
odogono/elsinore-js | src/error/index.js | captureStackTrace | function captureStackTrace(error, constructor) {
if (Error.captureStackTrace) {
Error.captureStackTrace(error, constructor);
} else {
error.stack = new Error().stack;
}
} | javascript | function captureStackTrace(error, constructor) {
if (Error.captureStackTrace) {
Error.captureStackTrace(error, constructor);
} else {
error.stack = new Error().stack;
}
} | [
"function",
"captureStackTrace",
"(",
"error",
",",
"constructor",
")",
"{",
"if",
"(",
"Error",
".",
"captureStackTrace",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"error",
",",
"constructor",
")",
";",
"}",
"else",
"{",
"error",
".",
"stack",
"="... | Error.captureStackTrace is not available in all
environments, so this function wraps an alternative
@param {*} error
@param {*} constructor | [
"Error",
".",
"captureStackTrace",
"is",
"not",
"available",
"in",
"all",
"environments",
"so",
"this",
"function",
"wraps",
"an",
"alternative"
] | 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/error/index.js#L63-L69 | train |
base/base-fs-tree | index.js | createFile | function createFile(tree, name, prop, options) {
var opts = utils.extend({}, options);
var str = create(tree[name], {label: 'cwd'});
var file = new utils.File({path: `${prop}-${name}.txt`, contents: new Buffer(str)});
if (typeof opts.treename === 'function') {
opts.treename(file);
}
file.... | javascript | function createFile(tree, name, prop, options) {
var opts = utils.extend({}, options);
var str = create(tree[name], {label: 'cwd'});
var file = new utils.File({path: `${prop}-${name}.txt`, contents: new Buffer(str)});
if (typeof opts.treename === 'function') {
opts.treename(file);
}
file.... | [
"function",
"createFile",
"(",
"tree",
",",
"name",
",",
"prop",
",",
"options",
")",
"{",
"var",
"opts",
"=",
"utils",
".",
"extend",
"(",
"{",
"}",
",",
"options",
")",
";",
"var",
"str",
"=",
"create",
"(",
"tree",
"[",
"name",
"]",
",",
"{",
... | Create a file | [
"Create",
"a",
"file"
] | b4b589ff85addd659d7446bf1e96b408e2fdadc5 | https://github.com/base/base-fs-tree/blob/b4b589ff85addd659d7446bf1e96b408e2fdadc5/index.js#L131-L145 | train |
FinalDevStudio/fi-khipu | lib/utils.js | sortObject | function sortObject(object) {
var keys = Object.keys(object);
var sorted = {};
var options = {
sensitivity: 'base'
};
function compare(a, b) {
return a.localeCompare(b, options);
}
keys.sort(compare);
for (var index in keys) {
if (keys[index]) {
var key = ke... | javascript | function sortObject(object) {
var keys = Object.keys(object);
var sorted = {};
var options = {
sensitivity: 'base'
};
function compare(a, b) {
return a.localeCompare(b, options);
}
keys.sort(compare);
for (var index in keys) {
if (keys[index]) {
var key = ke... | [
"function",
"sortObject",
"(",
"object",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
";",
"var",
"sorted",
"=",
"{",
"}",
";",
"var",
"options",
"=",
"{",
"sensitivity",
":",
"'base'",
"}",
";",
"function",
"compare",
"("... | Alphabetically sorts every property in an object and in any array values. | [
"Alphabetically",
"sorts",
"every",
"property",
"in",
"an",
"object",
"and",
"in",
"any",
"array",
"values",
"."
] | 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/utils.js#L13-L42 | train |
SteveWestbrook/is-valid-var-name | index.js | isValidES2015VarName | function isValidES2015VarName(name) {
// In ES2015-compatible code, these are reserved words.
if (name === 'await') { return false; }
if (name === 'enum') { return false; }
return validateVarName(allowedCharactersES2015, name, exports.strict);
} | javascript | function isValidES2015VarName(name) {
// In ES2015-compatible code, these are reserved words.
if (name === 'await') { return false; }
if (name === 'enum') { return false; }
return validateVarName(allowedCharactersES2015, name, exports.strict);
} | [
"function",
"isValidES2015VarName",
"(",
"name",
")",
"{",
"// In ES2015-compatible code, these are reserved words.",
"if",
"(",
"name",
"===",
"'await'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"name",
"===",
"'enum'",
")",
"{",
"return",
"false",
";"... | Determines whether a variable name is valid. Specifically, checks
whether the characters are valid and whether the name is a reserved word.
Note that while literals can be used as unquoted property names, these
will not necessarily be accepted as valid by this function.
@param name The variable name to check.
@return... | [
"Determines",
"whether",
"a",
"variable",
"name",
"is",
"valid",
".",
"Specifically",
"checks",
"whether",
"the",
"characters",
"are",
"valid",
"and",
"whether",
"the",
"name",
"is",
"a",
"reserved",
"word",
".",
"Note",
"that",
"while",
"literals",
"can",
"... | 3eca627d3a6c5fd52ffa3e6082554662c3fea0ec | https://github.com/SteveWestbrook/is-valid-var-name/blob/3eca627d3a6c5fd52ffa3e6082554662c3fea0ec/index.js#L34-L40 | train |
SteveWestbrook/is-valid-var-name | index.js | validateVarName | function validateVarName(regex, name, strict) {
if (strict) {
// These are only an issue in strict mode.
if (name === 'eval') { return false; }
if (name === 'arguments') { return false; }
}
var result = regex.test(name);
result = result && validateCommonReservedWords(name);
return result;
} | javascript | function validateVarName(regex, name, strict) {
if (strict) {
// These are only an issue in strict mode.
if (name === 'eval') { return false; }
if (name === 'arguments') { return false; }
}
var result = regex.test(name);
result = result && validateCommonReservedWords(name);
return result;
} | [
"function",
"validateVarName",
"(",
"regex",
",",
"name",
",",
"strict",
")",
"{",
"if",
"(",
"strict",
")",
"{",
"// These are only an issue in strict mode.",
"if",
"(",
"name",
"===",
"'eval'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"name",
"=... | Validates a variable name using the regular expression provided. Also uses
reserved words common to ES5 and ES2015.
@param regex {RegExp} A regular expression used to validate name.
@param name {String} The variable name to check.
@param [strict] If this is true, strict mode checking is on.
@return true if the name i... | [
"Validates",
"a",
"variable",
"name",
"using",
"the",
"regular",
"expression",
"provided",
".",
"Also",
"uses",
"reserved",
"words",
"common",
"to",
"ES5",
"and",
"ES2015",
"."
] | 3eca627d3a6c5fd52ffa3e6082554662c3fea0ec | https://github.com/SteveWestbrook/is-valid-var-name/blob/3eca627d3a6c5fd52ffa3e6082554662c3fea0ec/index.js#L66-L77 | train |
fod/px.js | lib/px.js | function(s) {
//TODO: validate array length
//TODO: return unwanted subset as new Px object
var counts = this.valCounts(),
multipliers = [];
_.each(s, function(d, i) {
if (d[0] === '*') {
s[i] = _.range(0, co... | javascript | function(s) {
//TODO: validate array length
//TODO: return unwanted subset as new Px object
var counts = this.valCounts(),
multipliers = [];
_.each(s, function(d, i) {
if (d[0] === '*') {
s[i] = _.range(0, co... | [
"function",
"(",
"s",
")",
"{",
"//TODO: validate array length",
"//TODO: return unwanted subset as new Px object",
"var",
"counts",
"=",
"this",
".",
"valCounts",
"(",
")",
",",
"multipliers",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"s",
",",
"function",
"... | remove values and associated data from this object | [
"remove",
"values",
"and",
"associated",
"data",
"from",
"this",
"object"
] | b7ed16d26fe1cf39ed32a63cdc4a9244d9423b41 | https://github.com/fod/px.js/blob/b7ed16d26fe1cf39ed32a63cdc4a9244d9423b41/lib/px.js#L219-L273 | train | |
feedhenry/fh-mbaas-client | lib/admin/services/services.js | deploy | function deploy(params, cb) {
params.resourcePath = config.addURIParams(constants.SERVICES_BASE_PATH + "/:guid/deploy", params);
params.method = "POST";
params.data = params.service;
mbaasRequest.admin(params, cb);
} | javascript | function deploy(params, cb) {
params.resourcePath = config.addURIParams(constants.SERVICES_BASE_PATH + "/:guid/deploy", params);
params.method = "POST";
params.data = params.service;
mbaasRequest.admin(params, cb);
} | [
"function",
"deploy",
"(",
"params",
",",
"cb",
")",
"{",
"params",
".",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"SERVICES_BASE_PATH",
"+",
"\"/:guid/deploy\"",
",",
"params",
")",
";",
"params",
".",
"method",
"=",
"\"POST... | Deploying A Service Definition To An Mbaas.
@param params
@param cb | [
"Deploying",
"A",
"Service",
"Definition",
"To",
"An",
"Mbaas",
"."
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/services/services.js#L10-L16 | train |
termosa/qinu | qinu.js | qinu | function qinu (options, args) {
const { dict, length, template, args: optArgs, random } =
this instanceof Qinu ? options : normalizeOptions(options)
if (!(args instanceof Array)) {
args = Array.prototype.slice.call(arguments, 1)
}
if (optArgs instanceof Array) {
args = optArgs.concat(args)
}
co... | javascript | function qinu (options, args) {
const { dict, length, template, args: optArgs, random } =
this instanceof Qinu ? options : normalizeOptions(options)
if (!(args instanceof Array)) {
args = Array.prototype.slice.call(arguments, 1)
}
if (optArgs instanceof Array) {
args = optArgs.concat(args)
}
co... | [
"function",
"qinu",
"(",
"options",
",",
"args",
")",
"{",
"const",
"{",
"dict",
",",
"length",
",",
"template",
",",
"args",
":",
"optArgs",
",",
"random",
"}",
"=",
"this",
"instanceof",
"Qinu",
"?",
"options",
":",
"normalizeOptions",
"(",
"options",
... | Not an arrow function, cause it requires context | [
"Not",
"an",
"arrow",
"function",
"cause",
"it",
"requires",
"context"
] | 2f33b2b078f19af4404a67a3e2856b8070a83b86 | https://github.com/termosa/qinu/blob/2f33b2b078f19af4404a67a3e2856b8070a83b86/qinu.js#L52-L65 | train |
onecommons/base | lib/app.js | brequire | function brequire(module) {
var basepath = process.env.SRC_base ? path.resolve(process.env.SRC_base)
: path.join(__dirname, '..');
if (module.charAt(0) == '.')
return require(path.join(basepath, module));
else //by calling require() from this location we ensure base's copy of the module will... | javascript | function brequire(module) {
var basepath = process.env.SRC_base ? path.resolve(process.env.SRC_base)
: path.join(__dirname, '..');
if (module.charAt(0) == '.')
return require(path.join(basepath, module));
else //by calling require() from this location we ensure base's copy of the module will... | [
"function",
"brequire",
"(",
"module",
")",
"{",
"var",
"basepath",
"=",
"process",
".",
"env",
".",
"SRC_base",
"?",
"path",
".",
"resolve",
"(",
"process",
".",
"env",
".",
"SRC_base",
")",
":",
"path",
".",
"join",
"(",
"__dirname",
",",
"'..'",
"... | you can use interchangeably with require except if or 1) you want a instance of module loaded that is distinct from base's instance or 2) you need to load a module using a relative path to your module | [
"you",
"can",
"use",
"interchangeably",
"with",
"require",
"except",
"if",
"or",
"1",
")",
"you",
"want",
"a",
"instance",
"of",
"module",
"loaded",
"that",
"is",
"distinct",
"from",
"base",
"s",
"instance",
"or",
"2",
")",
"you",
"need",
"to",
"load",
... | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/app.js#L708-L715 | train |
Kawba/MoLIR | molir.js | returnRankedIntents | function returnRankedIntents(input, intents) {
return new Promise((resolve, reject) => {
let lowerCase = input.toLowerCase();
let totalScore = 0;
//loop through all loaded intents
intents.forEach((intent) => {
intent.score = 0;
intent.utterences.forEach((utte... | javascript | function returnRankedIntents(input, intents) {
return new Promise((resolve, reject) => {
let lowerCase = input.toLowerCase();
let totalScore = 0;
//loop through all loaded intents
intents.forEach((intent) => {
intent.score = 0;
intent.utterences.forEach((utte... | [
"function",
"returnRankedIntents",
"(",
"input",
",",
"intents",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"lowerCase",
"=",
"input",
".",
"toLowerCase",
"(",
")",
";",
"let",
"totalScore",
"=",
"0",... | Function to classify input based on loaded intents | [
"Function",
"to",
"classify",
"input",
"based",
"on",
"loaded",
"intents"
] | f235a565854e6d20ad8fc064022434b0d6a6718e | https://github.com/Kawba/MoLIR/blob/f235a565854e6d20ad8fc064022434b0d6a6718e/molir.js#L37-L91 | train |
bonesoul/node-hpool-web | public/js/plugins/iCheck/icheck.js | operate | function operate(input, direct, method) {
var node = input[0],
state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,
active = method == _update ? {
checked: node[_checked],
disabled: node[_disabled],
indeterminate: input.attr(_indeterminate) == 't... | javascript | function operate(input, direct, method) {
var node = input[0],
state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,
active = method == _update ? {
checked: node[_checked],
disabled: node[_disabled],
indeterminate: input.attr(_indeterminate) == 't... | [
"function",
"operate",
"(",
"input",
",",
"direct",
",",
"method",
")",
"{",
"var",
"node",
"=",
"input",
"[",
"0",
"]",
",",
"state",
"=",
"/",
"er",
"/",
".",
"test",
"(",
"method",
")",
"?",
"_indeterminate",
":",
"/",
"bl",
"/",
".",
"test",
... | Do something with inputs | [
"Do",
"something",
"with",
"inputs"
] | 3d7749b2bcff8b59243939b5b3da19396c4878ff | https://github.com/bonesoul/node-hpool-web/blob/3d7749b2bcff8b59243939b5b3da19396c4878ff/public/js/plugins/iCheck/icheck.js#L309-L354 | train |
bonesoul/node-hpool-web | public/js/plugins/iCheck/icheck.js | on | function on(input, state, keep) {
var node = input[0],
parent = input.parent(),
checked = state == _checked,
indeterminate = state == _indeterminate,
disabled = state == _disabled,
callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
regular = option(input,... | javascript | function on(input, state, keep) {
var node = input[0],
parent = input.parent(),
checked = state == _checked,
indeterminate = state == _indeterminate,
disabled = state == _disabled,
callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
regular = option(input,... | [
"function",
"on",
"(",
"input",
",",
"state",
",",
"keep",
")",
"{",
"var",
"node",
"=",
"input",
"[",
"0",
"]",
",",
"parent",
"=",
"input",
".",
"parent",
"(",
")",
",",
"checked",
"=",
"state",
"==",
"_checked",
",",
"indeterminate",
"=",
"state... | Add checked, disabled or indeterminate state | [
"Add",
"checked",
"disabled",
"or",
"indeterminate",
"state"
] | 3d7749b2bcff8b59243939b5b3da19396c4878ff | https://github.com/bonesoul/node-hpool-web/blob/3d7749b2bcff8b59243939b5b3da19396c4878ff/public/js/plugins/iCheck/icheck.js#L357-L426 | train |
bonesoul/node-hpool-web | public/js/plugins/iCheck/icheck.js | off | function off(input, state, keep) {
var node = input[0],
parent = input.parent(),
checked = state == _checked,
indeterminate = state == _indeterminate,
disabled = state == _disabled,
callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
regular = option(input... | javascript | function off(input, state, keep) {
var node = input[0],
parent = input.parent(),
checked = state == _checked,
indeterminate = state == _indeterminate,
disabled = state == _disabled,
callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
regular = option(input... | [
"function",
"off",
"(",
"input",
",",
"state",
",",
"keep",
")",
"{",
"var",
"node",
"=",
"input",
"[",
"0",
"]",
",",
"parent",
"=",
"input",
".",
"parent",
"(",
")",
",",
"checked",
"=",
"state",
"==",
"_checked",
",",
"indeterminate",
"=",
"stat... | Remove checked, disabled or indeterminate state | [
"Remove",
"checked",
"disabled",
"or",
"indeterminate",
"state"
] | 3d7749b2bcff8b59243939b5b3da19396c4878ff | https://github.com/bonesoul/node-hpool-web/blob/3d7749b2bcff8b59243939b5b3da19396c4878ff/public/js/plugins/iCheck/icheck.js#L429-L464 | train |
bonesoul/node-hpool-web | public/js/plugins/iCheck/icheck.js | tidy | function tidy(input, callback) {
if (input.data(_iCheck)) {
// Remove everything except input
input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
// Callback
if (callback) {
input[_callback](callback);
};
// Unbind events
input.off('.i').unwrap... | javascript | function tidy(input, callback) {
if (input.data(_iCheck)) {
// Remove everything except input
input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
// Callback
if (callback) {
input[_callback](callback);
};
// Unbind events
input.off('.i').unwrap... | [
"function",
"tidy",
"(",
"input",
",",
"callback",
")",
"{",
"if",
"(",
"input",
".",
"data",
"(",
"_iCheck",
")",
")",
"{",
"// Remove everything except input",
"input",
".",
"parent",
"(",
")",
".",
"html",
"(",
"input",
".",
"attr",
"(",
"'style'",
... | Remove all traces | [
"Remove",
"all",
"traces"
] | 3d7749b2bcff8b59243939b5b3da19396c4878ff | https://github.com/bonesoul/node-hpool-web/blob/3d7749b2bcff8b59243939b5b3da19396c4878ff/public/js/plugins/iCheck/icheck.js#L467-L482 | train |
bonesoul/node-hpool-web | public/js/plugins/iCheck/icheck.js | option | function option(input, state, regular) {
if (input.data(_iCheck)) {
return input.data(_iCheck).o[state + (regular ? '' : 'Class')];
};
} | javascript | function option(input, state, regular) {
if (input.data(_iCheck)) {
return input.data(_iCheck).o[state + (regular ? '' : 'Class')];
};
} | [
"function",
"option",
"(",
"input",
",",
"state",
",",
"regular",
")",
"{",
"if",
"(",
"input",
".",
"data",
"(",
"_iCheck",
")",
")",
"{",
"return",
"input",
".",
"data",
"(",
"_iCheck",
")",
".",
"o",
"[",
"state",
"+",
"(",
"regular",
"?",
"''... | Get some option | [
"Get",
"some",
"option"
] | 3d7749b2bcff8b59243939b5b3da19396c4878ff | https://github.com/bonesoul/node-hpool-web/blob/3d7749b2bcff8b59243939b5b3da19396c4878ff/public/js/plugins/iCheck/icheck.js#L485-L489 | train |
onecommons/base | public/js/data.js | ajaxCallback | function ajaxCallback(data, textStatus) {
//responses should be a list of successful responses
//if any request failed it *may or may not* be an http-level error
//depending on server-side implementation
// konsole.log("datarequest", data, textStatus, 'dbdata.'+txnId, comm... | javascript | function ajaxCallback(data, textStatus) {
//responses should be a list of successful responses
//if any request failed it *may or may not* be an http-level error
//depending on server-side implementation
// konsole.log("datarequest", data, textStatus, 'dbdata.'+txnId, comm... | [
"function",
"ajaxCallback",
"(",
"data",
",",
"textStatus",
")",
"{",
"//responses should be a list of successful responses",
"//if any request failed it *may or may not* be an http-level error",
"//depending on server-side implementation",
"// konsole.log(\"datarequest\", data, textStatus, 'd... | var clientErrorMsg = this.clientErrorMsg; | [
"var",
"clientErrorMsg",
"=",
"this",
".",
"clientErrorMsg",
";"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/public/js/data.js#L188-L221 | train |
onecommons/base | public/js/data.js | function( obj ) {
var accessor = this._getAccessor( obj );
var seen = {};
for( var i = 0; i < this.form.elements.length; i++) {
this.serializeField( this.form.elements[i], accessor, seen);
}
return accessor.target;
} | javascript | function( obj ) {
var accessor = this._getAccessor( obj );
var seen = {};
for( var i = 0; i < this.form.elements.length; i++) {
this.serializeField( this.form.elements[i], accessor, seen);
}
return accessor.target;
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"accessor",
"=",
"this",
".",
"_getAccessor",
"(",
"obj",
")",
";",
"var",
"seen",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"form",
".",
"elements",
".",
"length"... | set the obj with form's current values | [
"set",
"the",
"obj",
"with",
"form",
"s",
"current",
"values"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/public/js/data.js#L1030-L1037 | train | |
onecommons/base | public/js/data.js | function( obj ) { //set form html
var accessor = this._getAccessor( obj );
for( var i = 0; i < this.form.elements.length; i++) {
this.deserializeField( this.form.elements[i], accessor );
}
return accessor.target;
} | javascript | function( obj ) { //set form html
var accessor = this._getAccessor( obj );
for( var i = 0; i < this.form.elements.length; i++) {
this.deserializeField( this.form.elements[i], accessor );
}
return accessor.target;
} | [
"function",
"(",
"obj",
")",
"{",
"//set form html",
"var",
"accessor",
"=",
"this",
".",
"_getAccessor",
"(",
"obj",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"form",
".",
"elements",
".",
"length",
";",
"i",
"++",
... | update the form with the object | [
"update",
"the",
"form",
"with",
"the",
"object"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/public/js/data.js#L1142-L1148 | train | |
onecommons/base | public/js/data.js | function( element, obj ) {
var accessor = this._getAccessor( obj );
var value = accessor.get( element.name || '');
value = this._format( element.name, value, element );
if( element.type == "radio" || element.type == "checkbox" ) {
element.checked = this._isSelected( element.value, value );
} ... | javascript | function( element, obj ) {
var accessor = this._getAccessor( obj );
var value = accessor.get( element.name || '');
value = this._format( element.name, value, element );
if( element.type == "radio" || element.type == "checkbox" ) {
element.checked = this._isSelected( element.value, value );
} ... | [
"function",
"(",
"element",
",",
"obj",
")",
"{",
"var",
"accessor",
"=",
"this",
".",
"_getAccessor",
"(",
"obj",
")",
";",
"var",
"value",
"=",
"accessor",
".",
"get",
"(",
"element",
".",
"name",
"||",
"''",
")",
";",
"value",
"=",
"this",
".",
... | update the form field with the property value | [
"update",
"the",
"form",
"field",
"with",
"the",
"property",
"value"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/public/js/data.js#L1151-L1168 | train | |
feedhenry/fh-mbaas-client | lib/app/appforms/submissions.js | uploadSubmissionFile | function uploadSubmissionFile(params, cb) {
var resourcePath = config.addURIParams("/appforms/submissions/:id/fields/:fieldId/files/:fileId", params);
var method = "POST";
var data = params.fileDetails;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
//Flagging This Reque... | javascript | function uploadSubmissionFile(params, cb) {
var resourcePath = config.addURIParams("/appforms/submissions/:id/fields/:fieldId/files/:fileId", params);
var method = "POST";
var data = params.fileDetails;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
//Flagging This Reque... | [
"function",
"uploadSubmissionFile",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"\"/appforms/submissions/:id/fields/:fieldId/files/:fileId\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"POST\"",
";",
"va... | Upload A File Associated With A Submission | [
"Upload",
"A",
"File",
"Associated",
"With",
"A",
"Submission"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/submissions.js#L38-L52 | train |
feedhenry/fh-mbaas-client | lib/app/appforms/submissions.js | getSubmissionStatus | function getSubmissionStatus(params, cb) {
var resourcePath = config.addURIParams("/appforms/submissions/:id/status", params);
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
//Flagging This Request As A File Request
params.fileRequest... | javascript | function getSubmissionStatus(params, cb) {
var resourcePath = config.addURIParams("/appforms/submissions/:id/status", params);
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
//Flagging This Request As A File Request
params.fileRequest... | [
"function",
"getSubmissionStatus",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"\"/appforms/submissions/:id/status\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"GET\"",
";",
"var",
"data",
"=",
"{... | Get The Current Status Of A Submission | [
"Get",
"The",
"Current",
"Status",
"Of",
"A",
"Submission"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/submissions.js#L73-L86 | train |
feedhenry/fh-mbaas-client | lib/app/appforms/submissions.js | exportCSV | function exportCSV(params, cb) {
var resourcePath = config.addURIParams("/appforms/submissions/export", params);
var method = "POST";
var data = params.queryParams;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
params.fileRequest = true;
mbaasRequest.app(params, cb);... | javascript | function exportCSV(params, cb) {
var resourcePath = config.addURIParams("/appforms/submissions/export", params);
var method = "POST";
var data = params.queryParams;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
params.fileRequest = true;
mbaasRequest.app(params, cb);... | [
"function",
"exportCSV",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"\"/appforms/submissions/export\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"POST\"",
";",
"var",
"data",
"=",
"params",
"."... | Export Submissions As A Zip File Containing CSVs.
@param params
@param cb | [
"Export",
"Submissions",
"As",
"A",
"Zip",
"File",
"Containing",
"CSVs",
"."
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/submissions.js#L152-L164 | train |
eHealthAfrica/data-models-deprecated | index.js | validate | function validate(candidate) {
if (candidate.doc_type) {
var schema = schemasDeepCopy()[candidate.doc_type];
validator.validate(candidate, schema);
var errors = validator.getLastErrors();
return errors;
}
return [{
dataModel: 'the object to be validated is missing a `doc_type` property'
}];... | javascript | function validate(candidate) {
if (candidate.doc_type) {
var schema = schemasDeepCopy()[candidate.doc_type];
validator.validate(candidate, schema);
var errors = validator.getLastErrors();
return errors;
}
return [{
dataModel: 'the object to be validated is missing a `doc_type` property'
}];... | [
"function",
"validate",
"(",
"candidate",
")",
"{",
"if",
"(",
"candidate",
".",
"doc_type",
")",
"{",
"var",
"schema",
"=",
"schemasDeepCopy",
"(",
")",
"[",
"candidate",
".",
"doc_type",
"]",
";",
"validator",
".",
"validate",
"(",
"candidate",
",",
"s... | Thin wrapper to make validation more convenient
@param {Object} candidate A model instance to validate
@return {[Error]} A list of errors or null | [
"Thin",
"wrapper",
"to",
"make",
"validation",
"more",
"convenient"
] | 93da821ed51f79b9b0411969b7721b49c7089890 | https://github.com/eHealthAfrica/data-models-deprecated/blob/93da821ed51f79b9b0411969b7721b49c7089890/index.js#L47-L58 | train |
eHealthAfrica/data-models-deprecated | index.js | generate | function generate(model, count) {
count = count || 1;
var registry = {};
var models = [];
if (model) {
models = typeof model === 'string' ? [model] : model;
} else {
models = Object.keys(schemas);
}
function build(model) {
var instance = jsf(schemas[model]);
var invalid = validate(instan... | javascript | function generate(model, count) {
count = count || 1;
var registry = {};
var models = [];
if (model) {
models = typeof model === 'string' ? [model] : model;
} else {
models = Object.keys(schemas);
}
function build(model) {
var instance = jsf(schemas[model]);
var invalid = validate(instan... | [
"function",
"generate",
"(",
"model",
",",
"count",
")",
"{",
"count",
"=",
"count",
"||",
"1",
";",
"var",
"registry",
"=",
"{",
"}",
";",
"var",
"models",
"=",
"[",
"]",
";",
"if",
"(",
"model",
")",
"{",
"models",
"=",
"typeof",
"model",
"==="... | Generate instances populated with pseudo random data
@param {(String|[String])} model An optional model or list of models
@param {Number} count An optional number of instances to generate
@return {Object} A map of model-instances | [
"Generate",
"instances",
"populated",
"with",
"pseudo",
"random",
"data"
] | 93da821ed51f79b9b0411969b7721b49c7089890 | https://github.com/eHealthAfrica/data-models-deprecated/blob/93da821ed51f79b9b0411969b7721b49c7089890/index.js#L67-L99 | train |
KTH/kth-node-server | index.js | serverClose | function serverClose (signal, done) {
_logger.info('Process received ' + signal + ', exiting ....')
if (done === undefined) {
done = function () {
process.exit(0)
}
}
if (server) {
server.close(done)
} else {
done()
}
} | javascript | function serverClose (signal, done) {
_logger.info('Process received ' + signal + ', exiting ....')
if (done === undefined) {
done = function () {
process.exit(0)
}
}
if (server) {
server.close(done)
} else {
done()
}
} | [
"function",
"serverClose",
"(",
"signal",
",",
"done",
")",
"{",
"_logger",
".",
"info",
"(",
"'Process received '",
"+",
"signal",
"+",
"', exiting ....'",
")",
"if",
"(",
"done",
"===",
"undefined",
")",
"{",
"done",
"=",
"function",
"(",
")",
"{",
"pr... | Closing the server
@param signal the log message depending on the given signal. | [
"Closing",
"the",
"server"
] | 0880a801c3d0298258084ba830929c9798e2275c | https://github.com/KTH/kth-node-server/blob/0880a801c3d0298258084ba830929c9798e2275c/index.js#L17-L29 | train |
nodejitsu/contour | pagelets/nodejitsu/anchor/base.js | scroll | function scroll(e) {
var attr = e.element.attributes;
if (!(attr || attr.href)) return;
var target = $(attr.href.value).plain(0);
if (!target) return;
e.preventDefault();
//
// Store the current window top Y and difference.
//
this.y = document.body.scrollTop;
this.target = ta... | javascript | function scroll(e) {
var attr = e.element.attributes;
if (!(attr || attr.href)) return;
var target = $(attr.href.value).plain(0);
if (!target) return;
e.preventDefault();
//
// Store the current window top Y and difference.
//
this.y = document.body.scrollTop;
this.target = ta... | [
"function",
"scroll",
"(",
"e",
")",
"{",
"var",
"attr",
"=",
"e",
".",
"element",
".",
"attributes",
";",
"if",
"(",
"!",
"(",
"attr",
"||",
"attr",
".",
"href",
")",
")",
"return",
";",
"var",
"target",
"=",
"$",
"(",
"attr",
".",
"href",
"."... | Scroll to the target of data-scroll.
@param {Event} e
@api private | [
"Scroll",
"to",
"the",
"target",
"of",
"data",
"-",
"scroll",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/anchor/base.js#L33-L54 | train |
nodejitsu/contour | pagelets/nodejitsu/anchor/base.js | animate | function animate() {
var diff = this.speed;
//
// If we're getting close to the endpoint stop at 0.
//
if (this.delta < diff) {
clearInterval(this.animated);
diff = this.delta;
}
//
// Keep track of how much is scrolled.
//
this.delta = this.delta - diff;
this.y... | javascript | function animate() {
var diff = this.speed;
//
// If we're getting close to the endpoint stop at 0.
//
if (this.delta < diff) {
clearInterval(this.animated);
diff = this.delta;
}
//
// Keep track of how much is scrolled.
//
this.delta = this.delta - diff;
this.y... | [
"function",
"animate",
"(",
")",
"{",
"var",
"diff",
"=",
"this",
".",
"speed",
";",
"//",
"// If we're getting close to the endpoint stop at 0.",
"//",
"if",
"(",
"this",
".",
"delta",
"<",
"diff",
")",
"{",
"clearInterval",
"(",
"this",
".",
"animated",
")... | Calculations for the animation.
@api private | [
"Calculations",
"for",
"the",
"animation",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/nodejitsu/anchor/base.js#L61-L82 | train |
writetome51/array-has | dist/privy/arrayHasAdjacent.js | arrayHasAdjacent | function arrayHasAdjacent(values, array) {
error_if_not_array_1.errorIfNotArray(values);
if (is_empty_not_empty_1.isEmpty(values))
return false;
var indexes = array_get_indexes_1.getIndexesOf(values[0], array);
var i = -1;
while (++i < indexes.length) {
if (indexes[i] + values.length... | javascript | function arrayHasAdjacent(values, array) {
error_if_not_array_1.errorIfNotArray(values);
if (is_empty_not_empty_1.isEmpty(values))
return false;
var indexes = array_get_indexes_1.getIndexesOf(values[0], array);
var i = -1;
while (++i < indexes.length) {
if (indexes[i] + values.length... | [
"function",
"arrayHasAdjacent",
"(",
"values",
",",
"array",
")",
"{",
"error_if_not_array_1",
".",
"errorIfNotArray",
"(",
"values",
")",
";",
"if",
"(",
"is_empty_not_empty_1",
".",
"isEmpty",
"(",
"values",
")",
")",
"return",
"false",
";",
"var",
"indexes"... | Checks if array contains adjacent values anywhere inside it. values cannot contain object. | [
"Checks",
"if",
"array",
"contains",
"adjacent",
"values",
"anywhere",
"inside",
"it",
".",
"values",
"cannot",
"contain",
"object",
"."
] | 8ced3fda5818940b814bbcdc37e03c65f285a965 | https://github.com/writetome51/array-has/blob/8ced3fda5818940b814bbcdc37e03c65f285a965/dist/privy/arrayHasAdjacent.js#L10-L24 | train |
haraldrudell/nodegod | lib/appentity.js | restartAppFromWatching | function restartAppFromWatching(err) {
updateWatcherCount()
if (err) self.emit('error', err)
if (dashboard.state !== 'stop') {
log('Restarting ' + conf.name + ' due to file watch trigger')
appLink.afterThat('restart')
} else log('Watcher restart ignored in stop state')
} | javascript | function restartAppFromWatching(err) {
updateWatcherCount()
if (err) self.emit('error', err)
if (dashboard.state !== 'stop') {
log('Restarting ' + conf.name + ' due to file watch trigger')
appLink.afterThat('restart')
} else log('Watcher restart ignored in stop state')
} | [
"function",
"restartAppFromWatching",
"(",
"err",
")",
"{",
"updateWatcherCount",
"(",
")",
"if",
"(",
"err",
")",
"self",
".",
"emit",
"(",
"'error'",
",",
"err",
")",
"if",
"(",
"dashboard",
".",
"state",
"!==",
"'stop'",
")",
"{",
"log",
"(",
"'Rest... | restart due to file change or copy change | [
"restart",
"due",
"to",
"file",
"change",
"or",
"copy",
"change"
] | 3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21 | https://github.com/haraldrudell/nodegod/blob/3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21/lib/appentity.js#L165-L172 | train |
jldec/pub-generator | render.js | renderTemplate | function renderTemplate(fragment, templateName) {
if (templateName === 'none') return fragment._txt;
var t = generator.template$[templateName];
if (!t) {
log('Unknown template %s for %s, using default.', templateName, fragment._href);
t = generator.template$.default;
}
var out;
try ... | javascript | function renderTemplate(fragment, templateName) {
if (templateName === 'none') return fragment._txt;
var t = generator.template$[templateName];
if (!t) {
log('Unknown template %s for %s, using default.', templateName, fragment._href);
t = generator.template$.default;
}
var out;
try ... | [
"function",
"renderTemplate",
"(",
"fragment",
",",
"templateName",
")",
"{",
"if",
"(",
"templateName",
"===",
"'none'",
")",
"return",
"fragment",
".",
"_txt",
";",
"var",
"t",
"=",
"generator",
".",
"template$",
"[",
"templateName",
"]",
";",
"if",
"(",... | template renderer handles missing template and template runtime errors | [
"template",
"renderer",
"handles",
"missing",
"template",
"and",
"template",
"runtime",
"errors"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/render.js#L79-L97 | train |
jldec/pub-generator | render.js | renderPage | function renderPage(page) {
var template = pageTemplate(page);
var html = renderTemplate(page, template);
return '<div data-render-page="' + esc(template) + '">' + html + '</div>';
} | javascript | function renderPage(page) {
var template = pageTemplate(page);
var html = renderTemplate(page, template);
return '<div data-render-page="' + esc(template) + '">' + html + '</div>';
} | [
"function",
"renderPage",
"(",
"page",
")",
"{",
"var",
"template",
"=",
"pageTemplate",
"(",
"page",
")",
";",
"var",
"html",
"=",
"renderTemplate",
"(",
"page",
",",
"template",
")",
";",
"return",
"'<div data-render-page=\"'",
"+",
"esc",
"(",
"template",... | render a page with a non-layout page-specific template this provides the primary mode of offline navigation on sites with a single layout this function always wraps in marker divs | [
"render",
"a",
"page",
"with",
"a",
"non",
"-",
"layout",
"page",
"-",
"specific",
"template",
"this",
"provides",
"the",
"primary",
"mode",
"of",
"offline",
"navigation",
"on",
"sites",
"with",
"a",
"single",
"layout",
"this",
"function",
"always",
"wraps",... | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/render.js#L124-L128 | train |
jldec/pub-generator | render.js | docTemplate | function docTemplate(page) {
return page.doclayout ||
(page.notemplate && 'none') ||
(page.nolayout && page.template) ||
(generator.template$['doc-layout'] && 'doc-layout') ||
layoutTemplate(page);
} | javascript | function docTemplate(page) {
return page.doclayout ||
(page.notemplate && 'none') ||
(page.nolayout && page.template) ||
(generator.template$['doc-layout'] && 'doc-layout') ||
layoutTemplate(page);
} | [
"function",
"docTemplate",
"(",
"page",
")",
"{",
"return",
"page",
".",
"doclayout",
"||",
"(",
"page",
".",
"notemplate",
"&&",
"'none'",
")",
"||",
"(",
"page",
".",
"nolayout",
"&&",
"page",
".",
"template",
")",
"||",
"(",
"generator",
".",
"templ... | return name of document template for a page delegate to layoutTemplate if site has no doc template page.notemplate bypasses default templates and returns literal text | [
"return",
"name",
"of",
"document",
"template",
"for",
"a",
"page",
"delegate",
"to",
"layoutTemplate",
"if",
"site",
"has",
"no",
"doc",
"template",
"page",
".",
"notemplate",
"bypasses",
"default",
"templates",
"and",
"returns",
"literal",
"text"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/render.js#L133-L139 | train |
jldec/pub-generator | render.js | rewriteLink | function rewriteLink(href, renderOpts) {
var imgRoute = renderOpts.fqImages && (renderOpts.fqImages.route || '/images/');
var imgPrefix = renderOpts.fqImages && renderOpts.fqImages.url;
var linkPrefix = renderOpts.fqLinks || renderOpts.relPath;
if (imgPrefix && u.startsWith(href, imgRoute)) { href = im... | javascript | function rewriteLink(href, renderOpts) {
var imgRoute = renderOpts.fqImages && (renderOpts.fqImages.route || '/images/');
var imgPrefix = renderOpts.fqImages && renderOpts.fqImages.url;
var linkPrefix = renderOpts.fqLinks || renderOpts.relPath;
if (imgPrefix && u.startsWith(href, imgRoute)) { href = im... | [
"function",
"rewriteLink",
"(",
"href",
",",
"renderOpts",
")",
"{",
"var",
"imgRoute",
"=",
"renderOpts",
".",
"fqImages",
"&&",
"(",
"renderOpts",
".",
"fqImages",
".",
"route",
"||",
"'/images/'",
")",
";",
"var",
"imgPrefix",
"=",
"renderOpts",
".",
"f... | Link rewriting logic - shared by renderLink and renderImage and hb.fixPath | [
"Link",
"rewriting",
"logic",
"-",
"shared",
"by",
"renderLink",
"and",
"renderImage",
"and",
"hb",
".",
"fixPath"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/render.js#L276-L285 | train |
jldec/pub-generator | render.js | inventory | function inventory() {
var images = generator.images = {};
var currentPage;
var baseRenderImage = generator.renderer.image;
generator.renderer.image = function(href, title, text) {
if (!images[href]) { images[href] = []; }
images[href].push(currentPage._href);
return baseRenderImage(... | javascript | function inventory() {
var images = generator.images = {};
var currentPage;
var baseRenderImage = generator.renderer.image;
generator.renderer.image = function(href, title, text) {
if (!images[href]) { images[href] = []; }
images[href].push(currentPage._href);
return baseRenderImage(... | [
"function",
"inventory",
"(",
")",
"{",
"var",
"images",
"=",
"generator",
".",
"images",
"=",
"{",
"}",
";",
"var",
"currentPage",
";",
"var",
"baseRenderImage",
"=",
"generator",
".",
"renderer",
".",
"image",
";",
"generator",
".",
"renderer",
".",
"i... | similar to parseLinks temporarily hooks generator renderer to compile images and links for all pages | [
"similar",
"to",
"parseLinks",
"temporarily",
"hooks",
"generator",
"renderer",
"to",
"compile",
"images",
"and",
"links",
"for",
"all",
"pages"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/render.js#L342-L360 | train |
vadr-vr/VR-Analytics-JSCore | js/dataManager/sessionManager.js | createSession | function createSession(){
// can also check if any ealier session can be used
if (!currentSession){
const createNewSession = _setSessionReferrer();
const currentSessionCookie = utils.getCookie(constants.sessionCookieName);
if (currentSessionCookie && !createNewSession){
... | javascript | function createSession(){
// can also check if any ealier session can be used
if (!currentSession){
const createNewSession = _setSessionReferrer();
const currentSessionCookie = utils.getCookie(constants.sessionCookieName);
if (currentSessionCookie && !createNewSession){
... | [
"function",
"createSession",
"(",
")",
"{",
"// can also check if any ealier session can be used",
"if",
"(",
"!",
"currentSession",
")",
"{",
"const",
"createNewSession",
"=",
"_setSessionReferrer",
"(",
")",
";",
"const",
"currentSessionCookie",
"=",
"utils",
".",
"... | Manages creation of current session.
@memberof DataManager
@private | [
"Manages",
"creation",
"of",
"current",
"session",
"."
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/dataManager/sessionManager.js#L19-L57 | train |
chapmanu/hb | lib/services/instagram/subscriber.js | function(subscription_id) {
var params = {
client_id: this._credentials.client_id,
client_secret: this._credentials.client_secret
};
if (subscription_id==='users') {
params.object = 'user';
} else if (subscription_id==='all') {
params.object = 'all';
} else {
params... | javascript | function(subscription_id) {
var params = {
client_id: this._credentials.client_id,
client_secret: this._credentials.client_secret
};
if (subscription_id==='users') {
params.object = 'user';
} else if (subscription_id==='all') {
params.object = 'all';
} else {
params... | [
"function",
"(",
"subscription_id",
")",
"{",
"var",
"params",
"=",
"{",
"client_id",
":",
"this",
".",
"_credentials",
".",
"client_id",
",",
"client_secret",
":",
"this",
".",
"_credentials",
".",
"client_secret",
"}",
";",
"if",
"(",
"subscription_id",
"=... | Generate request parameters for unsubscribing | [
"Generate",
"request",
"parameters",
"for",
"unsubscribing"
] | 5edd8de89c7c5fdffc3df0c627513889220f7d51 | https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/services/instagram/subscriber.js#L43-L56 | train | |
chapmanu/hb | lib/services/instagram/subscriber.js | function() {
this.subscribe('user', function(error, response) {
if (!error && response) {
logger.info('instagram -', 'users', 'subscription confirmed');
Subscriber.prototype.subscriptions['users'] = response.id;
}
});
} | javascript | function() {
this.subscribe('user', function(error, response) {
if (!error && response) {
logger.info('instagram -', 'users', 'subscription confirmed');
Subscriber.prototype.subscriptions['users'] = response.id;
}
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"subscribe",
"(",
"'user'",
",",
"function",
"(",
"error",
",",
"response",
")",
"{",
"if",
"(",
"!",
"error",
"&&",
"response",
")",
"{",
"logger",
".",
"info",
"(",
"'instagram -'",
",",
"'users'",
",",
"'sub... | Make a users subscription request | [
"Make",
"a",
"users",
"subscription",
"request"
] | 5edd8de89c7c5fdffc3df0c627513889220f7d51 | https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/services/instagram/subscriber.js#L119-L126 | train | |
vid/SenseBase | lib/annotations.js | createAnnotation | function createAnnotation(desc) {
utils.check(['type', 'hasTarget', 'annotatedBy'], desc);
var anno = { type: desc.type, hasTarget: desc.hasTarget, annotatedAt : desc.annotatedAt || new Date().toISOString(), annotatedBy : desc.annotatedBy, state: desc.state || utils.states.annotations.unvalidated};
// used to cr... | javascript | function createAnnotation(desc) {
utils.check(['type', 'hasTarget', 'annotatedBy'], desc);
var anno = { type: desc.type, hasTarget: desc.hasTarget, annotatedAt : desc.annotatedAt || new Date().toISOString(), annotatedBy : desc.annotatedBy, state: desc.state || utils.states.annotations.unvalidated};
// used to cr... | [
"function",
"createAnnotation",
"(",
"desc",
")",
"{",
"utils",
".",
"check",
"(",
"[",
"'type'",
",",
"'hasTarget'",
",",
"'annotatedBy'",
"]",
",",
"desc",
")",
";",
"var",
"anno",
"=",
"{",
"type",
":",
"desc",
".",
"type",
",",
"hasTarget",
":",
... | validates and creates an annotation. pass .roots to insert into hierarchy | [
"validates",
"and",
"creates",
"an",
"annotation",
".",
"pass",
".",
"roots",
"to",
"insert",
"into",
"hierarchy"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/annotations.js#L74-L128 | train |
vid/SenseBase | lib/annotations.js | createRange | function createRange(desc) {
var fields = ['exact', 'offset', 'selector'];
utils.check(fields, desc);
return { exact: desc.exact, offset: desc.offset, selector: desc.selector};
} | javascript | function createRange(desc) {
var fields = ['exact', 'offset', 'selector'];
utils.check(fields, desc);
return { exact: desc.exact, offset: desc.offset, selector: desc.selector};
} | [
"function",
"createRange",
"(",
"desc",
")",
"{",
"var",
"fields",
"=",
"[",
"'exact'",
",",
"'offset'",
",",
"'selector'",
"]",
";",
"utils",
".",
"check",
"(",
"fields",
",",
"desc",
")",
";",
"return",
"{",
"exact",
":",
"desc",
".",
"exact",
",",... | validates and creates an annotation range | [
"validates",
"and",
"creates",
"an",
"annotation",
"range"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/annotations.js#L132-L136 | train |
vid/SenseBase | lib/annotations.js | createInstance | function createInstance(desc) {
var fields = ['exact', 'instance', 'selector'];
utils.check(fields, desc);
return { exact: desc.exact, instance: desc.instance, selector: desc.selector};
} | javascript | function createInstance(desc) {
var fields = ['exact', 'instance', 'selector'];
utils.check(fields, desc);
return { exact: desc.exact, instance: desc.instance, selector: desc.selector};
} | [
"function",
"createInstance",
"(",
"desc",
")",
"{",
"var",
"fields",
"=",
"[",
"'exact'",
",",
"'instance'",
",",
"'selector'",
"]",
";",
"utils",
".",
"check",
"(",
"fields",
",",
"desc",
")",
";",
"return",
"{",
"exact",
":",
"desc",
".",
"exact",
... | validates and creates an annotation instance | [
"validates",
"and",
"creates",
"an",
"annotation",
"instance"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/annotations.js#L139-L143 | train |
vid/SenseBase | web/iframe/injected-iframe.js | diffTable | function diffTable(results) {
var curRefs = $('.references-list li').text().toString().split('\n').map(function(r) { return r.trim(); });
$('#sbResults').html('<table><thead><tr><th>Title</th><th>Created</th><th>Source</th></tr></thead><tbody></tbody></table>');
console.log('diffResults', results);
if (results ... | javascript | function diffTable(results) {
var curRefs = $('.references-list li').text().toString().split('\n').map(function(r) { return r.trim(); });
$('#sbResults').html('<table><thead><tr><th>Title</th><th>Created</th><th>Source</th></tr></thead><tbody></tbody></table>');
console.log('diffResults', results);
if (results ... | [
"function",
"diffTable",
"(",
"results",
")",
"{",
"var",
"curRefs",
"=",
"$",
"(",
"'.references-list li'",
")",
".",
"text",
"(",
")",
".",
"toString",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
".",
"map",
"(",
"function",
"(",
"r",
")",
"{",
"r... | for a demo. sigh. | [
"for",
"a",
"demo",
".",
"sigh",
"."
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/iframe/injected-iframe.js#L22-L83 | train |
vid/SenseBase | web/iframe/injected-iframe.js | findInstanceOffset | function findInstanceOffset(anno, text) {
var re = new RegExp('\\b'+anno.exact+'\\b', 'g'), cur = 1, match;
while ((match = re.exec(text)) !== null) {
if (cur === anno.instance) {
return match.index;
}
cur++;
}
} | javascript | function findInstanceOffset(anno, text) {
var re = new RegExp('\\b'+anno.exact+'\\b', 'g'), cur = 1, match;
while ((match = re.exec(text)) !== null) {
if (cur === anno.instance) {
return match.index;
}
cur++;
}
} | [
"function",
"findInstanceOffset",
"(",
"anno",
",",
"text",
")",
"{",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"'\\\\b'",
"+",
"anno",
".",
"exact",
"+",
"'\\\\b'",
",",
"'g'",
")",
",",
"cur",
"=",
"1",
",",
"match",
";",
"while",
"(",
"(",
"match"... | find the starting position of an instance | [
"find",
"the",
"starting",
"position",
"of",
"an",
"instance"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/iframe/injected-iframe.js#L168-L176 | train |
vid/SenseBase | web/iframe/injected-iframe.js | displayAllAnnos | function displayAllAnnos(treeItems) {
var items = [], selector, newHTML, i;
// two passes; first assign offsets and add to array with the same selector
for (i in treeItems.map) {
var anno = treeItems.map[i];
console.log(anno);
if (anno.selector === 'body') {
anno.selector = '#SBEnc... | javascript | function displayAllAnnos(treeItems) {
var items = [], selector, newHTML, i;
// two passes; first assign offsets and add to array with the same selector
for (i in treeItems.map) {
var anno = treeItems.map[i];
console.log(anno);
if (anno.selector === 'body') {
anno.selector = '#SBEnc... | [
"function",
"displayAllAnnos",
"(",
"treeItems",
")",
"{",
"var",
"items",
"=",
"[",
"]",
",",
"selector",
",",
"newHTML",
",",
"i",
";",
"// two passes; first assign offsets and add to array with the same selector",
"for",
"(",
"i",
"in",
"treeItems",
".",
"map",
... | prepare and display eligible annotations | [
"prepare",
"and",
"display",
"eligible",
"annotations"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/iframe/injected-iframe.js#L179-L220 | train |
vid/SenseBase | web/iframe/injected-iframe.js | insertAnno | function insertAnno(anno, newHTML) {
var annoID = 'SB-anno-' + anno.__id;
var startTag = '<span id="' + annoID + '" class="sbAnnotation sbAnnotation-b">', endTag = '</span>';
anno.offset = findInstanceOffset(anno, newHTML);
return newHTML.substring(0, anno.offset) + startTag + anno.exact + endTag + new... | javascript | function insertAnno(anno, newHTML) {
var annoID = 'SB-anno-' + anno.__id;
var startTag = '<span id="' + annoID + '" class="sbAnnotation sbAnnotation-b">', endTag = '</span>';
anno.offset = findInstanceOffset(anno, newHTML);
return newHTML.substring(0, anno.offset) + startTag + anno.exact + endTag + new... | [
"function",
"insertAnno",
"(",
"anno",
",",
"newHTML",
")",
"{",
"var",
"annoID",
"=",
"'SB-anno-'",
"+",
"anno",
".",
"__id",
";",
"var",
"startTag",
"=",
"'<span id=\"'",
"+",
"annoID",
"+",
"'\" class=\"sbAnnotation sbAnnotation-b\">'",
",",
"endTag",
"=",
... | insert annotation categories at correct position | [
"insert",
"annotation",
"categories",
"at",
"correct",
"position"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/iframe/injected-iframe.js#L223-L229 | train |
Whitebolt/require-extra | src/Module.js | _getParent | function _getParent(config) {
if (config.hasOwnProperty('parent')) {
if (!isString(config.parent)) return config.parent;
if (cache.has(config.parent)) return cache.get(config.parent);
}
return settings.get('parent').parent || settings.get('parent');
} | javascript | function _getParent(config) {
if (config.hasOwnProperty('parent')) {
if (!isString(config.parent)) return config.parent;
if (cache.has(config.parent)) return cache.get(config.parent);
}
return settings.get('parent').parent || settings.get('parent');
} | [
"function",
"_getParent",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"hasOwnProperty",
"(",
"'parent'",
")",
")",
"{",
"if",
"(",
"!",
"isString",
"(",
"config",
".",
"parent",
")",
")",
"return",
"config",
".",
"parent",
";",
"if",
"(",
"cac... | Get the parent of the module we are trying to create. Use the given config object supplied to the constructor.
@private
@param {Object} config Constructor config.
@returns {Module} The parent. | [
"Get",
"the",
"parent",
"of",
"the",
"module",
"we",
"are",
"trying",
"to",
"create",
".",
"Use",
"the",
"given",
"config",
"object",
"supplied",
"to",
"the",
"constructor",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/Module.js#L17-L24 | train |
Whitebolt/require-extra | src/Module.js | _getRequire | function _getRequire(config) {
if (!config.syncRequire && !config.resolveModulePath) return requireLike(config.filename);
const _requireResolver = {
basedir:config.basedir||path.dirname(config.filename),
parent:config.filename,
scope:config.scope,
useSandbox:config.useSandbox,
squashErrors:!!((... | javascript | function _getRequire(config) {
if (!config.syncRequire && !config.resolveModulePath) return requireLike(config.filename);
const _requireResolver = {
basedir:config.basedir||path.dirname(config.filename),
parent:config.filename,
scope:config.scope,
useSandbox:config.useSandbox,
squashErrors:!!((... | [
"function",
"_getRequire",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"config",
".",
"syncRequire",
"&&",
"!",
"config",
".",
"resolveModulePath",
")",
"return",
"requireLike",
"(",
"config",
".",
"filename",
")",
";",
"const",
"_requireResolver",
"=",
"{",
... | Create a require function to pass into the module.
@private
@param {Object} config Module construction config.
@returns {Function} The require function. | [
"Create",
"a",
"require",
"function",
"to",
"pass",
"into",
"the",
"module",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/Module.js#L33-L60 | train |
robeio/robe-json-server | src/server/mixins.js | createId | function createId (coll) {
var _ = this
var idProperty = _.__id()
if (_.isEmpty(coll)) {
return 1
} else {
var id = _.maxBy(coll, function (doc) {
return doc[idProperty]
})[idProperty]
if (_.isFinite(id)) {
// Increment integer id
return ++id
} else {
// Generate str... | javascript | function createId (coll) {
var _ = this
var idProperty = _.__id()
if (_.isEmpty(coll)) {
return 1
} else {
var id = _.maxBy(coll, function (doc) {
return doc[idProperty]
})[idProperty]
if (_.isFinite(id)) {
// Increment integer id
return ++id
} else {
// Generate str... | [
"function",
"createId",
"(",
"coll",
")",
"{",
"var",
"_",
"=",
"this",
"var",
"idProperty",
"=",
"_",
".",
"__id",
"(",
")",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"coll",
")",
")",
"{",
"return",
"1",
"}",
"else",
"{",
"var",
"id",
"=",
"_",
... | Return incremented id or uuid Used to override underscore-db's createId with utils.createId | [
"Return",
"incremented",
"id",
"or",
"uuid",
"Used",
"to",
"override",
"underscore",
"-",
"db",
"s",
"createId",
"with",
"utils",
".",
"createId"
] | 89b217b08b9d01a8e7b5a72c8505337c85f68629 | https://github.com/robeio/robe-json-server/blob/89b217b08b9d01a8e7b5a72c8505337c85f68629/src/server/mixins.js#L38-L56 | train |
socialally/air | lib/air/class.js | hasClass | function hasClass(className) {
var i, val;
for(i = 0;i < this.length;i++) {
val = this.get(i).getAttribute(attr);
val = val ? val.split(/\s+/) : [];
if(~val.indexOf(className)) {
return true;
}
}
return false;
} | javascript | function hasClass(className) {
var i, val;
for(i = 0;i < this.length;i++) {
val = this.get(i).getAttribute(attr);
val = val ? val.split(/\s+/) : [];
if(~val.indexOf(className)) {
return true;
}
}
return false;
} | [
"function",
"hasClass",
"(",
"className",
")",
"{",
"var",
"i",
",",
"val",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
"++",
")",
"{",
"val",
"=",
"this",
".",
"get",
"(",
"i",
")",
".",
"getAttribute",
"(... | Determine whether any of the matched elements are assigned the
given class. | [
"Determine",
"whether",
"any",
"of",
"the",
"matched",
"elements",
"are",
"assigned",
"the",
"given",
"class",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/class.js#L32-L42 | train |
socialally/air | lib/air/class.js | removeClass | function removeClass(className) {
if(!className) {
// remove all classes from all matched elements
this.each(function(el) {
el.removeAttribute(attr);
});
return this;
}
var classes = className.split(/\s+/);
this.each(function(el) {
var val = el.getAttribute(attr);
// no class attri... | javascript | function removeClass(className) {
if(!className) {
// remove all classes from all matched elements
this.each(function(el) {
el.removeAttribute(attr);
});
return this;
}
var classes = className.split(/\s+/);
this.each(function(el) {
var val = el.getAttribute(attr);
// no class attri... | [
"function",
"removeClass",
"(",
"className",
")",
"{",
"if",
"(",
"!",
"className",
")",
"{",
"// remove all classes from all matched elements",
"this",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"el",
".",
"removeAttribute",
"(",
"attr",
")",
";",
"... | Remove a single class, multiple classes, or all classes from
each element in the set of matched elements. | [
"Remove",
"a",
"single",
"class",
"multiple",
"classes",
"or",
"all",
"classes",
"from",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/class.js#L48-L70 | train |
socialally/air | lib/air/class.js | toggleClass | function toggleClass(className) {
var classes = className.split(/\s+/)
, name
, i;
for(i = 0;i < classes.length;i++) {
name = classes[i];
if(this.hasClass(name)) {
this.removeClass(name)
}else{
this.addClass(name)
}
}
} | javascript | function toggleClass(className) {
var classes = className.split(/\s+/)
, name
, i;
for(i = 0;i < classes.length;i++) {
name = classes[i];
if(this.hasClass(name)) {
this.removeClass(name)
}else{
this.addClass(name)
}
}
} | [
"function",
"toggleClass",
"(",
"className",
")",
"{",
"var",
"classes",
"=",
"className",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
",",
"name",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"classes",
".",
"length",
";",
"i",
"++",
... | Add or remove one or more classes from each element in the set of
matched elements depending on the class's presence. | [
"Add",
"or",
"remove",
"one",
"or",
"more",
"classes",
"from",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"depending",
"on",
"the",
"class",
"s",
"presence",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/class.js#L76-L88 | train |
DScheglov/merest | lib/controllers/del-by-id.js | delById | function delById(req, res, next) {
res.__apiMethod = 'delete';
var self = this;
var id = req.params.id;
var filter = this.option('delete', 'filter');
if (filter instanceof Function) filter = filter.call(this, req);
var query = extend({_id: id}, filter);
this.model.remove(query).exec(function(err, a... | javascript | function delById(req, res, next) {
res.__apiMethod = 'delete';
var self = this;
var id = req.params.id;
var filter = this.option('delete', 'filter');
if (filter instanceof Function) filter = filter.call(this, req);
var query = extend({_id: id}, filter);
this.model.remove(query).exec(function(err, a... | [
"function",
"delById",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"__apiMethod",
"=",
"'delete'",
";",
"var",
"self",
"=",
"this",
";",
"var",
"id",
"=",
"req",
".",
"params",
".",
"id",
";",
"var",
"filter",
"=",
"this",
".",
"op... | delById - controller that deletes a model instance
@param {express.Request} req the http(s) request
@param {express.Response} res the http(s) response
@param {Function} next the callback should be called if controller fails
@memberof ModelAPIRouter | [
"delById",
"-",
"controller",
"that",
"deletes",
"a",
"model",
"instance"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/controllers/del-by-id.js#L13-L30 | train |
jldec/pub-generator | update.js | labelFragment | function labelFragment(fragment, func, source) {
// use 'in' to handle case where delim is set to ''
var leftDelim = 'leftDelim' in source ? source.leftDelim : '----';
var rightDelim = 'rightDelim' in source ? source.rightDelim : '----';
var headerDelim = 'headerDelim' in source ? source.heade... | javascript | function labelFragment(fragment, func, source) {
// use 'in' to handle case where delim is set to ''
var leftDelim = 'leftDelim' in source ? source.leftDelim : '----';
var rightDelim = 'rightDelim' in source ? source.rightDelim : '----';
var headerDelim = 'headerDelim' in source ? source.heade... | [
"function",
"labelFragment",
"(",
"fragment",
",",
"func",
",",
"source",
")",
"{",
"// use 'in' to handle case where delim is set to ''",
"var",
"leftDelim",
"=",
"'leftDelim'",
"in",
"source",
"?",
"source",
".",
"leftDelim",
":",
"'----'",
";",
"var",
"rightDelim... | should move into util or parsefragments.js | [
"should",
"move",
"into",
"util",
"or",
"parsefragments",
".",
"js"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/update.js#L158-L181 | train |
jldec/pub-generator | update.js | clientSave | function clientSave() {
u.each(sources, function(source) {
var dirtyFiles = u.filter(source.files, function(file) {
if (file._dirty) { // 1 means unsaved, 2 means saving
file._dirty = 2; // side effect of filter
return true;
}
return false;
});
if (... | javascript | function clientSave() {
u.each(sources, function(source) {
var dirtyFiles = u.filter(source.files, function(file) {
if (file._dirty) { // 1 means unsaved, 2 means saving
file._dirty = 2; // side effect of filter
return true;
}
return false;
});
if (... | [
"function",
"clientSave",
"(",
")",
"{",
"u",
".",
"each",
"(",
"sources",
",",
"function",
"(",
"source",
")",
"{",
"var",
"dirtyFiles",
"=",
"u",
".",
"filter",
"(",
"source",
".",
"files",
",",
"function",
"(",
"file",
")",
"{",
"if",
"(",
"file... | clientSave currently used only in browser | [
"clientSave",
"currently",
"used",
"only",
"in",
"browser"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/update.js#L184-L258 | train |
jldec/pub-generator | update.js | reloadSources | function reloadSources(names) {
names = u.isArray(names) ? names :
names ? [names] :
u.keys(opts.source$);
var results = [];
u.each(names, function(name) {
var source = opts.source$[name];
if (source) {
source._reloadFromSource = true;
results.push(name);... | javascript | function reloadSources(names) {
names = u.isArray(names) ? names :
names ? [names] :
u.keys(opts.source$);
var results = [];
u.each(names, function(name) {
var source = opts.source$[name];
if (source) {
source._reloadFromSource = true;
results.push(name);... | [
"function",
"reloadSources",
"(",
"names",
")",
"{",
"names",
"=",
"u",
".",
"isArray",
"(",
"names",
")",
"?",
"names",
":",
"names",
"?",
"[",
"names",
"]",
":",
"u",
".",
"keys",
"(",
"opts",
".",
"source$",
")",
";",
"var",
"results",
"=",
"[... | trigger reload from source input = string or array of source names, nothing => all | [
"trigger",
"reload",
"from",
"source",
"input",
"=",
"string",
"or",
"array",
"of",
"source",
"names",
"nothing",
"=",
">",
"all"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/update.js#L324-L344 | train |
bigpipe/alcatraz | index.js | Alcatraz | function Alcatraz(method, source, domain) {
if (!(this instanceof Alcatraz)) return new Alcatraz(method, source);
this.domain = domain || ('undefined' !== typeof document ? document.domain : '');
this.method = 'if ('+method+') '+ method;
this.source = source;
this.compiled = null;
} | javascript | function Alcatraz(method, source, domain) {
if (!(this instanceof Alcatraz)) return new Alcatraz(method, source);
this.domain = domain || ('undefined' !== typeof document ? document.domain : '');
this.method = 'if ('+method+') '+ method;
this.source = source;
this.compiled = null;
} | [
"function",
"Alcatraz",
"(",
"method",
",",
"source",
",",
"domain",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Alcatraz",
")",
")",
"return",
"new",
"Alcatraz",
"(",
"method",
",",
"source",
")",
";",
"this",
".",
"domain",
"=",
"domain",
... | Alcatraz is our source code sandboxing.
@constructor
@param {String} method The global/method name that processes messages.
@param {String} source The actual code.
@param {String} domain The domain name.
@api private | [
"Alcatraz",
"is",
"our",
"source",
"code",
"sandboxing",
"."
] | d754bb8607e9c75810b7ff5127d8d30393cb2f34 | https://github.com/bigpipe/alcatraz/blob/d754bb8607e9c75810b7ff5127d8d30393cb2f34/index.js#L12-L19 | train |
bigpipe/alcatraz | index.js | polyconsole | function polyconsole(method) {
var attach = { debug: 1, error: 1, log: 1, warn: 1 };
//
// Ensure that this host environment always has working console.
//
global.console[method] = function polyfilled() {
var args = Array.prototype.slice.call(arguments, 0);
//
// ... | javascript | function polyconsole(method) {
var attach = { debug: 1, error: 1, log: 1, warn: 1 };
//
// Ensure that this host environment always has working console.
//
global.console[method] = function polyfilled() {
var args = Array.prototype.slice.call(arguments, 0);
//
// ... | [
"function",
"polyconsole",
"(",
"method",
")",
"{",
"var",
"attach",
"=",
"{",
"debug",
":",
"1",
",",
"error",
":",
"1",
",",
"log",
":",
"1",
",",
"warn",
":",
"1",
"}",
";",
"//",
"// Ensure that this host environment always has working console.",
"//",
... | Helper method to polyfill our global console method so we can proxy it's
usage to the
@param {String} method The console method we want to polyfill.
@api private | [
"Helper",
"method",
"to",
"polyfill",
"our",
"global",
"console",
"method",
"so",
"we",
"can",
"proxy",
"it",
"s",
"usage",
"to",
"the"
] | d754bb8607e9c75810b7ff5127d8d30393cb2f34 | https://github.com/bigpipe/alcatraz/blob/d754bb8607e9c75810b7ff5127d8d30393cb2f34/index.js#L138-L162 | train |
haraldrudell/nodegod | lib/linearcalendar.js | getDate | function getDate(ymValue) {
checkNumber(ymValue)
var utcFullYear = Math.floor(ymValue / monthsPerYear) + zeroUtcFullYear
var utcMonth = modFix(Math.floor(ymValue), monthsPerYear) + zeroUtcMonth
return new Date(Date.UTC(utcFullYear, utcMonth))
} | javascript | function getDate(ymValue) {
checkNumber(ymValue)
var utcFullYear = Math.floor(ymValue / monthsPerYear) + zeroUtcFullYear
var utcMonth = modFix(Math.floor(ymValue), monthsPerYear) + zeroUtcMonth
return new Date(Date.UTC(utcFullYear, utcMonth))
} | [
"function",
"getDate",
"(",
"ymValue",
")",
"{",
"checkNumber",
"(",
"ymValue",
")",
"var",
"utcFullYear",
"=",
"Math",
".",
"floor",
"(",
"ymValue",
"/",
"monthsPerYear",
")",
"+",
"zeroUtcFullYear",
"var",
"utcMonth",
"=",
"modFix",
"(",
"Math",
".",
"fl... | convert linearValue to Date object | [
"convert",
"linearValue",
"to",
"Date",
"object"
] | 3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21 | https://github.com/haraldrudell/nodegod/blob/3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21/lib/linearcalendar.js#L35-L40 | train |
haraldrudell/nodegod | lib/linearcalendar.js | encodeDate | function encodeDate(date) {
if (!(date instanceof Date)) throw new Error('Value not Date: ' + date)
return (date.getUTCFullYear() * monthsPerYear + date.getUTCMonth()) - yearMonthZero
} | javascript | function encodeDate(date) {
if (!(date instanceof Date)) throw new Error('Value not Date: ' + date)
return (date.getUTCFullYear() * monthsPerYear + date.getUTCMonth()) - yearMonthZero
} | [
"function",
"encodeDate",
"(",
"date",
")",
"{",
"if",
"(",
"!",
"(",
"date",
"instanceof",
"Date",
")",
")",
"throw",
"new",
"Error",
"(",
"'Value not Date: '",
"+",
"date",
")",
"return",
"(",
"date",
".",
"getUTCFullYear",
"(",
")",
"*",
"monthsPerYea... | get linearValue from Date object | [
"get",
"linearValue",
"from",
"Date",
"object"
] | 3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21 | https://github.com/haraldrudell/nodegod/blob/3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21/lib/linearcalendar.js#L43-L46 | train |
ryb73/dealers-choice-meta | packages/server/lib/game-managers/choice-provider/rock-paper-scissors.js | handleIt | function handleIt(cb) {
callbacks = cb;
broadcast = callbacks.broadcast;
let msg = {
cmd: MessageType.RockPaperScissors,
handlerId: id
};
broadcast("action", msg);
// Return a promise for the result
deferred = q.defer();
return deferred.promise;
} | javascript | function handleIt(cb) {
callbacks = cb;
broadcast = callbacks.broadcast;
let msg = {
cmd: MessageType.RockPaperScissors,
handlerId: id
};
broadcast("action", msg);
// Return a promise for the result
deferred = q.defer();
return deferred.promise;
} | [
"function",
"handleIt",
"(",
"cb",
")",
"{",
"callbacks",
"=",
"cb",
";",
"broadcast",
"=",
"callbacks",
".",
"broadcast",
";",
"let",
"msg",
"=",
"{",
"cmd",
":",
"MessageType",
".",
"RockPaperScissors",
",",
"handlerId",
":",
"id",
"}",
";",
"broadcast... | Returns a promise for the ID of the player who won the game | [
"Returns",
"a",
"promise",
"for",
"the",
"ID",
"of",
"the",
"player",
"who",
"won",
"the",
"game"
] | 4632e8897c832b01d944a340cf87d5c807809925 | https://github.com/ryb73/dealers-choice-meta/blob/4632e8897c832b01d944a340cf87d5c807809925/packages/server/lib/game-managers/choice-provider/rock-paper-scissors.js#L34-L47 | train |
ryb73/dealers-choice-meta | packages/server/lib/game-managers/choice-provider/rock-paper-scissors.js | beginCountdown | function beginCountdown() {
let msg = {
cmd: MessageType.RpsCountdown
};
broadcast("action", msg);
q.delay(COUNTDOWN_DELAY).done(determineWinner);
} | javascript | function beginCountdown() {
let msg = {
cmd: MessageType.RpsCountdown
};
broadcast("action", msg);
q.delay(COUNTDOWN_DELAY).done(determineWinner);
} | [
"function",
"beginCountdown",
"(",
")",
"{",
"let",
"msg",
"=",
"{",
"cmd",
":",
"MessageType",
".",
"RpsCountdown",
"}",
";",
"broadcast",
"(",
"\"action\"",
",",
"msg",
")",
";",
"q",
".",
"delay",
"(",
"COUNTDOWN_DELAY",
")",
".",
"done",
"(",
"dete... | This rock-paper-scissors game is SERIOUS | [
"This",
"rock",
"-",
"paper",
"-",
"scissors",
"game",
"is",
"SERIOUS"
] | 4632e8897c832b01d944a340cf87d5c807809925 | https://github.com/ryb73/dealers-choice-meta/blob/4632e8897c832b01d944a340cf87d5c807809925/packages/server/lib/game-managers/choice-provider/rock-paper-scissors.js#L63-L70 | train |
ryb73/dealers-choice-meta | packages/server/lib/game-managers/choice-provider/rock-paper-scissors.js | restartGame | function restartGame(players) {
// Replace the current instance with a new instance
let newGame = new RockPaperScissors(game, players, winCounter, id);
proxy.swap(newGame);
q.delay(RESULTS_DELAY)
.done(function() {
deferred.resolve(newGame.handleIt(callbacks));
});
} | javascript | function restartGame(players) {
// Replace the current instance with a new instance
let newGame = new RockPaperScissors(game, players, winCounter, id);
proxy.swap(newGame);
q.delay(RESULTS_DELAY)
.done(function() {
deferred.resolve(newGame.handleIt(callbacks));
});
} | [
"function",
"restartGame",
"(",
"players",
")",
"{",
"// Replace the current instance with a new instance",
"let",
"newGame",
"=",
"new",
"RockPaperScissors",
"(",
"game",
",",
"players",
",",
"winCounter",
",",
"id",
")",
";",
"proxy",
".",
"swap",
"(",
"newGame"... | Starts a new game of RPS with the given array of players. A delay is added so that the client has time to show the results to the user. | [
"Starts",
"a",
"new",
"game",
"of",
"RPS",
"with",
"the",
"given",
"array",
"of",
"players",
".",
"A",
"delay",
"is",
"added",
"so",
"that",
"the",
"client",
"has",
"time",
"to",
"show",
"the",
"results",
"to",
"the",
"user",
"."
] | 4632e8897c832b01d944a340cf87d5c807809925 | https://github.com/ryb73/dealers-choice-meta/blob/4632e8897c832b01d944a340cf87d5c807809925/packages/server/lib/game-managers/choice-provider/rock-paper-scissors.js#L106-L115 | train |
nodeca/hike-js | lib/shared.js | containsPath | function containsPath(self, dirname) {
return self.__paths__.some(function(p) {
return p === dirname.substr(0, p.length);
});
} | javascript | function containsPath(self, dirname) {
return self.__paths__.some(function(p) {
return p === dirname.substr(0, p.length);
});
} | [
"function",
"containsPath",
"(",
"self",
",",
"dirname",
")",
"{",
"return",
"self",
".",
"__paths__",
".",
"some",
"(",
"function",
"(",
"p",
")",
"{",
"return",
"p",
"===",
"dirname",
".",
"substr",
"(",
"0",
",",
"p",
".",
"length",
")",
";",
"}... | Returns true if `dirname` is a subdirectory of any of the `paths` | [
"Returns",
"true",
"if",
"dirname",
"is",
"a",
"subdirectory",
"of",
"any",
"of",
"the",
"paths"
] | 8d9b71473c7b1fa46991738b02e8f1e60b843d99 | https://github.com/nodeca/hike-js/blob/8d9b71473c7b1fa46991738b02e8f1e60b843d99/lib/shared.js#L59-L63 | train |
nodeca/hike-js | lib/shared.js | sortMatches | function sortMatches(self, matches, basename) {
var weights = {};
var ext_name = path.extname(basename);
var aliases = has(self.__aliases__, ext_name) ? self.__aliases__[ext_name] : [];
matches.forEach(function(match) {
// XXX: this doesn't work well with aliases
// i.e. entry=index.php, extna... | javascript | function sortMatches(self, matches, basename) {
var weights = {};
var ext_name = path.extname(basename);
var aliases = has(self.__aliases__, ext_name) ? self.__aliases__[ext_name] : [];
matches.forEach(function(match) {
// XXX: this doesn't work well with aliases
// i.e. entry=index.php, extna... | [
"function",
"sortMatches",
"(",
"self",
",",
"matches",
",",
"basename",
")",
"{",
"var",
"weights",
"=",
"{",
"}",
";",
"var",
"ext_name",
"=",
"path",
".",
"extname",
"(",
"basename",
")",
";",
"var",
"aliases",
"=",
"has",
"(",
"self",
".",
"__ali... | Sorts candidate matches by their extension priority. Extensions in the front of the `extensions` carry more weight. | [
"Sorts",
"candidate",
"matches",
"by",
"their",
"extension",
"priority",
".",
"Extensions",
"in",
"the",
"front",
"of",
"the",
"extensions",
"carry",
"more",
"weight",
"."
] | 8d9b71473c7b1fa46991738b02e8f1e60b843d99 | https://github.com/nodeca/hike-js/blob/8d9b71473c7b1fa46991738b02e8f1e60b843d99/lib/shared.js#L92-L126 | train |
nodeca/hike-js | lib/shared.js | match | function match(self, dirname, basename, callback) {
var pathname, stats, pattern, matches;
pattern = patternFor(self, basename);
matches = self.entries(dirname).filter(function(m) { return pattern.test(m); });
matches = sortMatches(self, matches, basename);
while (matches.length) {
pathname = path.join... | javascript | function match(self, dirname, basename, callback) {
var pathname, stats, pattern, matches;
pattern = patternFor(self, basename);
matches = self.entries(dirname).filter(function(m) { return pattern.test(m); });
matches = sortMatches(self, matches, basename);
while (matches.length) {
pathname = path.join... | [
"function",
"match",
"(",
"self",
",",
"dirname",
",",
"basename",
",",
"callback",
")",
"{",
"var",
"pathname",
",",
"stats",
",",
"pattern",
",",
"matches",
";",
"pattern",
"=",
"patternFor",
"(",
"self",
",",
"basename",
")",
";",
"matches",
"=",
"s... | Checks if the path is actually on the file system and performs any syscalls if necessary. | [
"Checks",
"if",
"the",
"path",
"is",
"actually",
"on",
"the",
"file",
"system",
"and",
"performs",
"any",
"syscalls",
"if",
"necessary",
"."
] | 8d9b71473c7b1fa46991738b02e8f1e60b843d99 | https://github.com/nodeca/hike-js/blob/8d9b71473c7b1fa46991738b02e8f1e60b843d99/lib/shared.js#L130-L145 | train |
vadr-vr/VR-Analytics-JSCore | js/dataCollector/dataCollector.js | setPositionCallback | function setPositionCallback(positionFunction){
if (typeof(positionFunction) == 'function'){
orientationCollector.setPositionCallback(positionFunction);
callbacks.positionCallback = positionFunction;
}
else
logger.warn('Trying to set a non function object as position callback');
... | javascript | function setPositionCallback(positionFunction){
if (typeof(positionFunction) == 'function'){
orientationCollector.setPositionCallback(positionFunction);
callbacks.positionCallback = positionFunction;
}
else
logger.warn('Trying to set a non function object as position callback');
... | [
"function",
"setPositionCallback",
"(",
"positionFunction",
")",
"{",
"if",
"(",
"typeof",
"(",
"positionFunction",
")",
"==",
"'function'",
")",
"{",
"orientationCollector",
".",
"setPositionCallback",
"(",
"positionFunction",
")",
";",
"callbacks",
".",
"positionC... | Sets the function to call when setting position
@memberof DataCollector
@param {function} positionFunction | [
"Sets",
"the",
"function",
"to",
"call",
"when",
"setting",
"position"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/dataCollector/dataCollector.js#L65-L76 | train |
vadr-vr/VR-Analytics-JSCore | js/dataCollector/dataCollector.js | configureEventCollection | function configureEventCollection(eventType, collectionStatus, timePeriod){
if (eventType in dataConfig){
// check that collection status is present as true or false
collectionStatus = collectionStatus == false ? false : true;
dataConfig[eventType].status = collectionStatus;
if(!i... | javascript | function configureEventCollection(eventType, collectionStatus, timePeriod){
if (eventType in dataConfig){
// check that collection status is present as true or false
collectionStatus = collectionStatus == false ? false : true;
dataConfig[eventType].status = collectionStatus;
if(!i... | [
"function",
"configureEventCollection",
"(",
"eventType",
",",
"collectionStatus",
",",
"timePeriod",
")",
"{",
"if",
"(",
"eventType",
"in",
"dataConfig",
")",
"{",
"// check that collection status is present as true or false",
"collectionStatus",
"=",
"collectionStatus",
... | Configures which events to collect by default and by what frequency
@memberof DataCollector
@param {string} eventType type of event - Orientation, Gaze, Performance
@param {boolean} collectionStatus set to true if you want to collect the event
@param {number} timePeriod time period in milliseconds after which to collec... | [
"Configures",
"which",
"events",
"to",
"collect",
"by",
"default",
"and",
"by",
"what",
"frequency"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/dataCollector/dataCollector.js#L121-L146 | train |
vadr-vr/VR-Analytics-JSCore | js/dataCollector/dataCollector.js | tick | function tick(){
performanceCollector.tick();
const useMedia = dataManager.getMediaState();
const playTimeSinceStart = timeManager.getPlayTimeSinceStart();
for (let key in dataConfig){
const infoDict = dataConfig[key];
if (infoDict.status &&
playTimeSinceStart - infoDic... | javascript | function tick(){
performanceCollector.tick();
const useMedia = dataManager.getMediaState();
const playTimeSinceStart = timeManager.getPlayTimeSinceStart();
for (let key in dataConfig){
const infoDict = dataConfig[key];
if (infoDict.status &&
playTimeSinceStart - infoDic... | [
"function",
"tick",
"(",
")",
"{",
"performanceCollector",
".",
"tick",
"(",
")",
";",
"const",
"useMedia",
"=",
"dataManager",
".",
"getMediaState",
"(",
")",
";",
"const",
"playTimeSinceStart",
"=",
"timeManager",
".",
"getPlayTimeSinceStart",
"(",
")",
";",... | Checks if any default data needs to be collected after each frame
@memberof DataCollector | [
"Checks",
"if",
"any",
"default",
"data",
"needs",
"to",
"be",
"collected",
"after",
"each",
"frame"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/dataCollector/dataCollector.js#L152-L180 | train |
vadr-vr/VR-Analytics-JSCore | js/dataCollector/dataCollector.js | _setEvents | function _setEvents(eventsArray){
for (let i = 0; i < eventsArray.length; i++){
let event = eventsArray[i];
dataManager.registerEvent(event[0], event[1], event[2]);
}
} | javascript | function _setEvents(eventsArray){
for (let i = 0; i < eventsArray.length; i++){
let event = eventsArray[i];
dataManager.registerEvent(event[0], event[1], event[2]);
}
} | [
"function",
"_setEvents",
"(",
"eventsArray",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"eventsArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"let",
"event",
"=",
"eventsArray",
"[",
"i",
"]",
";",
"dataManager",
".",
"registerEven... | collects the events from the given array and adds to datamanager | [
"collects",
"the",
"events",
"from",
"the",
"given",
"array",
"and",
"adds",
"to",
"datamanager"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/dataCollector/dataCollector.js#L183-L192 | train |
mesmotronic/conbo | src/conbo/binding/BindingUtils.js | function(propertyName, value)
{
if (this[propertyName] === value)
{
return this;
}
// Ensure numbers are returned as Number not String
if (value && conbo.isString(value) && !isNaN(value))
{
value = parseFloat(value);
if (isNaN(value)) value = '';
}
this[propertyName] = valu... | javascript | function(propertyName, value)
{
if (this[propertyName] === value)
{
return this;
}
// Ensure numbers are returned as Number not String
if (value && conbo.isString(value) && !isNaN(value))
{
value = parseFloat(value);
if (isNaN(value)) value = '';
}
this[propertyName] = valu... | [
"function",
"(",
"propertyName",
",",
"value",
")",
"{",
"if",
"(",
"this",
"[",
"propertyName",
"]",
"===",
"value",
")",
"{",
"return",
"this",
";",
"}",
"// Ensure numbers are returned as Number not String\r",
"if",
"(",
"value",
"&&",
"conbo",
".",
"isStri... | Set the value of a property, ensuring Numbers are types correctly
@private
@param propertyName
@param value
@example BindingUtils__set.call(target, 'n', 123);
@returns this | [
"Set",
"the",
"value",
"of",
"a",
"property",
"ensuring",
"Numbers",
"are",
"types",
"correctly"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/BindingUtils.js#L18-L35 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.