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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
rappid/rAppid.js | js/core/EventDispatcher.js | function (eventType, callback, scope) {
if (callback) {
scope = scope || this;
// get the list for the event
var list = this._eventHandlers[eventType] || (this._eventHandlers[eventType] = []);
// and push the callback functi... | javascript | function (eventType, callback, scope) {
if (callback) {
scope = scope || this;
// get the list for the event
var list = this._eventHandlers[eventType] || (this._eventHandlers[eventType] = []);
// and push the callback functi... | [
"function",
"(",
"eventType",
",",
"callback",
",",
"scope",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"scope",
"=",
"scope",
"||",
"this",
";",
"// get the list for the event",
"var",
"list",
"=",
"this",
".",
"_eventHandlers",
"[",
"eventType",
"]",
"||... | Binds a callback and a scope to a given eventType
@param {String} eventType The name of the event
@param {Function} callback The callback function - signature callback({@link EventDispatcher.Event},[caller])
@param {Object} [scope] This sets the scope for the callback function | [
"Binds",
"a",
"callback",
"and",
"a",
"scope",
"to",
"a",
"given",
"eventType"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/EventDispatcher.js#L72-L88 | train | |
rappid/rAppid.js | js/core/EventDispatcher.js | function (attributes, target) {
this.$ = attributes;
this.target = target;
this.isDefaultPrevented = false;
this.isPropagationStopped = false;
this.isImmediatePropagationStopped = false;
} | javascript | function (attributes, target) {
this.$ = attributes;
this.target = target;
this.isDefaultPrevented = false;
this.isPropagationStopped = false;
this.isImmediatePropagationStopped = false;
} | [
"function",
"(",
"attributes",
",",
"target",
")",
"{",
"this",
".",
"$",
"=",
"attributes",
";",
"this",
".",
"target",
"=",
"target",
";",
"this",
".",
"isDefaultPrevented",
"=",
"false",
";",
"this",
".",
"isPropagationStopped",
"=",
"false",
";",
"th... | Description of constructor.
@param {Object} attributes Hash of attributes | [
"Description",
"of",
"constructor",
"."
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/EventDispatcher.js#L225-L233 | train | |
rappid/rAppid.js | js/core/EventDispatcher.js | function () {
this.isDefaultPrevented = true;
if (this.$) {
var e = this.$.orginalEvent;
if (e) {
if (e.preventDefault) {
e.preventDefault();
} else {
... | javascript | function () {
this.isDefaultPrevented = true;
if (this.$) {
var e = this.$.orginalEvent;
if (e) {
if (e.preventDefault) {
e.preventDefault();
} else {
... | [
"function",
"(",
")",
"{",
"this",
".",
"isDefaultPrevented",
"=",
"true",
";",
"if",
"(",
"this",
".",
"$",
")",
"{",
"var",
"e",
"=",
"this",
".",
"$",
".",
"orginalEvent",
";",
"if",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"preventDefault",
... | Prevent default triggering | [
"Prevent",
"default",
"triggering"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/EventDispatcher.js#L238-L252 | train | |
rappid/rAppid.js | js/data/Collection.js | function (items, options) {
options = options || {};
_.defaults(options, {
root: null,
query: null,
pageSize: null,
queryParameters: {},
sortParameters: null,
factory: this.$modelFactory || require('... | javascript | function (items, options) {
options = options || {};
_.defaults(options, {
root: null,
query: null,
pageSize: null,
queryParameters: {},
sortParameters: null,
factory: this.$modelFactory || require('... | [
"function",
"(",
"items",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"_",
".",
"defaults",
"(",
"options",
",",
"{",
"root",
":",
"null",
",",
"query",
":",
"null",
",",
"pageSize",
":",
"null",
",",
"queryParameters",
... | read only to determinate if its a collection and prevent circular dependencies | [
"read",
"only",
"to",
"determinate",
"if",
"its",
"a",
"collection",
"and",
"prevent",
"circular",
"dependencies"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Collection.js#L25-L54 | train | |
rappid/rAppid.js | js/data/Collection.js | function (query, options) {
options.$itemsCount = undefined;
var collection = new this.factory(null, options);
collection.$context = this.$context;
return collection;
} | javascript | function (query, options) {
options.$itemsCount = undefined;
var collection = new this.factory(null, options);
collection.$context = this.$context;
return collection;
} | [
"function",
"(",
"query",
",",
"options",
")",
"{",
"options",
".",
"$itemsCount",
"=",
"undefined",
";",
"var",
"collection",
"=",
"new",
"this",
".",
"factory",
"(",
"null",
",",
"options",
")",
";",
"collection",
".",
"$context",
"=",
"this",
".",
"... | This method creates internally a filtered collection
@param {js.data.Query} query
@param {Object} options
@returns {js.data.Collection}
@private | [
"This",
"method",
"creates",
"internally",
"a",
"filtered",
"collection"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Collection.js#L93-L100 | train | |
rappid/rAppid.js | js/data/Collection.js | function (query) {
if (query instanceof Query && query.query.sort) {
if (this.$.query) {
query.query.where = this.$.query.query.where;
}
var options = _.defaults({}, {
query: query,
root: this.getRo... | javascript | function (query) {
if (query instanceof Query && query.query.sort) {
if (this.$.query) {
query.query.where = this.$.query.query.where;
}
var options = _.defaults({}, {
query: query,
root: this.getRo... | [
"function",
"(",
"query",
")",
"{",
"if",
"(",
"query",
"instanceof",
"Query",
"&&",
"query",
".",
"query",
".",
"sort",
")",
"{",
"if",
"(",
"this",
".",
"$",
".",
"query",
")",
"{",
"query",
".",
"query",
".",
"where",
"=",
"this",
".",
"$",
... | Returns a sorted query collection
@param {js.data.Query} query
@returns {js.data.Collection} | [
"Returns",
"a",
"sorted",
"query",
"collection"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Collection.js#L121-L143 | train | |
rappid/rAppid.js | js/data/Collection.js | function (pageIndex, options, callback) {
if (pageIndex < 0) {
throw "pageIndex must be >= 0";
}
var page = this.$pageCache[pageIndex];
if (!page) {
page = this.$pageCache[pageIndex] = new Page(null, this, pageIndex);
}
... | javascript | function (pageIndex, options, callback) {
if (pageIndex < 0) {
throw "pageIndex must be >= 0";
}
var page = this.$pageCache[pageIndex];
if (!page) {
page = this.$pageCache[pageIndex] = new Page(null, this, pageIndex);
}
... | [
"function",
"(",
"pageIndex",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"pageIndex",
"<",
"0",
")",
"{",
"throw",
"\"pageIndex must be >= 0\"",
";",
"}",
"var",
"page",
"=",
"this",
".",
"$pageCache",
"[",
"pageIndex",
"]",
";",
"if",
"(",
... | Fetches a page and returns it in the callback
@param {Number} pageIndex - starts at 0
@param {Object} options
@param {Function} callback | [
"Fetches",
"a",
"page",
"and",
"returns",
"it",
"in",
"the",
"callback"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Collection.js#L304-L332 | train | |
rappid/rAppid.js | js/data/Model.js | function (field) {
var schemaDefinition = this.schema[field];
if (!schemaDefinition) {
throw "Couldn't find '" + field + "' in schema";
}
var collection = this.get(field);
if (!collection) {
var context = this.getContextForChild... | javascript | function (field) {
var schemaDefinition = this.schema[field];
if (!schemaDefinition) {
throw "Couldn't find '" + field + "' in schema";
}
var collection = this.get(field);
if (!collection) {
var context = this.getContextForChild... | [
"function",
"(",
"field",
")",
"{",
"var",
"schemaDefinition",
"=",
"this",
".",
"schema",
"[",
"field",
"]",
";",
"if",
"(",
"!",
"schemaDefinition",
")",
"{",
"throw",
"\"Couldn't find '\"",
"+",
"field",
"+",
"\"' in schema\"",
";",
"}",
"var",
"collect... | Returns a sub collection of the model for a given field.
If the collection doesn't exist it gets created.
You should always use this method to get a sub collection.
@param {String} field
@returns {js.data.Collection} | [
"Returns",
"a",
"sub",
"collection",
"of",
"the",
"model",
"for",
"a",
"given",
"field",
".",
"If",
"the",
"collection",
"doesn",
"t",
"exist",
"it",
"gets",
"created",
".",
"You",
"should",
"always",
"use",
"this",
"method",
"to",
"get",
"a",
"sub",
"... | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Model.js#L177-L196 | train | |
rappid/rAppid.js | js/data/Model.js | function (action, options) {
var ret = this.callBase();
if (action === "create" && ret.hasOwnProperty(this.idField) && [this.idField] === null) {
delete ret[this.idField];
}
return ret;
} | javascript | function (action, options) {
var ret = this.callBase();
if (action === "create" && ret.hasOwnProperty(this.idField) && [this.idField] === null) {
delete ret[this.idField];
}
return ret;
} | [
"function",
"(",
"action",
",",
"options",
")",
"{",
"var",
"ret",
"=",
"this",
".",
"callBase",
"(",
")",
";",
"if",
"(",
"action",
"===",
"\"create\"",
"&&",
"ret",
".",
"hasOwnProperty",
"(",
"this",
".",
"idField",
")",
"&&",
"[",
"this",
".",
... | Pre-Composes the model before it goes to the DataSource processor
@param action
@param options
@returns {*} | [
"Pre",
"-",
"Composes",
"the",
"model",
"before",
"it",
"goes",
"to",
"the",
"DataSource",
"processor"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Model.js#L204-L212 | train | |
rappid/rAppid.js | js/data/Model.js | function (options, callback) {
if (arguments.length === 1 && options instanceof Function) {
callback = options;
options = null;
}
options = options || {};
var self = this;
if (this._fetch.state === FETCHSTATE.LOADING) {
... | javascript | function (options, callback) {
if (arguments.length === 1 && options instanceof Function) {
callback = options;
options = null;
}
options = options || {};
var self = this;
if (this._fetch.state === FETCHSTATE.LOADING) {
... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
"&&",
"options",
"instanceof",
"Function",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"null",
";",
"}",
"options",
"=",
"options",
... | Fetches the model over the given DataSource. The id of the model must be set.
@param {Object} options
@param {Array} options.fetchSubModels - array of submodels to fetch
@param {Function} callback - function(err, model, options) | [
"Fetches",
"the",
"model",
"over",
"the",
"given",
"DataSource",
".",
"The",
"id",
"of",
"the",
"model",
"must",
"be",
"set",
"."
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Model.js#L221-L256 | train | |
rappid/rAppid.js | js/data/Model.js | function (identifier) {
var idField = this.idField;
if (this.schema.hasOwnProperty(idField)) {
var schemaObject = this.schema[idField];
if (schemaObject.type && schemaObject.type === Number) {
return parseInt(identifier);
}
... | javascript | function (identifier) {
var idField = this.idField;
if (this.schema.hasOwnProperty(idField)) {
var schemaObject = this.schema[idField];
if (schemaObject.type && schemaObject.type === Number) {
return parseInt(identifier);
}
... | [
"function",
"(",
"identifier",
")",
"{",
"var",
"idField",
"=",
"this",
".",
"idField",
";",
"if",
"(",
"this",
".",
"schema",
".",
"hasOwnProperty",
"(",
"idField",
")",
")",
"{",
"var",
"schemaObject",
"=",
"this",
".",
"schema",
"[",
"idField",
"]",... | Converts the identifier to the given type in the schema
@param {String} identifier
@return {Number|String} | [
"Converts",
"the",
"identifier",
"to",
"the",
"given",
"type",
"in",
"the",
"schema"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Model.js#L339-L348 | train | |
rappid/rAppid.js | js/core/Repeat.js | function (items) {
var c,
j;
if (this.$renderedItems) {
for (j = this.$renderedItems.length - 1; j >= 0; j--) {
c = this.$renderedItems[j];
this.$parent.removeChild(c.component);
c.component.destroy();
... | javascript | function (items) {
var c,
j;
if (this.$renderedItems) {
for (j = this.$renderedItems.length - 1; j >= 0; j--) {
c = this.$renderedItems[j];
this.$parent.removeChild(c.component);
c.component.destroy();
... | [
"function",
"(",
"items",
")",
"{",
"var",
"c",
",",
"j",
";",
"if",
"(",
"this",
".",
"$renderedItems",
")",
"{",
"for",
"(",
"j",
"=",
"this",
".",
"$renderedItems",
".",
"length",
"-",
"1",
";",
"j",
">=",
"0",
";",
"j",
"--",
")",
"{",
"c... | Inner render method for a list of items
All rendered items will be removed and destroyed before rendering
@param {Array} items[]
@private | [
"Inner",
"render",
"method",
"for",
"a",
"list",
"of",
"items",
"All",
"rendered",
"items",
"will",
"be",
"removed",
"and",
"destroyed",
"before",
"rendering"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Repeat.js#L103-L136 | train | |
rappid/rAppid.js | js/core/Repeat.js | function (child, index) {
var indexOffset = this._calculateIndexOffsetForChild(child);
this.$parent.addChild(child, {childIndex: index + indexOffset});
} | javascript | function (child, index) {
var indexOffset = this._calculateIndexOffsetForChild(child);
this.$parent.addChild(child, {childIndex: index + indexOffset});
} | [
"function",
"(",
"child",
",",
"index",
")",
"{",
"var",
"indexOffset",
"=",
"this",
".",
"_calculateIndexOffsetForChild",
"(",
"child",
")",
";",
"this",
".",
"$parent",
".",
"addChild",
"(",
"child",
",",
"{",
"childIndex",
":",
"index",
"+",
"indexOffse... | Adds a child element to the right index in the parent element
@param {js.core.Element} child - the child to add
@param {Number} index - index of item
@private | [
"Adds",
"a",
"child",
"element",
"to",
"the",
"right",
"index",
"in",
"the",
"parent",
"element"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Repeat.js#L230-L233 | train | |
rappid/rAppid.js | js/core/Repeat.js | function (item) {
var key = this._getKeyForItem(item),
list = this.$renderedItems;
if (key) {
list = this.$renderedItemsMap[key];
}
if (list) {
var ri;
for (var i = 0; i < list.length; i++) {
... | javascript | function (item) {
var key = this._getKeyForItem(item),
list = this.$renderedItems;
if (key) {
list = this.$renderedItemsMap[key];
}
if (list) {
var ri;
for (var i = 0; i < list.length; i++) {
... | [
"function",
"(",
"item",
")",
"{",
"var",
"key",
"=",
"this",
".",
"_getKeyForItem",
"(",
"item",
")",
",",
"list",
"=",
"this",
".",
"$renderedItems",
";",
"if",
"(",
"key",
")",
"{",
"list",
"=",
"this",
".",
"$renderedItemsMap",
"[",
"key",
"]",
... | Returns the rendered component to a given item
@param item
@return {js.core.Component} component | [
"Returns",
"the",
"rendered",
"component",
"to",
"a",
"given",
"item"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Repeat.js#L297-L313 | train | |
rappid/rAppid.js | js/lib/query/query.js | function (operator, field) {
if (!this.query.where) {
return null;
}
function findExpression(expressions) {
var expression,
ret = null;
for (var i = 0; i < expressions.length; i++) {
expression =... | javascript | function (operator, field) {
if (!this.query.where) {
return null;
}
function findExpression(expressions) {
var expression,
ret = null;
for (var i = 0; i < expressions.length; i++) {
expression =... | [
"function",
"(",
"operator",
",",
"field",
")",
"{",
"if",
"(",
"!",
"this",
".",
"query",
".",
"where",
")",
"{",
"return",
"null",
";",
"}",
"function",
"findExpression",
"(",
"expressions",
")",
"{",
"var",
"expression",
",",
"ret",
"=",
"null",
"... | Tries to find a expression for an operator and a field
@param {String} operator
@param {String} field
@returns {*} | [
"Tries",
"to",
"find",
"a",
"expression",
"for",
"an",
"operator",
"and",
"a",
"field"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/lib/query/query.js#L128-L154 | train | |
rappid/rAppid.js | js/core/Component.js | function (event) {
for (var i = 0; i < this.events.length; i++) {
if (event === this.events[i]) {
return true;
}
}
return false;
} | javascript | function (event) {
for (var i = 0; i < this.events.length; i++) {
if (event === this.events[i]) {
return true;
}
}
return false;
} | [
"function",
"(",
"event",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"events",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"event",
"===",
"this",
".",
"events",
"[",
"i",
"]",
")",
"{",
"return",
"true",
... | Returns true if event is defined in Component event list
@param event | [
"Returns",
"true",
"if",
"event",
"is",
"defined",
"in",
"Component",
"event",
"list"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Component.js#L410-L417 | train | |
rappid/rAppid.js | js/core/Component.js | function (domNode) {
if (domNode.localName) {
return domNode.localName;
}
var localName = LocalNameCache[domNode.tagName];
if (localName) {
return localName;
}
var st = domNode.tagNam... | javascript | function (domNode) {
if (domNode.localName) {
return domNode.localName;
}
var localName = LocalNameCache[domNode.tagName];
if (localName) {
return localName;
}
var st = domNode.tagNam... | [
"function",
"(",
"domNode",
")",
"{",
"if",
"(",
"domNode",
".",
"localName",
")",
"{",
"return",
"domNode",
".",
"localName",
";",
"}",
"var",
"localName",
"=",
"LocalNameCache",
"[",
"domNode",
".",
"tagName",
"]",
";",
"if",
"(",
"localName",
")",
"... | determinate the local-name of a DomNode
@param domNode | [
"determinate",
"the",
"local",
"-",
"name",
"of",
"a",
"DomNode"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Component.js#L573-L588 | train | |
rappid/rAppid.js | js/data/DataSource.js | function (entity, action, options) {
var ret = {},
data = entity.compose(action, options),
schemaDefinition,
schemaType,
isModel = entity instanceof Model,
factory = entity.factory;
for (... | javascript | function (entity, action, options) {
var ret = {},
data = entity.compose(action, options),
schemaDefinition,
schemaType,
isModel = entity instanceof Model,
factory = entity.factory;
for (... | [
"function",
"(",
"entity",
",",
"action",
",",
"options",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
",",
"data",
"=",
"entity",
".",
"compose",
"(",
"action",
",",
"options",
")",
",",
"schemaDefinition",
",",
"schemaType",
",",
"isModel",
"=",
"entity",
... | Composes an entity, calls default compose method
@param entity
@param action
@param options
@return {JSON}
@private | [
"Composes",
"an",
"entity",
"calls",
"default",
"compose",
"method"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/DataSource.js#L373-L400 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.ejs.js | function(object, extra_helpers) {
object = object || {};
this._extra_helpers = extra_helpers;
var v = new EJS.Helpers(object, extra_helpers || {});
return this.template.process.call(object, object,v);
} | javascript | function(object, extra_helpers) {
object = object || {};
this._extra_helpers = extra_helpers;
var v = new EJS.Helpers(object, extra_helpers || {});
return this.template.process.call(object, object,v);
} | [
"function",
"(",
"object",
",",
"extra_helpers",
")",
"{",
"object",
"=",
"object",
"||",
"{",
"}",
";",
"this",
".",
"_extra_helpers",
"=",
"extra_helpers",
";",
"var",
"v",
"=",
"new",
"EJS",
".",
"Helpers",
"(",
"object",
",",
"extra_helpers",
"||",
... | Renders an object with extra view helpers attached to the view.
@param {Object} object data to be rendered
@param {Object} extra_helpers an object with additonal view helpers
@return {String} returns the result of the string | [
"Renders",
"an",
"object",
"with",
"extra",
"view",
"helpers",
"attached",
"to",
"the",
"view",
"."
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.ejs.js#L91-L96 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.ejs.js | function(options, data, helpers) {
if (!helpers) helpers = this._extras;
if (!data) data = this._data;
return new EJS(options).render(data, helpers);
} | javascript | function(options, data, helpers) {
if (!helpers) helpers = this._extras;
if (!data) data = this._data;
return new EJS(options).render(data, helpers);
} | [
"function",
"(",
"options",
",",
"data",
",",
"helpers",
")",
"{",
"if",
"(",
"!",
"helpers",
")",
"helpers",
"=",
"this",
".",
"_extras",
";",
"if",
"(",
"!",
"data",
")",
"data",
"=",
"this",
".",
"_data",
";",
"return",
"new",
"EJS",
"(",
"opt... | Renders a new view. If data is passed in, uses that to render the view.
@param {Object} options standard options passed to a new view.
@param {optional:Object} data
@return {String} | [
"Renders",
"a",
"new",
"view",
".",
"If",
"data",
"is",
"passed",
"in",
"uses",
"that",
"to",
"render",
"the",
"view",
"."
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.ejs.js#L421-L425 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.ejs.js | function(input, null_text) {
if (input == null || input === undefined) return null_text || '';
if (input instanceof(Date)) return input.toDateString();
if (input.toString) return input.toString().replace(/\n/g, '<br />').replace(/''/g, "'");
return '';
} | javascript | function(input, null_text) {
if (input == null || input === undefined) return null_text || '';
if (input instanceof(Date)) return input.toDateString();
if (input.toString) return input.toString().replace(/\n/g, '<br />').replace(/''/g, "'");
return '';
} | [
"function",
"(",
"input",
",",
"null_text",
")",
"{",
"if",
"(",
"input",
"==",
"null",
"||",
"input",
"===",
"undefined",
")",
"return",
"null_text",
"||",
"''",
";",
"if",
"(",
"input",
"instanceof",
"(",
"Date",
")",
")",
"return",
"input",
".",
"... | For a given value, tries to create a human representation.
@param {Object} input the value being converted.
@param {Object} null_text what text should be present if input == null or undefined, defaults to ''
@return {String} | [
"For",
"a",
"given",
"value",
"tries",
"to",
"create",
"a",
"human",
"representation",
"."
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.ejs.js#L432-L437 | train | |
rappid/rAppid.js | js/core/Binding.js | function (path) {
var str = [];
for (var i = 0; i < path.length; i++) {
var el = path[i];
if (el.type === TYPE_VAR) {
str.push(el.name);
} else {
return false;
}
}
return str.join(".");
} | javascript | function (path) {
var str = [];
for (var i = 0; i < path.length; i++) {
var el = path[i];
if (el.type === TYPE_VAR) {
str.push(el.name);
} else {
return false;
}
}
return str.join(".");
} | [
"function",
"(",
"path",
")",
"{",
"var",
"str",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"path",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"el",
"=",
"path",
"[",
"i",
"]",
";",
"if",
"(",
"el",
".",
"... | Returns false if path includes function
@param path | [
"Returns",
"false",
"if",
"path",
"includes",
"function"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Binding.js#L14-L25 | train | |
rappid/rAppid.js | js/core/Binding.js | function (event) {
if (!this.$) {
return;
}
for (var i = 0; i < this.$.fnc._attributes.length; i++) {
if (event.$.hasOwnProperty(this.$.fnc._attributes[i])) {
this._callback();
return;
}
... | javascript | function (event) {
if (!this.$) {
return;
}
for (var i = 0; i < this.$.fnc._attributes.length; i++) {
if (event.$.hasOwnProperty(this.$.fnc._attributes[i])) {
this._callback();
return;
}
... | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"this",
".",
"$",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$",
".",
"fnc",
".",
"_attributes",
".",
"length",
";",
"i",
"++",
")",
"{",
... | This method is called, when the a change event of an function binding is triggered
@param event
@private | [
"This",
"method",
"is",
"called",
"when",
"the",
"a",
"change",
"event",
"of",
"an",
"function",
"binding",
"is",
"triggered"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Binding.js#L334-L346 | train | |
rappid/rAppid.js | js/core/Binding.js | function () {
// binding already destroyed?
if (!this.$) {
return;
}
var e;
for (var j = 0; j < this.$events.length; j++) {
e = this.$events[j];
this.$.scope.unbind(e.eventType, e.callback, this);
}
... | javascript | function () {
// binding already destroyed?
if (!this.$) {
return;
}
var e;
for (var j = 0; j < this.$events.length; j++) {
e = this.$events[j];
this.$.scope.unbind(e.eventType, e.callback, this);
}
... | [
"function",
"(",
")",
"{",
"// binding already destroyed?",
"if",
"(",
"!",
"this",
".",
"$",
")",
"{",
"return",
";",
"}",
"var",
"e",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"this",
".",
"$events",
".",
"length",
";",
"j",
"++",
... | Unbinds all events and destroys subBinding... | [
"Unbinds",
"all",
"events",
"and",
"destroys",
"subBinding",
"..."
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Binding.js#L374-L415 | train | |
rappid/rAppid.js | js/core/Binding.js | function () {
var parameters = [];
for (var i = 0; i < this.$parameters.length; i++) {
var para = this.$parameters[i];
if (para instanceof Binding) {
para = para.getValue();
}
parameters.push(para);
}... | javascript | function () {
var parameters = [];
for (var i = 0; i < this.$parameters.length; i++) {
var para = this.$parameters[i];
if (para instanceof Binding) {
para = para.getValue();
}
parameters.push(para);
}... | [
"function",
"(",
")",
"{",
"var",
"parameters",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$parameters",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"para",
"=",
"this",
".",
"$parameters",
"[",
"i",
... | Returns an array with values of all function parameters
@return {Array}
@private | [
"Returns",
"an",
"array",
"with",
"values",
"of",
"all",
"function",
"parameters"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Binding.js#L421-L431 | train | |
rappid/rAppid.js | js/core/Binding.js | function () {
if (this.$subBinding) {
this.$subBinding.invalidateValueCache();
return this.$subBinding.getValue();
} else {
if (this.$cachedValue !== undefined && !this.$jsonObject) {
return this.$cachedValue;
}... | javascript | function () {
if (this.$subBinding) {
this.$subBinding.invalidateValueCache();
return this.$subBinding.getValue();
} else {
if (this.$cachedValue !== undefined && !this.$jsonObject) {
return this.$cachedValue;
}... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"$subBinding",
")",
"{",
"this",
".",
"$subBinding",
".",
"invalidateValueCache",
"(",
")",
";",
"return",
"this",
".",
"$subBinding",
".",
"getValue",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"th... | Returns the transformed value of the binding or null, if the binding path is not present
@return {*} | [
"Returns",
"the",
"transformed",
"value",
"of",
"the",
"binding",
"or",
"null",
"if",
"the",
"binding",
"path",
"is",
"not",
"present"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Binding.js#L436-L460 | train | |
rappid/rAppid.js | js/core/Binding.js | function () {
// get value
var val = this.getContextValue();
var target,
targets = this.$.root.getTargets();
if (targets) {
for (var i = 0; i < targets.length; i++) {
target = targets[i];
if (target.... | javascript | function () {
// get value
var val = this.getContextValue();
var target,
targets = this.$.root.getTargets();
if (targets) {
for (var i = 0; i < targets.length; i++) {
target = targets[i];
if (target.... | [
"function",
"(",
")",
"{",
"// get value",
"var",
"val",
"=",
"this",
".",
"getContextValue",
"(",
")",
";",
"var",
"target",
",",
"targets",
"=",
"this",
".",
"$",
".",
"root",
".",
"getTargets",
"(",
")",
";",
"if",
"(",
"targets",
")",
"{",
"for... | This method triggers the binding and syncs the target with the scope | [
"This",
"method",
"triggers",
"the",
"binding",
"and",
"syncs",
"the",
"target",
"with",
"the",
"scope"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Binding.js#L480-L497 | train | |
rappid/rAppid.js | js/core/Bindable.js | function () {
if (this._$source) {
var val, attributes = {}, unsetAttributes = {};
for (var key in this.$) {
if (this.$.hasOwnProperty(key)) {
val = this.$[key];
... | javascript | function () {
if (this._$source) {
var val, attributes = {}, unsetAttributes = {};
for (var key in this.$) {
if (this.$.hasOwnProperty(key)) {
val = this.$[key];
... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_$source",
")",
"{",
"var",
"val",
",",
"attributes",
"=",
"{",
"}",
",",
"unsetAttributes",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"$",
")",
"{",
"if",
"(",
"this",
... | Writes attributes back to the source | [
"Writes",
"attributes",
"back",
"to",
"the",
"source"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Bindable.js#L500-L528 | train | |
rappid/rAppid.js | js/core/Bindable.js | function (attribute, key) {
if (this.inject && this.inject.hasOwnProperty(key)) {
return attribute;
} else if (attribute instanceof Bindable) {
return attribute.clone();
} else if (attribute && (attribute.clone i... | javascript | function (attribute, key) {
if (this.inject && this.inject.hasOwnProperty(key)) {
return attribute;
} else if (attribute instanceof Bindable) {
return attribute.clone();
} else if (attribute && (attribute.clone i... | [
"function",
"(",
"attribute",
",",
"key",
")",
"{",
"if",
"(",
"this",
".",
"inject",
"&&",
"this",
".",
"inject",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"return",
"attribute",
";",
"}",
"else",
"if",
"(",
"attribute",
"instanceof",
"Bindabl... | Returns a copy of the attribute. This method is a hook for further cloning options
@param attribute
@param key
@private | [
"Returns",
"a",
"copy",
"of",
"the",
"attribute",
".",
"This",
"method",
"is",
"a",
"hook",
"for",
"further",
"cloning",
"options"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Bindable.js#L568-L594 | train | |
rappid/rAppid.js | js/core/Bindable.js | function (key, value, options) {
if (_.isNumber(key)) {
key = String(key);
}
if (_.isString(key)) {
var attributes = {};
attributes[key] = value;
} else {
... | javascript | function (key, value, options) {
if (_.isNumber(key)) {
key = String(key);
}
if (_.isString(key)) {
var attributes = {};
attributes[key] = value;
} else {
... | [
"function",
"(",
"key",
",",
"value",
",",
"options",
")",
"{",
"if",
"(",
"_",
".",
"isNumber",
"(",
"key",
")",
")",
"{",
"key",
"=",
"String",
"(",
"key",
")",
";",
"}",
"if",
"(",
"_",
".",
"isString",
"(",
"key",
")",
")",
"{",
"var",
... | Sets new values for attributes and notify about changes
@param {String} key The attribute key
@param {String} value The attribute value
@param {Object} options A hash of options
@param {Boolean} [options.silent=false] if true no event is triggered on change
@param {Boolean} [options.unset=false] if true the attribute ... | [
"Sets",
"new",
"values",
"for",
"attributes",
"and",
"notify",
"about",
"changes"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Bindable.js#L651-L738 | train | |
rappid/rAppid.js | srv/core/AuthenticationService.js | function (authenticationRequest) {
var authenticationProviders = this.$providers,
provider;
for (var i = 0; i < authenticationProviders.length; i++) {
provider = authenticationProviders[i];
if (provider.isResponsibleForAuthenticationRequest(aut... | javascript | function (authenticationRequest) {
var authenticationProviders = this.$providers,
provider;
for (var i = 0; i < authenticationProviders.length; i++) {
provider = authenticationProviders[i];
if (provider.isResponsibleForAuthenticationRequest(aut... | [
"function",
"(",
"authenticationRequest",
")",
"{",
"var",
"authenticationProviders",
"=",
"this",
".",
"$providers",
",",
"provider",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"authenticationProviders",
".",
"length",
";",
"i",
"++",
")",
"{",... | Returns the authentication provider for a given request
@param authenticationRequest
@returns {*} | [
"Returns",
"the",
"authentication",
"provider",
"for",
"a",
"given",
"request"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/core/AuthenticationService.js#L79-L95 | train | |
rappid/rAppid.js | srv/core/AuthenticationService.js | function (context, token, callback) {
var authentication = this.$.dataSource.createEntity(Authentication, token),
self = this;
// setup authentication
this.$stage.$bus.setUp(authentication);
flow()
.seq("authentication", function (cb) {
... | javascript | function (context, token, callback) {
var authentication = this.$.dataSource.createEntity(Authentication, token),
self = this;
// setup authentication
this.$stage.$bus.setUp(authentication);
flow()
.seq("authentication", function (cb) {
... | [
"function",
"(",
"context",
",",
"token",
",",
"callback",
")",
"{",
"var",
"authentication",
"=",
"this",
".",
"$",
".",
"dataSource",
".",
"createEntity",
"(",
"Authentication",
",",
"token",
")",
",",
"self",
"=",
"this",
";",
"// setup authentication",
... | Checks token against a database
@param token
@param callback | [
"Checks",
"token",
"against",
"a",
"database"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/core/AuthenticationService.js#L120-L161 | train | |
rappid/rAppid.js | srv/core/AuthenticationService.js | function (authentication, callback) {
/***
* Let's save the authentication and so the user is logged in
*
*/
var token = generateId();
var authenticationInstance = this.$.dataSource.createEntity(Authentication, token);
authenticatio... | javascript | function (authentication, callback) {
/***
* Let's save the authentication and so the user is logged in
*
*/
var token = generateId();
var authenticationInstance = this.$.dataSource.createEntity(Authentication, token);
authenticatio... | [
"function",
"(",
"authentication",
",",
"callback",
")",
"{",
"/***\n * Let's save the authentication and so the user is logged in\n *\n */",
"var",
"token",
"=",
"generateId",
"(",
")",
";",
"var",
"authenticationInstance",
"=",
"this",
".",... | Saves an authentication and adds an token to it
@param authentication
@param callback | [
"Saves",
"an",
"authentication",
"and",
"adds",
"an",
"token",
"to",
"it"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/core/AuthenticationService.js#L279-L289 | train | |
rappid/rAppid.js | srv/handler/rest/ResourceHandler.js | function (context, callback, checkParents) {
if (this.$parentResource) {
var self = this;
flow()
.seq("parentCollection", function (cb) {
self.$parentResource._findCollection(context, cb);
})
... | javascript | function (context, callback, checkParents) {
if (this.$parentResource) {
var self = this;
flow()
.seq("parentCollection", function (cb) {
self.$parentResource._findCollection(context, cb);
})
... | [
"function",
"(",
"context",
",",
"callback",
",",
"checkParents",
")",
"{",
"if",
"(",
"this",
".",
"$parentResource",
")",
"{",
"var",
"self",
"=",
"this",
";",
"flow",
"(",
")",
".",
"seq",
"(",
"\"parentCollection\"",
",",
"function",
"(",
"cb",
")"... | Returns a collection for this resource in the right context
@param {srv.core.Context} context
@param {Function} callback
@param {Boolean} [checkParents] - default true
@return {*}
@private | [
"Returns",
"a",
"collection",
"for",
"this",
"resource",
"in",
"the",
"right",
"context"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/handler/rest/ResourceHandler.js#L178-L208 | train | |
rappid/rAppid.js | js/core/History.js | function () {
if (this.$processUrl) {
var currentFragment = this._getFragment();
if (currentFragment == this.$fragment) {
return false;
}
this.navigate(currentFragment, !this.$.useState, true, true, emptyCallback);
... | javascript | function () {
if (this.$processUrl) {
var currentFragment = this._getFragment();
if (currentFragment == this.$fragment) {
return false;
}
this.navigate(currentFragment, !this.$.useState, true, true, emptyCallback);
... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"$processUrl",
")",
"{",
"var",
"currentFragment",
"=",
"this",
".",
"_getFragment",
"(",
")",
";",
"if",
"(",
"currentFragment",
"==",
"this",
".",
"$fragment",
")",
"{",
"return",
"false",
";",
"}",
... | Checks if the current fragment has changed and calls navigate in case it did | [
"Checks",
"if",
"the",
"current",
"fragment",
"has",
"changed",
"and",
"calls",
"navigate",
"in",
"case",
"it",
"did"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/History.js#L175-L188 | train | |
rappid/rAppid.js | js/core/History.js | function (fragment, callback) {
var routeExecutionStack = [];
for (var i = 0; i < this.$routers.length; i++) {
routeExecutionStack = routeExecutionStack.concat(this.$routers[i].generateRoutingStack(fragment));
}
if (routeExecutionStack.length === 0) {
... | javascript | function (fragment, callback) {
var routeExecutionStack = [];
for (var i = 0; i < this.$routers.length; i++) {
routeExecutionStack = routeExecutionStack.concat(this.$routers[i].generateRoutingStack(fragment));
}
if (routeExecutionStack.length === 0) {
... | [
"function",
"(",
"fragment",
",",
"callback",
")",
"{",
"var",
"routeExecutionStack",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$routers",
".",
"length",
";",
"i",
"++",
")",
"{",
"routeExecutionStack",
"=",
... | Triggers a route
@param {String} fragment - the fragment which should be triggered
@param {Function} callback - gets called after the route execution stack is done | [
"Triggers",
"a",
"route"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/History.js#L195-L212 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | getPlugins | function getPlugins(){
var plugins = $p.plugins,
f = function(){};
f.prototype = plugins;
// do not overwrite functions if external definition
f.prototype.compile = plugins.compile || compile;
f.prototype.render = plugins.render || render;
f.prototype.autoRender = plugins.autoRende... | javascript | function getPlugins(){
var plugins = $p.plugins,
f = function(){};
f.prototype = plugins;
// do not overwrite functions if external definition
f.prototype.compile = plugins.compile || compile;
f.prototype.render = plugins.render || render;
f.prototype.autoRender = plugins.autoRende... | [
"function",
"getPlugins",
"(",
")",
"{",
"var",
"plugins",
"=",
"$p",
".",
"plugins",
",",
"f",
"=",
"function",
"(",
")",
"{",
"}",
";",
"f",
".",
"prototype",
"=",
"plugins",
";",
"// do not overwrite functions if external definition",
"f",
".",
"prototype... | return a new instance of plugins | [
"return",
"a",
"new",
"instance",
"of",
"plugins"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L87-L103 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | wrapquote | function wrapquote(qfn, f){
return function(ctxt){
return qfn('' + f.call(ctxt.context, ctxt));
};
} | javascript | function wrapquote(qfn, f){
return function(ctxt){
return qfn('' + f.call(ctxt.context, ctxt));
};
} | [
"function",
"wrapquote",
"(",
"qfn",
",",
"f",
")",
"{",
"return",
"function",
"(",
"ctxt",
")",
"{",
"return",
"qfn",
"(",
"''",
"+",
"f",
".",
"call",
"(",
"ctxt",
".",
"context",
",",
"ctxt",
")",
")",
";",
"}",
";",
"}"
] | returns the string generator function | [
"returns",
"the",
"string",
"generator",
"function"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L119-L123 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | find | function find(n, sel){
if(typeof n === 'string'){
sel = n;
n = false;
}
if(typeof document.querySelectorAll !== 'undefined'){
return (n||document).querySelectorAll( sel );
}else{
error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your br... | javascript | function find(n, sel){
if(typeof n === 'string'){
sel = n;
n = false;
}
if(typeof document.querySelectorAll !== 'undefined'){
return (n||document).querySelectorAll( sel );
}else{
error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your br... | [
"function",
"find",
"(",
"n",
",",
"sel",
")",
"{",
"if",
"(",
"typeof",
"n",
"===",
"'string'",
")",
"{",
"sel",
"=",
"n",
";",
"n",
"=",
"false",
";",
"}",
"if",
"(",
"typeof",
"document",
".",
"querySelectorAll",
"!==",
"'undefined'",
")",
"{",
... | default find using querySelector when available on the browser | [
"default",
"find",
"using",
"querySelector",
"when",
"available",
"on",
"the",
"browser"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L126-L136 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | parseloopspec | function parseloopspec(p){
var m = p.match( /^(\w+)\s*<-\s*(\S+)?$/ );
if(m === null){
error('bad loop spec: "' + p + '"');
}
if(m[1] === 'item'){
error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
}
if( !m[2] || (... | javascript | function parseloopspec(p){
var m = p.match( /^(\w+)\s*<-\s*(\S+)?$/ );
if(m === null){
error('bad loop spec: "' + p + '"');
}
if(m[1] === 'item'){
error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
}
if( !m[2] || (... | [
"function",
"parseloopspec",
"(",
"p",
")",
"{",
"var",
"m",
"=",
"p",
".",
"match",
"(",
"/",
"^(\\w+)\\s*<-\\s*(\\S+)?$",
"/",
")",
";",
"if",
"(",
"m",
"===",
"null",
")",
"{",
"error",
"(",
"'bad loop spec: \"'",
"+",
"p",
"+",
"'\"'",
")",
";",
... | parse and check the loop directive | [
"parse",
"and",
"check",
"the",
"loop",
"directive"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L171-L183 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | loopfn | function loopfn(name, dselect, inner, sorter, filter){
return function(ctxt){
var a = dselect(ctxt),
old = ctxt[name],
temp = { items : a },
filtered = 0,
length,
strs = [],
buildArg = function(idx, temp, ftr, len){
ctxt.pos = temp.pos = idx;
... | javascript | function loopfn(name, dselect, inner, sorter, filter){
return function(ctxt){
var a = dselect(ctxt),
old = ctxt[name],
temp = { items : a },
filtered = 0,
length,
strs = [],
buildArg = function(idx, temp, ftr, len){
ctxt.pos = temp.pos = idx;
... | [
"function",
"loopfn",
"(",
"name",
",",
"dselect",
",",
"inner",
",",
"sorter",
",",
"filter",
")",
"{",
"return",
"function",
"(",
"ctxt",
")",
"{",
"var",
"a",
"=",
"dselect",
"(",
"ctxt",
")",
",",
"old",
"=",
"ctxt",
"[",
"name",
"]",
",",
"t... | read de loop data, and pass it to the inner rendering function | [
"read",
"de",
"loop",
"data",
"and",
"pass",
"it",
"to",
"the",
"inner",
"rendering",
"function"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L346-L391 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | loopgen | function loopgen(dom, sel, loop, fns){
var already = false, ls, sorter, filter, prop;
for(prop in loop){
if(loop.hasOwnProperty(prop)){
if(prop === 'sort'){
sorter = loop.sort;
continue;
}else if(prop === 'filter'){
filter = loop.filter;
continue;
... | javascript | function loopgen(dom, sel, loop, fns){
var already = false, ls, sorter, filter, prop;
for(prop in loop){
if(loop.hasOwnProperty(prop)){
if(prop === 'sort'){
sorter = loop.sort;
continue;
}else if(prop === 'filter'){
filter = loop.filter;
continue;
... | [
"function",
"loopgen",
"(",
"dom",
",",
"sel",
",",
"loop",
",",
"fns",
")",
"{",
"var",
"already",
"=",
"false",
",",
"ls",
",",
"sorter",
",",
"filter",
",",
"prop",
";",
"for",
"(",
"prop",
"in",
"loop",
")",
"{",
"if",
"(",
"loop",
".",
"ha... | generate the template for a loop node | [
"generate",
"the",
"template",
"for",
"a",
"loop",
"node"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L393-L433 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | compiler | function compiler(dom, directive, data, ans){
var fns = [];
// autoRendering nodes parsing -> auto-nodes
ans = ans || data && getAutoNodes(dom, data);
if(data){
var j, jj, cspec, n, target, nodes, itersel, node, inner;
// for each auto-nodes
while(ans.length > 0){
cspec = ans[0... | javascript | function compiler(dom, directive, data, ans){
var fns = [];
// autoRendering nodes parsing -> auto-nodes
ans = ans || data && getAutoNodes(dom, data);
if(data){
var j, jj, cspec, n, target, nodes, itersel, node, inner;
// for each auto-nodes
while(ans.length > 0){
cspec = ans[0... | [
"function",
"compiler",
"(",
"dom",
",",
"directive",
",",
"data",
",",
"ans",
")",
"{",
"var",
"fns",
"=",
"[",
"]",
";",
"// autoRendering nodes parsing -> auto-nodes",
"ans",
"=",
"ans",
"||",
"data",
"&&",
"getAutoNodes",
"(",
"dom",
",",
"data",
")",
... | returns a function that, given a context argument, will render the template defined by dom and directive. | [
"returns",
"a",
"function",
"that",
"given",
"a",
"context",
"argument",
"will",
"render",
"the",
"template",
"defined",
"by",
"dom",
"and",
"directive",
"."
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L510-L576 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | compile | function compile(directive, ctxt, template){
var rfn = compiler( ( template || this[0] ).cloneNode(true), directive, ctxt);
return function(context){
return rfn({context:context});
};
} | javascript | function compile(directive, ctxt, template){
var rfn = compiler( ( template || this[0] ).cloneNode(true), directive, ctxt);
return function(context){
return rfn({context:context});
};
} | [
"function",
"compile",
"(",
"directive",
",",
"ctxt",
",",
"template",
")",
"{",
"var",
"rfn",
"=",
"compiler",
"(",
"(",
"template",
"||",
"this",
"[",
"0",
"]",
")",
".",
"cloneNode",
"(",
"true",
")",
",",
"directive",
",",
"ctxt",
")",
";",
"re... | compile the template with directive if a context is passed, the autoRendering is triggered automatically return a function waiting the data as argument | [
"compile",
"the",
"template",
"with",
"directive",
"if",
"a",
"context",
"is",
"passed",
"the",
"autoRendering",
"is",
"triggered",
"automatically",
"return",
"a",
"function",
"waiting",
"the",
"data",
"as",
"argument"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L580-L585 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.pure.js | render | function render(ctxt, directive){
var fn = typeof directive === 'function' ? directive : plugins.compile( directive, false, this[0] );
for(var i = 0, ii = this.length; i < ii; i++){
this[i] = replaceWith( this[i], fn( ctxt, false ));
}
context = null;
return this;
} | javascript | function render(ctxt, directive){
var fn = typeof directive === 'function' ? directive : plugins.compile( directive, false, this[0] );
for(var i = 0, ii = this.length; i < ii; i++){
this[i] = replaceWith( this[i], fn( ctxt, false ));
}
context = null;
return this;
} | [
"function",
"render",
"(",
"ctxt",
",",
"directive",
")",
"{",
"var",
"fn",
"=",
"typeof",
"directive",
"===",
"'function'",
"?",
"directive",
":",
"plugins",
".",
"compile",
"(",
"directive",
",",
"false",
",",
"this",
"[",
"0",
"]",
")",
";",
"for",
... | compile with the directive as argument run the template function on the context argument return an HTML string should replace the template and return this | [
"compile",
"with",
"the",
"directive",
"as",
"argument",
"run",
"the",
"template",
"function",
"on",
"the",
"context",
"argument",
"return",
"an",
"HTML",
"string",
"should",
"replace",
"the",
"template",
"and",
"return",
"this"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.pure.js#L590-L597 | train |
adrianlee44/ical2json | index.js | convert | function convert(source) {
let currentKey = "",
currentValue = "",
objectNames = [],
output = {},
parentObj = {},
lines = source.split(NEW_LINE),
splitAt;
let currentObj = output;
let parents = [];
for (let i = 0; i < lines.length; i++) {
let line = lines[i];
if (li... | javascript | function convert(source) {
let currentKey = "",
currentValue = "",
objectNames = [],
output = {},
parentObj = {},
lines = source.split(NEW_LINE),
splitAt;
let currentObj = output;
let parents = [];
for (let i = 0; i < lines.length; i++) {
let line = lines[i];
if (li... | [
"function",
"convert",
"(",
"source",
")",
"{",
"let",
"currentKey",
"=",
"\"\"",
",",
"currentValue",
"=",
"\"\"",
",",
"objectNames",
"=",
"[",
"]",
",",
"output",
"=",
"{",
"}",
",",
"parentObj",
"=",
"{",
"}",
",",
"lines",
"=",
"source",
".",
... | Take ical string data and convert to JSON
@param {string} source
@returns {Object} | [
"Take",
"ical",
"string",
"data",
"and",
"convert",
"to",
"JSON"
] | 4f1e00f896d68fa7ed6365f12788d6603377cffc | https://github.com/adrianlee44/ical2json/blob/4f1e00f896d68fa7ed6365f12788d6603377cffc/index.js#L17-L72 | train |
adrianlee44/ical2json | index.js | revert | function revert(object) {
let lines = [];
for (let key in object) {
let value = object[key];
if (Array.isArray(value)) {
value.forEach((item) => {
lines.push(`BEGIN:${key}`);
lines.push(revert(item));
lines.push(`END:${key}`);
});
} else {
let fullLine = `${key... | javascript | function revert(object) {
let lines = [];
for (let key in object) {
let value = object[key];
if (Array.isArray(value)) {
value.forEach((item) => {
lines.push(`BEGIN:${key}`);
lines.push(revert(item));
lines.push(`END:${key}`);
});
} else {
let fullLine = `${key... | [
"function",
"revert",
"(",
"object",
")",
"{",
"let",
"lines",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"key",
"in",
"object",
")",
"{",
"let",
"value",
"=",
"object",
"[",
"key",
"]",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
"... | Take JSON, revert back to ical
@param {Object} object
@return {String} | [
"Take",
"JSON",
"revert",
"back",
"to",
"ical"
] | 4f1e00f896d68fa7ed6365f12788d6603377cffc | https://github.com/adrianlee44/ical2json/blob/4f1e00f896d68fa7ed6365f12788d6603377cffc/index.js#L79-L102 | train |
adrianlee44/ical2json | index.js | run | function run(options) {
let files, filePromises = [];
files = options.args || [];
for (let i = 0; i < files.length; i++) {
let file = files[i];
let filePath = path.resolve(cwd, file);
if (!fs.existsSync(filePath)) {
continue;
}
let stat = fs.statSync(filePath);
let ext = path.extn... | javascript | function run(options) {
let files, filePromises = [];
files = options.args || [];
for (let i = 0; i < files.length; i++) {
let file = files[i];
let filePath = path.resolve(cwd, file);
if (!fs.existsSync(filePath)) {
continue;
}
let stat = fs.statSync(filePath);
let ext = path.extn... | [
"function",
"run",
"(",
"options",
")",
"{",
"let",
"files",
",",
"filePromises",
"=",
"[",
"]",
";",
"files",
"=",
"options",
".",
"args",
"||",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
... | Pass in options to parse and generate JSON files
@param {Object} options
@return {Promise} | [
"Pass",
"in",
"options",
"to",
"parse",
"and",
"generate",
"JSON",
"files"
] | 4f1e00f896d68fa7ed6365f12788d6603377cffc | https://github.com/adrianlee44/ical2json/blob/4f1e00f896d68fa7ed6365f12788d6603377cffc/index.js#L109-L156 | train |
rappid/rAppid.js | js/data/Entity.js | function () {
if (this.factory.schema) {
this.schema = this.factory.schema;
return;
}
var base = this.base;
while (base.factory.classof(Entity)) {
var baseSchema = base.schema;
... | javascript | function () {
if (this.factory.schema) {
this.schema = this.factory.schema;
return;
}
var base = this.base;
while (base.factory.classof(Entity)) {
var baseSchema = base.schema;
... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"factory",
".",
"schema",
")",
"{",
"this",
".",
"schema",
"=",
"this",
".",
"factory",
".",
"schema",
";",
"return",
";",
"}",
"var",
"base",
"=",
"this",
".",
"base",
";",
"while",
"(",
"base",... | Constructs the schema with the schema definition
@private | [
"Constructs",
"the",
"schema",
"with",
"the",
"schema",
"definition"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Entity.js#L278-L354 | train | |
rappid/rAppid.js | js/data/Entity.js | function (key, scope) {
var value = this.get(key, scope);
if (key && this.schema[key]) {
for (var i = 0; i < this.transformers.length; i++) {
value = this.transformers[i].transformValue(key, value, this.schema[key]);
}
... | javascript | function (key, scope) {
var value = this.get(key, scope);
if (key && this.schema[key]) {
for (var i = 0; i < this.transformers.length; i++) {
value = this.transformers[i].transformValue(key, value, this.schema[key]);
}
... | [
"function",
"(",
"key",
",",
"scope",
")",
"{",
"var",
"value",
"=",
"this",
".",
"get",
"(",
"key",
",",
"scope",
")",
";",
"if",
"(",
"key",
"&&",
"this",
".",
"schema",
"[",
"key",
"]",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i... | Returns the transformed value of a field
@param {String} key
@param {Object|js.core.Bindable} [scope]
@returns {*} | [
"Returns",
"the",
"transformed",
"value",
"of",
"a",
"field"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Entity.js#L390-L398 | train | |
rappid/rAppid.js | js/data/Entity.js | function (options) {
var ret = {};
for (var k in this.schema) {
if (this.schema.hasOwnProperty(k)) {
ret[k] = this.getTransformedValue(k);
}
}
this.set(ret, options);
} | javascript | function (options) {
var ret = {};
for (var k in this.schema) {
if (this.schema.hasOwnProperty(k)) {
ret[k] = this.getTransformedValue(k);
}
}
this.set(ret, options);
} | [
"function",
"(",
"options",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"k",
"in",
"this",
".",
"schema",
")",
"{",
"if",
"(",
"this",
".",
"schema",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"ret",
"[",
"k",
"]",
"="... | Transforms all values defined in the schema
@param {Object} [options] | [
"Transforms",
"all",
"values",
"defined",
"in",
"the",
"schema"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Entity.js#L414-L423 | train | |
rappid/rAppid.js | js/data/Entity.js | function (entity, options, callback) {
if (entity instanceof Entity) {
entity.validate(options, callback);
} else {
callback("parameter is not an entity");
}
} | javascript | function (entity, options, callback) {
if (entity instanceof Entity) {
entity.validate(options, callback);
} else {
callback("parameter is not an entity");
}
} | [
"function",
"(",
"entity",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"entity",
"instanceof",
"Entity",
")",
"{",
"entity",
".",
"validate",
"(",
"options",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"\"parameter is not an ent... | Validates a sub entity
@param {js.data.Entity} entity
@param {Object} options
@param {Function} callback | [
"Validates",
"a",
"sub",
"entity"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/data/Entity.js#L648-L654 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.form.js | function(keypath, content, attributes) {
var attrs = {'for': this._attributesForKeyPath(keypath).name};
return simple_element('label', $.extend(attrs, attributes), content);
} | javascript | function(keypath, content, attributes) {
var attrs = {'for': this._attributesForKeyPath(keypath).name};
return simple_element('label', $.extend(attrs, attributes), content);
} | [
"function",
"(",
"keypath",
",",
"content",
",",
"attributes",
")",
"{",
"var",
"attrs",
"=",
"{",
"'for'",
":",
"this",
".",
"_attributesForKeyPath",
"(",
"keypath",
")",
".",
"name",
"}",
";",
"return",
"simple_element",
"(",
"'label'",
",",
"$",
".",
... | creates a label for `keypath` with the text `content with an optional `attributes` object | [
"creates",
"a",
"label",
"for",
"keypath",
"with",
"the",
"text",
"content",
"with",
"an",
"optional",
"attributes",
"object"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.form.js#L87-L90 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.form.js | function(keypath, attributes) {
attributes = $.extend({type: 'hidden'}, this._attributesForKeyPath(keypath), attributes);
return simple_element('input', attributes);
} | javascript | function(keypath, attributes) {
attributes = $.extend({type: 'hidden'}, this._attributesForKeyPath(keypath), attributes);
return simple_element('input', attributes);
} | [
"function",
"(",
"keypath",
",",
"attributes",
")",
"{",
"attributes",
"=",
"$",
".",
"extend",
"(",
"{",
"type",
":",
"'hidden'",
"}",
",",
"this",
".",
"_attributesForKeyPath",
"(",
"keypath",
")",
",",
"attributes",
")",
";",
"return",
"simple_element",... | creates a hidden input for `keypath` with an optional `attributes` object | [
"creates",
"a",
"hidden",
"input",
"for",
"keypath",
"with",
"an",
"optional",
"attributes",
"object"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.form.js#L93-L96 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.form.js | function(keypath, attributes) {
var current;
attributes = $.extend(this._attributesForKeyPath(keypath), attributes);
current = attributes.value;
delete attributes['value'];
return simple_element('textarea', attributes, current);
} | javascript | function(keypath, attributes) {
var current;
attributes = $.extend(this._attributesForKeyPath(keypath), attributes);
current = attributes.value;
delete attributes['value'];
return simple_element('textarea', attributes, current);
} | [
"function",
"(",
"keypath",
",",
"attributes",
")",
"{",
"var",
"current",
";",
"attributes",
"=",
"$",
".",
"extend",
"(",
"this",
".",
"_attributesForKeyPath",
"(",
"keypath",
")",
",",
"attributes",
")",
";",
"current",
"=",
"attributes",
".",
"value",
... | creates a textarea for `keypath` with an optional `attributes` object | [
"creates",
"a",
"textarea",
"for",
"keypath",
"with",
"an",
"optional",
"attributes",
"object"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.form.js#L105-L111 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.form.js | function(keypath, value, attributes) {
var selected;
attributes = $.extend(this._attributesForKeyPath(keypath), attributes);
selected = attributes.value;
attributes.value = getStringContent(this.object, value);
if (selected == attributes.value) {
attributes.checked = 'checked';
... | javascript | function(keypath, value, attributes) {
var selected;
attributes = $.extend(this._attributesForKeyPath(keypath), attributes);
selected = attributes.value;
attributes.value = getStringContent(this.object, value);
if (selected == attributes.value) {
attributes.checked = 'checked';
... | [
"function",
"(",
"keypath",
",",
"value",
",",
"attributes",
")",
"{",
"var",
"selected",
";",
"attributes",
"=",
"$",
".",
"extend",
"(",
"this",
".",
"_attributesForKeyPath",
"(",
"keypath",
")",
",",
"attributes",
")",
";",
"selected",
"=",
"attributes"... | creates a radio input for keypath with the value `value`. Multiple radios can be created with different value, if `value` equals the current value of the key of the form builder's object the attribute checked='checked' will be added. | [
"creates",
"a",
"radio",
"input",
"for",
"keypath",
"with",
"the",
"value",
"value",
".",
"Multiple",
"radios",
"can",
"be",
"created",
"with",
"different",
"value",
"if",
"value",
"equals",
"the",
"current",
"value",
"of",
"the",
"key",
"of",
"the",
"form... | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.form.js#L158-L167 | train | |
rappid/rAppid.js | js/core/List.js | function (items, options) {
options = options || {};
_.defaults(options, {silent: false, index: this.$items.length});
var index = options.index;
if (!_.isArray(items)) {
items = [items];
}
var item, itemIndex;
for (v... | javascript | function (items, options) {
options = options || {};
_.defaults(options, {silent: false, index: this.$items.length});
var index = options.index;
if (!_.isArray(items)) {
items = [items];
}
var item, itemIndex;
for (v... | [
"function",
"(",
"items",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"_",
".",
"defaults",
"(",
"options",
",",
"{",
"silent",
":",
"false",
",",
"index",
":",
"this",
".",
"$items",
".",
"length",
"}",
")",
";",
"v... | This method adds one ore items to the array.
@param {Array|Object} items
@param {Object} options | [
"This",
"method",
"adds",
"one",
"ore",
"items",
"to",
"the",
"array",
"."
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L77-L105 | train | |
rappid/rAppid.js | js/core/List.js | function (items, options) {
var removed = [];
if (!_.isArray(items)) {
items = [items];
}
var item;
for (var i = 0; i < items.length; i++) {
item = this.removeAt(this.indexOf(items[i]), options);
item && removed... | javascript | function (items, options) {
var removed = [];
if (!_.isArray(items)) {
items = [items];
}
var item;
for (var i = 0; i < items.length; i++) {
item = this.removeAt(this.indexOf(items[i]), options);
item && removed... | [
"function",
"(",
"items",
",",
"options",
")",
"{",
"var",
"removed",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"items",
")",
")",
"{",
"items",
"=",
"[",
"items",
"]",
";",
"}",
"var",
"item",
";",
"for",
"(",
"var",
"i",... | Removes an Array or just one item from the list. Triggers remove events.
@param {Object|Array} items
@param {Object} options | [
"Removes",
"an",
"Array",
"or",
"just",
"one",
"item",
"from",
"the",
"list",
".",
"Triggers",
"remove",
"events",
"."
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L125-L137 | train | |
rappid/rAppid.js | js/core/List.js | function (index, options) {
options = options || {};
if (index > -1 && index < this.$items.length) {
var items = this.$items.splice(index, 1),
item = items[0];
if (options.silent !== true) {
this.trigger('remove', {item: i... | javascript | function (index, options) {
options = options || {};
if (index > -1 && index < this.$items.length) {
var items = this.$items.splice(index, 1),
item = items[0];
if (options.silent !== true) {
this.trigger('remove', {item: i... | [
"function",
"(",
"index",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"index",
">",
"-",
"1",
"&&",
"index",
"<",
"this",
".",
"$items",
".",
"length",
")",
"{",
"var",
"items",
"=",
"this",
".",
"$items",... | Removes one item a specific index and triggers remove event
@param {Number} index
@param {Object} options
@return {Object} removed item | [
"Removes",
"one",
"item",
"a",
"specific",
"index",
"and",
"triggers",
"remove",
"event"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L152-L169 | train | |
rappid/rAppid.js | js/core/List.js | function (items, options) {
items = items || [];
var self = this;
this.each(function (item) {
if (item instanceof EventDispatcher) {
item.unbind('*', self._onItemEvent, self);
item.unbind('change', self._onItemChange, self);
... | javascript | function (items, options) {
items = items || [];
var self = this;
this.each(function (item) {
if (item instanceof EventDispatcher) {
item.unbind('*', self._onItemEvent, self);
item.unbind('change', self._onItemChange, self);
... | [
"function",
"(",
"items",
",",
"options",
")",
"{",
"items",
"=",
"items",
"||",
"[",
"]",
";",
"var",
"self",
"=",
"this",
";",
"this",
".",
"each",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"item",
"instanceof",
"EventDispatcher",
")",
"... | Resets the list with the given items and triggers reset event
@param {Array} items
@param {Object} options | [
"Resets",
"the",
"list",
"with",
"the",
"given",
"items",
"and",
"triggers",
"reset",
"event"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L175-L198 | train | |
rappid/rAppid.js | js/core/List.js | function (fnc, scope) {
scope = scope || this;
for (var i = 0; i < this.$items.length; i++) {
fnc.call(scope, this.$items[i], i, this.$items);
}
} | javascript | function (fnc, scope) {
scope = scope || this;
for (var i = 0; i < this.$items.length; i++) {
fnc.call(scope, this.$items[i], i, this.$items);
}
} | [
"function",
"(",
"fnc",
",",
"scope",
")",
"{",
"scope",
"=",
"scope",
"||",
"this",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$items",
".",
"length",
";",
"i",
"++",
")",
"{",
"fnc",
".",
"call",
"(",
"scope",
",",
... | Iterates over all items with given callback
@param {Function} fnc callback with signature function(item, index)
@param {Object} scope The call scope of the callback | [
"Iterates",
"over",
"all",
"items",
"with",
"given",
"callback"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L230-L236 | train | |
rappid/rAppid.js | js/core/List.js | function (fnc, scope) {
scope = scope || this;
var b = false,
items = this.$items,
length = items.length;
for (var i = 0; i < length; i++) {
b = fnc.call(scope, items[i], i, this.$items);
if (b === true) {
... | javascript | function (fnc, scope) {
scope = scope || this;
var b = false,
items = this.$items,
length = items.length;
for (var i = 0; i < length; i++) {
b = fnc.call(scope, items[i], i, this.$items);
if (b === true) {
... | [
"function",
"(",
"fnc",
",",
"scope",
")",
"{",
"scope",
"=",
"scope",
"||",
"this",
";",
"var",
"b",
"=",
"false",
",",
"items",
"=",
"this",
".",
"$items",
",",
"length",
"=",
"items",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";"... | Iterates over all items with the function.
Returns the element when the function returns true.
@param {Function} fnc Function to execute on each value in the list
@param {Object} scope The this object
@returns {*} | [
"Iterates",
"over",
"all",
"items",
"with",
"the",
"function",
".",
"Returns",
"the",
"element",
"when",
"the",
"function",
"returns",
"true",
"."
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L245-L259 | train | |
rappid/rAppid.js | js/core/List.js | function () {
var attributes = this._cloneAttribute(this.$);
var items = this._cloneAttribute(this.$items);
var ret = new this.factory(items, attributes);
ret._$source = this;
return ret;
} | javascript | function () {
var attributes = this._cloneAttribute(this.$);
var items = this._cloneAttribute(this.$items);
var ret = new this.factory(items, attributes);
ret._$source = this;
return ret;
} | [
"function",
"(",
")",
"{",
"var",
"attributes",
"=",
"this",
".",
"_cloneAttribute",
"(",
"this",
".",
"$",
")",
";",
"var",
"items",
"=",
"this",
".",
"_cloneAttribute",
"(",
"this",
".",
"$items",
")",
";",
"var",
"ret",
"=",
"new",
"this",
".",
... | Returns a fresh copy of the List
@return {List} a fresh copy of the list | [
"Returns",
"a",
"fresh",
"copy",
"of",
"the",
"List"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L277-L283 | train | |
rappid/rAppid.js | js/core/List.js | function () {
if (this._$source) {
var item, items = [];
for (var i = 0; i < this.$items.length; i++) {
item = this.$items[i];
if (item instanceof Bindable && item.sync()) {
item = item._$source;
... | javascript | function () {
if (this._$source) {
var item, items = [];
for (var i = 0; i < this.$items.length; i++) {
item = this.$items[i];
if (item instanceof Bindable && item.sync()) {
item = item._$source;
... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_$source",
")",
"{",
"var",
"item",
",",
"items",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$items",
".",
"length",
";",
"i",
"++",
")",
"{",
"item... | Syncs the items back to the source
@return {*} | [
"Syncs",
"the",
"items",
"back",
"to",
"the",
"source"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L288-L301 | train | |
rappid/rAppid.js | js/core/List.js | function (list) {
if (list.size() !== this.size()) {
return false;
}
var isEqual = true,
a, b;
for (var i = 0; i < this.$items.length; i++) {
a = this.$items[i];
b = list.at(i);
if (a instance... | javascript | function (list) {
if (list.size() !== this.size()) {
return false;
}
var isEqual = true,
a, b;
for (var i = 0; i < this.$items.length; i++) {
a = this.$items[i];
b = list.at(i);
if (a instance... | [
"function",
"(",
"list",
")",
"{",
"if",
"(",
"list",
".",
"size",
"(",
")",
"!==",
"this",
".",
"size",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"isEqual",
"=",
"true",
",",
"a",
",",
"b",
";",
"for",
"(",
"var",
"i",
"=",
"... | Checks if items are deep equal
@param {js.core.List} list
@return {boolean} | [
"Checks",
"if",
"items",
"are",
"deep",
"equal"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/List.js#L375-L396 | train | |
rappid/rAppid.js | js/core/ModuleLoader.js | function (moduleName, moduleInstance, callback, routeContext, cachedInstance) {
var self = this;
//noinspection JSValidateTypes
flow()
.seq(function (cb) {
self.$moduleInstance = moduleInstance;
var c... | javascript | function (moduleName, moduleInstance, callback, routeContext, cachedInstance) {
var self = this;
//noinspection JSValidateTypes
flow()
.seq(function (cb) {
self.$moduleInstance = moduleInstance;
var c... | [
"function",
"(",
"moduleName",
",",
"moduleInstance",
",",
"callback",
",",
"routeContext",
",",
"cachedInstance",
")",
"{",
"var",
"self",
"=",
"this",
";",
"//noinspection JSValidateTypes",
"flow",
"(",
")",
".",
"seq",
"(",
"function",
"(",
"cb",
")",
"{"... | Starts the module with the given name
@param {String} moduleName - The name of the module
@param {js.core.Module} moduleInstance - the module instance
@param {Function} callback - the callback function
@param {Object} routeContext - the route context
@param {Object} [cachedInstance]
@private | [
"Starts",
"the",
"module",
"with",
"the",
"given",
"name"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/ModuleLoader.js#L112-L193 | train | |
rappid/rAppid.js | js/core/TooltipManager.js | function (templateName, target, attributes, options) {
if (!this.$container) {
this.$container = this.createComponent(HtmlElement, {"class": this.$.containerClass, "tagName": "div"});
this.$stage.addChild(this.$container);
}
var tooltip = this.getToolt... | javascript | function (templateName, target, attributes, options) {
if (!this.$container) {
this.$container = this.createComponent(HtmlElement, {"class": this.$.containerClass, "tagName": "div"});
this.$stage.addChild(this.$container);
}
var tooltip = this.getToolt... | [
"function",
"(",
"templateName",
",",
"target",
",",
"attributes",
",",
"options",
")",
"{",
"if",
"(",
"!",
"this",
".",
"$container",
")",
"{",
"this",
".",
"$container",
"=",
"this",
".",
"createComponent",
"(",
"HtmlElement",
",",
"{",
"\"class\"",
"... | Shows a tooltip with the given template add the target element
@param {String} templateName - The name of the template to use
@param {js.core.Component} target - The target element
@param {Object} attributes - the
@param {Object} options - Options for displaying the
@param {Number} options.duration - default is false... | [
"Shows",
"a",
"tooltip",
"with",
"the",
"given",
"template",
"add",
"the",
"target",
"element"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/TooltipManager.js#L49-L122 | train | |
rappid/rAppid.js | js/core/TooltipManager.js | function (tooltip, target) {
if (!(tooltip instanceof Tooltip)) {
tooltip = this.getTooltipByNameAndTarget(tooltip, target);
}
if (tooltip) {
var i = this.$tooltips.indexOf(tooltip);
this.$tooltips.splice(i, 1);
this.$co... | javascript | function (tooltip, target) {
if (!(tooltip instanceof Tooltip)) {
tooltip = this.getTooltipByNameAndTarget(tooltip, target);
}
if (tooltip) {
var i = this.$tooltips.indexOf(tooltip);
this.$tooltips.splice(i, 1);
this.$co... | [
"function",
"(",
"tooltip",
",",
"target",
")",
"{",
"if",
"(",
"!",
"(",
"tooltip",
"instanceof",
"Tooltip",
")",
")",
"{",
"tooltip",
"=",
"this",
".",
"getTooltipByNameAndTarget",
"(",
"tooltip",
",",
"target",
")",
";",
"}",
"if",
"(",
"tooltip",
"... | Closes a tooltip by name and target element or tooltip Instance
@param {js.core.TooltipManager.Tooltip|String} tooltip - The tooltip instance or the templateName
@param {js.core.Component} [target] - The target element of the tooltip | [
"Closes",
"a",
"tooltip",
"by",
"name",
"and",
"target",
"element",
"or",
"tooltip",
"Instance"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/TooltipManager.js#L131-L140 | train | |
rappid/rAppid.js | js/core/TooltipManager.js | function (templateName, target) {
var tooltip;
for (var i = 0; i < this.$tooltips.length; i++) {
tooltip = this.$tooltips[i];
if (tooltip.templateName === templateName && tooltip.target === target) {
return tooltip.instance;
}
... | javascript | function (templateName, target) {
var tooltip;
for (var i = 0; i < this.$tooltips.length; i++) {
tooltip = this.$tooltips[i];
if (tooltip.templateName === templateName && tooltip.target === target) {
return tooltip.instance;
}
... | [
"function",
"(",
"templateName",
",",
"target",
")",
"{",
"var",
"tooltip",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"$tooltips",
".",
"length",
";",
"i",
"++",
")",
"{",
"tooltip",
"=",
"this",
".",
"$tooltips",
"[",
"i... | Returns a tooltip instance by name and target element
@param {String} templateName
@param {js.core.Component} target
@returns {js.core.TooltipManager.Tooltip} | [
"Returns",
"a",
"tooltip",
"instance",
"by",
"name",
"and",
"target",
"element"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/TooltipManager.js#L149-L158 | train | |
rappid/rAppid.js | js/lib/rAppid.js | function (xhr) {
this.xhr = xhr;
this.status = xhr.status;
this.$nativeResponseHeaders = xhr.getAllResponseHeaders();
this.responses = {};
var xml = xhr.responseXML;
// Construct response list
if (xml && xml.documentElement) {
this.responses.xml = xm... | javascript | function (xhr) {
this.xhr = xhr;
this.status = xhr.status;
this.$nativeResponseHeaders = xhr.getAllResponseHeaders();
this.responses = {};
var xml = xhr.responseXML;
// Construct response list
if (xml && xml.documentElement) {
this.responses.xml = xm... | [
"function",
"(",
"xhr",
")",
"{",
"this",
".",
"xhr",
"=",
"xhr",
";",
"this",
".",
"status",
"=",
"xhr",
".",
"status",
";",
"this",
".",
"$nativeResponseHeaders",
"=",
"xhr",
".",
"getAllResponseHeaders",
"(",
")",
";",
"this",
".",
"responses",
"=",... | IE leaves an \r character at EOL | [
"IE",
"leaves",
"an",
"\\",
"r",
"character",
"at",
"EOL"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/lib/rAppid.js#L398-L417 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.haml.js | parse_attribs | function parse_attribs(line) {
var attributes = {},
l = line.length,
i, c,
count = 1,
quote = false,
skip = false,
open, close, joiner, seperator,
pair = {
start: 1,
middle: null,
end: null
};
if (!(l > 0 && (line.cha... | javascript | function parse_attribs(line) {
var attributes = {},
l = line.length,
i, c,
count = 1,
quote = false,
skip = false,
open, close, joiner, seperator,
pair = {
start: 1,
middle: null,
end: null
};
if (!(l > 0 && (line.cha... | [
"function",
"parse_attribs",
"(",
"line",
")",
"{",
"var",
"attributes",
"=",
"{",
"}",
",",
"l",
"=",
"line",
".",
"length",
",",
"i",
",",
"c",
",",
"count",
"=",
"1",
",",
"quote",
"=",
"false",
",",
"skip",
"=",
"false",
",",
"open",
",",
"... | Parse the attribute block using a state machine | [
"Parse",
"the",
"attribute",
"block",
"using",
"a",
"state",
"machine"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.haml.js#L50-L136 | train |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.haml.js | parse_interpol | function parse_interpol(value) {
var items = [],
pos = 0,
next = 0,
match;
while (true) {
// Match up to embedded string
next = value.substr(pos).search(embedder);
if (next < 0) {
if (pos < value.length) {
items.push(JSON.stringify(value.substr(pos)));... | javascript | function parse_interpol(value) {
var items = [],
pos = 0,
next = 0,
match;
while (true) {
// Match up to embedded string
next = value.substr(pos).search(embedder);
if (next < 0) {
if (pos < value.length) {
items.push(JSON.stringify(value.substr(pos)));... | [
"function",
"parse_interpol",
"(",
"value",
")",
"{",
"var",
"items",
"=",
"[",
"]",
",",
"pos",
"=",
"0",
",",
"next",
"=",
"0",
",",
"match",
";",
"while",
"(",
"true",
")",
"{",
"// Match up to embedded string",
"next",
"=",
"value",
".",
"substr",
... | Split interpolated strings into an array of literals and code fragments. | [
"Split",
"interpolated",
"strings",
"into",
"an",
"array",
"of",
"literals",
"and",
"code",
"fragments",
"."
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.haml.js#L139-L164 | train |
mikeal/node.couchapp.js | main.js | loadFiles | function loadFiles(dir, options) {
var listings = fs.readdirSync(dir)
, options = options || {}
, obj = {};
listings.forEach(function (listing) {
var file = path.join(dir, listing)
, prop = listing.split('.')[0] // probably want regexp or something more robust
, stat = fs.statSync(file);
... | javascript | function loadFiles(dir, options) {
var listings = fs.readdirSync(dir)
, options = options || {}
, obj = {};
listings.forEach(function (listing) {
var file = path.join(dir, listing)
, prop = listing.split('.')[0] // probably want regexp or something more robust
, stat = fs.statSync(file);
... | [
"function",
"loadFiles",
"(",
"dir",
",",
"options",
")",
"{",
"var",
"listings",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
",",
"options",
"=",
"options",
"||",
"{",
"}",
",",
"obj",
"=",
"{",
"}",
";",
"listings",
".",
"forEach",
"(",
"func... | Recursively load directory contents into ddoc
It's really convenient to see the main couchapp code in single file,
rather than mapped into little files in lots of directories like
the python couchapp. But there are definitely cases where we might want
to use some module or another on the server side. This addition
loa... | [
"Recursively",
"load",
"directory",
"contents",
"into",
"ddoc"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/main.js#L83-L107 | train |
nuzzio/grunt-strip-code | tasks/strip_code.js | function () {
if (arguments.length === 0) {
grunt.warn(strings[options.locale]['translate.param.missing']);
}
var key = arguments[0];
if (!(key in strings[options.locale])) {
grunt.warn(strings[options.locale]['string.key.missing'] + ': ... | javascript | function () {
if (arguments.length === 0) {
grunt.warn(strings[options.locale]['translate.param.missing']);
}
var key = arguments[0];
if (!(key in strings[options.locale])) {
grunt.warn(strings[options.locale]['string.key.missing'] + ': ... | [
"function",
"(",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"grunt",
".",
"warn",
"(",
"strings",
"[",
"options",
".",
"locale",
"]",
"[",
"'translate.param.missing'",
"]",
")",
";",
"}",
"var",
"key",
"=",
"arguments",
"[... | Takes in dynamic parameters and expects first param to be a key for a string,
subsequent params will substitute the variables in the string
in the order they are declared.
For the string: "my.key": "I will do my %1 then my %2"
translate('my.key', 'first replacement', 'second replacement')
the first replacement argumen... | [
"Takes",
"in",
"dynamic",
"parameters",
"and",
"expects",
"first",
"param",
"to",
"be",
"a",
"key",
"for",
"a",
"string",
"subsequent",
"params",
"will",
"substitute",
"the",
"variables",
"in",
"the",
"string",
"in",
"the",
"order",
"they",
"are",
"declared"... | 4a84e8bb823b740839df5a6a37d528178f4df906 | https://github.com/nuzzio/grunt-strip-code/blob/4a84e8bb823b740839df5a6a37d528178f4df906/tasks/strip_code.js#L83-L103 | train | |
nuzzio/grunt-strip-code | tasks/strip_code.js | function (params) {
var message = translate(errors[params.caseNum])
.replace('%n', (params.lineNum + 1).toString())
.replace('%p', params.pattern)
.replace('%x', params.start)
.replace('%y', (params.endLineNum + 1).toString())
... | javascript | function (params) {
var message = translate(errors[params.caseNum])
.replace('%n', (params.lineNum + 1).toString())
.replace('%p', params.pattern)
.replace('%x', params.start)
.replace('%y', (params.endLineNum + 1).toString())
... | [
"function",
"(",
"params",
")",
"{",
"var",
"message",
"=",
"translate",
"(",
"errors",
"[",
"params",
".",
"caseNum",
"]",
")",
".",
"replace",
"(",
"'%n'",
",",
"(",
"params",
".",
"lineNum",
"+",
"1",
")",
".",
"toString",
"(",
")",
")",
".",
... | Generates error messages for block and pattern errors then quits. | [
"Generates",
"error",
"messages",
"for",
"block",
"and",
"pattern",
"errors",
"then",
"quits",
"."
] | 4a84e8bb823b740839df5a6a37d528178f4df906 | https://github.com/nuzzio/grunt-strip-code/blob/4a84e8bb823b740839df5a6a37d528178f4df906/tasks/strip_code.js#L205-L218 | train | |
nuzzio/grunt-strip-code | tasks/strip_code.js | function (line, lineNum) {
if (line.trim() === '') {
return;
}
function logAnyDelimiterType(line) {
blocks.forEach(function (blockDef, blockIdx) {
if (blockDef.start.test(line) === true) {
fileStartDelimite... | javascript | function (line, lineNum) {
if (line.trim() === '') {
return;
}
function logAnyDelimiterType(line) {
blocks.forEach(function (blockDef, blockIdx) {
if (blockDef.start.test(line) === true) {
fileStartDelimite... | [
"function",
"(",
"line",
",",
"lineNum",
")",
"{",
"if",
"(",
"line",
".",
"trim",
"(",
")",
"===",
"''",
")",
"{",
"return",
";",
"}",
"function",
"logAnyDelimiterType",
"(",
"line",
")",
"{",
"blocks",
".",
"forEach",
"(",
"function",
"(",
"blockDe... | Checks each line of the file.
Sub-functions check intersection and parity.
@param line
@param lineNum | [
"Checks",
"each",
"line",
"of",
"the",
"file",
".",
"Sub",
"-",
"functions",
"check",
"intersection",
"and",
"parity",
"."
] | 4a84e8bb823b740839df5a6a37d528178f4df906 | https://github.com/nuzzio/grunt-strip-code/blob/4a84e8bb823b740839df5a6a37d528178f4df906/tasks/strip_code.js#L227-L340 | train | |
uber/potter | cli/builtin/plugin.js | function(cb) {
fs.exists(potterHome, function(exists) {
if(exists) {
cb(null);
} else {
mkdirp(potterHome, cb);
}
});
} | javascript | function(cb) {
fs.exists(potterHome, function(exists) {
if(exists) {
cb(null);
} else {
mkdirp(potterHome, cb);
}
});
} | [
"function",
"(",
"cb",
")",
"{",
"fs",
".",
"exists",
"(",
"potterHome",
",",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"exists",
")",
"{",
"cb",
"(",
"null",
")",
";",
"}",
"else",
"{",
"mkdirp",
"(",
"potterHome",
",",
"cb",
")",
";",
"... | make sure the potter folder exists | [
"make",
"sure",
"the",
"potter",
"folder",
"exists"
] | ada4ebbb5955996be8eb2cfb4beeac01e3409aea | https://github.com/uber/potter/blob/ada4ebbb5955996be8eb2cfb4beeac01e3409aea/cli/builtin/plugin.js#L65-L73 | train | |
uber/potter | cli/builtin/plugin.js | function(cb) {
fs.exists(path.join(potterHome, 'package.json'), function(exists) {
if(exists) {
cb(null);
} else {
var packagejson = '{"dependencies":{}}';
fs.writeFile(path.join(potterHome, 'package.json'), packagej... | javascript | function(cb) {
fs.exists(path.join(potterHome, 'package.json'), function(exists) {
if(exists) {
cb(null);
} else {
var packagejson = '{"dependencies":{}}';
fs.writeFile(path.join(potterHome, 'package.json'), packagej... | [
"function",
"(",
"cb",
")",
"{",
"fs",
".",
"exists",
"(",
"path",
".",
"join",
"(",
"potterHome",
",",
"'package.json'",
")",
",",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"exists",
")",
"{",
"cb",
"(",
"null",
")",
";",
"}",
"else",
"{",... | make sure a package.json exists | [
"make",
"sure",
"a",
"package",
".",
"json",
"exists"
] | ada4ebbb5955996be8eb2cfb4beeac01e3409aea | https://github.com/uber/potter/blob/ada4ebbb5955996be8eb2cfb4beeac01e3409aea/cli/builtin/plugin.js#L75-L84 | train | |
steve-gray/swagger-codegen | src/definition-mapper.js | mapDefinitionsFromModel | function mapDefinitionsFromModel(model) {
const definitionMap = [];
/* istanbul ignore else */
if (model && model.definitions) {
debug('Parsing %s definitions', Object.keys(model.definitions).length);
for (const definitionName of Object.keys(model.definitions)) {
debug(' Reading definition for %s'... | javascript | function mapDefinitionsFromModel(model) {
const definitionMap = [];
/* istanbul ignore else */
if (model && model.definitions) {
debug('Parsing %s definitions', Object.keys(model.definitions).length);
for (const definitionName of Object.keys(model.definitions)) {
debug(' Reading definition for %s'... | [
"function",
"mapDefinitionsFromModel",
"(",
"model",
")",
"{",
"const",
"definitionMap",
"=",
"[",
"]",
";",
"/* istanbul ignore else */",
"if",
"(",
"model",
"&&",
"model",
".",
"definitions",
")",
"{",
"debug",
"(",
"'Parsing %s definitions'",
",",
"Object",
"... | Map the definitions from a Swagger model
@param {object} model - Swagger model
@return - Map of definition name to definition body | [
"Map",
"the",
"definitions",
"from",
"a",
"Swagger",
"model"
] | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/definition-mapper.js#L11-L28 | train |
waterlock/waterlock-local-auth | lib/controllers/actions/reset.js | handleGet | function handleGet(req, res, sails, params){
validateToken(req, res, sails, params);
} | javascript | function handleGet(req, res, sails, params){
validateToken(req, res, sails, params);
} | [
"function",
"handleGet",
"(",
"req",
",",
"res",
",",
"sails",
",",
"params",
")",
"{",
"validateToken",
"(",
"req",
",",
"res",
",",
"sails",
",",
"params",
")",
";",
"}"
] | Handles the GET method for this request
@param object req the express request object
@param object res the express response object
@param waterlineDAO User the waterline User dao
@param waterlineDAO ResetToken the waterline ResetToken dao
@param object params all params for this request | [
"Handles",
"the",
"GET",
"method",
"for",
"this",
"request"
] | 5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f | https://github.com/waterlock/waterlock-local-auth/blob/5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f/lib/controllers/actions/reset.js#L50-L52 | train |
waterlock/waterlock-local-auth | lib/controllers/actions/reset.js | handlePost | function handlePost(req, res, sails, params){
var func;
if(!_.isUndefined(params.email)){
func = sendEmail;
}else if(!_.isUndefined(req.session.resetToken) &&
req.session.resetToken &&
!_.isUndefined(params.password)){
func = issuePasswordReset;
}
if(!_.isUndefined(func)){
func(req, res... | javascript | function handlePost(req, res, sails, params){
var func;
if(!_.isUndefined(params.email)){
func = sendEmail;
}else if(!_.isUndefined(req.session.resetToken) &&
req.session.resetToken &&
!_.isUndefined(params.password)){
func = issuePasswordReset;
}
if(!_.isUndefined(func)){
func(req, res... | [
"function",
"handlePost",
"(",
"req",
",",
"res",
",",
"sails",
",",
"params",
")",
"{",
"var",
"func",
";",
"if",
"(",
"!",
"_",
".",
"isUndefined",
"(",
"params",
".",
"email",
")",
")",
"{",
"func",
"=",
"sendEmail",
";",
"}",
"else",
"if",
"(... | Handles the POST method for this request
@param object req the express request object
@param object res the express response object
@param waterlineDAO User the waterline User dao
@param waterlineDAO ResetToken the waterline ResetToken dao
@param object params all params for this request | [
"Handles",
"the",
"POST",
"method",
"for",
"this",
"request"
] | 5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f | https://github.com/waterlock/waterlock-local-auth/blob/5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f/lib/controllers/actions/reset.js#L62-L79 | train |
waterlock/waterlock-local-auth | lib/controllers/actions/reset.js | sendEmail | function sendEmail(req, res, sails, params){
sails.models.auth.findOne({email: params.email}).populate('user').exec(function(err, a){
if(a){
sails.models.resettoken.create({owner: a.id}).exec(function(err, t){
if(err){
return res.serverError(err);
}
sails.models.auth.update... | javascript | function sendEmail(req, res, sails, params){
sails.models.auth.findOne({email: params.email}).populate('user').exec(function(err, a){
if(a){
sails.models.resettoken.create({owner: a.id}).exec(function(err, t){
if(err){
return res.serverError(err);
}
sails.models.auth.update... | [
"function",
"sendEmail",
"(",
"req",
",",
"res",
",",
"sails",
",",
"params",
")",
"{",
"sails",
".",
"models",
".",
"auth",
".",
"findOne",
"(",
"{",
"email",
":",
"params",
".",
"email",
"}",
")",
".",
"populate",
"(",
"'user'",
")",
".",
"exec",... | Begins the reset process by creating a new reset token
and sending an email to the user
@param object req the express request object
@param object res the express response object
@param waterlineDAO User the waterline User dao
@param waterlineDAO ResetToken the waterline ResetToken dao
@param object params all pa... | [
"Begins",
"the",
"reset",
"process",
"by",
"creating",
"a",
"new",
"reset",
"token",
"and",
"sending",
"an",
"email",
"to",
"the",
"user"
] | 5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f | https://github.com/waterlock/waterlock-local-auth/blob/5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f/lib/controllers/actions/reset.js#L90-L108 | train |
waterlock/waterlock-local-auth | lib/controllers/actions/reset.js | validateToken | function validateToken(req, res, sails, params){
var config = wl.config;
var authConfig = wl.authConfig;
if(params.token){
try{
// decode the token
var _token = jwt.decode(params.token, config.jsonWebTokens.secret);
// set the time of the request
var _reqTime = Date.now();
// I... | javascript | function validateToken(req, res, sails, params){
var config = wl.config;
var authConfig = wl.authConfig;
if(params.token){
try{
// decode the token
var _token = jwt.decode(params.token, config.jsonWebTokens.secret);
// set the time of the request
var _reqTime = Date.now();
// I... | [
"function",
"validateToken",
"(",
"req",
",",
"res",
",",
"sails",
",",
"params",
")",
"{",
"var",
"config",
"=",
"wl",
".",
"config",
";",
"var",
"authConfig",
"=",
"wl",
".",
"authConfig",
";",
"if",
"(",
"params",
".",
"token",
")",
"{",
"try",
... | validates a users token and redirects them to the new url if provided
@param object req the express request object
@param object res the express response object
@param waterlineDAO User the waterline User dao
@param waterlineDAO ResetToken the waterline ResetToken dao
@param object params all params for this requ... | [
"validates",
"a",
"users",
"token",
"and",
"redirects",
"them",
"to",
"the",
"new",
"url",
"if",
"provided"
] | 5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f | https://github.com/waterlock/waterlock-local-auth/blob/5ac2f153e41cefaf91d5f90ffc86b50dab2dde0f/lib/controllers/actions/reset.js#L152-L206 | train |
knpwrs/babel-plugin-remove-webpack | src/index.js | isMemberCall | function isMemberCall({ callee }, obj, prop) {
return callee.type === 'MemberExpression'
&& callee.object.name === obj
&& callee.property.name === prop;
} | javascript | function isMemberCall({ callee }, obj, prop) {
return callee.type === 'MemberExpression'
&& callee.object.name === obj
&& callee.property.name === prop;
} | [
"function",
"isMemberCall",
"(",
"{",
"callee",
"}",
",",
"obj",
",",
"prop",
")",
"{",
"return",
"callee",
".",
"type",
"===",
"'MemberExpression'",
"&&",
"callee",
".",
"object",
".",
"name",
"===",
"obj",
"&&",
"callee",
".",
"property",
".",
"name",
... | Determines if a given node represents a call to prop on object.
@param {Object} node The ast node.
@param {string} obj The object identity.
@param {string} prop The property identity.
@return {Boolean} `true` if node represents `obj[prop]()`. `false` otherwise. | [
"Determines",
"if",
"a",
"given",
"node",
"represents",
"a",
"call",
"to",
"prop",
"on",
"object",
"."
] | dc239cf44d9f857eafc46ead9446205aede32409 | https://github.com/knpwrs/babel-plugin-remove-webpack/blob/dc239cf44d9f857eafc46ead9446205aede32409/src/index.js#L8-L12 | train |
AmpersandJS/ampersand-collection | ampersand-collection.js | function () {
var list = slice.call(this.indexes || []);
var i = 0;
list.push(this.mainIndex);
list.push('cid');
var l = list.length;
this.models = [];
this._indexes = {};
for (; i < l; i++) {
this._indexes[list[i]] = {};
}
} | javascript | function () {
var list = slice.call(this.indexes || []);
var i = 0;
list.push(this.mainIndex);
list.push('cid');
var l = list.length;
this.models = [];
this._indexes = {};
for (; i < l; i++) {
this._indexes[list[i]] = {};
}
} | [
"function",
"(",
")",
"{",
"var",
"list",
"=",
"slice",
".",
"call",
"(",
"this",
".",
"indexes",
"||",
"[",
"]",
")",
";",
"var",
"i",
"=",
"0",
";",
"list",
".",
"push",
"(",
"this",
".",
"mainIndex",
")",
";",
"list",
".",
"push",
"(",
"'c... | Private method to reset all internal state. Called when the collection is first initialized or reset. | [
"Private",
"method",
"to",
"reset",
"all",
"internal",
"state",
".",
"Called",
"when",
"the",
"collection",
"is",
"first",
"initialized",
"or",
"reset",
"."
] | 6cf9b8e7077363af6618c51133b46bb8996caa44 | https://github.com/AmpersandJS/ampersand-collection/blob/6cf9b8e7077363af6618c51133b46bb8996caa44/ampersand-collection.js#L269-L280 | train | |
steve-gray/swagger-codegen | src/handlebars-engine.js | handlebarsEngine | function handlebarsEngine(taskOptions) {
debug('Initializing new instance of hbs');
const handlebars = hbs.create();
/* istanbul ignore else */
if (taskOptions.helpers) {
for (const helper of Object.keys(taskOptions.helpers)) {
debug(' Registering helper: %s', helper);
handlebars.registerHelpe... | javascript | function handlebarsEngine(taskOptions) {
debug('Initializing new instance of hbs');
const handlebars = hbs.create();
/* istanbul ignore else */
if (taskOptions.helpers) {
for (const helper of Object.keys(taskOptions.helpers)) {
debug(' Registering helper: %s', helper);
handlebars.registerHelpe... | [
"function",
"handlebarsEngine",
"(",
"taskOptions",
")",
"{",
"debug",
"(",
"'Initializing new instance of hbs'",
")",
";",
"const",
"handlebars",
"=",
"hbs",
".",
"create",
"(",
")",
";",
"/* istanbul ignore else */",
"if",
"(",
"taskOptions",
".",
"helpers",
")"... | The handlebarsEngine loads a new instance of handlebars and applies
the task-specific helper functions | [
"The",
"handlebarsEngine",
"loads",
"a",
"new",
"instance",
"of",
"handlebars",
"and",
"applies",
"the",
"task",
"-",
"specific",
"helper",
"functions"
] | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/handlebars-engine.js#L10-L23 | train |
steve-gray/swagger-codegen | src/handlebars-helpers.js | arrayContainsItem | function arrayContainsItem(array, value, options) {
if (array && _.indexOf(array, value) >= 0) {
return options.fn(this);
}
return options.inverse(this);
} | javascript | function arrayContainsItem(array, value, options) {
if (array && _.indexOf(array, value) >= 0) {
return options.fn(this);
}
return options.inverse(this);
} | [
"function",
"arrayContainsItem",
"(",
"array",
",",
"value",
",",
"options",
")",
"{",
"if",
"(",
"array",
"&&",
"_",
".",
"indexOf",
"(",
"array",
",",
"value",
")",
">=",
"0",
")",
"{",
"return",
"options",
".",
"fn",
"(",
"this",
")",
";",
"}",
... | Does an array contain a value?
@param {object} array - Array to scan
@param {object} value - Value to find
@param {object} options - Handlebars options.
@returns {string} - Result | [
"Does",
"an",
"array",
"contain",
"a",
"value?"
] | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/handlebars-helpers.js#L14-L20 | train |
steve-gray/swagger-codegen | src/handlebars-helpers.js | compareValues | function compareValues(lvalue, operator, rvalue, options) {
const operators = {
'==': function compareEqual(l, r) { return l === r; },
'===': function compareIdentical(l, r) { return l === r; },
'!=': function compareNotEqual(l, r) { return l !== r; },
'<': function compareLessThan(l, r) { return l < ... | javascript | function compareValues(lvalue, operator, rvalue, options) {
const operators = {
'==': function compareEqual(l, r) { return l === r; },
'===': function compareIdentical(l, r) { return l === r; },
'!=': function compareNotEqual(l, r) { return l !== r; },
'<': function compareLessThan(l, r) { return l < ... | [
"function",
"compareValues",
"(",
"lvalue",
",",
"operator",
",",
"rvalue",
",",
"options",
")",
"{",
"const",
"operators",
"=",
"{",
"'=='",
":",
"function",
"compareEqual",
"(",
"l",
",",
"r",
")",
"{",
"return",
"l",
"===",
"r",
";",
"}",
",",
"'=... | Compare two values with a predicate to determine some
equivelence relation.
@remarks Supported operators are ==, ===, !=, <, >, <= and >=
@param {object} lvalue - Left operand
@param {object} operator - Comparison operators
@param {object} rvalue - Right operand
@param {object} op... | [
"Compare",
"two",
"values",
"with",
"a",
"predicate",
"to",
"determine",
"some",
"equivelence",
"relation",
"."
] | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/handlebars-helpers.js#L32-L54 | train |
steve-gray/swagger-codegen | src/handlebars-helpers.js | lowercaseFirstLetter | function lowercaseFirstLetter(options) {
const string = options.fn(this);
return string.charAt(0).toLowerCase() + string.slice(1);
} | javascript | function lowercaseFirstLetter(options) {
const string = options.fn(this);
return string.charAt(0).toLowerCase() + string.slice(1);
} | [
"function",
"lowercaseFirstLetter",
"(",
"options",
")",
"{",
"const",
"string",
"=",
"options",
".",
"fn",
"(",
"this",
")",
";",
"return",
"string",
".",
"charAt",
"(",
"0",
")",
".",
"toLowerCase",
"(",
")",
"+",
"string",
".",
"slice",
"(",
"1",
... | Drop-case the first letter of a string
@param {object} options - Handlebars options.
@returns {string} - Original string with lowercased first letter. | [
"Drop",
"-",
"case",
"the",
"first",
"letter",
"of",
"a",
"string"
] | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/handlebars-helpers.js#L61-L64 | train |
steve-gray/swagger-codegen | src/handlebars-helpers.js | capSplitAndJoin | function capSplitAndJoin(joiner, options) {
const string = options.fn(this);
const members = string.split(/(?=[A-Z])/);
return members.join(joiner);
} | javascript | function capSplitAndJoin(joiner, options) {
const string = options.fn(this);
const members = string.split(/(?=[A-Z])/);
return members.join(joiner);
} | [
"function",
"capSplitAndJoin",
"(",
"joiner",
",",
"options",
")",
"{",
"const",
"string",
"=",
"options",
".",
"fn",
"(",
"this",
")",
";",
"const",
"members",
"=",
"string",
".",
"split",
"(",
"/",
"(?=[A-Z])",
"/",
")",
";",
"return",
"members",
"."... | Split a string by capital letters and then re-join by another.
@param {string} joiner - String to join with
@param {object} options - Handlebars options.
@return {string} - Handlebars result | [
"Split",
"a",
"string",
"by",
"capital",
"letters",
"and",
"then",
"re",
"-",
"join",
"by",
"another",
"."
] | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/handlebars-helpers.js#L81-L85 | train |
steve-gray/swagger-codegen | src/handlebars-helpers.js | propertyValueExtract | function propertyValueExtract(context, name, propName, options) {
if (context[name] === undefined || context[name] === null) {
return options.inverse(context);
}
this[propName] = context[name];
/* eslint-disable no-param-reassign */
context[propName] = context[name];
/* eslint-enable no-param-reassign *... | javascript | function propertyValueExtract(context, name, propName, options) {
if (context[name] === undefined || context[name] === null) {
return options.inverse(context);
}
this[propName] = context[name];
/* eslint-disable no-param-reassign */
context[propName] = context[name];
/* eslint-enable no-param-reassign *... | [
"function",
"propertyValueExtract",
"(",
"context",
",",
"name",
",",
"propName",
",",
"options",
")",
"{",
"if",
"(",
"context",
"[",
"name",
"]",
"===",
"undefined",
"||",
"context",
"[",
"name",
"]",
"===",
"null",
")",
"{",
"return",
"options",
".",
... | Extract the name of a property with a handlebars-unfriendly
name, such as hyphenated names. Sets the property called name
into context.propName if it exists and excutes the first block
with context value.
Executes inverse block otherwise.
@param {object} context - Object to look in.
@param {string} nam... | [
"Extract",
"the",
"name",
"of",
"a",
"property",
"with",
"a",
"handlebars",
"-",
"unfriendly",
"name",
"such",
"as",
"hyphenated",
"names",
".",
"Sets",
"the",
"property",
"called",
"name",
"into",
"context",
".",
"propName",
"if",
"it",
"exists",
"and",
"... | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/handlebars-helpers.js#L100-L109 | train |
steve-gray/swagger-codegen | src/handlebars-helpers.js | uppercaseFirstLetter | function uppercaseFirstLetter(options) {
const string = options.fn(this);
return string.charAt(0).toUpperCase() + string.slice(1);
} | javascript | function uppercaseFirstLetter(options) {
const string = options.fn(this);
return string.charAt(0).toUpperCase() + string.slice(1);
} | [
"function",
"uppercaseFirstLetter",
"(",
"options",
")",
"{",
"const",
"string",
"=",
"options",
".",
"fn",
"(",
"this",
")",
";",
"return",
"string",
".",
"charAt",
"(",
"0",
")",
".",
"toUpperCase",
"(",
")",
"+",
"string",
".",
"slice",
"(",
"1",
... | Capitalize the first letter of a string
@param {object} options - Handlebars options.
@returns {string} - Original string with capitalized first letter. | [
"Capitalize",
"the",
"first",
"letter",
"of",
"a",
"string"
] | cd712aa062ed06ba50f37ff30d5c51d50a9819ad | https://github.com/steve-gray/swagger-codegen/blob/cd712aa062ed06ba50f37ff30d5c51d50a9819ad/src/handlebars-helpers.js#L125-L128 | train |
pschroen/rollup-plugin-bundleutils | index.js | regex | function regex(replacements) {
return {
name: 'regex',
renderChunk(code) {
const magicString = new MagicString(code);
let hasReplacements = false;
replacements.forEach(replacement => {
let [find, replace = ''] = replacement;
if (t... | javascript | function regex(replacements) {
return {
name: 'regex',
renderChunk(code) {
const magicString = new MagicString(code);
let hasReplacements = false;
replacements.forEach(replacement => {
let [find, replace = ''] = replacement;
if (t... | [
"function",
"regex",
"(",
"replacements",
")",
"{",
"return",
"{",
"name",
":",
"'regex'",
",",
"renderChunk",
"(",
"code",
")",
"{",
"const",
"magicString",
"=",
"new",
"MagicString",
"(",
"code",
")",
";",
"let",
"hasReplacements",
"=",
"false",
";",
"... | regex replace after tree shaking | [
"regex",
"replace",
"after",
"tree",
"shaking"
] | c9d044af0f8cab00cea0170b7a14028f5d2e3980 | https://github.com/pschroen/rollup-plugin-bundleutils/blob/c9d044af0f8cab00cea0170b7a14028f5d2e3980/index.js#L26-L58 | train |
pschroen/rollup-plugin-bundleutils | index.js | babel | function babel(options = {}) {
return {
name: 'babel',
renderChunk(code) {
options.presets = [['env', { modules: false }]];
options.sourceMaps = true;
return transform(code, options);
}
};
} | javascript | function babel(options = {}) {
return {
name: 'babel',
renderChunk(code) {
options.presets = [['env', { modules: false }]];
options.sourceMaps = true;
return transform(code, options);
}
};
} | [
"function",
"babel",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"return",
"{",
"name",
":",
"'babel'",
",",
"renderChunk",
"(",
"code",
")",
"{",
"options",
".",
"presets",
"=",
"[",
"[",
"'env'",
",",
"{",
"modules",
":",
"false",
"}",
"]",
"]",
"... | transpile after tree shaking | [
"transpile",
"after",
"tree",
"shaking"
] | c9d044af0f8cab00cea0170b7a14028f5d2e3980 | https://github.com/pschroen/rollup-plugin-bundleutils/blob/c9d044af0f8cab00cea0170b7a14028f5d2e3980/index.js#L61-L71 | train |
pschroen/rollup-plugin-bundleutils | index.js | uglify | function uglify(options = {}) {
return {
name: 'uglify',
renderChunk(code) {
options.sourceMap = true;
return minify(code, options);
}
};
} | javascript | function uglify(options = {}) {
return {
name: 'uglify',
renderChunk(code) {
options.sourceMap = true;
return minify(code, options);
}
};
} | [
"function",
"uglify",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"return",
"{",
"name",
":",
"'uglify'",
",",
"renderChunk",
"(",
"code",
")",
"{",
"options",
".",
"sourceMap",
"=",
"true",
";",
"return",
"minify",
"(",
"code",
",",
"options",
")",
";"... | minify after tree shaking | [
"minify",
"after",
"tree",
"shaking"
] | c9d044af0f8cab00cea0170b7a14028f5d2e3980 | https://github.com/pschroen/rollup-plugin-bundleutils/blob/c9d044af0f8cab00cea0170b7a14028f5d2e3980/index.js#L74-L83 | train |
nelson-ai/semantic-graphql | src/graphql/getGraphqlName.js | getGraphqlName | function getGraphqlName(g, iri) {
const { prefixes } = g.config;
const localName = getIriLocalName(iri);
const namespaceIri = iri.slice(0, -localName.length);
const prefix = Object.keys(prefixes).find(key => prefixes[key] === namespaceIri) || '';
return capitalize(prefix + localName).replace(/\W/g, '_');
} | javascript | function getGraphqlName(g, iri) {
const { prefixes } = g.config;
const localName = getIriLocalName(iri);
const namespaceIri = iri.slice(0, -localName.length);
const prefix = Object.keys(prefixes).find(key => prefixes[key] === namespaceIri) || '';
return capitalize(prefix + localName).replace(/\W/g, '_');
} | [
"function",
"getGraphqlName",
"(",
"g",
",",
"iri",
")",
"{",
"const",
"{",
"prefixes",
"}",
"=",
"g",
".",
"config",
";",
"const",
"localName",
"=",
"getIriLocalName",
"(",
"iri",
")",
";",
"const",
"namespaceIri",
"=",
"iri",
".",
"slice",
"(",
"0",
... | GraphQL-safe name for GraphQL types | [
"GraphQL",
"-",
"safe",
"name",
"for",
"GraphQL",
"types"
] | d2e678d898ce48435ebafa7b7603fe0e76a92f8c | https://github.com/nelson-ai/semantic-graphql/blob/d2e678d898ce48435ebafa7b7603fe0e76a92f8c/src/graphql/getGraphqlName.js#L6-L14 | train |
nelson-ai/semantic-graphql | src/requireGraphqlRelay.js | requireGraphqlRelay | function requireGraphqlRelay() {
if (graphqlRelay) return graphqlRelay;
try {
graphqlRelay = require('graphql-relay');
}
catch (ex) {
// Nothing
}
if (!graphqlRelay) {
// Go up until graphql-relay is found
// Inspired by https://www.npmjs.com/package/parent-require
for (let parent = mo... | javascript | function requireGraphqlRelay() {
if (graphqlRelay) return graphqlRelay;
try {
graphqlRelay = require('graphql-relay');
}
catch (ex) {
// Nothing
}
if (!graphqlRelay) {
// Go up until graphql-relay is found
// Inspired by https://www.npmjs.com/package/parent-require
for (let parent = mo... | [
"function",
"requireGraphqlRelay",
"(",
")",
"{",
"if",
"(",
"graphqlRelay",
")",
"return",
"graphqlRelay",
";",
"try",
"{",
"graphqlRelay",
"=",
"require",
"(",
"'graphql-relay'",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"// Nothing",
"}",
"if",
"(",
... | optionalPeerDependencies still don't exist, so graphql-relay is a ghost dep let's find it | [
"optionalPeerDependencies",
"still",
"don",
"t",
"exist",
"so",
"graphql",
"-",
"relay",
"is",
"a",
"ghost",
"dep",
"let",
"s",
"find",
"it"
] | d2e678d898ce48435ebafa7b7603fe0e76a92f8c | https://github.com/nelson-ai/semantic-graphql/blob/d2e678d898ce48435ebafa7b7603fe0e76a92f8c/src/requireGraphqlRelay.js#L5-L32 | train |
demmer/node-cassandra-native-driver | lib/client.js | parseArgs | function parseArgs() {
var args = Array.prototype.slice.call(arguments);
var ret = {
query: args[0],
params: [],
options: {},
callback: undefined,
endCallback: undefined
};
args.shift();
// If specified, params must be an array
if (args[0] instanceof Ar... | javascript | function parseArgs() {
var args = Array.prototype.slice.call(arguments);
var ret = {
query: args[0],
params: [],
options: {},
callback: undefined,
endCallback: undefined
};
args.shift();
// If specified, params must be an array
if (args[0] instanceof Ar... | [
"function",
"parseArgs",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"ret",
"=",
"{",
"query",
":",
"args",
"[",
"0",
"]",
",",
"params",
":",
"[",
"]",
",",
"options... | Utility to parse the query function args | [
"Utility",
"to",
"parse",
"the",
"query",
"function",
"args"
] | 7a0d9043d661fa255ab9ead21cdce1976a31b88b | https://github.com/demmer/node-cassandra-native-driver/blob/7a0d9043d661fa255ab9ead21cdce1976a31b88b/lib/client.js#L14-L47 | train |
helpers/logging-helpers | index.js | createArgs | function createArgs(args, color) {
var last = args[args.length - 1];
if (args.length > 1 && isObject(last && last.hash)) {
args.pop();
}
if (typeof color === 'string' && utils[color]) {
args[0] = utils[color](args[0]);
}
return args;
} | javascript | function createArgs(args, color) {
var last = args[args.length - 1];
if (args.length > 1 && isObject(last && last.hash)) {
args.pop();
}
if (typeof color === 'string' && utils[color]) {
args[0] = utils[color](args[0]);
}
return args;
} | [
"function",
"createArgs",
"(",
"args",
",",
"color",
")",
"{",
"var",
"last",
"=",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"args",
".",
"length",
">",
"1",
"&&",
"isObject",
"(",
"last",
"&&",
"last",
".",
"hash",
")",
... | Remove handlebars options from the arguments if more than one argument
is passed, and apply a color to the first argument if specified | [
"Remove",
"handlebars",
"options",
"from",
"the",
"arguments",
"if",
"more",
"than",
"one",
"argument",
"is",
"passed",
"and",
"apply",
"a",
"color",
"to",
"the",
"first",
"argument",
"if",
"specified"
] | 1c85a1eeb142142e18693d9122ac9d9a106e21e9 | https://github.com/helpers/logging-helpers/blob/1c85a1eeb142142e18693d9122ac9d9a106e21e9/index.js#L239-L248 | train |
helpers/logging-helpers | index.js | switchOutput | function switchOutput(type, json) {
if (type[0] === '.') type = type.slice(1);
var result = '';
switch (type) {
case 'md':
result = ''
+ '\n```json\n'
+ json
+ '\n```\n';
break;
case 'html':
result = ''
+ '<div class="highlight highlight-json">\n'
... | javascript | function switchOutput(type, json) {
if (type[0] === '.') type = type.slice(1);
var result = '';
switch (type) {
case 'md':
result = ''
+ '\n```json\n'
+ json
+ '\n```\n';
break;
case 'html':
result = ''
+ '<div class="highlight highlight-json">\n'
... | [
"function",
"switchOutput",
"(",
"type",
",",
"json",
")",
"{",
"if",
"(",
"type",
"[",
"0",
"]",
"===",
"'.'",
")",
"type",
"=",
"type",
".",
"slice",
"(",
"1",
")",
";",
"var",
"result",
"=",
"''",
";",
"switch",
"(",
"type",
")",
"{",
"case"... | Generate output for the `_inspect` helper based on the
given `type` | [
"Generate",
"output",
"for",
"the",
"_inspect",
"helper",
"based",
"on",
"the",
"given",
"type"
] | 1c85a1eeb142142e18693d9122ac9d9a106e21e9 | https://github.com/helpers/logging-helpers/blob/1c85a1eeb142142e18693d9122ac9d9a106e21e9/index.js#L255-L280 | 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.