id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
45,400 | nodejitsu/contour | pagelets/head.js | stylesheets | function stylesheets(options) {
return this.stylesheets.reduce(function reduce(links, sheet) {
return links + options.fn(sheet);
}, '');
} | javascript | function stylesheets(options) {
return this.stylesheets.reduce(function reduce(links, sheet) {
return links + options.fn(sheet);
}, '');
} | [
"function",
"stylesheets",
"(",
"options",
")",
"{",
"return",
"this",
".",
"stylesheets",
".",
"reduce",
"(",
"function",
"reduce",
"(",
"links",
",",
"sheet",
")",
"{",
"return",
"links",
"+",
"options",
".",
"fn",
"(",
"sheet",
")",
";",
"}",
",",
"''",
")",
";",
"}"
]
| Handlebars helper that will iterate over the stylesheets in the data.
@param {Object} options
@return {String} generated template
@api private | [
"Handlebars",
"helper",
"that",
"will",
"iterate",
"over",
"the",
"stylesheets",
"in",
"the",
"data",
"."
]
| 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/head.js#L43-L47 |
45,401 | nodejitsu/contour | pagelets/head.js | define | function define() {
if (!('canonical' in this.data)) {
this.data.canonical = [
'https://',
pkg.subdomain,
'.nodejitsu.com',
url.parse(this.defaults.canonical).pathname
].join('');
}
return this;
} | javascript | function define() {
if (!('canonical' in this.data)) {
this.data.canonical = [
'https://',
pkg.subdomain,
'.nodejitsu.com',
url.parse(this.defaults.canonical).pathname
].join('');
}
return this;
} | [
"function",
"define",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"'canonical'",
"in",
"this",
".",
"data",
")",
")",
"{",
"this",
".",
"data",
".",
"canonical",
"=",
"[",
"'https://'",
",",
"pkg",
".",
"subdomain",
",",
"'.nodejitsu.com'",
",",
"url",
".",
"parse",
"(",
"this",
".",
"defaults",
".",
"canonical",
")",
".",
"pathname",
"]",
".",
"join",
"(",
"''",
")",
";",
"}",
"return",
"this",
";",
"}"
]
| Always set a canonical reference on the data.
@returns {Pagelet}
@api private | [
"Always",
"set",
"a",
"canonical",
"reference",
"on",
"the",
"data",
"."
]
| 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/head.js#L55-L66 |
45,402 | mchalapuk/hyper-text-slider | lib/core/slide-change-event.js | SlideChangeEvent | function SlideChangeEvent(fromIndex, toIndex) {
check(fromIndex, 'fromIndex').is.aNumber();
check(toIndex, 'toIndex').is.aNumber();
var pub = Object.create(SlideChangeEvent.prototype);
/**
* Index of previous slide.
*
* @type Number
* @access read-only
* @fqn SlideChangeEvent.prototype.fromIndex
*/
pub.fromIndex = fromIndex;
/**
* Index of current slide.
*
* @type Number
* @access read-only
* @fqn SlideChangeEvent.prototype.toIndex
*/
pub.toIndex = toIndex;
return pub;
} | javascript | function SlideChangeEvent(fromIndex, toIndex) {
check(fromIndex, 'fromIndex').is.aNumber();
check(toIndex, 'toIndex').is.aNumber();
var pub = Object.create(SlideChangeEvent.prototype);
/**
* Index of previous slide.
*
* @type Number
* @access read-only
* @fqn SlideChangeEvent.prototype.fromIndex
*/
pub.fromIndex = fromIndex;
/**
* Index of current slide.
*
* @type Number
* @access read-only
* @fqn SlideChangeEvent.prototype.toIndex
*/
pub.toIndex = toIndex;
return pub;
} | [
"function",
"SlideChangeEvent",
"(",
"fromIndex",
",",
"toIndex",
")",
"{",
"check",
"(",
"fromIndex",
",",
"'fromIndex'",
")",
".",
"is",
".",
"aNumber",
"(",
")",
";",
"check",
"(",
"toIndex",
",",
"'toIndex'",
")",
".",
"is",
".",
"aNumber",
"(",
")",
";",
"var",
"pub",
"=",
"Object",
".",
"create",
"(",
"SlideChangeEvent",
".",
"prototype",
")",
";",
"/**\n * Index of previous slide.\n *\n * @type Number\n * @access read-only\n * @fqn SlideChangeEvent.prototype.fromIndex\n */",
"pub",
".",
"fromIndex",
"=",
"fromIndex",
";",
"/**\n * Index of current slide.\n *\n * @type Number\n * @access read-only\n * @fqn SlideChangeEvent.prototype.toIndex\n */",
"pub",
".",
"toIndex",
"=",
"toIndex",
";",
"return",
"pub",
";",
"}"
]
| Creates SlideChangeEvent.
@param {Number} from index of a previous slide
@param {Number} to index of current slide
@fqn SlideChangeEvent.prototype.constructor | [
"Creates",
"SlideChangeEvent",
"."
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/slide-change-event.js#L37-L62 |
45,403 | sofa/sofa | dist/sofa.js | function (backendAddress) {
backendAddress = backendAddress || {};
var country = {
value: safeUse(backendAddress.country),
label: safeUse(backendAddress.countryname)
};
return {
company: safeUse(backendAddress.company),
salutation: safeUse(backendAddress.salutation),
surname: safeUse(backendAddress.lastname),
name: safeUse(backendAddress.firstname),
street: safeUse(backendAddress.street1),
zip: safeUse(backendAddress.zip),
city: safeUse(backendAddress.city),
country: !country.value ? null : country,
email: safeUse(backendAddress.email),
telephone: safeUse(backendAddress.telephone)
};
} | javascript | function (backendAddress) {
backendAddress = backendAddress || {};
var country = {
value: safeUse(backendAddress.country),
label: safeUse(backendAddress.countryname)
};
return {
company: safeUse(backendAddress.company),
salutation: safeUse(backendAddress.salutation),
surname: safeUse(backendAddress.lastname),
name: safeUse(backendAddress.firstname),
street: safeUse(backendAddress.street1),
zip: safeUse(backendAddress.zip),
city: safeUse(backendAddress.city),
country: !country.value ? null : country,
email: safeUse(backendAddress.email),
telephone: safeUse(backendAddress.telephone)
};
} | [
"function",
"(",
"backendAddress",
")",
"{",
"backendAddress",
"=",
"backendAddress",
"||",
"{",
"}",
";",
"var",
"country",
"=",
"{",
"value",
":",
"safeUse",
"(",
"backendAddress",
".",
"country",
")",
",",
"label",
":",
"safeUse",
"(",
"backendAddress",
".",
"countryname",
")",
"}",
";",
"return",
"{",
"company",
":",
"safeUse",
"(",
"backendAddress",
".",
"company",
")",
",",
"salutation",
":",
"safeUse",
"(",
"backendAddress",
".",
"salutation",
")",
",",
"surname",
":",
"safeUse",
"(",
"backendAddress",
".",
"lastname",
")",
",",
"name",
":",
"safeUse",
"(",
"backendAddress",
".",
"firstname",
")",
",",
"street",
":",
"safeUse",
"(",
"backendAddress",
".",
"street1",
")",
",",
"zip",
":",
"safeUse",
"(",
"backendAddress",
".",
"zip",
")",
",",
"city",
":",
"safeUse",
"(",
"backendAddress",
".",
"city",
")",
",",
"country",
":",
"!",
"country",
".",
"value",
"?",
"null",
":",
"country",
",",
"email",
":",
"safeUse",
"(",
"backendAddress",
".",
"email",
")",
",",
"telephone",
":",
"safeUse",
"(",
"backendAddress",
".",
"telephone",
")",
"}",
";",
"}"
]
| unfortunately the backend uses all sorts of different address formats this one converts an address coming from a summary response to the generic app address format. | [
"unfortunately",
"the",
"backend",
"uses",
"all",
"sorts",
"of",
"different",
"address",
"formats",
"this",
"one",
"converts",
"an",
"address",
"coming",
"from",
"a",
"summary",
"response",
"to",
"the",
"generic",
"app",
"address",
"format",
"."
]
| 0dda1f2f197e3cf7d93bcea4b890777af74e65f6 | https://github.com/sofa/sofa/blob/0dda1f2f197e3cf7d93bcea4b890777af74e65f6/dist/sofa.js#L2048-L2069 |
|
45,404 | sofa/sofa | dist/sofa.js | function (products, categoryUrlId) {
return products.map(function (product) {
product.categoryUrlId = categoryUrlId;
// the backend is sending us prices as strings.
// we need to fix that up for sorting and other things to work
product.price = parseFloat(product.price, 10);
return sofa.Util.extend(new sofa.models.Product(), product);
});
} | javascript | function (products, categoryUrlId) {
return products.map(function (product) {
product.categoryUrlId = categoryUrlId;
// the backend is sending us prices as strings.
// we need to fix that up for sorting and other things to work
product.price = parseFloat(product.price, 10);
return sofa.Util.extend(new sofa.models.Product(), product);
});
} | [
"function",
"(",
"products",
",",
"categoryUrlId",
")",
"{",
"return",
"products",
".",
"map",
"(",
"function",
"(",
"product",
")",
"{",
"product",
".",
"categoryUrlId",
"=",
"categoryUrlId",
";",
"// the backend is sending us prices as strings.",
"// we need to fix that up for sorting and other things to work",
"product",
".",
"price",
"=",
"parseFloat",
"(",
"product",
".",
"price",
",",
"10",
")",
";",
"return",
"sofa",
".",
"Util",
".",
"extend",
"(",
"new",
"sofa",
".",
"models",
".",
"Product",
"(",
")",
",",
"product",
")",
";",
"}",
")",
";",
"}"
]
| it's a bit akward that we need to do that. It should be adressed directly on our server API so that this extra processing can be removed. | [
"it",
"s",
"a",
"bit",
"akward",
"that",
"we",
"need",
"to",
"do",
"that",
".",
"It",
"should",
"be",
"adressed",
"directly",
"on",
"our",
"server",
"API",
"so",
"that",
"this",
"extra",
"processing",
"can",
"be",
"removed",
"."
]
| 0dda1f2f197e3cf7d93bcea4b890777af74e65f6 | https://github.com/sofa/sofa/blob/0dda1f2f197e3cf7d93bcea4b890777af74e65f6/dist/sofa.js#L2344-L2352 |
|
45,405 | sofa/sofa | dist/sofa.js | function () {
var activeCoupons = basketService.getActiveCoupons();
var oldCouponCodes = activeCoupons.map(function (activeCoupon) {
return activeCoupon.code;
});
basketService.clearCoupons();
oldCouponCodes.forEach(function (couponCode) {
self.submitCode(couponCode);
});
} | javascript | function () {
var activeCoupons = basketService.getActiveCoupons();
var oldCouponCodes = activeCoupons.map(function (activeCoupon) {
return activeCoupon.code;
});
basketService.clearCoupons();
oldCouponCodes.forEach(function (couponCode) {
self.submitCode(couponCode);
});
} | [
"function",
"(",
")",
"{",
"var",
"activeCoupons",
"=",
"basketService",
".",
"getActiveCoupons",
"(",
")",
";",
"var",
"oldCouponCodes",
"=",
"activeCoupons",
".",
"map",
"(",
"function",
"(",
"activeCoupon",
")",
"{",
"return",
"activeCoupon",
".",
"code",
";",
"}",
")",
";",
"basketService",
".",
"clearCoupons",
"(",
")",
";",
"oldCouponCodes",
".",
"forEach",
"(",
"function",
"(",
"couponCode",
")",
"{",
"self",
".",
"submitCode",
"(",
"couponCode",
")",
";",
"}",
")",
";",
"}"
]
| When the cart changes, refresh the values of the coupons by sending them to the backend along with the new cart | [
"When",
"the",
"cart",
"changes",
"refresh",
"the",
"values",
"of",
"the",
"coupons",
"by",
"sending",
"them",
"to",
"the",
"backend",
"along",
"with",
"the",
"new",
"cart"
]
| 0dda1f2f197e3cf7d93bcea4b890777af74e65f6 | https://github.com/sofa/sofa/blob/0dda1f2f197e3cf7d93bcea4b890777af74e65f6/dist/sofa.js#L2658-L2670 |
|
45,406 | feedhenry/fh-mbaas-client | lib/app/appforms/config.js | get | function get(params, cb) {
var resourcePath = "/appforms/config";
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | javascript | function get(params, cb) {
var resourcePath = "/appforms/config";
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.app(params, cb);
} | [
"function",
"get",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"\"/appforms/config\"",
";",
"var",
"method",
"=",
"\"GET\"",
";",
"var",
"data",
"=",
"{",
"}",
";",
"params",
".",
"resourcePath",
"=",
"resourcePath",
";",
"params",
".",
"method",
"=",
"method",
";",
"params",
".",
"data",
"=",
"data",
";",
"mbaasRequest",
".",
"app",
"(",
"params",
",",
"cb",
")",
";",
"}"
]
| Get The Forms App Configuration Associated With A Project | [
"Get",
"The",
"Forms",
"App",
"Configuration",
"Associated",
"With",
"A",
"Project"
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/app/appforms/config.js#L6-L16 |
45,407 | jldec/pub-generator | serialize.js | serializeFile | function serializeFile(file) {
// preserve path, source, and file-save props
var o = u.pick(file, 'path', '_oldtext', '_dirty');
// recreate file.text from serialized fragments
// new or modifified fragments should delete file.text
o.text = file.text || serializeTextFragments(file);
return o;
} | javascript | function serializeFile(file) {
// preserve path, source, and file-save props
var o = u.pick(file, 'path', '_oldtext', '_dirty');
// recreate file.text from serialized fragments
// new or modifified fragments should delete file.text
o.text = file.text || serializeTextFragments(file);
return o;
} | [
"function",
"serializeFile",
"(",
"file",
")",
"{",
"// preserve path, source, and file-save props",
"var",
"o",
"=",
"u",
".",
"pick",
"(",
"file",
",",
"'path'",
",",
"'_oldtext'",
",",
"'_dirty'",
")",
";",
"// recreate file.text from serialized fragments",
"// new or modifified fragments should delete file.text",
"o",
".",
"text",
"=",
"file",
".",
"text",
"||",
"serializeTextFragments",
"(",
"file",
")",
";",
"return",
"o",
";",
"}"
]
| return serializable file object | [
"return",
"serializable",
"file",
"object"
]
| 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/serialize.js#L27-L37 |
45,408 | socialally/air | lib/air/clone.js | clone | function clone() {
var arr = [];
this.each(function(el) {
arr.push(el.cloneNode(true));
});
return this.air(arr);
} | javascript | function clone() {
var arr = [];
this.each(function(el) {
arr.push(el.cloneNode(true));
});
return this.air(arr);
} | [
"function",
"clone",
"(",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"this",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"arr",
".",
"push",
"(",
"el",
".",
"cloneNode",
"(",
"true",
")",
")",
";",
"}",
")",
";",
"return",
"this",
".",
"air",
"(",
"arr",
")",
";",
"}"
]
| Create a deep copy of the set of matched elements. | [
"Create",
"a",
"deep",
"copy",
"of",
"the",
"set",
"of",
"matched",
"elements",
"."
]
| a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/clone.js#L4-L10 |
45,409 | vesln/unix.js | lib/result.js | Result | function Result(cmd, err, stdout, stderr) {
this.cmd = cmd;
this.err = err;
this.stdout = strip(stdout);
this.stderr = strip(stderr);
} | javascript | function Result(cmd, err, stdout, stderr) {
this.cmd = cmd;
this.err = err;
this.stdout = strip(stdout);
this.stderr = strip(stderr);
} | [
"function",
"Result",
"(",
"cmd",
",",
"err",
",",
"stdout",
",",
"stderr",
")",
"{",
"this",
".",
"cmd",
"=",
"cmd",
";",
"this",
".",
"err",
"=",
"err",
";",
"this",
".",
"stdout",
"=",
"strip",
"(",
"stdout",
")",
";",
"this",
".",
"stderr",
"=",
"strip",
"(",
"stderr",
")",
";",
"}"
]
| Command result.
@param {String} command
@param {Object} error
@param {String} stdout
@param {String} stderr
@constructor | [
"Command",
"result",
"."
]
| 706b70b3d4d0cf815414303d58791afeae2fed3e | https://github.com/vesln/unix.js/blob/706b70b3d4d0cf815414303d58791afeae2fed3e/lib/result.js#L23-L28 |
45,410 | cliffano/couchpenter | lib/db.js | _errorCb | function _errorCb(err, result) {
// if there is a conflict error, retrieve the document's revision first
function _successCb(err, result) {
// use the revision to update the existing documents
// NOTE: it is not impossible that the revision of this document
// is modified by other operations right before updating, Couchpenter
// will only try once to avoid any possibility of retrying infinitely.
doc._rev = result._rev;
self.couch.use(dbName).insert(doc, self._handle(cb, {
dbName: dbName,
docId: doc._id,
message: 'updated'
}));
}
self.couch.use(dbName).get(doc._id, self._handle(cb, {
dbName: dbName,
docId: doc._id,
successCb: _successCb
}));
} | javascript | function _errorCb(err, result) {
// if there is a conflict error, retrieve the document's revision first
function _successCb(err, result) {
// use the revision to update the existing documents
// NOTE: it is not impossible that the revision of this document
// is modified by other operations right before updating, Couchpenter
// will only try once to avoid any possibility of retrying infinitely.
doc._rev = result._rev;
self.couch.use(dbName).insert(doc, self._handle(cb, {
dbName: dbName,
docId: doc._id,
message: 'updated'
}));
}
self.couch.use(dbName).get(doc._id, self._handle(cb, {
dbName: dbName,
docId: doc._id,
successCb: _successCb
}));
} | [
"function",
"_errorCb",
"(",
"err",
",",
"result",
")",
"{",
"// if there is a conflict error, retrieve the document's revision first",
"function",
"_successCb",
"(",
"err",
",",
"result",
")",
"{",
"// use the revision to update the existing documents",
"// NOTE: it is not impossible that the revision of this document",
"// is modified by other operations right before updating, Couchpenter",
"// will only try once to avoid any possibility of retrying infinitely.",
"doc",
".",
"_rev",
"=",
"result",
".",
"_rev",
";",
"self",
".",
"couch",
".",
"use",
"(",
"dbName",
")",
".",
"insert",
"(",
"doc",
",",
"self",
".",
"_handle",
"(",
"cb",
",",
"{",
"dbName",
":",
"dbName",
",",
"docId",
":",
"doc",
".",
"_id",
",",
"message",
":",
"'updated'",
"}",
")",
")",
";",
"}",
"self",
".",
"couch",
".",
"use",
"(",
"dbName",
")",
".",
"get",
"(",
"doc",
".",
"_id",
",",
"self",
".",
"_handle",
"(",
"cb",
",",
"{",
"dbName",
":",
"dbName",
",",
"docId",
":",
"doc",
".",
"_id",
",",
"successCb",
":",
"_successCb",
"}",
")",
")",
";",
"}"
]
| try to create documents, but with conflict error handling | [
"try",
"to",
"create",
"documents",
"but",
"with",
"conflict",
"error",
"handling"
]
| 00cce387da2f39e4b276b27b0bacb073caa80453 | https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/db.js#L143-L165 |
45,411 | cliffano/couchpenter | lib/db.js | _successCb | function _successCb(err, result) {
self.couch.use(dbName).destroy(result._id, result._rev, self._handle(cb, {
dbName: dbName,
docId: doc._id,
message: 'deleted'
}));
} | javascript | function _successCb(err, result) {
self.couch.use(dbName).destroy(result._id, result._rev, self._handle(cb, {
dbName: dbName,
docId: doc._id,
message: 'deleted'
}));
} | [
"function",
"_successCb",
"(",
"err",
",",
"result",
")",
"{",
"self",
".",
"couch",
".",
"use",
"(",
"dbName",
")",
".",
"destroy",
"(",
"result",
".",
"_id",
",",
"result",
".",
"_rev",
",",
"self",
".",
"_handle",
"(",
"cb",
",",
"{",
"dbName",
":",
"dbName",
",",
"docId",
":",
"doc",
".",
"_id",
",",
"message",
":",
"'deleted'",
"}",
")",
")",
";",
"}"
]
| retrieve the document revision and use it to delete the document | [
"retrieve",
"the",
"document",
"revision",
"and",
"use",
"it",
"to",
"delete",
"the",
"document"
]
| 00cce387da2f39e4b276b27b0bacb073caa80453 | https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/db.js#L195-L202 |
45,412 | cliffano/couchpenter | lib/db.js | _result | function _result(err, dbName, docId, message) {
var result = {
id: util.format('%s%s%s', dbName, (docId) ? '/' : '', docId || ''),
message: message || util.format('%s (%s)', err.error, err.status_code)
};
if (err) {
result.error = err;
}
return result;
} | javascript | function _result(err, dbName, docId, message) {
var result = {
id: util.format('%s%s%s', dbName, (docId) ? '/' : '', docId || ''),
message: message || util.format('%s (%s)', err.error, err.status_code)
};
if (err) {
result.error = err;
}
return result;
} | [
"function",
"_result",
"(",
"err",
",",
"dbName",
",",
"docId",
",",
"message",
")",
"{",
"var",
"result",
"=",
"{",
"id",
":",
"util",
".",
"format",
"(",
"'%s%s%s'",
",",
"dbName",
",",
"(",
"docId",
")",
"?",
"'/'",
":",
"''",
",",
"docId",
"||",
"''",
")",
",",
"message",
":",
"message",
"||",
"util",
".",
"format",
"(",
"'%s (%s)'",
",",
"err",
".",
"error",
",",
"err",
".",
"status_code",
")",
"}",
";",
"if",
"(",
"err",
")",
"{",
"result",
".",
"error",
"=",
"err",
";",
"}",
"return",
"result",
";",
"}"
]
| construct result object, the existence of error field indicates whether the result is a success or not | [
"construct",
"result",
"object",
"the",
"existence",
"of",
"error",
"field",
"indicates",
"whether",
"the",
"result",
"is",
"a",
"success",
"or",
"not"
]
| 00cce387da2f39e4b276b27b0bacb073caa80453 | https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/db.js#L382-L391 |
45,413 | kflorence/gulp-data-matter | index.js | matter | function matter(file) {
var parsed = gm(file.contents.toString());
file.contents = new Buffer(parsed.content);
return parsed.data;
} | javascript | function matter(file) {
var parsed = gm(file.contents.toString());
file.contents = new Buffer(parsed.content);
return parsed.data;
} | [
"function",
"matter",
"(",
"file",
")",
"{",
"var",
"parsed",
"=",
"gm",
"(",
"file",
".",
"contents",
".",
"toString",
"(",
")",
")",
";",
"file",
".",
"contents",
"=",
"new",
"Buffer",
"(",
"parsed",
".",
"content",
")",
";",
"return",
"parsed",
".",
"data",
";",
"}"
]
| Extract and parse front-matter from files using gray-matter.
@param {Object} file Vinyl File object
@return Data from front matter | [
"Extract",
"and",
"parse",
"front",
"-",
"matter",
"from",
"files",
"using",
"gray",
"-",
"matter",
"."
]
| 7655bcbfe08dd5f228e9c7887b17778651bf35d0 | https://github.com/kflorence/gulp-data-matter/blob/7655bcbfe08dd5f228e9c7887b17778651bf35d0/index.js#L11-L15 |
45,414 | mchalapuk/hyper-text-slider | lib/docgen/formatter.js | lazyBuildObjectTree | function lazyBuildObjectTree(priv, formatted) {
definePropertyGetters(formatted, {
children: lazy(function() { return priv.fqnMap.getChildrenOf(formatted.fqn); }),
fields: lazy(function() { return formatted.children.filter(Filter.ofType('property')); }),
methods: lazy(function() { return formatted.children.filter(Filter.ofType('function')); }),
parent: lazy(function() { return priv.fqnMap.getParentOf(formatted.fqn); }),
parentElement: lazy(function() { return priv.fqnMap.get(formatted.idTags['parent-element']); }),
});
} | javascript | function lazyBuildObjectTree(priv, formatted) {
definePropertyGetters(formatted, {
children: lazy(function() { return priv.fqnMap.getChildrenOf(formatted.fqn); }),
fields: lazy(function() { return formatted.children.filter(Filter.ofType('property')); }),
methods: lazy(function() { return formatted.children.filter(Filter.ofType('function')); }),
parent: lazy(function() { return priv.fqnMap.getParentOf(formatted.fqn); }),
parentElement: lazy(function() { return priv.fqnMap.get(formatted.idTags['parent-element']); }),
});
} | [
"function",
"lazyBuildObjectTree",
"(",
"priv",
",",
"formatted",
")",
"{",
"definePropertyGetters",
"(",
"formatted",
",",
"{",
"children",
":",
"lazy",
"(",
"function",
"(",
")",
"{",
"return",
"priv",
".",
"fqnMap",
".",
"getChildrenOf",
"(",
"formatted",
".",
"fqn",
")",
";",
"}",
")",
",",
"fields",
":",
"lazy",
"(",
"function",
"(",
")",
"{",
"return",
"formatted",
".",
"children",
".",
"filter",
"(",
"Filter",
".",
"ofType",
"(",
"'property'",
")",
")",
";",
"}",
")",
",",
"methods",
":",
"lazy",
"(",
"function",
"(",
")",
"{",
"return",
"formatted",
".",
"children",
".",
"filter",
"(",
"Filter",
".",
"ofType",
"(",
"'function'",
")",
")",
";",
"}",
")",
",",
"parent",
":",
"lazy",
"(",
"function",
"(",
")",
"{",
"return",
"priv",
".",
"fqnMap",
".",
"getParentOf",
"(",
"formatted",
".",
"fqn",
")",
";",
"}",
")",
",",
"parentElement",
":",
"lazy",
"(",
"function",
"(",
")",
"{",
"return",
"priv",
".",
"fqnMap",
".",
"get",
"(",
"formatted",
".",
"idTags",
"[",
"'parent-element'",
"]",
")",
";",
"}",
")",
",",
"}",
")",
";",
"}"
]
| sets parent->child relations | [
"sets",
"parent",
"-",
">",
"child",
"relations"
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/docgen/formatter.js#L199-L207 |
45,415 | mchalapuk/hyper-text-slider | lib/docgen/formatter.js | toGithubHash | function toGithubHash(title) {
var GITHUB_ILLEGAL = new RegExp('[\\[\\]{}()<>^$#@!%&*+\/\\|~`"\':;,.]', 'g');
return title.toLowerCase().replace(/ /g, '-').replace(GITHUB_ILLEGAL, '');
} | javascript | function toGithubHash(title) {
var GITHUB_ILLEGAL = new RegExp('[\\[\\]{}()<>^$#@!%&*+\/\\|~`"\':;,.]', 'g');
return title.toLowerCase().replace(/ /g, '-').replace(GITHUB_ILLEGAL, '');
} | [
"function",
"toGithubHash",
"(",
"title",
")",
"{",
"var",
"GITHUB_ILLEGAL",
"=",
"new",
"RegExp",
"(",
"'[\\\\[\\\\]{}()<>^$#@!%&*+\\/\\\\|~`\"\\':;,.]'",
",",
"'g'",
")",
";",
"return",
"title",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"/",
" ",
"/",
"g",
",",
"'-'",
")",
".",
"replace",
"(",
"GITHUB_ILLEGAL",
",",
"''",
")",
";",
"}"
]
| Algorithm of generating a HTML label used in Github Markdown | [
"Algorithm",
"of",
"generating",
"a",
"HTML",
"label",
"used",
"in",
"Github",
"Markdown"
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/docgen/formatter.js#L237-L240 |
45,416 | neurospeech/web-atoms-mvvm.js | dist/web-atoms-mvvm.js | bindableProperty | function bindableProperty(target, key) {
// property value
var _val = this[key];
var keyName = "_" + key;
this[keyName] = _val;
// property getter
var getter = function () {
// console.log(`Get: ${key} => ${_val}`);
return this[keyName];
};
// property setter
var setter = function (newVal) {
// console.log(`Set: ${key} => ${newVal}`);
// debugger;
var oldValue = this[keyName];
// tslint:disable-next-line:triple-equals
if (oldValue == newVal) {
return;
}
this[keyName] = newVal;
var c = this._$_supressRefresh;
if (!(c && c[key])) {
Atom.refresh(this, key);
}
if (this.onPropertyChanged) {
this.onPropertyChanged(key);
}
};
// delete property
if (delete this[key]) {
// create new property with getter and setter
Object.defineProperty(target, key, {
get: getter,
set: setter,
enumerable: true,
configurable: true
});
// tslint:disable-next-line:no-string-literal
if (target.constructor.prototype["get_atomParent"]) {
target["get_" + key] = getter;
target["set_" + key] = setter;
}
}
} | javascript | function bindableProperty(target, key) {
// property value
var _val = this[key];
var keyName = "_" + key;
this[keyName] = _val;
// property getter
var getter = function () {
// console.log(`Get: ${key} => ${_val}`);
return this[keyName];
};
// property setter
var setter = function (newVal) {
// console.log(`Set: ${key} => ${newVal}`);
// debugger;
var oldValue = this[keyName];
// tslint:disable-next-line:triple-equals
if (oldValue == newVal) {
return;
}
this[keyName] = newVal;
var c = this._$_supressRefresh;
if (!(c && c[key])) {
Atom.refresh(this, key);
}
if (this.onPropertyChanged) {
this.onPropertyChanged(key);
}
};
// delete property
if (delete this[key]) {
// create new property with getter and setter
Object.defineProperty(target, key, {
get: getter,
set: setter,
enumerable: true,
configurable: true
});
// tslint:disable-next-line:no-string-literal
if (target.constructor.prototype["get_atomParent"]) {
target["get_" + key] = getter;
target["set_" + key] = setter;
}
}
} | [
"function",
"bindableProperty",
"(",
"target",
",",
"key",
")",
"{",
"// property value",
"var",
"_val",
"=",
"this",
"[",
"key",
"]",
";",
"var",
"keyName",
"=",
"\"_\"",
"+",
"key",
";",
"this",
"[",
"keyName",
"]",
"=",
"_val",
";",
"// property getter",
"var",
"getter",
"=",
"function",
"(",
")",
"{",
"// console.log(`Get: ${key} => ${_val}`);",
"return",
"this",
"[",
"keyName",
"]",
";",
"}",
";",
"// property setter",
"var",
"setter",
"=",
"function",
"(",
"newVal",
")",
"{",
"// console.log(`Set: ${key} => ${newVal}`);",
"// debugger;",
"var",
"oldValue",
"=",
"this",
"[",
"keyName",
"]",
";",
"// tslint:disable-next-line:triple-equals",
"if",
"(",
"oldValue",
"==",
"newVal",
")",
"{",
"return",
";",
"}",
"this",
"[",
"keyName",
"]",
"=",
"newVal",
";",
"var",
"c",
"=",
"this",
".",
"_$_supressRefresh",
";",
"if",
"(",
"!",
"(",
"c",
"&&",
"c",
"[",
"key",
"]",
")",
")",
"{",
"Atom",
".",
"refresh",
"(",
"this",
",",
"key",
")",
";",
"}",
"if",
"(",
"this",
".",
"onPropertyChanged",
")",
"{",
"this",
".",
"onPropertyChanged",
"(",
"key",
")",
";",
"}",
"}",
";",
"// delete property",
"if",
"(",
"delete",
"this",
"[",
"key",
"]",
")",
"{",
"// create new property with getter and setter",
"Object",
".",
"defineProperty",
"(",
"target",
",",
"key",
",",
"{",
"get",
":",
"getter",
",",
"set",
":",
"setter",
",",
"enumerable",
":",
"true",
",",
"configurable",
":",
"true",
"}",
")",
";",
"// tslint:disable-next-line:no-string-literal",
"if",
"(",
"target",
".",
"constructor",
".",
"prototype",
"[",
"\"get_atomParent\"",
"]",
")",
"{",
"target",
"[",
"\"get_\"",
"+",
"key",
"]",
"=",
"getter",
";",
"target",
"[",
"\"set_\"",
"+",
"key",
"]",
"=",
"setter",
";",
"}",
"}",
"}"
]
| This decorator will mark given property as bindable, it will define
getter and setter, and in the setter, it will refresh the property.
class Customer{
@bindableProperty
firstName:string;
}
@param {*} target
@param {string} key | [
"This",
"decorator",
"will",
"mark",
"given",
"property",
"as",
"bindable",
"it",
"will",
"define",
"getter",
"and",
"setter",
"and",
"in",
"the",
"setter",
"it",
"will",
"refresh",
"the",
"property",
"."
]
| 777222c3d5b491686be3a81a433e0cf7cb3ff979 | https://github.com/neurospeech/web-atoms-mvvm.js/blob/777222c3d5b491686be3a81a433e0cf7cb3ff979/dist/web-atoms-mvvm.js#L172-L215 |
45,417 | neurospeech/web-atoms-mvvm.js | dist/web-atoms-mvvm.js | AtomWatcher | function AtomWatcher(target, path, runAfterSetup, forValidation) {
var _this = this;
this._isExecuting = false;
this.target = target;
var e = false;
if (forValidation === true) {
this.forValidation = true;
}
if (path instanceof Function) {
var f = path;
path = parsePath(path);
e = true;
this.func = f;
this.funcText = f.toString();
}
this.runEvaluate = function () {
_this.evaluate();
};
this.runEvaluate.watcher = this;
this.path = path.map(function (x) { return x.split(".").map(function (y) { return new ObjectProperty(y); }); });
if (e) {
if (runAfterSetup) {
this.evaluate();
}
// else {
// // setup watcher...
// for(var p of this.path) {
// this.evaluatePath(this.target,p);
// }
// }
}
} | javascript | function AtomWatcher(target, path, runAfterSetup, forValidation) {
var _this = this;
this._isExecuting = false;
this.target = target;
var e = false;
if (forValidation === true) {
this.forValidation = true;
}
if (path instanceof Function) {
var f = path;
path = parsePath(path);
e = true;
this.func = f;
this.funcText = f.toString();
}
this.runEvaluate = function () {
_this.evaluate();
};
this.runEvaluate.watcher = this;
this.path = path.map(function (x) { return x.split(".").map(function (y) { return new ObjectProperty(y); }); });
if (e) {
if (runAfterSetup) {
this.evaluate();
}
// else {
// // setup watcher...
// for(var p of this.path) {
// this.evaluatePath(this.target,p);
// }
// }
}
} | [
"function",
"AtomWatcher",
"(",
"target",
",",
"path",
",",
"runAfterSetup",
",",
"forValidation",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"this",
".",
"_isExecuting",
"=",
"false",
";",
"this",
".",
"target",
"=",
"target",
";",
"var",
"e",
"=",
"false",
";",
"if",
"(",
"forValidation",
"===",
"true",
")",
"{",
"this",
".",
"forValidation",
"=",
"true",
";",
"}",
"if",
"(",
"path",
"instanceof",
"Function",
")",
"{",
"var",
"f",
"=",
"path",
";",
"path",
"=",
"parsePath",
"(",
"path",
")",
";",
"e",
"=",
"true",
";",
"this",
".",
"func",
"=",
"f",
";",
"this",
".",
"funcText",
"=",
"f",
".",
"toString",
"(",
")",
";",
"}",
"this",
".",
"runEvaluate",
"=",
"function",
"(",
")",
"{",
"_this",
".",
"evaluate",
"(",
")",
";",
"}",
";",
"this",
".",
"runEvaluate",
".",
"watcher",
"=",
"this",
";",
"this",
".",
"path",
"=",
"path",
".",
"map",
"(",
"function",
"(",
"x",
")",
"{",
"return",
"x",
".",
"split",
"(",
"\".\"",
")",
".",
"map",
"(",
"function",
"(",
"y",
")",
"{",
"return",
"new",
"ObjectProperty",
"(",
"y",
")",
";",
"}",
")",
";",
"}",
")",
";",
"if",
"(",
"e",
")",
"{",
"if",
"(",
"runAfterSetup",
")",
"{",
"this",
".",
"evaluate",
"(",
")",
";",
"}",
"// else {",
"// // setup watcher...",
"// for(var p of this.path) {",
"// this.evaluatePath(this.target,p);",
"// }",
"// }",
"}",
"}"
]
| Creates an instance of AtomWatcher.
var w = new AtomWatcher(this, x => x.data.fullName = `${x.data.firstName} ${x.data.lastName}`);
You must dispose `w` in order to avoid memory leaks.
Above method will set fullName whenver, data or its firstName,lastName property is modified.
AtomWatcher will assign null if any expression results in null in single property path.
In order to avoid null, you can rewrite above expression as,
var w = new AtomWatcher(this,
x => {
if(x.data.firstName && x.data.lastName){
x.data.fullName = `${x.data.firstName} ${x.data.lastName}`
}
});
@param {T} target - Target on which watch will be set to observe given set of properties
@param {(string[] | ((x:T) => any))} path - Path is either lambda expression or array of
property path to watch, if path was lambda, it will be executed when any of
members will modify
@param {boolean} [forValidation] forValidtion - Ignore, used for internal purpose
@memberof AtomWatcher | [
"Creates",
"an",
"instance",
"of",
"AtomWatcher",
"."
]
| 777222c3d5b491686be3a81a433e0cf7cb3ff979 | https://github.com/neurospeech/web-atoms-mvvm.js/blob/777222c3d5b491686be3a81a433e0cf7cb3ff979/dist/web-atoms-mvvm.js#L1431-L1462 |
45,418 | neurospeech/web-atoms-mvvm.js | dist/web-atoms-mvvm.js | function () {
return {
href: location.href,
hash: location.hash,
host: location.host,
hostName: location.hostname,
port: location.port,
protocol: location.protocol
};
} | javascript | function () {
return {
href: location.href,
hash: location.hash,
host: location.host,
hostName: location.hostname,
port: location.port,
protocol: location.protocol
};
} | [
"function",
"(",
")",
"{",
"return",
"{",
"href",
":",
"location",
".",
"href",
",",
"hash",
":",
"location",
".",
"hash",
",",
"host",
":",
"location",
".",
"host",
",",
"hostName",
":",
"location",
".",
"hostname",
",",
"port",
":",
"location",
".",
"port",
",",
"protocol",
":",
"location",
".",
"protocol",
"}",
";",
"}"
]
| Gets current location of browser, this does not return
actual location but it returns values of browser location.
This is done to provide mocking behaviour for unit testing.
@readonly
@type {AtomLocation}
@memberof BrowserService | [
"Gets",
"current",
"location",
"of",
"browser",
"this",
"does",
"not",
"return",
"actual",
"location",
"but",
"it",
"returns",
"values",
"of",
"browser",
"location",
".",
"This",
"is",
"done",
"to",
"provide",
"mocking",
"behaviour",
"for",
"unit",
"testing",
"."
]
| 777222c3d5b491686be3a81a433e0cf7cb3ff979 | https://github.com/neurospeech/web-atoms-mvvm.js/blob/777222c3d5b491686be3a81a433e0cf7cb3ff979/dist/web-atoms-mvvm.js#L1625-L1634 |
|
45,419 | vid/SenseBase | web/ext-lib/dragFile.js | previewfile | function previewfile(file) {
if (false && tests.filereader === true) {
var reader = new FileReader();
reader.onload = function (event) {
var image = new Image();
image.src = event.target.result;
image.width = 250; // a fake resize
holder.appendChild(image);
};
reader.readAsDataURL(file);
} else {
holder.innerHTML += '<p>Uploaded ' + file.name + ' ' + (file.size ? (file.size/1024|0) + 'K' : '');
// console.log(file);
}
} | javascript | function previewfile(file) {
if (false && tests.filereader === true) {
var reader = new FileReader();
reader.onload = function (event) {
var image = new Image();
image.src = event.target.result;
image.width = 250; // a fake resize
holder.appendChild(image);
};
reader.readAsDataURL(file);
} else {
holder.innerHTML += '<p>Uploaded ' + file.name + ' ' + (file.size ? (file.size/1024|0) + 'K' : '');
// console.log(file);
}
} | [
"function",
"previewfile",
"(",
"file",
")",
"{",
"if",
"(",
"false",
"&&",
"tests",
".",
"filereader",
"===",
"true",
")",
"{",
"var",
"reader",
"=",
"new",
"FileReader",
"(",
")",
";",
"reader",
".",
"onload",
"=",
"function",
"(",
"event",
")",
"{",
"var",
"image",
"=",
"new",
"Image",
"(",
")",
";",
"image",
".",
"src",
"=",
"event",
".",
"target",
".",
"result",
";",
"image",
".",
"width",
"=",
"250",
";",
"// a fake resize",
"holder",
".",
"appendChild",
"(",
"image",
")",
";",
"}",
";",
"reader",
".",
"readAsDataURL",
"(",
"file",
")",
";",
"}",
"else",
"{",
"holder",
".",
"innerHTML",
"+=",
"'<p>Uploaded '",
"+",
"file",
".",
"name",
"+",
"' '",
"+",
"(",
"file",
".",
"size",
"?",
"(",
"file",
".",
"size",
"/",
"1024",
"|",
"0",
")",
"+",
"'K'",
":",
"''",
")",
";",
"// console.log(file);",
"}",
"}"
]
| FIXME display filetype icon | [
"FIXME",
"display",
"filetype",
"icon"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/ext-lib/dragFile.js#L47-L62 |
45,420 | unkelpehr/node-exit-hook | exit-hook.js | handleExit | function handleExit (canCancel, signal, code) {
var i = 0,
sub;
while ((sub = subs[i++])) {
if (sub[0].call(sub[1], canCancel, signal, code) === false && canCancel) {
return;
}
}
if (canCancel) {
process.exit(code);
}
} | javascript | function handleExit (canCancel, signal, code) {
var i = 0,
sub;
while ((sub = subs[i++])) {
if (sub[0].call(sub[1], canCancel, signal, code) === false && canCancel) {
return;
}
}
if (canCancel) {
process.exit(code);
}
} | [
"function",
"handleExit",
"(",
"canCancel",
",",
"signal",
",",
"code",
")",
"{",
"var",
"i",
"=",
"0",
",",
"sub",
";",
"while",
"(",
"(",
"sub",
"=",
"subs",
"[",
"i",
"++",
"]",
")",
")",
"{",
"if",
"(",
"sub",
"[",
"0",
"]",
".",
"call",
"(",
"sub",
"[",
"1",
"]",
",",
"canCancel",
",",
"signal",
",",
"code",
")",
"===",
"false",
"&&",
"canCancel",
")",
"{",
"return",
";",
"}",
"}",
"if",
"(",
"canCancel",
")",
"{",
"process",
".",
"exit",
"(",
"code",
")",
";",
"}",
"}"
]
| Handler for all exit events | [
"Handler",
"for",
"all",
"exit",
"events"
]
| 5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e | https://github.com/unkelpehr/node-exit-hook/blob/5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e/exit-hook.js#L9-L22 |
45,421 | unkelpehr/node-exit-hook | exit-hook.js | exitHook | function exitHook (context, func) {
if (!func) {
func = context;
context = func;
}
if (typeof func === 'function') {
subs.push([func, context])
}
return exitHook;
} | javascript | function exitHook (context, func) {
if (!func) {
func = context;
context = func;
}
if (typeof func === 'function') {
subs.push([func, context])
}
return exitHook;
} | [
"function",
"exitHook",
"(",
"context",
",",
"func",
")",
"{",
"if",
"(",
"!",
"func",
")",
"{",
"func",
"=",
"context",
";",
"context",
"=",
"func",
";",
"}",
"if",
"(",
"typeof",
"func",
"===",
"'function'",
")",
"{",
"subs",
".",
"push",
"(",
"[",
"func",
",",
"context",
"]",
")",
"}",
"return",
"exitHook",
";",
"}"
]
| Adds a new function to execute when the application is exiting. | [
"Adds",
"a",
"new",
"function",
"to",
"execute",
"when",
"the",
"application",
"is",
"exiting",
"."
]
| 5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e | https://github.com/unkelpehr/node-exit-hook/blob/5c4a6078c3d8f0fb98fbbfbd8a952b5d6e8a159e/exit-hook.js#L25-L36 |
45,422 | ngenerio/smsghjs | lib/sendmsg.js | SendMessage | function SendMessage (auth, apiVersion) {
if (!(this instanceof SendMessage)) return new SendMessage(auth, apiVersion)
this._noopCallback = function () {}
this._headers = {
'Accept': 'application/json',
'Authorization': 'Basic ' + auth.basicAuth
}
this.versionNumber = apiVersion || 'v3'
this.lastQueryTime = 0
this.setContextPath()
} | javascript | function SendMessage (auth, apiVersion) {
if (!(this instanceof SendMessage)) return new SendMessage(auth, apiVersion)
this._noopCallback = function () {}
this._headers = {
'Accept': 'application/json',
'Authorization': 'Basic ' + auth.basicAuth
}
this.versionNumber = apiVersion || 'v3'
this.lastQueryTime = 0
this.setContextPath()
} | [
"function",
"SendMessage",
"(",
"auth",
",",
"apiVersion",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"SendMessage",
")",
")",
"return",
"new",
"SendMessage",
"(",
"auth",
",",
"apiVersion",
")",
"this",
".",
"_noopCallback",
"=",
"function",
"(",
")",
"{",
"}",
"this",
".",
"_headers",
"=",
"{",
"'Accept'",
":",
"'application/json'",
",",
"'Authorization'",
":",
"'Basic '",
"+",
"auth",
".",
"basicAuth",
"}",
"this",
".",
"versionNumber",
"=",
"apiVersion",
"||",
"'v3'",
"this",
".",
"lastQueryTime",
"=",
"0",
"this",
".",
"setContextPath",
"(",
")",
"}"
]
| The main constructor used for sending messages
@param {Auth} auth The authentication details
@param {String} apiVersion The API version to use for request (Versioned API) | [
"The",
"main",
"constructor",
"used",
"for",
"sending",
"messages"
]
| cfb33bb6b5b02d54125bed67365a5b174a1ad562 | https://github.com/ngenerio/smsghjs/blob/cfb33bb6b5b02d54125bed67365a5b174a1ad562/lib/sendmsg.js#L12-L22 |
45,423 | express-go/express-go | lib/Boot/Boot.js | Init | function Init(appGlobal, pathsList) {
debug("Initializing Boot");
loadFinder = new Finder();
loadProvider = new Provider();
loadNamespace = new Namespace();
global = appGlobal;
global.App = {};
global.Modules = {};
global.Config = {};
this.initProviders(sortProvider);
this.initApplication();
this.initModules();
var mainApp = require("../express");
this.boot(mainApp);
mainApp.boot = function (nameProvider, userApp) {
debug("Booting Manual Provider");
loadProvider.bootProvider(nameProvider, userApp ? userApp : mainApp);
};
mainApp.provider = function (nameProvider) {
debug("Getting " + nameProvider + " Provider");
return loadProvider.providerByName(nameProvider).instance;
};
return mainApp;
} | javascript | function Init(appGlobal, pathsList) {
debug("Initializing Boot");
loadFinder = new Finder();
loadProvider = new Provider();
loadNamespace = new Namespace();
global = appGlobal;
global.App = {};
global.Modules = {};
global.Config = {};
this.initProviders(sortProvider);
this.initApplication();
this.initModules();
var mainApp = require("../express");
this.boot(mainApp);
mainApp.boot = function (nameProvider, userApp) {
debug("Booting Manual Provider");
loadProvider.bootProvider(nameProvider, userApp ? userApp : mainApp);
};
mainApp.provider = function (nameProvider) {
debug("Getting " + nameProvider + " Provider");
return loadProvider.providerByName(nameProvider).instance;
};
return mainApp;
} | [
"function",
"Init",
"(",
"appGlobal",
",",
"pathsList",
")",
"{",
"debug",
"(",
"\"Initializing Boot\"",
")",
";",
"loadFinder",
"=",
"new",
"Finder",
"(",
")",
";",
"loadProvider",
"=",
"new",
"Provider",
"(",
")",
";",
"loadNamespace",
"=",
"new",
"Namespace",
"(",
")",
";",
"global",
"=",
"appGlobal",
";",
"global",
".",
"App",
"=",
"{",
"}",
";",
"global",
".",
"Modules",
"=",
"{",
"}",
";",
"global",
".",
"Config",
"=",
"{",
"}",
";",
"this",
".",
"initProviders",
"(",
"sortProvider",
")",
";",
"this",
".",
"initApplication",
"(",
")",
";",
"this",
".",
"initModules",
"(",
")",
";",
"var",
"mainApp",
"=",
"require",
"(",
"\"../express\"",
")",
";",
"this",
".",
"boot",
"(",
"mainApp",
")",
";",
"mainApp",
".",
"boot",
"=",
"function",
"(",
"nameProvider",
",",
"userApp",
")",
"{",
"debug",
"(",
"\"Booting Manual Provider\"",
")",
";",
"loadProvider",
".",
"bootProvider",
"(",
"nameProvider",
",",
"userApp",
"?",
"userApp",
":",
"mainApp",
")",
";",
"}",
";",
"mainApp",
".",
"provider",
"=",
"function",
"(",
"nameProvider",
")",
"{",
"debug",
"(",
"\"Getting \"",
"+",
"nameProvider",
"+",
"\" Provider\"",
")",
";",
"return",
"loadProvider",
".",
"providerByName",
"(",
"nameProvider",
")",
".",
"instance",
";",
"}",
";",
"return",
"mainApp",
";",
"}"
]
| Loading components, objects
@param appGlobal
@param pathsList | [
"Loading",
"components",
"objects"
]
| d8da60bc2046380528464a827c43de4f75c5b2d7 | https://github.com/express-go/express-go/blob/d8da60bc2046380528464a827c43de4f75c5b2d7/lib/Boot/Boot.js#L37-L60 |
45,424 | cfpb/AtomicComponent | src/utilities/object-assign/index.js | assign | function assign( destination ) {
destination = destination || {};
for ( let i = 1, len = arguments.length; i < len; i++ ) {
const source = arguments[i] || {};
for ( const key in source ) {
if ( Object.prototype.hasOwnProperty.call( source, key ) ) {
const value = source[key];
if ( _isPlainObject( value ) ) {
assign( destination[key] || ( destination[key] = {} ), value );
} else {
destination[key] = value;
}
}
}
}
return destination;
} | javascript | function assign( destination ) {
destination = destination || {};
for ( let i = 1, len = arguments.length; i < len; i++ ) {
const source = arguments[i] || {};
for ( const key in source ) {
if ( Object.prototype.hasOwnProperty.call( source, key ) ) {
const value = source[key];
if ( _isPlainObject( value ) ) {
assign( destination[key] || ( destination[key] = {} ), value );
} else {
destination[key] = value;
}
}
}
}
return destination;
} | [
"function",
"assign",
"(",
"destination",
")",
"{",
"destination",
"=",
"destination",
"||",
"{",
"}",
";",
"for",
"(",
"let",
"i",
"=",
"1",
",",
"len",
"=",
"arguments",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"const",
"source",
"=",
"arguments",
"[",
"i",
"]",
"||",
"{",
"}",
";",
"for",
"(",
"const",
"key",
"in",
"source",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"source",
",",
"key",
")",
")",
"{",
"const",
"value",
"=",
"source",
"[",
"key",
"]",
";",
"if",
"(",
"_isPlainObject",
"(",
"value",
")",
")",
"{",
"assign",
"(",
"destination",
"[",
"key",
"]",
"||",
"(",
"destination",
"[",
"key",
"]",
"=",
"{",
"}",
")",
",",
"value",
")",
";",
"}",
"else",
"{",
"destination",
"[",
"key",
"]",
"=",
"value",
";",
"}",
"}",
"}",
"}",
"return",
"destination",
";",
"}"
]
| Copies properties of all sources to the destination object overriding its own
existing properties. When assigning from multiple sources, fields of every
next source will override same named fields of previous sources.
@param {Object} destination object.
@returns {Object} assigned destination object. | [
"Copies",
"properties",
"of",
"all",
"sources",
"to",
"the",
"destination",
"object",
"overriding",
"its",
"own",
"existing",
"properties",
".",
"When",
"assigning",
"from",
"multiple",
"sources",
"fields",
"of",
"every",
"next",
"source",
"will",
"override",
"same",
"named",
"fields",
"of",
"previous",
"sources",
"."
]
| f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/object-assign/index.js#L29-L46 |
45,425 | briancsparks/js-aws | lib/ec2/ec2.js | function(dbg, raFn, subName, g, name, argv_, context, outerCallback, callback) {
var argv = _.extend({}, argv_);
g[name] = {};
return raFn(argv, context, function(err, result_) {
if (err) { return sg.die(err, outerCallback, 'fetching '+name); }
var result = subName ? result_[subName] : result_;
if (_.isArray(result)) {
g[name] = [];
_.each(result, function(value) {
g[name].push(value);
});
} else {
_.each(result, function(value, key) {
g[name][key] = value;
});
}
// Get from prod
var argv2 = _.extend({}, argv_, jsaws.getAcct('pub', process.env.JSAWS_AWS_ACCT_EXTRA_CREDS), {session:'prod'});
return raFn(argv2, context, function(err, result_) {
if (err) { return sg.die(err, outerCallback, 'fetching '+name); }
var result = subName ? result_[subName] : result_;
if (_.isArray(result)) {
_.each(result, function(value) {
g[name].push(value);
});
} else {
_.each(result, function(value, key) {
g[name][key] = value;
});
}
return callback.apply(this, arguments);
});
});
} | javascript | function(dbg, raFn, subName, g, name, argv_, context, outerCallback, callback) {
var argv = _.extend({}, argv_);
g[name] = {};
return raFn(argv, context, function(err, result_) {
if (err) { return sg.die(err, outerCallback, 'fetching '+name); }
var result = subName ? result_[subName] : result_;
if (_.isArray(result)) {
g[name] = [];
_.each(result, function(value) {
g[name].push(value);
});
} else {
_.each(result, function(value, key) {
g[name][key] = value;
});
}
// Get from prod
var argv2 = _.extend({}, argv_, jsaws.getAcct('pub', process.env.JSAWS_AWS_ACCT_EXTRA_CREDS), {session:'prod'});
return raFn(argv2, context, function(err, result_) {
if (err) { return sg.die(err, outerCallback, 'fetching '+name); }
var result = subName ? result_[subName] : result_;
if (_.isArray(result)) {
_.each(result, function(value) {
g[name].push(value);
});
} else {
_.each(result, function(value, key) {
g[name][key] = value;
});
}
return callback.apply(this, arguments);
});
});
} | [
"function",
"(",
"dbg",
",",
"raFn",
",",
"subName",
",",
"g",
",",
"name",
",",
"argv_",
",",
"context",
",",
"outerCallback",
",",
"callback",
")",
"{",
"var",
"argv",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"argv_",
")",
";",
"g",
"[",
"name",
"]",
"=",
"{",
"}",
";",
"return",
"raFn",
"(",
"argv",
",",
"context",
",",
"function",
"(",
"err",
",",
"result_",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"sg",
".",
"die",
"(",
"err",
",",
"outerCallback",
",",
"'fetching '",
"+",
"name",
")",
";",
"}",
"var",
"result",
"=",
"subName",
"?",
"result_",
"[",
"subName",
"]",
":",
"result_",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"result",
")",
")",
"{",
"g",
"[",
"name",
"]",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"result",
",",
"function",
"(",
"value",
")",
"{",
"g",
"[",
"name",
"]",
".",
"push",
"(",
"value",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"_",
".",
"each",
"(",
"result",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"g",
"[",
"name",
"]",
"[",
"key",
"]",
"=",
"value",
";",
"}",
")",
";",
"}",
"// Get from prod",
"var",
"argv2",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"argv_",
",",
"jsaws",
".",
"getAcct",
"(",
"'pub'",
",",
"process",
".",
"env",
".",
"JSAWS_AWS_ACCT_EXTRA_CREDS",
")",
",",
"{",
"session",
":",
"'prod'",
"}",
")",
";",
"return",
"raFn",
"(",
"argv2",
",",
"context",
",",
"function",
"(",
"err",
",",
"result_",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"sg",
".",
"die",
"(",
"err",
",",
"outerCallback",
",",
"'fetching '",
"+",
"name",
")",
";",
"}",
"var",
"result",
"=",
"subName",
"?",
"result_",
"[",
"subName",
"]",
":",
"result_",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"result",
")",
")",
"{",
"_",
".",
"each",
"(",
"result",
",",
"function",
"(",
"value",
")",
"{",
"g",
"[",
"name",
"]",
".",
"push",
"(",
"value",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"_",
".",
"each",
"(",
"result",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"g",
"[",
"name",
"]",
"[",
"key",
"]",
"=",
"value",
";",
"}",
")",
";",
"}",
"return",
"callback",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
]
| fetch, using creds, not contacting server in the other acct | [
"fetch",
"using",
"creds",
"not",
"contacting",
"server",
"in",
"the",
"other",
"acct"
]
| bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L1744-L1785 |
|
45,426 | briancsparks/js-aws | lib/ec2/ec2.js | getUserdata0_ | function getUserdata0_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
format("if ! [ -d /home/%s ]; then", username),
format(" usermod -l %s %s", username, origUsername),
format(" groupmod -n %s %s", username, origUsername),
format(" usermod -d /home/%s -m %s", username, username),
"fi",
format("if [ -f /etc/sudoers.d/90-cloudimg-%s ]; then", origUsername),
format(" mv /etc/sudoers.d/90-cloudimg-%s /etc/sudoers.d/90-cloud-init-users", origUsername),
"fi",
format("perl -pi -e 's/%s/%s/g;' /etc/sudoers.d/90-cloud-init-users", origUsername, username),
"if ! grep `hostname` /etc/hosts; then",
" echo \"127.0.0.1 `hostname`\" | sudo tee -a /etc/hosts",
"fi",
""
];
_.each(envVars, function(value, key) {
script.push("echo "+key+"="+value+" | sudo tee -a /etc/environment");
});
script.push( "");
console.error(script);
return script;
} | javascript | function getUserdata0_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
format("if ! [ -d /home/%s ]; then", username),
format(" usermod -l %s %s", username, origUsername),
format(" groupmod -n %s %s", username, origUsername),
format(" usermod -d /home/%s -m %s", username, username),
"fi",
format("if [ -f /etc/sudoers.d/90-cloudimg-%s ]; then", origUsername),
format(" mv /etc/sudoers.d/90-cloudimg-%s /etc/sudoers.d/90-cloud-init-users", origUsername),
"fi",
format("perl -pi -e 's/%s/%s/g;' /etc/sudoers.d/90-cloud-init-users", origUsername, username),
"if ! grep `hostname` /etc/hosts; then",
" echo \"127.0.0.1 `hostname`\" | sudo tee -a /etc/hosts",
"fi",
""
];
_.each(envVars, function(value, key) {
script.push("echo "+key+"="+value+" | sudo tee -a /etc/environment");
});
script.push( "");
console.error(script);
return script;
} | [
"function",
"getUserdata0_",
"(",
"username",
",",
"upNamespace",
",",
"envVars_",
",",
"origUsername",
")",
"{",
"var",
"envVars",
"=",
"cleanEnvVars",
"(",
"upNamespace",
",",
"envVars_",
")",
";",
"var",
"script",
"=",
"[",
"\"#!/bin/bash -ex\"",
",",
"format",
"(",
"\"if ! [ -d /home/%s ]; then\"",
",",
"username",
")",
",",
"format",
"(",
"\" usermod -l %s %s\"",
",",
"username",
",",
"origUsername",
")",
",",
"format",
"(",
"\" groupmod -n %s %s\"",
",",
"username",
",",
"origUsername",
")",
",",
"format",
"(",
"\" usermod -d /home/%s -m %s\"",
",",
"username",
",",
"username",
")",
",",
"\"fi\"",
",",
"format",
"(",
"\"if [ -f /etc/sudoers.d/90-cloudimg-%s ]; then\"",
",",
"origUsername",
")",
",",
"format",
"(",
"\" mv /etc/sudoers.d/90-cloudimg-%s /etc/sudoers.d/90-cloud-init-users\"",
",",
"origUsername",
")",
",",
"\"fi\"",
",",
"format",
"(",
"\"perl -pi -e 's/%s/%s/g;' /etc/sudoers.d/90-cloud-init-users\"",
",",
"origUsername",
",",
"username",
")",
",",
"\"if ! grep `hostname` /etc/hosts; then\"",
",",
"\" echo \\\"127.0.0.1 `hostname`\\\" | sudo tee -a /etc/hosts\"",
",",
"\"fi\"",
",",
"\"\"",
"]",
";",
"_",
".",
"each",
"(",
"envVars",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"script",
".",
"push",
"(",
"\"echo \"",
"+",
"key",
"+",
"\"=\"",
"+",
"value",
"+",
"\" | sudo tee -a /etc/environment\"",
")",
";",
"}",
")",
";",
"script",
".",
"push",
"(",
"\"\"",
")",
";",
"console",
".",
"error",
"(",
"script",
")",
";",
"return",
"script",
";",
"}"
]
| The userdata for when starting an instance from a base-image.
Basically, it renames the default 'ubuntu' user to 'scotty'; manages
/etc/hosts, and sets a couple of system-wide env vars. | [
"The",
"userdata",
"for",
"when",
"starting",
"an",
"instance",
"from",
"a",
"base",
"-",
"image",
"."
]
| bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2539-L2567 |
45,427 | briancsparks/js-aws | lib/ec2/ec2.js | getUserdataForAmi_ | function getUserdataForAmi_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
""
];
_.each(envVars, function(value, key) {
script.push("/usr/local/bin/yoshi-set-env "+key+" "+value);
});
script.push( "");
console.error(script);
return script;
} | javascript | function getUserdataForAmi_(username, upNamespace, envVars_, origUsername) {
var envVars = cleanEnvVars(upNamespace, envVars_);
var script = [
"#!/bin/bash -ex",
""
];
_.each(envVars, function(value, key) {
script.push("/usr/local/bin/yoshi-set-env "+key+" "+value);
});
script.push( "");
console.error(script);
return script;
} | [
"function",
"getUserdataForAmi_",
"(",
"username",
",",
"upNamespace",
",",
"envVars_",
",",
"origUsername",
")",
"{",
"var",
"envVars",
"=",
"cleanEnvVars",
"(",
"upNamespace",
",",
"envVars_",
")",
";",
"var",
"script",
"=",
"[",
"\"#!/bin/bash -ex\"",
",",
"\"\"",
"]",
";",
"_",
".",
"each",
"(",
"envVars",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"script",
".",
"push",
"(",
"\"/usr/local/bin/yoshi-set-env \"",
"+",
"key",
"+",
"\" \"",
"+",
"value",
")",
";",
"}",
")",
";",
"script",
".",
"push",
"(",
"\"\"",
")",
";",
"console",
".",
"error",
"(",
"script",
")",
";",
"return",
"script",
";",
"}"
]
| The userdata for when starting an instance from a created AMI. | [
"The",
"userdata",
"for",
"when",
"starting",
"an",
"instance",
"from",
"a",
"created",
"AMI",
"."
]
| bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2578-L2592 |
45,428 | briancsparks/js-aws | lib/ec2/ec2.js | taggedAs | function taggedAs(taggedItem, name, namespace, namespaceEx) {
var tags = taggedItem.tags || taggedItem.Tags;
if (!namespace) { return /* undefined */; }
if (!tags) { return /* undefined */; }
// The new, improved way (item.namespace=foo && item[name]=value)
if (tags.namespace === namespace) {
if (name in tags) { return tags[name]; }
}
if (tags[namespace] && (name in tags[namespace])) { return tags[namespace][name]; }
if (!namespaceEx) { return /* undefined */; }
if (tags[namespaceEx] && (name in tags[namespaceEx])) { return tags[namespaceEx][name]; }
return /* undefined */;
} | javascript | function taggedAs(taggedItem, name, namespace, namespaceEx) {
var tags = taggedItem.tags || taggedItem.Tags;
if (!namespace) { return /* undefined */; }
if (!tags) { return /* undefined */; }
// The new, improved way (item.namespace=foo && item[name]=value)
if (tags.namespace === namespace) {
if (name in tags) { return tags[name]; }
}
if (tags[namespace] && (name in tags[namespace])) { return tags[namespace][name]; }
if (!namespaceEx) { return /* undefined */; }
if (tags[namespaceEx] && (name in tags[namespaceEx])) { return tags[namespaceEx][name]; }
return /* undefined */;
} | [
"function",
"taggedAs",
"(",
"taggedItem",
",",
"name",
",",
"namespace",
",",
"namespaceEx",
")",
"{",
"var",
"tags",
"=",
"taggedItem",
".",
"tags",
"||",
"taggedItem",
".",
"Tags",
";",
"if",
"(",
"!",
"namespace",
")",
"{",
"return",
"/* undefined */",
";",
"}",
"if",
"(",
"!",
"tags",
")",
"{",
"return",
"/* undefined */",
";",
"}",
"// The new, improved way (item.namespace=foo && item[name]=value)",
"if",
"(",
"tags",
".",
"namespace",
"===",
"namespace",
")",
"{",
"if",
"(",
"name",
"in",
"tags",
")",
"{",
"return",
"tags",
"[",
"name",
"]",
";",
"}",
"}",
"if",
"(",
"tags",
"[",
"namespace",
"]",
"&&",
"(",
"name",
"in",
"tags",
"[",
"namespace",
"]",
")",
")",
"{",
"return",
"tags",
"[",
"namespace",
"]",
"[",
"name",
"]",
";",
"}",
"if",
"(",
"!",
"namespaceEx",
")",
"{",
"return",
"/* undefined */",
";",
"}",
"if",
"(",
"tags",
"[",
"namespaceEx",
"]",
"&&",
"(",
"name",
"in",
"tags",
"[",
"namespaceEx",
"]",
")",
")",
"{",
"return",
"tags",
"[",
"namespaceEx",
"]",
"[",
"name",
"]",
";",
"}",
"return",
"/* undefined */",
";",
"}"
]
| Returns the tag, and knows a few different styles. | [
"Returns",
"the",
"tag",
"and",
"knows",
"a",
"few",
"different",
"styles",
"."
]
| bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2709-L2726 |
45,429 | briancsparks/js-aws | lib/ec2/ec2.js | isTaggedAs | function isTaggedAs(taggedItem, name, value, namespace, namespaceEx) {
return taggedAs(taggedItem, name, namespace, namespaceEx) == value; // == is intentional
} | javascript | function isTaggedAs(taggedItem, name, value, namespace, namespaceEx) {
return taggedAs(taggedItem, name, namespace, namespaceEx) == value; // == is intentional
} | [
"function",
"isTaggedAs",
"(",
"taggedItem",
",",
"name",
",",
"value",
",",
"namespace",
",",
"namespaceEx",
")",
"{",
"return",
"taggedAs",
"(",
"taggedItem",
",",
"name",
",",
"namespace",
",",
"namespaceEx",
")",
"==",
"value",
";",
"// == is intentional",
"}"
]
| Returns true if the item is tagged with the value. | [
"Returns",
"true",
"if",
"the",
"item",
"is",
"tagged",
"with",
"the",
"value",
"."
]
| bb403415a1de754e6dee2238d3b5fb9bf5a2bf15 | https://github.com/briancsparks/js-aws/blob/bb403415a1de754e6dee2238d3b5fb9bf5a2bf15/lib/ec2/ec2.js#L2731-L2733 |
45,430 | Sobesednik/wrote | es5/src/create-writable.js | createWritable | function createWritable() {
var $args = arguments;return new Promise(function ($return, $error) {
var file, ws;
file = $args.length > 0 && $args[0] !== undefined ? $args[0] : getTempFile();
return Promise.resolve(openFileForWrite(file)).then(function ($await_2) {
try {
ws = $await_2;
return $return(ws);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
} | javascript | function createWritable() {
var $args = arguments;return new Promise(function ($return, $error) {
var file, ws;
file = $args.length > 0 && $args[0] !== undefined ? $args[0] : getTempFile();
return Promise.resolve(openFileForWrite(file)).then(function ($await_2) {
try {
ws = $await_2;
return $return(ws);
} catch ($boundEx) {
return $error($boundEx);
}
}.bind(this), $error);
}.bind(this));
} | [
"function",
"createWritable",
"(",
")",
"{",
"var",
"$args",
"=",
"arguments",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"$return",
",",
"$error",
")",
"{",
"var",
"file",
",",
"ws",
";",
"file",
"=",
"$args",
".",
"length",
">",
"0",
"&&",
"$args",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"$args",
"[",
"0",
"]",
":",
"getTempFile",
"(",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
"openFileForWrite",
"(",
"file",
")",
")",
".",
"then",
"(",
"function",
"(",
"$await_2",
")",
"{",
"try",
"{",
"ws",
"=",
"$await_2",
";",
"return",
"$return",
"(",
"ws",
")",
";",
"}",
"catch",
"(",
"$boundEx",
")",
"{",
"return",
"$error",
"(",
"$boundEx",
")",
";",
"}",
"}",
".",
"bind",
"(",
"this",
")",
",",
"$error",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
]
| Open the file for writing and create a write stream.
@param {string} ffile path to the file
@returns {Promise<Writable>} A promise with the stream | [
"Open",
"the",
"file",
"for",
"writing",
"and",
"create",
"a",
"write",
"stream",
"."
]
| 24992ad3bba4e5959dfb617b6c1f22d9a1306ab9 | https://github.com/Sobesednik/wrote/blob/24992ad3bba4e5959dfb617b6c1f22d9a1306ab9/es5/src/create-writable.js#L47-L60 |
45,431 | feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | list | function list(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions", params);
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.admin(params, cb);
} | javascript | function list(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions", params);
var method = "GET";
var data = {};
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
mbaasRequest.admin(params, cb);
} | [
"function",
"list",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"GET\"",
";",
"var",
"data",
"=",
"{",
"}",
";",
"params",
".",
"resourcePath",
"=",
"resourcePath",
";",
"params",
".",
"method",
"=",
"method",
";",
"params",
".",
"data",
"=",
"data",
";",
"mbaasRequest",
".",
"admin",
"(",
"params",
",",
"cb",
")",
";",
"}"
]
| List Submissions For An Environment
@param params
@param {object} params.paginate
@param {number} params.paginate.page Page to get
@param {number} params.paginate.limit Entries Per Page
@param cb | [
"List",
"Submissions",
"For",
"An",
"Environment"
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L13-L23 |
45,432 | feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | updateFile | function updateFile(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/fields/:fieldId/files/:fileId", params);
var method = "PUT";
var data = params.fileDetails;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
params.fileRequest = true;
params.fileUploadRequest = true;
mbaasRequest.admin(params, cb);
} | javascript | function updateFile(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/fields/:fieldId/files/:fileId", params);
var method = "PUT";
var data = params.fileDetails;
params.resourcePath = resourcePath;
params.method = method;
params.data = data;
params.fileRequest = true;
params.fileUploadRequest = true;
mbaasRequest.admin(params, cb);
} | [
"function",
"updateFile",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions/:id/fields/:fieldId/files/:fileId\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"PUT\"",
";",
"var",
"data",
"=",
"params",
".",
"fileDetails",
";",
"params",
".",
"resourcePath",
"=",
"resourcePath",
";",
"params",
".",
"method",
"=",
"method",
";",
"params",
".",
"data",
"=",
"data",
";",
"params",
".",
"fileRequest",
"=",
"true",
";",
"params",
".",
"fileUploadRequest",
"=",
"true",
";",
"mbaasRequest",
".",
"admin",
"(",
"params",
",",
"cb",
")",
";",
"}"
]
| Update A File For A Submission
@param {object} params
@param {string} params.id The submission ID (The submission should already exist)
@param {string} params.domain The Domain
@param {string} params.environment The Environment ID to upload To
@param {string} params.fieldId The ID of the file field the file should be associated with.
@param {string} params.fileId The ID of the file. It must already exist
@param {object} params.fileDetails The Details of the file to be uploaded
@param {string} params.fileDetails.stream A Readable file stream
@param {string} params.fileDetails.name The name of the file
@param {number} params.fileDetails.size The size of the file (In Bytes)
@param {string} params.fileDetails.type The mime type of the file
@param cb | [
"Update",
"A",
"File",
"For",
"A",
"Submission"
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L101-L114 |
45,433 | feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | filterSubmissions | function filterSubmissions(params, cb) {
params.resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/filter", params);
params.method = "POST";
params.data = params.filterParams;
mbaasRequest.admin(params, cb);
} | javascript | function filterSubmissions(params, cb) {
params.resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/filter", params);
params.method = "POST";
params.data = params.filterParams;
mbaasRequest.admin(params, cb);
} | [
"function",
"filterSubmissions",
"(",
"params",
",",
"cb",
")",
"{",
"params",
".",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions/filter\"",
",",
"params",
")",
";",
"params",
".",
"method",
"=",
"\"POST\"",
";",
"params",
".",
"data",
"=",
"params",
".",
"filterParams",
";",
"mbaasRequest",
".",
"admin",
"(",
"params",
",",
"cb",
")",
";",
"}"
]
| Filtering Submissions From An Environment Mbaas.
Forms Can Be Filtered By form ID or Project ID
@param {object} params.pagination
@param {number} params.pagination.page Page to get
@param {number} params.pagination.limit Entries Per Page
@param cb | [
"Filtering",
"Submissions",
"From",
"An",
"Environment",
"Mbaas",
"."
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L189-L195 |
45,434 | feedhenry/fh-mbaas-client | lib/admin/appforms/submissions.js | getSubmissionPDF | function getSubmissionPDF(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/exportpdf", params);
var method = "POST";
params.resourcePath = resourcePath;
params.method = method;
params.data = params.data || {};
params.fileRequest = true;
mbaasRequest.admin(params, cb);
} | javascript | function getSubmissionPDF(params, cb) {
var resourcePath = config.addURIParams(constants.FORMS_BASE_PATH + "/submissions/:id/exportpdf", params);
var method = "POST";
params.resourcePath = resourcePath;
params.method = method;
params.data = params.data || {};
params.fileRequest = true;
mbaasRequest.admin(params, cb);
} | [
"function",
"getSubmissionPDF",
"(",
"params",
",",
"cb",
")",
"{",
"var",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"FORMS_BASE_PATH",
"+",
"\"/submissions/:id/exportpdf\"",
",",
"params",
")",
";",
"var",
"method",
"=",
"\"POST\"",
";",
"params",
".",
"resourcePath",
"=",
"resourcePath",
";",
"params",
".",
"method",
"=",
"method",
";",
"params",
".",
"data",
"=",
"params",
".",
"data",
"||",
"{",
"}",
";",
"params",
".",
"fileRequest",
"=",
"true",
";",
"mbaasRequest",
".",
"admin",
"(",
"params",
",",
"cb",
")",
";",
"}"
]
| Getting A PDF Of A Submission
@param params
@param params.data
@param params.data.coreLocation - The host name of the domain accessing the PDF.
@param cb | [
"Getting",
"A",
"PDF",
"Of",
"A",
"Submission"
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/appforms/submissions.js#L243-L254 |
45,435 | eoaranda/mta-metro | lib/metronorth.js | function(key,options){
this.key = key;
var route = "",
dayroute = "",
timeroute = "",
debug = false;
if (!this.key || this.key == "" || this.key == "<YOU-API-KEY>") {
throw new Error('MTA API key missing or incorrect.');
}
if (options.debug){
debug = options.debug;
}
if (options.from.id && options.to.id) {
route = options.from.id + "/" + options.to.id;
}else{
throw new Error('You forgot to provide an origin or a destiny.');
}
//date part
if (options.day >= UTILS.nowDate()) {
let dayParts= options.day.split("-");
dayroute = dayParts[0] + "/" + dayParts[1] + "/" + dayParts[2];
} else {
let dayParts= UTILS.nowDate().split("-");
dayroute = dayParts[0] + "/" + dayParts[1] + "/" + dayParts[2];
}
//time part
if (options.time >= UTILS.nowTime) {
timeroute = options.time.replace(/:/g, '');
} else {
timeroute = UTILS.nowTime().replace(/:/g, '');
}
let json_req_url = API_URL + "/" + API_VER + "/" + route + "/DepartBy/" + dayroute + "/" + timeroute + "/" + this.key + "/" + API_FILE;
return new Promise(function (resolve, reject) {
if(debug==true){
resolve(json_req_url);
}else{
FETCH(json_req_url)
.then(
data => resolve(data.json())
).catch(
err => reject("Error: Unable to parse response as JSON: " + err.message)
);
}
});
} | javascript | function(key,options){
this.key = key;
var route = "",
dayroute = "",
timeroute = "",
debug = false;
if (!this.key || this.key == "" || this.key == "<YOU-API-KEY>") {
throw new Error('MTA API key missing or incorrect.');
}
if (options.debug){
debug = options.debug;
}
if (options.from.id && options.to.id) {
route = options.from.id + "/" + options.to.id;
}else{
throw new Error('You forgot to provide an origin or a destiny.');
}
//date part
if (options.day >= UTILS.nowDate()) {
let dayParts= options.day.split("-");
dayroute = dayParts[0] + "/" + dayParts[1] + "/" + dayParts[2];
} else {
let dayParts= UTILS.nowDate().split("-");
dayroute = dayParts[0] + "/" + dayParts[1] + "/" + dayParts[2];
}
//time part
if (options.time >= UTILS.nowTime) {
timeroute = options.time.replace(/:/g, '');
} else {
timeroute = UTILS.nowTime().replace(/:/g, '');
}
let json_req_url = API_URL + "/" + API_VER + "/" + route + "/DepartBy/" + dayroute + "/" + timeroute + "/" + this.key + "/" + API_FILE;
return new Promise(function (resolve, reject) {
if(debug==true){
resolve(json_req_url);
}else{
FETCH(json_req_url)
.then(
data => resolve(data.json())
).catch(
err => reject("Error: Unable to parse response as JSON: " + err.message)
);
}
});
} | [
"function",
"(",
"key",
",",
"options",
")",
"{",
"this",
".",
"key",
"=",
"key",
";",
"var",
"route",
"=",
"\"\"",
",",
"dayroute",
"=",
"\"\"",
",",
"timeroute",
"=",
"\"\"",
",",
"debug",
"=",
"false",
";",
"if",
"(",
"!",
"this",
".",
"key",
"||",
"this",
".",
"key",
"==",
"\"\"",
"||",
"this",
".",
"key",
"==",
"\"<YOU-API-KEY>\"",
")",
"{",
"throw",
"new",
"Error",
"(",
"'MTA API key missing or incorrect.'",
")",
";",
"}",
"if",
"(",
"options",
".",
"debug",
")",
"{",
"debug",
"=",
"options",
".",
"debug",
";",
"}",
"if",
"(",
"options",
".",
"from",
".",
"id",
"&&",
"options",
".",
"to",
".",
"id",
")",
"{",
"route",
"=",
"options",
".",
"from",
".",
"id",
"+",
"\"/\"",
"+",
"options",
".",
"to",
".",
"id",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'You forgot to provide an origin or a destiny.'",
")",
";",
"}",
"//date part",
"if",
"(",
"options",
".",
"day",
">=",
"UTILS",
".",
"nowDate",
"(",
")",
")",
"{",
"let",
"dayParts",
"=",
"options",
".",
"day",
".",
"split",
"(",
"\"-\"",
")",
";",
"dayroute",
"=",
"dayParts",
"[",
"0",
"]",
"+",
"\"/\"",
"+",
"dayParts",
"[",
"1",
"]",
"+",
"\"/\"",
"+",
"dayParts",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"let",
"dayParts",
"=",
"UTILS",
".",
"nowDate",
"(",
")",
".",
"split",
"(",
"\"-\"",
")",
";",
"dayroute",
"=",
"dayParts",
"[",
"0",
"]",
"+",
"\"/\"",
"+",
"dayParts",
"[",
"1",
"]",
"+",
"\"/\"",
"+",
"dayParts",
"[",
"2",
"]",
";",
"}",
"//time part",
"if",
"(",
"options",
".",
"time",
">=",
"UTILS",
".",
"nowTime",
")",
"{",
"timeroute",
"=",
"options",
".",
"time",
".",
"replace",
"(",
"/",
":",
"/",
"g",
",",
"''",
")",
";",
"}",
"else",
"{",
"timeroute",
"=",
"UTILS",
".",
"nowTime",
"(",
")",
".",
"replace",
"(",
"/",
":",
"/",
"g",
",",
"''",
")",
";",
"}",
"let",
"json_req_url",
"=",
"API_URL",
"+",
"\"/\"",
"+",
"API_VER",
"+",
"\"/\"",
"+",
"route",
"+",
"\"/DepartBy/\"",
"+",
"dayroute",
"+",
"\"/\"",
"+",
"timeroute",
"+",
"\"/\"",
"+",
"this",
".",
"key",
"+",
"\"/\"",
"+",
"API_FILE",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"if",
"(",
"debug",
"==",
"true",
")",
"{",
"resolve",
"(",
"json_req_url",
")",
";",
"}",
"else",
"{",
"FETCH",
"(",
"json_req_url",
")",
".",
"then",
"(",
"data",
"=>",
"resolve",
"(",
"data",
".",
"json",
"(",
")",
")",
")",
".",
"catch",
"(",
"err",
"=>",
"reject",
"(",
"\"Error: Unable to parse response as JSON: \"",
"+",
"err",
".",
"message",
")",
")",
";",
"}",
"}",
")",
";",
"}"
]
| returns an array with the schedule | [
"returns",
"an",
"array",
"with",
"the",
"schedule"
]
| f0b10c99df222b39433a9cac3e0a3debf1f053df | https://github.com/eoaranda/mta-metro/blob/f0b10c99df222b39433a9cac3e0a3debf1f053df/lib/metronorth.js#L12-L63 |
|
45,436 | specla/validator | lib/transformType.js | transformObject | function transformObject (type) {
const transformed = {}
for (let key in type) {
transformed[key] = transformType(type[key])
}
return transformed
} | javascript | function transformObject (type) {
const transformed = {}
for (let key in type) {
transformed[key] = transformType(type[key])
}
return transformed
} | [
"function",
"transformObject",
"(",
"type",
")",
"{",
"const",
"transformed",
"=",
"{",
"}",
"for",
"(",
"let",
"key",
"in",
"type",
")",
"{",
"transformed",
"[",
"key",
"]",
"=",
"transformType",
"(",
"type",
"[",
"key",
"]",
")",
"}",
"return",
"transformed",
"}"
]
| Transform an object
@param {Object} type
@return {Object} transformed object type
@private | [
"Transform",
"an",
"object"
]
| 087d3877e2dff464682b0cf07389c0ad9cfd9b85 | https://github.com/specla/validator/blob/087d3877e2dff464682b0cf07389c0ad9cfd9b85/lib/transformType.js#L46-L54 |
45,437 | specla/validator | lib/transformType.js | findType | function findType (type) {
let name = ''
const defaultTypes = [
'string',
'number',
'boolean',
'symbol',
'array',
'object'
]
try {
name = type.prototype.constructor.name.toLowerCase()
} catch (err) {}
if (defaultTypes.includes(name)) {
return types[name]()
}
return value => {
if (!(value instanceof type)) {
throw new Error(`is not instance of ${type.prototype.constructor.name}`)
}
return true
}
} | javascript | function findType (type) {
let name = ''
const defaultTypes = [
'string',
'number',
'boolean',
'symbol',
'array',
'object'
]
try {
name = type.prototype.constructor.name.toLowerCase()
} catch (err) {}
if (defaultTypes.includes(name)) {
return types[name]()
}
return value => {
if (!(value instanceof type)) {
throw new Error(`is not instance of ${type.prototype.constructor.name}`)
}
return true
}
} | [
"function",
"findType",
"(",
"type",
")",
"{",
"let",
"name",
"=",
"''",
"const",
"defaultTypes",
"=",
"[",
"'string'",
",",
"'number'",
",",
"'boolean'",
",",
"'symbol'",
",",
"'array'",
",",
"'object'",
"]",
"try",
"{",
"name",
"=",
"type",
".",
"prototype",
".",
"constructor",
".",
"name",
".",
"toLowerCase",
"(",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"}",
"if",
"(",
"defaultTypes",
".",
"includes",
"(",
"name",
")",
")",
"{",
"return",
"types",
"[",
"name",
"]",
"(",
")",
"}",
"return",
"value",
"=>",
"{",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"type",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"type",
".",
"prototype",
".",
"constructor",
".",
"name",
"}",
"`",
")",
"}",
"return",
"true",
"}",
"}"
]
| Find validator fucntion for a type
@param {Function} type
@return {Function} | [
"Find",
"validator",
"fucntion",
"for",
"a",
"type"
]
| 087d3877e2dff464682b0cf07389c0ad9cfd9b85 | https://github.com/specla/validator/blob/087d3877e2dff464682b0cf07389c0ad9cfd9b85/lib/transformType.js#L70-L96 |
45,438 | vid/SenseBase | lib/reset.js | step | function step(err, res) {
if (!err && res && res.error) {
console.log('ERR', res);
err = res.error;
}
var nextStep = steps.shift();
if (err && curStep !== 'delIndex') {
console.log('failing on', curStep, err);
console.trace();
callback(err);
return;
}
if (nextStep) {
curStep = nextStep;
var data = stepDefs[curStep].data;
utils.doPostJson(stepDefs[curStep], data, step);
} else {
callback(err, res);
}
} | javascript | function step(err, res) {
if (!err && res && res.error) {
console.log('ERR', res);
err = res.error;
}
var nextStep = steps.shift();
if (err && curStep !== 'delIndex') {
console.log('failing on', curStep, err);
console.trace();
callback(err);
return;
}
if (nextStep) {
curStep = nextStep;
var data = stepDefs[curStep].data;
utils.doPostJson(stepDefs[curStep], data, step);
} else {
callback(err, res);
}
} | [
"function",
"step",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"res",
"&&",
"res",
".",
"error",
")",
"{",
"console",
".",
"log",
"(",
"'ERR'",
",",
"res",
")",
";",
"err",
"=",
"res",
".",
"error",
";",
"}",
"var",
"nextStep",
"=",
"steps",
".",
"shift",
"(",
")",
";",
"if",
"(",
"err",
"&&",
"curStep",
"!==",
"'delIndex'",
")",
"{",
"console",
".",
"log",
"(",
"'failing on'",
",",
"curStep",
",",
"err",
")",
";",
"console",
".",
"trace",
"(",
")",
";",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"if",
"(",
"nextStep",
")",
"{",
"curStep",
"=",
"nextStep",
";",
"var",
"data",
"=",
"stepDefs",
"[",
"curStep",
"]",
".",
"data",
";",
"utils",
".",
"doPostJson",
"(",
"stepDefs",
"[",
"curStep",
"]",
",",
"data",
",",
"step",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"err",
",",
"res",
")",
";",
"}",
"}"
]
| check for an error, if no error do the next step, if no next step callback | [
"check",
"for",
"an",
"error",
"if",
"no",
"error",
"do",
"the",
"next",
"step",
"if",
"no",
"next",
"step",
"callback"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/reset.js#L168-L187 |
45,439 | feedhenry/fh-mbaas-client | lib/config/config.js | addURIParams | function addURIParams(uri, params) {
uri = uri || "";
params = params || {};
params = _.clone(params);
var keys = _.keys(params);
var separatedPath = uri.split("/");
separatedPath = _.compact(separatedPath);
//Replacing Any Path Elements
separatedPath = _.map(separatedPath, function(pathEntry) {
if (pathEntry.indexOf(":") !== 0) {
return pathEntry;
}
var key = _.find(keys, function(key) {
return (":" + key) === pathEntry;
});
if (key) {
return params[key];
} else {
return {
key: pathEntry.substring(1, pathEntry.length),
error: constants.PROPERTY_NOT_SET
};
}
});
//If the path contains an invalid parameter, return the error object
var invalidParameter = _.findWhere(separatedPath, {error: constants.PROPERTY_NOT_SET});
if (invalidParameter) {
return invalidParameter;
}
var fullPath = "";
_.each(separatedPath, function(pathElem) {
return fullPath += "/" + pathElem;
});
return fullPath;
} | javascript | function addURIParams(uri, params) {
uri = uri || "";
params = params || {};
params = _.clone(params);
var keys = _.keys(params);
var separatedPath = uri.split("/");
separatedPath = _.compact(separatedPath);
//Replacing Any Path Elements
separatedPath = _.map(separatedPath, function(pathEntry) {
if (pathEntry.indexOf(":") !== 0) {
return pathEntry;
}
var key = _.find(keys, function(key) {
return (":" + key) === pathEntry;
});
if (key) {
return params[key];
} else {
return {
key: pathEntry.substring(1, pathEntry.length),
error: constants.PROPERTY_NOT_SET
};
}
});
//If the path contains an invalid parameter, return the error object
var invalidParameter = _.findWhere(separatedPath, {error: constants.PROPERTY_NOT_SET});
if (invalidParameter) {
return invalidParameter;
}
var fullPath = "";
_.each(separatedPath, function(pathElem) {
return fullPath += "/" + pathElem;
});
return fullPath;
} | [
"function",
"addURIParams",
"(",
"uri",
",",
"params",
")",
"{",
"uri",
"=",
"uri",
"||",
"\"\"",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
"=",
"_",
".",
"clone",
"(",
"params",
")",
";",
"var",
"keys",
"=",
"_",
".",
"keys",
"(",
"params",
")",
";",
"var",
"separatedPath",
"=",
"uri",
".",
"split",
"(",
"\"/\"",
")",
";",
"separatedPath",
"=",
"_",
".",
"compact",
"(",
"separatedPath",
")",
";",
"//Replacing Any Path Elements",
"separatedPath",
"=",
"_",
".",
"map",
"(",
"separatedPath",
",",
"function",
"(",
"pathEntry",
")",
"{",
"if",
"(",
"pathEntry",
".",
"indexOf",
"(",
"\":\"",
")",
"!==",
"0",
")",
"{",
"return",
"pathEntry",
";",
"}",
"var",
"key",
"=",
"_",
".",
"find",
"(",
"keys",
",",
"function",
"(",
"key",
")",
"{",
"return",
"(",
"\":\"",
"+",
"key",
")",
"===",
"pathEntry",
";",
"}",
")",
";",
"if",
"(",
"key",
")",
"{",
"return",
"params",
"[",
"key",
"]",
";",
"}",
"else",
"{",
"return",
"{",
"key",
":",
"pathEntry",
".",
"substring",
"(",
"1",
",",
"pathEntry",
".",
"length",
")",
",",
"error",
":",
"constants",
".",
"PROPERTY_NOT_SET",
"}",
";",
"}",
"}",
")",
";",
"//If the path contains an invalid parameter, return the error object",
"var",
"invalidParameter",
"=",
"_",
".",
"findWhere",
"(",
"separatedPath",
",",
"{",
"error",
":",
"constants",
".",
"PROPERTY_NOT_SET",
"}",
")",
";",
"if",
"(",
"invalidParameter",
")",
"{",
"return",
"invalidParameter",
";",
"}",
"var",
"fullPath",
"=",
"\"\"",
";",
"_",
".",
"each",
"(",
"separatedPath",
",",
"function",
"(",
"pathElem",
")",
"{",
"return",
"fullPath",
"+=",
"\"/\"",
"+",
"pathElem",
";",
"}",
")",
";",
"return",
"fullPath",
";",
"}"
]
| Maps Parameters To Url Parameters.
@param uri
@param params
@returns {*} | [
"Maps",
"Parameters",
"To",
"Url",
"Parameters",
"."
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/config/config.js#L11-L57 |
45,440 | jquense/component-metadata-loader | lib/index.js | cleanDoclets | function cleanDoclets(desc) {
var idx = desc.indexOf('@');
return (idx === -1 ? desc : desc.substr(0, idx)).trim();
} | javascript | function cleanDoclets(desc) {
var idx = desc.indexOf('@');
return (idx === -1 ? desc : desc.substr(0, idx)).trim();
} | [
"function",
"cleanDoclets",
"(",
"desc",
")",
"{",
"var",
"idx",
"=",
"desc",
".",
"indexOf",
"(",
"'@'",
")",
";",
"return",
"(",
"idx",
"===",
"-",
"1",
"?",
"desc",
":",
"desc",
".",
"substr",
"(",
"0",
",",
"idx",
")",
")",
".",
"trim",
"(",
")",
";",
"}"
]
| removes doclet syntax from comments | [
"removes",
"doclet",
"syntax",
"from",
"comments"
]
| 07e38af2e0ad5b444ae091687f0ae4497a0a9c9f | https://github.com/jquense/component-metadata-loader/blob/07e38af2e0ad5b444ae091687f0ae4497a0a9c9f/lib/index.js#L22-L25 |
45,441 | vadr-vr/VR-Analytics-JSCore | js/dataManager/serverRequestManager.js | addDataRequest | function addDataRequest(requestDict){
logger.info('Adding request to server');
const dataRequest = _getServerRequest(requestDict);
_addRequestToDb(dataRequest).then(() => {
if (!requestingPost){
_makeRequestToServer();
}
});
} | javascript | function addDataRequest(requestDict){
logger.info('Adding request to server');
const dataRequest = _getServerRequest(requestDict);
_addRequestToDb(dataRequest).then(() => {
if (!requestingPost){
_makeRequestToServer();
}
});
} | [
"function",
"addDataRequest",
"(",
"requestDict",
")",
"{",
"logger",
".",
"info",
"(",
"'Adding request to server'",
")",
";",
"const",
"dataRequest",
"=",
"_getServerRequest",
"(",
"requestDict",
")",
";",
"_addRequestToDb",
"(",
"dataRequest",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"!",
"requestingPost",
")",
"{",
"_makeRequestToServer",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Adds request to send data in list of requests
@memberof ServerRequestManager
@param {object} requestDict The dictionary contaning data for the added request | [
"Adds",
"request",
"to",
"send",
"data",
"in",
"list",
"of",
"requests"
]
| 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/dataManager/serverRequestManager.js#L24-L40 |
45,442 | ikr/estimate-tasks | lib/calc.js | function (bestCaseHours, mostLikelyCaseHours, worstCaseHours, confidencePercent) {
var isVector = (typeof bestCaseHours === 'object')
this.bestCaseHours = isVector ? bestCaseHours[0] : bestCaseHours
this.mostLikelyCaseHours = isVector ? bestCaseHours[1] : mostLikelyCaseHours
this.worstCaseHours = isVector ? bestCaseHours[2] : worstCaseHours
this.confidencePercent = isVector ? bestCaseHours[3] : confidencePercent
} | javascript | function (bestCaseHours, mostLikelyCaseHours, worstCaseHours, confidencePercent) {
var isVector = (typeof bestCaseHours === 'object')
this.bestCaseHours = isVector ? bestCaseHours[0] : bestCaseHours
this.mostLikelyCaseHours = isVector ? bestCaseHours[1] : mostLikelyCaseHours
this.worstCaseHours = isVector ? bestCaseHours[2] : worstCaseHours
this.confidencePercent = isVector ? bestCaseHours[3] : confidencePercent
} | [
"function",
"(",
"bestCaseHours",
",",
"mostLikelyCaseHours",
",",
"worstCaseHours",
",",
"confidencePercent",
")",
"{",
"var",
"isVector",
"=",
"(",
"typeof",
"bestCaseHours",
"===",
"'object'",
")",
"this",
".",
"bestCaseHours",
"=",
"isVector",
"?",
"bestCaseHours",
"[",
"0",
"]",
":",
"bestCaseHours",
"this",
".",
"mostLikelyCaseHours",
"=",
"isVector",
"?",
"bestCaseHours",
"[",
"1",
"]",
":",
"mostLikelyCaseHours",
"this",
".",
"worstCaseHours",
"=",
"isVector",
"?",
"bestCaseHours",
"[",
"2",
"]",
":",
"worstCaseHours",
"this",
".",
"confidencePercent",
"=",
"isVector",
"?",
"bestCaseHours",
"[",
"3",
"]",
":",
"confidencePercent",
"}"
]
| bestCaseHours <= mostLikelyCaseHours <= worstCaseHours
Minimum possible confidencePercent is 10 | [
"bestCaseHours",
"<",
"=",
"mostLikelyCaseHours",
"<",
"=",
"worstCaseHours",
"Minimum",
"possible",
"confidencePercent",
"is",
"10"
]
| a5fd271b8a1bc23257694673e42bf8f9dbd2ec40 | https://github.com/ikr/estimate-tasks/blob/a5fd271b8a1bc23257694673e42bf8f9dbd2ec40/lib/calc.js#L19-L26 |
|
45,443 | uniphil/xxs | xxs.js | createUpdater | function createUpdater(actionUpdates) {
if (process.env.NODE_ENV !== 'production') {
// Ensure that all values are functions
Object.getOwnPropertySymbols(actionUpdates).concat(Object.keys(actionUpdates))
.filter(k => typeof actionUpdates[k] !== 'function')
.forEach(k => { throw new Error(`Expected a ((state, payload) => state) function for action '${k.toString()}' but found '${actionUpdates[k].toString()}'`); });
}
// If we have this action as a key, call it's value to update state, otherwise
// pass through the state.
return (state, action, payload) =>
actionUpdates[action] ? actionUpdates[action](state, payload) : state;
} | javascript | function createUpdater(actionUpdates) {
if (process.env.NODE_ENV !== 'production') {
// Ensure that all values are functions
Object.getOwnPropertySymbols(actionUpdates).concat(Object.keys(actionUpdates))
.filter(k => typeof actionUpdates[k] !== 'function')
.forEach(k => { throw new Error(`Expected a ((state, payload) => state) function for action '${k.toString()}' but found '${actionUpdates[k].toString()}'`); });
}
// If we have this action as a key, call it's value to update state, otherwise
// pass through the state.
return (state, action, payload) =>
actionUpdates[action] ? actionUpdates[action](state, payload) : state;
} | [
"function",
"createUpdater",
"(",
"actionUpdates",
")",
"{",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
")",
"{",
"// Ensure that all values are functions",
"Object",
".",
"getOwnPropertySymbols",
"(",
"actionUpdates",
")",
".",
"concat",
"(",
"Object",
".",
"keys",
"(",
"actionUpdates",
")",
")",
".",
"filter",
"(",
"k",
"=>",
"typeof",
"actionUpdates",
"[",
"k",
"]",
"!==",
"'function'",
")",
".",
"forEach",
"(",
"k",
"=>",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"k",
".",
"toString",
"(",
")",
"}",
"${",
"actionUpdates",
"[",
"k",
"]",
".",
"toString",
"(",
")",
"}",
"`",
")",
";",
"}",
")",
";",
"}",
"// If we have this action as a key, call it's value to update state, otherwise",
"// pass through the state.",
"return",
"(",
"state",
",",
"action",
",",
"payload",
")",
"=>",
"actionUpdates",
"[",
"action",
"]",
"?",
"actionUpdates",
"[",
"action",
"]",
"(",
"state",
",",
"payload",
")",
":",
"state",
";",
"}"
]
| A helper to generate updater functions mapped by action
@param {object} actionUpdates An object with Actions (strings or symbols) as
keys and ((state, payload) => nextState) functions as values
@returns {function} An updater function ((state, action, payload) => nextState) | [
"A",
"helper",
"to",
"generate",
"updater",
"functions",
"mapped",
"by",
"action"
]
| 44b559e491f568756c41f6fbdd26420b6393189d | https://github.com/uniphil/xxs/blob/44b559e491f568756c41f6fbdd26420b6393189d/xxs.js#L56-L67 |
45,444 | uniphil/xxs | xxs.js | dispatch | function dispatch(action, payload) {
if (process.env.NODE_ENV !== 'production' && dispatching) {
throw new Error(`'${action.toString()}' was dispatched while '${dispatching.toString()}' was still updating. Updaters should be pure functions and must not dispatch actions.`);
}
try {
dispatching = action;
state = updater(state, action, payload);
if (process.env.NODE_ENV !== 'production' && debug) {
console.info(state);
}
} finally {
dispatching = null;
}
updateUI();
} | javascript | function dispatch(action, payload) {
if (process.env.NODE_ENV !== 'production' && dispatching) {
throw new Error(`'${action.toString()}' was dispatched while '${dispatching.toString()}' was still updating. Updaters should be pure functions and must not dispatch actions.`);
}
try {
dispatching = action;
state = updater(state, action, payload);
if (process.env.NODE_ENV !== 'production' && debug) {
console.info(state);
}
} finally {
dispatching = null;
}
updateUI();
} | [
"function",
"dispatch",
"(",
"action",
",",
"payload",
")",
"{",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
"&&",
"dispatching",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"action",
".",
"toString",
"(",
")",
"}",
"${",
"dispatching",
".",
"toString",
"(",
")",
"}",
"`",
")",
";",
"}",
"try",
"{",
"dispatching",
"=",
"action",
";",
"state",
"=",
"updater",
"(",
"state",
",",
"action",
",",
"payload",
")",
";",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!==",
"'production'",
"&&",
"debug",
")",
"{",
"console",
".",
"info",
"(",
"state",
")",
";",
"}",
"}",
"finally",
"{",
"dispatching",
"=",
"null",
";",
"}",
"updateUI",
"(",
")",
";",
"}"
]
| dummy spec for the node we're attaching to
@param {Symbol|string} action? The action to dispatch (or undefined to force a render)
@param {any} payload? Any data associated with the action
@returns {void} | [
"dummy",
"spec",
"for",
"the",
"node",
"we",
"re",
"attaching",
"to"
]
| 44b559e491f568756c41f6fbdd26420b6393189d | https://github.com/uniphil/xxs/blob/44b559e491f568756c41f6fbdd26420b6393189d/xxs.js#L157-L171 |
45,445 | DScheglov/merest | lib/middlewares/transform-response.js | Bundle | function Bundle(transform, req, res) {
this.status = res.__status || 200;
this.body = res.__body || {};
this.apiMethod = res.__apiMethod;
this.apiInstanceMethod = res.__apiInstanceMethod;
this.apiStaticMethod = res.__apiStaticMethod;
this.api = res.__api;
this.modelAPI = res.__modelAPI;
if (this.modelAPI) {
this.model = this.modelAPI.model.modelName;
}
transform.call(this, req, res);
} | javascript | function Bundle(transform, req, res) {
this.status = res.__status || 200;
this.body = res.__body || {};
this.apiMethod = res.__apiMethod;
this.apiInstanceMethod = res.__apiInstanceMethod;
this.apiStaticMethod = res.__apiStaticMethod;
this.api = res.__api;
this.modelAPI = res.__modelAPI;
if (this.modelAPI) {
this.model = this.modelAPI.model.modelName;
}
transform.call(this, req, res);
} | [
"function",
"Bundle",
"(",
"transform",
",",
"req",
",",
"res",
")",
"{",
"this",
".",
"status",
"=",
"res",
".",
"__status",
"||",
"200",
";",
"this",
".",
"body",
"=",
"res",
".",
"__body",
"||",
"{",
"}",
";",
"this",
".",
"apiMethod",
"=",
"res",
".",
"__apiMethod",
";",
"this",
".",
"apiInstanceMethod",
"=",
"res",
".",
"__apiInstanceMethod",
";",
"this",
".",
"apiStaticMethod",
"=",
"res",
".",
"__apiStaticMethod",
";",
"this",
".",
"api",
"=",
"res",
".",
"__api",
";",
"this",
".",
"modelAPI",
"=",
"res",
".",
"__modelAPI",
";",
"if",
"(",
"this",
".",
"modelAPI",
")",
"{",
"this",
".",
"model",
"=",
"this",
".",
"modelAPI",
".",
"model",
".",
"modelName",
";",
"}",
"transform",
".",
"call",
"(",
"this",
",",
"req",
",",
"res",
")",
";",
"}"
]
| Bundle - class to aggregate data to be changed
@param {Function} transform the function transforms `this.status` and `this.body`
@param {Number} status HTTP Response code
@param {Any} body The Body to be changed
@return {Transformer} created transformed option | [
"Bundle",
"-",
"class",
"to",
"aggregate",
"data",
"to",
"be",
"changed"
]
| d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/middlewares/transform-response.js#L14-L26 |
45,446 | DScheglov/merest | lib/middlewares/transform-response.js | transformResponse | function transformResponse(transform) {
assert.ok(transform);
assert.ok(transform instanceof Function);
var originalStatus, originalJson, reqClosure;
return function (req, res, next) {
originalStatus = res.status;
originalJson = res.json;
reqClosure = req;
res.status = setStatus;
res.json = sendJson;
return next();
}
function setStatus(status) {
this.__status = status;
return this;
}
function sendJson(body) {
this.__body = body;
var B = new Bundle(transform, reqClosure, this);
originalStatus.call(this, B.status);
return originalJson.call(this, B.body);
}
} | javascript | function transformResponse(transform) {
assert.ok(transform);
assert.ok(transform instanceof Function);
var originalStatus, originalJson, reqClosure;
return function (req, res, next) {
originalStatus = res.status;
originalJson = res.json;
reqClosure = req;
res.status = setStatus;
res.json = sendJson;
return next();
}
function setStatus(status) {
this.__status = status;
return this;
}
function sendJson(body) {
this.__body = body;
var B = new Bundle(transform, reqClosure, this);
originalStatus.call(this, B.status);
return originalJson.call(this, B.body);
}
} | [
"function",
"transformResponse",
"(",
"transform",
")",
"{",
"assert",
".",
"ok",
"(",
"transform",
")",
";",
"assert",
".",
"ok",
"(",
"transform",
"instanceof",
"Function",
")",
";",
"var",
"originalStatus",
",",
"originalJson",
",",
"reqClosure",
";",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"originalStatus",
"=",
"res",
".",
"status",
";",
"originalJson",
"=",
"res",
".",
"json",
";",
"reqClosure",
"=",
"req",
";",
"res",
".",
"status",
"=",
"setStatus",
";",
"res",
".",
"json",
"=",
"sendJson",
";",
"return",
"next",
"(",
")",
";",
"}",
"function",
"setStatus",
"(",
"status",
")",
"{",
"this",
".",
"__status",
"=",
"status",
";",
"return",
"this",
";",
"}",
"function",
"sendJson",
"(",
"body",
")",
"{",
"this",
".",
"__body",
"=",
"body",
";",
"var",
"B",
"=",
"new",
"Bundle",
"(",
"transform",
",",
"reqClosure",
",",
"this",
")",
";",
"originalStatus",
".",
"call",
"(",
"this",
",",
"B",
".",
"status",
")",
";",
"return",
"originalJson",
".",
"call",
"(",
"this",
",",
"B",
".",
"body",
")",
";",
"}",
"}"
]
| transformResponse - the factory for middleware that transforms response
@param {Function} transform the function transfomrs `this.status` and `this.body`
@return {Function} express middleware that transfomrs response | [
"transformResponse",
"-",
"the",
"factory",
"for",
"middleware",
"that",
"transforms",
"response"
]
| d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/middlewares/transform-response.js#L34-L62 |
45,447 | yeikos/js.url | url.js | function() {
// Construimos los atributos en base a la localización
var attr = Public.unbuild(this._attributes, this.location);
// Si no se encuentra disponible la instancia localización
if (!(this.location instanceof Public))
// La dirección será externa si tiene definido el atributo `protocol` o `host`
return (attr.protocol || attr.host) ? true : false;
// La URL será externa si `protocol` o `host` no coincide con el de localización
return (this.location.attr('protocol') !== attr.protocol || this.location.attr('host') !== attr.host);
} | javascript | function() {
// Construimos los atributos en base a la localización
var attr = Public.unbuild(this._attributes, this.location);
// Si no se encuentra disponible la instancia localización
if (!(this.location instanceof Public))
// La dirección será externa si tiene definido el atributo `protocol` o `host`
return (attr.protocol || attr.host) ? true : false;
// La URL será externa si `protocol` o `host` no coincide con el de localización
return (this.location.attr('protocol') !== attr.protocol || this.location.attr('host') !== attr.host);
} | [
"function",
"(",
")",
"{",
"// Construimos los atributos en base a la localización",
"var",
"attr",
"=",
"Public",
".",
"unbuild",
"(",
"this",
".",
"_attributes",
",",
"this",
".",
"location",
")",
";",
"// Si no se encuentra disponible la instancia localización",
"if",
"(",
"!",
"(",
"this",
".",
"location",
"instanceof",
"Public",
")",
")",
"// La dirección será externa si tiene definido el atributo `protocol` o `host`",
"return",
"(",
"attr",
".",
"protocol",
"||",
"attr",
".",
"host",
")",
"?",
"true",
":",
"false",
";",
"// La URL será externa si `protocol` o `host` no coincide con el de localización",
"return",
"(",
"this",
".",
"location",
".",
"attr",
"(",
"'protocol'",
")",
"!==",
"attr",
".",
"protocol",
"||",
"this",
".",
"location",
".",
"attr",
"(",
"'host'",
")",
"!==",
"attr",
".",
"host",
")",
";",
"}"
]
| Comprueba si la URL es externa | [
"Comprueba",
"si",
"la",
"URL",
"es",
"externa"
]
| 4015fcb113528c253d5732b86564dfbe965ebdc6 | https://github.com/yeikos/js.url/blob/4015fcb113528c253d5732b86564dfbe965ebdc6/url.js#L231-L249 |
|
45,448 | yeikos/js.url | url.js | function() {
var attr = Public.attributes.slice(0),
argv = [].slice.apply(arguments),
buffer = {},
x = argv.length,
y = attr.length;
// Convertimos la matriz de argumentos a objeto
while (x--)
buffer[_toString(argv[x]).toLowerCase()] = 1;
// Si se desea eliminar el atributo `hostname` o `port`
if (buffer.hostname || buffer.port) {
// Eliminamos el atributo `host`, ya que contiene a ambos
buffer.host = 1;
// Si se desea eliminar el atributo `host`
} else if (buffer.host) {
// Eliminamos el atributo `hostname` y `port`, ya que contiene a ambos
buffer.hostname = 1;
buffer.port = 1;
}
// Recorremos los atributos
while (y--)
// Si se encuentra en la lista
if (buffer[attr[y]])
// Lo eliminamos
attr.splice(y, 1);
return _prototypeSelect.apply(this, [attr]);
} | javascript | function() {
var attr = Public.attributes.slice(0),
argv = [].slice.apply(arguments),
buffer = {},
x = argv.length,
y = attr.length;
// Convertimos la matriz de argumentos a objeto
while (x--)
buffer[_toString(argv[x]).toLowerCase()] = 1;
// Si se desea eliminar el atributo `hostname` o `port`
if (buffer.hostname || buffer.port) {
// Eliminamos el atributo `host`, ya que contiene a ambos
buffer.host = 1;
// Si se desea eliminar el atributo `host`
} else if (buffer.host) {
// Eliminamos el atributo `hostname` y `port`, ya que contiene a ambos
buffer.hostname = 1;
buffer.port = 1;
}
// Recorremos los atributos
while (y--)
// Si se encuentra en la lista
if (buffer[attr[y]])
// Lo eliminamos
attr.splice(y, 1);
return _prototypeSelect.apply(this, [attr]);
} | [
"function",
"(",
")",
"{",
"var",
"attr",
"=",
"Public",
".",
"attributes",
".",
"slice",
"(",
"0",
")",
",",
"argv",
"=",
"[",
"]",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
",",
"buffer",
"=",
"{",
"}",
",",
"x",
"=",
"argv",
".",
"length",
",",
"y",
"=",
"attr",
".",
"length",
";",
"// Convertimos la matriz de argumentos a objeto",
"while",
"(",
"x",
"--",
")",
"buffer",
"[",
"_toString",
"(",
"argv",
"[",
"x",
"]",
")",
".",
"toLowerCase",
"(",
")",
"]",
"=",
"1",
";",
"// Si se desea eliminar el atributo `hostname` o `port`",
"if",
"(",
"buffer",
".",
"hostname",
"||",
"buffer",
".",
"port",
")",
"{",
"// Eliminamos el atributo `host`, ya que contiene a ambos",
"buffer",
".",
"host",
"=",
"1",
";",
"// Si se desea eliminar el atributo `host`",
"}",
"else",
"if",
"(",
"buffer",
".",
"host",
")",
"{",
"// Eliminamos el atributo `hostname` y `port`, ya que contiene a ambos",
"buffer",
".",
"hostname",
"=",
"1",
";",
"buffer",
".",
"port",
"=",
"1",
";",
"}",
"// Recorremos los atributos",
"while",
"(",
"y",
"--",
")",
"// Si se encuentra en la lista",
"if",
"(",
"buffer",
"[",
"attr",
"[",
"y",
"]",
"]",
")",
"// Lo eliminamos",
"attr",
".",
"splice",
"(",
"y",
",",
"1",
")",
";",
"return",
"_prototypeSelect",
".",
"apply",
"(",
"this",
",",
"[",
"attr",
"]",
")",
";",
"}"
]
| Construye la URL sin los atributos seleccionados | [
"Construye",
"la",
"URL",
"sin",
"los",
"atributos",
"seleccionados"
]
| 4015fcb113528c253d5732b86564dfbe965ebdc6 | https://github.com/yeikos/js.url/blob/4015fcb113528c253d5732b86564dfbe965ebdc6/url.js#L261-L308 |
|
45,449 | yeikos/js.url | url.js | _isElement | function _isElement(input) {
return (typeof HTMLElement === 'function') ?
(input instanceof HTMLElement) :
(input && typeof input === 'object' && input.nodeType === 1 && typeof input.nodeName === 'string');
} | javascript | function _isElement(input) {
return (typeof HTMLElement === 'function') ?
(input instanceof HTMLElement) :
(input && typeof input === 'object' && input.nodeType === 1 && typeof input.nodeName === 'string');
} | [
"function",
"_isElement",
"(",
"input",
")",
"{",
"return",
"(",
"typeof",
"HTMLElement",
"===",
"'function'",
")",
"?",
"(",
"input",
"instanceof",
"HTMLElement",
")",
":",
"(",
"input",
"&&",
"typeof",
"input",
"===",
"'object'",
"&&",
"input",
".",
"nodeType",
"===",
"1",
"&&",
"typeof",
"input",
".",
"nodeName",
"===",
"'string'",
")",
";",
"}"
]
| Comprueba si el objeto es un elemento HTML | [
"Comprueba",
"si",
"el",
"objeto",
"es",
"un",
"elemento",
"HTML"
]
| 4015fcb113528c253d5732b86564dfbe965ebdc6 | https://github.com/yeikos/js.url/blob/4015fcb113528c253d5732b86564dfbe965ebdc6/url.js#L1253-L1261 |
45,450 | jquense/cobble | index.js | cobble | function cobble(){
var args = [], last;
for(var i = 0; i < arguments.length; ++i) {
last = arguments[i];
if( isArray(last) ) args = args.concat(last)
else args[args.length] = last
}
return cobble.into({}, args)
} | javascript | function cobble(){
var args = [], last;
for(var i = 0; i < arguments.length; ++i) {
last = arguments[i];
if( isArray(last) ) args = args.concat(last)
else args[args.length] = last
}
return cobble.into({}, args)
} | [
"function",
"cobble",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
",",
"last",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"++",
"i",
")",
"{",
"last",
"=",
"arguments",
"[",
"i",
"]",
";",
"if",
"(",
"isArray",
"(",
"last",
")",
")",
"args",
"=",
"args",
".",
"concat",
"(",
"last",
")",
"else",
"args",
"[",
"args",
".",
"length",
"]",
"=",
"last",
"}",
"return",
"cobble",
".",
"into",
"(",
"{",
"}",
",",
"args",
")",
"}"
]
| compose objects into a new object, leaving the original objects untouched
@param {...object} an object to be composed.
@return {object} | [
"compose",
"objects",
"into",
"a",
"new",
"object",
"leaving",
"the",
"original",
"objects",
"untouched"
]
| 25889b99309cdd6d690fa8efdb6f86e99c41c466 | https://github.com/jquense/cobble/blob/25889b99309cdd6d690fa8efdb6f86e99c41c466/index.js#L12-L22 |
45,451 | lodestarjs/lodestar-ractive | src/main.js | LodeRactive | function LodeRactive( options ) {
if ( typeof Ractive === 'undefined' ) throw Error('Couldn\'t find an instance of Ractive, you need to have it in order to use this framework.');
if ( options && typeof options.DEBUG !== 'undefined') Ractive.DEBUG = options.DEBUG;
this.router = new Router( options );
} | javascript | function LodeRactive( options ) {
if ( typeof Ractive === 'undefined' ) throw Error('Couldn\'t find an instance of Ractive, you need to have it in order to use this framework.');
if ( options && typeof options.DEBUG !== 'undefined') Ractive.DEBUG = options.DEBUG;
this.router = new Router( options );
} | [
"function",
"LodeRactive",
"(",
"options",
")",
"{",
"if",
"(",
"typeof",
"Ractive",
"===",
"'undefined'",
")",
"throw",
"Error",
"(",
"'Couldn\\'t find an instance of Ractive, you need to have it in order to use this framework.'",
")",
";",
"if",
"(",
"options",
"&&",
"typeof",
"options",
".",
"DEBUG",
"!==",
"'undefined'",
")",
"Ractive",
".",
"DEBUG",
"=",
"options",
".",
"DEBUG",
";",
"this",
".",
"router",
"=",
"new",
"Router",
"(",
"options",
")",
";",
"}"
]
| Constructor for the framework. It depends on Ractive as this is a POC
of using the router with Ractive.
@param {Object} options, the configuration options for the framework.
@returns {Void}, nothing returned | [
"Constructor",
"for",
"the",
"framework",
".",
"It",
"depends",
"on",
"Ractive",
"as",
"this",
"is",
"a",
"POC",
"of",
"using",
"the",
"router",
"with",
"Ractive",
"."
]
| 58cded8a1b8f0d258f174dd5fcfc0a291d7664e9 | https://github.com/lodestarjs/lodestar-ractive/blob/58cded8a1b8f0d258f174dd5fcfc0a291d7664e9/src/main.js#L10-L18 |
45,452 | socialally/air | lib/air/parent.js | parent | function parent(/*selector*/) {
var arr = [], $ = this.air, slice = this.slice;
this.each(function(el) {
arr = arr.concat(slice.call($(el.parentNode).dom));
});
return $(arr);
} | javascript | function parent(/*selector*/) {
var arr = [], $ = this.air, slice = this.slice;
this.each(function(el) {
arr = arr.concat(slice.call($(el.parentNode).dom));
});
return $(arr);
} | [
"function",
"parent",
"(",
"/*selector*/",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
",",
"$",
"=",
"this",
".",
"air",
",",
"slice",
"=",
"this",
".",
"slice",
";",
"this",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"arr",
"=",
"arr",
".",
"concat",
"(",
"slice",
".",
"call",
"(",
"$",
"(",
"el",
".",
"parentNode",
")",
".",
"dom",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"(",
"arr",
")",
";",
"}"
]
| Get the parent of each element in the current set of matched elements,
optionally filtered by a selector.
TODO: implement selector filtering | [
"Get",
"the",
"parent",
"of",
"each",
"element",
"in",
"the",
"current",
"set",
"of",
"matched",
"elements",
"optionally",
"filtered",
"by",
"a",
"selector",
"."
]
| a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/parent.js#L7-L13 |
45,453 | MorganConrad/metalsmith-inspect | inspect.js | inspect | function inspect(options){
options = normalize(options);
return function(files, metalsmith, done) {
if (options.disable)
return done();
//try {
var bigJSObject = {};
if (options.includeMetalsmith) {
bigJSObject[options.includeMetalsmith] = metalsmith.metadata();
}
Object.keys(files).forEach(function(filePath){
var inData = files[filePath];
if (options.fileFilter(filePath, inData, metalsmith)) {
var outData = {};
Object.keys(inData).forEach(function(key) {
if (options.accept(key, inData)) {
outData[key] = inData[key];
}
});
if (!options.contentsAsBuffer && outData.contents)
outData.contents = inData.contents.toString();
bigJSObject[filePath] = outData;
}
});
options.printfn(bigJSObject);
done();
// }
// catch (err) {
// done(err);
// }
};
/**
* Normalize an `options` dictionary.
*
* @param {Object} options
*/
function normalize(options){
options = options || {};
options.printfn = options.printfn || function(obj) {
console.dir(obj, {colors: true});
};
if (!options.accept) {
if (options.include) {
options.accept = function(propKey) { return options.include.indexOf(propKey) >= 0; };
}
else if (options.exclude){
options.accept = function(propKey) { return options.exclude.indexOf(propKey) < 0; };
}
else {
options.accept = function() { return true; };
}
}
options.fileFilter = fileFilter(options.filter);
return options;
};
/* calculate file filter function */
function fileFilter(filter) {
if (filter) {
if (typeof filter === 'string') {
var regex = new RegExp(filter);
return function(filePath) { return regex.test(filePath); }
}
else if (filter instanceof RegExp)
return function(filePath) { return filter.test(filePath); }
else { // must be a function itself
return filter;
}
}
else // none, return "pass all"
return function() { return true; };
}
} | javascript | function inspect(options){
options = normalize(options);
return function(files, metalsmith, done) {
if (options.disable)
return done();
//try {
var bigJSObject = {};
if (options.includeMetalsmith) {
bigJSObject[options.includeMetalsmith] = metalsmith.metadata();
}
Object.keys(files).forEach(function(filePath){
var inData = files[filePath];
if (options.fileFilter(filePath, inData, metalsmith)) {
var outData = {};
Object.keys(inData).forEach(function(key) {
if (options.accept(key, inData)) {
outData[key] = inData[key];
}
});
if (!options.contentsAsBuffer && outData.contents)
outData.contents = inData.contents.toString();
bigJSObject[filePath] = outData;
}
});
options.printfn(bigJSObject);
done();
// }
// catch (err) {
// done(err);
// }
};
/**
* Normalize an `options` dictionary.
*
* @param {Object} options
*/
function normalize(options){
options = options || {};
options.printfn = options.printfn || function(obj) {
console.dir(obj, {colors: true});
};
if (!options.accept) {
if (options.include) {
options.accept = function(propKey) { return options.include.indexOf(propKey) >= 0; };
}
else if (options.exclude){
options.accept = function(propKey) { return options.exclude.indexOf(propKey) < 0; };
}
else {
options.accept = function() { return true; };
}
}
options.fileFilter = fileFilter(options.filter);
return options;
};
/* calculate file filter function */
function fileFilter(filter) {
if (filter) {
if (typeof filter === 'string') {
var regex = new RegExp(filter);
return function(filePath) { return regex.test(filePath); }
}
else if (filter instanceof RegExp)
return function(filePath) { return filter.test(filePath); }
else { // must be a function itself
return filter;
}
}
else // none, return "pass all"
return function() { return true; };
}
} | [
"function",
"inspect",
"(",
"options",
")",
"{",
"options",
"=",
"normalize",
"(",
"options",
")",
";",
"return",
"function",
"(",
"files",
",",
"metalsmith",
",",
"done",
")",
"{",
"if",
"(",
"options",
".",
"disable",
")",
"return",
"done",
"(",
")",
";",
"//try {\r",
"var",
"bigJSObject",
"=",
"{",
"}",
";",
"if",
"(",
"options",
".",
"includeMetalsmith",
")",
"{",
"bigJSObject",
"[",
"options",
".",
"includeMetalsmith",
"]",
"=",
"metalsmith",
".",
"metadata",
"(",
")",
";",
"}",
"Object",
".",
"keys",
"(",
"files",
")",
".",
"forEach",
"(",
"function",
"(",
"filePath",
")",
"{",
"var",
"inData",
"=",
"files",
"[",
"filePath",
"]",
";",
"if",
"(",
"options",
".",
"fileFilter",
"(",
"filePath",
",",
"inData",
",",
"metalsmith",
")",
")",
"{",
"var",
"outData",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"inData",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"options",
".",
"accept",
"(",
"key",
",",
"inData",
")",
")",
"{",
"outData",
"[",
"key",
"]",
"=",
"inData",
"[",
"key",
"]",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"options",
".",
"contentsAsBuffer",
"&&",
"outData",
".",
"contents",
")",
"outData",
".",
"contents",
"=",
"inData",
".",
"contents",
".",
"toString",
"(",
")",
";",
"bigJSObject",
"[",
"filePath",
"]",
"=",
"outData",
";",
"}",
"}",
")",
";",
"options",
".",
"printfn",
"(",
"bigJSObject",
")",
";",
"done",
"(",
")",
";",
"// }\r",
"// catch (err) {\r",
"// done(err);\r",
"// }\r",
"}",
";",
"/**\r\n * Normalize an `options` dictionary.\r\n *\r\n * @param {Object} options\r\n */",
"function",
"normalize",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"printfn",
"=",
"options",
".",
"printfn",
"||",
"function",
"(",
"obj",
")",
"{",
"console",
".",
"dir",
"(",
"obj",
",",
"{",
"colors",
":",
"true",
"}",
")",
";",
"}",
";",
"if",
"(",
"!",
"options",
".",
"accept",
")",
"{",
"if",
"(",
"options",
".",
"include",
")",
"{",
"options",
".",
"accept",
"=",
"function",
"(",
"propKey",
")",
"{",
"return",
"options",
".",
"include",
".",
"indexOf",
"(",
"propKey",
")",
">=",
"0",
";",
"}",
";",
"}",
"else",
"if",
"(",
"options",
".",
"exclude",
")",
"{",
"options",
".",
"accept",
"=",
"function",
"(",
"propKey",
")",
"{",
"return",
"options",
".",
"exclude",
".",
"indexOf",
"(",
"propKey",
")",
"<",
"0",
";",
"}",
";",
"}",
"else",
"{",
"options",
".",
"accept",
"=",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
";",
"}",
"}",
"options",
".",
"fileFilter",
"=",
"fileFilter",
"(",
"options",
".",
"filter",
")",
";",
"return",
"options",
";",
"}",
";",
"/* calculate file filter function */",
"function",
"fileFilter",
"(",
"filter",
")",
"{",
"if",
"(",
"filter",
")",
"{",
"if",
"(",
"typeof",
"filter",
"===",
"'string'",
")",
"{",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"filter",
")",
";",
"return",
"function",
"(",
"filePath",
")",
"{",
"return",
"regex",
".",
"test",
"(",
"filePath",
")",
";",
"}",
"}",
"else",
"if",
"(",
"filter",
"instanceof",
"RegExp",
")",
"return",
"function",
"(",
"filePath",
")",
"{",
"return",
"filter",
".",
"test",
"(",
"filePath",
")",
";",
"}",
"else",
"{",
"// must be a function itself\r",
"return",
"filter",
";",
"}",
"}",
"else",
"// none, return \"pass all\"\r",
"return",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
";",
"}",
"}"
]
| Metalsmith plugin that prints the objects
@param {Object} opts
@return {Function} | [
"Metalsmith",
"plugin",
"that",
"prints",
"the",
"objects"
]
| 3e2dc04254fa90862a2589584c95e84b8db66b8b | https://github.com/MorganConrad/metalsmith-inspect/blob/3e2dc04254fa90862a2589584c95e84b8db66b8b/inspect.js#L12-L105 |
45,454 | MorganConrad/metalsmith-inspect | inspect.js | normalize | function normalize(options){
options = options || {};
options.printfn = options.printfn || function(obj) {
console.dir(obj, {colors: true});
};
if (!options.accept) {
if (options.include) {
options.accept = function(propKey) { return options.include.indexOf(propKey) >= 0; };
}
else if (options.exclude){
options.accept = function(propKey) { return options.exclude.indexOf(propKey) < 0; };
}
else {
options.accept = function() { return true; };
}
}
options.fileFilter = fileFilter(options.filter);
return options;
} | javascript | function normalize(options){
options = options || {};
options.printfn = options.printfn || function(obj) {
console.dir(obj, {colors: true});
};
if (!options.accept) {
if (options.include) {
options.accept = function(propKey) { return options.include.indexOf(propKey) >= 0; };
}
else if (options.exclude){
options.accept = function(propKey) { return options.exclude.indexOf(propKey) < 0; };
}
else {
options.accept = function() { return true; };
}
}
options.fileFilter = fileFilter(options.filter);
return options;
} | [
"function",
"normalize",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"printfn",
"=",
"options",
".",
"printfn",
"||",
"function",
"(",
"obj",
")",
"{",
"console",
".",
"dir",
"(",
"obj",
",",
"{",
"colors",
":",
"true",
"}",
")",
";",
"}",
";",
"if",
"(",
"!",
"options",
".",
"accept",
")",
"{",
"if",
"(",
"options",
".",
"include",
")",
"{",
"options",
".",
"accept",
"=",
"function",
"(",
"propKey",
")",
"{",
"return",
"options",
".",
"include",
".",
"indexOf",
"(",
"propKey",
")",
">=",
"0",
";",
"}",
";",
"}",
"else",
"if",
"(",
"options",
".",
"exclude",
")",
"{",
"options",
".",
"accept",
"=",
"function",
"(",
"propKey",
")",
"{",
"return",
"options",
".",
"exclude",
".",
"indexOf",
"(",
"propKey",
")",
"<",
"0",
";",
"}",
";",
"}",
"else",
"{",
"options",
".",
"accept",
"=",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
";",
"}",
"}",
"options",
".",
"fileFilter",
"=",
"fileFilter",
"(",
"options",
".",
"filter",
")",
";",
"return",
"options",
";",
"}"
]
| Normalize an `options` dictionary.
@param {Object} options | [
"Normalize",
"an",
"options",
"dictionary",
"."
]
| 3e2dc04254fa90862a2589584c95e84b8db66b8b | https://github.com/MorganConrad/metalsmith-inspect/blob/3e2dc04254fa90862a2589584c95e84b8db66b8b/inspect.js#L61-L83 |
45,455 | haraldrudell/nodegod | lib/rotatedlogger.js | write | function write(s) {
var err
var args = Array.prototype.slice.call(arguments)
var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
var cbCounter = 1
if (writeToStdoutEnabled) {
cbCounter++
process.stdout.write(s, stdWr)
}
if (writeStream) {
cbCounter++
writeStream.write(s, wRes)
}
end()
function stdWr(e) {
if (e) {
if (!err) err = e
writeToStdoutEnabled = false
write('stdout error: ' + e.message)
self.emit('error', e)
}
end()
}
function wRes(e) {
if (e) {
if (!err) err = e
writeStream = false
write('stream error: ' + e.message)
self.emit('error', e)
}
end()
}
function end() {
if (!--cbCounter)
if (cb)
if (err) cb(err)
else cb()
}
} | javascript | function write(s) {
var err
var args = Array.prototype.slice.call(arguments)
var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
var cbCounter = 1
if (writeToStdoutEnabled) {
cbCounter++
process.stdout.write(s, stdWr)
}
if (writeStream) {
cbCounter++
writeStream.write(s, wRes)
}
end()
function stdWr(e) {
if (e) {
if (!err) err = e
writeToStdoutEnabled = false
write('stdout error: ' + e.message)
self.emit('error', e)
}
end()
}
function wRes(e) {
if (e) {
if (!err) err = e
writeStream = false
write('stream error: ' + e.message)
self.emit('error', e)
}
end()
}
function end() {
if (!--cbCounter)
if (cb)
if (err) cb(err)
else cb()
}
} | [
"function",
"write",
"(",
"s",
")",
"{",
"var",
"err",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
"var",
"cb",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'function'",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
"var",
"cbCounter",
"=",
"1",
"if",
"(",
"writeToStdoutEnabled",
")",
"{",
"cbCounter",
"++",
"process",
".",
"stdout",
".",
"write",
"(",
"s",
",",
"stdWr",
")",
"}",
"if",
"(",
"writeStream",
")",
"{",
"cbCounter",
"++",
"writeStream",
".",
"write",
"(",
"s",
",",
"wRes",
")",
"}",
"end",
"(",
")",
"function",
"stdWr",
"(",
"e",
")",
"{",
"if",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"err",
")",
"err",
"=",
"e",
"writeToStdoutEnabled",
"=",
"false",
"write",
"(",
"'stdout error: '",
"+",
"e",
".",
"message",
")",
"self",
".",
"emit",
"(",
"'error'",
",",
"e",
")",
"}",
"end",
"(",
")",
"}",
"function",
"wRes",
"(",
"e",
")",
"{",
"if",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"err",
")",
"err",
"=",
"e",
"writeStream",
"=",
"false",
"write",
"(",
"'stream error: '",
"+",
"e",
".",
"message",
")",
"self",
".",
"emit",
"(",
"'error'",
",",
"e",
")",
"}",
"end",
"(",
")",
"}",
"function",
"end",
"(",
")",
"{",
"if",
"(",
"!",
"--",
"cbCounter",
")",
"if",
"(",
"cb",
")",
"if",
"(",
"err",
")",
"cb",
"(",
"err",
")",
"else",
"cb",
"(",
")",
"}",
"}"
]
| logging of utf-8 string | [
"logging",
"of",
"utf",
"-",
"8",
"string"
]
| 3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21 | https://github.com/haraldrudell/nodegod/blob/3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21/lib/rotatedlogger.js#L76-L117 |
45,456 | iamchairs/snooze | lib/module.js | function(nm, modules, snooze) {
this.snooze = snooze;
if(nm === null || nm === undefined || nm.length < 1) {
throw new Error('Module name note defined.');
}
this.name = nm;
this.snoozeConfig = this.snooze.getConfig();
this.runs = [];
this.configs = [];
this.modules = modules || [];
this.EntityManager = new EntityManager(this, snooze);
this.importedModules = {};
this.importProcesses = [];
this.configPreprocessors = [];
// TODO: move this to a better location
var self = this;
this.EntityManager.defineReservedInjectable('$config', function() {
return self.getConfig();
});
this.EntityManager.defineReservedInjectable('$entityManager', function() {
return self.EntityManager;
});
} | javascript | function(nm, modules, snooze) {
this.snooze = snooze;
if(nm === null || nm === undefined || nm.length < 1) {
throw new Error('Module name note defined.');
}
this.name = nm;
this.snoozeConfig = this.snooze.getConfig();
this.runs = [];
this.configs = [];
this.modules = modules || [];
this.EntityManager = new EntityManager(this, snooze);
this.importedModules = {};
this.importProcesses = [];
this.configPreprocessors = [];
// TODO: move this to a better location
var self = this;
this.EntityManager.defineReservedInjectable('$config', function() {
return self.getConfig();
});
this.EntityManager.defineReservedInjectable('$entityManager', function() {
return self.EntityManager;
});
} | [
"function",
"(",
"nm",
",",
"modules",
",",
"snooze",
")",
"{",
"this",
".",
"snooze",
"=",
"snooze",
";",
"if",
"(",
"nm",
"===",
"null",
"||",
"nm",
"===",
"undefined",
"||",
"nm",
".",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Module name note defined.'",
")",
";",
"}",
"this",
".",
"name",
"=",
"nm",
";",
"this",
".",
"snoozeConfig",
"=",
"this",
".",
"snooze",
".",
"getConfig",
"(",
")",
";",
"this",
".",
"runs",
"=",
"[",
"]",
";",
"this",
".",
"configs",
"=",
"[",
"]",
";",
"this",
".",
"modules",
"=",
"modules",
"||",
"[",
"]",
";",
"this",
".",
"EntityManager",
"=",
"new",
"EntityManager",
"(",
"this",
",",
"snooze",
")",
";",
"this",
".",
"importedModules",
"=",
"{",
"}",
";",
"this",
".",
"importProcesses",
"=",
"[",
"]",
";",
"this",
".",
"configPreprocessors",
"=",
"[",
"]",
";",
"// TODO: move this to a better location",
"var",
"self",
"=",
"this",
";",
"this",
".",
"EntityManager",
".",
"defineReservedInjectable",
"(",
"'$config'",
",",
"function",
"(",
")",
"{",
"return",
"self",
".",
"getConfig",
"(",
")",
";",
"}",
")",
";",
"this",
".",
"EntityManager",
".",
"defineReservedInjectable",
"(",
"'$entityManager'",
",",
"function",
"(",
")",
"{",
"return",
"self",
".",
"EntityManager",
";",
"}",
")",
";",
"}"
]
| A SnoozeJS Module
@constructor
@param {string} nm - The name of the module
@param {array} modules - Array of module names to inject | [
"A",
"SnoozeJS",
"Module"
]
| 6127a6a183562721311bdb03b16c5448b71900ec | https://github.com/iamchairs/snooze/blob/6127a6a183562721311bdb03b16c5448b71900ec/lib/module.js#L15-L41 |
|
45,457 | binduwavell/generator-alfresco-common | lib/maven-archetype-file-filtering.js | function (content, properties) {
var lines = content.split(lineEndingRE);
lines = replaceProperties(lines, properties);
lines = replaceSymbols(lines);
return lines.join('\n');
} | javascript | function (content, properties) {
var lines = content.split(lineEndingRE);
lines = replaceProperties(lines, properties);
lines = replaceSymbols(lines);
return lines.join('\n');
} | [
"function",
"(",
"content",
",",
"properties",
")",
"{",
"var",
"lines",
"=",
"content",
".",
"split",
"(",
"lineEndingRE",
")",
";",
"lines",
"=",
"replaceProperties",
"(",
"lines",
",",
"properties",
")",
";",
"lines",
"=",
"replaceSymbols",
"(",
"lines",
")",
";",
"return",
"lines",
".",
"join",
"(",
"'\\n'",
")",
";",
"}"
]
| Given some text, we find all references that correlate with provided properties
and replace them with the value assigned to the property.
@param {!string} content
@param {!Object} properties
@returns {!string} | [
"Given",
"some",
"text",
"we",
"find",
"all",
"references",
"that",
"correlate",
"with",
"provided",
"properties",
"and",
"replace",
"them",
"with",
"the",
"value",
"assigned",
"to",
"the",
"property",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/maven-archetype-file-filtering.js#L24-L29 |
|
45,458 | binduwavell/generator-alfresco-common | lib/maven-archetype-file-filtering.js | replaceProperties | function replaceProperties (lines, properties) {
var filteredLines = [];
lines.forEach((line) => {
for (var prop in properties) {
line = expandReference(line, prop, properties[prop]);
}
filteredLines.push(line);
});
return filteredLines;
} | javascript | function replaceProperties (lines, properties) {
var filteredLines = [];
lines.forEach((line) => {
for (var prop in properties) {
line = expandReference(line, prop, properties[prop]);
}
filteredLines.push(line);
});
return filteredLines;
} | [
"function",
"replaceProperties",
"(",
"lines",
",",
"properties",
")",
"{",
"var",
"filteredLines",
"=",
"[",
"]",
";",
"lines",
".",
"forEach",
"(",
"(",
"line",
")",
"=>",
"{",
"for",
"(",
"var",
"prop",
"in",
"properties",
")",
"{",
"line",
"=",
"expandReference",
"(",
"line",
",",
"prop",
",",
"properties",
"[",
"prop",
"]",
")",
";",
"}",
"filteredLines",
".",
"push",
"(",
"line",
")",
";",
"}",
")",
";",
"return",
"filteredLines",
";",
"}"
]
| Given a list of lines from a file, we go through each line and replace properties that
are provided with the associated value.
NOTE: This does not process properties if they are not in the properties parameter.
@param {!Array<string>} lines are processed one at a time
@param {!Object} properties are replaced
@returns {!Array<string>} original lines with properties replaced | [
"Given",
"a",
"list",
"of",
"lines",
"from",
"a",
"file",
"we",
"go",
"through",
"each",
"line",
"and",
"replace",
"properties",
"that",
"are",
"provided",
"with",
"the",
"associated",
"value",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/maven-archetype-file-filtering.js#L66-L75 |
45,459 | pageobjectmodel/pom | src/emitter.js | once | function once(eventName, handler, context, args) {
this.on(eventName, handler, context, args, true);
} | javascript | function once(eventName, handler, context, args) {
this.on(eventName, handler, context, args, true);
} | [
"function",
"once",
"(",
"eventName",
",",
"handler",
",",
"context",
",",
"args",
")",
"{",
"this",
".",
"on",
"(",
"eventName",
",",
"handler",
",",
"context",
",",
"args",
",",
"true",
")",
";",
"}"
]
| Adds listener for an event that should be called once
@param {string} eventName
@param {function} handler
@param {object} context
@param {array} args | [
"Adds",
"listener",
"for",
"an",
"event",
"that",
"should",
"be",
"called",
"once"
]
| 75c566244e0520c3ca260dda261df3f4a92d8335 | https://github.com/pageobjectmodel/pom/blob/75c566244e0520c3ca260dda261df3f4a92d8335/src/emitter.js#L139-L141 |
45,460 | pageobjectmodel/pom | src/emitter.js | bubbleEvent | function bubbleEvent(eventName, toEmitter) {
this.on(eventName, (event) => {
toEmitter.emit(eventName, event.data, event);
});
} | javascript | function bubbleEvent(eventName, toEmitter) {
this.on(eventName, (event) => {
toEmitter.emit(eventName, event.data, event);
});
} | [
"function",
"bubbleEvent",
"(",
"eventName",
",",
"toEmitter",
")",
"{",
"this",
".",
"on",
"(",
"eventName",
",",
"(",
"event",
")",
"=>",
"{",
"toEmitter",
".",
"emit",
"(",
"eventName",
",",
"event",
".",
"data",
",",
"event",
")",
";",
"}",
")",
";",
"}"
]
| Bubbles event to other emitter
@param {string} eventName
@param {object} toEmitter | [
"Bubbles",
"event",
"to",
"other",
"emitter"
]
| 75c566244e0520c3ca260dda261df3f4a92d8335 | https://github.com/pageobjectmodel/pom/blob/75c566244e0520c3ca260dda261df3f4a92d8335/src/emitter.js#L192-L196 |
45,461 | pageobjectmodel/pom | src/emitter.js | getListeners | function getListeners(eventName, handler, context, args) {
if (!this.__listeners || !this.__listeners[eventName]) {
return null;
}
return this.__listeners[eventName]
.map((config) => {
if (handler !== undefined && config.fn !== handler) {
return false;
}
if (context !== undefined && config.context !== context) {
return false;
}
if (args !== undefined && config.args !== args) {
return false;
}
return config;
})
.filter((result) => !!result);
} | javascript | function getListeners(eventName, handler, context, args) {
if (!this.__listeners || !this.__listeners[eventName]) {
return null;
}
return this.__listeners[eventName]
.map((config) => {
if (handler !== undefined && config.fn !== handler) {
return false;
}
if (context !== undefined && config.context !== context) {
return false;
}
if (args !== undefined && config.args !== args) {
return false;
}
return config;
})
.filter((result) => !!result);
} | [
"function",
"getListeners",
"(",
"eventName",
",",
"handler",
",",
"context",
",",
"args",
")",
"{",
"if",
"(",
"!",
"this",
".",
"__listeners",
"||",
"!",
"this",
".",
"__listeners",
"[",
"eventName",
"]",
")",
"{",
"return",
"null",
";",
"}",
"return",
"this",
".",
"__listeners",
"[",
"eventName",
"]",
".",
"map",
"(",
"(",
"config",
")",
"=>",
"{",
"if",
"(",
"handler",
"!==",
"undefined",
"&&",
"config",
".",
"fn",
"!==",
"handler",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"context",
"!==",
"undefined",
"&&",
"config",
".",
"context",
"!==",
"context",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"args",
"!==",
"undefined",
"&&",
"config",
".",
"args",
"!==",
"args",
")",
"{",
"return",
"false",
";",
"}",
"return",
"config",
";",
"}",
")",
".",
"filter",
"(",
"(",
"result",
")",
"=>",
"!",
"!",
"result",
")",
";",
"}"
]
| Gets all listeners that match criteria
@param {string} eventName required
@param {function} handler if defined will be used for match
@param {object} context if defined will be used for match
@param {array} args if defined will be used for match
@returns {array<EventConfig>|null} | [
"Gets",
"all",
"listeners",
"that",
"match",
"criteria"
]
| 75c566244e0520c3ca260dda261df3f4a92d8335 | https://github.com/pageobjectmodel/pom/blob/75c566244e0520c3ca260dda261df3f4a92d8335/src/emitter.js#L206-L225 |
45,462 | OpenSmartEnvironment/ose | lib/entry/index.js | init | function init(shard, eid) { // {{{2
/**
* Entry constructor
*
* @param shard {Object} Entry owner shard instance
* @param eid {Number|String} Entry id
*
* @method constructor
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.shard = shard; // {{{3
/**
* Reference to containing [shard]
*
* @property shard
* @type Object
*/
this.id = eid; // {{{3
/**
* Unique id of entry within containing [shard]
*
* @property id
* @type Integer
*/
// }}}3
if (eid in shard.cache) {
throw O.log.error(this, 'Duplicit eid', eid);
}
shard.cache[eid] = this;
} | javascript | function init(shard, eid) { // {{{2
/**
* Entry constructor
*
* @param shard {Object} Entry owner shard instance
* @param eid {Number|String} Entry id
*
* @method constructor
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.shard = shard; // {{{3
/**
* Reference to containing [shard]
*
* @property shard
* @type Object
*/
this.id = eid; // {{{3
/**
* Unique id of entry within containing [shard]
*
* @property id
* @type Integer
*/
// }}}3
if (eid in shard.cache) {
throw O.log.error(this, 'Duplicit eid', eid);
}
shard.cache[eid] = this;
} | [
"function",
"init",
"(",
"shard",
",",
"eid",
")",
"{",
"// {{{2",
"/**\n * Entry constructor\n *\n * @param shard {Object} Entry owner shard instance\n * @param eid {Number|String} Entry id\n *\n * @method constructor\n */",
"O",
".",
"inherited",
"(",
"this",
")",
"(",
")",
";",
"this",
".",
"setMaxListeners",
"(",
"Consts",
".",
"coreListeners",
")",
";",
"this",
".",
"subjectState",
"=",
"this",
".",
"SUBJECT_STATE",
".",
"INIT",
";",
"this",
".",
"shard",
"=",
"shard",
";",
"// {{{3",
"/**\n * Reference to containing [shard]\n *\n * @property shard\n * @type Object\n */",
"this",
".",
"id",
"=",
"eid",
";",
"// {{{3",
"/**\n * Unique id of entry within containing [shard]\n *\n * @property id\n * @type Integer\n */",
"// }}}3",
"if",
"(",
"eid",
"in",
"shard",
".",
"cache",
")",
"{",
"throw",
"O",
".",
"log",
".",
"error",
"(",
"this",
",",
"'Duplicit eid'",
",",
"eid",
")",
";",
"}",
"shard",
".",
"cache",
"[",
"eid",
"]",
"=",
"this",
";",
"}"
]
| slaves {{{2
Contains all response sockets of slave entries
@property slaves
@type Object
@internal
Public {{{1 | [
"slaves",
"{{{",
"2",
"Contains",
"all",
"response",
"sockets",
"of",
"slave",
"entries"
]
| 2ab051d9db6e77341c40abb9cbdae6ce586917e0 | https://github.com/OpenSmartEnvironment/ose/blob/2ab051d9db6e77341c40abb9cbdae6ce586917e0/lib/entry/index.js#L134-L173 |
45,463 | kaelzhang/node-trait | index.js | function(key) {
if (arguments.length === 0) {
// reset all values, including non-enumerable and readonly properties
this.key_list.forEach(function(key) {
this._reset(key);
}, this);
} else {
this._reset(key);
}
} | javascript | function(key) {
if (arguments.length === 0) {
// reset all values, including non-enumerable and readonly properties
this.key_list.forEach(function(key) {
this._reset(key);
}, this);
} else {
this._reset(key);
}
} | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"// reset all values, including non-enumerable and readonly properties",
"this",
".",
"key_list",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"this",
".",
"_reset",
"(",
"key",
")",
";",
"}",
",",
"this",
")",
";",
"}",
"else",
"{",
"this",
".",
"_reset",
"(",
"key",
")",
";",
"}",
"}"
]
| Reset to default value. Run this method will execute setup methods | [
"Reset",
"to",
"default",
"value",
".",
"Run",
"this",
"method",
"will",
"execute",
"setup",
"methods"
]
| cd78e902baedbd16728518ba5be2fbcc48ca564f | https://github.com/kaelzhang/node-trait/blob/cd78e902baedbd16728518ba5be2fbcc48ca564f/index.js#L106-L116 |
|
45,464 | kaelzhang/node-trait | index.js | function(key) {
var attr = this.__attrs[key];
if (!attr) {
return;
}
var value = attr.value = attr._origin;
var setup = attr.type.setup;
if (setup) {
setup.call(this.host, value, key, this);
}
} | javascript | function(key) {
var attr = this.__attrs[key];
if (!attr) {
return;
}
var value = attr.value = attr._origin;
var setup = attr.type.setup;
if (setup) {
setup.call(this.host, value, key, this);
}
} | [
"function",
"(",
"key",
")",
"{",
"var",
"attr",
"=",
"this",
".",
"__attrs",
"[",
"key",
"]",
";",
"if",
"(",
"!",
"attr",
")",
"{",
"return",
";",
"}",
"var",
"value",
"=",
"attr",
".",
"value",
"=",
"attr",
".",
"_origin",
";",
"var",
"setup",
"=",
"attr",
".",
"type",
".",
"setup",
";",
"if",
"(",
"setup",
")",
"{",
"setup",
".",
"call",
"(",
"this",
".",
"host",
",",
"value",
",",
"key",
",",
"this",
")",
";",
"}",
"}"
]
| Force to unsetting a value by key, use this method carefully. | [
"Force",
"to",
"unsetting",
"a",
"value",
"by",
"key",
"use",
"this",
"method",
"carefully",
"."
]
| cd78e902baedbd16728518ba5be2fbcc48ca564f | https://github.com/kaelzhang/node-trait/blob/cd78e902baedbd16728518ba5be2fbcc48ca564f/index.js#L120-L133 |
|
45,465 | jldec/pub-generator | helpers.js | resolve | function resolve(ref, context) {
if (typeof ref !== 'string') return ref;
if (/^#/.test(ref)) { ref = (context._href || '/') + ref; }
return generator.fragment$[ref];
} | javascript | function resolve(ref, context) {
if (typeof ref !== 'string') return ref;
if (/^#/.test(ref)) { ref = (context._href || '/') + ref; }
return generator.fragment$[ref];
} | [
"function",
"resolve",
"(",
"ref",
",",
"context",
")",
"{",
"if",
"(",
"typeof",
"ref",
"!==",
"'string'",
")",
"return",
"ref",
";",
"if",
"(",
"/",
"^#",
"/",
".",
"test",
"(",
"ref",
")",
")",
"{",
"ref",
"=",
"(",
"context",
".",
"_href",
"||",
"'/'",
")",
"+",
"ref",
";",
"}",
"return",
"generator",
".",
"fragment$",
"[",
"ref",
"]",
";",
"}"
]
| resolve references to fragments directly or via href string | [
"resolve",
"references",
"to",
"fragments",
"directly",
"or",
"via",
"href",
"string"
]
| 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/helpers.js#L236-L240 |
45,466 | jldec/pub-generator | helpers.js | pageLang | function pageLang(page) {
return page.lang ||
opts.lang ||
(opts.langDirs && !u.isRootLevel(page._href) && u.topLevel(page._href)) ||
'en';
} | javascript | function pageLang(page) {
return page.lang ||
opts.lang ||
(opts.langDirs && !u.isRootLevel(page._href) && u.topLevel(page._href)) ||
'en';
} | [
"function",
"pageLang",
"(",
"page",
")",
"{",
"return",
"page",
".",
"lang",
"||",
"opts",
".",
"lang",
"||",
"(",
"opts",
".",
"langDirs",
"&&",
"!",
"u",
".",
"isRootLevel",
"(",
"page",
".",
"_href",
")",
"&&",
"u",
".",
"topLevel",
"(",
"page",
".",
"_href",
")",
")",
"||",
"'en'",
";",
"}"
]
| determine language string for a page | [
"determine",
"language",
"string",
"for",
"a",
"page"
]
| 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/helpers.js#L243-L248 |
45,467 | jldec/pub-generator | helpers.js | defaultFragmentHtml | function defaultFragmentHtml(fragmentName, faMarkdown, html, frame) {
var f = generator.fragment$[fragmentName];
if (f) return fragmentHtml(f);
if (faMarkdown && u.find(opts.pkgs, function(pkg) {
return ('pub-pkg-font-awesome' === pkg.pkgName);
})) {
return fragmentHtml( { _txt:faMarkdown, _href:'/#synthetic' }, {noWrap:1});
}
return /</.test(html) ? html :
fragmentHtml( {_txt:html, _href:'/#synthetic' }, {noWrap:1});
} | javascript | function defaultFragmentHtml(fragmentName, faMarkdown, html, frame) {
var f = generator.fragment$[fragmentName];
if (f) return fragmentHtml(f);
if (faMarkdown && u.find(opts.pkgs, function(pkg) {
return ('pub-pkg-font-awesome' === pkg.pkgName);
})) {
return fragmentHtml( { _txt:faMarkdown, _href:'/#synthetic' }, {noWrap:1});
}
return /</.test(html) ? html :
fragmentHtml( {_txt:html, _href:'/#synthetic' }, {noWrap:1});
} | [
"function",
"defaultFragmentHtml",
"(",
"fragmentName",
",",
"faMarkdown",
",",
"html",
",",
"frame",
")",
"{",
"var",
"f",
"=",
"generator",
".",
"fragment$",
"[",
"fragmentName",
"]",
";",
"if",
"(",
"f",
")",
"return",
"fragmentHtml",
"(",
"f",
")",
";",
"if",
"(",
"faMarkdown",
"&&",
"u",
".",
"find",
"(",
"opts",
".",
"pkgs",
",",
"function",
"(",
"pkg",
")",
"{",
"return",
"(",
"'pub-pkg-font-awesome'",
"===",
"pkg",
".",
"pkgName",
")",
";",
"}",
")",
")",
"{",
"return",
"fragmentHtml",
"(",
"{",
"_txt",
":",
"faMarkdown",
",",
"_href",
":",
"'/#synthetic'",
"}",
",",
"{",
"noWrap",
":",
"1",
"}",
")",
";",
"}",
"return",
"/",
"<",
"/",
".",
"test",
"(",
"html",
")",
"?",
"html",
":",
"fragmentHtml",
"(",
"{",
"_txt",
":",
"html",
",",
"_href",
":",
"'/#synthetic'",
"}",
",",
"{",
"noWrap",
":",
"1",
"}",
")",
";",
"}"
]
| try user-provided fragment, then faMarkdown with font-awesome, then html treat 3rd parameter as markdown if it doesn't contain < | [
"try",
"user",
"-",
"provided",
"fragment",
"then",
"faMarkdown",
"with",
"font",
"-",
"awesome",
"then",
"html",
"treat",
"3rd",
"parameter",
"as",
"markdown",
"if",
"it",
"doesn",
"t",
"contain",
"<"
]
| 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/helpers.js#L404-L416 |
45,468 | socialally/air | lib/air/create.js | el | function el(tag, attrs) {
var n = el.air(create(tag));
if(attrs && n.attr) {
return n.attr(attrs);
}
return n;
} | javascript | function el(tag, attrs) {
var n = el.air(create(tag));
if(attrs && n.attr) {
return n.attr(attrs);
}
return n;
} | [
"function",
"el",
"(",
"tag",
",",
"attrs",
")",
"{",
"var",
"n",
"=",
"el",
".",
"air",
"(",
"create",
"(",
"tag",
")",
")",
";",
"if",
"(",
"attrs",
"&&",
"n",
".",
"attr",
")",
"{",
"return",
"n",
".",
"attr",
"(",
"attrs",
")",
";",
"}",
"return",
"n",
";",
"}"
]
| Create a wrapped DOM element.
@param tag The element tag name.
@param attrs Object map of element attributes. | [
"Create",
"a",
"wrapped",
"DOM",
"element",
"."
]
| a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/create.js#L25-L31 |
45,469 | DynoSRC/dynosrc | lib/git.js | Repo | function Repo(name, username) {
this.name = name;
this.username = username;
this.isLoaded = Deferred();
this.isCloned = Deferred();
this.isClonning = false;
this.branch = null;
} | javascript | function Repo(name, username) {
this.name = name;
this.username = username;
this.isLoaded = Deferred();
this.isCloned = Deferred();
this.isClonning = false;
this.branch = null;
} | [
"function",
"Repo",
"(",
"name",
",",
"username",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"username",
"=",
"username",
";",
"this",
".",
"isLoaded",
"=",
"Deferred",
"(",
")",
";",
"this",
".",
"isCloned",
"=",
"Deferred",
"(",
")",
";",
"this",
".",
"isClonning",
"=",
"false",
";",
"this",
".",
"branch",
"=",
"null",
";",
"}"
]
| Not used, but kinda cool. If we do need this we will swap the git shell aspect out for a stable js-git though under the good | [
"Not",
"used",
"but",
"kinda",
"cool",
".",
"If",
"we",
"do",
"need",
"this",
"we",
"will",
"swap",
"the",
"git",
"shell",
"aspect",
"out",
"for",
"a",
"stable",
"js",
"-",
"git",
"though",
"under",
"the",
"good"
]
| 1a763c9310b719a51b0df56387970ecd3f08c438 | https://github.com/DynoSRC/dynosrc/blob/1a763c9310b719a51b0df56387970ecd3f08c438/lib/git.js#L82-L89 |
45,470 | jaredhanson/antenna | lib/route.js | Route | function Route(topic, fns, options) {
options = options || {};
this.topic = topic;
this.fns = fns;
this.regexp = pattern.parse(topic
, this.keys = []
, options.sensitive
, options.strict);
} | javascript | function Route(topic, fns, options) {
options = options || {};
this.topic = topic;
this.fns = fns;
this.regexp = pattern.parse(topic
, this.keys = []
, options.sensitive
, options.strict);
} | [
"function",
"Route",
"(",
"topic",
",",
"fns",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"topic",
"=",
"topic",
";",
"this",
".",
"fns",
"=",
"fns",
";",
"this",
".",
"regexp",
"=",
"pattern",
".",
"parse",
"(",
"topic",
",",
"this",
".",
"keys",
"=",
"[",
"]",
",",
"options",
".",
"sensitive",
",",
"options",
".",
"strict",
")",
";",
"}"
]
| `Route` constructor.
@api protected | [
"Route",
"constructor",
"."
]
| fecfa8320a29d0f1cf22df0230f3b65a12316087 | https://github.com/jaredhanson/antenna/blob/fecfa8320a29d0f1cf22df0230f3b65a12316087/lib/route.js#L12-L20 |
45,471 | henrytseng/angular-state-router | src/services/url-manager.js | function() {
var current = $state.current();
if(current && current.url) {
var path;
path = current.url;
// Add parameters or use default parameters
var params = current.params || {};
var query = {};
for(var name in params) {
var re = new RegExp(':'+name, 'g');
if(path.match(re)) {
path = path.replace(re, params[name]);
} else {
query[name] = params[name];
}
}
$location.path(path);
$location.search(query);
_url = $location.url();
}
} | javascript | function() {
var current = $state.current();
if(current && current.url) {
var path;
path = current.url;
// Add parameters or use default parameters
var params = current.params || {};
var query = {};
for(var name in params) {
var re = new RegExp(':'+name, 'g');
if(path.match(re)) {
path = path.replace(re, params[name]);
} else {
query[name] = params[name];
}
}
$location.path(path);
$location.search(query);
_url = $location.url();
}
} | [
"function",
"(",
")",
"{",
"var",
"current",
"=",
"$state",
".",
"current",
"(",
")",
";",
"if",
"(",
"current",
"&&",
"current",
".",
"url",
")",
"{",
"var",
"path",
";",
"path",
"=",
"current",
".",
"url",
";",
"// Add parameters or use default parameters",
"var",
"params",
"=",
"current",
".",
"params",
"||",
"{",
"}",
";",
"var",
"query",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"name",
"in",
"params",
")",
"{",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"':'",
"+",
"name",
",",
"'g'",
")",
";",
"if",
"(",
"path",
".",
"match",
"(",
"re",
")",
")",
"{",
"path",
"=",
"path",
".",
"replace",
"(",
"re",
",",
"params",
"[",
"name",
"]",
")",
";",
"}",
"else",
"{",
"query",
"[",
"name",
"]",
"=",
"params",
"[",
"name",
"]",
";",
"}",
"}",
"$location",
".",
"path",
"(",
"path",
")",
";",
"$location",
".",
"search",
"(",
"query",
")",
";",
"_url",
"=",
"$location",
".",
"url",
"(",
")",
";",
"}",
"}"
]
| Update URL based on state | [
"Update",
"URL",
"based",
"on",
"state"
]
| 5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b | https://github.com/henrytseng/angular-state-router/blob/5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b/src/services/url-manager.js#L14-L38 |
|
45,472 | keybase/node-bitcoin | lib/lib.js | function (str) {
for (var bytes = [], i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i) & 0xFF);
return bytes;
} | javascript | function (str) {
for (var bytes = [], i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i) & 0xFF);
return bytes;
} | [
"function",
"(",
"str",
")",
"{",
"for",
"(",
"var",
"bytes",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"++",
")",
"bytes",
".",
"push",
"(",
"str",
".",
"charCodeAt",
"(",
"i",
")",
"&",
"0xFF",
")",
";",
"return",
"bytes",
";",
"}"
]
| Convert a string to a byte array | [
"Convert",
"a",
"string",
"to",
"a",
"byte",
"array"
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L1455-L1459 |
|
45,473 | keybase/node-bitcoin | lib/lib.js | function (bytes) {
for (var str = [], i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
} | javascript | function (bytes) {
for (var str = [], i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
} | [
"function",
"(",
"bytes",
")",
"{",
"for",
"(",
"var",
"str",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"str",
".",
"push",
"(",
"String",
".",
"fromCharCode",
"(",
"bytes",
"[",
"i",
"]",
")",
")",
";",
"return",
"str",
".",
"join",
"(",
"\"\"",
")",
";",
"}"
]
| Convert a byte array to a string | [
"Convert",
"a",
"byte",
"array",
"to",
"a",
"string"
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L1462-L1466 |
|
45,474 | keybase/node-bitcoin | lib/lib.js | function () {
// p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
var p = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
var a = BigInteger.ZERO;
var b = ec.fromHex("7");
var n = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
var h = BigInteger.ONE;
var curve = new ec.CurveFp(p, a, b);
var G = curve.decodePointHex("04"
+ "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"
+ "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");
return new ec.X9Parameters(curve, G, n, h);
} | javascript | function () {
// p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
var p = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
var a = BigInteger.ZERO;
var b = ec.fromHex("7");
var n = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
var h = BigInteger.ONE;
var curve = new ec.CurveFp(p, a, b);
var G = curve.decodePointHex("04"
+ "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"
+ "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");
return new ec.X9Parameters(curve, G, n, h);
} | [
"function",
"(",
")",
"{",
"// p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1",
"var",
"p",
"=",
"ec",
".",
"fromHex",
"(",
"\"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F\"",
")",
";",
"var",
"a",
"=",
"BigInteger",
".",
"ZERO",
";",
"var",
"b",
"=",
"ec",
".",
"fromHex",
"(",
"\"7\"",
")",
";",
"var",
"n",
"=",
"ec",
".",
"fromHex",
"(",
"\"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141\"",
")",
";",
"var",
"h",
"=",
"BigInteger",
".",
"ONE",
";",
"var",
"curve",
"=",
"new",
"ec",
".",
"CurveFp",
"(",
"p",
",",
"a",
",",
"b",
")",
";",
"var",
"G",
"=",
"curve",
".",
"decodePointHex",
"(",
"\"04\"",
"+",
"\"79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798\"",
"+",
"\"483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8\"",
")",
";",
"return",
"new",
"ec",
".",
"X9Parameters",
"(",
"curve",
",",
"G",
",",
"n",
",",
"h",
")",
";",
"}"
]
| used by Bitcoin | [
"used",
"by",
"Bitcoin"
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2391-L2403 |
|
45,475 | keybase/node-bitcoin | lib/lib.js | function (input) {
var bi = BigInteger.fromByteArrayUnsigned(input);
var chars = [];
while (bi.compareTo(B58.base) >= 0) {
var mod = bi.mod(B58.base);
chars.unshift(B58.alphabet[mod.intValue()]);
bi = bi.subtract(mod).divide(B58.base);
}
chars.unshift(B58.alphabet[bi.intValue()]);
// Convert leading zeros too.
for (var i = 0; i < input.length; i++) {
if (input[i] == 0x00) {
chars.unshift(B58.alphabet[0]);
} else break;
}
return chars.join('');
} | javascript | function (input) {
var bi = BigInteger.fromByteArrayUnsigned(input);
var chars = [];
while (bi.compareTo(B58.base) >= 0) {
var mod = bi.mod(B58.base);
chars.unshift(B58.alphabet[mod.intValue()]);
bi = bi.subtract(mod).divide(B58.base);
}
chars.unshift(B58.alphabet[bi.intValue()]);
// Convert leading zeros too.
for (var i = 0; i < input.length; i++) {
if (input[i] == 0x00) {
chars.unshift(B58.alphabet[0]);
} else break;
}
return chars.join('');
} | [
"function",
"(",
"input",
")",
"{",
"var",
"bi",
"=",
"BigInteger",
".",
"fromByteArrayUnsigned",
"(",
"input",
")",
";",
"var",
"chars",
"=",
"[",
"]",
";",
"while",
"(",
"bi",
".",
"compareTo",
"(",
"B58",
".",
"base",
")",
">=",
"0",
")",
"{",
"var",
"mod",
"=",
"bi",
".",
"mod",
"(",
"B58",
".",
"base",
")",
";",
"chars",
".",
"unshift",
"(",
"B58",
".",
"alphabet",
"[",
"mod",
".",
"intValue",
"(",
")",
"]",
")",
";",
"bi",
"=",
"bi",
".",
"subtract",
"(",
"mod",
")",
".",
"divide",
"(",
"B58",
".",
"base",
")",
";",
"}",
"chars",
".",
"unshift",
"(",
"B58",
".",
"alphabet",
"[",
"bi",
".",
"intValue",
"(",
")",
"]",
")",
";",
"// Convert leading zeros too.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"input",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"input",
"[",
"i",
"]",
"==",
"0x00",
")",
"{",
"chars",
".",
"unshift",
"(",
"B58",
".",
"alphabet",
"[",
"0",
"]",
")",
";",
"}",
"else",
"break",
";",
"}",
"return",
"chars",
".",
"join",
"(",
"''",
")",
";",
"}"
]
| Convert a byte array to a base58-encoded string.
Written by Mike Hearn for BitcoinJ.
Copyright (c) 2011 Google Inc.
Ported to JavaScript by Stefan Thomas. | [
"Convert",
"a",
"byte",
"array",
"to",
"a",
"base58",
"-",
"encoded",
"string",
"."
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2486-L2505 |
|
45,476 | keybase/node-bitcoin | lib/lib.js | function (len, val) {
var array = [];
var i = 0;
while (i < len) {
array[i++] = val;
}
return array;
} | javascript | function (len, val) {
var array = [];
var i = 0;
while (i < len) {
array[i++] = val;
}
return array;
} | [
"function",
"(",
"len",
",",
"val",
")",
"{",
"var",
"array",
"=",
"[",
"]",
";",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"len",
")",
"{",
"array",
"[",
"i",
"++",
"]",
"=",
"val",
";",
"}",
"return",
"array",
";",
"}"
]
| Create an array of a certain length filled with a specific value. | [
"Create",
"an",
"array",
"of",
"a",
"certain",
"length",
"filled",
"with",
"a",
"specific",
"value",
"."
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2815-L2822 |
|
45,477 | keybase/node-bitcoin | lib/lib.js | function (i) {
if (i < 0xfd) {
// unsigned char
return [i];
} else if (i <= 1 << 16) {
// unsigned short (LE)
return [0xfd, i >>> 8, i & 255];
} else if (i <= 1 << 32) {
// unsigned int (LE)
return [0xfe].concat(Crypto.util.wordsToBytes([i]));
} else {
// unsigned long long (LE)
return [0xff].concat(Crypto.util.wordsToBytes([i >>> 32, i]));
}
} | javascript | function (i) {
if (i < 0xfd) {
// unsigned char
return [i];
} else if (i <= 1 << 16) {
// unsigned short (LE)
return [0xfd, i >>> 8, i & 255];
} else if (i <= 1 << 32) {
// unsigned int (LE)
return [0xfe].concat(Crypto.util.wordsToBytes([i]));
} else {
// unsigned long long (LE)
return [0xff].concat(Crypto.util.wordsToBytes([i >>> 32, i]));
}
} | [
"function",
"(",
"i",
")",
"{",
"if",
"(",
"i",
"<",
"0xfd",
")",
"{",
"// unsigned char",
"return",
"[",
"i",
"]",
";",
"}",
"else",
"if",
"(",
"i",
"<=",
"1",
"<<",
"16",
")",
"{",
"// unsigned short (LE)",
"return",
"[",
"0xfd",
",",
"i",
">>>",
"8",
",",
"i",
"&",
"255",
"]",
";",
"}",
"else",
"if",
"(",
"i",
"<=",
"1",
"<<",
"32",
")",
"{",
"// unsigned int (LE)",
"return",
"[",
"0xfe",
"]",
".",
"concat",
"(",
"Crypto",
".",
"util",
".",
"wordsToBytes",
"(",
"[",
"i",
"]",
")",
")",
";",
"}",
"else",
"{",
"// unsigned long long (LE)",
"return",
"[",
"0xff",
"]",
".",
"concat",
"(",
"Crypto",
".",
"util",
".",
"wordsToBytes",
"(",
"[",
"i",
">>>",
"32",
",",
"i",
"]",
")",
")",
";",
"}",
"}"
]
| Turn an integer into a "var_int".
"var_int" is a variable length integer used by Bitcoin's binary format.
Returns a byte array. | [
"Turn",
"an",
"integer",
"into",
"a",
"var_int",
"."
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2830-L2844 |
|
45,478 | keybase/node-bitcoin | lib/lib.js | function (valueBuffer) {
var value = this.valueToBigInt(valueBuffer).toString();
var integerPart = value.length > 8 ? value.substr(0, value.length - 8) : '0';
var decimalPart = value.length > 8 ? value.substr(value.length - 8) : value;
while (decimalPart.length < 8) decimalPart = "0" + decimalPart;
decimalPart = decimalPart.replace(/0*$/, '');
while (decimalPart.length < 2) decimalPart += "0";
return integerPart + "." + decimalPart;
} | javascript | function (valueBuffer) {
var value = this.valueToBigInt(valueBuffer).toString();
var integerPart = value.length > 8 ? value.substr(0, value.length - 8) : '0';
var decimalPart = value.length > 8 ? value.substr(value.length - 8) : value;
while (decimalPart.length < 8) decimalPart = "0" + decimalPart;
decimalPart = decimalPart.replace(/0*$/, '');
while (decimalPart.length < 2) decimalPart += "0";
return integerPart + "." + decimalPart;
} | [
"function",
"(",
"valueBuffer",
")",
"{",
"var",
"value",
"=",
"this",
".",
"valueToBigInt",
"(",
"valueBuffer",
")",
".",
"toString",
"(",
")",
";",
"var",
"integerPart",
"=",
"value",
".",
"length",
">",
"8",
"?",
"value",
".",
"substr",
"(",
"0",
",",
"value",
".",
"length",
"-",
"8",
")",
":",
"'0'",
";",
"var",
"decimalPart",
"=",
"value",
".",
"length",
">",
"8",
"?",
"value",
".",
"substr",
"(",
"value",
".",
"length",
"-",
"8",
")",
":",
"value",
";",
"while",
"(",
"decimalPart",
".",
"length",
"<",
"8",
")",
"decimalPart",
"=",
"\"0\"",
"+",
"decimalPart",
";",
"decimalPart",
"=",
"decimalPart",
".",
"replace",
"(",
"/",
"0*$",
"/",
",",
"''",
")",
";",
"while",
"(",
"decimalPart",
".",
"length",
"<",
"2",
")",
"decimalPart",
"+=",
"\"0\"",
";",
"return",
"integerPart",
"+",
"\".\"",
"+",
"decimalPart",
";",
"}"
]
| Format a Bitcoin value as a string.
Takes a BigInteger or byte-array and returns that amount of Bitcoins in a
nice standard formatting.
Examples:
12.3555
0.1234
900.99998888
34.00 | [
"Format",
"a",
"Bitcoin",
"value",
"as",
"a",
"string",
"."
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2866-L2874 |
|
45,479 | keybase/node-bitcoin | lib/lib.js | function (valueString) {
// TODO: Detect other number formats (e.g. comma as decimal separator)
var valueComp = valueString.split('.');
var integralPart = valueComp[0];
var fractionalPart = valueComp[1] || "0";
while (fractionalPart.length < 8) fractionalPart += "0";
fractionalPart = fractionalPart.replace(/^0+/g, '');
var value = BigInteger.valueOf(parseInt(integralPart));
value = value.multiply(BigInteger.valueOf(100000000));
value = value.add(BigInteger.valueOf(parseInt(fractionalPart)));
return value;
} | javascript | function (valueString) {
// TODO: Detect other number formats (e.g. comma as decimal separator)
var valueComp = valueString.split('.');
var integralPart = valueComp[0];
var fractionalPart = valueComp[1] || "0";
while (fractionalPart.length < 8) fractionalPart += "0";
fractionalPart = fractionalPart.replace(/^0+/g, '');
var value = BigInteger.valueOf(parseInt(integralPart));
value = value.multiply(BigInteger.valueOf(100000000));
value = value.add(BigInteger.valueOf(parseInt(fractionalPart)));
return value;
} | [
"function",
"(",
"valueString",
")",
"{",
"// TODO: Detect other number formats (e.g. comma as decimal separator)",
"var",
"valueComp",
"=",
"valueString",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"integralPart",
"=",
"valueComp",
"[",
"0",
"]",
";",
"var",
"fractionalPart",
"=",
"valueComp",
"[",
"1",
"]",
"||",
"\"0\"",
";",
"while",
"(",
"fractionalPart",
".",
"length",
"<",
"8",
")",
"fractionalPart",
"+=",
"\"0\"",
";",
"fractionalPart",
"=",
"fractionalPart",
".",
"replace",
"(",
"/",
"^0+",
"/",
"g",
",",
"''",
")",
";",
"var",
"value",
"=",
"BigInteger",
".",
"valueOf",
"(",
"parseInt",
"(",
"integralPart",
")",
")",
";",
"value",
"=",
"value",
".",
"multiply",
"(",
"BigInteger",
".",
"valueOf",
"(",
"100000000",
")",
")",
";",
"value",
"=",
"value",
".",
"add",
"(",
"BigInteger",
".",
"valueOf",
"(",
"parseInt",
"(",
"fractionalPart",
")",
")",
")",
";",
"return",
"value",
";",
"}"
]
| Parse a floating point string as a Bitcoin value.
Keep in mind that parsing user input is messy. You should always display
the parsed value back to the user to make sure we understood his input
correctly. | [
"Parse",
"a",
"floating",
"point",
"string",
"as",
"a",
"Bitcoin",
"value",
"."
]
| 44d9e7279f48be95e3e7bb61110a4d76e71a977a | https://github.com/keybase/node-bitcoin/blob/44d9e7279f48be95e3e7bb61110a4d76e71a977a/lib/lib.js#L2882-L2893 |
|
45,480 | nyurik/mw-graph-shared | src/VegaWrapper.js | removeColon | function removeColon(protocol) {
return protocol && protocol.length && protocol[protocol.length - 1] === ':'
? protocol.substring(0, protocol.length - 1) : protocol;
} | javascript | function removeColon(protocol) {
return protocol && protocol.length && protocol[protocol.length - 1] === ':'
? protocol.substring(0, protocol.length - 1) : protocol;
} | [
"function",
"removeColon",
"(",
"protocol",
")",
"{",
"return",
"protocol",
"&&",
"protocol",
".",
"length",
"&&",
"protocol",
"[",
"protocol",
".",
"length",
"-",
"1",
"]",
"===",
"':'",
"?",
"protocol",
".",
"substring",
"(",
"0",
",",
"protocol",
".",
"length",
"-",
"1",
")",
":",
"protocol",
";",
"}"
]
| Utility function to remove trailing colon from a protocol
@param {string} protocol
@return {string} | [
"Utility",
"function",
"to",
"remove",
"trailing",
"colon",
"from",
"a",
"protocol"
]
| 0e1dd7356de18a0631680f4dd7231a3a2746093d | https://github.com/nyurik/mw-graph-shared/blob/0e1dd7356de18a0631680f4dd7231a3a2746093d/src/VegaWrapper.js#L15-L18 |
45,481 | nyurik/mw-graph-shared | src/VegaWrapper.js | VegaWrapper | function VegaWrapper(wrapperOpts) {
var self = this;
// Copy all options into this object
self.objExtender = wrapperOpts.datalib.extend;
self.objExtender(self, wrapperOpts);
self.validators = {};
self.datalib.load.loader = function (opt, callback) {
var error = callback || function (e) { throw e; }, url;
try {
url = self.sanitizeUrl(opt); // enable override
} catch (err) {
error(err);
return;
}
// Process data response
var cb = function (error, data) {
return self.dataParser(error, data, opt, callback);
};
if (self.useXhr) {
return self.datalib.load.xhr(url, opt, cb);
} else {
return self.datalib.load.http(url, opt, cb);
}
};
self.datalib.load.sanitizeUrl = self.sanitizeUrl.bind(self);
// Prevent accidental use
self.datalib.load.file = alwaysFail;
if (self.useXhr) {
self.datalib.load.http = alwaysFail;
} else {
self.datalib.load.xhr = alwaysFail;
}
} | javascript | function VegaWrapper(wrapperOpts) {
var self = this;
// Copy all options into this object
self.objExtender = wrapperOpts.datalib.extend;
self.objExtender(self, wrapperOpts);
self.validators = {};
self.datalib.load.loader = function (opt, callback) {
var error = callback || function (e) { throw e; }, url;
try {
url = self.sanitizeUrl(opt); // enable override
} catch (err) {
error(err);
return;
}
// Process data response
var cb = function (error, data) {
return self.dataParser(error, data, opt, callback);
};
if (self.useXhr) {
return self.datalib.load.xhr(url, opt, cb);
} else {
return self.datalib.load.http(url, opt, cb);
}
};
self.datalib.load.sanitizeUrl = self.sanitizeUrl.bind(self);
// Prevent accidental use
self.datalib.load.file = alwaysFail;
if (self.useXhr) {
self.datalib.load.http = alwaysFail;
} else {
self.datalib.load.xhr = alwaysFail;
}
} | [
"function",
"VegaWrapper",
"(",
"wrapperOpts",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Copy all options into this object",
"self",
".",
"objExtender",
"=",
"wrapperOpts",
".",
"datalib",
".",
"extend",
";",
"self",
".",
"objExtender",
"(",
"self",
",",
"wrapperOpts",
")",
";",
"self",
".",
"validators",
"=",
"{",
"}",
";",
"self",
".",
"datalib",
".",
"load",
".",
"loader",
"=",
"function",
"(",
"opt",
",",
"callback",
")",
"{",
"var",
"error",
"=",
"callback",
"||",
"function",
"(",
"e",
")",
"{",
"throw",
"e",
";",
"}",
",",
"url",
";",
"try",
"{",
"url",
"=",
"self",
".",
"sanitizeUrl",
"(",
"opt",
")",
";",
"// enable override",
"}",
"catch",
"(",
"err",
")",
"{",
"error",
"(",
"err",
")",
";",
"return",
";",
"}",
"// Process data response",
"var",
"cb",
"=",
"function",
"(",
"error",
",",
"data",
")",
"{",
"return",
"self",
".",
"dataParser",
"(",
"error",
",",
"data",
",",
"opt",
",",
"callback",
")",
";",
"}",
";",
"if",
"(",
"self",
".",
"useXhr",
")",
"{",
"return",
"self",
".",
"datalib",
".",
"load",
".",
"xhr",
"(",
"url",
",",
"opt",
",",
"cb",
")",
";",
"}",
"else",
"{",
"return",
"self",
".",
"datalib",
".",
"load",
".",
"http",
"(",
"url",
",",
"opt",
",",
"cb",
")",
";",
"}",
"}",
";",
"self",
".",
"datalib",
".",
"load",
".",
"sanitizeUrl",
"=",
"self",
".",
"sanitizeUrl",
".",
"bind",
"(",
"self",
")",
";",
"// Prevent accidental use",
"self",
".",
"datalib",
".",
"load",
".",
"file",
"=",
"alwaysFail",
";",
"if",
"(",
"self",
".",
"useXhr",
")",
"{",
"self",
".",
"datalib",
".",
"load",
".",
"http",
"=",
"alwaysFail",
";",
"}",
"else",
"{",
"self",
".",
"datalib",
".",
"load",
".",
"xhr",
"=",
"alwaysFail",
";",
"}",
"}"
]
| Shared library to wrap around vega code
@param {Object} wrapperOpts Configuration options
@param {Object} wrapperOpts.datalib Vega's datalib object
@param {Object} wrapperOpts.datalib.load Vega's data loader
@param {Function} wrapperOpts.datalib.load.loader Vega's data loader function
@param {Function} wrapperOpts.datalib.extend similar to jquery's extend()
@param {boolean} wrapperOpts.useXhr true if we should use XHR, false for node.js http loading
@param {boolean} wrapperOpts.isTrusted true if the graph spec can be trusted
@param {Object} wrapperOpts.domains allowed protocols and a list of their domains
@param {Object} wrapperOpts.domainMap domain remapping
@param {Function} wrapperOpts.logger
@param {Function} wrapperOpts.parseUrl
@param {Function} wrapperOpts.formatUrl
@param {string} [wrapperOpts.languageCode]
@constructor | [
"Shared",
"library",
"to",
"wrap",
"around",
"vega",
"code"
]
| 0e1dd7356de18a0631680f4dd7231a3a2746093d | https://github.com/nyurik/mw-graph-shared/blob/0e1dd7356de18a0631680f4dd7231a3a2746093d/src/VegaWrapper.js#L37-L75 |
45,482 | theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _prepareViews | function _prepareViews( actionData, paramData )
{
let linkedTranssModules = actionData.linkedVTransModules, // look into slice speed over creating new array
ViewsModuleLength = linkedTranssModules.length,
promises = [],
preparedViews = [],
actionDataClone = null,
viewCache = {},
i = 0,
viewsModuleObject;
while( i < ViewsModuleLength ) {
viewsModuleObject = linkedTranssModules[i];
actionDataClone = _cloneViewState( actionData, viewsModuleObject, paramData );
preparedViews[ preparedViews.length ] = _fetchViews( viewsModuleObject.views, actionDataClone, promises, viewCache);
++i;
}
viewCache = null;
return { promises : promises, preparedViews : preparedViews };
} | javascript | function _prepareViews( actionData, paramData )
{
let linkedTranssModules = actionData.linkedVTransModules, // look into slice speed over creating new array
ViewsModuleLength = linkedTranssModules.length,
promises = [],
preparedViews = [],
actionDataClone = null,
viewCache = {},
i = 0,
viewsModuleObject;
while( i < ViewsModuleLength ) {
viewsModuleObject = linkedTranssModules[i];
actionDataClone = _cloneViewState( actionData, viewsModuleObject, paramData );
preparedViews[ preparedViews.length ] = _fetchViews( viewsModuleObject.views, actionDataClone, promises, viewCache);
++i;
}
viewCache = null;
return { promises : promises, preparedViews : preparedViews };
} | [
"function",
"_prepareViews",
"(",
"actionData",
",",
"paramData",
")",
"{",
"let",
"linkedTranssModules",
"=",
"actionData",
".",
"linkedVTransModules",
",",
"// look into slice speed over creating new array",
"ViewsModuleLength",
"=",
"linkedTranssModules",
".",
"length",
",",
"promises",
"=",
"[",
"]",
",",
"preparedViews",
"=",
"[",
"]",
",",
"actionDataClone",
"=",
"null",
",",
"viewCache",
"=",
"{",
"}",
",",
"i",
"=",
"0",
",",
"viewsModuleObject",
";",
"while",
"(",
"i",
"<",
"ViewsModuleLength",
")",
"{",
"viewsModuleObject",
"=",
"linkedTranssModules",
"[",
"i",
"]",
";",
"actionDataClone",
"=",
"_cloneViewState",
"(",
"actionData",
",",
"viewsModuleObject",
",",
"paramData",
")",
";",
"preparedViews",
"[",
"preparedViews",
".",
"length",
"]",
"=",
"_fetchViews",
"(",
"viewsModuleObject",
".",
"views",
",",
"actionDataClone",
",",
"promises",
",",
"viewCache",
")",
";",
"++",
"i",
";",
"}",
"viewCache",
"=",
"null",
";",
"return",
"{",
"promises",
":",
"promises",
",",
"preparedViews",
":",
"preparedViews",
"}",
";",
"}"
]
| loop through all transition modules and prepare the
views requested by the config
@param {object} actionData containing all transition types and views required
@param {object} paramData sent with the action
@return {object} promises array and pepared views array | [
"loop",
"through",
"all",
"transition",
"modules",
"and",
"prepare",
"the",
"views",
"requested",
"by",
"the",
"config"
]
| a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L35-L56 |
45,483 | theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _fetchViews | function _fetchViews( viewsToPrepare, actionDataClone, promises, viewCache )
{
const views = viewsToPrepare,
viewManager = _options.viewManager,
length = views.length,
currentViewID = actionDataClone.currentViewID,
nextViewID = actionDataClone.nextViewID;
let i = 0,
_deferred,
view,
foundView,
parsedRef,
viewRef;
while( i < length )
{
viewRef = views[ i ];
if(viewRef)
{
foundView = viewCache[ viewRef ];
if(!foundView) { // cache the view instance for reuse if needed
foundView = viewCache[ viewRef ] = viewManager.fetchView( viewRef );
_deferred = Deferred();
promises[ promises.length ] = _deferred.promise;
if( !foundView ){ return TVM.error( viewRef+' is undefined' ); }
if( foundView.prepareView ){ foundView.prepareView( _deferred ); }
else { _deferred.resolve(); }
}
view = foundView;
/* change ref to current view or next view to allow general transitions */
parsedRef = _viewRef(viewRef, [ currentViewID, nextViewID ]);
if( parsedRef ) {
actionDataClone.views[ parsedRef ] = view;
}
actionDataClone.views[ viewRef ] = view;
}
++i;
}
return actionDataClone;
} | javascript | function _fetchViews( viewsToPrepare, actionDataClone, promises, viewCache )
{
const views = viewsToPrepare,
viewManager = _options.viewManager,
length = views.length,
currentViewID = actionDataClone.currentViewID,
nextViewID = actionDataClone.nextViewID;
let i = 0,
_deferred,
view,
foundView,
parsedRef,
viewRef;
while( i < length )
{
viewRef = views[ i ];
if(viewRef)
{
foundView = viewCache[ viewRef ];
if(!foundView) { // cache the view instance for reuse if needed
foundView = viewCache[ viewRef ] = viewManager.fetchView( viewRef );
_deferred = Deferred();
promises[ promises.length ] = _deferred.promise;
if( !foundView ){ return TVM.error( viewRef+' is undefined' ); }
if( foundView.prepareView ){ foundView.prepareView( _deferred ); }
else { _deferred.resolve(); }
}
view = foundView;
/* change ref to current view or next view to allow general transitions */
parsedRef = _viewRef(viewRef, [ currentViewID, nextViewID ]);
if( parsedRef ) {
actionDataClone.views[ parsedRef ] = view;
}
actionDataClone.views[ viewRef ] = view;
}
++i;
}
return actionDataClone;
} | [
"function",
"_fetchViews",
"(",
"viewsToPrepare",
",",
"actionDataClone",
",",
"promises",
",",
"viewCache",
")",
"{",
"const",
"views",
"=",
"viewsToPrepare",
",",
"viewManager",
"=",
"_options",
".",
"viewManager",
",",
"length",
"=",
"views",
".",
"length",
",",
"currentViewID",
"=",
"actionDataClone",
".",
"currentViewID",
",",
"nextViewID",
"=",
"actionDataClone",
".",
"nextViewID",
";",
"let",
"i",
"=",
"0",
",",
"_deferred",
",",
"view",
",",
"foundView",
",",
"parsedRef",
",",
"viewRef",
";",
"while",
"(",
"i",
"<",
"length",
")",
"{",
"viewRef",
"=",
"views",
"[",
"i",
"]",
";",
"if",
"(",
"viewRef",
")",
"{",
"foundView",
"=",
"viewCache",
"[",
"viewRef",
"]",
";",
"if",
"(",
"!",
"foundView",
")",
"{",
"// cache the view instance for reuse if needed",
"foundView",
"=",
"viewCache",
"[",
"viewRef",
"]",
"=",
"viewManager",
".",
"fetchView",
"(",
"viewRef",
")",
";",
"_deferred",
"=",
"Deferred",
"(",
")",
";",
"promises",
"[",
"promises",
".",
"length",
"]",
"=",
"_deferred",
".",
"promise",
";",
"if",
"(",
"!",
"foundView",
")",
"{",
"return",
"TVM",
".",
"error",
"(",
"viewRef",
"+",
"' is undefined'",
")",
";",
"}",
"if",
"(",
"foundView",
".",
"prepareView",
")",
"{",
"foundView",
".",
"prepareView",
"(",
"_deferred",
")",
";",
"}",
"else",
"{",
"_deferred",
".",
"resolve",
"(",
")",
";",
"}",
"}",
"view",
"=",
"foundView",
";",
"/* change ref to current view or next view to allow general transitions */",
"parsedRef",
"=",
"_viewRef",
"(",
"viewRef",
",",
"[",
"currentViewID",
",",
"nextViewID",
"]",
")",
";",
"if",
"(",
"parsedRef",
")",
"{",
"actionDataClone",
".",
"views",
"[",
"parsedRef",
"]",
"=",
"view",
";",
"}",
"actionDataClone",
".",
"views",
"[",
"viewRef",
"]",
"=",
"view",
";",
"}",
"++",
"i",
";",
"}",
"return",
"actionDataClone",
";",
"}"
]
| loop through and fetch all the requested views, use viewReady
and collect a promise for each to allow the view to build up and perform
its preperation tasks if required
@param {array} views - string references
@param {object} actionDataClone - cloned data as to not override config
@param {array} promises - collect all view promises
@param {object} viewCache - prevents views from being instantiated and requested more than once
@return {object} populated actionDataClone data object | [
"loop",
"through",
"and",
"fetch",
"all",
"the",
"requested",
"views",
"use",
"viewReady",
"and",
"collect",
"a",
"promise",
"for",
"each",
"to",
"allow",
"the",
"view",
"to",
"build",
"up",
"and",
"perform",
"its",
"preperation",
"tasks",
"if",
"required"
]
| a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L69-L117 |
45,484 | theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _viewRef | function _viewRef( ref, comparisonViews ) {
var index = comparisonViews.indexOf( ref );
return (index === -1 )? null : ['currentView', 'nextView'][ index ];
} | javascript | function _viewRef( ref, comparisonViews ) {
var index = comparisonViews.indexOf( ref );
return (index === -1 )? null : ['currentView', 'nextView'][ index ];
} | [
"function",
"_viewRef",
"(",
"ref",
",",
"comparisonViews",
")",
"{",
"var",
"index",
"=",
"comparisonViews",
".",
"indexOf",
"(",
"ref",
")",
";",
"return",
"(",
"index",
"===",
"-",
"1",
")",
"?",
"null",
":",
"[",
"'currentView'",
",",
"'nextView'",
"]",
"[",
"index",
"]",
";",
"}"
]
| convert view named references to either current view
or next view if the ID's match
Makes it easier to access and build generic use cases
@param {string} ref current View ID
@param {array} comparisonViews - currentView and nextView string IDS
@return {string} - new IDS if matched | [
"convert",
"view",
"named",
"references",
"to",
"either",
"current",
"view",
"or",
"next",
"view",
"if",
"the",
"ID",
"s",
"match",
"Makes",
"it",
"easier",
"to",
"access",
"and",
"build",
"generic",
"use",
"cases"
]
| a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L128-L131 |
45,485 | theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _getCached | function _getCached( cached, data )
{
if( !data ){ return cached; }
let i = -1, len = cached.length;
while (++i < len) {
cached[i].data = data;
}
return cached;
} | javascript | function _getCached( cached, data )
{
if( !data ){ return cached; }
let i = -1, len = cached.length;
while (++i < len) {
cached[i].data = data;
}
return cached;
} | [
"function",
"_getCached",
"(",
"cached",
",",
"data",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"cached",
";",
"}",
"let",
"i",
"=",
"-",
"1",
",",
"len",
"=",
"cached",
".",
"length",
";",
"while",
"(",
"++",
"i",
"<",
"len",
")",
"{",
"cached",
"[",
"i",
"]",
".",
"data",
"=",
"data",
";",
"}",
"return",
"cached",
";",
"}"
]
| return cached views based on action type
@param {array} cached - previously prepared views
@param {object} data - action data passed through with action
@return {array} - cached views | [
"return",
"cached",
"views",
"based",
"on",
"action",
"type"
]
| a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L140-L149 |
45,486 | theboyWhoCriedWoolf/transition-manager | src/core/transitionViewManager.js | _cloneViewState | function _cloneViewState( actionData, transitionObject, paramData ) {
return {
data : paramData,
currentViewID : actionData.currentView, // optional
nextViewID : actionData.nextView, // optional
views : {},
transitionType : transitionObject.transitionType
};
} | javascript | function _cloneViewState( actionData, transitionObject, paramData ) {
return {
data : paramData,
currentViewID : actionData.currentView, // optional
nextViewID : actionData.nextView, // optional
views : {},
transitionType : transitionObject.transitionType
};
} | [
"function",
"_cloneViewState",
"(",
"actionData",
",",
"transitionObject",
",",
"paramData",
")",
"{",
"return",
"{",
"data",
":",
"paramData",
",",
"currentViewID",
":",
"actionData",
".",
"currentView",
",",
"// optional",
"nextViewID",
":",
"actionData",
".",
"nextView",
",",
"// optional",
"views",
":",
"{",
"}",
",",
"transitionType",
":",
"transitionObject",
".",
"transitionType",
"}",
";",
"}"
]
| clone the action data object
fast clone and prevents the config references to be
oweriden by instances or other settings
@param {object} actionData passed in from the config
@param {object} transitionObject - action data transition
@param {object} paramData sent with the action
@return {object} new object with an instance or reference from the params | [
"clone",
"the",
"action",
"data",
"object",
"fast",
"clone",
"and",
"prevents",
"the",
"config",
"references",
"to",
"be",
"oweriden",
"by",
"instances",
"or",
"other",
"settings"
]
| a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/core/transitionViewManager.js#L160-L168 |
45,487 | shamoons/linguist-samples | samples/JavaScript/http.js | parserOnHeaders | function parserOnHeaders(headers, url) {
// Once we exceeded headers limit - stop collecting them
if (this.maxHeaderPairs <= 0 ||
this._headers.length < this.maxHeaderPairs) {
this._headers = this._headers.concat(headers);
}
this._url += url;
} | javascript | function parserOnHeaders(headers, url) {
// Once we exceeded headers limit - stop collecting them
if (this.maxHeaderPairs <= 0 ||
this._headers.length < this.maxHeaderPairs) {
this._headers = this._headers.concat(headers);
}
this._url += url;
} | [
"function",
"parserOnHeaders",
"(",
"headers",
",",
"url",
")",
"{",
"// Once we exceeded headers limit - stop collecting them",
"if",
"(",
"this",
".",
"maxHeaderPairs",
"<=",
"0",
"||",
"this",
".",
"_headers",
".",
"length",
"<",
"this",
".",
"maxHeaderPairs",
")",
"{",
"this",
".",
"_headers",
"=",
"this",
".",
"_headers",
".",
"concat",
"(",
"headers",
")",
";",
"}",
"this",
".",
"_url",
"+=",
"url",
";",
"}"
]
| Only called in the slow case where slow means that the request headers were either fragmented across multiple TCP packets or too large to be processed in a single run. This method is also called to process trailing HTTP headers. | [
"Only",
"called",
"in",
"the",
"slow",
"case",
"where",
"slow",
"means",
"that",
"the",
"request",
"headers",
"were",
"either",
"fragmented",
"across",
"multiple",
"TCP",
"packets",
"or",
"too",
"large",
"to",
"be",
"processed",
"in",
"a",
"single",
"run",
".",
"This",
"method",
"is",
"also",
"called",
"to",
"process",
"trailing",
"HTTP",
"headers",
"."
]
| 71c5ec1a535f7dde31f9e407679475f57fae0c08 | https://github.com/shamoons/linguist-samples/blob/71c5ec1a535f7dde31f9e407679475f57fae0c08/samples/JavaScript/http.js#L45-L52 |
45,488 | zipscene/winston-daily-rotate | index.js | throwIf | function throwIf (target /*, illegal... */) {
Array.prototype.slice.call(arguments, 1).forEach(function (name) {
if (options[name]) {
throw new Error('Cannot set ' + name + ' and ' + target + 'together');
}
});
} | javascript | function throwIf (target /*, illegal... */) {
Array.prototype.slice.call(arguments, 1).forEach(function (name) {
if (options[name]) {
throw new Error('Cannot set ' + name + ' and ' + target + 'together');
}
});
} | [
"function",
"throwIf",
"(",
"target",
"/*, illegal... */",
")",
"{",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"if",
"(",
"options",
"[",
"name",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Cannot set '",
"+",
"name",
"+",
"' and '",
"+",
"target",
"+",
"'together'",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Helper function which throws an `Error` in the event that any of the rest of the arguments is present in `options`. | [
"Helper",
"function",
"which",
"throws",
"an",
"Error",
"in",
"the",
"event",
"that",
"any",
"of",
"the",
"rest",
"of",
"the",
"arguments",
"is",
"present",
"in",
"options",
"."
]
| 63a708572475b766061cb950e9dd1f98b20ea772 | https://github.com/zipscene/winston-daily-rotate/blob/63a708572475b766061cb950e9dd1f98b20ea772/index.js#L35-L41 |
45,489 | mesmotronic/conbo | examples/Template.js | function()
{
this.appendView
(
new ns.MyLoadedView(this.context.addTo({templateUrl:'template-2.html'})),
new ns.MyOtherView(this.context.addTo({template:'This is an internal template using <b>options.template</b> that hates <span cb-style="favoriteColor:color">{{favoriteColor}}</span>'}))
);
} | javascript | function()
{
this.appendView
(
new ns.MyLoadedView(this.context.addTo({templateUrl:'template-2.html'})),
new ns.MyOtherView(this.context.addTo({template:'This is an internal template using <b>options.template</b> that hates <span cb-style="favoriteColor:color">{{favoriteColor}}</span>'}))
);
} | [
"function",
"(",
")",
"{",
"this",
".",
"appendView",
"(",
"new",
"ns",
".",
"MyLoadedView",
"(",
"this",
".",
"context",
".",
"addTo",
"(",
"{",
"templateUrl",
":",
"'template-2.html'",
"}",
")",
")",
",",
"new",
"ns",
".",
"MyOtherView",
"(",
"this",
".",
"context",
".",
"addTo",
"(",
"{",
"template",
":",
"'This is an internal template using <b>options.template</b> that hates <span cb-style=\"favoriteColor:color\">{{favoriteColor}}</span>'",
"}",
")",
")",
")",
";",
"}"
]
| All classes have an initialize entry point | [
"All",
"classes",
"have",
"an",
"initialize",
"entry",
"point"
]
| 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/examples/Template.js#L50-L57 |
|
45,490 | Stitchuuuu/thread-promisify | thread.js | Log | function Log() {
var args = CopyArguments(arguments);
var level = args.shift();
args.unshift("[Thread] <"+threadId+">");
args.unshift(level);
process.send({name: "thread-log", args: SerializeForProcess(args)});
} | javascript | function Log() {
var args = CopyArguments(arguments);
var level = args.shift();
args.unshift("[Thread] <"+threadId+">");
args.unshift(level);
process.send({name: "thread-log", args: SerializeForProcess(args)});
} | [
"function",
"Log",
"(",
")",
"{",
"var",
"args",
"=",
"CopyArguments",
"(",
"arguments",
")",
";",
"var",
"level",
"=",
"args",
".",
"shift",
"(",
")",
";",
"args",
".",
"unshift",
"(",
"\"[Thread] <\"",
"+",
"threadId",
"+",
"\">\"",
")",
";",
"args",
".",
"unshift",
"(",
"level",
")",
";",
"process",
".",
"send",
"(",
"{",
"name",
":",
"\"thread-log\"",
",",
"args",
":",
"SerializeForProcess",
"(",
"args",
")",
"}",
")",
";",
"}"
]
| Log an information | [
"Log",
"an",
"information"
]
| 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/thread.js#L14-L20 |
45,491 | Stitchuuuu/thread-promisify | thread.js | ConvertArgs | function ConvertArgs(args, baseResponse) {
var baseResponse = Object.assign({}, baseResponse);
args.forEach(function(arg, i) {
if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
var idRemoteFunction = arg.id;
args[i] = function() {
process.send(Object.assign(baseResponse, {name: "thread-execute-remote-function", args: [{id: idRemoteFunction, args: SerializeForProcess(CopyArguments(arguments))}]}));
};
}
});
return args;
} | javascript | function ConvertArgs(args, baseResponse) {
var baseResponse = Object.assign({}, baseResponse);
args.forEach(function(arg, i) {
if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
var idRemoteFunction = arg.id;
args[i] = function() {
process.send(Object.assign(baseResponse, {name: "thread-execute-remote-function", args: [{id: idRemoteFunction, args: SerializeForProcess(CopyArguments(arguments))}]}));
};
}
});
return args;
} | [
"function",
"ConvertArgs",
"(",
"args",
",",
"baseResponse",
")",
"{",
"var",
"baseResponse",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"baseResponse",
")",
";",
"args",
".",
"forEach",
"(",
"function",
"(",
"arg",
",",
"i",
")",
"{",
"if",
"(",
"typeof",
"(",
"arg",
")",
"==",
"\"object\"",
"&&",
"arg",
".",
"_classname",
"==",
"\"SerializedFunction\"",
")",
"{",
"var",
"idRemoteFunction",
"=",
"arg",
".",
"id",
";",
"args",
"[",
"i",
"]",
"=",
"function",
"(",
")",
"{",
"process",
".",
"send",
"(",
"Object",
".",
"assign",
"(",
"baseResponse",
",",
"{",
"name",
":",
"\"thread-execute-remote-function\"",
",",
"args",
":",
"[",
"{",
"id",
":",
"idRemoteFunction",
",",
"args",
":",
"SerializeForProcess",
"(",
"CopyArguments",
"(",
"arguments",
")",
")",
"}",
"]",
"}",
")",
")",
";",
"}",
";",
"}",
"}",
")",
";",
"return",
"args",
";",
"}"
]
| Convert SerializedFunction objects to function, so when called
we execute the function in the original thread | [
"Convert",
"SerializedFunction",
"objects",
"to",
"function",
"so",
"when",
"called",
"we",
"execute",
"the",
"function",
"in",
"the",
"original",
"thread"
]
| 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/thread.js#L26-L37 |
45,492 | Stitchuuuu/thread-promisify | thread.js | finalizeRequestDone | function finalizeRequestDone() {
if (PendingRequests.length) {
// If we have queued requests, we execute the next one
currentRequest = PendingRequests.shift();
Log(3, "Executing request", currentRequest.id);
executeRequest(currentRequest);
} else {
// We set a timeout in case of other requests blocked in the process
executing = false;
PendingTimeout = setTimeout(() => {
if (Object.keys(PendingRequests).length == 0) {
// Telling main thread that he can kill us if he wants
Log(3, "Inactive thread");
process.send({name: "thread-no-pending-requests", args: [{threadId: threadId}]});
}
}, 1000);
}
} | javascript | function finalizeRequestDone() {
if (PendingRequests.length) {
// If we have queued requests, we execute the next one
currentRequest = PendingRequests.shift();
Log(3, "Executing request", currentRequest.id);
executeRequest(currentRequest);
} else {
// We set a timeout in case of other requests blocked in the process
executing = false;
PendingTimeout = setTimeout(() => {
if (Object.keys(PendingRequests).length == 0) {
// Telling main thread that he can kill us if he wants
Log(3, "Inactive thread");
process.send({name: "thread-no-pending-requests", args: [{threadId: threadId}]});
}
}, 1000);
}
} | [
"function",
"finalizeRequestDone",
"(",
")",
"{",
"if",
"(",
"PendingRequests",
".",
"length",
")",
"{",
"// If we have queued requests, we execute the next one",
"currentRequest",
"=",
"PendingRequests",
".",
"shift",
"(",
")",
";",
"Log",
"(",
"3",
",",
"\"Executing request\"",
",",
"currentRequest",
".",
"id",
")",
";",
"executeRequest",
"(",
"currentRequest",
")",
";",
"}",
"else",
"{",
"// We set a timeout in case of other requests blocked in the process",
"executing",
"=",
"false",
";",
"PendingTimeout",
"=",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"Object",
".",
"keys",
"(",
"PendingRequests",
")",
".",
"length",
"==",
"0",
")",
"{",
"// Telling main thread that he can kill us if he wants",
"Log",
"(",
"3",
",",
"\"Inactive thread\"",
")",
";",
"process",
".",
"send",
"(",
"{",
"name",
":",
"\"thread-no-pending-requests\"",
",",
"args",
":",
"[",
"{",
"threadId",
":",
"threadId",
"}",
"]",
"}",
")",
";",
"}",
"}",
",",
"1000",
")",
";",
"}",
"}"
]
| Finalize a request when it is done | [
"Finalize",
"a",
"request",
"when",
"it",
"is",
"done"
]
| 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/thread.js#L42-L60 |
45,493 | CrocInc/grunt-croc-requirejs | rjs/xcss.js | _includeCSSInternal | function _includeCSSInternal (css) {
var head,
style = document.getElementById(_stylesheetTagID);
if (!style) {
// there's no our styles tag - create
style = document.createElement('style');
style.setAttribute('id', _stylesheetTagID);
style.setAttribute('type', 'text/css');
head = document.getElementsByTagName('head')[0];
head.appendChild(style);
}
if (style.styleSheet) { // IE
style.styleSheet.cssText += css;
} else { // the others
style.appendChild(document.createTextNode(css));
}
} | javascript | function _includeCSSInternal (css) {
var head,
style = document.getElementById(_stylesheetTagID);
if (!style) {
// there's no our styles tag - create
style = document.createElement('style');
style.setAttribute('id', _stylesheetTagID);
style.setAttribute('type', 'text/css');
head = document.getElementsByTagName('head')[0];
head.appendChild(style);
}
if (style.styleSheet) { // IE
style.styleSheet.cssText += css;
} else { // the others
style.appendChild(document.createTextNode(css));
}
} | [
"function",
"_includeCSSInternal",
"(",
"css",
")",
"{",
"var",
"head",
",",
"style",
"=",
"document",
".",
"getElementById",
"(",
"_stylesheetTagID",
")",
";",
"if",
"(",
"!",
"style",
")",
"{",
"// there's no our styles tag - create",
"style",
"=",
"document",
".",
"createElement",
"(",
"'style'",
")",
";",
"style",
".",
"setAttribute",
"(",
"'id'",
",",
"_stylesheetTagID",
")",
";",
"style",
".",
"setAttribute",
"(",
"'type'",
",",
"'text/css'",
")",
";",
"head",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'head'",
")",
"[",
"0",
"]",
";",
"head",
".",
"appendChild",
"(",
"style",
")",
";",
"}",
"if",
"(",
"style",
".",
"styleSheet",
")",
"{",
"// IE",
"style",
".",
"styleSheet",
".",
"cssText",
"+=",
"css",
";",
"}",
"else",
"{",
"// the others",
"style",
".",
"appendChild",
"(",
"document",
".",
"createTextNode",
"(",
"css",
")",
")",
";",
"}",
"}"
]
| Add css code into STYLE tag in HEAD. It tries to use the single STYLE tag with special ID "xcss_styles"
@param css - style | [
"Add",
"css",
"code",
"into",
"STYLE",
"tag",
"in",
"HEAD",
".",
"It",
"tries",
"to",
"use",
"the",
"single",
"STYLE",
"tag",
"with",
"special",
"ID",
"xcss_styles"
]
| bc07f1b096a6484b472a72830dcacc65ca64b407 | https://github.com/CrocInc/grunt-croc-requirejs/blob/bc07f1b096a6484b472a72830dcacc65ca64b407/rjs/xcss.js#L64-L82 |
45,494 | CrocInc/grunt-croc-requirejs | rjs/xcss.js | function (css, name) {
if (typeof css === "function") { css = css(); }
if (!css) { return; }
if (!name) {
_includeCSSInternal(css);
} else if (!_stylesheetFiles[name]) {
_includeCSSInternal(css);
_stylesheetFiles[name] = true;
}
} | javascript | function (css, name) {
if (typeof css === "function") { css = css(); }
if (!css) { return; }
if (!name) {
_includeCSSInternal(css);
} else if (!_stylesheetFiles[name]) {
_includeCSSInternal(css);
_stylesheetFiles[name] = true;
}
} | [
"function",
"(",
"css",
",",
"name",
")",
"{",
"if",
"(",
"typeof",
"css",
"===",
"\"function\"",
")",
"{",
"css",
"=",
"css",
"(",
")",
";",
"}",
"if",
"(",
"!",
"css",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"name",
")",
"{",
"_includeCSSInternal",
"(",
"css",
")",
";",
"}",
"else",
"if",
"(",
"!",
"_stylesheetFiles",
"[",
"name",
"]",
")",
"{",
"_includeCSSInternal",
"(",
"css",
")",
";",
"_stylesheetFiles",
"[",
"name",
"]",
"=",
"true",
";",
"}",
"}"
]
| Append style element with css param's content
@param {String|Function} css Content for style element or a function which returns it
@param {String} name Name of the stylesheet to prevent duplication. | [
"Append",
"style",
"element",
"with",
"css",
"param",
"s",
"content"
]
| bc07f1b096a6484b472a72830dcacc65ca64b407 | https://github.com/CrocInc/grunt-croc-requirejs/blob/bc07f1b096a6484b472a72830dcacc65ca64b407/rjs/xcss.js#L100-L109 |
|
45,495 | svipas/cachimo | src/cachimo.js | clear | function clear() {
timeouts.forEach((callback, timeout) => {
clearTimeout(timeout);
// reject Promise or execute callback which returns Error
callback();
});
const length = size();
cache.clear();
return length;
} | javascript | function clear() {
timeouts.forEach((callback, timeout) => {
clearTimeout(timeout);
// reject Promise or execute callback which returns Error
callback();
});
const length = size();
cache.clear();
return length;
} | [
"function",
"clear",
"(",
")",
"{",
"timeouts",
".",
"forEach",
"(",
"(",
"callback",
",",
"timeout",
")",
"=>",
"{",
"clearTimeout",
"(",
"timeout",
")",
";",
"// reject Promise or execute callback which returns Error",
"callback",
"(",
")",
";",
"}",
")",
";",
"const",
"length",
"=",
"size",
"(",
")",
";",
"cache",
".",
"clear",
"(",
")",
";",
"return",
"length",
";",
"}"
]
| Removes all elements stored in cache and clears all timeouts.
@returns {number} how much elements was removed from cache | [
"Removes",
"all",
"elements",
"stored",
"in",
"cache",
"and",
"clears",
"all",
"timeouts",
"."
]
| c6e53dfff29e4dcb67979c71992887ab1c51b5df | https://github.com/svipas/cachimo/blob/c6e53dfff29e4dcb67979c71992887ab1c51b5df/src/cachimo.js#L78-L89 |
45,496 | svipas/cachimo | src/cachimo.js | put | function put(key, value, timeout, callback) {
// key type is incorrect
if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'boolean') {
throw new TypeError(`key can be only: string | number | boolean instead of ${typeof key}`);
}
// check if key is not NaN
if (typeof key === 'number' && isNaN(key)) {
throw new TypeError('key can be only: string | number | boolean instead of NaN');
}
// timeout type is incorrect and/or timeout is not positive number
if (timeout !== undefined && (typeof timeout !== 'number' || isNaN(timeout) || timeout <= 0)) {
throw new TypeError('timeout should be positive number');
}
// callback type is incorrect
if (callback !== undefined && typeof callback !== 'function') {
throw new TypeError(`callback should be function instead of ${typeof callback}`);
}
// key does exist
if (has(key)) {
return false;
}
cache.set(key, value);
// return Promise
if (timeout !== undefined && callback === undefined) {
return new Promise((resolve, reject) => {
const t = setTimeout(() => {
if (cache.delete(key)) {
resolve({ key, value, timeout });
} else {
reject(new Error(`${key} does not exist`));
}
}, timeout);
timeouts.set(t, () => reject(new Error(`${key} timeout was cleared`)));
});
}
// execute callback
if (timeout !== undefined && callback !== undefined) {
const t = setTimeout(() => {
if (cache.delete(key)) {
callback(null, key, value, timeout);
} else {
callback(new Error(`${key} does not exist`));
}
}, timeout);
timeouts.set(t, () => callback(new Error(`${key} timeout was cleared`)));
}
return true;
} | javascript | function put(key, value, timeout, callback) {
// key type is incorrect
if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'boolean') {
throw new TypeError(`key can be only: string | number | boolean instead of ${typeof key}`);
}
// check if key is not NaN
if (typeof key === 'number' && isNaN(key)) {
throw new TypeError('key can be only: string | number | boolean instead of NaN');
}
// timeout type is incorrect and/or timeout is not positive number
if (timeout !== undefined && (typeof timeout !== 'number' || isNaN(timeout) || timeout <= 0)) {
throw new TypeError('timeout should be positive number');
}
// callback type is incorrect
if (callback !== undefined && typeof callback !== 'function') {
throw new TypeError(`callback should be function instead of ${typeof callback}`);
}
// key does exist
if (has(key)) {
return false;
}
cache.set(key, value);
// return Promise
if (timeout !== undefined && callback === undefined) {
return new Promise((resolve, reject) => {
const t = setTimeout(() => {
if (cache.delete(key)) {
resolve({ key, value, timeout });
} else {
reject(new Error(`${key} does not exist`));
}
}, timeout);
timeouts.set(t, () => reject(new Error(`${key} timeout was cleared`)));
});
}
// execute callback
if (timeout !== undefined && callback !== undefined) {
const t = setTimeout(() => {
if (cache.delete(key)) {
callback(null, key, value, timeout);
} else {
callback(new Error(`${key} does not exist`));
}
}, timeout);
timeouts.set(t, () => callback(new Error(`${key} timeout was cleared`)));
}
return true;
} | [
"function",
"put",
"(",
"key",
",",
"value",
",",
"timeout",
",",
"callback",
")",
"{",
"// key type is incorrect",
"if",
"(",
"typeof",
"key",
"!==",
"'string'",
"&&",
"typeof",
"key",
"!==",
"'number'",
"&&",
"typeof",
"key",
"!==",
"'boolean'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"typeof",
"key",
"}",
"`",
")",
";",
"}",
"// check if key is not NaN",
"if",
"(",
"typeof",
"key",
"===",
"'number'",
"&&",
"isNaN",
"(",
"key",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'key can be only: string | number | boolean instead of NaN'",
")",
";",
"}",
"// timeout type is incorrect and/or timeout is not positive number",
"if",
"(",
"timeout",
"!==",
"undefined",
"&&",
"(",
"typeof",
"timeout",
"!==",
"'number'",
"||",
"isNaN",
"(",
"timeout",
")",
"||",
"timeout",
"<=",
"0",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'timeout should be positive number'",
")",
";",
"}",
"// callback type is incorrect",
"if",
"(",
"callback",
"!==",
"undefined",
"&&",
"typeof",
"callback",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"typeof",
"callback",
"}",
"`",
")",
";",
"}",
"// key does exist",
"if",
"(",
"has",
"(",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"cache",
".",
"set",
"(",
"key",
",",
"value",
")",
";",
"// return Promise",
"if",
"(",
"timeout",
"!==",
"undefined",
"&&",
"callback",
"===",
"undefined",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"t",
"=",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"cache",
".",
"delete",
"(",
"key",
")",
")",
"{",
"resolve",
"(",
"{",
"key",
",",
"value",
",",
"timeout",
"}",
")",
";",
"}",
"else",
"{",
"reject",
"(",
"new",
"Error",
"(",
"`",
"${",
"key",
"}",
"`",
")",
")",
";",
"}",
"}",
",",
"timeout",
")",
";",
"timeouts",
".",
"set",
"(",
"t",
",",
"(",
")",
"=>",
"reject",
"(",
"new",
"Error",
"(",
"`",
"${",
"key",
"}",
"`",
")",
")",
")",
";",
"}",
")",
";",
"}",
"// execute callback",
"if",
"(",
"timeout",
"!==",
"undefined",
"&&",
"callback",
"!==",
"undefined",
")",
"{",
"const",
"t",
"=",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"cache",
".",
"delete",
"(",
"key",
")",
")",
"{",
"callback",
"(",
"null",
",",
"key",
",",
"value",
",",
"timeout",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"new",
"Error",
"(",
"`",
"${",
"key",
"}",
"`",
")",
")",
";",
"}",
"}",
",",
"timeout",
")",
";",
"timeouts",
".",
"set",
"(",
"t",
",",
"(",
")",
"=>",
"callback",
"(",
"new",
"Error",
"(",
"`",
"${",
"key",
"}",
"`",
")",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Stores an element in-memory with specified key and value.
If only `key` and `value` is provided it returns boolean.
true: if element was stored and key doesn't exist.
false: if key does exist.
If additionally only `timeout` is provided it returns Promise.
Element will be deleted after given `timeout` and Promise will be resolved.
Otherwise it will be rejected if element does not exist.
If additionally `timeout` and `callback` is provided it executes given `callback` after given `timeout`.
@param {string | number | boolean} key can be only: `string` | `number` | `boolean`
@param {any} value can be any type
@param {number} timeout after how much time in milliseconds element will be deleted
@param {(err: Error, key: string | number | boolean, value: any, timeout: number)} callback will be executed after given `timeout`
@returns {boolean | Promise<{ key: string | number | boolean, value: any, timeout: number }>} boolean or Promise | [
"Stores",
"an",
"element",
"in",
"-",
"memory",
"with",
"specified",
"key",
"and",
"value",
"."
]
| c6e53dfff29e4dcb67979c71992887ab1c51b5df | https://github.com/svipas/cachimo/blob/c6e53dfff29e4dcb67979c71992887ab1c51b5df/src/cachimo.js#L111-L165 |
45,497 | synder/xpress | demo/commander/index.js | Option | function Option(flags, description) {
this.flags = flags;
this.required = ~flags.indexOf('<');
this.optional = ~flags.indexOf('[');
this.bool = !~flags.indexOf('-no-');
flags = flags.split(/[ ,|]+/);
if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
this.long = flags.shift();
this.description = description || '';
} | javascript | function Option(flags, description) {
this.flags = flags;
this.required = ~flags.indexOf('<');
this.optional = ~flags.indexOf('[');
this.bool = !~flags.indexOf('-no-');
flags = flags.split(/[ ,|]+/);
if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
this.long = flags.shift();
this.description = description || '';
} | [
"function",
"Option",
"(",
"flags",
",",
"description",
")",
"{",
"this",
".",
"flags",
"=",
"flags",
";",
"this",
".",
"required",
"=",
"~",
"flags",
".",
"indexOf",
"(",
"'<'",
")",
";",
"this",
".",
"optional",
"=",
"~",
"flags",
".",
"indexOf",
"(",
"'['",
")",
";",
"this",
".",
"bool",
"=",
"!",
"~",
"flags",
".",
"indexOf",
"(",
"'-no-'",
")",
";",
"flags",
"=",
"flags",
".",
"split",
"(",
"/",
"[ ,|]+",
"/",
")",
";",
"if",
"(",
"flags",
".",
"length",
">",
"1",
"&&",
"!",
"/",
"^[[<]",
"/",
".",
"test",
"(",
"flags",
"[",
"1",
"]",
")",
")",
"this",
".",
"short",
"=",
"flags",
".",
"shift",
"(",
")",
";",
"this",
".",
"long",
"=",
"flags",
".",
"shift",
"(",
")",
";",
"this",
".",
"description",
"=",
"description",
"||",
"''",
";",
"}"
]
| Initialize a new `Option` with the given `flags` and `description`.
@param {String} flags
@param {String} description
@api public | [
"Initialize",
"a",
"new",
"Option",
"with",
"the",
"given",
"flags",
"and",
"description",
"."
]
| 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/commander/index.js#L38-L47 |
45,498 | henrytseng/angular-state-view | src/services/view-manager.js | function() {
// Reset views
var resetPromised = {};
angular.forEach(_activeSet, function(view, id) {
resetPromised[id] = $q.when(view.reset());
});
// Empty active set
_activeSet = {};
return $q.all(resetPromised);
} | javascript | function() {
// Reset views
var resetPromised = {};
angular.forEach(_activeSet, function(view, id) {
resetPromised[id] = $q.when(view.reset());
});
// Empty active set
_activeSet = {};
return $q.all(resetPromised);
} | [
"function",
"(",
")",
"{",
"// Reset views",
"var",
"resetPromised",
"=",
"{",
"}",
";",
"angular",
".",
"forEach",
"(",
"_activeSet",
",",
"function",
"(",
"view",
",",
"id",
")",
"{",
"resetPromised",
"[",
"id",
"]",
"=",
"$q",
".",
"when",
"(",
"view",
".",
"reset",
"(",
")",
")",
";",
"}",
")",
";",
"// Empty active set",
"_activeSet",
"=",
"{",
"}",
";",
"return",
"$q",
".",
"all",
"(",
"resetPromised",
")",
";",
"}"
]
| Reset active views
@return {Promise} A promise fulfilled when currently active views are reset | [
"Reset",
"active",
"views"
]
| cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L20-L31 |
|
45,499 | henrytseng/angular-state-view | src/services/view-manager.js | function(id, view, data, controller) {
return _getTemplate(data).then(function(template) {
// Controller
if(controller) {
var current = $state.current();
return view.render(template, controller, current.locals);
// Template only
} else {
return view.render(template);
}
});
} | javascript | function(id, view, data, controller) {
return _getTemplate(data).then(function(template) {
// Controller
if(controller) {
var current = $state.current();
return view.render(template, controller, current.locals);
// Template only
} else {
return view.render(template);
}
});
} | [
"function",
"(",
"id",
",",
"view",
",",
"data",
",",
"controller",
")",
"{",
"return",
"_getTemplate",
"(",
"data",
")",
".",
"then",
"(",
"function",
"(",
"template",
")",
"{",
"// Controller",
"if",
"(",
"controller",
")",
"{",
"var",
"current",
"=",
"$state",
".",
"current",
"(",
")",
";",
"return",
"view",
".",
"render",
"(",
"template",
",",
"controller",
",",
"current",
".",
"locals",
")",
";",
"// Template only",
"}",
"else",
"{",
"return",
"view",
".",
"render",
"(",
"template",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Render a view
@param {String} id Unique identifier for view
@param {View} view A view instance
@param {Mixed} data Template data, String src to include or Function invocation
@return {Promise} A promise fulfilled when currently active view is rendered | [
"Render",
"a",
"view"
]
| cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L52-L65 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.