repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Fovea/jackbone | jackbone.js | function (timerId, timerName, t) {
if (this.enabled) {
if (this._startDate[timerId]) {
var duration = (t || (+new Date())) - this._startDate[timerId];
delete this._startDate[timerId];
if (console.profile) {
... | javascript | function (timerId, timerName, t) {
if (this.enabled) {
if (this._startDate[timerId]) {
var duration = (t || (+new Date())) - this._startDate[timerId];
delete this._startDate[timerId];
if (console.profile) {
... | [
"function",
"(",
"timerId",
",",
"timerName",
",",
"t",
")",
"{",
"if",
"(",
"this",
".",
"enabled",
")",
"{",
"if",
"(",
"this",
".",
"_startDate",
"[",
"timerId",
"]",
")",
"{",
"var",
"duration",
"=",
"(",
"t",
"||",
"(",
"+",
"new",
"Date",
... | Called when an operation is done. Will update Jackbone.profiler.stats and show average duration on the console. | [
"Called",
"when",
"an",
"operation",
"is",
"done",
".",
"Will",
"update",
"Jackbone",
".",
"profiler",
".",
"stats",
"and",
"show",
"average",
"duration",
"on",
"the",
"console",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L86-L124 | train | |
Fovea/jackbone | jackbone.js | function (options) {
this.options = options;
// options.back can be used to change view 'Back' link.
if (options.back) {
this.back = options.back;
}
this.callSubviews('setOptions', options);
this.applyOptions(options);
} | javascript | function (options) {
this.options = options;
// options.back can be used to change view 'Back' link.
if (options.back) {
this.back = options.back;
}
this.callSubviews('setOptions', options);
this.applyOptions(options);
} | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"options",
";",
"// options.back can be used to change view 'Back' link.",
"if",
"(",
"options",
".",
"back",
")",
"{",
"this",
".",
"back",
"=",
"options",
".",
"back",
";",
"}",
"this",
"."... | Change options for this view and its subviews. | [
"Change",
"options",
"for",
"this",
"view",
"and",
"its",
"subviews",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L155-L165 | train | |
Fovea/jackbone | jackbone.js | function (method) {
if (this.subviews.length !== 0) {
var params = slice.call(arguments);
params.shift();
_.each(this.subviews, function (s) {
if (s[method]) {
s[method].apply(s, params);
}
... | javascript | function (method) {
if (this.subviews.length !== 0) {
var params = slice.call(arguments);
params.shift();
_.each(this.subviews, function (s) {
if (s[method]) {
s[method].apply(s, params);
}
... | [
"function",
"(",
"method",
")",
"{",
"if",
"(",
"this",
".",
"subviews",
".",
"length",
"!==",
"0",
")",
"{",
"var",
"params",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"params",
".",
"shift",
"(",
")",
";",
"_",
".",
"each",
"(",
... | Call the given method for all subviews. Passing extra arguments is posible, they will be passed to subviews too. | [
"Call",
"the",
"given",
"method",
"for",
"all",
"subviews",
".",
"Passing",
"extra",
"arguments",
"is",
"posible",
"they",
"will",
"be",
"passed",
"to",
"subviews",
"too",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L170-L180 | train | |
Fovea/jackbone | jackbone.js | function (e) {
e.preventDefault();
var $target = $(e.target);
while ($target) {
var route = $target.attr('route');
if (route) {
// A route has been defined, follow the link using
// Jackbone's default router.
... | javascript | function (e) {
e.preventDefault();
var $target = $(e.target);
while ($target) {
var route = $target.attr('route');
if (route) {
// A route has been defined, follow the link using
// Jackbone's default router.
... | [
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"$target",
"=",
"$",
"(",
"e",
".",
"target",
")",
";",
"while",
"(",
"$target",
")",
"{",
"var",
"route",
"=",
"$target",
".",
"attr",
"(",
"'route'",
")",
";",
... | This is the default event handler | [
"This",
"is",
"the",
"default",
"event",
"handler"
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L259-L282 | train | |
Fovea/jackbone | jackbone.js | function () {
// Note: Controllers are responsible of setting needRedraw.
if (this.needRedraw) {
// Create root element for the page
var page = document.createElement('div');
page.style.display = 'block';
page.setAttribute('data-r... | javascript | function () {
// Note: Controllers are responsible of setting needRedraw.
if (this.needRedraw) {
// Create root element for the page
var page = document.createElement('div');
page.style.display = 'block';
page.setAttribute('data-r... | [
"function",
"(",
")",
"{",
"// Note: Controllers are responsible of setting needRedraw.",
"if",
"(",
"this",
".",
"needRedraw",
")",
"{",
"// Create root element for the page",
"var",
"page",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"page",
".",
... | Default render. Sets header, content and footer. | [
"Default",
"render",
".",
"Sets",
"header",
"content",
"and",
"footer",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L354-L412 | train | |
Fovea/jackbone | jackbone.js | function () {
var that = this;
var now = +new Date();
var toRemove = _(this.controllers).filter(function (c) {
var age = (now - c.lastView);
return (age > 60000); // Keep in cache for 1 minute.
});
_(toRemove).each(function (c... | javascript | function () {
var that = this;
var now = +new Date();
var toRemove = _(this.controllers).filter(function (c) {
var age = (now - c.lastView);
return (age > 60000); // Keep in cache for 1 minute.
});
_(toRemove).each(function (c... | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"now",
"=",
"+",
"new",
"Date",
"(",
")",
";",
"var",
"toRemove",
"=",
"_",
"(",
"this",
".",
"controllers",
")",
".",
"filter",
"(",
"function",
"(",
"c",
")",
"{",
"var",
"age... | Garbage collector, removes unused views and controllers. | [
"Garbage",
"collector",
"removes",
"unused",
"views",
"and",
"controllers",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L683-L703 | train | |
Fovea/jackbone | jackbone.js | function () {
var content = ctrl.view;
var header = noHeader ? null : new Jackbone.DefaultHeader();
var footer = noFooter ? null : new Jackbone.DefaultFooter();
var view = new JQMView(header, content, footer);
// C... | javascript | function () {
var content = ctrl.view;
var header = noHeader ? null : new Jackbone.DefaultHeader();
var footer = noFooter ? null : new Jackbone.DefaultFooter();
var view = new JQMView(header, content, footer);
// C... | [
"function",
"(",
")",
"{",
"var",
"content",
"=",
"ctrl",
".",
"view",
";",
"var",
"header",
"=",
"noHeader",
"?",
"null",
":",
"new",
"Jackbone",
".",
"DefaultHeader",
"(",
")",
";",
"var",
"footer",
"=",
"noFooter",
"?",
"null",
":",
"new",
"Jackbo... | Create views for a controller | [
"Create",
"views",
"for",
"a",
"controller"
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L888-L900 | train | |
Fovea/jackbone | jackbone.js | function (separator, page, args) {
// By default, we return page name without arguments.
var ret = page;
if (typeof args !== 'undefined') {
if (args && args.length) {
// Some arguments have been provided, add them.
if (args.length !== 0) {
... | javascript | function (separator, page, args) {
// By default, we return page name without arguments.
var ret = page;
if (typeof args !== 'undefined') {
if (args && args.length) {
// Some arguments have been provided, add them.
if (args.length !== 0) {
... | [
"function",
"(",
"separator",
",",
"page",
",",
"args",
")",
"{",
"// By default, we return page name without arguments.",
"var",
"ret",
"=",
"page",
";",
"if",
"(",
"typeof",
"args",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"args",
"&&",
"args",
".",
"len... | Used to generate page hash tag or HTML attribute. by getPageName and getPageHash. Does it by joining page and arguments using the given separator. | [
"Used",
"to",
"generate",
"page",
"hash",
"tag",
"or",
"HTML",
"attribute",
".",
"by",
"getPageName",
"and",
"getPageHash",
".",
"Does",
"it",
"by",
"joining",
"page",
"and",
"arguments",
"using",
"the",
"given",
"separator",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L947-L963 | train | |
Fovea/jackbone | jackbone.js | function (pageName, page, role) {
// Extends Views
// Create JQuery Mobile Page
var pageid = 'pagename-' + pageName.toLowerCase();
var isExistingPage = $('#' + pageid);
// For already existing pages, only delegate events so they can
// handle onPa... | javascript | function (pageName, page, role) {
// Extends Views
// Create JQuery Mobile Page
var pageid = 'pagename-' + pageName.toLowerCase();
var isExistingPage = $('#' + pageid);
// For already existing pages, only delegate events so they can
// handle onPa... | [
"function",
"(",
"pageName",
",",
"page",
",",
"role",
")",
"{",
"// Extends Views",
"// Create JQuery Mobile Page",
"var",
"pageid",
"=",
"'pagename-'",
"+",
"pageName",
".",
"toLowerCase",
"(",
")",
";",
"var",
"isExistingPage",
"=",
"$",
"(",
"'#'",
"+",
... | Change to the given page. | [
"Change",
"to",
"the",
"given",
"page",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L1061-L1151 | train | |
Fovea/jackbone | jackbone.js | function (pageName, role) {
var lastPageName = this.currentPageName || '';
var lastPageRole = this.currentPageRole || '';
this.currentPageName = pageName;
this.currentPageRole = role;
// Known transition, return it.
if (_(this.transitions)... | javascript | function (pageName, role) {
var lastPageName = this.currentPageName || '';
var lastPageRole = this.currentPageRole || '';
this.currentPageName = pageName;
this.currentPageRole = role;
// Known transition, return it.
if (_(this.transitions)... | [
"function",
"(",
"pageName",
",",
"role",
")",
"{",
"var",
"lastPageName",
"=",
"this",
".",
"currentPageName",
"||",
"''",
";",
"var",
"lastPageRole",
"=",
"this",
".",
"currentPageRole",
"||",
"''",
";",
"this",
".",
"currentPageName",
"=",
"pageName",
"... | Return parameters of the transition to use to switch to pageName It's context dependant, meaning this method remembers the currently viewed view and determine the transition accordingly. | [
"Return",
"parameters",
"of",
"the",
"transition",
"to",
"use",
"to",
"switch",
"to",
"pageName",
"It",
"s",
"context",
"dependant",
"meaning",
"this",
"method",
"remembers",
"the",
"currently",
"viewed",
"view",
"and",
"determine",
"the",
"transition",
"accordi... | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/jackbone.js#L1162-L1194 | train | |
imiric/tiq-db | index.js | TiqDB | function TiqDB(config) {
var defaultConfig = {
client: 'sqlite3',
connection: {
host: 'localhost',
user: null,
password: null,
database: 'tiq',
filename: path.join(process.env.XDG_DATA_HOME ||
path.join(process.env.HOME, '.local', 'share'), 'tiq', 'store... | javascript | function TiqDB(config) {
var defaultConfig = {
client: 'sqlite3',
connection: {
host: 'localhost',
user: null,
password: null,
database: 'tiq',
filename: path.join(process.env.XDG_DATA_HOME ||
path.join(process.env.HOME, '.local', 'share'), 'tiq', 'store... | [
"function",
"TiqDB",
"(",
"config",
")",
"{",
"var",
"defaultConfig",
"=",
"{",
"client",
":",
"'sqlite3'",
",",
"connection",
":",
"{",
"host",
":",
"'localhost'",
",",
"user",
":",
"null",
",",
"password",
":",
"null",
",",
"database",
":",
"'tiq'",
... | Main module object.
@param {Object} config
@param {string} [config.client="sqlite3"] - The client for the chosen RDBMS.
This can be one of "sqlite3", "pg" or "mysql".
@param {Object} [config.connection={}]
@param {string} [config.connection.host="localhost"]
@param {string} [config.connection.user=null]
@param {string... | [
"Main",
"module",
"object",
"."
] | d40afa6523ca150e9b52be7ab6921e03257feb61 | https://github.com/imiric/tiq-db/blob/d40afa6523ca150e9b52be7ab6921e03257feb61/index.js#L39-L57 | train |
wunderbyte/grunt-spiritual-dox | src/js/guidox@wunderbyte.com/spirits/main/dox.PrismSpirit.js | function () {
this._super.onenter ();
if ( this.box.pageY < window.innerHeight ) {
this._hilite ();
} else {
this.tick.time ( function () {
this._hilite ();
}, 200 );
}
} | javascript | function () {
this._super.onenter ();
if ( this.box.pageY < window.innerHeight ) {
this._hilite ();
} else {
this.tick.time ( function () {
this._hilite ();
}, 200 );
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"_super",
".",
"onenter",
"(",
")",
";",
"if",
"(",
"this",
".",
"box",
".",
"pageY",
"<",
"window",
".",
"innerHeight",
")",
"{",
"this",
".",
"_hilite",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"ti... | Visible code get's highlighted now while unseen code runs on a timeout.
The internal async thing in Prism doesn't seem to work as advertised... | [
"Visible",
"code",
"get",
"s",
"highlighted",
"now",
"while",
"unseen",
"code",
"runs",
"on",
"a",
"timeout",
".",
"The",
"internal",
"async",
"thing",
"in",
"Prism",
"doesn",
"t",
"seem",
"to",
"work",
"as",
"advertised",
"..."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/main/dox.PrismSpirit.js#L12-L21 | train | |
wunderbyte/grunt-spiritual-dox | src/js/guidox@wunderbyte.com/spirits/main/dox.PrismSpirit.js | function ( code ) {
var text = code.firstChild;
if ( text ) {
text.data = text.data.substring ( 1 ); // we inserted a #
}
} | javascript | function ( code ) {
var text = code.firstChild;
if ( text ) {
text.data = text.data.substring ( 1 ); // we inserted a #
}
} | [
"function",
"(",
"code",
")",
"{",
"var",
"text",
"=",
"code",
".",
"firstChild",
";",
"if",
"(",
"text",
")",
"{",
"text",
".",
"data",
"=",
"text",
".",
"data",
".",
"substring",
"(",
"1",
")",
";",
"// we inserted a #",
"}",
"}"
] | Prism appears to have a regexp dysfunction on
leading whitespace in the first line of code.
@param {HTMLCodeElement} code | [
"Prism",
"appears",
"to",
"have",
"a",
"regexp",
"dysfunction",
"on",
"leading",
"whitespace",
"in",
"the",
"first",
"line",
"of",
"code",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/main/dox.PrismSpirit.js#L54-L59 | train | |
novemberborn/legendary | lib/private/trampoline.js | trampoline | function trampoline(queue) {
index = [0];
stack = [queue];
var queueIndex, queueLength;
var stackIndex = 1; // 1-indexed!
var stackLength = stack.length;
var topOfStack = true;
while (stackIndex) {
queue = stack[stackIndex - 1];
queueIndex = index[stackIndex - 1];
if (queueIndex === -1) {
... | javascript | function trampoline(queue) {
index = [0];
stack = [queue];
var queueIndex, queueLength;
var stackIndex = 1; // 1-indexed!
var stackLength = stack.length;
var topOfStack = true;
while (stackIndex) {
queue = stack[stackIndex - 1];
queueIndex = index[stackIndex - 1];
if (queueIndex === -1) {
... | [
"function",
"trampoline",
"(",
"queue",
")",
"{",
"index",
"=",
"[",
"0",
"]",
";",
"stack",
"=",
"[",
"queue",
"]",
";",
"var",
"queueIndex",
",",
"queueLength",
";",
"var",
"stackIndex",
"=",
"1",
";",
"// 1-indexed!",
"var",
"stackLength",
"=",
"sta... | Starts a trampoline to process the queue. | [
"Starts",
"a",
"trampoline",
"to",
"process",
"the",
"queue",
"."
] | 8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc | https://github.com/novemberborn/legendary/blob/8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc/lib/private/trampoline.js#L8-L47 | train |
novemberborn/legendary | lib/private/trampoline.js | enterTurn | function enterTurn() {
var snapshot;
while ((snapshot = queue).length) {
queue = [];
trampoline(snapshot);
}
queue = null;
} | javascript | function enterTurn() {
var snapshot;
while ((snapshot = queue).length) {
queue = [];
trampoline(snapshot);
}
queue = null;
} | [
"function",
"enterTurn",
"(",
")",
"{",
"var",
"snapshot",
";",
"while",
"(",
"(",
"snapshot",
"=",
"queue",
")",
".",
"length",
")",
"{",
"queue",
"=",
"[",
"]",
";",
"trampoline",
"(",
"snapshot",
")",
";",
"}",
"queue",
"=",
"null",
";",
"}"
] | Once we have entered a turn we can keep executing propagations without waiting for another tick. Start a trampoline to process the current queue. | [
"Once",
"we",
"have",
"entered",
"a",
"turn",
"we",
"can",
"keep",
"executing",
"propagations",
"without",
"waiting",
"for",
"another",
"tick",
".",
"Start",
"a",
"trampoline",
"to",
"process",
"the",
"current",
"queue",
"."
] | 8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc | https://github.com/novemberborn/legendary/blob/8420f2dd20e2e3eaced51385fb6b0dc65b81a9fc/lib/private/trampoline.js#L51-L58 | train |
staticbuild/staticbuild | lib/nunjucks/functions.js | createForBuild | function createForBuild(build) {
var exports = {};
function bundles(name, sourceType) {
/*jshint validthis: true */
var ml = build.bundles(name, sourceType);
return this.markSafe(ml);
}
exports.bundles = bundles;
function link(srcPath, relative) {
/*jshint validthis: true */
var ml =... | javascript | function createForBuild(build) {
var exports = {};
function bundles(name, sourceType) {
/*jshint validthis: true */
var ml = build.bundles(name, sourceType);
return this.markSafe(ml);
}
exports.bundles = bundles;
function link(srcPath, relative) {
/*jshint validthis: true */
var ml =... | [
"function",
"createForBuild",
"(",
"build",
")",
"{",
"var",
"exports",
"=",
"{",
"}",
";",
"function",
"bundles",
"(",
"name",
",",
"sourceType",
")",
"{",
"/*jshint validthis: true */",
"var",
"ml",
"=",
"build",
".",
"bundles",
"(",
"name",
",",
"source... | Nunjucks specific functions. This module is currently not in use. | [
"Nunjucks",
"specific",
"functions",
".",
"This",
"module",
"is",
"currently",
"not",
"in",
"use",
"."
] | 73891a9a719de46ba07c26a10ce36c43da34ff0e | https://github.com/staticbuild/staticbuild/blob/73891a9a719de46ba07c26a10ce36c43da34ff0e/lib/nunjucks/functions.js#L5-L40 | train |
tradle/ws-client | index.js | Client | function Client (opts) {
var self = this
typeforce({
url: 'String',
otrKey: 'DSA',
// byRootHash: 'Function',
instanceTag: '?String',
autoconnect: '?Boolean' // defaults to true
}, opts)
EventEmitter.call(this)
this.setMaxListeners(0)
this._url = parseURL(opts.url)
this._autoconnect... | javascript | function Client (opts) {
var self = this
typeforce({
url: 'String',
otrKey: 'DSA',
// byRootHash: 'Function',
instanceTag: '?String',
autoconnect: '?Boolean' // defaults to true
}, opts)
EventEmitter.call(this)
this.setMaxListeners(0)
this._url = parseURL(opts.url)
this._autoconnect... | [
"function",
"Client",
"(",
"opts",
")",
"{",
"var",
"self",
"=",
"this",
"typeforce",
"(",
"{",
"url",
":",
"'String'",
",",
"otrKey",
":",
"'DSA'",
",",
"// byRootHash: 'Function',",
"instanceTag",
":",
"'?String'",
",",
"autoconnect",
":",
"'?Boolean'",
"/... | var HANDSHAKE_TIMEOUT = 5000 | [
"var",
"HANDSHAKE_TIMEOUT",
"=",
"5000"
] | 4854da00d731d8c8da6da2f6a6b93056be992cb3 | https://github.com/tradle/ws-client/blob/4854da00d731d8c8da6da2f6a6b93056be992cb3/index.js#L21-L45 | train |
appcelerator-archive/appc-connector-utils | lib/index.js | preserveNamespace | function preserveNamespace (models) {
const prefixedModels = {}
if (connector.config.skipModelNamespace) {
// if namspace is not applied we do not need to preserve it
return models
} else {
for (var model in models) {
prefixedModels[models[model].name] = models[model]
}
... | javascript | function preserveNamespace (models) {
const prefixedModels = {}
if (connector.config.skipModelNamespace) {
// if namspace is not applied we do not need to preserve it
return models
} else {
for (var model in models) {
prefixedModels[models[model].name] = models[model]
}
... | [
"function",
"preserveNamespace",
"(",
"models",
")",
"{",
"const",
"prefixedModels",
"=",
"{",
"}",
"if",
"(",
"connector",
".",
"config",
".",
"skipModelNamespace",
")",
"{",
"// if namspace is not applied we do not need to preserve it",
"return",
"models",
"}",
"els... | Preserves the models namspaces if it exists.
@param {Array} models the array of existing models | [
"Preserves",
"the",
"models",
"namspaces",
"if",
"it",
"exists",
"."
] | 4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8 | https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/index.js#L69-L80 | train |
redisjs/jsr-server | lib/command/pubsub/unsubscribe.js | execute | function execute(req, res) {
this.state.pubsub.unsubscribe(req.conn, req.args);
} | javascript | function execute(req, res) {
this.state.pubsub.unsubscribe(req.conn, req.args);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"state",
".",
"pubsub",
".",
"unsubscribe",
"(",
"req",
".",
"conn",
",",
"req",
".",
"args",
")",
";",
"}"
] | Respond to the UNSUBSCRIBE command. | [
"Respond",
"to",
"the",
"UNSUBSCRIBE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/unsubscribe.js#L17-L19 | train |
75lb/gfmt | lib/gfmt.js | gfmTable | function gfmTable (data, options) {
options = options || {}
if (!data || !data.length) {
return ''
}
data = escapePipes(data)
var tableOptions = {
nowrap: !options.wrap,
padding: { left: '| ', right: ' ' },
columns: options.columns || [],
getColumn: function (columnName) {
return ... | javascript | function gfmTable (data, options) {
options = options || {}
if (!data || !data.length) {
return ''
}
data = escapePipes(data)
var tableOptions = {
nowrap: !options.wrap,
padding: { left: '| ', right: ' ' },
columns: options.columns || [],
getColumn: function (columnName) {
return ... | [
"function",
"gfmTable",
"(",
"data",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"if",
"(",
"!",
"data",
"||",
"!",
"data",
".",
"length",
")",
"{",
"return",
"''",
"}",
"data",
"=",
"escapePipes",
"(",
"data",
")",
"var",
... | Get a github-flavoured-markdown table instance
@param {object|object[]} - the input data
@param [options] {object}
@param [options.columns] {object[]} - column definitions
@param [options.wrap] {boolean} - wrap to fit into width
@param [options.width] {boolean} - table width
@param [options.ignoreEmptyColumns] {boolean... | [
"Get",
"a",
"github",
"-",
"flavoured",
"-",
"markdown",
"table",
"instance"
] | 5ed8739f91366cbee62bcc94e6dc9a33141a1057 | https://github.com/75lb/gfmt/blob/5ed8739f91366cbee62bcc94e6dc9a33141a1057/lib/gfmt.js#L40-L84 | train |
vkiding/judpack-lib | src/cordova/restore-util.js | installPluginsFromConfigXML | function installPluginsFromConfigXML(args) {
events.emit('verbose', 'Checking config.xml for saved plugins that haven\'t been added to the project');
//Install plugins that are listed on config.xml
var projectRoot = cordova_util.cdProjectRoot();
var configPath = cordova_util.projectConfig(projectRoot);... | javascript | function installPluginsFromConfigXML(args) {
events.emit('verbose', 'Checking config.xml for saved plugins that haven\'t been added to the project');
//Install plugins that are listed on config.xml
var projectRoot = cordova_util.cdProjectRoot();
var configPath = cordova_util.projectConfig(projectRoot);... | [
"function",
"installPluginsFromConfigXML",
"(",
"args",
")",
"{",
"events",
".",
"emit",
"(",
"'verbose'",
",",
"'Checking config.xml for saved plugins that haven\\'t been added to the project'",
")",
";",
"//Install plugins that are listed on config.xml",
"var",
"projectRoot",
"... | returns a Promise | [
"returns",
"a",
"Promise"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/restore-util.js#L81-L139 | train |
martinjunior/grunt-emo | tasks/components/StyleGuideGenerator.js | function(grunt, gruntFilesArray, gruntOptions) {
/**
* @property styleGuideGenerator.grunt
* @type {Object}
*/
this.grunt = grunt;
/**
* An unexpanded grunt file array
*
* @property styleGuideGenerator.gruntFilesArray
* @type {Arra... | javascript | function(grunt, gruntFilesArray, gruntOptions) {
/**
* @property styleGuideGenerator.grunt
* @type {Object}
*/
this.grunt = grunt;
/**
* An unexpanded grunt file array
*
* @property styleGuideGenerator.gruntFilesArray
* @type {Arra... | [
"function",
"(",
"grunt",
",",
"gruntFilesArray",
",",
"gruntOptions",
")",
"{",
"/**\n * @property styleGuideGenerator.grunt\n * @type {Object}\n */",
"this",
".",
"grunt",
"=",
"grunt",
";",
"/**\n * An unexpanded grunt file array\n * \n ... | A grunt style guide generator
@param {Object} grunt
@param {Array} gruntFilesArray an unexpanded grunt file array
@param {Object} gruntOptions grunt task options | [
"A",
"grunt",
"style",
"guide",
"generator"
] | a7c6de9538bccfcae050a6d389d6aa118c933f3c | https://github.com/martinjunior/grunt-emo/blob/a7c6de9538bccfcae050a6d389d6aa118c933f3c/tasks/components/StyleGuideGenerator.js#L14-L46 | train | |
esha/posterior | docs/demo.js | function(obj) {
if (typeof obj === "object") {
if (Array.isArray(obj) && obj.length > 1) {
obj = '[ '+toString(obj[0])+', ... ]';
}
}
return (obj+'');
} | javascript | function(obj) {
if (typeof obj === "object") {
if (Array.isArray(obj) && obj.length > 1) {
obj = '[ '+toString(obj[0])+', ... ]';
}
}
return (obj+'');
} | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"typeof",
"obj",
"===",
"\"object\"",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
"&&",
"obj",
".",
"length",
">",
"1",
")",
"{",
"obj",
"=",
"'[ '",
"+",
"toString",
"(",
"obj",
"... | hijack console.debug to echo to a DOM element | [
"hijack",
"console",
".",
"debug",
"to",
"echo",
"to",
"a",
"DOM",
"element"
] | 2f50ce98495762eed3b2c1553e371a117b5ae8c6 | https://github.com/esha/posterior/blob/2f50ce98495762eed3b2c1553e371a117b5ae8c6/docs/demo.js#L6-L13 | train | |
yibn2008/cli-source-preview | index.js | preview | function preview (source, line, options) {
let from, to, pos
// set from/to line
if (Array.isArray(line)) {
from = line[0] | 0
to = line[1] | 0 || from
} else if (typeof line === 'object') {
from = to = line.line | 0
pos = {
line: line.line | 0,
column: line.column | 0
}
} els... | javascript | function preview (source, line, options) {
let from, to, pos
// set from/to line
if (Array.isArray(line)) {
from = line[0] | 0
to = line[1] | 0 || from
} else if (typeof line === 'object') {
from = to = line.line | 0
pos = {
line: line.line | 0,
column: line.column | 0
}
} els... | [
"function",
"preview",
"(",
"source",
",",
"line",
",",
"options",
")",
"{",
"let",
"from",
",",
"to",
",",
"pos",
"// set from/to line",
"if",
"(",
"Array",
".",
"isArray",
"(",
"line",
")",
")",
"{",
"from",
"=",
"line",
"[",
"0",
"]",
"|",
"0",
... | Preview parts of source code
line:
- Array: `[ Number, Number ]`, the line range to preview
- Object: `{ line: Number, column: Number }`, preivew specified line/column
- Number: preivew single line
options:
- offset: the extra lines number before/after specified line range (default: 5)
- lineNumber: show line numbe... | [
"Preview",
"parts",
"of",
"source",
"code"
] | 747c2d892b71bbd2c30c4a1782aa2f8c111c41ac | https://github.com/yibn2008/cli-source-preview/blob/747c2d892b71bbd2c30c4a1782aa2f8c111c41ac/index.js#L48-L104 | train |
yibn2008/cli-source-preview | index.js | readSource | function readSource (source, from, to, offset, delimiter) {
// fix args
from = from | 0
to = to | 0 || from
delimiter = delimiter || PREVIEW_OPTS.delimiter
if (typeof offset === 'undefined') {
offset = PREVIEW_OPTS.offset
} else {
offset = offset | 0
}
let lastIdx = -1
let currIdx = lastIdx
... | javascript | function readSource (source, from, to, offset, delimiter) {
// fix args
from = from | 0
to = to | 0 || from
delimiter = delimiter || PREVIEW_OPTS.delimiter
if (typeof offset === 'undefined') {
offset = PREVIEW_OPTS.offset
} else {
offset = offset | 0
}
let lastIdx = -1
let currIdx = lastIdx
... | [
"function",
"readSource",
"(",
"source",
",",
"from",
",",
"to",
",",
"offset",
",",
"delimiter",
")",
"{",
"// fix args",
"from",
"=",
"from",
"|",
"0",
"to",
"=",
"to",
"|",
"0",
"||",
"from",
"delimiter",
"=",
"delimiter",
"||",
"PREVIEW_OPTS",
".",... | Read source by line number
Return: [
{
number: Number,
source: String
},
...
]
@param {String} source
@param {Number} from
@param {Number} to (optional)
@param {Number} offset (optional)
@param {String} delimiter (optional)
@return {Array} Source splitd by line | [
"Read",
"source",
"by",
"line",
"number"
] | 747c2d892b71bbd2c30c4a1782aa2f8c111c41ac | https://github.com/yibn2008/cli-source-preview/blob/747c2d892b71bbd2c30c4a1782aa2f8c111c41ac/index.js#L124-L164 | train |
panjiesw/frest | internal/docs/themes/hugo-theme-learn/static/js/hugo-learn.js | getUrlParameter | function getUrlParameter(sPageURL) {
var url = sPageURL.split('?');
var obj = {};
if (url.length == 2) {
var sURLVariables = url[1].split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
ob... | javascript | function getUrlParameter(sPageURL) {
var url = sPageURL.split('?');
var obj = {};
if (url.length == 2) {
var sURLVariables = url[1].split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
ob... | [
"function",
"getUrlParameter",
"(",
"sPageURL",
")",
"{",
"var",
"url",
"=",
"sPageURL",
".",
"split",
"(",
"'?'",
")",
";",
"var",
"obj",
"=",
"{",
"}",
";",
"if",
"(",
"url",
".",
"length",
"==",
"2",
")",
"{",
"var",
"sURLVariables",
"=",
"url",... | Get Parameters from some url | [
"Get",
"Parameters",
"from",
"some",
"url"
] | 975a16ae24bd214b608d0b0001d3d86e5cd65f9e | https://github.com/panjiesw/frest/blob/975a16ae24bd214b608d0b0001d3d86e5cd65f9e/internal/docs/themes/hugo-theme-learn/static/js/hugo-learn.js#L2-L17 | train |
glesage/node-loop-bench | main.js | function ()
{
var tableData = [
['LOOP TYPE', ...config.counts]
];
var bases = [];
Object.keys(results['while desc']).forEach(function (countType)
{
var times = results['while desc'][countType];
var sum = times.reduce(function (acc, val)
... | javascript | function ()
{
var tableData = [
['LOOP TYPE', ...config.counts]
];
var bases = [];
Object.keys(results['while desc']).forEach(function (countType)
{
var times = results['while desc'][countType];
var sum = times.reduce(function (acc, val)
... | [
"function",
"(",
")",
"{",
"var",
"tableData",
"=",
"[",
"[",
"'LOOP TYPE'",
",",
"...",
"config",
".",
"counts",
"]",
"]",
";",
"var",
"bases",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"results",
"[",
"'while desc'",
"]",
")",
".",
"forEach... | Use text-table to log the results in a table format | [
"Use",
"text",
"-",
"table",
"to",
"log",
"the",
"results",
"in",
"a",
"table",
"format"
] | d034be83191c769ab53dd7bab956e782c5278960 | https://github.com/glesage/node-loop-bench/blob/d034be83191c769ab53dd7bab956e782c5278960/main.js#L81-L120 | train | |
andrewscwei/requiem | src/dom/getAttribute.js | getAttribute | function getAttribute(element, name) {
assertType(element, Node, false, 'Invalid element specified');
if (!element.getAttribute) return null;
let value = element.getAttribute(name);
if (value === '') return true;
if (value === undefined || value === null) return null;
try {
return JSON.parse(value);
... | javascript | function getAttribute(element, name) {
assertType(element, Node, false, 'Invalid element specified');
if (!element.getAttribute) return null;
let value = element.getAttribute(name);
if (value === '') return true;
if (value === undefined || value === null) return null;
try {
return JSON.parse(value);
... | [
"function",
"getAttribute",
"(",
"element",
",",
"name",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"if",
"(",
"!",
"element",
".",
"getAttribute",
")",
"return",
"null",
";",
"let",
"va... | Gets an attribute of an element by its name.
@param {Node} element - Target element.
@param {string} name - Attribute name.
@return {string} Attribute value.
@alias module:requiem~dom.getAttribute | [
"Gets",
"an",
"attribute",
"of",
"an",
"element",
"by",
"its",
"name",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getAttribute.js#L17-L31 | train |
raincatcher-beta/raincatcher-file | lib/client/file-client/FileClient.js | fileUpload | function fileUpload(fileURI, serverURI, fileUploadOptions) {
var deferred = q.defer();
var transfer = new FileTransfer();
transfer.upload(fileURI, serverURI, function uploadSuccess(response) {
deferred.resolve(response);
}, function uploadFailure(error) {
deferred.reject(error);
}, fileUploadOptions);... | javascript | function fileUpload(fileURI, serverURI, fileUploadOptions) {
var deferred = q.defer();
var transfer = new FileTransfer();
transfer.upload(fileURI, serverURI, function uploadSuccess(response) {
deferred.resolve(response);
}, function uploadFailure(error) {
deferred.reject(error);
}, fileUploadOptions);... | [
"function",
"fileUpload",
"(",
"fileURI",
",",
"serverURI",
",",
"fileUploadOptions",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"var",
"transfer",
"=",
"new",
"FileTransfer",
"(",
")",
";",
"transfer",
".",
"upload",
"(",
"fileU... | Handling file upload to server | [
"Handling",
"file",
"upload",
"to",
"server"
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/client/file-client/FileClient.js#L168-L177 | train |
raincatcher-beta/raincatcher-file | lib/client/file-client/FileClient.js | fileUploadRetry | function fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries) {
return fileUpload(fileURI, serverURI, fileUploadOptions)
.then(function(response) {
return response;
}, function() {
if (retries === 0) {
throw new Error("Can't upload to " + JSON.stringify(serverURI));
}
ret... | javascript | function fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries) {
return fileUpload(fileURI, serverURI, fileUploadOptions)
.then(function(response) {
return response;
}, function() {
if (retries === 0) {
throw new Error("Can't upload to " + JSON.stringify(serverURI));
}
ret... | [
"function",
"fileUploadRetry",
"(",
"fileURI",
",",
"serverURI",
",",
"fileUploadOptions",
",",
"timeout",
",",
"retries",
")",
"{",
"return",
"fileUpload",
"(",
"fileURI",
",",
"serverURI",
",",
"fileUploadOptions",
")",
".",
"then",
"(",
"function",
"(",
"re... | Handling retry mechanism of the file upload. | [
"Handling",
"retry",
"mechanism",
"of",
"the",
"file",
"upload",
"."
] | 1a4b5d53505eb381a3d4c0bd384e743c39886c1d | https://github.com/raincatcher-beta/raincatcher-file/blob/1a4b5d53505eb381a3d4c0bd384e743c39886c1d/lib/client/file-client/FileClient.js#L180-L193 | train |
jkuczm/metalsmith-mtime | lib/index.js | addAllMtimes | function addAllMtimes(files, metalsmith, done) {
var source = metalsmith.source();
// File system will be accessed for each element so iterate in parallel.
each(Object.keys(files), getAddMtime, done);
/**
* Gets mtime of given `file` and adds it to metadata.
*
* @param {String} file
* @param {Fu... | javascript | function addAllMtimes(files, metalsmith, done) {
var source = metalsmith.source();
// File system will be accessed for each element so iterate in parallel.
each(Object.keys(files), getAddMtime, done);
/**
* Gets mtime of given `file` and adds it to metadata.
*
* @param {String} file
* @param {Fu... | [
"function",
"addAllMtimes",
"(",
"files",
",",
"metalsmith",
",",
"done",
")",
"{",
"var",
"source",
"=",
"metalsmith",
".",
"source",
"(",
")",
";",
"// File system will be accessed for each element so iterate in parallel.",
"each",
"(",
"Object",
".",
"keys",
"(",... | Adds files mtimes to all corresponding objects in `files`.
@param {Object} files
@param {Object} metalsmith
@param {Function} done
@api private | [
"Adds",
"files",
"mtimes",
"to",
"all",
"corresponding",
"objects",
"in",
"files",
"."
] | 0e7022e82b32f11044da4253833addd26bcdf478 | https://github.com/jkuczm/metalsmith-mtime/blob/0e7022e82b32f11044da4253833addd26bcdf478/lib/index.js#L39-L84 | train |
jkuczm/metalsmith-mtime | lib/index.js | getAddMtime | function getAddMtime(file, done) {
fs.stat(path.join(source, file), addMtime);
/**
* Adds `stats.mtime` of `file` to its metadata.
*
* @param {Error} err
* @param {fs.Stats} stats
* @api private
*/
function addMtime(err, stats) {
if (err) {
// Skip elements of ... | javascript | function getAddMtime(file, done) {
fs.stat(path.join(source, file), addMtime);
/**
* Adds `stats.mtime` of `file` to its metadata.
*
* @param {Error} err
* @param {fs.Stats} stats
* @api private
*/
function addMtime(err, stats) {
if (err) {
// Skip elements of ... | [
"function",
"getAddMtime",
"(",
"file",
",",
"done",
")",
"{",
"fs",
".",
"stat",
"(",
"path",
".",
"join",
"(",
"source",
",",
"file",
")",
",",
"addMtime",
")",
";",
"/**\n * Adds `stats.mtime` of `file` to its metadata.\n *\n * @param {Error} err\n ... | Gets mtime of given `file` and adds it to metadata.
@param {String} file
@param {Function} done
@api private | [
"Gets",
"mtime",
"of",
"given",
"file",
"and",
"adds",
"it",
"to",
"metadata",
"."
] | 0e7022e82b32f11044da4253833addd26bcdf478 | https://github.com/jkuczm/metalsmith-mtime/blob/0e7022e82b32f11044da4253833addd26bcdf478/lib/index.js#L55-L83 | train |
jkuczm/metalsmith-mtime | lib/index.js | addMtime | function addMtime(err, stats) {
if (err) {
// Skip elements of `files` that don't point to existing files.
// This can happen if some other Metalsmith plugin does something
// strange with `files`.
if (err.code === 'ENOENT') {
debug('file %s not found', file);
r... | javascript | function addMtime(err, stats) {
if (err) {
// Skip elements of `files` that don't point to existing files.
// This can happen if some other Metalsmith plugin does something
// strange with `files`.
if (err.code === 'ENOENT') {
debug('file %s not found', file);
r... | [
"function",
"addMtime",
"(",
"err",
",",
"stats",
")",
"{",
"if",
"(",
"err",
")",
"{",
"// Skip elements of `files` that don't point to existing files.",
"// This can happen if some other Metalsmith plugin does something",
"// strange with `files`.",
"if",
"(",
"err",
".",
"... | Adds `stats.mtime` of `file` to its metadata.
@param {Error} err
@param {fs.Stats} stats
@api private | [
"Adds",
"stats",
".",
"mtime",
"of",
"file",
"to",
"its",
"metadata",
"."
] | 0e7022e82b32f11044da4253833addd26bcdf478 | https://github.com/jkuczm/metalsmith-mtime/blob/0e7022e82b32f11044da4253833addd26bcdf478/lib/index.js#L67-L82 | train |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(object, type, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) {
var fieldsType = type || {};
for (var i = 0, ii = fields.length; i < ii; ++i) {
var params = fieldsType[1] || {};
... | javascript | function(object, type, property) {
var self = this;
object.__addSetter(property, this.SETTER_NAME, this.SETTER_WEIGHT, function(value, fields) {
var fieldsType = type || {};
for (var i = 0, ii = fields.length; i < ii; ++i) {
var params = fieldsType[1] || {};
... | [
"function",
"(",
"object",
",",
"type",
",",
"property",
")",
"{",
"var",
"self",
"=",
"this",
";",
"object",
".",
"__addSetter",
"(",
"property",
",",
"this",
".",
"SETTER_NAME",
",",
"this",
".",
"SETTER_WEIGHT",
",",
"function",
"(",
"value",
",",
"... | Add property setter which checks and converts property value according to its type
@param {object} object Some object
@param {string} type Property type
@param {string} property Property name
@this {metaProcessor} | [
"Add",
"property",
"setter",
"which",
"checks",
"and",
"converts",
"property",
"value",
"according",
"to",
"its",
"type"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L24-L44 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(value, type, property, fields, object) {
if (_.isUndefined(value) || _.isNull(value)) {
return value;
}
var params = {};
if (_.isArray(type)) {
params = type[1] || {};
type = type[0];
}
if (!(type in this._types)) {
... | javascript | function(value, type, property, fields, object) {
if (_.isUndefined(value) || _.isNull(value)) {
return value;
}
var params = {};
if (_.isArray(type)) {
params = type[1] || {};
type = type[0];
}
if (!(type in this._types)) {
... | [
"function",
"(",
"value",
",",
"type",
",",
"property",
",",
"fields",
",",
"object",
")",
"{",
"if",
"(",
"_",
".",
"isUndefined",
"(",
"value",
")",
"||",
"_",
".",
"isNull",
"(",
"value",
")",
")",
"{",
"return",
"value",
";",
"}",
"var",
"par... | Check and converts property value according to its type
@param {*} value Property value
@param {string} type Property type
@param {string} property Property name
@param {array} fields Property fields
@param {object} object Object to which property belongs
@throws {Error} if specified property type do... | [
"Check",
"and",
"converts",
"property",
"value",
"according",
"to",
"its",
"type"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L59-L75 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(delimiter) {
if (!_.isString(delimiter) && !_.isRegExp(delimiter)) {
throw new Error('Delimiter must be a string or a regular expression!');
}
this._defaultArrayDelimiter = delimiter;
return this;
} | javascript | function(delimiter) {
if (!_.isString(delimiter) && !_.isRegExp(delimiter)) {
throw new Error('Delimiter must be a string or a regular expression!');
}
this._defaultArrayDelimiter = delimiter;
return this;
} | [
"function",
"(",
"delimiter",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"delimiter",
")",
"&&",
"!",
"_",
".",
"isRegExp",
"(",
"delimiter",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Delimiter must be a string or a regular expression!'",
")",... | Sets default array delimiter
@param {string} delimiter Array delimiter
@returns {metaProcessor} this
@throws {Error} if delimiter is not a string
@this {metaProcessor} | [
"Sets",
"default",
"array",
"delimiter"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L136-L142 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(value, params, property) {
value = +value;
if ('min' in params && value < params.min) {
throw new Error('Value "' + value +
'" of property "' + property + '" must not be less then "' + params.min + '"!');
}
if ('max' in params... | javascript | function(value, params, property) {
value = +value;
if ('min' in params && value < params.min) {
throw new Error('Value "' + value +
'" of property "' + property + '" must not be less then "' + params.min + '"!');
}
if ('max' in params... | [
"function",
"(",
"value",
",",
"params",
",",
"property",
")",
"{",
"value",
"=",
"+",
"value",
";",
"if",
"(",
"'min'",
"in",
"params",
"&&",
"value",
"<",
"params",
".",
"min",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Value \"'",
"+",
"value",
"... | Number property type
Converts value to number, applies 'min' and 'max' parameters
@param {*} value Property value
@param {object} params Property parameters
@param {string} property Property name
@throws {Error} if value less then 'min' parameter
@throws {Error} if value greater then 'max' parameter
@retur... | [
"Number",
"property",
"type",
"Converts",
"value",
"to",
"number",
"applies",
"min",
"and",
"max",
"parameters"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L189-L201 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(value, params, property) {
value = ''+value;
if ('pattern' in params && !params.pattern.test(value)) {
throw new Error('Value "' + value +
'" of property "' + property + '" does not match pattern "' + params.pattern + '"!');
}
... | javascript | function(value, params, property) {
value = ''+value;
if ('pattern' in params && !params.pattern.test(value)) {
throw new Error('Value "' + value +
'" of property "' + property + '" does not match pattern "' + params.pattern + '"!');
}
... | [
"function",
"(",
"value",
",",
"params",
",",
"property",
")",
"{",
"value",
"=",
"''",
"+",
"value",
";",
"if",
"(",
"'pattern'",
"in",
"params",
"&&",
"!",
"params",
".",
"pattern",
".",
"test",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"Error... | String property type
Converts value to string, applies 'pattern' and 'variants' parameters
@param {*} value Property value
@param {object} params Property parameters
@param {string} property Property name
@throws {Error} if value does not match 'pattern'
@throws {Error} if value does not one of 'variants' v... | [
"String",
"property",
"type",
"Converts",
"value",
"to",
"string",
"applies",
"pattern",
"and",
"variants",
"parameters"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L218-L230 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(value, params, property) {
if (_.isNumber(value) && !isNaN(value)) {
value = new Date(value);
}
else if (_.isString(value)) {
value = new Date(Date.parse(value));
}
if (!(value instanceof Date)) {
throw... | javascript | function(value, params, property) {
if (_.isNumber(value) && !isNaN(value)) {
value = new Date(value);
}
else if (_.isString(value)) {
value = new Date(Date.parse(value));
}
if (!(value instanceof Date)) {
throw... | [
"function",
"(",
"value",
",",
"params",
",",
"property",
")",
"{",
"if",
"(",
"_",
".",
"isNumber",
"(",
"value",
")",
"&&",
"!",
"isNaN",
"(",
"value",
")",
")",
"{",
"value",
"=",
"new",
"Date",
"(",
"value",
")",
";",
"}",
"else",
"if",
"("... | Datetime property type
Converts value to Date
@param {*} value Property value
@param {object} params Property parameters
@param {string} property Property name
@throws {Error} if value could not be successfully converted to Date
@returns {Date} Processed property value
@this {metaProcessor} | [
"Datetime",
"property",
"type",
"Converts",
"value",
"to",
"Date"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L246-L259 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(value, params, property, fields, object) {
if (_.isString(value)) {
value = value.split(params.delimiter || this._defaultArrayDelimiter);
}
if ('element' in params) {
for (var i = 0, ii = value.length; i < ii; ++i) {
valu... | javascript | function(value, params, property, fields, object) {
if (_.isString(value)) {
value = value.split(params.delimiter || this._defaultArrayDelimiter);
}
if ('element' in params) {
for (var i = 0, ii = value.length; i < ii; ++i) {
valu... | [
"function",
"(",
"value",
",",
"params",
",",
"property",
",",
"fields",
",",
"object",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"value",
")",
")",
"{",
"value",
"=",
"value",
".",
"split",
"(",
"params",
".",
"delimiter",
"||",
"this",
".",... | Array property type
Converts value to array, applies 'element' parameter
@param {*} value Property value
@param {object} params Property parameters
@param {string} property Property name
@param {array} fields Property fields
@param {object} object Object to which property belongs
@returns {array} Proce... | [
"Array",
"property",
"type",
"Converts",
"value",
"to",
"array",
"applies",
"element",
"parameter"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L275-L288 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(value, params, property, fields, object) {
var that = this;
if (!_.isSimpleObject(value)) {
throw new Error('Value of property "' +
[property].concat(fields).join('.') +'" must be a simple object!');
}
if ('keys' in params) {... | javascript | function(value, params, property, fields, object) {
var that = this;
if (!_.isSimpleObject(value)) {
throw new Error('Value of property "' +
[property].concat(fields).join('.') +'" must be a simple object!');
}
if ('keys' in params) {... | [
"function",
"(",
"value",
",",
"params",
",",
"property",
",",
"fields",
",",
"object",
")",
"{",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"!",
"_",
".",
"isSimpleObject",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Value of prope... | Hash property type
Check 'simple object' type of value, applies 'keys' and 'element' parameters
@param {*} value Property value
@param {object} params Property parameters
@param {string} property Property name
@param {array} fields Property fields
@param {object} object Object to which property belongs
... | [
"Hash",
"property",
"type",
"Check",
"simple",
"object",
"type",
"of",
"value",
"applies",
"keys",
"and",
"element",
"parameters"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L307-L330 | train | |
alexpods/ClazzJS | src/components/meta/Property/Type.js | function(value, params, property, fields, object) {
if (!_.isObject(value)) {
throw new Error('Value of property "' + property + '" must be an object!');
}
if ('instanceOf' in params) {
var instanceOf = params.instanceOf;
var clazzCl... | javascript | function(value, params, property, fields, object) {
if (!_.isObject(value)) {
throw new Error('Value of property "' + property + '" must be an object!');
}
if ('instanceOf' in params) {
var instanceOf = params.instanceOf;
var clazzCl... | [
"function",
"(",
"value",
",",
"params",
",",
"property",
",",
"fields",
",",
"object",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"value",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Value of property \"'",
"+",
"property",
"+",
"'\" must... | Object property type
Check 'object' type of value, applies 'instanceOf' parameters
@param {*} value Property value
@param {object} params Property parameters
@param {string} property Property name
@param {array} fields Property fields
@param {object} object Object to which property belongs
@throws {Err... | [
"Object",
"property",
"type",
"Check",
"object",
"type",
"of",
"value",
"applies",
"instanceOf",
"parameters"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Property/Type.js#L349-L381 | train | |
Becklyn/becklyn-gulp | tasks/publish.js | removeExisting | function removeExisting ()
{
if (fs.existsSync("web/assets"))
{
var stat = fs.lstatSync("web/assets");
if (stat.isFile() || stat.isSymbolicLink())
{
fs.unlinkSync("web/assets");
}
else
{
wrench.rmdirSyncRecursive("web/assets");
}
... | javascript | function removeExisting ()
{
if (fs.existsSync("web/assets"))
{
var stat = fs.lstatSync("web/assets");
if (stat.isFile() || stat.isSymbolicLink())
{
fs.unlinkSync("web/assets");
}
else
{
wrench.rmdirSyncRecursive("web/assets");
}
... | [
"function",
"removeExisting",
"(",
")",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"\"web/assets\"",
")",
")",
"{",
"var",
"stat",
"=",
"fs",
".",
"lstatSync",
"(",
"\"web/assets\"",
")",
";",
"if",
"(",
"stat",
".",
"isFile",
"(",
")",
"||",
"sta... | Removes the existing directory | [
"Removes",
"the",
"existing",
"directory"
] | 1c633378d561f07101f9db19ccd153617b8e0252 | https://github.com/Becklyn/becklyn-gulp/blob/1c633378d561f07101f9db19ccd153617b8e0252/tasks/publish.js#L14-L29 | train |
wordijp/flexi-require | lib/internal/bower-utils.js | componentsHome | function componentsHome(workdir) {
var bowerrc = path.join(workdir, '.bowerrc'),
defaultHome = path.join(workdir, 'bower_components');
return (fs.existsSync(bowerrc) && require(bowerrc).directory) || defaultHome;
} | javascript | function componentsHome(workdir) {
var bowerrc = path.join(workdir, '.bowerrc'),
defaultHome = path.join(workdir, 'bower_components');
return (fs.existsSync(bowerrc) && require(bowerrc).directory) || defaultHome;
} | [
"function",
"componentsHome",
"(",
"workdir",
")",
"{",
"var",
"bowerrc",
"=",
"path",
".",
"join",
"(",
"workdir",
",",
"'.bowerrc'",
")",
",",
"defaultHome",
"=",
"path",
".",
"join",
"(",
"workdir",
",",
"'bower_components'",
")",
";",
"return",
"(",
... | determine bower components home dir, maybe need to get dir name from '.bowerrc' | [
"determine",
"bower",
"components",
"home",
"dir",
"maybe",
"need",
"to",
"get",
"dir",
"name",
"from",
".",
"bowerrc"
] | f62a7141fd97f4a5b47c9808a5c4a3349aeccb43 | https://github.com/wordijp/flexi-require/blob/f62a7141fd97f4a5b47c9808a5c4a3349aeccb43/lib/internal/bower-utils.js#L12-L16 | train |
wordijp/flexi-require | lib/internal/bower-utils.js | componentName | function componentName(rawname) {
var name = rawname.split(':')[0],
index = name.replace('\\', '/').indexOf('/');
return (index > 0) ? name.substring(0, index) : name;
} | javascript | function componentName(rawname) {
var name = rawname.split(':')[0],
index = name.replace('\\', '/').indexOf('/');
return (index > 0) ? name.substring(0, index) : name;
} | [
"function",
"componentName",
"(",
"rawname",
")",
"{",
"var",
"name",
"=",
"rawname",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
",",
"index",
"=",
"name",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
".",
"indexOf",
"(",
"'/'",
")",
";",
"... | extract component name from inputting rawname | [
"extract",
"component",
"name",
"from",
"inputting",
"rawname"
] | f62a7141fd97f4a5b47c9808a5c4a3349aeccb43 | https://github.com/wordijp/flexi-require/blob/f62a7141fd97f4a5b47c9808a5c4a3349aeccb43/lib/internal/bower-utils.js#L21-L25 | train |
wordijp/flexi-require | lib/internal/bower-utils.js | componentNames | function componentNames(workdir) {
workdir = workdir || process.cwd();
try {
var bowerJson = require(path.join(workdir, 'bower.json'));
return _(Object.keys(bowerJson.dependencies || {}))
.union(Object.keys(bowerJson.devDependencies || {}))
.value();
} catch (ex) {
// not found bower
//console.warn(ex.... | javascript | function componentNames(workdir) {
workdir = workdir || process.cwd();
try {
var bowerJson = require(path.join(workdir, 'bower.json'));
return _(Object.keys(bowerJson.dependencies || {}))
.union(Object.keys(bowerJson.devDependencies || {}))
.value();
} catch (ex) {
// not found bower
//console.warn(ex.... | [
"function",
"componentNames",
"(",
"workdir",
")",
"{",
"workdir",
"=",
"workdir",
"||",
"process",
".",
"cwd",
"(",
")",
";",
"try",
"{",
"var",
"bowerJson",
"=",
"require",
"(",
"path",
".",
"join",
"(",
"workdir",
",",
"'bower.json'",
")",
")",
";",... | get bower components names | [
"get",
"bower",
"components",
"names"
] | f62a7141fd97f4a5b47c9808a5c4a3349aeccb43 | https://github.com/wordijp/flexi-require/blob/f62a7141fd97f4a5b47c9808a5c4a3349aeccb43/lib/internal/bower-utils.js#L30-L42 | train |
wordijp/flexi-require | lib/internal/bower-utils.js | resolve | function resolve(name, workdir) {
workdir = workdir || process.cwd();
var compName = componentName(name),
subname = name.substring(compName.length + 1),
basedir = path.join(componentsHome(workdir), compName),
bowerJson = require(path.join(basedir, 'bower.json'));
var mainfile = Array.isArray(bowerJson.main)
... | javascript | function resolve(name, workdir) {
workdir = workdir || process.cwd();
var compName = componentName(name),
subname = name.substring(compName.length + 1),
basedir = path.join(componentsHome(workdir), compName),
bowerJson = require(path.join(basedir, 'bower.json'));
var mainfile = Array.isArray(bowerJson.main)
... | [
"function",
"resolve",
"(",
"name",
",",
"workdir",
")",
"{",
"workdir",
"=",
"workdir",
"||",
"process",
".",
"cwd",
"(",
")",
";",
"var",
"compName",
"=",
"componentName",
"(",
"name",
")",
",",
"subname",
"=",
"name",
".",
"substring",
"(",
"compNam... | resolve and return entry file's full path for specified component | [
"resolve",
"and",
"return",
"entry",
"file",
"s",
"full",
"path",
"for",
"specified",
"component"
] | f62a7141fd97f4a5b47c9808a5c4a3349aeccb43 | https://github.com/wordijp/flexi-require/blob/f62a7141fd97f4a5b47c9808a5c4a3349aeccb43/lib/internal/bower-utils.js#L48-L77 | train |
wunderbyte/grunt-spiritual-dox | Gruntfile.js | uglify | function uglify(js) {
return ugli.minify(js, {
fromString: true,
mangle: false,
compress: {
warnings: false
}
}).code;
} | javascript | function uglify(js) {
return ugli.minify(js, {
fromString: true,
mangle: false,
compress: {
warnings: false
}
}).code;
} | [
"function",
"uglify",
"(",
"js",
")",
"{",
"return",
"ugli",
".",
"minify",
"(",
"js",
",",
"{",
"fromString",
":",
"true",
",",
"mangle",
":",
"false",
",",
"compress",
":",
"{",
"warnings",
":",
"false",
"}",
"}",
")",
".",
"code",
";",
"}"
] | Compute compressed source for file.
@param {String} filepath The file path
@returns {String} | [
"Compute",
"compressed",
"source",
"for",
"file",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/Gruntfile.js#L106-L114 | train |
JohnnieFucker/dreamix-rpc | lib/rpc-client/failureProcess.js | failsafe | function failsafe(code, tracer, serverId, msg, opts, cb) { // eslint-disable-line
const self = this;
const retryTimes = opts.retryTimes || constants.DEFAULT_PARAM.FAILSAFE_RETRIES;
const retryConnectTime = opts.retryConnectTime || constants.DEFAULT_PARAM.FAILSAFE_CONNECT_TIME;
if (!tracer.retryTimes)... | javascript | function failsafe(code, tracer, serverId, msg, opts, cb) { // eslint-disable-line
const self = this;
const retryTimes = opts.retryTimes || constants.DEFAULT_PARAM.FAILSAFE_RETRIES;
const retryConnectTime = opts.retryConnectTime || constants.DEFAULT_PARAM.FAILSAFE_CONNECT_TIME;
if (!tracer.retryTimes)... | [
"function",
"failsafe",
"(",
"code",
",",
"tracer",
",",
"serverId",
",",
"msg",
",",
"opts",
",",
"cb",
")",
"{",
"// eslint-disable-line",
"const",
"self",
"=",
"this",
";",
"const",
"retryTimes",
"=",
"opts",
".",
"retryTimes",
"||",
"constants",
".",
... | Failsafe rpc failure process.
@param code {Number} error code number.
@param tracer {Object} current rpc tracer.
@param serverId {String} rpc remote target server id.
@param msg {Object} rpc message.
@param opts {Object} rpc client options.
@param cb {Function} user rpc callback.
@api private | [
"Failsafe",
"rpc",
"failure",
"process",
"."
] | eb29e247214148c025456b2bb0542e1094fd2edb | https://github.com/JohnnieFucker/dreamix-rpc/blob/eb29e247214148c025456b2bb0542e1094fd2edb/lib/rpc-client/failureProcess.js#L54-L94 | train |
tolokoban/ToloFrameWork | lib/boilerplate.preprocessor.js | process | function process( ctx, obj ) {
try {
if ( Array.isArray( obj ) ) return processArray( ctx, obj );
switch ( typeof obj ) {
case "string":
return processString( ctx, obj );
case "object":
return processObject( ctx, obj );
default:
return obj;... | javascript | function process( ctx, obj ) {
try {
if ( Array.isArray( obj ) ) return processArray( ctx, obj );
switch ( typeof obj ) {
case "string":
return processString( ctx, obj );
case "object":
return processObject( ctx, obj );
default:
return obj;... | [
"function",
"process",
"(",
"ctx",
",",
"obj",
")",
"{",
"try",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"return",
"processArray",
"(",
"ctx",
",",
"obj",
")",
";",
"switch",
"(",
"typeof",
"obj",
")",
"{",
"case",
"\"string\"... | Return a copy of `obj` after processing it. | [
"Return",
"a",
"copy",
"of",
"obj",
"after",
"processing",
"it",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/boilerplate.preprocessor.js#L53-L67 | train |
redisjs/jsr-server | lib/pubsub.js | PubSub | function PubSub(stats) {
// ref to statistics so they can be updated
// as subscriptions change
this._stats = stats;
// normal channels
this._channels = {};
// pattern channels
this._patterns = {};
this._count = {
channels: {
total: 0, // total number of channels
subscribers: 0... | javascript | function PubSub(stats) {
// ref to statistics so they can be updated
// as subscriptions change
this._stats = stats;
// normal channels
this._channels = {};
// pattern channels
this._patterns = {};
this._count = {
channels: {
total: 0, // total number of channels
subscribers: 0... | [
"function",
"PubSub",
"(",
"stats",
")",
"{",
"// ref to statistics so they can be updated",
"// as subscriptions change",
"this",
".",
"_stats",
"=",
"stats",
";",
"// normal channels",
"this",
".",
"_channels",
"=",
"{",
"}",
";",
"// pattern channels",
"this",
".",... | Encapsulates the pubsub system.
Maps channel identifiers to arrays of client identifiers subscribed
to the given channel.
Clients are given a reference to the channels they are subscribed to,
this global subsystem is responsible for managing the client pubsub
references as well as the global references.
The global i... | [
"Encapsulates",
"the",
"pubsub",
"system",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/pubsub.js#L41-L63 | train |
redisjs/jsr-server | lib/pubsub.js | getChannelList | function getChannelList(channels) {
var i
, channel
, list = [];
for(i = 0;i < channels.length;i++) {
channel = channels[i];
list.push(channel,
this._channels[channel] ? this._channels[channel].length : 0);
}
return list;
} | javascript | function getChannelList(channels) {
var i
, channel
, list = [];
for(i = 0;i < channels.length;i++) {
channel = channels[i];
list.push(channel,
this._channels[channel] ? this._channels[channel].length : 0);
}
return list;
} | [
"function",
"getChannelList",
"(",
"channels",
")",
"{",
"var",
"i",
",",
"channel",
",",
"list",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"channels",
".",
"length",
";",
"i",
"++",
")",
"{",
"channel",
"=",
"channels",
"[",
... | Get a multi bulk array reply of channels with subscriber counts.
Suitable for the PUBSUB NUMSUB [channel-1 channel-N] command.
@param channels The array of channels. | [
"Get",
"a",
"multi",
"bulk",
"array",
"reply",
"of",
"channels",
"with",
"subscriber",
"counts",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/pubsub.js#L127-L137 | train |
redisjs/jsr-server | lib/pubsub.js | getChannels | function getChannels(pattern) {
if(!pattern) return Object.keys(this._channels);
var re = (pattern instanceof RegExp) ? pattern : Pattern.compile(pattern)
, k
, list = [];
for(k in this._channels) {
if(re.test(k)) {
list.push(k);
}
}
return list;
} | javascript | function getChannels(pattern) {
if(!pattern) return Object.keys(this._channels);
var re = (pattern instanceof RegExp) ? pattern : Pattern.compile(pattern)
, k
, list = [];
for(k in this._channels) {
if(re.test(k)) {
list.push(k);
}
}
return list;
} | [
"function",
"getChannels",
"(",
"pattern",
")",
"{",
"if",
"(",
"!",
"pattern",
")",
"return",
"Object",
".",
"keys",
"(",
"this",
".",
"_channels",
")",
";",
"var",
"re",
"=",
"(",
"pattern",
"instanceof",
"RegExp",
")",
"?",
"pattern",
":",
"Pattern"... | Get channels matching pattern not including pattern subscribers.
Suitable for the PUBSUB CHANNELS [pattern] command. | [
"Get",
"channels",
"matching",
"pattern",
"not",
"including",
"pattern",
"subscribers",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/pubsub.js#L144-L155 | train |
redisjs/jsr-server | lib/pubsub.js | cleanup | function cleanup(client) {
if(client.pubsub
&& client.pubsub.channels
&& client.pubsub.patterns
&& !client.pubsub.channels.length
&& !client.pubsub.patterns.length) {
client.pubsub = null;
}
} | javascript | function cleanup(client) {
if(client.pubsub
&& client.pubsub.channels
&& client.pubsub.patterns
&& !client.pubsub.channels.length
&& !client.pubsub.patterns.length) {
client.pubsub = null;
}
} | [
"function",
"cleanup",
"(",
"client",
")",
"{",
"if",
"(",
"client",
".",
"pubsub",
"&&",
"client",
".",
"pubsub",
".",
"channels",
"&&",
"client",
".",
"pubsub",
".",
"patterns",
"&&",
"!",
"client",
".",
"pubsub",
".",
"channels",
".",
"length",
"&&"... | Clean pubsub references on the client when it has no
more channels or patterns. | [
"Clean",
"pubsub",
"references",
"on",
"the",
"client",
"when",
"it",
"has",
"no",
"more",
"channels",
"or",
"patterns",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/pubsub.js#L386-L394 | train |
bentomas/node-async-testing | lib/running.js | generateHelp | function generateHelp(flags) {
var max = 0;
for (var group in flags) {
for (var i = 0; i < flags[group].length; i++) {
var n = 2; // ' '
if (flags[group][i].longFlag) {
n += 2; // '--'
n += flags[group][i].longFlag.length;
}
if (flags[group][i].longFlag && flags[group][i... | javascript | function generateHelp(flags) {
var max = 0;
for (var group in flags) {
for (var i = 0; i < flags[group].length; i++) {
var n = 2; // ' '
if (flags[group][i].longFlag) {
n += 2; // '--'
n += flags[group][i].longFlag.length;
}
if (flags[group][i].longFlag && flags[group][i... | [
"function",
"generateHelp",
"(",
"flags",
")",
"{",
"var",
"max",
"=",
"0",
";",
"for",
"(",
"var",
"group",
"in",
"flags",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"flags",
"[",
"group",
"]",
".",
"length",
";",
"i",
"++",
... | creates the help message for running this from the command line | [
"creates",
"the",
"help",
"message",
"for",
"running",
"this",
"from",
"the",
"command",
"line"
] | 82384ba4b8444e4659464bad661788827ea721aa | https://github.com/bentomas/node-async-testing/blob/82384ba4b8444e4659464bad661788827ea721aa/lib/running.js#L247-L302 | train |
KapIT/observe-utils | lib/observe-utils.js | isPositiveFiniteInteger | function isPositiveFiniteInteger(value, errorMessage) {
value = Number(value);
if (isNaN(value) || !isFinite(value) || value < 0 || value % 1 !== 0) {
throw new RangeError(errorMessage.replace('$', value));
}
return value;
} | javascript | function isPositiveFiniteInteger(value, errorMessage) {
value = Number(value);
if (isNaN(value) || !isFinite(value) || value < 0 || value % 1 !== 0) {
throw new RangeError(errorMessage.replace('$', value));
}
return value;
} | [
"function",
"isPositiveFiniteInteger",
"(",
"value",
",",
"errorMessage",
")",
"{",
"value",
"=",
"Number",
"(",
"value",
")",
";",
"if",
"(",
"isNaN",
"(",
"value",
")",
"||",
"!",
"isFinite",
"(",
"value",
")",
"||",
"value",
"<",
"0",
"||",
"value",... | cast a value as number, and test if the obtained result is a positive finite integer, throw an error otherwise | [
"cast",
"a",
"value",
"as",
"number",
"and",
"test",
"if",
"the",
"obtained",
"result",
"is",
"a",
"positive",
"finite",
"integer",
"throw",
"an",
"error",
"otherwise"
] | 4a9d0140e2dfcb15e85f9d5951692045265fb391 | https://github.com/KapIT/observe-utils/blob/4a9d0140e2dfcb15e85f9d5951692045265fb391/lib/observe-utils.js#L82-L88 | train |
KapIT/observe-utils | lib/observe-utils.js | defineObservableProperty | function defineObservableProperty(target, property, originalValue) {
//we store the value in an non-enumerable property with generated unique name
var internalPropName = '_' + (uidCounter++) + property;
if (target.hasOwnProperty(property)) {
Object.defineProperty(target, internalPr... | javascript | function defineObservableProperty(target, property, originalValue) {
//we store the value in an non-enumerable property with generated unique name
var internalPropName = '_' + (uidCounter++) + property;
if (target.hasOwnProperty(property)) {
Object.defineProperty(target, internalPr... | [
"function",
"defineObservableProperty",
"(",
"target",
",",
"property",
",",
"originalValue",
")",
"{",
"//we store the value in an non-enumerable property with generated unique name",
"var",
"internalPropName",
"=",
"'_'",
"+",
"(",
"uidCounter",
"++",
")",
"+",
"property"... | Define a property on an object that will call the Notifier.notify method when updated | [
"Define",
"a",
"property",
"on",
"an",
"object",
"that",
"will",
"call",
"the",
"Notifier",
".",
"notify",
"method",
"when",
"updated"
] | 4a9d0140e2dfcb15e85f9d5951692045265fb391 | https://github.com/KapIT/observe-utils/blob/4a9d0140e2dfcb15e85f9d5951692045265fb391/lib/observe-utils.js#L97-L133 | train |
zthun/zbuildtools | src/karma/zkarma.js | createKarmaTypescriptConfig | function createKarmaTypescriptConfig(tsconfigJson, coverageDir) {
return {
tsconfig: tsconfigJson,
coverageOptions: {
instrumentation: !isDebug()
},
reports: {
'cobertura': {
directory: coverageDir,
sub... | javascript | function createKarmaTypescriptConfig(tsconfigJson, coverageDir) {
return {
tsconfig: tsconfigJson,
coverageOptions: {
instrumentation: !isDebug()
},
reports: {
'cobertura': {
directory: coverageDir,
sub... | [
"function",
"createKarmaTypescriptConfig",
"(",
"tsconfigJson",
",",
"coverageDir",
")",
"{",
"return",
"{",
"tsconfig",
":",
"tsconfigJson",
",",
"coverageOptions",
":",
"{",
"instrumentation",
":",
"!",
"isDebug",
"(",
")",
"}",
",",
"reports",
":",
"{",
"'c... | Creates an object that represents a karma typescript config object.
@param {String} tsconfigJson The relative path to the tsconfig.json file.
@param {String} coverageDir The coverage report directory.
@return {Object} The common options for a karma typescript configuration. | [
"Creates",
"an",
"object",
"that",
"represents",
"a",
"karma",
"typescript",
"config",
"object",
"."
] | f9b339fc3c3b8188638ccd17a96cb44d457bafd4 | https://github.com/zthun/zbuildtools/blob/f9b339fc3c3b8188638ccd17a96cb44d457bafd4/src/karma/zkarma.js#L39-L60 | train |
igorski/zjslib | src/Sprite.js | Sprite | function Sprite( aElement, aProperties, aContent )
{
aProperties = aProperties || {};
var domElement = "div";
if ( aElement && typeof aElement !== "object" )
{
domElement = /** @type {string} */ ( aElement);
}
/* creates HTML element of requested tag type in the DOM */
if ( !aE... | javascript | function Sprite( aElement, aProperties, aContent )
{
aProperties = aProperties || {};
var domElement = "div";
if ( aElement && typeof aElement !== "object" )
{
domElement = /** @type {string} */ ( aElement);
}
/* creates HTML element of requested tag type in the DOM */
if ( !aE... | [
"function",
"Sprite",
"(",
"aElement",
",",
"aProperties",
",",
"aContent",
")",
"{",
"aProperties",
"=",
"aProperties",
"||",
"{",
"}",
";",
"var",
"domElement",
"=",
"\"div\"",
";",
"if",
"(",
"aElement",
"&&",
"typeof",
"aElement",
"!==",
"\"object\"",
... | A wrapper providing a convenient API to manage a DOM element, provides
Event handling and "display list"s
extends a basic EventTarget for dispatching events
@constructor
@param {string|Element|Node|Window|HTMLDocument=} aElement when String: this function will create an element in the
DOM with the String as tag name... | [
"A",
"wrapper",
"providing",
"a",
"convenient",
"API",
"to",
"manage",
"a",
"DOM",
"element",
"provides",
"Event",
"handling",
"and",
"display",
"list",
"s"
] | d3c3fd49862d21de4646af0403c03f31b1134b00 | https://github.com/igorski/zjslib/blob/d3c3fd49862d21de4646af0403c03f31b1134b00/src/Sprite.js#L50-L87 | train |
igorski/zjslib | src/Sprite.js | function( e )
{
var event = new Event( aType );
event.target = self;
event.srcEvent = e;
aHandler( event );
} | javascript | function( e )
{
var event = new Event( aType );
event.target = self;
event.srcEvent = e;
aHandler( event );
} | [
"function",
"(",
"e",
")",
"{",
"var",
"event",
"=",
"new",
"Event",
"(",
"aType",
")",
";",
"event",
".",
"target",
"=",
"self",
";",
"event",
".",
"srcEvent",
"=",
"e",
";",
"aHandler",
"(",
"event",
")",
";",
"}"
] | wrap the callback invocation to reference the Sprite, NOT the DOM node as its target | [
"wrap",
"the",
"callback",
"invocation",
"to",
"reference",
"the",
"Sprite",
"NOT",
"the",
"DOM",
"node",
"as",
"its",
"target"
] | d3c3fd49862d21de4646af0403c03f31b1134b00 | https://github.com/igorski/zjslib/blob/d3c3fd49862d21de4646af0403c03f31b1134b00/src/Sprite.js#L180-L187 | train | |
magemello/gulp-license-check | index.js | checkHeaderFromStream | function checkHeaderFromStream(file, ctx) {
file.contents.pipe(es.wait(function (err, data) {
if (err) {
throw err;
}
var bufferFile = new File({
path: file.path,
contents: data
});
checkHeaderFromBuffer(bufferFile, ctx);
}));
} | javascript | function checkHeaderFromStream(file, ctx) {
file.contents.pipe(es.wait(function (err, data) {
if (err) {
throw err;
}
var bufferFile = new File({
path: file.path,
contents: data
});
checkHeaderFromBuffer(bufferFile, ctx);
}));
} | [
"function",
"checkHeaderFromStream",
"(",
"file",
",",
"ctx",
")",
"{",
"file",
".",
"contents",
".",
"pipe",
"(",
"es",
".",
"wait",
"(",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"var",
... | Check header from stream.
@param {object} file - current file from stream.
@param {object} ctx - context.
@returns {string[]} file in string[] format. | [
"Check",
"header",
"from",
"stream",
"."
] | fbd547b989a90f7ea3bb41304868a03ec207f204 | https://github.com/magemello/gulp-license-check/blob/fbd547b989a90f7ea3bb41304868a03ec207f204/index.js#L59-L72 | train |
magemello/gulp-license-check | index.js | checkHeaderFromBuffer | function checkHeaderFromBuffer(file, ctx) {
if (isLicenseHeaderPresent(file)) {
log(file.path, ctx);
} else {
error(file.path, ctx);
}
} | javascript | function checkHeaderFromBuffer(file, ctx) {
if (isLicenseHeaderPresent(file)) {
log(file.path, ctx);
} else {
error(file.path, ctx);
}
} | [
"function",
"checkHeaderFromBuffer",
"(",
"file",
",",
"ctx",
")",
"{",
"if",
"(",
"isLicenseHeaderPresent",
"(",
"file",
")",
")",
"{",
"log",
"(",
"file",
".",
"path",
",",
"ctx",
")",
";",
"}",
"else",
"{",
"error",
"(",
"file",
".",
"path",
",",
... | Check header from buffer.
@param {object} file - current file from buffer.
@param {object} ctx - context. | [
"Check",
"header",
"from",
"buffer",
"."
] | fbd547b989a90f7ea3bb41304868a03ec207f204 | https://github.com/magemello/gulp-license-check/blob/fbd547b989a90f7ea3bb41304868a03ec207f204/index.js#L80-L86 | train |
magemello/gulp-license-check | index.js | readLicenseHeaderFile | function readLicenseHeaderFile() {
if (licenseFileUtf8) {
return licenseFileUtf8;
}
if (fs.existsSync(licenseFilePath)) {
return fs.readFileSync(licenseFilePath, 'utf8').split(/\r?\n/);
}
throw new gutil.PluginError('gulp-license-check', new Error('The license header file doesn`t exist ' + licenseFile... | javascript | function readLicenseHeaderFile() {
if (licenseFileUtf8) {
return licenseFileUtf8;
}
if (fs.existsSync(licenseFilePath)) {
return fs.readFileSync(licenseFilePath, 'utf8').split(/\r?\n/);
}
throw new gutil.PluginError('gulp-license-check', new Error('The license header file doesn`t exist ' + licenseFile... | [
"function",
"readLicenseHeaderFile",
"(",
")",
"{",
"if",
"(",
"licenseFileUtf8",
")",
"{",
"return",
"licenseFileUtf8",
";",
"}",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"licenseFilePath",
")",
")",
"{",
"return",
"fs",
".",
"readFileSync",
"(",
"licenseFi... | Read the file header path.
@returns {string[]} The license header template in sting[] format. | [
"Read",
"the",
"file",
"header",
"path",
"."
] | fbd547b989a90f7ea3bb41304868a03ec207f204 | https://github.com/magemello/gulp-license-check/blob/fbd547b989a90f7ea3bb41304868a03ec207f204/index.js#L104-L114 | train |
magemello/gulp-license-check | index.js | log | function log(filePath, ctx) {
if (isInfoLogActive) {
ctx.emit('log', {
msg: HEADER_PRESENT,
path: filePath
});
gutil.log(gutil.colors.green(HEADER_PRESENT), filePath);
}
} | javascript | function log(filePath, ctx) {
if (isInfoLogActive) {
ctx.emit('log', {
msg: HEADER_PRESENT,
path: filePath
});
gutil.log(gutil.colors.green(HEADER_PRESENT), filePath);
}
} | [
"function",
"log",
"(",
"filePath",
",",
"ctx",
")",
"{",
"if",
"(",
"isInfoLogActive",
")",
"{",
"ctx",
".",
"emit",
"(",
"'log'",
",",
"{",
"msg",
":",
"HEADER_PRESENT",
",",
"path",
":",
"filePath",
"}",
")",
";",
"gutil",
".",
"log",
"(",
"guti... | Log util.
@param {string} filePath - file Path.
@param {object} ctx - context. | [
"Log",
"util",
"."
] | fbd547b989a90f7ea3bb41304868a03ec207f204 | https://github.com/magemello/gulp-license-check/blob/fbd547b989a90f7ea3bb41304868a03ec207f204/index.js#L122-L130 | train |
magemello/gulp-license-check | index.js | error | function error(filePath, ctx) {
if (isErrorBlocking) {
throw new gutil.PluginError('gulp-license-check', new Error('The following file doesn`t contain the license header ' + filePath));
} else {
logError(filePath, ctx);
}
} | javascript | function error(filePath, ctx) {
if (isErrorBlocking) {
throw new gutil.PluginError('gulp-license-check', new Error('The following file doesn`t contain the license header ' + filePath));
} else {
logError(filePath, ctx);
}
} | [
"function",
"error",
"(",
"filePath",
",",
"ctx",
")",
"{",
"if",
"(",
"isErrorBlocking",
")",
"{",
"throw",
"new",
"gutil",
".",
"PluginError",
"(",
"'gulp-license-check'",
",",
"new",
"Error",
"(",
"'The following file doesn`t contain the license header '",
"+",
... | Manage error in case the header is not present.
@param {string} filePath - file Path.
@param {object} ctx - context. | [
"Manage",
"error",
"in",
"case",
"the",
"header",
"is",
"not",
"present",
"."
] | fbd547b989a90f7ea3bb41304868a03ec207f204 | https://github.com/magemello/gulp-license-check/blob/fbd547b989a90f7ea3bb41304868a03ec207f204/index.js#L138-L144 | train |
magemello/gulp-license-check | index.js | logError | function logError(filePath, ctx) {
if (isErrorLogActive) {
ctx.emit('log', {
msg: HEADER_NOT_PRESENT,
path: filePath
});
gutil.log(gutil.colors.red(HEADER_NOT_PRESENT), filePath);
}
} | javascript | function logError(filePath, ctx) {
if (isErrorLogActive) {
ctx.emit('log', {
msg: HEADER_NOT_PRESENT,
path: filePath
});
gutil.log(gutil.colors.red(HEADER_NOT_PRESENT), filePath);
}
} | [
"function",
"logError",
"(",
"filePath",
",",
"ctx",
")",
"{",
"if",
"(",
"isErrorLogActive",
")",
"{",
"ctx",
".",
"emit",
"(",
"'log'",
",",
"{",
"msg",
":",
"HEADER_NOT_PRESENT",
",",
"path",
":",
"filePath",
"}",
")",
";",
"gutil",
".",
"log",
"(... | Log error.
@param {string} filePath - file Path.
@param {object} ctx - context. | [
"Log",
"error",
"."
] | fbd547b989a90f7ea3bb41304868a03ec207f204 | https://github.com/magemello/gulp-license-check/blob/fbd547b989a90f7ea3bb41304868a03ec207f204/index.js#L152-L160 | train |
magemello/gulp-license-check | index.js | isLicenseHeaderPresent | function isLicenseHeaderPresent(currentFile) {
if (!isFileEmpty(currentFile.contents)) {
var currentFileUtf8 = readCurrentFile(currentFile),
licenseFileUtf8 = readLicenseHeaderFile(),
skipStrict = 0;
if(currentFileUtf8[0] === '"use strict";' ) {
skipStrict = 1;
}
for (var i = skipStrict; i <... | javascript | function isLicenseHeaderPresent(currentFile) {
if (!isFileEmpty(currentFile.contents)) {
var currentFileUtf8 = readCurrentFile(currentFile),
licenseFileUtf8 = readLicenseHeaderFile(),
skipStrict = 0;
if(currentFileUtf8[0] === '"use strict";' ) {
skipStrict = 1;
}
for (var i = skipStrict; i <... | [
"function",
"isLicenseHeaderPresent",
"(",
"currentFile",
")",
"{",
"if",
"(",
"!",
"isFileEmpty",
"(",
"currentFile",
".",
"contents",
")",
")",
"{",
"var",
"currentFileUtf8",
"=",
"readCurrentFile",
"(",
"currentFile",
")",
",",
"licenseFileUtf8",
"=",
"readLi... | Check if header is present.
@param {object} currentFile - file in string[] format.
@returns {boolean} dose match. | [
"Check",
"if",
"header",
"is",
"present",
"."
] | fbd547b989a90f7ea3bb41304868a03ec207f204 | https://github.com/magemello/gulp-license-check/blob/fbd547b989a90f7ea3bb41304868a03ec207f204/index.js#L169-L186 | train |
calleboketoft/ng2-browser-storage | src/browser-storage/services/browser-storage.util.js | getConfigFromLS | function getConfigFromLS() {
var configStr = localStorage[getFullBSKey(browser_storage_config_1.browserStorageConfig.DB_CONFIG_KEY)];
if (typeof configStr === 'undefined') {
return null;
}
else {
return JSON.parse(configStr);
}
} | javascript | function getConfigFromLS() {
var configStr = localStorage[getFullBSKey(browser_storage_config_1.browserStorageConfig.DB_CONFIG_KEY)];
if (typeof configStr === 'undefined') {
return null;
}
else {
return JSON.parse(configStr);
}
} | [
"function",
"getConfigFromLS",
"(",
")",
"{",
"var",
"configStr",
"=",
"localStorage",
"[",
"getFullBSKey",
"(",
"browser_storage_config_1",
".",
"browserStorageConfig",
".",
"DB_CONFIG_KEY",
")",
"]",
";",
"if",
"(",
"typeof",
"configStr",
"===",
"'undefined'",
"... | get config from browser storage and deserialize to JSON | [
"get",
"config",
"from",
"browser",
"storage",
"and",
"deserialize",
"to",
"JSON"
] | 7186096797957de62649bbb832a7c6b7d463d861 | https://github.com/calleboketoft/ng2-browser-storage/blob/7186096797957de62649bbb832a7c6b7d463d861/src/browser-storage/services/browser-storage.util.js#L5-L13 | train |
calleboketoft/ng2-browser-storage | src/browser-storage/services/browser-storage.util.js | setConfigToLS | function setConfigToLS(configObj) {
var configStr = JSON.stringify(configObj);
window.localStorage[getFullBSKey(browser_storage_config_1.browserStorageConfig.DB_CONFIG_KEY)] = configStr;
} | javascript | function setConfigToLS(configObj) {
var configStr = JSON.stringify(configObj);
window.localStorage[getFullBSKey(browser_storage_config_1.browserStorageConfig.DB_CONFIG_KEY)] = configStr;
} | [
"function",
"setConfigToLS",
"(",
"configObj",
")",
"{",
"var",
"configStr",
"=",
"JSON",
".",
"stringify",
"(",
"configObj",
")",
";",
"window",
".",
"localStorage",
"[",
"getFullBSKey",
"(",
"browser_storage_config_1",
".",
"browserStorageConfig",
".",
"DB_CONFI... | serialize config and save to browser storage | [
"serialize",
"config",
"and",
"save",
"to",
"browser",
"storage"
] | 7186096797957de62649bbb832a7c6b7d463d861 | https://github.com/calleboketoft/ng2-browser-storage/blob/7186096797957de62649bbb832a7c6b7d463d861/src/browser-storage/services/browser-storage.util.js#L16-L19 | train |
calleboketoft/ng2-browser-storage | src/browser-storage/services/browser-storage.util.js | getInitialBrowserStorageState | function getInitialBrowserStorageState() {
var memorizedFile = getConfigFromLS()[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY];
return memorizedFile.map(function (memItem) {
var browserStorageValue = window[memItem.storageType]['getItem'](getFullBSKey(memItem.key));
if (browserSt... | javascript | function getInitialBrowserStorageState() {
var memorizedFile = getConfigFromLS()[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY];
return memorizedFile.map(function (memItem) {
var browserStorageValue = window[memItem.storageType]['getItem'](getFullBSKey(memItem.key));
if (browserSt... | [
"function",
"getInitialBrowserStorageState",
"(",
")",
"{",
"var",
"memorizedFile",
"=",
"getConfigFromLS",
"(",
")",
"[",
"browser_storage_config_1",
".",
"browserStorageConfig",
".",
"DB_INITIAL_KEY",
"]",
";",
"return",
"memorizedFile",
".",
"map",
"(",
"function",... | go through memorized file config and get all separate browser storage values from keys | [
"go",
"through",
"memorized",
"file",
"config",
"and",
"get",
"all",
"separate",
"browser",
"storage",
"values",
"from",
"keys"
] | 7186096797957de62649bbb832a7c6b7d463d861 | https://github.com/calleboketoft/ng2-browser-storage/blob/7186096797957de62649bbb832a7c6b7d463d861/src/browser-storage/services/browser-storage.util.js#L23-L34 | train |
calleboketoft/ng2-browser-storage | src/browser-storage/services/browser-storage.util.js | initFromScratch | function initFromScratch(cbsConfigFromFile) {
cbsConfigFromFile.initialState.forEach(function (item) { return saveItemToBrowserStorage(item); });
return _a = {},
_a[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY] = cbsConfigFromFile.initialState,
_a;
var _a;
} | javascript | function initFromScratch(cbsConfigFromFile) {
cbsConfigFromFile.initialState.forEach(function (item) { return saveItemToBrowserStorage(item); });
return _a = {},
_a[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY] = cbsConfigFromFile.initialState,
_a;
var _a;
} | [
"function",
"initFromScratch",
"(",
"cbsConfigFromFile",
")",
"{",
"cbsConfigFromFile",
".",
"initialState",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"saveItemToBrowserStorage",
"(",
"item",
")",
";",
"}",
")",
";",
"return",
"_a",
"="... | Initialize storage items from scratch | [
"Initialize",
"storage",
"items",
"from",
"scratch"
] | 7186096797957de62649bbb832a7c6b7d463d861 | https://github.com/calleboketoft/ng2-browser-storage/blob/7186096797957de62649bbb832a7c6b7d463d861/src/browser-storage/services/browser-storage.util.js#L55-L61 | train |
calleboketoft/ng2-browser-storage | src/browser-storage/services/browser-storage.util.js | initExisting | function initExisting(cbsConfigFromFile, cbsConfigFromLS) {
// Restore items that have been manually removed by a user
restoreManuallyRemovedItems(cbsConfigFromLS);
var configFileDifferOptions = {
fileInitialState: cbsConfigFromFile.initialState,
memoryInitialState: cbsConfigFromLS[browser_s... | javascript | function initExisting(cbsConfigFromFile, cbsConfigFromLS) {
// Restore items that have been manually removed by a user
restoreManuallyRemovedItems(cbsConfigFromLS);
var configFileDifferOptions = {
fileInitialState: cbsConfigFromFile.initialState,
memoryInitialState: cbsConfigFromLS[browser_s... | [
"function",
"initExisting",
"(",
"cbsConfigFromFile",
",",
"cbsConfigFromLS",
")",
"{",
"// Restore items that have been manually removed by a user",
"restoreManuallyRemovedItems",
"(",
"cbsConfigFromLS",
")",
";",
"var",
"configFileDifferOptions",
"=",
"{",
"fileInitialState",
... | Initialize storage items for existing config, handle any config file updates | [
"Initialize",
"storage",
"items",
"for",
"existing",
"config",
"handle",
"any",
"config",
"file",
"updates"
] | 7186096797957de62649bbb832a7c6b7d463d861 | https://github.com/calleboketoft/ng2-browser-storage/blob/7186096797957de62649bbb832a7c6b7d463d861/src/browser-storage/services/browser-storage.util.js#L63-L73 | train |
calleboketoft/ng2-browser-storage | src/browser-storage/services/browser-storage.util.js | restoreManuallyRemovedItems | function restoreManuallyRemovedItems(cbsConfigFromLS) {
cbsConfigFromLS[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY].map(function (memoryItem) {
var storageItemValue = getItemValueFromBrowserStorage(memoryItem);
// the storage item has been removed, put back from memory object
... | javascript | function restoreManuallyRemovedItems(cbsConfigFromLS) {
cbsConfigFromLS[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY].map(function (memoryItem) {
var storageItemValue = getItemValueFromBrowserStorage(memoryItem);
// the storage item has been removed, put back from memory object
... | [
"function",
"restoreManuallyRemovedItems",
"(",
"cbsConfigFromLS",
")",
"{",
"cbsConfigFromLS",
"[",
"browser_storage_config_1",
".",
"browserStorageConfig",
".",
"DB_INITIAL_KEY",
"]",
".",
"map",
"(",
"function",
"(",
"memoryItem",
")",
"{",
"var",
"storageItemValue",... | if an item has been manually removed from browser storage, restore it | [
"if",
"an",
"item",
"has",
"been",
"manually",
"removed",
"from",
"browser",
"storage",
"restore",
"it"
] | 7186096797957de62649bbb832a7c6b7d463d861 | https://github.com/calleboketoft/ng2-browser-storage/blob/7186096797957de62649bbb832a7c6b7d463d861/src/browser-storage/services/browser-storage.util.js#L75-L83 | train |
blueflag/immutable-math | lib/transformations.js | percentBy | function percentBy(valueMapper) {
var valueSetter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
return function (input) {
if (input.isEmpty()) {
return input;
}
var percents = input.map(valueMapper).update(percent());
if (!valueSetter) ... | javascript | function percentBy(valueMapper) {
var valueSetter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
return function (input) {
if (input.isEmpty()) {
return input;
}
var percents = input.map(valueMapper).update(percent());
if (!valueSetter) ... | [
"function",
"percentBy",
"(",
"valueMapper",
")",
"{",
"var",
"valueSetter",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"null",
";",
"return",
"function",
"(",
... | Like `percent`, but also accepts a `valueMapper` function which allows you to process child properties.
@param {ValueMapper} valueMapper
@param {ValueSetter} valueSetter
@return {InputFunction} | [
"Like",
"percent",
"but",
"also",
"accepts",
"a",
"valueMapper",
"function",
"which",
"allows",
"you",
"to",
"process",
"child",
"properties",
"."
] | 64aba91517ce6836e0a3ebec2ba2b248408140f3 | https://github.com/blueflag/immutable-math/blob/64aba91517ce6836e0a3ebec2ba2b248408140f3/lib/transformations.js#L39-L56 | train |
jamespdlynn/microjs | examples/game/lib/model/player.js | function(deltaTime){
var currentTime = new Date().getTime();
deltaTime = deltaTime || currentTime-this.lastUpdated;
//Ignore minor updates
if (deltaTime < 5){
return this;
}
deltaTime /= 1000; //convert to seconds
//... | javascript | function(deltaTime){
var currentTime = new Date().getTime();
deltaTime = deltaTime || currentTime-this.lastUpdated;
//Ignore minor updates
if (deltaTime < 5){
return this;
}
deltaTime /= 1000; //convert to seconds
//... | [
"function",
"(",
"deltaTime",
")",
"{",
"var",
"currentTime",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"deltaTime",
"=",
"deltaTime",
"||",
"currentTime",
"-",
"this",
".",
"lastUpdated",
";",
"//Ignore minor updates",
"if",
"(",
"delta... | Updates this player's velocity and position values
@param {number} [deltaTime] Time interval in milliseconds (by default uses the amount of time since function last called)
@returns {*} | [
"Updates",
"this",
"player",
"s",
"velocity",
"and",
"position",
"values"
] | 780a4074de84bcd74e3ae50d0ed64144b4474166 | https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/model/player.js#L73-L140 | train | |
jamespdlynn/microjs | examples/game/lib/model/player.js | function(posX, posY){
//Calculate the position deltas while account for zone boundaries
var zoneWidth = Constants.Zone.WIDTH;
var zoneHeight = Constants.Zone.HEIGHT;
var deltaX = posX - this.get("posX");
if (Math.abs(deltaX) > zoneWidth/2){
(... | javascript | function(posX, posY){
//Calculate the position deltas while account for zone boundaries
var zoneWidth = Constants.Zone.WIDTH;
var zoneHeight = Constants.Zone.HEIGHT;
var deltaX = posX - this.get("posX");
if (Math.abs(deltaX) > zoneWidth/2){
(... | [
"function",
"(",
"posX",
",",
"posY",
")",
"{",
"//Calculate the position deltas while account for zone boundaries",
"var",
"zoneWidth",
"=",
"Constants",
".",
"Zone",
".",
"WIDTH",
";",
"var",
"zoneHeight",
"=",
"Constants",
".",
"Zone",
".",
"HEIGHT",
";",
"var"... | Ease a player to a new position, by adding an auxiliary angle and velocity to update by.
This function can serve as a "dead reckoning algorithm" to smooth difference between positions on the client and server
@param {number} posX
@param {number} posY
@returns {*} | [
"Ease",
"a",
"player",
"to",
"a",
"new",
"position",
"by",
"adding",
"an",
"auxiliary",
"angle",
"and",
"velocity",
"to",
"update",
"by",
".",
"This",
"function",
"can",
"serve",
"as",
"a",
"dead",
"reckoning",
"algorithm",
"to",
"smooth",
"difference",
"b... | 780a4074de84bcd74e3ae50d0ed64144b4474166 | https://github.com/jamespdlynn/microjs/blob/780a4074de84bcd74e3ae50d0ed64144b4474166/examples/game/lib/model/player.js#L149-L177 | train | |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | readFileSync | function readFileSync (fileName, options) {
verifyFileName (fileName);
var info = getFileInfo (fileName);
if (info.exists === false) {
var message1 = format (cc.MSG_DOES_NOT_EXIST, fileName);
throw new SafeFileError (cc.DOES_NOT_EXIST, message1);
}
if (info.isFile === false) {
... | javascript | function readFileSync (fileName, options) {
verifyFileName (fileName);
var info = getFileInfo (fileName);
if (info.exists === false) {
var message1 = format (cc.MSG_DOES_NOT_EXIST, fileName);
throw new SafeFileError (cc.DOES_NOT_EXIST, message1);
}
if (info.isFile === false) {
... | [
"function",
"readFileSync",
"(",
"fileName",
",",
"options",
")",
"{",
"verifyFileName",
"(",
"fileName",
")",
";",
"var",
"info",
"=",
"getFileInfo",
"(",
"fileName",
")",
";",
"if",
"(",
"info",
".",
"exists",
"===",
"false",
")",
"{",
"var",
"message1... | Read file.
@param {String} fileName File to read.
@returns {String} Data read from file.
@throws SafeFileError | [
"Read",
"file",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L23-L47 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | writeFileSync | function writeFileSync (fileName, data, options) {
verifyFileName (fileName);
var info = getFileInfo (fileName);
if ((info.exists === true) && (info.isFile === false)) {
var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc.IS_NOT_A_FILE, message1);
}
... | javascript | function writeFileSync (fileName, data, options) {
verifyFileName (fileName);
var info = getFileInfo (fileName);
if ((info.exists === true) && (info.isFile === false)) {
var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc.IS_NOT_A_FILE, message1);
}
... | [
"function",
"writeFileSync",
"(",
"fileName",
",",
"data",
",",
"options",
")",
"{",
"verifyFileName",
"(",
"fileName",
")",
";",
"var",
"info",
"=",
"getFileInfo",
"(",
"fileName",
")",
";",
"if",
"(",
"(",
"info",
".",
"exists",
"===",
"true",
")",
"... | Write data to a file.
@param {String} fileName Name of file (path optional).
@param {String} data Data to write.
@throws SafeFileError | [
"Write",
"data",
"to",
"a",
"file",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L55-L76 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | safeGetState | function safeGetState (fileName) {
if ((fileName === undefined) || (fileName === null)) {
return (cc.INVALID_NAME);
}
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
return (cc.IS_NOT_A_FILE);
}
va... | javascript | function safeGetState (fileName) {
if ((fileName === undefined) || (fileName === null)) {
return (cc.INVALID_NAME);
}
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
return (cc.IS_NOT_A_FILE);
}
va... | [
"function",
"safeGetState",
"(",
"fileName",
")",
"{",
"if",
"(",
"(",
"fileName",
"===",
"undefined",
")",
"||",
"(",
"fileName",
"===",
"null",
")",
")",
"{",
"return",
"(",
"cc",
".",
"INVALID_NAME",
")",
";",
"}",
"// if fileName exists, verify it is a f... | Get status of the file.
@param {String} file Name of base file.
@returns {Integer} SAFE_NORMAL, SAFE_AUTO_RECOVERABLE, SAFE_INTERVENE,
INVALID_NAME, IS_NOT_A_FILE, or DOES_NOT_EXIST | [
"Get",
"status",
"of",
"the",
"file",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L84-L96 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | safeRecover | function safeRecover (fileName) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc.IS_NOT_A_FILE, m... | javascript | function safeRecover (fileName) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message1 = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc.IS_NOT_A_FILE, m... | [
"function",
"safeRecover",
"(",
"fileName",
")",
"{",
"verifyFileName",
"(",
"fileName",
")",
";",
"// if fileName exists, verify it is a file",
"var",
"info",
"=",
"getFileInfo",
"(",
"fileName",
")",
";",
"if",
"(",
"(",
"info",
".",
"exists",
")",
"&&",
"("... | Initiate auto-recovery processing.
@param {String} fileName Name of base file
@throws SafeFileError | [
"Initiate",
"auto",
"-",
"recovery",
"processing",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L103-L121 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | safeReadFileSync | function safeReadFileSync (fileName, options) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc... | javascript | function safeReadFileSync (fileName, options) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileError (cc... | [
"function",
"safeReadFileSync",
"(",
"fileName",
",",
"options",
")",
"{",
"verifyFileName",
"(",
"fileName",
")",
";",
"// if fileName exists, verify it is a file",
"var",
"info",
"=",
"getFileInfo",
"(",
"fileName",
")",
";",
"if",
"(",
"(",
"info",
".",
"exis... | Read a file, performing recovery processing if necessary.
@param {String} file File to read.
@returns {String} Data read from file.
@throws SafeFileError | [
"Read",
"a",
"file",
"performing",
"recovery",
"processing",
"if",
"necessary",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L129-L147 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | safeWriteFileSync | function safeWriteFileSync (fileName, data, options) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileEr... | javascript | function safeWriteFileSync (fileName, data, options) {
verifyFileName (fileName);
// if fileName exists, verify it is a file
var info = getFileInfo (fileName);
if ((info.exists) && (info.isFile === false)) {
var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
throw new SafeFileEr... | [
"function",
"safeWriteFileSync",
"(",
"fileName",
",",
"data",
",",
"options",
")",
"{",
"verifyFileName",
"(",
"fileName",
")",
";",
"// if fileName exists, verify it is a file",
"var",
"info",
"=",
"getFileInfo",
"(",
"fileName",
")",
";",
"if",
"(",
"(",
"inf... | Write data to a file using a recoverable process.
@param {String} fileName Name of file (path optional).
@param {String} data Data to write.
@throws SafeFileError | [
"Write",
"data",
"to",
"a",
"file",
"using",
"a",
"recoverable",
"process",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L155-L187 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | verifyFileName | function verifyFileName (fileName)
{
// if fileName undefined or null, throw exception
if ((fileName === undefined) || (fileName === null)) {
var message1 = format (cc.MSG_INVALID_NAME);
throw new SafeFileError (cc.INVALID_NAME, message1);
}
} | javascript | function verifyFileName (fileName)
{
// if fileName undefined or null, throw exception
if ((fileName === undefined) || (fileName === null)) {
var message1 = format (cc.MSG_INVALID_NAME);
throw new SafeFileError (cc.INVALID_NAME, message1);
}
} | [
"function",
"verifyFileName",
"(",
"fileName",
")",
"{",
"// if fileName undefined or null, throw exception",
"if",
"(",
"(",
"fileName",
"===",
"undefined",
")",
"||",
"(",
"fileName",
"===",
"null",
")",
")",
"{",
"var",
"message1",
"=",
"format",
"(",
"cc",
... | Verify fileName parameter.
@param {String} fileName Name of file to verify.
@throws SafeFileError | [
"Verify",
"fileName",
"parameter",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L194-L201 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | getState | function getState (file) {
// collect state for all possible data and recovery files
var state = {};
state.ephemeral = getFileInfo (file + ".eph");
state.ready = getFileInfo (file + ".rdy");
state.base = getFileInfo (file);
state.backup = getFileInfo (file + ".bak");
state.tertiary = getFile... | javascript | function getState (file) {
// collect state for all possible data and recovery files
var state = {};
state.ephemeral = getFileInfo (file + ".eph");
state.ready = getFileInfo (file + ".rdy");
state.base = getFileInfo (file);
state.backup = getFileInfo (file + ".bak");
state.tertiary = getFile... | [
"function",
"getState",
"(",
"file",
")",
"{",
"// collect state for all possible data and recovery files",
"var",
"state",
"=",
"{",
"}",
";",
"state",
".",
"ephemeral",
"=",
"getFileInfo",
"(",
"file",
"+",
"\".eph\"",
")",
";",
"state",
".",
"ready",
"=",
"... | Get state for file system entities.
@param {String} file Base file name.
@returns {Object} State object. | [
"Get",
"state",
"for",
"file",
"system",
"entities",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L208-L232 | train |
usingjsonschema/ujs-safefile-nodejs | lib/safeFile.js | performRecovery | function performRecovery (state, removeEphemeral) {
// if ephemeral flag true, and ephemeral file exists, remove it
if ((removeEphemeral) && (state.ephemeral.exists)) {
fs.unlinkSync (state.ephemeral.name);
}
// if only backups exist, restore from backup
var baseAvailable = state.base.exist... | javascript | function performRecovery (state, removeEphemeral) {
// if ephemeral flag true, and ephemeral file exists, remove it
if ((removeEphemeral) && (state.ephemeral.exists)) {
fs.unlinkSync (state.ephemeral.name);
}
// if only backups exist, restore from backup
var baseAvailable = state.base.exist... | [
"function",
"performRecovery",
"(",
"state",
",",
"removeEphemeral",
")",
"{",
"// if ephemeral flag true, and ephemeral file exists, remove it",
"if",
"(",
"(",
"removeEphemeral",
")",
"&&",
"(",
"state",
".",
"ephemeral",
".",
"exists",
")",
")",
"{",
"fs",
".",
... | Evaluate save state, initiating recovery if necessary.
@param {Object} state State object with file names and existence flags | [
"Evaluate",
"save",
"state",
"initiating",
"recovery",
"if",
"necessary",
"."
] | 73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7 | https://github.com/usingjsonschema/ujs-safefile-nodejs/blob/73a50d0c74bb7c0f0b73a91312f10f7c3f78adb7/lib/safeFile.js#L260-L312 | train |
SciSpike/yaktor-ui-angular1 | lib/parse.js | function (daString) {
// stop shouting
daString = daString.replace(/^([A-Z]*)$/, function (match, c) {
return (c ? c.toLowerCase() : '')
})
// prepare camels for _
daString = daString.replace(/([A-Z])/g, function (match, c) {
return (c ? '_' + c : '')
})
// conv... | javascript | function (daString) {
// stop shouting
daString = daString.replace(/^([A-Z]*)$/, function (match, c) {
return (c ? c.toLowerCase() : '')
})
// prepare camels for _
daString = daString.replace(/([A-Z])/g, function (match, c) {
return (c ? '_' + c : '')
})
// conv... | [
"function",
"(",
"daString",
")",
"{",
"// stop shouting",
"daString",
"=",
"daString",
".",
"replace",
"(",
"/",
"^([A-Z]*)$",
"/",
",",
"function",
"(",
"match",
",",
"c",
")",
"{",
"return",
"(",
"c",
"?",
"c",
".",
"toLowerCase",
"(",
")",
":",
"... | Generate a UI model based on a SciSpike generated state matrix. | [
"Generate",
"a",
"UI",
"model",
"based",
"on",
"a",
"SciSpike",
"generated",
"state",
"matrix",
"."
] | 35c29a18045a5f0f7eeedd3781f77a155ed5b017 | https://github.com/SciSpike/yaktor-ui-angular1/blob/35c29a18045a5f0f7eeedd3781f77a155ed5b017/lib/parse.js#L8-L27 | train | |
biggora/trinte-creator | app/bin/trinte.js | bootModel | function bootModel(trinte, schema, file) {
if (/\.js$/i.test(file)) {
var name = file.replace(/\.js$/i, '');
var modelDir = path.resolve(__dirname, '../app/models');
trinte.models[name] = require(modelDir + '/' + name)(schema);// Include the mongoose file
global[name] = trinte.models... | javascript | function bootModel(trinte, schema, file) {
if (/\.js$/i.test(file)) {
var name = file.replace(/\.js$/i, '');
var modelDir = path.resolve(__dirname, '../app/models');
trinte.models[name] = require(modelDir + '/' + name)(schema);// Include the mongoose file
global[name] = trinte.models... | [
"function",
"bootModel",
"(",
"trinte",
",",
"schema",
",",
"file",
")",
"{",
"if",
"(",
"/",
"\\.js$",
"/",
"i",
".",
"test",
"(",
"file",
")",
")",
"{",
"var",
"name",
"=",
"file",
".",
"replace",
"(",
"/",
"\\.js$",
"/",
"i",
",",
"''",
")",... | simplistic model support
@param {TrinteJS} trinte - trinte app descriptor.
@param {Schema} schema
@param {String} file | [
"simplistic",
"model",
"support"
] | fdd723405418967ca8a690867940863fd77e636b | https://github.com/biggora/trinte-creator/blob/fdd723405418967ca8a690867940863fd77e636b/app/bin/trinte.js#L39-L46 | train |
mstrutt/node-match-media | main.js | convertUnit | function convertUnit (xUnit, mUnit, mVal) {
if (xUnit !== mUnit) {
if (mUnit === 'em') {
mVal = options.px_em_ratio * mVal;
}
if (xUnit === 'em') {
mVal = mVal/options.px_em_ratio;
}
}
return mVal;
} | javascript | function convertUnit (xUnit, mUnit, mVal) {
if (xUnit !== mUnit) {
if (mUnit === 'em') {
mVal = options.px_em_ratio * mVal;
}
if (xUnit === 'em') {
mVal = mVal/options.px_em_ratio;
}
}
return mVal;
} | [
"function",
"convertUnit",
"(",
"xUnit",
",",
"mUnit",
",",
"mVal",
")",
"{",
"if",
"(",
"xUnit",
"!==",
"mUnit",
")",
"{",
"if",
"(",
"mUnit",
"===",
"'em'",
")",
"{",
"mVal",
"=",
"options",
".",
"px_em_ratio",
"*",
"mVal",
";",
"}",
"if",
"(",
... | checking for unit match and converting if needed | [
"checking",
"for",
"unit",
"match",
"and",
"converting",
"if",
"needed"
] | 6c239bfb6f154a6ac030ed9446b8fac0faa7e66a | https://github.com/mstrutt/node-match-media/blob/6c239bfb6f154a6ac030ed9446b8fac0faa7e66a/main.js#L11-L22 | train |
tnantoka/LooseLeaf | lib/looseleaf.js | loadModules | function loadModules(dir, container, args) {
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
var file = files[i];
var filePath = path.join(dir, file);
if (fs.statSync(filePath).isDirectory()) {
container[file] = {};
loadModules(filePath, container[file], args);
... | javascript | function loadModules(dir, container, args) {
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
var file = files[i];
var filePath = path.join(dir, file);
if (fs.statSync(filePath).isDirectory()) {
container[file] = {};
loadModules(filePath, container[file], args);
... | [
"function",
"loadModules",
"(",
"dir",
",",
"container",
",",
"args",
")",
"{",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"... | Load and require js files to container obj from dir | [
"Load",
"and",
"require",
"js",
"files",
"to",
"container",
"obj",
"from",
"dir"
] | 0c6333977224d8f4ef7ad40415aa69e0ff76f7b5 | https://github.com/tnantoka/LooseLeaf/blob/0c6333977224d8f4ef7ad40415aa69e0ff76f7b5/lib/looseleaf.js#L92-L107 | train |
mathieudutour/nplint | lib/cli-engine.js | loadPlugins | function loadPlugins(pluginNames) {
if (pluginNames) {
pluginNames.forEach(function(pluginName) {
var pluginNamespace = util.getNamespace(pluginName),
pluginNameWithoutNamespace = util.removeNameSpace(pluginName),
pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace),... | javascript | function loadPlugins(pluginNames) {
if (pluginNames) {
pluginNames.forEach(function(pluginName) {
var pluginNamespace = util.getNamespace(pluginName),
pluginNameWithoutNamespace = util.removeNameSpace(pluginName),
pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace),... | [
"function",
"loadPlugins",
"(",
"pluginNames",
")",
"{",
"if",
"(",
"pluginNames",
")",
"{",
"pluginNames",
".",
"forEach",
"(",
"function",
"(",
"pluginName",
")",
"{",
"var",
"pluginNamespace",
"=",
"util",
".",
"getNamespace",
"(",
"pluginName",
")",
",",... | Load the given plugins if they are not loaded already.
@param {string[]} pluginNames An array of plugin names which should be loaded.
@returns {void} | [
"Load",
"the",
"given",
"plugins",
"if",
"they",
"are",
"not",
"loaded",
"already",
"."
] | ef444abcc6dd08fb61d5fc8ce618598d4455e08e | https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/cli-engine.js#L32-L52 | train |
mathieudutour/nplint | lib/cli-engine.js | CLIEngine | function CLIEngine(options) {
/**
* Stored options for this instance
* @type {Object}
*/
this.options = assign(Object.create(defaultOptions), options || {});
// load in additional rules
if (this.options.rulePaths) {
this.options.rulePaths.forEach(function(rulesdir) {
rules.load(rulesdir);
... | javascript | function CLIEngine(options) {
/**
* Stored options for this instance
* @type {Object}
*/
this.options = assign(Object.create(defaultOptions), options || {});
// load in additional rules
if (this.options.rulePaths) {
this.options.rulePaths.forEach(function(rulesdir) {
rules.load(rulesdir);
... | [
"function",
"CLIEngine",
"(",
"options",
")",
"{",
"/**\n * Stored options for this instance\n * @type {Object}\n */",
"this",
".",
"options",
"=",
"assign",
"(",
"Object",
".",
"create",
"(",
"defaultOptions",
")",
",",
"options",
"||",
"{",
"}",
")",
";",
... | Creates a new instance of the core CLI engine.
@param {CLIEngineOptions} options The options for this instance.
@constructor | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"core",
"CLI",
"engine",
"."
] | ef444abcc6dd08fb61d5fc8ce618598d4455e08e | https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/cli-engine.js#L120-L134 | train |
mathieudutour/nplint | lib/cli-engine.js | function(name, pluginobject) {
var pluginNameWithoutPrefix = util.removePluginPrefix(util.removeNameSpace(name));
if (pluginobject.rules) {
rules.import(pluginobject.rules, pluginNameWithoutPrefix);
}
loadedPlugins[pluginNameWithoutPrefix] = pluginobject;
} | javascript | function(name, pluginobject) {
var pluginNameWithoutPrefix = util.removePluginPrefix(util.removeNameSpace(name));
if (pluginobject.rules) {
rules.import(pluginobject.rules, pluginNameWithoutPrefix);
}
loadedPlugins[pluginNameWithoutPrefix] = pluginobject;
} | [
"function",
"(",
"name",
",",
"pluginobject",
")",
"{",
"var",
"pluginNameWithoutPrefix",
"=",
"util",
".",
"removePluginPrefix",
"(",
"util",
".",
"removeNameSpace",
"(",
"name",
")",
")",
";",
"if",
"(",
"pluginobject",
".",
"rules",
")",
"{",
"rules",
"... | Add a plugin by passing it's configuration
@param {string} name Name of the plugin.
@param {Object} pluginobject Plugin configuration object.
@returns {void} | [
"Add",
"a",
"plugin",
"by",
"passing",
"it",
"s",
"configuration"
] | ef444abcc6dd08fb61d5fc8ce618598d4455e08e | https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/cli-engine.js#L206-L212 | train | |
mathieudutour/nplint | lib/cli-engine.js | function(directory) {
if (!this.packageJSONFinder) {
this.packageJSONFinder = new FileFinder(PACKAGE_FILENAME);
}
return this.packageJSONFinder.findInDirectoryOrParentsSync(directory || process.cwd());
} | javascript | function(directory) {
if (!this.packageJSONFinder) {
this.packageJSONFinder = new FileFinder(PACKAGE_FILENAME);
}
return this.packageJSONFinder.findInDirectoryOrParentsSync(directory || process.cwd());
} | [
"function",
"(",
"directory",
")",
"{",
"if",
"(",
"!",
"this",
".",
"packageJSONFinder",
")",
"{",
"this",
".",
"packageJSONFinder",
"=",
"new",
"FileFinder",
"(",
"PACKAGE_FILENAME",
")",
";",
"}",
"return",
"this",
".",
"packageJSONFinder",
".",
"findInDi... | Find package.json from directory and parent directories.
@param {string} directory The directory to start searching from.
@returns {string[]} The paths of local config files found. | [
"Find",
"package",
".",
"json",
"from",
"directory",
"and",
"parent",
"directories",
"."
] | ef444abcc6dd08fb61d5fc8ce618598d4455e08e | https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/cli-engine.js#L245-L251 | train | |
layoutmanager/layoutmanager | build/define.js | function(moduleName, deps, callback) {
//if (moduleName === "jquery/selector") { debugger; }
if (!deps && !callback) {
return;
}
// Allow deps to be optional.
if (!callback && typeof deps === "function") {
callback = deps;
deps = undefined;
}
// Ensure dependencies is never falsey.
deps = ... | javascript | function(moduleName, deps, callback) {
//if (moduleName === "jquery/selector") { debugger; }
if (!deps && !callback) {
return;
}
// Allow deps to be optional.
if (!callback && typeof deps === "function") {
callback = deps;
deps = undefined;
}
// Ensure dependencies is never falsey.
deps = ... | [
"function",
"(",
"moduleName",
",",
"deps",
",",
"callback",
")",
"{",
"//if (moduleName === \"jquery/selector\") { debugger; }",
"if",
"(",
"!",
"deps",
"&&",
"!",
"callback",
")",
"{",
"return",
";",
"}",
"// Allow deps to be optional.",
"if",
"(",
"!",
"callbac... | Register modules first, but do not execute the callbacks until a matching `require` has been requested for this module. | [
"Register",
"modules",
"first",
"but",
"do",
"not",
"execute",
"the",
"callbacks",
"until",
"a",
"matching",
"require",
"has",
"been",
"requested",
"for",
"this",
"module",
"."
] | de01c901b570e3eb9f014bb43de7b363e5b22c99 | https://github.com/layoutmanager/layoutmanager/blob/de01c901b570e3eb9f014bb43de7b363e5b22c99/build/define.js#L6-L40 | train | |
Nazariglez/perenquen | lib/pixi/src/filters/shockwave/ShockwaveFilter.js | ShockwaveFilter | function ShockwaveFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/shockwave.frag', 'utf8'),
// custom uniforms
{
center: { type: 'v2', value: { x: 0.5, y: 0.5 } },
params: { type... | javascript | function ShockwaveFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/shockwave.frag', 'utf8'),
// custom uniforms
{
center: { type: 'v2', value: { x: 0.5, y: 0.5 } },
params: { type... | [
"function",
"ShockwaveFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"null",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/shockwave.frag'",
",",
"'utf8'",
")",
",",
"... | The ColorMatrixFilter class lets you apply a 4x4 matrix transformation on the RGBA
color and alpha values of every pixel on your displayObject to produce a result
with a new set of RGBA color and alpha values. It's pretty powerful!
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"The",
"ColorMatrixFilter",
"class",
"lets",
"you",
"apply",
"a",
"4x4",
"matrix",
"transformation",
"on",
"the",
"RGBA",
"color",
"and",
"alpha",
"values",
"of",
"every",
"pixel",
"on",
"your",
"displayObject",
"to",
"produce",
"a",
"result",
"with",
"a",
"... | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/shockwave/ShockwaveFilter.js#L14-L28 | train |
canuc/ajaxs | ajaxs/index.js | getExtensionlessFilename | function getExtensionlessFilename( filename ) {
return filename.substr( 0, filename.length - path.extname( filename ).length);
} | javascript | function getExtensionlessFilename( filename ) {
return filename.substr( 0, filename.length - path.extname( filename ).length);
} | [
"function",
"getExtensionlessFilename",
"(",
"filename",
")",
"{",
"return",
"filename",
".",
"substr",
"(",
"0",
",",
"filename",
".",
"length",
"-",
"path",
".",
"extname",
"(",
"filename",
")",
".",
"length",
")",
";",
"}"
] | Synchronously retrieve the fixed filename.
@param { string } filename The filename to remove the extension from | [
"Synchronously",
"retrieve",
"the",
"fixed",
"filename",
"."
] | 3bea19efbff83d903a9b34ccd60ade9473a95690 | https://github.com/canuc/ajaxs/blob/3bea19efbff83d903a9b34ccd60ade9473a95690/ajaxs/index.js#L27-L29 | train |
canuc/ajaxs | ajaxs/index.js | templateWithArgs | function templateWithArgs( apiDir, apiName, apiFuncName ) {
cacheAPIs[apiName] = {
reg: (RegularCacheClient
.replace(/%%api.root%%/g,apiDir)
.replace(/%%api.name%%/g,apiName)
.replace(/%%api.funcs%%/g,JSON.stringify(apiFuncName))),
service: (ServiceCacheClient
.replace(/%%api.root%%/g,apiDir)
.repl... | javascript | function templateWithArgs( apiDir, apiName, apiFuncName ) {
cacheAPIs[apiName] = {
reg: (RegularCacheClient
.replace(/%%api.root%%/g,apiDir)
.replace(/%%api.name%%/g,apiName)
.replace(/%%api.funcs%%/g,JSON.stringify(apiFuncName))),
service: (ServiceCacheClient
.replace(/%%api.root%%/g,apiDir)
.repl... | [
"function",
"templateWithArgs",
"(",
"apiDir",
",",
"apiName",
",",
"apiFuncName",
")",
"{",
"cacheAPIs",
"[",
"apiName",
"]",
"=",
"{",
"reg",
":",
"(",
"RegularCacheClient",
".",
"replace",
"(",
"/",
"%%api.root%%",
"/",
"g",
",",
"apiDir",
")",
".",
"... | Synchronously create a template | [
"Synchronously",
"create",
"a",
"template"
] | 3bea19efbff83d903a9b34ccd60ade9473a95690 | https://github.com/canuc/ajaxs/blob/3bea19efbff83d903a9b34ccd60ade9473a95690/ajaxs/index.js#L34-L46 | train |
canuc/ajaxs | ajaxs/index.js | copyArgumentsArray | function copyArgumentsArray(args) {
var copy = [];
var index = 0;
for (var i in args) {
copy[index] = args[i];
index++;
}
return copy;
} | javascript | function copyArgumentsArray(args) {
var copy = [];
var index = 0;
for (var i in args) {
copy[index] = args[i];
index++;
}
return copy;
} | [
"function",
"copyArgumentsArray",
"(",
"args",
")",
"{",
"var",
"copy",
"=",
"[",
"]",
";",
"var",
"index",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"in",
"args",
")",
"{",
"copy",
"[",
"index",
"]",
"=",
"args",
"[",
"i",
"]",
";",
"index",
"++"... | Synchronously copy an arguments object array.
@internal
@param { object } args the objects array | [
"Synchronously",
"copy",
"an",
"arguments",
"object",
"array",
"."
] | 3bea19efbff83d903a9b34ccd60ade9473a95690 | https://github.com/canuc/ajaxs/blob/3bea19efbff83d903a9b34ccd60ade9473a95690/ajaxs/index.js#L53-L61 | train |
canuc/ajaxs | ajaxs/index.js | readRawBody | function readRawBody(req,res,rawBodyCallback,callbackScope) {
if ( typeof req._body !== 'undefined' && req._body ) {
rawBodyCallback.call(callbackScope,req,res);
} else {
req.rawBody = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
req.rawBody += chunk;
});
req.on('end', ... | javascript | function readRawBody(req,res,rawBodyCallback,callbackScope) {
if ( typeof req._body !== 'undefined' && req._body ) {
rawBodyCallback.call(callbackScope,req,res);
} else {
req.rawBody = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
req.rawBody += chunk;
});
req.on('end', ... | [
"function",
"readRawBody",
"(",
"req",
",",
"res",
",",
"rawBodyCallback",
",",
"callbackScope",
")",
"{",
"if",
"(",
"typeof",
"req",
".",
"_body",
"!==",
"'undefined'",
"&&",
"req",
".",
"_body",
")",
"{",
"rawBodyCallback",
".",
"call",
"(",
"callbackSc... | Asynchronous call to read the raw body from the request that we have deemed,
as an API request.
NOTE: This function implements a workaround if the middleware is placed
after the body parser in the connect stack.
@internal
@param { object } req an expressjs http request object.
@param { object } res an expressjs http ... | [
"Asynchronous",
"call",
"to",
"read",
"the",
"raw",
"body",
"from",
"the",
"request",
"that",
"we",
"have",
"deemed",
"as",
"an",
"API",
"request",
"."
] | 3bea19efbff83d903a9b34ccd60ade9473a95690 | https://github.com/canuc/ajaxs/blob/3bea19efbff83d903a9b34ccd60ade9473a95690/ajaxs/index.js#L119-L136 | train |
redisjs/jsr-conf | lib/config-error.js | ConfigError | function ConfigError(lineno, line, file, err) {
this.name = ConfigError.name;
Error.call(this);
var fmt = '*** FATAL CONFIG FILE ERROR ***%s';
fmt += 'Reading the configuration file, at line %s%s';
fmt += '>>> %s%s';
fmt += err && err.message && !(err instanceof TypeDefError) ? err.message :
'Bad direc... | javascript | function ConfigError(lineno, line, file, err) {
this.name = ConfigError.name;
Error.call(this);
var fmt = '*** FATAL CONFIG FILE ERROR ***%s';
fmt += 'Reading the configuration file, at line %s%s';
fmt += '>>> %s%s';
fmt += err && err.message && !(err instanceof TypeDefError) ? err.message :
'Bad direc... | [
"function",
"ConfigError",
"(",
"lineno",
",",
"line",
",",
"file",
",",
"err",
")",
"{",
"this",
".",
"name",
"=",
"ConfigError",
".",
"name",
";",
"Error",
".",
"call",
"(",
"this",
")",
";",
"var",
"fmt",
"=",
"'*** FATAL CONFIG FILE ERROR ***%s'",
";... | Represents a configuration file error.
@param lineno The line number in the source file.
@param line The line that triggered the error.
@param file The configuration file being loaded.
@param err A source error containing more detail. | [
"Represents",
"a",
"configuration",
"file",
"error",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/config-error.js#L13-L26 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.