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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
synder/xpress | demo/body-parser/index.js | bodyParser | function bodyParser (options) {
var opts = {}
// exclude type option
if (options) {
for (var prop in options) {
if (prop !== 'type') {
opts[prop] = options[prop]
}
}
}
var _urlencoded = exports.urlencoded(opts)
var _json = exports.json(opts)
return function bodyParser (req, ... | javascript | function bodyParser (options) {
var opts = {}
// exclude type option
if (options) {
for (var prop in options) {
if (prop !== 'type') {
opts[prop] = options[prop]
}
}
}
var _urlencoded = exports.urlencoded(opts)
var _json = exports.json(opts)
return function bodyParser (req, ... | [
"function",
"bodyParser",
"(",
"options",
")",
"{",
"var",
"opts",
"=",
"{",
"}",
"// exclude type option",
"if",
"(",
"options",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"options",
")",
"{",
"if",
"(",
"prop",
"!==",
"'type'",
")",
"{",
"opts",
"[... | Create a middleware to parse json and urlencoded bodies.
@param {object} [options]
@return {function}
@deprecated
@public | [
"Create",
"a",
"middleware",
"to",
"parse",
"json",
"and",
"urlencoded",
"bodies",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/index.js#L93-L114 | train |
synder/xpress | demo/body-parser/index.js | loadParser | function loadParser (parserName) {
var parser = parsers[parserName]
if (parser !== undefined) {
return parser
}
// this uses a switch for static require analysis
switch (parserName) {
case 'json':
parser = require('./lib/types/json')
break
case 'raw':
parser = require('./lib/ty... | javascript | function loadParser (parserName) {
var parser = parsers[parserName]
if (parser !== undefined) {
return parser
}
// this uses a switch for static require analysis
switch (parserName) {
case 'json':
parser = require('./lib/types/json')
break
case 'raw':
parser = require('./lib/ty... | [
"function",
"loadParser",
"(",
"parserName",
")",
"{",
"var",
"parser",
"=",
"parsers",
"[",
"parserName",
"]",
"if",
"(",
"parser",
"!==",
"undefined",
")",
"{",
"return",
"parser",
"}",
"// this uses a switch for static require analysis",
"switch",
"(",
"parserN... | Load a parser module.
@private | [
"Load",
"a",
"parser",
"module",
"."
] | 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/index.js#L132-L157 | train |
imperodesign/jquery-autoselect | index.js | function( term ) {
var split_term = term.split(' ');
var matchers = [];
for (var i=0; i < split_term.length; i++) {
if ( split_term[i].length > 0 ) {
var matcher = {};
matcher['partial'] = new RegExp( $.ui.autocomplete.escapeRegex( split_term[i] ), "i" );
... | javascript | function( term ) {
var split_term = term.split(' ');
var matchers = [];
for (var i=0; i < split_term.length; i++) {
if ( split_term[i].length > 0 ) {
var matcher = {};
matcher['partial'] = new RegExp( $.ui.autocomplete.escapeRegex( split_term[i] ), "i" );
... | [
"function",
"(",
"term",
")",
"{",
"var",
"split_term",
"=",
"term",
".",
"split",
"(",
"' '",
")",
";",
"var",
"matchers",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"split_term",
".",
"length",
";",
"i",
"++",
")",
... | loose matching of search terms | [
"loose",
"matching",
"of",
"search",
"terms"
] | c4c92c7458f00b281128a8a2ba59381f105829b6 | https://github.com/imperodesign/jquery-autoselect/blob/c4c92c7458f00b281128a8a2ba59381f105829b6/index.js#L158-L202 | train | |
imperodesign/jquery-autoselect | index.js | function( option ) {
if ( option ) {
if ( context.$select_field.val() !== option['real-value'] ) {
context.$select_field.val( option['real-value'] );
context.$select_field.change();
}
} else {
var option_name = context.$text_field.val().toLowerCase()... | javascript | function( option ) {
if ( option ) {
if ( context.$select_field.val() !== option['real-value'] ) {
context.$select_field.val( option['real-value'] );
context.$select_field.change();
}
} else {
var option_name = context.$text_field.val().toLowerCase()... | [
"function",
"(",
"option",
")",
"{",
"if",
"(",
"option",
")",
"{",
"if",
"(",
"context",
".",
"$select_field",
".",
"val",
"(",
")",
"!==",
"option",
"[",
"'real-value'",
"]",
")",
"{",
"context",
".",
"$select_field",
".",
"val",
"(",
"option",
"["... | update the select field value using either selected option or current input in the text field | [
"update",
"the",
"select",
"field",
"value",
"using",
"either",
"selected",
"option",
"or",
"current",
"input",
"in",
"the",
"text",
"field"
] | c4c92c7458f00b281128a8a2ba59381f105829b6 | https://github.com/imperodesign/jquery-autoselect/blob/c4c92c7458f00b281128a8a2ba59381f105829b6/index.js#L204-L230 | train | |
wvv8oo/charm.js | samples/js/q.js | coerce | function coerce(promise) {
var deferred = defer();
nextTick(function () {
try {
promise.then(deferred.resolve, deferred.reject, deferred.notify);
} catch (exception) {
deferred.reject(exception);
}
});
return deferred.pr... | javascript | function coerce(promise) {
var deferred = defer();
nextTick(function () {
try {
promise.then(deferred.resolve, deferred.reject, deferred.notify);
} catch (exception) {
deferred.reject(exception);
}
});
return deferred.pr... | [
"function",
"coerce",
"(",
"promise",
")",
"{",
"var",
"deferred",
"=",
"defer",
"(",
")",
";",
"nextTick",
"(",
"function",
"(",
")",
"{",
"try",
"{",
"promise",
".",
"then",
"(",
"deferred",
".",
"resolve",
",",
"deferred",
".",
"reject",
",",
"def... | Converts thenables to Q promises.
@param promise thenable promise
@returns a Q promise | [
"Converts",
"thenables",
"to",
"Q",
"promises",
"."
] | 1c6098873bf065cf9db13fb0970d7eabe62fb72c | https://github.com/wvv8oo/charm.js/blob/1c6098873bf065cf9db13fb0970d7eabe62fb72c/samples/js/q.js#L1093-L1103 | train |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | iterDeps | function iterDeps(method, obj, depKey, seen, meta) {
var guid = guidFor(obj);
if (!seen[guid]) seen[guid] = {};
if (seen[guid][depKey]) return;
seen[guid][depKey] = true;
var deps = meta.deps;
deps = deps && deps[depKey];
if (deps) {
for(var key in deps) {
if (DEP_SKIP[key]) continue;
me... | javascript | function iterDeps(method, obj, depKey, seen, meta) {
var guid = guidFor(obj);
if (!seen[guid]) seen[guid] = {};
if (seen[guid][depKey]) return;
seen[guid][depKey] = true;
var deps = meta.deps;
deps = deps && deps[depKey];
if (deps) {
for(var key in deps) {
if (DEP_SKIP[key]) continue;
me... | [
"function",
"iterDeps",
"(",
"method",
",",
"obj",
",",
"depKey",
",",
"seen",
",",
"meta",
")",
"{",
"var",
"guid",
"=",
"guidFor",
"(",
"obj",
")",
";",
"if",
"(",
"!",
"seen",
"[",
"guid",
"]",
")",
"seen",
"[",
"guid",
"]",
"=",
"{",
"}",
... | skip some keys and toString @private | [
"skip",
"some",
"keys",
"and",
"toString"
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L2046-L2061 | train |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | actionSetFor | function actionSetFor(obj, eventName, target, writable) {
return metaPath(obj, ['listeners', eventName, guidFor(target)], writable);
} | javascript | function actionSetFor(obj, eventName, target, writable) {
return metaPath(obj, ['listeners', eventName, guidFor(target)], writable);
} | [
"function",
"actionSetFor",
"(",
"obj",
",",
"eventName",
",",
"target",
",",
"writable",
")",
"{",
"return",
"metaPath",
"(",
"obj",
",",
"[",
"'listeners'",
",",
"eventName",
",",
"guidFor",
"(",
"target",
")",
"]",
",",
"writable",
")",
";",
"}"
] | Gets the set of all actions, keyed on the guid of each action's method property. @private | [
"Gets",
"the",
"set",
"of",
"all",
"actions",
"keyed",
"on",
"the",
"guid",
"of",
"each",
"action",
"s",
"method",
"property",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L3122-L3124 | train |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | targetSetFor | function targetSetFor(obj, eventName) {
var listenerSet = meta(obj, false).listeners;
if (!listenerSet) { return false; }
return listenerSet[eventName] || false;
} | javascript | function targetSetFor(obj, eventName) {
var listenerSet = meta(obj, false).listeners;
if (!listenerSet) { return false; }
return listenerSet[eventName] || false;
} | [
"function",
"targetSetFor",
"(",
"obj",
",",
"eventName",
")",
"{",
"var",
"listenerSet",
"=",
"meta",
"(",
"obj",
",",
"false",
")",
".",
"listeners",
";",
"if",
"(",
"!",
"listenerSet",
")",
"{",
"return",
"false",
";",
"}",
"return",
"listenerSet",
... | Gets the set of all targets, keyed on the guid of each action's target property. @private | [
"Gets",
"the",
"set",
"of",
"all",
"targets",
"keyed",
"on",
"the",
"guid",
"of",
"each",
"action",
"s",
"target",
"property",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L3129-L3134 | train |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | addListener | function addListener(obj, eventName, target, method) {
Ember.assert("You must pass at least an object and event name to Ember.addListener", !!obj && !!eventName);
if (!method && 'function' === typeof target) {
method = target;
target = null;
}
var actionSet = actionSetFor(obj, eventName, target, true)... | javascript | function addListener(obj, eventName, target, method) {
Ember.assert("You must pass at least an object and event name to Ember.addListener", !!obj && !!eventName);
if (!method && 'function' === typeof target) {
method = target;
target = null;
}
var actionSet = actionSetFor(obj, eventName, target, true)... | [
"function",
"addListener",
"(",
"obj",
",",
"eventName",
",",
"target",
",",
"method",
")",
"{",
"Ember",
".",
"assert",
"(",
"\"You must pass at least an object and event name to Ember.addListener\"",
",",
"!",
"!",
"obj",
"&&",
"!",
"!",
"eventName",
")",
";",
... | The sendEvent arguments > 2 are passed to an event listener.
@memberOf Ember | [
"The",
"sendEvent",
"arguments",
">",
"2",
"are",
"passed",
"to",
"an",
"event",
"listener",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L3185-L3203 | train |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | watchedEvents | function watchedEvents(obj) {
var listeners = meta(obj, false).listeners, ret = [];
if (listeners) {
for(var eventName in listeners) {
if (!SKIP_PROPERTIES[eventName] && listeners[eventName]) {
ret.push(eventName);
}
}
}
return ret;
} | javascript | function watchedEvents(obj) {
var listeners = meta(obj, false).listeners, ret = [];
if (listeners) {
for(var eventName in listeners) {
if (!SKIP_PROPERTIES[eventName] && listeners[eventName]) {
ret.push(eventName);
}
}
}
return ret;
} | [
"function",
"watchedEvents",
"(",
"obj",
")",
"{",
"var",
"listeners",
"=",
"meta",
"(",
"obj",
",",
"false",
")",
".",
"listeners",
",",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"listeners",
")",
"{",
"for",
"(",
"var",
"eventName",
"in",
"listeners",
... | returns a list of currently watched events @memberOf Ember | [
"returns",
"a",
"list",
"of",
"currently",
"watched",
"events"
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L3253-L3264 | train |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(str) {
return str.replace(STRING_CAMELIZE_REGEXP, function(match, separator, chr) {
return chr ? chr.toUpperCase() : '';
});
} | javascript | function(str) {
return str.replace(STRING_CAMELIZE_REGEXP, function(match, separator, chr) {
return chr ? chr.toUpperCase() : '';
});
} | [
"function",
"(",
"str",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"STRING_CAMELIZE_REGEXP",
",",
"function",
"(",
"match",
",",
"separator",
",",
"chr",
")",
"{",
"return",
"chr",
"?",
"chr",
".",
"toUpperCase",
"(",
")",
":",
"''",
";",
"}",
"... | Returns the lowerCaseCamel form of a string.
'innerHTML'.camelize() => 'innerHTML'
'action_name'.camelize() => 'actionName'
'css-class-name'.camelize() => 'cssClassName'
'my favorite items'.camelize() => 'myFavoriteItems'
@param {String} str
The string to camelize.
@returns {String} the camelized st... | [
"Returns",
"the",
"lowerCaseCamel",
"form",
"of",
"a",
"string",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L5571-L5575 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function() {
if (this.isDestroying) { return; }
this.isDestroying = true;
if (this.willDestroy) { this.willDestroy(); }
set(this, 'isDestroyed', true);
Ember.run.schedule('destroy', this, this._scheduledDestroy);
return this;
} | javascript | function() {
if (this.isDestroying) { return; }
this.isDestroying = true;
if (this.willDestroy) { this.willDestroy(); }
set(this, 'isDestroyed', true);
Ember.run.schedule('destroy', this, this._scheduledDestroy);
return this;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isDestroying",
")",
"{",
"return",
";",
"}",
"this",
".",
"isDestroying",
"=",
"true",
";",
"if",
"(",
"this",
".",
"willDestroy",
")",
"{",
"this",
".",
"willDestroy",
"(",
")",
";",
"}",
"set",
... | Destroys an object by setting the isDestroyed flag and removing its
metadata, which effectively destroys observers and bindings.
If you try to set a property on a destroyed object, an exception will be
raised.
Note that destruction is scheduled for the end of the run loop and does not
happen immediately.
@returns {E... | [
"Destroys",
"an",
"object",
"by",
"setting",
"the",
"isDestroyed",
"flag",
"and",
"removing",
"its",
"metadata",
"which",
"effectively",
"destroys",
"observers",
"and",
"bindings",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L8322-L8332 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(router) {
var properties = Ember.A(Ember.keys(this)),
injections = get(this.constructor, 'injections'),
namespace = this, controller, name;
if (!router && Ember.Router.detect(namespace['Router'])) {
router = namespace['Router'].create();
this._createdRouter = router;
}
... | javascript | function(router) {
var properties = Ember.A(Ember.keys(this)),
injections = get(this.constructor, 'injections'),
namespace = this, controller, name;
if (!router && Ember.Router.detect(namespace['Router'])) {
router = namespace['Router'].create();
this._createdRouter = router;
}
... | [
"function",
"(",
"router",
")",
"{",
"var",
"properties",
"=",
"Ember",
".",
"A",
"(",
"Ember",
".",
"keys",
"(",
"this",
")",
")",
",",
"injections",
"=",
"get",
"(",
"this",
".",
"constructor",
",",
"'injections'",
")",
",",
"namespace",
"=",
"this... | Instantiate all controllers currently available on the namespace
and inject them onto a router.
Example:
App.PostsController = Ember.ArrayController.extend();
App.CommentsController = Ember.ArrayController.extend();
var router = Ember.Router.create({
...
});
App.initialize(router);
router.get('postsController') ... | [
"Instantiate",
"all",
"controllers",
"currently",
"available",
"on",
"the",
"namespace",
"and",
"inject",
"them",
"onto",
"a",
"router",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L10220-L10253 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(tagName, parent, fn, other) {
var buffer = new Ember._RenderBuffer(tagName);
buffer.parentBuffer = parent;
if (other) { Ember.$.extend(buffer, other); }
if (fn) { fn.call(this, buffer); }
return buffer;
} | javascript | function(tagName, parent, fn, other) {
var buffer = new Ember._RenderBuffer(tagName);
buffer.parentBuffer = parent;
if (other) { Ember.$.extend(buffer, other); }
if (fn) { fn.call(this, buffer); }
return buffer;
} | [
"function",
"(",
"tagName",
",",
"parent",
",",
"fn",
",",
"other",
")",
"{",
"var",
"buffer",
"=",
"new",
"Ember",
".",
"_RenderBuffer",
"(",
"tagName",
")",
";",
"buffer",
".",
"parentBuffer",
"=",
"parent",
";",
"if",
"(",
"other",
")",
"{",
"Embe... | Create a new child render buffer from a parent buffer. Optionally set
additional properties on the buffer. Optionally invoke a callback
with the newly created buffer.
This is a primitive method used by other public methods: `begin`,
`prepend`, `replaceWith`, `insertAfter`.
@private
@param {String} tagName Tag name to... | [
"Create",
"a",
"new",
"child",
"render",
"buffer",
"from",
"a",
"parent",
"buffer",
".",
"Optionally",
"set",
"additional",
"properties",
"on",
"the",
"buffer",
".",
"Optionally",
"invoke",
"a",
"callback",
"with",
"the",
"newly",
"created",
"buffer",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L10914-L10922 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(newBuffer) {
var parent = this.parentBuffer;
if (!parent) { return; }
var childBuffers = parent.childBuffers;
var index = indexOf.call(childBuffers, this);
if (newBuffer) {
childBuffers.splice(index, 1, newBuffer);
} else {
childBuffers.splice(index, 1);
}
} | javascript | function(newBuffer) {
var parent = this.parentBuffer;
if (!parent) { return; }
var childBuffers = parent.childBuffers;
var index = indexOf.call(childBuffers, this);
if (newBuffer) {
childBuffers.splice(index, 1, newBuffer);
} else {
childBuffers.splice(index, 1);
}
} | [
"function",
"(",
"newBuffer",
")",
"{",
"var",
"parent",
"=",
"this",
".",
"parentBuffer",
";",
"if",
"(",
"!",
"parent",
")",
"{",
"return",
";",
"}",
"var",
"childBuffers",
"=",
"parent",
".",
"childBuffers",
";",
"var",
"index",
"=",
"indexOf",
".",... | Replace the current buffer with a new buffer. This is a primitive
used by `remove`, which passes `null` for `newBuffer`, and `replaceWith`,
which passes the new buffer it created.
@private
@param {Ember._RenderBuffer} buffer The buffer to insert in place of
the existing buffer. | [
"Replace",
"the",
"current",
"buffer",
"with",
"a",
"new",
"buffer",
".",
"This",
"is",
"a",
"primitive",
"used",
"by",
"remove",
"which",
"passes",
"null",
"for",
"newBuffer",
"and",
"replaceWith",
"which",
"passes",
"the",
"new",
"buffer",
"it",
"created",... | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L10933-L10946 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(tagName) {
var parentBuffer = get(this, 'parentBuffer');
return this.newBuffer(tagName, parentBuffer, function(buffer) {
var siblings = parentBuffer.childBuffers;
var index = indexOf.call(siblings, this);
siblings.splice(index + 1, 0, buffer);
});
} | javascript | function(tagName) {
var parentBuffer = get(this, 'parentBuffer');
return this.newBuffer(tagName, parentBuffer, function(buffer) {
var siblings = parentBuffer.childBuffers;
var index = indexOf.call(siblings, this);
siblings.splice(index + 1, 0, buffer);
});
} | [
"function",
"(",
"tagName",
")",
"{",
"var",
"parentBuffer",
"=",
"get",
"(",
"this",
",",
"'parentBuffer'",
")",
";",
"return",
"this",
".",
"newBuffer",
"(",
"tagName",
",",
"parentBuffer",
",",
"function",
"(",
"buffer",
")",
"{",
"var",
"siblings",
"... | Insert a new render buffer after the current render buffer.
@param {String} tagName Tag name to use for the new buffer's element | [
"Insert",
"a",
"new",
"render",
"buffer",
"after",
"the",
"current",
"render",
"buffer",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L10991-L10999 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(name, context) {
// Normalize arguments. Supported arguments:
//
// name
// name, context
// outletName, name
// outletName, name, context
// options
//
// The options hash has the following keys:
//
// name: the name of the controller and view
// to use. I... | javascript | function(name, context) {
// Normalize arguments. Supported arguments:
//
// name
// name, context
// outletName, name
// outletName, name, context
// options
//
// The options hash has the following keys:
//
// name: the name of the controller and view
// to use. I... | [
"function",
"(",
"name",
",",
"context",
")",
"{",
"// Normalize arguments. Supported arguments:",
"//",
"// name",
"// name, context",
"// outletName, name",
"// outletName, name, context",
"// options",
"//",
"// The options hash has the following keys:",
"//",
"// name: the na... | `connectOutlet` creates a new instance of a provided view
class, wires it up to its associated controller, and
assigns the new view to a property on the current controller.
The purpose of this method is to enable views that use
outlets to quickly assign new views for a given outlet.
For example, an application view's... | [
"connectOutlet",
"creates",
"a",
"new",
"instance",
"of",
"a",
"provided",
"view",
"class",
"wires",
"it",
"up",
"to",
"its",
"associated",
"controller",
"and",
"assigns",
"the",
"new",
"view",
"to",
"a",
"property",
"on",
"the",
"current",
"controller",
"."... | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L11396-L11462 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function() {
var controllers = get(this, 'controllers'),
controllerNames = Array.prototype.slice.apply(arguments),
controllerName;
for (var i=0, l=controllerNames.length; i<l; i++) {
controllerName = controllerNames[i] + 'Controller';
set(this, controllerName, get(controllers, contr... | javascript | function() {
var controllers = get(this, 'controllers'),
controllerNames = Array.prototype.slice.apply(arguments),
controllerName;
for (var i=0, l=controllerNames.length; i<l; i++) {
controllerName = controllerNames[i] + 'Controller';
set(this, controllerName, get(controllers, contr... | [
"function",
"(",
")",
"{",
"var",
"controllers",
"=",
"get",
"(",
"this",
",",
"'controllers'",
")",
",",
"controllerNames",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
",",
"controllerName",
";",
"for",
"(",
"var",... | Convenience method to connect controllers. This method makes other controllers
available on the controller the method was invoked on.
For example, to make the `personController` and the `postController` available
on the `overviewController`, you would call:
overviewController.connectControllers('person', 'post');
@p... | [
"Convenience",
"method",
"to",
"connect",
"controllers",
".",
"This",
"method",
"makes",
"other",
"controllers",
"available",
"on",
"the",
"controller",
"the",
"method",
"was",
"invoked",
"on",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L11475-L11484 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(buffer) {
var attributeBindings = get(this, 'attributeBindings'),
attributeValue, elem, type;
if (!attributeBindings) { return; }
a_forEach(attributeBindings, function(binding) {
var split = binding.split(':'),
property = split[0],
attributeName = split[1] || pro... | javascript | function(buffer) {
var attributeBindings = get(this, 'attributeBindings'),
attributeValue, elem, type;
if (!attributeBindings) { return; }
a_forEach(attributeBindings, function(binding) {
var split = binding.split(':'),
property = split[0],
attributeName = split[1] || pro... | [
"function",
"(",
"buffer",
")",
"{",
"var",
"attributeBindings",
"=",
"get",
"(",
"this",
",",
"'attributeBindings'",
")",
",",
"attributeValue",
",",
"elem",
",",
"type",
";",
"if",
"(",
"!",
"attributeBindings",
")",
"{",
"return",
";",
"}",
"a_forEach",... | Iterates through the view's attribute bindings, sets up observers for each,
then applies the current value of the attributes to the passed render buffer.
@param {Ember.RenderBuffer} buffer | [
"Iterates",
"through",
"the",
"view",
"s",
"attribute",
"bindings",
"sets",
"up",
"observers",
"for",
"each",
"then",
"applies",
"the",
"current",
"value",
"of",
"the",
"attributes",
"to",
"the",
"passed",
"render",
"buffer",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L12521-L12550 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(tagName) {
tagName = tagName || get(this, 'tagName');
// Explicitly check for null or undefined, as tagName
// may be an empty string, which would evaluate to false.
if (tagName === null || tagName === undefined) {
tagName = 'div';
}
return Ember.RenderBuffer(tagName);
} | javascript | function(tagName) {
tagName = tagName || get(this, 'tagName');
// Explicitly check for null or undefined, as tagName
// may be an empty string, which would evaluate to false.
if (tagName === null || tagName === undefined) {
tagName = 'div';
}
return Ember.RenderBuffer(tagName);
} | [
"function",
"(",
"tagName",
")",
"{",
"tagName",
"=",
"tagName",
"||",
"get",
"(",
"this",
",",
"'tagName'",
")",
";",
"// Explicitly check for null or undefined, as tagName",
"// may be an empty string, which would evaluate to false.",
"if",
"(",
"tagName",
"===",
"null"... | Creates a new renderBuffer with the passed tagName. You can override this
method to provide further customization to the buffer if needed. Normally
you will not need to call or override this method.
@returns {Ember.RenderBuffer} | [
"Creates",
"a",
"new",
"renderBuffer",
"with",
"the",
"passed",
"tagName",
".",
"You",
"can",
"override",
"this",
"method",
"to",
"provide",
"further",
"customization",
"to",
"the",
"buffer",
"if",
"needed",
".",
"Normally",
"you",
"will",
"not",
"need",
"to... | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L12790-L12800 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(view) {
Ember.deprecate("Something you did caused a view to re-render after it rendered but before it was inserted into the DOM. Because this is avoidable and the cause of significant performance issues in applications, this behavior is deprecated. If you want to use the debugger to find out what caused th... | javascript | function(view) {
Ember.deprecate("Something you did caused a view to re-render after it rendered but before it was inserted into the DOM. Because this is avoidable and the cause of significant performance issues in applications, this behavior is deprecated. If you want to use the debugger to find out what caused th... | [
"function",
"(",
"view",
")",
"{",
"Ember",
".",
"deprecate",
"(",
"\"Something you did caused a view to re-render after it rendered but before it was inserted into the DOM. Because this is avoidable and the cause of significant performance issues in applications, this behavior is deprecated. If y... | when a view is rendered in a buffer, rerendering it simply replaces the existing buffer with a new one | [
"when",
"a",
"view",
"is",
"rendered",
"in",
"a",
"buffer",
"rerendering",
"it",
"simply",
"replaces",
"the",
"existing",
"buffer",
"with",
"a",
"new",
"one"
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L13747-L13754 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(views, start, removed) {
if (removed === 0) { return; }
var changedViews = views.slice(start, start+removed);
this.initializeViews(changedViews, null, null);
this.invokeForState('childViewsWillChange', views, start, removed);
} | javascript | function(views, start, removed) {
if (removed === 0) { return; }
var changedViews = views.slice(start, start+removed);
this.initializeViews(changedViews, null, null);
this.invokeForState('childViewsWillChange', views, start, removed);
} | [
"function",
"(",
"views",
",",
"start",
",",
"removed",
")",
"{",
"if",
"(",
"removed",
"===",
"0",
")",
"{",
"return",
";",
"}",
"var",
"changedViews",
"=",
"views",
".",
"slice",
"(",
"start",
",",
"start",
"+",
"removed",
")",
";",
"this",
".",
... | When a child view is removed, destroy its element so that
it is removed from the DOM.
The array observer that triggers this action is set up in the
`renderToBuffer` method.
@private
@param {Ember.Array} views the child views array before mutation
@param {Number} start the start position of the mutation
@param {Number... | [
"When",
"a",
"child",
"view",
"is",
"removed",
"destroy",
"its",
"element",
"so",
"that",
"it",
"is",
"removed",
"from",
"the",
"DOM",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L14239-L14246 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(views, start, removed, added) {
var len = get(views, 'length');
// No new child views were added; bail out.
if (added === 0) return;
var changedViews = views.slice(start, start+added);
this.initializeViews(changedViews, this, get(this, 'templateData'));
// Let the current state handl... | javascript | function(views, start, removed, added) {
var len = get(views, 'length');
// No new child views were added; bail out.
if (added === 0) return;
var changedViews = views.slice(start, start+added);
this.initializeViews(changedViews, this, get(this, 'templateData'));
// Let the current state handl... | [
"function",
"(",
"views",
",",
"start",
",",
"removed",
",",
"added",
")",
"{",
"var",
"len",
"=",
"get",
"(",
"views",
",",
"'length'",
")",
";",
"// No new child views were added; bail out.",
"if",
"(",
"added",
"===",
"0",
")",
"return",
";",
"var",
"... | When a child view is added, make sure the DOM gets updated appropriately.
If the view has already rendered an element, we tell the child view to
create an element and insert it into the DOM. If the enclosing container view
has already written to a buffer, but not yet converted that buffer into an
element, we insert th... | [
"When",
"a",
"child",
"view",
"is",
"added",
"make",
"sure",
"the",
"DOM",
"gets",
"updated",
"appropriately",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L14263-L14274 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(view, prev) {
if (prev) {
prev.domManager.after(prev, view);
} else {
this.domManager.prepend(this, view);
}
} | javascript | function(view, prev) {
if (prev) {
prev.domManager.after(prev, view);
} else {
this.domManager.prepend(this, view);
}
} | [
"function",
"(",
"view",
",",
"prev",
")",
"{",
"if",
"(",
"prev",
")",
"{",
"prev",
".",
"domManager",
".",
"after",
"(",
"prev",
",",
"view",
")",
";",
"}",
"else",
"{",
"this",
".",
"domManager",
".",
"prepend",
"(",
"this",
",",
"view",
")",
... | Schedules a child view to be inserted into the DOM after bindings have
finished syncing for this run loop.
@param {Ember.View} view the child view to insert
@param {Ember.View} prev the child view after which the specified view should
be inserted
@private | [
"Schedules",
"a",
"child",
"view",
"to",
"be",
"inserted",
"into",
"the",
"DOM",
"after",
"bindings",
"have",
"finished",
"syncing",
"for",
"this",
"run",
"loop",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L14295-L14301 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function() {
this._super();
set(this, 'stateMeta', Ember.Map.create());
var initialState = get(this, 'initialState');
if (!initialState && get(this, 'states.start')) {
initialState = 'start';
}
if (initialState) {
this.transitionTo(initialState);
Ember.assert('Failed to tra... | javascript | function() {
this._super();
set(this, 'stateMeta', Ember.Map.create());
var initialState = get(this, 'initialState');
if (!initialState && get(this, 'states.start')) {
initialState = 'start';
}
if (initialState) {
this.transitionTo(initialState);
Ember.assert('Failed to tra... | [
"function",
"(",
")",
"{",
"this",
".",
"_super",
"(",
")",
";",
"set",
"(",
"this",
",",
"'stateMeta'",
",",
"Ember",
".",
"Map",
".",
"create",
"(",
")",
")",
";",
"var",
"initialState",
"=",
"get",
"(",
"this",
",",
"'initialState'",
")",
";",
... | When creating a new statemanager, look for a default state to transition
into. This state can either be named `start`, or can be specified using the
`initialState` property. | [
"When",
"creating",
"a",
"new",
"statemanager",
"look",
"for",
"a",
"default",
"state",
"to",
"transition",
"into",
".",
"This",
"state",
"can",
"either",
"be",
"named",
"start",
"or",
"can",
"be",
"specified",
"using",
"the",
"initialState",
"property",
"."... | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L15498-L15513 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(root, path) {
var parts = path.split('.'),
state = root;
for (var i=0, l=parts.length; i<l; i++) {
state = get(get(state, 'states'), parts[i]);
if (!state) { break; }
}
return state;
} | javascript | function(root, path) {
var parts = path.split('.'),
state = root;
for (var i=0, l=parts.length; i<l; i++) {
state = get(get(state, 'states'), parts[i]);
if (!state) { break; }
}
return state;
} | [
"function",
"(",
"root",
",",
"path",
")",
"{",
"var",
"parts",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
",",
"state",
"=",
"root",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"parts",
".",
"length",
";",
"i",
"<",
"l",
";",
"i... | Finds a state by its state path.
Example:
manager = Ember.StateManager.create({
root: Ember.State.create({
dashboard: Ember.State.create()
})
});
manager.getStateByPath(manager, "root.dashboard")
returns the dashboard state
@param {Ember.State} root the state to start searching from
@param {String} path the state ... | [
"Finds",
"a",
"state",
"by",
"its",
"state",
"path",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L15609-L15619 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(manager, params) {
var modelClass, routeMatcher, param;
if (modelClass = this.modelClassFor(get(manager, 'namespace'))) {
Ember.assert("Expected "+modelClass.toString()+" to implement `find` for use in '"+this.get('path')+"' `deserialize`. Please implement the `find` method or overwrite `deseria... | javascript | function(manager, params) {
var modelClass, routeMatcher, param;
if (modelClass = this.modelClassFor(get(manager, 'namespace'))) {
Ember.assert("Expected "+modelClass.toString()+" to implement `find` for use in '"+this.get('path')+"' `deserialize`. Please implement the `find` method or overwrite `deseria... | [
"function",
"(",
"manager",
",",
"params",
")",
"{",
"var",
"modelClass",
",",
"routeMatcher",
",",
"param",
";",
"if",
"(",
"modelClass",
"=",
"this",
".",
"modelClassFor",
"(",
"get",
"(",
"manager",
",",
"'namespace'",
")",
")",
")",
"{",
"Ember",
"... | The default method that takes a `params` object and converts
it into an object.
By default, a params hash that looks like `{ post_id: 1 }`
will be looked up as `namespace.Post.find(1)`. This is
designed to work seamlessly with Ember Data, but will work
fine with any class that has a `find` method. | [
"The",
"default",
"method",
"that",
"takes",
"a",
"params",
"object",
"and",
"converts",
"it",
"into",
"an",
"object",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L16131-L16140 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(manager, context) {
var modelClass, routeMatcher, namespace, param, id;
if (Ember.empty(context)) { return ''; }
if (modelClass = this.modelClassFor(get(manager, 'namespace'))) {
param = paramForClass(modelClass);
id = get(context, 'id');
context = {};
context[param] = id;... | javascript | function(manager, context) {
var modelClass, routeMatcher, namespace, param, id;
if (Ember.empty(context)) { return ''; }
if (modelClass = this.modelClassFor(get(manager, 'namespace'))) {
param = paramForClass(modelClass);
id = get(context, 'id');
context = {};
context[param] = id;... | [
"function",
"(",
"manager",
",",
"context",
")",
"{",
"var",
"modelClass",
",",
"routeMatcher",
",",
"namespace",
",",
"param",
",",
"id",
";",
"if",
"(",
"Ember",
".",
"empty",
"(",
"context",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"m... | The default method that takes an object and converts it into
a params hash.
By default, if there is a single dynamic segment named
`blog_post_id` and the object is a `BlogPost` with an
`id` of `12`, the serialize method will produce:
{ blog_post_id: 12 } | [
"The",
"default",
"method",
"that",
"takes",
"an",
"object",
"and",
"converts",
"it",
"into",
"a",
"params",
"hash",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L16152-L16165 | train | |
feilaoda/power | public/javascripts/vendor/javascripts/ember.js | function(root, parsedPath, options) {
var val,
path = parsedPath.path;
if (path === 'this') {
val = root;
} else if (path === '') {
val = true;
} else {
val = getPath(root, path, options);
}
return Ember.View._classStringForValue(path, val, parsedPath.className, parse... | javascript | function(root, parsedPath, options) {
var val,
path = parsedPath.path;
if (path === 'this') {
val = root;
} else if (path === '') {
val = true;
} else {
val = getPath(root, path, options);
}
return Ember.View._classStringForValue(path, val, parsedPath.className, parse... | [
"function",
"(",
"root",
",",
"parsedPath",
",",
"options",
")",
"{",
"var",
"val",
",",
"path",
"=",
"parsedPath",
".",
"path",
";",
"if",
"(",
"path",
"===",
"'this'",
")",
"{",
"val",
"=",
"root",
";",
"}",
"else",
"if",
"(",
"path",
"===",
"'... | Helper method to retrieve the property from the context and determine which class string to return, based on whether it is a Boolean or not. | [
"Helper",
"method",
"to",
"retrieve",
"the",
"property",
"from",
"the",
"context",
"and",
"determine",
"which",
"class",
"string",
"to",
"return",
"based",
"on",
"whether",
"it",
"is",
"a",
"Boolean",
"or",
"not",
"."
] | 89432e5b8e455eceef5f5098d479ad94c88acc59 | https://github.com/feilaoda/power/blob/89432e5b8e455eceef5f5098d479ad94c88acc59/public/javascripts/vendor/javascripts/ember.js#L18627-L18640 | train | |
uvworkspace/uvwlib | lib/utils/inherit.js | inherit | function inherit (base) {
if (typeof base === 'function') {
return initClass(protoize.apply(null, arguments), [], 0);
} else {
return initClass(Object.create(base), arguments, 1);
}
} | javascript | function inherit (base) {
if (typeof base === 'function') {
return initClass(protoize.apply(null, arguments), [], 0);
} else {
return initClass(Object.create(base), arguments, 1);
}
} | [
"function",
"inherit",
"(",
"base",
")",
"{",
"if",
"(",
"typeof",
"base",
"===",
"'function'",
")",
"{",
"return",
"initClass",
"(",
"protoize",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
",",
"[",
"]",
",",
"0",
")",
";",
"}",
"else",
"{",... | inherit an ordinary prototype or classical constructor | [
"inherit",
"an",
"ordinary",
"prototype",
"or",
"classical",
"constructor"
] | ef1893e0c9cdcaa321186dd5dc17fc2c9bd9e641 | https://github.com/uvworkspace/uvwlib/blob/ef1893e0c9cdcaa321186dd5dc17fc2c9bd9e641/lib/utils/inherit.js#L7-L13 | train |
RainBirdAi/rainbird-linter | lib/reporter.js | getChalk | function getChalk(code) {
if (code.slice(0, 1) === 'I') {
return chalk.blue;
} else if (code.slice(0, 1) === 'W') {
return chalk.yellow;
} else {
return chalk.red;
}
} | javascript | function getChalk(code) {
if (code.slice(0, 1) === 'I') {
return chalk.blue;
} else if (code.slice(0, 1) === 'W') {
return chalk.yellow;
} else {
return chalk.red;
}
} | [
"function",
"getChalk",
"(",
"code",
")",
"{",
"if",
"(",
"code",
".",
"slice",
"(",
"0",
",",
"1",
")",
"===",
"'I'",
")",
"{",
"return",
"chalk",
".",
"blue",
";",
"}",
"else",
"if",
"(",
"code",
".",
"slice",
"(",
"0",
",",
"1",
")",
"==="... | _JS Hint_ prefixes messages with a letter to determine if it's informational, a warning, or an error. By using these the correct log level can be determined | [
"_JS",
"Hint_",
"prefixes",
"messages",
"with",
"a",
"letter",
"to",
"determine",
"if",
"it",
"s",
"informational",
"a",
"warning",
"or",
"an",
"error",
".",
"By",
"using",
"these",
"the",
"correct",
"log",
"level",
"can",
"be",
"determined"
] | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/lib/reporter.js#L14-L22 | train |
RainBirdAi/rainbird-linter | lib/reporter.js | reporter | function reporter(error, file) {
// _JS Hint_ can sometimes call the reporter function with no error. This is
// simply ignored.
if (!error) {
return;
}
if (!(error.code in errors)) {
errors[error.code] = { reason: error.raw, count: 0 };
}
errors[error.code].count++;
... | javascript | function reporter(error, file) {
// _JS Hint_ can sometimes call the reporter function with no error. This is
// simply ignored.
if (!error) {
return;
}
if (!(error.code in errors)) {
errors[error.code] = { reason: error.raw, count: 0 };
}
errors[error.code].count++;
... | [
"function",
"reporter",
"(",
"error",
",",
"file",
")",
"{",
"// _JS Hint_ can sometimes call the reporter function with no error. This is",
"// simply ignored.",
"if",
"(",
"!",
"error",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"(",
"error",
".",
"code",
"in... | The _JS Hint_ reporter displays a formatted line with the level determined by _JS Hint_, followed by the evidence for that error. | [
"The",
"_JS",
"Hint_",
"reporter",
"displays",
"a",
"formatted",
"line",
"with",
"the",
"level",
"determined",
"by",
"_JS",
"Hint_",
"followed",
"by",
"the",
"evidence",
"for",
"that",
"error",
"."
] | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/lib/reporter.js#L27-L50 | train |
RainBirdAi/rainbird-linter | lib/reporter.js | displaySummary | function displaySummary(errorCode) {
var error = errors[errorCode];
if (error.count > 1) {
console.log(getChalk(errorCode)('%s: %s (%d instances)'),
errorCode, error.reason, error.count);
} else {
console.log(getChalk(errorCode)('%s: %s (1 instance)'),
errorCode, erro... | javascript | function displaySummary(errorCode) {
var error = errors[errorCode];
if (error.count > 1) {
console.log(getChalk(errorCode)('%s: %s (%d instances)'),
errorCode, error.reason, error.count);
} else {
console.log(getChalk(errorCode)('%s: %s (1 instance)'),
errorCode, erro... | [
"function",
"displaySummary",
"(",
"errorCode",
")",
"{",
"var",
"error",
"=",
"errors",
"[",
"errorCode",
"]",
";",
"if",
"(",
"error",
".",
"count",
">",
"1",
")",
"{",
"console",
".",
"log",
"(",
"getChalk",
"(",
"errorCode",
")",
"(",
"'%s: %s (%d ... | The summary output shows the JS Hint error code and the number of times it occurred. | [
"The",
"summary",
"output",
"shows",
"the",
"JS",
"Hint",
"error",
"code",
"and",
"the",
"number",
"of",
"times",
"it",
"occurred",
"."
] | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/lib/reporter.js#L55-L64 | train |
RainBirdAi/rainbird-linter | lib/reporter.js | callback | function callback(err, hasError) {
if (err !== null) {
console.log(chalk.red('Error running JSHint over project: %j\n'), err);
}
if (hasError) {
console.log(chalk.blue('\nSummary\n=======\n'));
for (var errorCode in errors) {
if (errors.hasOwnProperty(errorCode)) {
... | javascript | function callback(err, hasError) {
if (err !== null) {
console.log(chalk.red('Error running JSHint over project: %j\n'), err);
}
if (hasError) {
console.log(chalk.blue('\nSummary\n=======\n'));
for (var errorCode in errors) {
if (errors.hasOwnProperty(errorCode)) {
... | [
"function",
"callback",
"(",
"err",
",",
"hasError",
")",
"{",
"if",
"(",
"err",
"!==",
"null",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"red",
"(",
"'Error running JSHint over project: %j\\n'",
")",
",",
"err",
")",
";",
"}",
"if",
"(",
"ha... | The callback is called when _JS Hint_ has finished parsing all files and is used to display a summary of all messages output. | [
"The",
"callback",
"is",
"called",
"when",
"_JS",
"Hint_",
"has",
"finished",
"parsing",
"all",
"files",
"and",
"is",
"used",
"to",
"display",
"a",
"summary",
"of",
"all",
"messages",
"output",
"."
] | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/lib/reporter.js#L69-L93 | train |
ericlathrop/game-keyboard | index.js | Keyboard | function Keyboard(keyMap) {
/**
* The current key states.
* @member {object}
* @private
*/
this.keys = {};
var self = this;
for (var kc in keyMap) {
if (keyMap.hasOwnProperty(kc)) {
this.keys[keyMap[kc]] = 0;
}
}
window.addEventListener("keydown", function(event) {
if (keyMap.hasOwnProperty(even... | javascript | function Keyboard(keyMap) {
/**
* The current key states.
* @member {object}
* @private
*/
this.keys = {};
var self = this;
for (var kc in keyMap) {
if (keyMap.hasOwnProperty(kc)) {
this.keys[keyMap[kc]] = 0;
}
}
window.addEventListener("keydown", function(event) {
if (keyMap.hasOwnProperty(even... | [
"function",
"Keyboard",
"(",
"keyMap",
")",
"{",
"/**\n\t * The current key states.\n\t * @member {object}\n\t * @private\n\t */",
"this",
".",
"keys",
"=",
"{",
"}",
";",
"var",
"self",
"=",
"this",
";",
"for",
"(",
"var",
"kc",
"in",
"keyMap",
")",
"{",
"if",
... | Keyboard input handling.
@constructor
@param {module:KeyMap} keymap A map of keycodes to descriptive key names. | [
"Keyboard",
"input",
"handling",
"."
] | 5cf23565167b71bcdf055b54d36f064512365d90 | https://github.com/ericlathrop/game-keyboard/blob/5cf23565167b71bcdf055b54d36f064512365d90/index.js#L8-L36 | train |
aheckmann/mongodb-schema-miner | lib/schema.js | merge | function merge (schema, doc, self) {
var keys = Object.keys(doc);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
var type;
// if nothing in schema yet, just assign
if ('undefined' == typeof schema[key]) {
var type = self.getType(doc, key);
if (undefined !== type) {
... | javascript | function merge (schema, doc, self) {
var keys = Object.keys(doc);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
var type;
// if nothing in schema yet, just assign
if ('undefined' == typeof schema[key]) {
var type = self.getType(doc, key);
if (undefined !== type) {
... | [
"function",
"merge",
"(",
"schema",
",",
"doc",
",",
"self",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"doc",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
... | Merge an object into schema | [
"Merge",
"an",
"object",
"into",
"schema"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/schema.js#L33-L95 | train |
aheckmann/mongodb-schema-miner | lib/schema.js | equalType | function equalType (a, b) {
if (Array.isArray(a) && Array.isArray(b)) {
if (0 === a.length || 0 === b.length) {
return true;
}
return equalType(a[0], b[0]);
}
if ('null' == a || 'null' == b) {
return true;
}
return a == b;
} | javascript | function equalType (a, b) {
if (Array.isArray(a) && Array.isArray(b)) {
if (0 === a.length || 0 === b.length) {
return true;
}
return equalType(a[0], b[0]);
}
if ('null' == a || 'null' == b) {
return true;
}
return a == b;
} | [
"function",
"equalType",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"a",
")",
"&&",
"Array",
".",
"isArray",
"(",
"b",
")",
")",
"{",
"if",
"(",
"0",
"===",
"a",
".",
"length",
"||",
"0",
"===",
"b",
".",
"length",... | Determines if two types are equal | [
"Determines",
"if",
"two",
"types",
"are",
"equal"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/schema.js#L272-L286 | train |
aheckmann/mongodb-schema-miner | lib/schema.js | getArrayType | function getArrayType (arr, self) {
var compareDocs = false;
var type = self.getType(arr, 0);
if (isObject(type)) {
type = new Schema(arr[0]);
compareDocs = true;
}
var match = true;
var element;
var err;
for (var i = 1; i < arr.length; ++i) {
element = arr[i];
if (isObject(element))... | javascript | function getArrayType (arr, self) {
var compareDocs = false;
var type = self.getType(arr, 0);
if (isObject(type)) {
type = new Schema(arr[0]);
compareDocs = true;
}
var match = true;
var element;
var err;
for (var i = 1; i < arr.length; ++i) {
element = arr[i];
if (isObject(element))... | [
"function",
"getArrayType",
"(",
"arr",
",",
"self",
")",
"{",
"var",
"compareDocs",
"=",
"false",
";",
"var",
"type",
"=",
"self",
".",
"getType",
"(",
"arr",
",",
"0",
")",
";",
"if",
"(",
"isObject",
"(",
"type",
")",
")",
"{",
"type",
"=",
"n... | Determine the type of array
example return vals:
['Mixed']
['Buffer']
[{ name: 'String', count: 'Number' }] | [
"Determine",
"the",
"type",
"of",
"array"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/schema.js#L299-L340 | train |
aheckmann/mongodb-schema-miner | lib/schema.js | convertObject | function convertObject (schema, self) {
var keys = Object.keys(schema);
var ret = {};
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
ret[key] = convertElement(schema[key], self);
}
return ret;
} | javascript | function convertObject (schema, self) {
var keys = Object.keys(schema);
var ret = {};
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
ret[key] = convertElement(schema[key], self);
}
return ret;
} | [
"function",
"convertObject",
"(",
"schema",
",",
"self",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"schema",
")",
";",
"var",
"ret",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";"... | Converts an object containing schemas to a plain object | [
"Converts",
"an",
"object",
"containing",
"schemas",
"to",
"a",
"plain",
"object"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/schema.js#L356-L366 | train |
aheckmann/mongodb-schema-miner | lib/schema.js | convertElement | function convertElement (el, self) {
if (el instanceof Schema) {
return el.toObject(self);
}
if (isObject(el)) {
return convertObject(el, self);
}
if (Array.isArray(el)) {
return el.map(function (item) {
return convertElement(item, self);
})
}
return el;
} | javascript | function convertElement (el, self) {
if (el instanceof Schema) {
return el.toObject(self);
}
if (isObject(el)) {
return convertObject(el, self);
}
if (Array.isArray(el)) {
return el.map(function (item) {
return convertElement(item, self);
})
}
return el;
} | [
"function",
"convertElement",
"(",
"el",
",",
"self",
")",
"{",
"if",
"(",
"el",
"instanceof",
"Schema",
")",
"{",
"return",
"el",
".",
"toObject",
"(",
"self",
")",
";",
"}",
"if",
"(",
"isObject",
"(",
"el",
")",
")",
"{",
"return",
"convertObject"... | Converts a single element to plain object | [
"Converts",
"a",
"single",
"element",
"to",
"plain",
"object"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/schema.js#L372-L388 | train |
nodejitsu/contour | pagelets/head.js | stylesheets | function stylesheets(options) {
return this.stylesheets.reduce(function reduce(links, sheet) {
return links + options.fn(sheet);
}, '');
} | javascript | function stylesheets(options) {
return this.stylesheets.reduce(function reduce(links, sheet) {
return links + options.fn(sheet);
}, '');
} | [
"function",
"stylesheets",
"(",
"options",
")",
"{",
"return",
"this",
".",
"stylesheets",
".",
"reduce",
"(",
"function",
"reduce",
"(",
"links",
",",
"sheet",
")",
"{",
"return",
"links",
"+",
"options",
".",
"fn",
"(",
"sheet",
")",
";",
"}",
",",
... | Handlebars helper that will iterate over the stylesheets in the data.
@param {Object} options
@return {String} generated template
@api private | [
"Handlebars",
"helper",
"that",
"will",
"iterate",
"over",
"the",
"stylesheets",
"in",
"the",
"data",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/head.js#L43-L47 | train |
nodejitsu/contour | pagelets/head.js | define | function define() {
if (!('canonical' in this.data)) {
this.data.canonical = [
'https://',
pkg.subdomain,
'.nodejitsu.com',
url.parse(this.defaults.canonical).pathname
].join('');
}
return this;
} | javascript | function define() {
if (!('canonical' in this.data)) {
this.data.canonical = [
'https://',
pkg.subdomain,
'.nodejitsu.com',
url.parse(this.defaults.canonical).pathname
].join('');
}
return this;
} | [
"function",
"define",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"'canonical'",
"in",
"this",
".",
"data",
")",
")",
"{",
"this",
".",
"data",
".",
"canonical",
"=",
"[",
"'https://'",
",",
"pkg",
".",
"subdomain",
",",
"'.nodejitsu.com'",
",",
"url",
".",
... | Always set a canonical reference on the data.
@returns {Pagelet}
@api private | [
"Always",
"set",
"a",
"canonical",
"reference",
"on",
"the",
"data",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/head.js#L55-L66 | train |
mchalapuk/hyper-text-slider | lib/core/slide-change-event.js | SlideChangeEvent | function SlideChangeEvent(fromIndex, toIndex) {
check(fromIndex, 'fromIndex').is.aNumber();
check(toIndex, 'toIndex').is.aNumber();
var pub = Object.create(SlideChangeEvent.prototype);
/**
* Index of previous slide.
*
* @type Number
* @access read-only
* @fqn SlideChangeEvent.prototype.fromInde... | javascript | function SlideChangeEvent(fromIndex, toIndex) {
check(fromIndex, 'fromIndex').is.aNumber();
check(toIndex, 'toIndex').is.aNumber();
var pub = Object.create(SlideChangeEvent.prototype);
/**
* Index of previous slide.
*
* @type Number
* @access read-only
* @fqn SlideChangeEvent.prototype.fromInde... | [
"function",
"SlideChangeEvent",
"(",
"fromIndex",
",",
"toIndex",
")",
"{",
"check",
"(",
"fromIndex",
",",
"'fromIndex'",
")",
".",
"is",
".",
"aNumber",
"(",
")",
";",
"check",
"(",
"toIndex",
",",
"'toIndex'",
")",
".",
"is",
".",
"aNumber",
"(",
")... | Creates SlideChangeEvent.
@param {Number} from index of a previous slide
@param {Number} to index of current slide
@fqn SlideChangeEvent.prototype.constructor | [
"Creates",
"SlideChangeEvent",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slide-change-event.js#L37-L62 | train |
sofa/sofa | dist/sofa.js | function (backendAddress) {
backendAddress = backendAddress || {};
var country = {
value: safeUse(backendAddress.country),
label: safeUse(backendAddress.countryname)
};
return {
company: safeUse(backendAddress.company),
saluta... | javascript | function (backendAddress) {
backendAddress = backendAddress || {};
var country = {
value: safeUse(backendAddress.country),
label: safeUse(backendAddress.countryname)
};
return {
company: safeUse(backendAddress.company),
saluta... | [
"function",
"(",
"backendAddress",
")",
"{",
"backendAddress",
"=",
"backendAddress",
"||",
"{",
"}",
";",
"var",
"country",
"=",
"{",
"value",
":",
"safeUse",
"(",
"backendAddress",
".",
"country",
")",
",",
"label",
":",
"safeUse",
"(",
"backendAddress",
... | unfortunately the backend uses all sorts of different address formats this one converts an address coming from a summary response to the generic app address format. | [
"unfortunately",
"the",
"backend",
"uses",
"all",
"sorts",
"of",
"different",
"address",
"formats",
"this",
"one",
"converts",
"an",
"address",
"coming",
"from",
"a",
"summary",
"response",
"to",
"the",
"generic",
"app",
"address",
"format",
"."
] | 0dda1f2f197e3cf7d93bcea4b890777af74e65f6 | https://github.com/sofa/sofa/blob/0dda1f2f197e3cf7d93bcea4b890777af74e65f6/dist/sofa.js#L2048-L2069 | train | |
sofa/sofa | dist/sofa.js | function (products, categoryUrlId) {
return products.map(function (product) {
product.categoryUrlId = categoryUrlId;
// the backend is sending us prices as strings.
// we need to fix that up for sorting and other things to work
product.price = parseFloat(product.p... | javascript | function (products, categoryUrlId) {
return products.map(function (product) {
product.categoryUrlId = categoryUrlId;
// the backend is sending us prices as strings.
// we need to fix that up for sorting and other things to work
product.price = parseFloat(product.p... | [
"function",
"(",
"products",
",",
"categoryUrlId",
")",
"{",
"return",
"products",
".",
"map",
"(",
"function",
"(",
"product",
")",
"{",
"product",
".",
"categoryUrlId",
"=",
"categoryUrlId",
";",
"// the backend is sending us prices as strings.",
"// we need to fix ... | it's a bit akward that we need to do that. It should be adressed directly on our server API so that this extra processing can be removed. | [
"it",
"s",
"a",
"bit",
"akward",
"that",
"we",
"need",
"to",
"do",
"that",
".",
"It",
"should",
"be",
"adressed",
"directly",
"on",
"our",
"server",
"API",
"so",
"that",
"this",
"extra",
"processing",
"can",
"be",
"removed",
"."
] | 0dda1f2f197e3cf7d93bcea4b890777af74e65f6 | https://github.com/sofa/sofa/blob/0dda1f2f197e3cf7d93bcea4b890777af74e65f6/dist/sofa.js#L2344-L2352 | train | |
sofa/sofa | dist/sofa.js | function () {
var activeCoupons = basketService.getActiveCoupons();
var oldCouponCodes = activeCoupons.map(function (activeCoupon) {
return activeCoupon.code;
});
basketService.clearCoupons();
oldCouponCodes.forEach(function (couponCode) {
self.submitCo... | javascript | function () {
var activeCoupons = basketService.getActiveCoupons();
var oldCouponCodes = activeCoupons.map(function (activeCoupon) {
return activeCoupon.code;
});
basketService.clearCoupons();
oldCouponCodes.forEach(function (couponCode) {
self.submitCo... | [
"function",
"(",
")",
"{",
"var",
"activeCoupons",
"=",
"basketService",
".",
"getActiveCoupons",
"(",
")",
";",
"var",
"oldCouponCodes",
"=",
"activeCoupons",
".",
"map",
"(",
"function",
"(",
"activeCoupon",
")",
"{",
"return",
"activeCoupon",
".",
"code",
... | When the cart changes, refresh the values of the coupons by sending them to the backend along with the new cart | [
"When",
"the",
"cart",
"changes",
"refresh",
"the",
"values",
"of",
"the",
"coupons",
"by",
"sending",
"them",
"to",
"the",
"backend",
"along",
"with",
"the",
"new",
"cart"
] | 0dda1f2f197e3cf7d93bcea4b890777af74e65f6 | https://github.com/sofa/sofa/blob/0dda1f2f197e3cf7d93bcea4b890777af74e65f6/dist/sofa.js#L2658-L2670 | train | |
feedhenry/fh-mbaas-client | lib/app/appforms/config.js | get | function get(params, cb) {
var resourcePath = "/appforms/config";
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | javascript | function get(params, cb) {
var resourcePath = "/appforms/config";
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | [
"function",
"get",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"\"/appforms/config\"",
";",
"var",
"method",
"=",
"\"GET\"",
";",
"var",
"data",
"=",
"{",
"}",
";",
"params",
".",
"resourcePath",
"=",
"resourcePath",
";",
"params",
".... | Get The Forms App Configuration Associated With A Project | [
"Get",
"The",
"Forms",
"App",
"Configuration",
"Associated",
"With",
"A",
"Project"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/config.js#L6-L16 | train |
jldec/pub-generator | serialize.js | serializeFile | function serializeFile(file) {
// preserve path, source, and file-save props
var o = u.pick(file, 'path', '_oldtext', '_dirty');
// recreate file.text from serialized fragments
// new or modifified fragments should delete file.text
o.text = file.text || serializeTextFragments(file);
return o;
} | javascript | function serializeFile(file) {
// preserve path, source, and file-save props
var o = u.pick(file, 'path', '_oldtext', '_dirty');
// recreate file.text from serialized fragments
// new or modifified fragments should delete file.text
o.text = file.text || serializeTextFragments(file);
return o;
} | [
"function",
"serializeFile",
"(",
"file",
")",
"{",
"// preserve path, source, and file-save props",
"var",
"o",
"=",
"u",
".",
"pick",
"(",
"file",
",",
"'path'",
",",
"'_oldtext'",
",",
"'_dirty'",
")",
";",
"// recreate file.text from serialized fragments",
"// new... | return serializable file object | [
"return",
"serializable",
"file",
"object"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/serialize.js#L27-L37 | train |
socialally/air | lib/air/clone.js | clone | function clone() {
var arr = [];
this.each(function(el) {
arr.push(el.cloneNode(true));
});
return this.air(arr);
} | javascript | function clone() {
var arr = [];
this.each(function(el) {
arr.push(el.cloneNode(true));
});
return this.air(arr);
} | [
"function",
"clone",
"(",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"this",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"arr",
".",
"push",
"(",
"el",
".",
"cloneNode",
"(",
"true",
")",
")",
";",
"}",
")",
";",
"return",
"this",
"."... | Create a deep copy of the set of matched elements. | [
"Create",
"a",
"deep",
"copy",
"of",
"the",
"set",
"of",
"matched",
"elements",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/clone.js#L4-L10 | train |
vesln/unix.js | lib/result.js | Result | function Result(cmd, err, stdout, stderr) {
this.cmd = cmd;
this.err = err;
this.stdout = strip(stdout);
this.stderr = strip(stderr);
} | javascript | function Result(cmd, err, stdout, stderr) {
this.cmd = cmd;
this.err = err;
this.stdout = strip(stdout);
this.stderr = strip(stderr);
} | [
"function",
"Result",
"(",
"cmd",
",",
"err",
",",
"stdout",
",",
"stderr",
")",
"{",
"this",
".",
"cmd",
"=",
"cmd",
";",
"this",
".",
"err",
"=",
"err",
";",
"this",
".",
"stdout",
"=",
"strip",
"(",
"stdout",
")",
";",
"this",
".",
"stderr",
... | Command result.
@param {String} command
@param {Object} error
@param {String} stdout
@param {String} stderr
@constructor | [
"Command",
"result",
"."
] | 706b70b3d4d0cf815414303d58791afeae2fed3e | https://github.com/vesln/unix.js/blob/706b70b3d4d0cf815414303d58791afeae2fed3e/lib/result.js#L23-L28 | train |
cliffano/couchpenter | lib/db.js | _errorCb | function _errorCb(err, result) {
// if there is a conflict error, retrieve the document's revision first
function _successCb(err, result) {
// use the revision to update the existing documents
// NOTE: it is not impossible that the revision of this document
// i... | javascript | function _errorCb(err, result) {
// if there is a conflict error, retrieve the document's revision first
function _successCb(err, result) {
// use the revision to update the existing documents
// NOTE: it is not impossible that the revision of this document
// i... | [
"function",
"_errorCb",
"(",
"err",
",",
"result",
")",
"{",
"// if there is a conflict error, retrieve the document's revision first",
"function",
"_successCb",
"(",
"err",
",",
"result",
")",
"{",
"// use the revision to update the existing documents",
"// NOTE: it is not impos... | try to create documents, but with conflict error handling | [
"try",
"to",
"create",
"documents",
"but",
"with",
"conflict",
"error",
"handling"
] | 00cce387da2f39e4b276b27b0bacb073caa80453 | https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/db.js#L143-L165 | train |
cliffano/couchpenter | lib/db.js | _successCb | function _successCb(err, result) {
self.couch.use(dbName).destroy(result._id, result._rev, self._handle(cb, {
dbName: dbName,
docId: doc._id,
message: 'deleted'
}));
} | javascript | function _successCb(err, result) {
self.couch.use(dbName).destroy(result._id, result._rev, self._handle(cb, {
dbName: dbName,
docId: doc._id,
message: 'deleted'
}));
} | [
"function",
"_successCb",
"(",
"err",
",",
"result",
")",
"{",
"self",
".",
"couch",
".",
"use",
"(",
"dbName",
")",
".",
"destroy",
"(",
"result",
".",
"_id",
",",
"result",
".",
"_rev",
",",
"self",
".",
"_handle",
"(",
"cb",
",",
"{",
"dbName",
... | retrieve the document revision and use it to delete the document | [
"retrieve",
"the",
"document",
"revision",
"and",
"use",
"it",
"to",
"delete",
"the",
"document"
] | 00cce387da2f39e4b276b27b0bacb073caa80453 | https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/db.js#L195-L202 | train |
cliffano/couchpenter | lib/db.js | _result | function _result(err, dbName, docId, message) {
var result = {
id: util.format('%s%s%s', dbName, (docId) ? '/' : '', docId || ''),
message: message || util.format('%s (%s)', err.error, err.status_code)
};
if (err) {
result.error = err;
}
return result;
} | javascript | function _result(err, dbName, docId, message) {
var result = {
id: util.format('%s%s%s', dbName, (docId) ? '/' : '', docId || ''),
message: message || util.format('%s (%s)', err.error, err.status_code)
};
if (err) {
result.error = err;
}
return result;
} | [
"function",
"_result",
"(",
"err",
",",
"dbName",
",",
"docId",
",",
"message",
")",
"{",
"var",
"result",
"=",
"{",
"id",
":",
"util",
".",
"format",
"(",
"'%s%s%s'",
",",
"dbName",
",",
"(",
"docId",
")",
"?",
"'/'",
":",
"''",
",",
"docId",
"|... | construct result object, the existence of error field indicates whether the result is a success or not | [
"construct",
"result",
"object",
"the",
"existence",
"of",
"error",
"field",
"indicates",
"whether",
"the",
"result",
"is",
"a",
"success",
"or",
"not"
] | 00cce387da2f39e4b276b27b0bacb073caa80453 | https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/db.js#L382-L391 | train |
kflorence/gulp-data-matter | index.js | matter | function matter(file) {
var parsed = gm(file.contents.toString());
file.contents = new Buffer(parsed.content);
return parsed.data;
} | javascript | function matter(file) {
var parsed = gm(file.contents.toString());
file.contents = new Buffer(parsed.content);
return parsed.data;
} | [
"function",
"matter",
"(",
"file",
")",
"{",
"var",
"parsed",
"=",
"gm",
"(",
"file",
".",
"contents",
".",
"toString",
"(",
")",
")",
";",
"file",
".",
"contents",
"=",
"new",
"Buffer",
"(",
"parsed",
".",
"content",
")",
";",
"return",
"parsed",
... | Extract and parse front-matter from files using gray-matter.
@param {Object} file Vinyl File object
@return Data from front matter | [
"Extract",
"and",
"parse",
"front",
"-",
"matter",
"from",
"files",
"using",
"gray",
"-",
"matter",
"."
] | 7655bcbfe08dd5f228e9c7887b17778651bf35d0 | https://github.com/kflorence/gulp-data-matter/blob/7655bcbfe08dd5f228e9c7887b17778651bf35d0/index.js#L11-L15 | train |
mchalapuk/hyper-text-slider | lib/docgen/formatter.js | lazyBuildObjectTree | function lazyBuildObjectTree(priv, formatted) {
definePropertyGetters(formatted, {
children: lazy(function() { return priv.fqnMap.getChildrenOf(formatted.fqn); }),
fields: lazy(function() { return formatted.children.filter(Filter.ofType('property')); }),
methods: lazy(function() { return formatted.childre... | javascript | function lazyBuildObjectTree(priv, formatted) {
definePropertyGetters(formatted, {
children: lazy(function() { return priv.fqnMap.getChildrenOf(formatted.fqn); }),
fields: lazy(function() { return formatted.children.filter(Filter.ofType('property')); }),
methods: lazy(function() { return formatted.childre... | [
"function",
"lazyBuildObjectTree",
"(",
"priv",
",",
"formatted",
")",
"{",
"definePropertyGetters",
"(",
"formatted",
",",
"{",
"children",
":",
"lazy",
"(",
"function",
"(",
")",
"{",
"return",
"priv",
".",
"fqnMap",
".",
"getChildrenOf",
"(",
"formatted",
... | sets parent->child relations | [
"sets",
"parent",
"-",
">",
"child",
"relations"
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/docgen/formatter.js#L199-L207 | train |
mchalapuk/hyper-text-slider | lib/docgen/formatter.js | toGithubHash | function toGithubHash(title) {
var GITHUB_ILLEGAL = new RegExp('[\\[\\]{}()<>^$#@!%&*+\/\\|~`"\':;,.]', 'g');
return title.toLowerCase().replace(/ /g, '-').replace(GITHUB_ILLEGAL, '');
} | javascript | function toGithubHash(title) {
var GITHUB_ILLEGAL = new RegExp('[\\[\\]{}()<>^$#@!%&*+\/\\|~`"\':;,.]', 'g');
return title.toLowerCase().replace(/ /g, '-').replace(GITHUB_ILLEGAL, '');
} | [
"function",
"toGithubHash",
"(",
"title",
")",
"{",
"var",
"GITHUB_ILLEGAL",
"=",
"new",
"RegExp",
"(",
"'[\\\\[\\\\]{}()<>^$#@!%&*+\\/\\\\|~`\"\\':;,.]'",
",",
"'g'",
")",
";",
"return",
"title",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"/",
" ",
"/... | Algorithm of generating a HTML label used in Github Markdown | [
"Algorithm",
"of",
"generating",
"a",
"HTML",
"label",
"used",
"in",
"Github",
"Markdown"
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/docgen/formatter.js#L237-L240 | train |
neurospeech/web-atoms-mvvm.js | dist/web-atoms-mvvm.js | bindableProperty | function bindableProperty(target, key) {
// property value
var _val = this[key];
var keyName = "_" + key;
this[keyName] = _val;
// property getter
var getter = function () {
// console.log(`Get: ${key} => ${_val}`);
return this[keyName];
};
// property setter
var sett... | javascript | function bindableProperty(target, key) {
// property value
var _val = this[key];
var keyName = "_" + key;
this[keyName] = _val;
// property getter
var getter = function () {
// console.log(`Get: ${key} => ${_val}`);
return this[keyName];
};
// property setter
var sett... | [
"function",
"bindableProperty",
"(",
"target",
",",
"key",
")",
"{",
"// property value",
"var",
"_val",
"=",
"this",
"[",
"key",
"]",
";",
"var",
"keyName",
"=",
"\"_\"",
"+",
"key",
";",
"this",
"[",
"keyName",
"]",
"=",
"_val",
";",
"// property gette... | This decorator will mark given property as bindable, it will define
getter and setter, and in the setter, it will refresh the property.
class Customer{
@bindableProperty
firstName:string;
}
@param {*} target
@param {string} key | [
"This",
"decorator",
"will",
"mark",
"given",
"property",
"as",
"bindable",
"it",
"will",
"define",
"getter",
"and",
"setter",
"and",
"in",
"the",
"setter",
"it",
"will",
"refresh",
"the",
"property",
"."
] | 777222c3d5b491686be3a81a433e0cf7cb3ff979 | https://github.com/neurospeech/web-atoms-mvvm.js/blob/777222c3d5b491686be3a81a433e0cf7cb3ff979/dist/web-atoms-mvvm.js#L172-L215 | train |
neurospeech/web-atoms-mvvm.js | dist/web-atoms-mvvm.js | AtomWatcher | function AtomWatcher(target, path, runAfterSetup, forValidation) {
var _this = this;
this._isExecuting = false;
this.target = target;
var e = false;
if (forValidation === true) {
this.forValidation = true;
}
if (path ins... | javascript | function AtomWatcher(target, path, runAfterSetup, forValidation) {
var _this = this;
this._isExecuting = false;
this.target = target;
var e = false;
if (forValidation === true) {
this.forValidation = true;
}
if (path ins... | [
"function",
"AtomWatcher",
"(",
"target",
",",
"path",
",",
"runAfterSetup",
",",
"forValidation",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"this",
".",
"_isExecuting",
"=",
"false",
";",
"this",
".",
"target",
"=",
"target",
";",
"var",
"e",
"=",
"... | Creates an instance of AtomWatcher.
var w = new AtomWatcher(this, x => x.data.fullName = `${x.data.firstName} ${x.data.lastName}`);
You must dispose `w` in order to avoid memory leaks.
Above method will set fullName whenver, data or its firstName,lastName property is modified.
AtomWatcher will assign null if any exp... | [
"Creates",
"an",
"instance",
"of",
"AtomWatcher",
"."
] | 777222c3d5b491686be3a81a433e0cf7cb3ff979 | https://github.com/neurospeech/web-atoms-mvvm.js/blob/777222c3d5b491686be3a81a433e0cf7cb3ff979/dist/web-atoms-mvvm.js#L1431-L1462 | train |
neurospeech/web-atoms-mvvm.js | dist/web-atoms-mvvm.js | function () {
return {
href: location.href,
hash: location.hash,
host: location.host,
hostName: location.hostname,
port: location.port,
protocol: location.protocol
};
... | javascript | function () {
return {
href: location.href,
hash: location.hash,
host: location.host,
hostName: location.hostname,
port: location.port,
protocol: location.protocol
};
... | [
"function",
"(",
")",
"{",
"return",
"{",
"href",
":",
"location",
".",
"href",
",",
"hash",
":",
"location",
".",
"hash",
",",
"host",
":",
"location",
".",
"host",
",",
"hostName",
":",
"location",
".",
"hostname",
",",
"port",
":",
"location",
"."... | Gets current location of browser, this does not return
actual location but it returns values of browser location.
This is done to provide mocking behaviour for unit testing.
@readonly
@type {AtomLocation}
@memberof BrowserService | [
"Gets",
"current",
"location",
"of",
"browser",
"this",
"does",
"not",
"return",
"actual",
"location",
"but",
"it",
"returns",
"values",
"of",
"browser",
"location",
".",
"This",
"is",
"done",
"to",
"provide",
"mocking",
"behaviour",
"for",
"unit",
"testing",
... | 777222c3d5b491686be3a81a433e0cf7cb3ff979 | https://github.com/neurospeech/web-atoms-mvvm.js/blob/777222c3d5b491686be3a81a433e0cf7cb3ff979/dist/web-atoms-mvvm.js#L1625-L1634 | train | |
vid/SenseBase | web/ext-lib/dragFile.js | previewfile | function previewfile(file) {
if (false && tests.filereader === true) {
var reader = new FileReader();
reader.onload = function (event) {
var image = new Image();
image.src = event.target.result;
image.width = 250; // a fake resize
holder.appendChild(image);
};
... | javascript | function previewfile(file) {
if (false && tests.filereader === true) {
var reader = new FileReader();
reader.onload = function (event) {
var image = new Image();
image.src = event.target.result;
image.width = 250; // a fake resize
holder.appendChild(image);
};
... | [
"function",
"previewfile",
"(",
"file",
")",
"{",
"if",
"(",
"false",
"&&",
"tests",
".",
"filereader",
"===",
"true",
")",
"{",
"var",
"reader",
"=",
"new",
"FileReader",
"(",
")",
";",
"reader",
".",
"onload",
"=",
"function",
"(",
"event",
")",
"{... | FIXME display filetype icon | [
"FIXME",
"display",
"filetype",
"icon"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/ext-lib/dragFile.js#L47-L62 | train |
unkelpehr/node-exit-hook | exit-hook.js | handleExit | function handleExit (canCancel, signal, code) {
var i = 0,
sub;
while ((sub = subs[i++])) {
if (sub[0].call(sub[1], canCancel, signal, code) === false && canCancel) {
return;
}
}
if (canCancel) {
process.exit(code);
}
} | javascript | function handleExit (canCancel, signal, code) {
var i = 0,
sub;
while ((sub = subs[i++])) {
if (sub[0].call(sub[1], canCancel, signal, code) === false && canCancel) {
return;
}
}
if (canCancel) {
process.exit(code);
}
} | [
"function",
"handleExit",
"(",
"canCancel",
",",
"signal",
",",
"code",
")",
"{",
"var",
"i",
"=",
"0",
",",
"sub",
";",
"while",
"(",
"(",
"sub",
"=",
"subs",
"[",
"i",
"++",
"]",
")",
")",
"{",
"if",
"(",
"sub",
"[",
"0",
"]",
".",
"call",
... | Handler for all exit events | [
"Handler",
"for",
"all",
"exit",
"events"
] | 5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e | https://github.com/unkelpehr/node-exit-hook/blob/5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e/exit-hook.js#L9-L22 | train |
unkelpehr/node-exit-hook | exit-hook.js | exitHook | function exitHook (context, func) {
if (!func) {
func = context;
context = func;
}
if (typeof func === 'function') {
subs.push([func, context])
}
return exitHook;
} | javascript | function exitHook (context, func) {
if (!func) {
func = context;
context = func;
}
if (typeof func === 'function') {
subs.push([func, context])
}
return exitHook;
} | [
"function",
"exitHook",
"(",
"context",
",",
"func",
")",
"{",
"if",
"(",
"!",
"func",
")",
"{",
"func",
"=",
"context",
";",
"context",
"=",
"func",
";",
"}",
"if",
"(",
"typeof",
"func",
"===",
"'function'",
")",
"{",
"subs",
".",
"push",
"(",
... | Adds a new function to execute when the application is exiting. | [
"Adds",
"a",
"new",
"function",
"to",
"execute",
"when",
"the",
"application",
"is",
"exiting",
"."
] | 5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e | https://github.com/unkelpehr/node-exit-hook/blob/5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e/exit-hook.js#L25-L36 | train |
ngenerio/smsghjs | lib/sendmsg.js | SendMessage | function SendMessage (auth, apiVersion) {
if (!(this instanceof SendMessage)) return new SendMessage(auth, apiVersion)
this._noopCallback = function () {}
this._headers = {
'Accept': 'application/json',
'Authorization': 'Basic ' + auth.basicAuth
}
this.versionNumber = apiVersion || 'v3'
this.lastQue... | javascript | function SendMessage (auth, apiVersion) {
if (!(this instanceof SendMessage)) return new SendMessage(auth, apiVersion)
this._noopCallback = function () {}
this._headers = {
'Accept': 'application/json',
'Authorization': 'Basic ' + auth.basicAuth
}
this.versionNumber = apiVersion || 'v3'
this.lastQue... | [
"function",
"SendMessage",
"(",
"auth",
",",
"apiVersion",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"SendMessage",
")",
")",
"return",
"new",
"SendMessage",
"(",
"auth",
",",
"apiVersion",
")",
"this",
".",
"_noopCallback",
"=",
"function",
"("... | The main constructor used for sending messages
@param {Auth} auth The authentication details
@param {String} apiVersion The API version to use for request (Versioned API) | [
"The",
"main",
"constructor",
"used",
"for",
"sending",
"messages"
] | cfb33bb6b5b02d54125bed67365a5b174a1ad562 | https://github.com/ngenerio/smsghjs/blob/cfb33bb6b5b02d54125bed67365a5b174a1ad562/lib/sendmsg.js#L12-L22 | train |
express-go/express-go | lib/Boot/Boot.js | Init | function Init(appGlobal, pathsList) {
debug("Initializing Boot");
loadFinder = new Finder();
loadProvider = new Provider();
loadNamespace = new Namespace();
global = appGlobal;
global.App = {};
global.Modules = {};
g... | javascript | function Init(appGlobal, pathsList) {
debug("Initializing Boot");
loadFinder = new Finder();
loadProvider = new Provider();
loadNamespace = new Namespace();
global = appGlobal;
global.App = {};
global.Modules = {};
g... | [
"function",
"Init",
"(",
"appGlobal",
",",
"pathsList",
")",
"{",
"debug",
"(",
"\"Initializing Boot\"",
")",
";",
"loadFinder",
"=",
"new",
"Finder",
"(",
")",
";",
"loadProvider",
"=",
"new",
"Provider",
"(",
")",
";",
"loadNamespace",
"=",
"new",
"Names... | Loading components, objects
@param appGlobal
@param pathsList | [
"Loading",
"components",
"objects"
] | d8da60bc2046380528464a827c43de4f75c5b2d7 | https://github.com/express-go/express-go/blob/d8da60bc2046380528464a827c43de4f75c5b2d7/lib/Boot/Boot.js#L37-L60 | train |
cfpb/AtomicComponent | src/utilities/object-assign/index.js | assign | function assign( destination ) {
destination = destination || {};
for ( let i = 1, len = arguments.length; i < len; i++ ) {
const source = arguments[i] || {};
for ( const key in source ) {
if ( Object.prototype.hasOwnProperty.call( source, key ) ) {
const value = source[key];
if ( _isP... | javascript | function assign( destination ) {
destination = destination || {};
for ( let i = 1, len = arguments.length; i < len; i++ ) {
const source = arguments[i] || {};
for ( const key in source ) {
if ( Object.prototype.hasOwnProperty.call( source, key ) ) {
const value = source[key];
if ( _isP... | [
"function",
"assign",
"(",
"destination",
")",
"{",
"destination",
"=",
"destination",
"||",
"{",
"}",
";",
"for",
"(",
"let",
"i",
"=",
"1",
",",
"len",
"=",
"arguments",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"const",
"s... | Copies properties of all sources to the destination object overriding its own
existing properties. When assigning from multiple sources, fields of every
next source will override same named fields of previous sources.
@param {Object} destination object.
@returns {Object} assigned destination object. | [
"Copies",
"properties",
"of",
"all",
"sources",
"to",
"the",
"destination",
"object",
"overriding",
"its",
"own",
"existing",
"properties",
".",
"When",
"assigning",
"from",
"multiple",
"sources",
"fields",
"of",
"every",
"next",
"source",
"will",
"override",
"s... | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/object-assign/index.js#L29-L46 | train |
briancsparks/js-aws | lib/ec2/ec2.js | function(dbg, raFn, subName, g, name, argv_, context, outerCallback, callback) {
var argv = _.extend({}, argv_);
g[name] = {};
return raFn(argv, context, function(err, result_) {
if (err) { return sg.die(err, outerCallback, 'fetching '+name); }
var result = subName ? result_[subName] : result_;
if... | javascript | function(dbg, raFn, subName, g, name, argv_, context, outerCallback, callback) {
var argv = _.extend({}, argv_);
g[name] = {};
return raFn(argv, context, function(err, result_) {
if (err) { return sg.die(err, outerCallback, 'fetching '+name); }
var result = subName ? result_[subName] : result_;
if... | [
"function",
"(",
"dbg",
",",
"raFn",
",",
"subName",
",",
"g",
",",
"name",
",",
"argv_",
",",
"context",
",",
"outerCallback",
",",
"callback",
")",
"{",
"var",
"argv",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"argv_",
")",
";",
"g",
"[",
... | fetch, using creds, not contacting server in the other acct | [
"fetch",
"using",
"creds",
"not",
"contacting",
"server",
"in",
"the",
"other",
"acct"
] | bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L1744-L1785 | train | |
briancsparks/js-aws | lib/ec2/ec2.js | getUserdata0_ | function getUserdata0_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
format("if ! [ -d /home/%s ]; then", username),
format(" usermod -l %s %s", username, origUsername),
format(" gr... | javascript | function getUserdata0_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
format("if ! [ -d /home/%s ]; then", username),
format(" usermod -l %s %s", username, origUsername),
format(" gr... | [
"function",
"getUserdata0_",
"(",
"username",
",",
"upNamespace",
",",
"envVars_",
",",
"origUsername",
")",
"{",
"var",
"envVars",
"=",
"cleanEnvVars",
"(",
"upNamespace",
",",
"envVars_",
")",
";",
"var",
"script",
"=",
"[",
"\"#!/bin/bash -ex\"",
",",
"form... | The userdata for when starting an instance from a base-image.
Basically, it renames the default 'ubuntu' user to 'scotty'; manages
/etc/hosts, and sets a couple of system-wide env vars. | [
"The",
"userdata",
"for",
"when",
"starting",
"an",
"instance",
"from",
"a",
"base",
"-",
"image",
"."
] | bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2539-L2567 | train |
briancsparks/js-aws | lib/ec2/ec2.js | getUserdataForAmi_ | function getUserdataForAmi_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
""
];
_.each(envVars, function(value, key) {
script.push("/usr/local/bin/yoshi-set-env "+key+" "+value);
});
... | javascript | function getUserdataForAmi_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
""
];
_.each(envVars, function(value, key) {
script.push("/usr/local/bin/yoshi-set-env "+key+" "+value);
});
... | [
"function",
"getUserdataForAmi_",
"(",
"username",
",",
"upNamespace",
",",
"envVars_",
",",
"origUsername",
")",
"{",
"var",
"envVars",
"=",
"cleanEnvVars",
"(",
"upNamespace",
",",
"envVars_",
")",
";",
"var",
"script",
"=",
"[",
"\"#!/bin/bash -ex\"",
",",
... | The userdata for when starting an instance from a created AMI. | [
"The",
"userdata",
"for",
"when",
"starting",
"an",
"instance",
"from",
"a",
"created",
"AMI",
"."
] | bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2578-L2592 | train |
briancsparks/js-aws | lib/ec2/ec2.js | taggedAs | function taggedAs(taggedItem, name, namespace, namespaceEx) {
var tags = taggedItem.tags || taggedItem.Tags;
if (!namespace) { return /* undefined */; }
if (!tags) { return /* undefined */; }
// The new, improved way (ite... | javascript | function taggedAs(taggedItem, name, namespace, namespaceEx) {
var tags = taggedItem.tags || taggedItem.Tags;
if (!namespace) { return /* undefined */; }
if (!tags) { return /* undefined */; }
// The new, improved way (ite... | [
"function",
"taggedAs",
"(",
"taggedItem",
",",
"name",
",",
"namespace",
",",
"namespaceEx",
")",
"{",
"var",
"tags",
"=",
"taggedItem",
".",
"tags",
"||",
"taggedItem",
".",
"Tags",
";",
"if",
"(",
"!",
"namespace",
")",
"{",
"return",
"/* undefined */",... | Returns the tag, and knows a few different styles. | [
"Returns",
"the",
"tag",
"and",
"knows",
"a",
"few",
"different",
"styles",
"."
] | bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2709-L2726 | train |
briancsparks/js-aws | lib/ec2/ec2.js | isTaggedAs | function isTaggedAs(taggedItem, name, value, namespace, namespaceEx) {
return taggedAs(taggedItem, name, namespace, namespaceEx) == value; // == is intentional
} | javascript | function isTaggedAs(taggedItem, name, value, namespace, namespaceEx) {
return taggedAs(taggedItem, name, namespace, namespaceEx) == value; // == is intentional
} | [
"function",
"isTaggedAs",
"(",
"taggedItem",
",",
"name",
",",
"value",
",",
"namespace",
",",
"namespaceEx",
")",
"{",
"return",
"taggedAs",
"(",
"taggedItem",
",",
"name",
",",
"namespace",
",",
"namespaceEx",
")",
"==",
"value",
";",
"// == is intentional",... | Returns true if the item is tagged with the value. | [
"Returns",
"true",
"if",
"the",
"item",
"is",
"tagged",
"with",
"the",
"value",
"."
] | bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2731-L2733 | train |
Sobesednik/wrote | es5/src/create-writable.js | createWritable | function createWritable() {
var $args = arguments;return new Promise(function ($return, $error) {
var file, ws;
file = $args.length > 0 && $args[0] !== undefined ? $args[0] : getTempFile();
return Promise.resolve(openFileForWrite(file)).then(function ($await_2) {
try {
... | javascript | function createWritable() {
var $args = arguments;return new Promise(function ($return, $error) {
var file, ws;
file = $args.length > 0 && $args[0] !== undefined ? $args[0] : getTempFile();
return Promise.resolve(openFileForWrite(file)).then(function ($await_2) {
try {
... | [
"function",
"createWritable",
"(",
")",
"{",
"var",
"$args",
"=",
"arguments",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"$return",
",",
"$error",
")",
"{",
"var",
"file",
",",
"ws",
";",
"file",
"=",
"$args",
".",
"length",
">",
"0",
"&... | Open the file for writing and create a write stream.
@param {string} ffile path to the file
@returns {Promise<Writable>} A promise with the stream | [
"Open",
"the",
"file",
"for",
"writing",
"and",
"create",
"a",
"write",
"stream",
"."
] | 24992ad3bba4e5959dfb617b6c1f22d9a1306ab9 | https://github.com/Sobesednik/wrote/blob/24992ad3bba4e5959dfb617b6c1f22d9a1306ab9/es5/src/create-writable.js#L47-L60 | train |
feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | list | function list(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions", params);
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.admin(params, cb);
} | javascript | function list(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions", params);
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.admin(params, cb);
} | [
"function",
"list",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"GET\"",
";",
"var",
"dat... | List Submissions For An Environment
@param params
@param {object} params.paginate
@param {number} params.paginate.page Page to get
@param {number} params.paginate.limit Entries Per Page
@param cb | [
"List",
"Submissions",
"For",
"An",
"Environment"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L13-L23 | train |
feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | updateFile | function updateFile(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/fields/:fieldId/files/:fileId", params);
var method = "PUT";
var data = params.fileDetails;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
params.fileRe... | javascript | function updateFile(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/fields/:fieldId/files/:fileId", params);
var method = "PUT";
var data = params.fileDetails;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
params.fileRe... | [
"function",
"updateFile",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions/:id/fields/:fieldId/files/:fileId\"",
",",
"params",
")",
";",
"var",
"method",
... | Update A File For A Submission
@param {object} params
@param {string} params.id The submission ID (The submission should already exist)
@param {string} params.domain The Domain
@param {string} params.environment The Environment ID to upload To
@param {string}... | [
"Update",
"A",
"File",
"For",
"A",
"Submission"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L101-L114 | train |
feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | filterSubmissions | function filterSubmissions(params, cb) {
params.resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/filter", params);
params.method = "POST";
params.data = params.filterParams;
mbaasRequest.admin(params, cb);
} | javascript | function filterSubmissions(params, cb) {
params.resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/filter", params);
params.method = "POST";
params.data = params.filterParams;
mbaasRequest.admin(params, cb);
} | [
"function",
"filterSubmissions",
"(",
"params",
",",
"cb",
")",
"{",
"params",
".",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions/filter\"",
",",
"params",
")",
";",
"params",
".",
"method",
... | Filtering Submissions From An Environment Mbaas.
Forms Can Be Filtered By form ID or Project ID
@param {object} params.pagination
@param {number} params.pagination.page Page to get
@param {number} params.pagination.limit Entries Per Page
@param cb | [
"Filtering",
"Submissions",
"From",
"An",
"Environment",
"Mbaas",
"."
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L189-L195 | train |
feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | getSubmissionPDF | function getSubmissionPDF(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/exportpdf", params);
var method = "POST";
params.resourcePath = resourcePath;
params.method = method;
params.data = params.data || {};
params.fileRequest = true;
mbaasRequest.adm... | javascript | function getSubmissionPDF(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/exportpdf", params);
var method = "POST";
params.resourcePath = resourcePath;
params.method = method;
params.data = params.data || {};
params.fileRequest = true;
mbaasRequest.adm... | [
"function",
"getSubmissionPDF",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions/:id/exportpdf\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"POST... | Getting A PDF Of A Submission
@param params
@param params.data
@param params.data.coreLocation - The host name of the domain accessing the PDF.
@param cb | [
"Getting",
"A",
"PDF",
"Of",
"A",
"Submission"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L243-L254 | train |
eoaranda/mta-metro | lib/metronorth.js | function(key,options){
this.key = key;
var route = "",
dayroute = "",
timeroute = "",
debug = false;
if (!this.key || this.key == "" || this.key == "<YOU-API-KEY>") {
throw new Error('MTA API key missing or incorrect.');
}... | javascript | function(key,options){
this.key = key;
var route = "",
dayroute = "",
timeroute = "",
debug = false;
if (!this.key || this.key == "" || this.key == "<YOU-API-KEY>") {
throw new Error('MTA API key missing or incorrect.');
}... | [
"function",
"(",
"key",
",",
"options",
")",
"{",
"this",
".",
"key",
"=",
"key",
";",
"var",
"route",
"=",
"\"\"",
",",
"dayroute",
"=",
"\"\"",
",",
"timeroute",
"=",
"\"\"",
",",
"debug",
"=",
"false",
";",
"if",
"(",
"!",
"this",
".",
"key",
... | returns an array with the schedule | [
"returns",
"an",
"array",
"with",
"the",
"schedule"
] | f0b10c99df222b39433a9cac3e0a3debf1f053df | https://github.com/eoaranda/mta-metro/blob/f0b10c99df222b39433a9cac3e0a3debf1f053df/lib/metronorth.js#L12-L63 | train | |
specla/validator | lib/transformType.js | transformObject | function transformObject (type) {
const transformed = {}
for (let key in type) {
transformed[key] = transformType(type[key])
}
return transformed
} | javascript | function transformObject (type) {
const transformed = {}
for (let key in type) {
transformed[key] = transformType(type[key])
}
return transformed
} | [
"function",
"transformObject",
"(",
"type",
")",
"{",
"const",
"transformed",
"=",
"{",
"}",
"for",
"(",
"let",
"key",
"in",
"type",
")",
"{",
"transformed",
"[",
"key",
"]",
"=",
"transformType",
"(",
"type",
"[",
"key",
"]",
")",
"}",
"return",
"tr... | Transform an object
@param {Object} type
@return {Object} transformed object type
@private | [
"Transform",
"an",
"object"
] | 087d3877e2dff464682b0cf07389c0ad9cfd9b85 | https://github.com/specla/validator/blob/087d3877e2dff464682b0cf07389c0ad9cfd9b85/lib/transformType.js#L46-L54 | train |
specla/validator | lib/transformType.js | findType | function findType (type) {
let name = ''
const defaultTypes = [
'string',
'number',
'boolean',
'symbol',
'array',
'object'
]
try {
name = type.prototype.constructor.name.toLowerCase()
} catch (err) {}
if (defaultTypes.includes(name)) {
return types[name]()
}
return val... | javascript | function findType (type) {
let name = ''
const defaultTypes = [
'string',
'number',
'boolean',
'symbol',
'array',
'object'
]
try {
name = type.prototype.constructor.name.toLowerCase()
} catch (err) {}
if (defaultTypes.includes(name)) {
return types[name]()
}
return val... | [
"function",
"findType",
"(",
"type",
")",
"{",
"let",
"name",
"=",
"''",
"const",
"defaultTypes",
"=",
"[",
"'string'",
",",
"'number'",
",",
"'boolean'",
",",
"'symbol'",
",",
"'array'",
",",
"'object'",
"]",
"try",
"{",
"name",
"=",
"type",
".",
"pro... | Find validator fucntion for a type
@param {Function} type
@return {Function} | [
"Find",
"validator",
"fucntion",
"for",
"a",
"type"
] | 087d3877e2dff464682b0cf07389c0ad9cfd9b85 | https://github.com/specla/validator/blob/087d3877e2dff464682b0cf07389c0ad9cfd9b85/lib/transformType.js#L70-L96 | train |
vid/SenseBase | lib/reset.js | step | function step(err, res) {
if (!err && res && res.error) {
console.log('ERR', res);
err = res.error;
}
var nextStep = steps.shift();
if (err && curStep !== 'delIndex') {
console.log('failing on', curStep, err);
console.trace();
callback(err);
return;
}
if (nextStep) {
curStep = ne... | javascript | function step(err, res) {
if (!err && res && res.error) {
console.log('ERR', res);
err = res.error;
}
var nextStep = steps.shift();
if (err && curStep !== 'delIndex') {
console.log('failing on', curStep, err);
console.trace();
callback(err);
return;
}
if (nextStep) {
curStep = ne... | [
"function",
"step",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"res",
"&&",
"res",
".",
"error",
")",
"{",
"console",
".",
"log",
"(",
"'ERR'",
",",
"res",
")",
";",
"err",
"=",
"res",
".",
"error",
";",
"}",
"var",
"nextS... | check for an error, if no error do the next step, if no next step callback | [
"check",
"for",
"an",
"error",
"if",
"no",
"error",
"do",
"the",
"next",
"step",
"if",
"no",
"next",
"step",
"callback"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/reset.js#L168-L187 | train |
feedhenry/fh-mbaas-client | lib/config/config.js | addURIParams | function addURIParams(uri, params) {
uri = uri || "";
params = params || {};
params = _.clone(params);
var keys = _.keys(params);
var separatedPath = uri.split("/");
separatedPath = _.compact(separatedPath);
//Replacing Any Path Elements
separatedPath = _.map(separatedPath, function(pathEntry) {
... | javascript | function addURIParams(uri, params) {
uri = uri || "";
params = params || {};
params = _.clone(params);
var keys = _.keys(params);
var separatedPath = uri.split("/");
separatedPath = _.compact(separatedPath);
//Replacing Any Path Elements
separatedPath = _.map(separatedPath, function(pathEntry) {
... | [
"function",
"addURIParams",
"(",
"uri",
",",
"params",
")",
"{",
"uri",
"=",
"uri",
"||",
"\"\"",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
"=",
"_",
".",
"clone",
"(",
"params",
")",
";",
"var",
"keys",
"=",
"_",
".",
"keys",
... | Maps Parameters To Url Parameters.
@param uri
@param params
@returns {*} | [
"Maps",
"Parameters",
"To",
"Url",
"Parameters",
"."
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/config/config.js#L11-L57 | train |
jquense/component-metadata-loader | lib/index.js | cleanDoclets | function cleanDoclets(desc) {
var idx = desc.indexOf('@');
return (idx === -1 ? desc : desc.substr(0, idx)).trim();
} | javascript | function cleanDoclets(desc) {
var idx = desc.indexOf('@');
return (idx === -1 ? desc : desc.substr(0, idx)).trim();
} | [
"function",
"cleanDoclets",
"(",
"desc",
")",
"{",
"var",
"idx",
"=",
"desc",
".",
"indexOf",
"(",
"'@'",
")",
";",
"return",
"(",
"idx",
"===",
"-",
"1",
"?",
"desc",
":",
"desc",
".",
"substr",
"(",
"0",
",",
"idx",
")",
")",
".",
"trim",
"("... | removes doclet syntax from comments | [
"removes",
"doclet",
"syntax",
"from",
"comments"
] | 07e38af2e0ad5b444ae091687f0ae4497a0a9c9f | https://github.com/jquense/component-metadata-loader/blob/07e38af2e0ad5b444ae091687f0ae4497a0a9c9f/lib/index.js#L22-L25 | train |
vadr-vr/VR-Analytics-JSCore | js/dataManager/serverRequestManager.js | addDataRequest | function addDataRequest(requestDict){
logger.info('Adding request to server');
const dataRequest = _getServerRequest(requestDict);
_addRequestToDb(dataRequest).then(() => {
if (!requestingPost){
_makeRequestToServer();
}
});
} | javascript | function addDataRequest(requestDict){
logger.info('Adding request to server');
const dataRequest = _getServerRequest(requestDict);
_addRequestToDb(dataRequest).then(() => {
if (!requestingPost){
_makeRequestToServer();
}
});
} | [
"function",
"addDataRequest",
"(",
"requestDict",
")",
"{",
"logger",
".",
"info",
"(",
"'Adding request to server'",
")",
";",
"const",
"dataRequest",
"=",
"_getServerRequest",
"(",
"requestDict",
")",
";",
"_addRequestToDb",
"(",
"dataRequest",
")",
".",
"then",... | Adds request to send data in list of requests
@memberof ServerRequestManager
@param {object} requestDict The dictionary contaning data for the added request | [
"Adds",
"request",
"to",
"send",
"data",
"in",
"list",
"of",
"requests"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/dataManager/serverRequestManager.js#L24-L40 | train |
ikr/estimate-tasks | lib/calc.js | function (bestCaseHours, mostLikelyCaseHours, worstCaseHours, confidencePercent) {
var isVector = (typeof bestCaseHours === 'object')
this.bestCaseHours = isVector ? bestCaseHours[0] : bestCaseHours
this.mostLikelyCaseHours = isVector ? bestCaseHours[1] : mostLikelyCaseHours
this.worstC... | javascript | function (bestCaseHours, mostLikelyCaseHours, worstCaseHours, confidencePercent) {
var isVector = (typeof bestCaseHours === 'object')
this.bestCaseHours = isVector ? bestCaseHours[0] : bestCaseHours
this.mostLikelyCaseHours = isVector ? bestCaseHours[1] : mostLikelyCaseHours
this.worstC... | [
"function",
"(",
"bestCaseHours",
",",
"mostLikelyCaseHours",
",",
"worstCaseHours",
",",
"confidencePercent",
")",
"{",
"var",
"isVector",
"=",
"(",
"typeof",
"bestCaseHours",
"===",
"'object'",
")",
"this",
".",
"bestCaseHours",
"=",
"isVector",
"?",
"bestCaseHo... | bestCaseHours <= mostLikelyCaseHours <= worstCaseHours
Minimum possible confidencePercent is 10 | [
"bestCaseHours",
"<",
"=",
"mostLikelyCaseHours",
"<",
"=",
"worstCaseHours",
"Minimum",
"possible",
"confidencePercent",
"is",
"10"
] | a5fd271b8a1bc23257694673e42bf8f9dbd2ec40 | https://github.com/ikr/estimate-tasks/blob/a5fd271b8a1bc23257694673e42bf8f9dbd2ec40/lib/calc.js#L19-L26 | train | |
uniphil/xxs | xxs.js | createUpdater | function createUpdater(actionUpdates) {
if (process.env.NODE_ENV !== 'production') {
// Ensure that all values are functions
Object.getOwnPropertySymbols(actionUpdates).concat(Object.keys(actionUpdates))
.filter(k => typeof actionUpdates[k] !== 'function')
.forEach(k => { throw new Error(`Expected... | javascript | function createUpdater(actionUpdates) {
if (process.env.NODE_ENV !== 'production') {
// Ensure that all values are functions
Object.getOwnPropertySymbols(actionUpdates).concat(Object.keys(actionUpdates))
.filter(k => typeof actionUpdates[k] !== 'function')
.forEach(k => { throw new Error(`Expected... | [
"function",
"createUpdater",
"(",
"actionUpdates",
")",
"{",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"{",
"// Ensure that all values are functions",
"Object",
".",
"getOwnPropertySymbols",
"(",
"actionUpdates",
")",
".",
"conca... | A helper to generate updater functions mapped by action
@param {object} actionUpdates An object with Actions (strings or symbols) as
keys and ((state, payload) => nextState) functions as values
@returns {function} An updater function ((state, action, payload) => nextState) | [
"A",
"helper",
"to",
"generate",
"updater",
"functions",
"mapped",
"by",
"action"
] | 44b559e491f568756c41f6fbdd26420b6393189d | https://github.com/uniphil/xxs/blob/44b559e491f568756c41f6fbdd26420b6393189d/xxs.js#L56-L67 | train |
uniphil/xxs | xxs.js | dispatch | function dispatch(action, payload) {
if (process.env.NODE_ENV !== 'production' && dispatching) {
throw new Error(`'${action.toString()}' was dispatched while '${dispatching.toString()}' was still updating. Updaters should be pure functions and must not dispatch actions.`);
}
try {
dispatching = ... | javascript | function dispatch(action, payload) {
if (process.env.NODE_ENV !== 'production' && dispatching) {
throw new Error(`'${action.toString()}' was dispatched while '${dispatching.toString()}' was still updating. Updaters should be pure functions and must not dispatch actions.`);
}
try {
dispatching = ... | [
"function",
"dispatch",
"(",
"action",
",",
"payload",
")",
"{",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
"&&",
"dispatching",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"action",
".",
"toString",
"(",
")",
"}",... | dummy spec for the node we're attaching to
@param {Symbol|string} action? The action to dispatch (or undefined to force a render)
@param {any} payload? Any data associated with the action
@returns {void} | [
"dummy",
"spec",
"for",
"the",
"node",
"we",
"re",
"attaching",
"to"
] | 44b559e491f568756c41f6fbdd26420b6393189d | https://github.com/uniphil/xxs/blob/44b559e491f568756c41f6fbdd26420b6393189d/xxs.js#L157-L171 | train |
DScheglov/merest | lib/middlewares/transform-response.js | Bundle | function Bundle(transform, req, res) {
this.status = res.__status || 200;
this.body = res.__body || {};
this.apiMethod = res.__apiMethod;
this.apiInstanceMethod = res.__apiInstanceMethod;
this.apiStaticMethod = res.__apiStaticMethod;
this.api = res.__api;
this.modelAPI = res.__modelAPI;
if (this... | javascript | function Bundle(transform, req, res) {
this.status = res.__status || 200;
this.body = res.__body || {};
this.apiMethod = res.__apiMethod;
this.apiInstanceMethod = res.__apiInstanceMethod;
this.apiStaticMethod = res.__apiStaticMethod;
this.api = res.__api;
this.modelAPI = res.__modelAPI;
if (this... | [
"function",
"Bundle",
"(",
"transform",
",",
"req",
",",
"res",
")",
"{",
"this",
".",
"status",
"=",
"res",
".",
"__status",
"||",
"200",
";",
"this",
".",
"body",
"=",
"res",
".",
"__body",
"||",
"{",
"}",
";",
"this",
".",
"apiMethod",
"=",
"r... | Bundle - class to aggregate data to be changed
@param {Function} transform the function transforms `this.status` and `this.body`
@param {Number} status HTTP Response code
@param {Any} body The Body to be changed
@return {Transformer} created transformed option | [
"Bundle",
"-",
"class",
"to",
"aggregate",
"data",
"to",
"be",
"changed"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/middlewares/transform-response.js#L14-L26 | train |
DScheglov/merest | lib/middlewares/transform-response.js | transformResponse | function transformResponse(transform) {
assert.ok(transform);
assert.ok(transform instanceof Function);
var originalStatus, originalJson, reqClosure;
return function (req, res, next) {
originalStatus = res.status;
originalJson = res.json;
reqClosure = req;
res.status = setStatus;
... | javascript | function transformResponse(transform) {
assert.ok(transform);
assert.ok(transform instanceof Function);
var originalStatus, originalJson, reqClosure;
return function (req, res, next) {
originalStatus = res.status;
originalJson = res.json;
reqClosure = req;
res.status = setStatus;
... | [
"function",
"transformResponse",
"(",
"transform",
")",
"{",
"assert",
".",
"ok",
"(",
"transform",
")",
";",
"assert",
".",
"ok",
"(",
"transform",
"instanceof",
"Function",
")",
";",
"var",
"originalStatus",
",",
"originalJson",
",",
"reqClosure",
";",
"re... | transformResponse - the factory for middleware that transforms response
@param {Function} transform the function transfomrs `this.status` and `this.body`
@return {Function} express middleware that transfomrs response | [
"transformResponse",
"-",
"the",
"factory",
"for",
"middleware",
"that",
"transforms",
"response"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/middlewares/transform-response.js#L34-L62 | train |
yeikos/js.url | url.js | function() {
// Construimos los atributos en base a la localización
var attr = Public.unbuild(this._attributes, this.location);
// Si no se encuentra disponible la instancia localización
if (!(this.location instanceof Public))
// La dirección será externa si tiene definido el atributo `protocol` o ... | javascript | function() {
// Construimos los atributos en base a la localización
var attr = Public.unbuild(this._attributes, this.location);
// Si no se encuentra disponible la instancia localización
if (!(this.location instanceof Public))
// La dirección será externa si tiene definido el atributo `protocol` o ... | [
"function",
"(",
")",
"{",
"// Construimos los atributos en base a la localización",
"var",
"attr",
"=",
"Public",
".",
"unbuild",
"(",
"this",
".",
"_attributes",
",",
"this",
".",
"location",
")",
";",
"// Si no se encuentra disponible la instancia localización",
"if",
... | Comprueba si la URL es externa | [
"Comprueba",
"si",
"la",
"URL",
"es",
"externa"
] | 4015fcb113528c253d5732b86564dfbe965ebdc6 | https://github.com/yeikos/js.url/blob/4015fcb113528c253d5732b86564dfbe965ebdc6/url.js#L231-L249 | train | |
yeikos/js.url | url.js | function() {
var attr = Public.attributes.slice(0),
argv = [].slice.apply(arguments),
buffer = {},
x = argv.length,
y = attr.length;
// Convertimos la matriz de argumentos a objeto
while (x--)
buffer[_toString(argv[x]).toLowerCase()] = 1;
// Si se desea eliminar el atributo `hostnam... | javascript | function() {
var attr = Public.attributes.slice(0),
argv = [].slice.apply(arguments),
buffer = {},
x = argv.length,
y = attr.length;
// Convertimos la matriz de argumentos a objeto
while (x--)
buffer[_toString(argv[x]).toLowerCase()] = 1;
// Si se desea eliminar el atributo `hostnam... | [
"function",
"(",
")",
"{",
"var",
"attr",
"=",
"Public",
".",
"attributes",
".",
"slice",
"(",
"0",
")",
",",
"argv",
"=",
"[",
"]",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
",",
"buffer",
"=",
"{",
"}",
",",
"x",
"=",
"argv",
".",
... | Construye la URL sin los atributos seleccionados | [
"Construye",
"la",
"URL",
"sin",
"los",
"atributos",
"seleccionados"
] | 4015fcb113528c253d5732b86564dfbe965ebdc6 | https://github.com/yeikos/js.url/blob/4015fcb113528c253d5732b86564dfbe965ebdc6/url.js#L261-L308 | train | |
yeikos/js.url | url.js | _isElement | function _isElement(input) {
return (typeof HTMLElement === 'function') ?
(input instanceof HTMLElement) :
(input && typeof input === 'object' && input.nodeType === 1 && typeof input.nodeName === 'string');
} | javascript | function _isElement(input) {
return (typeof HTMLElement === 'function') ?
(input instanceof HTMLElement) :
(input && typeof input === 'object' && input.nodeType === 1 && typeof input.nodeName === 'string');
} | [
"function",
"_isElement",
"(",
"input",
")",
"{",
"return",
"(",
"typeof",
"HTMLElement",
"===",
"'function'",
")",
"?",
"(",
"input",
"instanceof",
"HTMLElement",
")",
":",
"(",
"input",
"&&",
"typeof",
"input",
"===",
"'object'",
"&&",
"input",
".",
"nod... | Comprueba si el objeto es un elemento HTML | [
"Comprueba",
"si",
"el",
"objeto",
"es",
"un",
"elemento",
"HTML"
] | 4015fcb113528c253d5732b86564dfbe965ebdc6 | https://github.com/yeikos/js.url/blob/4015fcb113528c253d5732b86564dfbe965ebdc6/url.js#L1253-L1261 | train |
jquense/cobble | index.js | cobble | function cobble(){
var args = [], last;
for(var i = 0; i < arguments.length; ++i) {
last = arguments[i];
if( isArray(last) ) args = args.concat(last)
else args[args.length] = last
}
return cobble.into({}, args)
} | javascript | function cobble(){
var args = [], last;
for(var i = 0; i < arguments.length; ++i) {
last = arguments[i];
if( isArray(last) ) args = args.concat(last)
else args[args.length] = last
}
return cobble.into({}, args)
} | [
"function",
"cobble",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
",",
"last",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"++",
"i",
")",
"{",
"last",
"=",
"arguments",
"[",
"i",
"]",
";",
"if",
... | compose objects into a new object, leaving the original objects untouched
@param {...object} an object to be composed.
@return {object} | [
"compose",
"objects",
"into",
"a",
"new",
"object",
"leaving",
"the",
"original",
"objects",
"untouched"
] | 25889b99309cdd6d690fa8efdb6f86e99c41c466 | https://github.com/jquense/cobble/blob/25889b99309cdd6d690fa8efdb6f86e99c41c466/index.js#L12-L22 | train |
lodestarjs/lodestar-ractive | src/main.js | LodeRactive | function LodeRactive( options ) {
if ( typeof Ractive === 'undefined' ) throw Error('Couldn\'t find an instance of Ractive, you need to have it in order to use this framework.');
if ( options && typeof options.DEBUG !== 'undefined') Ractive.DEBUG = options.DEBUG;
this.router = new Router( options );
} | javascript | function LodeRactive( options ) {
if ( typeof Ractive === 'undefined' ) throw Error('Couldn\'t find an instance of Ractive, you need to have it in order to use this framework.');
if ( options && typeof options.DEBUG !== 'undefined') Ractive.DEBUG = options.DEBUG;
this.router = new Router( options );
} | [
"function",
"LodeRactive",
"(",
"options",
")",
"{",
"if",
"(",
"typeof",
"Ractive",
"===",
"'undefined'",
")",
"throw",
"Error",
"(",
"'Couldn\\'t find an instance of Ractive, you need to have it in order to use this framework.'",
")",
";",
"if",
"(",
"options",
"&&",
... | Constructor for the framework. It depends on Ractive as this is a POC
of using the router with Ractive.
@param {Object} options, the configuration options for the framework.
@returns {Void}, nothing returned | [
"Constructor",
"for",
"the",
"framework",
".",
"It",
"depends",
"on",
"Ractive",
"as",
"this",
"is",
"a",
"POC",
"of",
"using",
"the",
"router",
"with",
"Ractive",
"."
] | 58cded8a1b8f0d258f174dd5fcfc0a291d7664e9 | https://github.com/lodestarjs/lodestar-ractive/blob/58cded8a1b8f0d258f174dd5fcfc0a291d7664e9/src/main.js#L10-L18 | train |
socialally/air | lib/air/parent.js | parent | function parent(/*selector*/) {
var arr = [], $ = this.air, slice = this.slice;
this.each(function(el) {
arr = arr.concat(slice.call($(el.parentNode).dom));
});
return $(arr);
} | javascript | function parent(/*selector*/) {
var arr = [], $ = this.air, slice = this.slice;
this.each(function(el) {
arr = arr.concat(slice.call($(el.parentNode).dom));
});
return $(arr);
} | [
"function",
"parent",
"(",
"/*selector*/",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
",",
"$",
"=",
"this",
".",
"air",
",",
"slice",
"=",
"this",
".",
"slice",
";",
"this",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"arr",
"=",
"arr",
"."... | Get the parent of each element in the current set of matched elements,
optionally filtered by a selector.
TODO: implement selector filtering | [
"Get",
"the",
"parent",
"of",
"each",
"element",
"in",
"the",
"current",
"set",
"of",
"matched",
"elements",
"optionally",
"filtered",
"by",
"a",
"selector",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/parent.js#L7-L13 | train |
MorganConrad/metalsmith-inspect | inspect.js | inspect | function inspect(options){
options = normalize(options);
return function(files, metalsmith, done) {
if (options.disable)
return done();
//try {
var bigJSObject = {};
if (options.includeMetalsmith) {
bigJSObject[options.includeMetalsmith] = metalsmith... | javascript | function inspect(options){
options = normalize(options);
return function(files, metalsmith, done) {
if (options.disable)
return done();
//try {
var bigJSObject = {};
if (options.includeMetalsmith) {
bigJSObject[options.includeMetalsmith] = metalsmith... | [
"function",
"inspect",
"(",
"options",
")",
"{",
"options",
"=",
"normalize",
"(",
"options",
")",
";",
"return",
"function",
"(",
"files",
",",
"metalsmith",
",",
"done",
")",
"{",
"if",
"(",
"options",
".",
"disable",
")",
"return",
"done",
"(",
")",... | Metalsmith plugin that prints the objects
@param {Object} opts
@return {Function} | [
"Metalsmith",
"plugin",
"that",
"prints",
"the",
"objects"
] | 3e2dc04254fa90862a2589584c95e84b8db66b8b | https://github.com/MorganConrad/metalsmith-inspect/blob/3e2dc04254fa90862a2589584c95e84b8db66b8b/inspect.js#L12-L105 | train |
MorganConrad/metalsmith-inspect | inspect.js | normalize | function normalize(options){
options = options || {};
options.printfn = options.printfn || function(obj) {
console.dir(obj, {colors: true});
};
if (!options.accept) {
if (options.include) {
options.accept = function(propKey) { return options.include.indexOf(propKey) >= 0; ... | javascript | function normalize(options){
options = options || {};
options.printfn = options.printfn || function(obj) {
console.dir(obj, {colors: true});
};
if (!options.accept) {
if (options.include) {
options.accept = function(propKey) { return options.include.indexOf(propKey) >= 0; ... | [
"function",
"normalize",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"printfn",
"=",
"options",
".",
"printfn",
"||",
"function",
"(",
"obj",
")",
"{",
"console",
".",
"dir",
"(",
"obj",
",",
"{",
"colors... | Normalize an `options` dictionary.
@param {Object} options | [
"Normalize",
"an",
"options",
"dictionary",
"."
] | 3e2dc04254fa90862a2589584c95e84b8db66b8b | https://github.com/MorganConrad/metalsmith-inspect/blob/3e2dc04254fa90862a2589584c95e84b8db66b8b/inspect.js#L61-L83 | train |
haraldrudell/nodegod | lib/rotatedlogger.js | write | function write(s) {
var err
var args = Array.prototype.slice.call(arguments)
var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
var cbCounter = 1
if (writeToStdoutEnabled) {
cbCounter++
process.stdout.write(s, stdWr)
}
if (writeStream) {
cbCounter++
writeStream.write(s, w... | javascript | function write(s) {
var err
var args = Array.prototype.slice.call(arguments)
var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
var cbCounter = 1
if (writeToStdoutEnabled) {
cbCounter++
process.stdout.write(s, stdWr)
}
if (writeStream) {
cbCounter++
writeStream.write(s, w... | [
"function",
"write",
"(",
"s",
")",
"{",
"var",
"err",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
"var",
"cb",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'function... | logging of utf-8 string | [
"logging",
"of",
"utf",
"-",
"8",
"string"
] | 3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21 | https://github.com/haraldrudell/nodegod/blob/3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21/lib/rotatedlogger.js#L76-L117 | train |
iamchairs/snooze | lib/module.js | function(nm, modules, snooze) {
this.snooze = snooze;
if(nm === null || nm === undefined || nm.length < 1) {
throw new Error('Module name note defined.');
}
this.name = nm;
this.snoozeConfig = this.snooze.getConfig();
this.runs = [];
this.configs = [];
this.modules = modules || [];
this.EntityMan... | javascript | function(nm, modules, snooze) {
this.snooze = snooze;
if(nm === null || nm === undefined || nm.length < 1) {
throw new Error('Module name note defined.');
}
this.name = nm;
this.snoozeConfig = this.snooze.getConfig();
this.runs = [];
this.configs = [];
this.modules = modules || [];
this.EntityMan... | [
"function",
"(",
"nm",
",",
"modules",
",",
"snooze",
")",
"{",
"this",
".",
"snooze",
"=",
"snooze",
";",
"if",
"(",
"nm",
"===",
"null",
"||",
"nm",
"===",
"undefined",
"||",
"nm",
".",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"Error",
"("... | A SnoozeJS Module
@constructor
@param {string} nm - The name of the module
@param {array} modules - Array of module names to inject | [
"A",
"SnoozeJS",
"Module"
] | 6127a6a183562721311bdb03b16c5448b71900ec | https://github.com/iamchairs/snooze/blob/6127a6a183562721311bdb03b16c5448b71900ec/lib/module.js#L15-L41 | train | |
binduwavell/generator-alfresco-common | lib/maven-archetype-file-filtering.js | function (content, properties) {
var lines = content.split(lineEndingRE);
lines = replaceProperties(lines, properties);
lines = replaceSymbols(lines);
return lines.join('\n');
} | javascript | function (content, properties) {
var lines = content.split(lineEndingRE);
lines = replaceProperties(lines, properties);
lines = replaceSymbols(lines);
return lines.join('\n');
} | [
"function",
"(",
"content",
",",
"properties",
")",
"{",
"var",
"lines",
"=",
"content",
".",
"split",
"(",
"lineEndingRE",
")",
";",
"lines",
"=",
"replaceProperties",
"(",
"lines",
",",
"properties",
")",
";",
"lines",
"=",
"replaceSymbols",
"(",
"lines"... | Given some text, we find all references that correlate with provided properties
and replace them with the value assigned to the property.
@param {!string} content
@param {!Object} properties
@returns {!string} | [
"Given",
"some",
"text",
"we",
"find",
"all",
"references",
"that",
"correlate",
"with",
"provided",
"properties",
"and",
"replace",
"them",
"with",
"the",
"value",
"assigned",
"to",
"the",
"property",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/maven-archetype-file-filtering.js#L24-L29 | train | |
binduwavell/generator-alfresco-common | lib/maven-archetype-file-filtering.js | replaceProperties | function replaceProperties (lines, properties) {
var filteredLines = [];
lines.forEach((line) => {
for (var prop in properties) {
line = expandReference(line, prop, properties[prop]);
}
filteredLines.push(line);
});
return filteredLines;
} | javascript | function replaceProperties (lines, properties) {
var filteredLines = [];
lines.forEach((line) => {
for (var prop in properties) {
line = expandReference(line, prop, properties[prop]);
}
filteredLines.push(line);
});
return filteredLines;
} | [
"function",
"replaceProperties",
"(",
"lines",
",",
"properties",
")",
"{",
"var",
"filteredLines",
"=",
"[",
"]",
";",
"lines",
".",
"forEach",
"(",
"(",
"line",
")",
"=>",
"{",
"for",
"(",
"var",
"prop",
"in",
"properties",
")",
"{",
"line",
"=",
"... | Given a list of lines from a file, we go through each line and replace properties that
are provided with the associated value.
NOTE: This does not process properties if they are not in the properties parameter.
@param {!Array<string>} lines are processed one at a time
@param {!Object} properties are replaced
@returns... | [
"Given",
"a",
"list",
"of",
"lines",
"from",
"a",
"file",
"we",
"go",
"through",
"each",
"line",
"and",
"replace",
"properties",
"that",
"are",
"provided",
"with",
"the",
"associated",
"value",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/maven-archetype-file-filtering.js#L66-L75 | train |
pageobjectmodel/pom | src/emitter.js | once | function once(eventName, handler, context, args) {
this.on(eventName, handler, context, args, true);
} | javascript | function once(eventName, handler, context, args) {
this.on(eventName, handler, context, args, true);
} | [
"function",
"once",
"(",
"eventName",
",",
"handler",
",",
"context",
",",
"args",
")",
"{",
"this",
".",
"on",
"(",
"eventName",
",",
"handler",
",",
"context",
",",
"args",
",",
"true",
")",
";",
"}"
] | Adds listener for an event that should be called once
@param {string} eventName
@param {function} handler
@param {object} context
@param {array} args | [
"Adds",
"listener",
"for",
"an",
"event",
"that",
"should",
"be",
"called",
"once"
] | 75c566244e0520c3ca260dda261df3f4a92d8335 | https://github.com/pageobjectmodel/pom/blob/75c566244e0520c3ca260dda261df3f4a92d8335/src/emitter.js#L139-L141 | 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.