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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
SPANDigital/presidium-core | src/config.js | resolveConfig | function resolveConfig(conf, version = '') {
conf['siteroot'] = conf.baseurl || '/';
if (version) {
conf['baseurl'] = path.join(conf.siteroot, version);
}
for (let key in conf) {
if (CONFIG_VAR_REGEX.test(conf[key])) {
conf[key] = resolve(conf[key], conf, [key]);
}
}
return conf;
} | javascript | function resolveConfig(conf, version = '') {
conf['siteroot'] = conf.baseurl || '/';
if (version) {
conf['baseurl'] = path.join(conf.siteroot, version);
}
for (let key in conf) {
if (CONFIG_VAR_REGEX.test(conf[key])) {
conf[key] = resolve(conf[key], conf, [key]);
}
}
return conf;
} | [
"function",
"resolveConfig",
"(",
"conf",
",",
"version",
"=",
"''",
")",
"{",
"conf",
"[",
"'siteroot'",
"]",
"=",
"conf",
".",
"baseurl",
"||",
"'/'",
";",
"if",
"(",
"version",
")",
"{",
"conf",
"[",
"'baseurl'",
"]",
"=",
"path",
".",
"join",
"... | Helper function that resolves any variable depenencies in the config.
@param {String} version - The version number supplied.
@param {Object} conf - The parsed config file. | [
"Helper",
"function",
"that",
"resolves",
"any",
"variable",
"depenencies",
"in",
"the",
"config",
"."
] | 8d3034d97ef85f95391a14bd895898a0ab2e92ed | https://github.com/SPANDigital/presidium-core/blob/8d3034d97ef85f95391a14bd895898a0ab2e92ed/src/config.js#L79-L91 | train |
SPANDigital/presidium-core | src/config.js | resolve | function resolve(value, conf, ring = []) {
value.match(CONFIG_VAR_REGEX).forEach((variable) => {
const key = variable.substring(variable.lastIndexOf('${') + 2, variable.lastIndexOf('}'));
if (ring.includes(key)) {
throw `Circular dependency error: cannot resolve variable(s) ${ring}.`;
}
ring.push(key);
... | javascript | function resolve(value, conf, ring = []) {
value.match(CONFIG_VAR_REGEX).forEach((variable) => {
const key = variable.substring(variable.lastIndexOf('${') + 2, variable.lastIndexOf('}'));
if (ring.includes(key)) {
throw `Circular dependency error: cannot resolve variable(s) ${ring}.`;
}
ring.push(key);
... | [
"function",
"resolve",
"(",
"value",
",",
"conf",
",",
"ring",
"=",
"[",
"]",
")",
"{",
"value",
".",
"match",
"(",
"CONFIG_VAR_REGEX",
")",
".",
"forEach",
"(",
"(",
"variable",
")",
"=>",
"{",
"const",
"key",
"=",
"variable",
".",
"substring",
"(",... | Recursively resolve variable depedencies.
@param {String} value - String to resolve of dependencies.
@param {Dictionary} conf - The parsed config file.
@param {Array} ring - An array of previously seen keys. | [
"Recursively",
"resolve",
"variable",
"depedencies",
"."
] | 8d3034d97ef85f95391a14bd895898a0ab2e92ed | https://github.com/SPANDigital/presidium-core/blob/8d3034d97ef85f95391a14bd895898a0ab2e92ed/src/config.js#L99-L119 | train |
holidayextras/hxTracer | index.js | timeAndLog | function timeAndLog(text) {
if (active) {
var spaces = space.substring(0, currentIndentation);
console.error('TRACER TXT', meaningfulTime(), spaces, text);
}
} | javascript | function timeAndLog(text) {
if (active) {
var spaces = space.substring(0, currentIndentation);
console.error('TRACER TXT', meaningfulTime(), spaces, text);
}
} | [
"function",
"timeAndLog",
"(",
"text",
")",
"{",
"if",
"(",
"active",
")",
"{",
"var",
"spaces",
"=",
"space",
".",
"substring",
"(",
"0",
",",
"currentIndentation",
")",
";",
"console",
".",
"error",
"(",
"'TRACER TXT'",
",",
"meaningfulTime",
"(",
")",... | Grab a timestamp and add it to the tracers output | [
"Grab",
"a",
"timestamp",
"and",
"add",
"it",
"to",
"the",
"tracers",
"output"
] | cff4321e10d816239a025363dec73f093f52963f | https://github.com/holidayextras/hxTracer/blob/cff4321e10d816239a025363dec73f093f52963f/index.js#L58-L63 | train |
holidayextras/hxTracer | index.js | processModules | function processModules(item) {
if (item.exports && !item._traced) {
bootstrap(item, 'exports', item.filename);
item._traced = true;
}
if (item.children) {
item.children.map(processModules);
}
} | javascript | function processModules(item) {
if (item.exports && !item._traced) {
bootstrap(item, 'exports', item.filename);
item._traced = true;
}
if (item.children) {
item.children.map(processModules);
}
} | [
"function",
"processModules",
"(",
"item",
")",
"{",
"if",
"(",
"item",
".",
"exports",
"&&",
"!",
"item",
".",
"_traced",
")",
"{",
"bootstrap",
"(",
"item",
",",
"'exports'",
",",
"item",
".",
"filename",
")",
";",
"item",
".",
"_traced",
"=",
"tru... | This iterates over every module in the project and attempts to bootstrap each one in turn | [
"This",
"iterates",
"over",
"every",
"module",
"in",
"the",
"project",
"and",
"attempts",
"to",
"bootstrap",
"each",
"one",
"in",
"turn"
] | cff4321e10d816239a025363dec73f093f52963f | https://github.com/holidayextras/hxTracer/blob/cff4321e10d816239a025363dec73f093f52963f/index.js#L67-L75 | train |
holidayextras/hxTracer | index.js | bootstrap | function bootstrap(item, prop, path) {
if ( (path.split('node_modules').length > 2) || (path.slice(-4) == 'emit') || (item == require('util') && (prop=='format')) ) return;
if (!item.hasOwnProperty(prop) || Object.getOwnPropertyDescriptor(item, prop).get) return;
var original = item[prop];
if (allFuncs.indexOf(... | javascript | function bootstrap(item, prop, path) {
if ( (path.split('node_modules').length > 2) || (path.slice(-4) == 'emit') || (item == require('util') && (prop=='format')) ) return;
if (!item.hasOwnProperty(prop) || Object.getOwnPropertyDescriptor(item, prop).get) return;
var original = item[prop];
if (allFuncs.indexOf(... | [
"function",
"bootstrap",
"(",
"item",
",",
"prop",
",",
"path",
")",
"{",
"if",
"(",
"(",
"path",
".",
"split",
"(",
"'node_modules'",
")",
".",
"length",
">",
"2",
")",
"||",
"(",
"path",
".",
"slice",
"(",
"-",
"4",
")",
"==",
"'emit'",
")",
... | Bootstrap recursively iterates through an item, infecting every Function | [
"Bootstrap",
"recursively",
"iterates",
"through",
"an",
"item",
"infecting",
"every",
"Function"
] | cff4321e10d816239a025363dec73f093f52963f | https://github.com/holidayextras/hxTracer/blob/cff4321e10d816239a025363dec73f093f52963f/index.js#L79-L101 | train |
holidayextras/hxTracer | index.js | timeDiff | function timeDiff(newest, oldest) {
var diff = (parseFloat(newest) - parseFloat(oldest));
if (diff < 0) {
diff = ((10000 + parseFloat(newest)) - parseFloat(oldest));
}
return diff;
} | javascript | function timeDiff(newest, oldest) {
var diff = (parseFloat(newest) - parseFloat(oldest));
if (diff < 0) {
diff = ((10000 + parseFloat(newest)) - parseFloat(oldest));
}
return diff;
} | [
"function",
"timeDiff",
"(",
"newest",
",",
"oldest",
")",
"{",
"var",
"diff",
"=",
"(",
"parseFloat",
"(",
"newest",
")",
"-",
"parseFloat",
"(",
"oldest",
")",
")",
";",
"if",
"(",
"diff",
"<",
"0",
")",
"{",
"diff",
"=",
"(",
"(",
"10000",
"+"... | The timestamps we get are artificilly limited to 10 seconds. They might wrap around, so take that in to account | [
"The",
"timestamps",
"we",
"get",
"are",
"artificilly",
"limited",
"to",
"10",
"seconds",
".",
"They",
"might",
"wrap",
"around",
"so",
"take",
"that",
"in",
"to",
"account"
] | cff4321e10d816239a025363dec73f093f52963f | https://github.com/holidayextras/hxTracer/blob/cff4321e10d816239a025363dec73f093f52963f/index.js#L219-L225 | train |
holidayextras/hxTracer | index.js | meaningfulTime | function meaningfulTime() {
if (moduleRef) {
var parts = processRef.hrtime();
return (((parts[0]*1000)+(parts[1]/1000000))%10000).toFixed(2) + 'ms';
} else {
return performance.now().toFixed(2)+'ms';
}
} | javascript | function meaningfulTime() {
if (moduleRef) {
var parts = processRef.hrtime();
return (((parts[0]*1000)+(parts[1]/1000000))%10000).toFixed(2) + 'ms';
} else {
return performance.now().toFixed(2)+'ms';
}
} | [
"function",
"meaningfulTime",
"(",
")",
"{",
"if",
"(",
"moduleRef",
")",
"{",
"var",
"parts",
"=",
"processRef",
".",
"hrtime",
"(",
")",
";",
"return",
"(",
"(",
"(",
"parts",
"[",
"0",
"]",
"*",
"1000",
")",
"+",
"(",
"parts",
"[",
"1",
"]",
... | Get a sub-millisecond timing thats actually readable | [
"Get",
"a",
"sub",
"-",
"millisecond",
"timing",
"thats",
"actually",
"readable"
] | cff4321e10d816239a025363dec73f093f52963f | https://github.com/holidayextras/hxTracer/blob/cff4321e10d816239a025363dec73f093f52963f/index.js#L228-L235 | train |
holidayextras/hxTracer | index.js | measureTracerOverhead | function measureTracerOverhead() {
var time1 = meaningfulTime();
var time2 = meaningfulTime();
console.error("TRACER OVERHEAD", timeDiff(time2, time1).toFixed(2)+'ms', 'per timing');
} | javascript | function measureTracerOverhead() {
var time1 = meaningfulTime();
var time2 = meaningfulTime();
console.error("TRACER OVERHEAD", timeDiff(time2, time1).toFixed(2)+'ms', 'per timing');
} | [
"function",
"measureTracerOverhead",
"(",
")",
"{",
"var",
"time1",
"=",
"meaningfulTime",
"(",
")",
";",
"var",
"time2",
"=",
"meaningfulTime",
"(",
")",
";",
"console",
".",
"error",
"(",
"\"TRACER OVERHEAD\"",
",",
"timeDiff",
"(",
"time2",
",",
"time1",
... | How much time does it take to measure time? | [
"How",
"much",
"time",
"does",
"it",
"take",
"to",
"measure",
"time?"
] | cff4321e10d816239a025363dec73f093f52963f | https://github.com/holidayextras/hxTracer/blob/cff4321e10d816239a025363dec73f093f52963f/index.js#L238-L242 | train |
holidayextras/hxTracer | index.js | processLogs | function processLogs() {
var calcs = 0;
for (var i in stats) {
stats[i].average = stats[i].totalTime / stats[i].count;
calcs += stats[i].calcs;
}
var time1 = meaningfulTime();
var time2 = meaningfulTime();
console.error("TRACER TOTAL OVERHEAD", (calcs*timeDiff(time2, time1)).toFixed(2)+'ms');
whi... | javascript | function processLogs() {
var calcs = 0;
for (var i in stats) {
stats[i].average = stats[i].totalTime / stats[i].count;
calcs += stats[i].calcs;
}
var time1 = meaningfulTime();
var time2 = meaningfulTime();
console.error("TRACER TOTAL OVERHEAD", (calcs*timeDiff(time2, time1)).toFixed(2)+'ms');
whi... | [
"function",
"processLogs",
"(",
")",
"{",
"var",
"calcs",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"in",
"stats",
")",
"{",
"stats",
"[",
"i",
"]",
".",
"average",
"=",
"stats",
"[",
"i",
"]",
".",
"totalTime",
"/",
"stats",
"[",
"i",
"]",
".",
... | Process our logs after tracing to work out how much time is spent where | [
"Process",
"our",
"logs",
"after",
"tracing",
"to",
"work",
"out",
"how",
"much",
"time",
"is",
"spent",
"where"
] | cff4321e10d816239a025363dec73f093f52963f | https://github.com/holidayextras/hxTracer/blob/cff4321e10d816239a025363dec73f093f52963f/index.js#L245-L272 | train |
Enplug/dashboard-sdk | dist/sdk.js | debug | function debug(message) {
if (enplug.debug) {
arguments[0] = TAG + arguments[0];
console.log.apply(console, arguments);
}
} | javascript | function debug(message) {
if (enplug.debug) {
arguments[0] = TAG + arguments[0];
console.log.apply(console, arguments);
}
} | [
"function",
"debug",
"(",
"message",
")",
"{",
"if",
"(",
"enplug",
".",
"debug",
")",
"{",
"arguments",
"[",
"0",
"]",
"=",
"TAG",
"+",
"arguments",
"[",
"0",
"]",
";",
"console",
".",
"log",
".",
"apply",
"(",
"console",
",",
"arguments",
")",
... | Logs messages to console when enplug.debug is enabled. Adds tag to messages.
@param message | [
"Logs",
"messages",
"to",
"console",
"when",
"enplug",
".",
"debug",
"is",
"enabled",
".",
"Adds",
"tag",
"to",
"messages",
"."
] | f5f5c69437e56072032effad6daa4088314b66b4 | https://github.com/Enplug/dashboard-sdk/blob/f5f5c69437e56072032effad6daa4088314b66b4/dist/sdk.js#L71-L76 | train |
Enplug/dashboard-sdk | dist/sdk.js | validateCallbacks | function validateCallbacks(options) {
if (options.successCallback && typeof options.successCallback !== 'function') {
throw new Error(TAG + 'Success callback must be a function.');
} else {
options.successCallback = options.successCallback || enplug.noop;
... | javascript | function validateCallbacks(options) {
if (options.successCallback && typeof options.successCallback !== 'function') {
throw new Error(TAG + 'Success callback must be a function.');
} else {
options.successCallback = options.successCallback || enplug.noop;
... | [
"function",
"validateCallbacks",
"(",
"options",
")",
"{",
"if",
"(",
"options",
".",
"successCallback",
"&&",
"typeof",
"options",
".",
"successCallback",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"Error",
"(",
"TAG",
"+",
"'Success callback must be a functi... | Validate and assign defaults for callback methods.
@param {MethodCall} options | [
"Validate",
"and",
"assign",
"defaults",
"for",
"callback",
"methods",
"."
] | f5f5c69437e56072032effad6daa4088314b66b4 | https://github.com/Enplug/dashboard-sdk/blob/f5f5c69437e56072032effad6daa4088314b66b4/dist/sdk.js#L82-L94 | train |
Enplug/dashboard-sdk | dist/sdk.js | parseResponse | function parseResponse(event) {
try {
var response = JSON.parse(event.data);
// Check for success key to ignore messages being sent
if (response.namespace === namespace && typeof response.success === 'boolean') {
return response;
... | javascript | function parseResponse(event) {
try {
var response = JSON.parse(event.data);
// Check for success key to ignore messages being sent
if (response.namespace === namespace && typeof response.success === 'boolean') {
return response;
... | [
"function",
"parseResponse",
"(",
"event",
")",
"{",
"try",
"{",
"var",
"response",
"=",
"JSON",
".",
"parse",
"(",
"event",
".",
"data",
")",
";",
"// Check for success key to ignore messages being sent",
"if",
"(",
"response",
".",
"namespace",
"===",
"namespa... | Verifies that a message is intended for the transport.
@param {MessageEvent} event
@returns {boolean} - Whether the message was successfully parsed. | [
"Verifies",
"that",
"a",
"message",
"is",
"intended",
"for",
"the",
"transport",
"."
] | f5f5c69437e56072032effad6daa4088314b66b4 | https://github.com/Enplug/dashboard-sdk/blob/f5f5c69437e56072032effad6daa4088314b66b4/dist/sdk.js#L101-L114 | train |
Enplug/dashboard-sdk | dist/sdk.js | function (options) {
if (typeof options === 'object') {
// Add implementation-specific method prefix (dashboard or app)
options.name = this.prefix + '.' + options.name;
return this.transport.send(options);
} else {
throw new Erro... | javascript | function (options) {
if (typeof options === 'object') {
// Add implementation-specific method prefix (dashboard or app)
options.name = this.prefix + '.' + options.name;
return this.transport.send(options);
} else {
throw new Erro... | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'object'",
")",
"{",
"// Add implementation-specific method prefix (dashboard or app)",
"options",
".",
"name",
"=",
"this",
".",
"prefix",
"+",
"'.'",
"+",
"options",
".",
"name",
";"... | Factory for all SDK method calls.
@param {MethodCall|*} options
@returns {number} callId | [
"Factory",
"for",
"all",
"SDK",
"method",
"calls",
"."
] | f5f5c69437e56072032effad6daa4088314b66b4 | https://github.com/Enplug/dashboard-sdk/blob/f5f5c69437e56072032effad6daa4088314b66b4/dist/sdk.js#L263-L273 | train | |
Enplug/dashboard-sdk | dist/sdk.js | decorateSend | function decorateSend(q, scope, transport) {
var original = transport.send;
transport.send = function (options) {
// Store originals
var defer = q.defer(),
onSuccess = options.successCallback || angular.noop,
onError = options.errorCallback || ang... | javascript | function decorateSend(q, scope, transport) {
var original = transport.send;
transport.send = function (options) {
// Store originals
var defer = q.defer(),
onSuccess = options.successCallback || angular.noop,
onError = options.errorCallback || ang... | [
"function",
"decorateSend",
"(",
"q",
",",
"scope",
",",
"transport",
")",
"{",
"var",
"original",
"=",
"transport",
".",
"send",
";",
"transport",
".",
"send",
"=",
"function",
"(",
"options",
")",
"{",
"// Store originals",
"var",
"defer",
"=",
"q",
".... | Modifies transport.send to return promises.
@param {Object} q
@param {Object} scope
@param {Object} transport | [
"Modifies",
"transport",
".",
"send",
"to",
"return",
"promises",
"."
] | f5f5c69437e56072032effad6daa4088314b66b4 | https://github.com/Enplug/dashboard-sdk/blob/f5f5c69437e56072032effad6daa4088314b66b4/dist/sdk.js#L1558-L1586 | train |
evannetwork/dbcp | scripts/deploy.js | function (hash) {
return new Promise((resolve, reject) => {
request(`${ ipfsProtocol }://${ ipfsHost }/ipfs/${hash}`, function (err, response, body) {
if (err) {
reject(err);
} else {
resolve(response);
}
});
});
} | javascript | function (hash) {
return new Promise((resolve, reject) => {
request(`${ ipfsProtocol }://${ ipfsHost }/ipfs/${hash}`, function (err, response, body) {
if (err) {
reject(err);
} else {
resolve(response);
}
});
});
} | [
"function",
"(",
"hash",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
"(",
"`",
"${",
"ipfsProtocol",
"}",
"${",
"ipfsHost",
"}",
"${",
"hash",
"}",
"`",
",",
"function",
"(",
"err",
",",
"res... | Loads an ipfs hash to be sure, that its added and pinned.
@param {string} hash ipfs hash to load | [
"Loads",
"an",
"ipfs",
"hash",
"to",
"be",
"sure",
"that",
"its",
"added",
"and",
"pinned",
"."
] | c1f29577e0cc829a1259d683914673da7d54b58c | https://github.com/evannetwork/dbcp/blob/c1f29577e0cc829a1259d683914673da7d54b58c/scripts/deploy.js#L172-L182 | train | |
evannetwork/dbcp | scripts/deploy.js | deleteDeploymentFolder | async function deleteDeploymentFolder() {
del.sync(deploymentTmpFolder, { force: true });
del.sync(deploymentFolder, { force: true });
} | javascript | async function deleteDeploymentFolder() {
del.sync(deploymentTmpFolder, { force: true });
del.sync(deploymentFolder, { force: true });
} | [
"async",
"function",
"deleteDeploymentFolder",
"(",
")",
"{",
"del",
".",
"sync",
"(",
"deploymentTmpFolder",
",",
"{",
"force",
":",
"true",
"}",
")",
";",
"del",
".",
"sync",
"(",
"deploymentFolder",
",",
"{",
"force",
":",
"true",
"}",
")",
";",
"}"... | Delete the deployment folder when everything is ready. | [
"Delete",
"the",
"deployment",
"folder",
"when",
"everything",
"is",
"ready",
"."
] | c1f29577e0cc829a1259d683914673da7d54b58c | https://github.com/evannetwork/dbcp/blob/c1f29577e0cc829a1259d683914673da7d54b58c/scripts/deploy.js#L253-L256 | train |
evannetwork/dbcp | scripts/deploy.js | deploy | async function deploy() {
try {
await browserifyDBCP();
await uglify();
const ipfsHash = await deployToIPFS(`${ deploymentFolder}/${ browserifyName}`);
await pinToIPFS(ipfsHash);
const ipnsHash = await deployToIpns(ipfsHash);
deleteDeploymentFolder();
console.log(`\nFinished deployment`);... | javascript | async function deploy() {
try {
await browserifyDBCP();
await uglify();
const ipfsHash = await deployToIPFS(`${ deploymentFolder}/${ browserifyName}`);
await pinToIPFS(ipfsHash);
const ipnsHash = await deployToIpns(ipfsHash);
deleteDeploymentFolder();
console.log(`\nFinished deployment`);... | [
"async",
"function",
"deploy",
"(",
")",
"{",
"try",
"{",
"await",
"browserifyDBCP",
"(",
")",
";",
"await",
"uglify",
"(",
")",
";",
"const",
"ipfsHash",
"=",
"await",
"deployToIPFS",
"(",
"`",
"${",
"deploymentFolder",
"}",
"${",
"browserifyName",
"}",
... | Build the js files into one file using browserify, deploys the file to ipfs and binds the new hash to ipns | [
"Build",
"the",
"js",
"files",
"into",
"one",
"file",
"using",
"browserify",
"deploys",
"the",
"file",
"to",
"ipfs",
"and",
"binds",
"the",
"new",
"hash",
"to",
"ipns"
] | c1f29577e0cc829a1259d683914673da7d54b58c | https://github.com/evannetwork/dbcp/blob/c1f29577e0cc829a1259d683914673da7d54b58c/scripts/deploy.js#L261-L276 | train |
nickschot/ember-mobile-core | addon/utils/parse-touch-data.js | getPointDistance | function getPointDistance(x0, x1, y0, y1) {
return (Math.sqrt(((x1 - x0) * (x1 - x0)) + ((y1 - y0) * (y1 - y0))));
} | javascript | function getPointDistance(x0, x1, y0, y1) {
return (Math.sqrt(((x1 - x0) * (x1 - x0)) + ((y1 - y0) * (y1 - y0))));
} | [
"function",
"getPointDistance",
"(",
"x0",
",",
"x1",
",",
"y0",
",",
"y1",
")",
"{",
"return",
"(",
"Math",
".",
"sqrt",
"(",
"(",
"(",
"x1",
"-",
"x0",
")",
"*",
"(",
"x1",
"-",
"x0",
")",
")",
"+",
"(",
"(",
"y1",
"-",
"y0",
")",
"*",
... | Calculates the distance between two points
@function getPointDistance
@param {number} x0 X coordinate of the origin
@param {number} x1 X coordinate of the current position
@param {number} y0 Y coordinate of the origin
@param {number} y1 Y coordinate of the current position
@return {number} Distance between the two poi... | [
"Calculates",
"the",
"distance",
"between",
"two",
"points"
] | b9baebf8c62cdc38e3ee5dd6063c46c95cfcbc92 | https://github.com/nickschot/ember-mobile-core/blob/b9baebf8c62cdc38e3ee5dd6063c46c95cfcbc92/addon/utils/parse-touch-data.js#L155-L157 | train |
nickschot/ember-mobile-core | addon/utils/parse-touch-data.js | getAngle | function getAngle(originX, originY, projectionX, projectionY) {
const angle = Math.atan2(projectionY - originY, projectionX - originX) * ((180) / Math.PI);
return 360 - ((angle < 0) ? (360 + angle) : angle);
} | javascript | function getAngle(originX, originY, projectionX, projectionY) {
const angle = Math.atan2(projectionY - originY, projectionX - originX) * ((180) / Math.PI);
return 360 - ((angle < 0) ? (360 + angle) : angle);
} | [
"function",
"getAngle",
"(",
"originX",
",",
"originY",
",",
"projectionX",
",",
"projectionY",
")",
"{",
"const",
"angle",
"=",
"Math",
".",
"atan2",
"(",
"projectionY",
"-",
"originY",
",",
"projectionX",
"-",
"originX",
")",
"*",
"(",
"(",
"180",
")",... | Calculates the angle between two points.
@function getAngle
@param {number} originX
@param {number} originY
@param {number} projectionX
@param {number} projectionY
@return {number} Angle between the two points
@private | [
"Calculates",
"the",
"angle",
"between",
"two",
"points",
"."
] | b9baebf8c62cdc38e3ee5dd6063c46c95cfcbc92 | https://github.com/nickschot/ember-mobile-core/blob/b9baebf8c62cdc38e3ee5dd6063c46c95cfcbc92/addon/utils/parse-touch-data.js#L170-L173 | train |
nyteshade/graphql-lattice | dist/decorators/ModelProperties.js | add | function add(className) {
if (typeof className === 'function') {
className = className.name;
}
extractBits.DIRECT_TYPES.push(className);
} | javascript | function add(className) {
if (typeof className === 'function') {
className = className.name;
}
extractBits.DIRECT_TYPES.push(className);
} | [
"function",
"add",
"(",
"className",
")",
"{",
"if",
"(",
"typeof",
"className",
"===",
"'function'",
")",
"{",
"className",
"=",
"className",
".",
"name",
";",
"}",
"extractBits",
".",
"DIRECT_TYPES",
".",
"push",
"(",
"className",
")",
";",
"}"
] | Appends the supplied class name to the list of registered direct types. If
a class or function is passed, rather than a String,
@method DirectTypeManager#types
@param {Function|string|RegExp} className the name of the class to append.
Typically it is best to pass the name property of the class in question
such as `Re... | [
"Appends",
"the",
"supplied",
"class",
"name",
"to",
"the",
"list",
"of",
"registered",
"direct",
"types",
".",
"If",
"a",
"class",
"or",
"function",
"is",
"passed",
"rather",
"than",
"a",
"String"
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/decorators/ModelProperties.js#L254-L260 | train |
nyteshade/graphql-lattice | dist/decorators/ModelProperties.js | applyTags | function applyTags(Class, addTags, fieldName, descriptor) {
var tags = (Array.isArray(addTags) && addTags || []).map(function (tag) {
return typeof tag === 'string' && Symbol.for(tag) || tag;
}).filter(function (tag) {
return (0, _typeof2.default)(tag) === 'symbol';
});
tags.forEach(function (tag) {
... | javascript | function applyTags(Class, addTags, fieldName, descriptor) {
var tags = (Array.isArray(addTags) && addTags || []).map(function (tag) {
return typeof tag === 'string' && Symbol.for(tag) || tag;
}).filter(function (tag) {
return (0, _typeof2.default)(tag) === 'symbol';
});
tags.forEach(function (tag) {
... | [
"function",
"applyTags",
"(",
"Class",
",",
"addTags",
",",
"fieldName",
",",
"descriptor",
")",
"{",
"var",
"tags",
"=",
"(",
"Array",
".",
"isArray",
"(",
"addTags",
")",
"&&",
"addTags",
"||",
"[",
"]",
")",
".",
"map",
"(",
"function",
"(",
"tag"... | When applying multiple property getters and setters, knowing some info
about what was applied elsewhere can be important. "Tags" can be applied
that store the fieldName and descriptor applied via one of these decorators.
Multiple "tags" are supported to allow for detecting the difference between
decorators applied by ... | [
"When",
"applying",
"multiple",
"property",
"getters",
"and",
"setters",
"knowing",
"some",
"info",
"about",
"what",
"was",
"applied",
"elsewhere",
"can",
"be",
"important",
".",
"Tags",
"can",
"be",
"applied",
"that",
"store",
"the",
"fieldName",
"and",
"desc... | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/decorators/ModelProperties.js#L323-L333 | train |
SimpliField/oh-csv | src/index.js | csvWrapForExcel | function csvWrapForExcel(encoder) {
// Pipe the CSV encoder to the ucs2 converter
var converter = new Stream.Transform();
var csvStream = new Stream.PassThrough();
converter._transform = function(chunk, encoding, cb) {
this.push(new Buffer(chunk.toString(), 'ucs2'));
cb();
};
// Write the UCS2 BOM h... | javascript | function csvWrapForExcel(encoder) {
// Pipe the CSV encoder to the ucs2 converter
var converter = new Stream.Transform();
var csvStream = new Stream.PassThrough();
converter._transform = function(chunk, encoding, cb) {
this.push(new Buffer(chunk.toString(), 'ucs2'));
cb();
};
// Write the UCS2 BOM h... | [
"function",
"csvWrapForExcel",
"(",
"encoder",
")",
"{",
"// Pipe the CSV encoder to the ucs2 converter",
"var",
"converter",
"=",
"new",
"Stream",
".",
"Transform",
"(",
")",
";",
"var",
"csvStream",
"=",
"new",
"Stream",
".",
"PassThrough",
"(",
")",
";",
"con... | X-Platform Excel encoder | [
"X",
"-",
"Platform",
"Excel",
"encoder"
] | c6c921783fb257cbc4d4e806210b1eccaf1d0f74 | https://github.com/SimpliField/oh-csv/blob/c6c921783fb257cbc4d4e806210b1eccaf1d0f74/src/index.js#L465-L476 | train |
mjeanroy/karma-json-preprocessor | src/karma-json-preprocessor.js | createJsonPreprocessor | function createJsonPreprocessor(logger, basePath, config) {
const log = logger.create('preprocessor.json');
const conf = config || {};
const stripPrefix = new RegExp(`^${(conf.stripPrefix || '')}`);
return function(content, file, done) {
log.debug('Processing "%s".', file.originalPath);
// Build json ... | javascript | function createJsonPreprocessor(logger, basePath, config) {
const log = logger.create('preprocessor.json');
const conf = config || {};
const stripPrefix = new RegExp(`^${(conf.stripPrefix || '')}`);
return function(content, file, done) {
log.debug('Processing "%s".', file.originalPath);
// Build json ... | [
"function",
"createJsonPreprocessor",
"(",
"logger",
",",
"basePath",
",",
"config",
")",
"{",
"const",
"log",
"=",
"logger",
".",
"create",
"(",
"'preprocessor.json'",
")",
";",
"const",
"conf",
"=",
"config",
"||",
"{",
"}",
";",
"const",
"stripPrefix",
... | Create the JSON preprocessor.
@param {Object} logger Karma logger.
@param {string} basePath The base path initialized by karma.
@param {Object} config The configuration object.
@return {function} The preprocessor function. | [
"Create",
"the",
"JSON",
"preprocessor",
"."
] | 732be0355edfb40b4116a3fd0ed41ca3c218cf73 | https://github.com/mjeanroy/karma-json-preprocessor/blob/732be0355edfb40b4116a3fd0ed41ca3c218cf73/src/karma-json-preprocessor.js#L59-L85 | train |
rocjs/extensions | packages/roc-package-webpack-dev/src/webpack/utils/rocExportWebpackPlugin.js | createGetAlias | function createGetAlias(aliases) {
if (isPlainObject(aliases) && !Array.isArray(aliases)) {
aliases = Object.keys(aliases).map((key) => { // eslint-disable-line
let onlyModule = false;
let obj = aliases[key];
if (/\$$/.test(key)) {
onlyModule = true;
... | javascript | function createGetAlias(aliases) {
if (isPlainObject(aliases) && !Array.isArray(aliases)) {
aliases = Object.keys(aliases).map((key) => { // eslint-disable-line
let onlyModule = false;
let obj = aliases[key];
if (/\$$/.test(key)) {
onlyModule = true;
... | [
"function",
"createGetAlias",
"(",
"aliases",
")",
"{",
"if",
"(",
"isPlainObject",
"(",
"aliases",
")",
"&&",
"!",
"Array",
".",
"isArray",
"(",
"aliases",
")",
")",
"{",
"aliases",
"=",
"Object",
".",
"keys",
"(",
"aliases",
")",
".",
"map",
"(",
"... | Based on code from enhanced-resolve | [
"Based",
"on",
"code",
"from",
"enhanced",
"-",
"resolve"
] | e9c364768c4edd30b789b94c51d20778d903d063 | https://github.com/rocjs/extensions/blob/e9c364768c4edd30b789b94c51d20778d903d063/packages/roc-package-webpack-dev/src/webpack/utils/rocExportWebpackPlugin.js#L91-L123 | train |
nyteshade/graphql-lattice | dist/LatticeFactory.js | setChecklist | function setChecklist(Class, item) {
var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var checklist = getChecklist(Class);
if (checklist) {
// $FlowFixMe
checklist[item] = value;
}
} | javascript | function setChecklist(Class, item) {
var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var checklist = getChecklist(Class);
if (checklist) {
// $FlowFixMe
checklist[item] = value;
}
} | [
"function",
"setChecklist",
"(",
"Class",
",",
"item",
")",
"{",
"var",
"value",
"=",
"arguments",
".",
"length",
">",
"2",
"&&",
"arguments",
"[",
"2",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"2",
"]",
":",
"true",
";",
"var",
"checklist",
"... | Obtains the checklist from the supplied GQLBase extended class. If the
class has a checklist, its checklist item is set to true or the boolean
value specified.
@param {Function} Class a reference to the GQLBase class to set
@param {Symbol} item one of CHECK_SCHEMA, CHECK_RESOLVERS, or
CHECK_API_DOCS
@param {Boolean} v... | [
"Obtains",
"the",
"checklist",
"from",
"the",
"supplied",
"GQLBase",
"extended",
"class",
".",
"If",
"the",
"class",
"has",
"a",
"checklist",
"its",
"checklist",
"item",
"is",
"set",
"to",
"true",
"or",
"the",
"boolean",
"value",
"specified",
"."
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/LatticeFactory.js#L280-L288 | train |
nyteshade/graphql-lattice | dist/LatticeFactory.js | hasChecklist | function hasChecklist(Class) {
var checklist = getChecklist(Class);
for (var _len2 = arguments.length, items = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
items[_key2 - 1] = arguments[_key2];
}
if (checklist && items.length) {
for (var _i2 = 0; _i2 < items.length; _i2++)... | javascript | function hasChecklist(Class) {
var checklist = getChecklist(Class);
for (var _len2 = arguments.length, items = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
items[_key2 - 1] = arguments[_key2];
}
if (checklist && items.length) {
for (var _i2 = 0; _i2 < items.length; _i2++)... | [
"function",
"hasChecklist",
"(",
"Class",
")",
"{",
"var",
"checklist",
"=",
"getChecklist",
"(",
"Class",
")",
";",
"for",
"(",
"var",
"_len2",
"=",
"arguments",
".",
"length",
",",
"items",
"=",
"new",
"Array",
"(",
"_len2",
">",
"1",
"?",
"_len2",
... | This function, when invoked with only a class will return true if the
Class has a defined checklist. If one ore more CHECKLIST symbols are
passed, the function will only return true if all the supplied symbols
are set to truthy values.
@param {Function} Class a reference to the GQLBase class to set
@param {Array<Symbo... | [
"This",
"function",
"when",
"invoked",
"with",
"only",
"a",
"class",
"will",
"return",
"true",
"if",
"the",
"Class",
"has",
"a",
"defined",
"checklist",
".",
"If",
"one",
"ore",
"more",
"CHECKLIST",
"symbols",
"are",
"passed",
"the",
"function",
"will",
"o... | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/LatticeFactory.js#L303-L323 | train |
nyteshade/graphql-lattice | dist/LatticeFactory.js | newChecklist | function newChecklist(Class) {
if (Class) {
var _keys, _complete, _Class$META_KEY$CHECK, _mutatorMap;
// $FlowFixMe
Class[_GQLBase.META_KEY][CHECKLIST] = (_Class$META_KEY$CHECK = {}, (0, _defineProperty2.default)(_Class$META_KEY$CHECK, CHECK_SCHEMA, false), (0, _defineProperty2.default)(_Class$META_KEY$C... | javascript | function newChecklist(Class) {
if (Class) {
var _keys, _complete, _Class$META_KEY$CHECK, _mutatorMap;
// $FlowFixMe
Class[_GQLBase.META_KEY][CHECKLIST] = (_Class$META_KEY$CHECK = {}, (0, _defineProperty2.default)(_Class$META_KEY$CHECK, CHECK_SCHEMA, false), (0, _defineProperty2.default)(_Class$META_KEY$C... | [
"function",
"newChecklist",
"(",
"Class",
")",
"{",
"if",
"(",
"Class",
")",
"{",
"var",
"_keys",
",",
"_complete",
",",
"_Class$META_KEY$CHECK",
",",
"_mutatorMap",
";",
"// $FlowFixMe",
"Class",
"[",
"_GQLBase",
".",
"META_KEY",
"]",
"[",
"CHECKLIST",
"]",... | Injects and creates a new CHECKLIST object on the supplied GQLBase
extended class. All items are installed and set to false.
@param {Function} Class a reference to the GQLBase class to set | [
"Injects",
"and",
"creates",
"a",
"new",
"CHECKLIST",
"object",
"on",
"the",
"supplied",
"GQLBase",
"extended",
"class",
".",
"All",
"items",
"are",
"installed",
"and",
"set",
"to",
"false",
"."
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/LatticeFactory.js#L332-L353 | train |
nyteshade/graphql-lattice | dist/LatticeFactory.js | validateTemplate | function validateTemplate(template) {
var hide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var results = new ValidationResults();
var indent = function indent(string) {
var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
... | javascript | function validateTemplate(template) {
var hide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var results = new ValidationResults();
var indent = function indent(string) {
var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
... | [
"function",
"validateTemplate",
"(",
"template",
")",
"{",
"var",
"hide",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"false",
";",
"var",
"results",
"=",
"new",... | Walks through a supplied template object and collects errors with its
format before bubbling up an exception if any part of it fails to
pass muster. The exception can be prevented from throwing if hide is set
to true
@param {Object} template an object to be parsed for construction via the
Lattice Factory
@param {boole... | [
"Walks",
"through",
"a",
"supplied",
"template",
"object",
"and",
"collects",
"errors",
"with",
"its",
"format",
"before",
"bubbling",
"up",
"an",
"exception",
"if",
"any",
"part",
"of",
"it",
"fails",
"to",
"pass",
"muster",
".",
"The",
"exception",
"can",
... | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/LatticeFactory.js#L409-L518 | train |
fourplusone/etherpad-plugins | ep_headings/static/js/index.js | function(hook, context){
var hs = $('#heading-selection');
hs.on('change', function(){
var value = $(this).val();
var intValue = parseInt(value,10);
if(!_.isNaN(intValue)){
context.ace.callWithAce(function(ace){
ace.ace_doInsertHeading(intValue);
},'insertheading' , true);
hs.v... | javascript | function(hook, context){
var hs = $('#heading-selection');
hs.on('change', function(){
var value = $(this).val();
var intValue = parseInt(value,10);
if(!_.isNaN(intValue)){
context.ace.callWithAce(function(ace){
ace.ace_doInsertHeading(intValue);
},'insertheading' , true);
hs.v... | [
"function",
"(",
"hook",
",",
"context",
")",
"{",
"var",
"hs",
"=",
"$",
"(",
"'#heading-selection'",
")",
";",
"hs",
".",
"on",
"(",
"'change'",
",",
"function",
"(",
")",
"{",
"var",
"value",
"=",
"$",
"(",
"this",
")",
".",
"val",
"(",
")",
... | Bind the event handler to the toolbar buttons | [
"Bind",
"the",
"event",
"handler",
"to",
"the",
"toolbar",
"buttons"
] | f6561a2b2323f8df2d3ef79154527f1ec5adfa56 | https://github.com/fourplusone/etherpad-plugins/blob/f6561a2b2323f8df2d3ef79154527f1ec5adfa56/ep_headings/static/js/index.js#L15-L27 | train | |
fourplusone/etherpad-plugins | ep_headings/static/js/index.js | aceInitialized | function aceInitialized(hook, context){
var editorInfo = context.editorInfo;
editorInfo.ace_doInsertHeading = _(doInsertHeading).bind(context);
} | javascript | function aceInitialized(hook, context){
var editorInfo = context.editorInfo;
editorInfo.ace_doInsertHeading = _(doInsertHeading).bind(context);
} | [
"function",
"aceInitialized",
"(",
"hook",
",",
"context",
")",
"{",
"var",
"editorInfo",
"=",
"context",
".",
"editorInfo",
";",
"editorInfo",
".",
"ace_doInsertHeading",
"=",
"_",
"(",
"doInsertHeading",
")",
".",
"bind",
"(",
"context",
")",
";",
"}"
] | Once ace is initialized, we set ace_doInsertHeading and bind it to the context | [
"Once",
"ace",
"is",
"initialized",
"we",
"set",
"ace_doInsertHeading",
"and",
"bind",
"it",
"to",
"the",
"context"
] | f6561a2b2323f8df2d3ef79154527f1ec5adfa56 | https://github.com/fourplusone/etherpad-plugins/blob/f6561a2b2323f8df2d3ef79154527f1ec5adfa56/ep_headings/static/js/index.js#L86-L89 | train |
nyteshade/graphql-lattice | dist/utils.js | argMapper | function argMapper(arg, index, array) {
var isError = (0, _neTypes.typeOf)(arg) === Error.name;
var showStack = /\bSTACK\b/i.test(process.env.LATTICE_ERRORS || ''); // $FlowFixMe
return !isError ? arg : showStack ? arg : arg.message;
} | javascript | function argMapper(arg, index, array) {
var isError = (0, _neTypes.typeOf)(arg) === Error.name;
var showStack = /\bSTACK\b/i.test(process.env.LATTICE_ERRORS || ''); // $FlowFixMe
return !isError ? arg : showStack ? arg : arg.message;
} | [
"function",
"argMapper",
"(",
"arg",
",",
"index",
",",
"array",
")",
"{",
"var",
"isError",
"=",
"(",
"0",
",",
"_neTypes",
".",
"typeOf",
")",
"(",
"arg",
")",
"===",
"Error",
".",
"name",
";",
"var",
"showStack",
"=",
"/",
"\\bSTACK\\b",
"/",
"i... | All arguments of any logging function in `LatticeLogs` get passed through
this function first to modify or alter the type of value being logged.
@param {mixed} arg the argument being passed to the `map()` function
@param {number} index the index in the array of arguments
@param {Array<mixed>} array the array containin... | [
"All",
"arguments",
"of",
"any",
"logging",
"function",
"in",
"LatticeLogs",
"get",
"passed",
"through",
"this",
"function",
"first",
"to",
"modify",
"or",
"alter",
"the",
"type",
"of",
"value",
"being",
"logged",
"."
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/utils.js#L351-L356 | train |
nyteshade/graphql-lattice | dist/utils.js | failFast | function failFast(logLevel, lessThan) {
var ll = LatticeLogs;
if (logLevel) {
var compareTo = lessThan || process.env.LATTICE_LOGLEVEL || ll.ERROR;
if (!ll.equalOrBelow(logLevel, compareTo)) return true;
}
return /\b(NONE|OFF|NO|0)\b/i.test(process.env.LATTICE_ERRORS || '');
} | javascript | function failFast(logLevel, lessThan) {
var ll = LatticeLogs;
if (logLevel) {
var compareTo = lessThan || process.env.LATTICE_LOGLEVEL || ll.ERROR;
if (!ll.equalOrBelow(logLevel, compareTo)) return true;
}
return /\b(NONE|OFF|NO|0)\b/i.test(process.env.LATTICE_ERRORS || '');
} | [
"function",
"failFast",
"(",
"logLevel",
",",
"lessThan",
")",
"{",
"var",
"ll",
"=",
"LatticeLogs",
";",
"if",
"(",
"logLevel",
")",
"{",
"var",
"compareTo",
"=",
"lessThan",
"||",
"process",
".",
"env",
".",
"LATTICE_LOGLEVEL",
"||",
"ll",
".",
"ERROR"... | A function that, when it returns true, will cause logging to be skipped | [
"A",
"function",
"that",
"when",
"it",
"returns",
"true",
"will",
"cause",
"logging",
"to",
"be",
"skipped"
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/utils.js#L359-L368 | train |
nyteshade/graphql-lattice | dist/utils.js | log | function log() {
var _console;
if (LatticeLogs.failFast(LatticeLogs.LOG)) return;
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
(_console = console).log.apply(_console, (0, _toConsumableArray2.default)(args... | javascript | function log() {
var _console;
if (LatticeLogs.failFast(LatticeLogs.LOG)) return;
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
(_console = console).log.apply(_console, (0, _toConsumableArray2.default)(args... | [
"function",
"log",
"(",
")",
"{",
"var",
"_console",
";",
"if",
"(",
"LatticeLogs",
".",
"failFast",
"(",
"LatticeLogs",
".",
"LOG",
")",
")",
"return",
";",
"for",
"(",
"var",
"_len3",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"new",
"Array... | Pass-thru to console.log; arguments parsed via `argMapper` | [
"Pass",
"-",
"thru",
"to",
"console",
".",
"log",
";",
"arguments",
"parsed",
"via",
"argMapper"
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/utils.js#L371-L381 | train |
nyteshade/graphql-lattice | dist/utils.js | warn | function warn() {
var _console2;
if (LatticeLogs.failFast(LatticeLogs.WARN)) return;
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
(_console2 = console).warn.apply(_console2, (0, _toConsumableArray2.default... | javascript | function warn() {
var _console2;
if (LatticeLogs.failFast(LatticeLogs.WARN)) return;
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
(_console2 = console).warn.apply(_console2, (0, _toConsumableArray2.default... | [
"function",
"warn",
"(",
")",
"{",
"var",
"_console2",
";",
"if",
"(",
"LatticeLogs",
".",
"failFast",
"(",
"LatticeLogs",
".",
"WARN",
")",
")",
"return",
";",
"for",
"(",
"var",
"_len4",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"new",
"Ar... | Pass-thru to console.warn; arguments parsed via `argMapper` | [
"Pass",
"-",
"thru",
"to",
"console",
".",
"warn",
";",
"arguments",
"parsed",
"via",
"argMapper"
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/utils.js#L384-L394 | train |
nyteshade/graphql-lattice | dist/utils.js | error | function error() {
var _console3;
if (LatticeLogs.failFast(LatticeLogs.ERROR)) return;
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
(_console3 = console).error.apply(_console3, (0, _toConsumableArray2.defa... | javascript | function error() {
var _console3;
if (LatticeLogs.failFast(LatticeLogs.ERROR)) return;
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
(_console3 = console).error.apply(_console3, (0, _toConsumableArray2.defa... | [
"function",
"error",
"(",
")",
"{",
"var",
"_console3",
";",
"if",
"(",
"LatticeLogs",
".",
"failFast",
"(",
"LatticeLogs",
".",
"ERROR",
")",
")",
"return",
";",
"for",
"(",
"var",
"_len5",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"new",
"... | Pass-thru to console.error; arguments parsed via `argMapper` | [
"Pass",
"-",
"thru",
"to",
"console",
".",
"error",
";",
"arguments",
"parsed",
"via",
"argMapper"
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/utils.js#L397-L407 | train |
nyteshade/graphql-lattice | dist/utils.js | info | function info() {
var _console4;
if (LatticeLogs.failFast(LatticeLogs.INFO)) return;
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
(_console4 = console).info.apply(_console4, (0, _toConsumableArray2.default... | javascript | function info() {
var _console4;
if (LatticeLogs.failFast(LatticeLogs.INFO)) return;
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
(_console4 = console).info.apply(_console4, (0, _toConsumableArray2.default... | [
"function",
"info",
"(",
")",
"{",
"var",
"_console4",
";",
"if",
"(",
"LatticeLogs",
".",
"failFast",
"(",
"LatticeLogs",
".",
"INFO",
")",
")",
"return",
";",
"for",
"(",
"var",
"_len6",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"new",
"Ar... | Pass-thru to console.info; arguments parsed via `argMapper` | [
"Pass",
"-",
"thru",
"to",
"console",
".",
"info",
";",
"arguments",
"parsed",
"via",
"argMapper"
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/utils.js#L410-L420 | train |
nyteshade/graphql-lattice | dist/utils.js | trace | function trace() {
var _console5;
if (LatticeLogs.failFast(LatticeLogs.TRACE)) return;
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
}
(_console5 = console).trace.apply(_console5, (0, _toConsumableArray2.defa... | javascript | function trace() {
var _console5;
if (LatticeLogs.failFast(LatticeLogs.TRACE)) return;
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
args[_key7] = arguments[_key7];
}
(_console5 = console).trace.apply(_console5, (0, _toConsumableArray2.defa... | [
"function",
"trace",
"(",
")",
"{",
"var",
"_console5",
";",
"if",
"(",
"LatticeLogs",
".",
"failFast",
"(",
"LatticeLogs",
".",
"TRACE",
")",
")",
"return",
";",
"for",
"(",
"var",
"_len7",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"new",
"... | Pass-thru to console.trace; arguments parsed via `argMapper` | [
"Pass",
"-",
"thru",
"to",
"console",
".",
"trace",
";",
"arguments",
"parsed",
"via",
"argMapper"
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/utils.js#L423-L433 | train |
nyteshade/graphql-lattice | dist/GQLBase.js | notDefined | function notDefined(keyToTest, keySupplied, instance) {
return new RegExp("^" + keyToTest + "$").test(keySupplied.toString()) && !instance.hasOwnProperty(keyToTest);
} | javascript | function notDefined(keyToTest, keySupplied, instance) {
return new RegExp("^" + keyToTest + "$").test(keySupplied.toString()) && !instance.hasOwnProperty(keyToTest);
} | [
"function",
"notDefined",
"(",
"keyToTest",
",",
"keySupplied",
",",
"instance",
")",
"{",
"return",
"new",
"RegExp",
"(",
"\"^\"",
"+",
"keyToTest",
"+",
"\"$\"",
")",
".",
"test",
"(",
"keySupplied",
".",
"toString",
"(",
")",
")",
"&&",
"!",
"instance... | Simple function to check if a supplied key matches a string of your
choosing and that string is not a defined property on the instance
passed to the check.
@method GQLBaseEnv~notDefined
@memberof GQLBaseEnv
@since 2.5.0
@param {string} keyToTest a String denoting the property you wish to test
@param {mixed} keySuppli... | [
"Simple",
"function",
"to",
"check",
"if",
"a",
"supplied",
"key",
"matches",
"a",
"string",
"of",
"your",
"choosing",
"and",
"that",
"string",
"is",
"not",
"a",
"defined",
"property",
"on",
"the",
"instance",
"passed",
"to",
"the",
"check",
"."
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/GQLBase.js#L158-L160 | train |
nyteshade/graphql-lattice | dist/GQLBase.js | getProp | function getProp(propName) {
var bindGetters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var bindTo = arguments.length > 2 ? arguments[2] : undefined;
// $FlowFixMe
var proto = Object.getPrototypeOf(this);
var descriptor = Object.getOwnPropertyDescriptor(pro... | javascript | function getProp(propName) {
var bindGetters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var bindTo = arguments.length > 2 ? arguments[2] : undefined;
// $FlowFixMe
var proto = Object.getPrototypeOf(this);
var descriptor = Object.getOwnPropertyDescriptor(pro... | [
"function",
"getProp",
"(",
"propName",
")",
"{",
"var",
"bindGetters",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"true",
";",
"var",
"bindTo",
"=",
"arguments... | Properties defined for GraphQL types in Lattice can be defined as
a getter, a function or an async function. In the case of standard
functions, if they return a promise they will be handled as though
they were async
Given the variety of things a GraphQL type can actually be, obtaining
its value can annoying. This meth... | [
"Properties",
"defined",
"for",
"GraphQL",
"types",
"in",
"Lattice",
"can",
"be",
"defined",
"as",
"a",
"getter",
"a",
"function",
"or",
"an",
"async",
"function",
".",
"In",
"the",
"case",
"of",
"standard",
"functions",
"if",
"they",
"return",
"a",
"promi... | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/GQLBase.js#L495-L522 | train |
nyteshade/graphql-lattice | dist/GQLBase.js | IDLFilePath | function IDLFilePath(path) {
var extension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.graphql';
return Symbol.for("Path ".concat(path, " Extension ").concat(extension));
} | javascript | function IDLFilePath(path) {
var extension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.graphql';
return Symbol.for("Path ".concat(path, " Extension ").concat(extension));
} | [
"function",
"IDLFilePath",
"(",
"path",
")",
"{",
"var",
"extension",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"'.graphql'",
";",
"return",
"Symbol",
".",
"fo... | Creates an appropriate Symbol crafted with the right data for use by
the IDLFileHandler class below.
@static
@memberof GQLBase
@method ⌾⠀IDLFilePath
@param {string} path a path to the IDL containing file
@param {string} [extension='.graphql'] an extension, including the
prefixed period, that will be added to the supp... | [
"Creates",
"an",
"appropriate",
"Symbol",
"crafted",
"with",
"the",
"right",
"data",
"for",
"use",
"by",
"the",
"IDLFileHandler",
"class",
"below",
"."
] | c95aba71e769eac2c900a4a578109a42e385342a | https://github.com/nyteshade/graphql-lattice/blob/c95aba71e769eac2c900a4a578109a42e385342a/dist/GQLBase.js#L1042-L1045 | train |
jacobrask/eslint-plugin-sorting | lib/rules/sort-object-props.js | nodeToString | function nodeToString(node) {
switch (node.type) {
case ("BinaryExpression"): {
return nodeToString(node.left) + node.operator.toString() + nodeToString(node.right);
}
case ("CallExpression"): {
var args = node.arguments.map(function(arg) {
return node... | javascript | function nodeToString(node) {
switch (node.type) {
case ("BinaryExpression"): {
return nodeToString(node.left) + node.operator.toString() + nodeToString(node.right);
}
case ("CallExpression"): {
var args = node.arguments.map(function(arg) {
return node... | [
"function",
"nodeToString",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"(",
"\"BinaryExpression\"",
")",
":",
"{",
"return",
"nodeToString",
"(",
"node",
".",
"left",
")",
"+",
"node",
".",
"operator",
".",
"toString",
... | Recursively converts Nodes to strings so they can be sorted
@param {Node} node: Babel AST Node
@returns {String} Node value as a string | [
"Recursively",
"converts",
"Nodes",
"to",
"strings",
"so",
"they",
"can",
"be",
"sorted"
] | ea30e0011bad0768b16f70e3526db93e119b5eaa | https://github.com/jacobrask/eslint-plugin-sorting/blob/ea30e0011bad0768b16f70e3526db93e119b5eaa/lib/rules/sort-object-props.js#L10-L55 | train |
gl-vis/gl-streamtube3d | streamtube.js | function(positions) {
var xs = [], ys = [], zs = [];
var xi = {}, yi = {}, zi = {};
for (var i=0; i<positions.length; i++) {
var p = positions[i];
var x = p[0], y = p[1], z = p[2];
// Split the positions array into arrays of unique component values.
//
// Why go through the trouble of using a uniqueness h... | javascript | function(positions) {
var xs = [], ys = [], zs = [];
var xi = {}, yi = {}, zi = {};
for (var i=0; i<positions.length; i++) {
var p = positions[i];
var x = p[0], y = p[1], z = p[2];
// Split the positions array into arrays of unique component values.
//
// Why go through the trouble of using a uniqueness h... | [
"function",
"(",
"positions",
")",
"{",
"var",
"xs",
"=",
"[",
"]",
",",
"ys",
"=",
"[",
"]",
",",
"zs",
"=",
"[",
"]",
";",
"var",
"xi",
"=",
"{",
"}",
",",
"yi",
"=",
"{",
"}",
",",
"zi",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
... | Finds the minimum per-component distance in positions. | [
"Finds",
"the",
"minimum",
"per",
"-",
"component",
"distance",
"in",
"positions",
"."
] | e07fe532d22e6c9c45f60e318f6f38e116a60952 | https://github.com/gl-vis/gl-streamtube3d/blob/e07fe532d22e6c9c45f60e318f6f38e116a60952/streamtube.js#L301-L359 | train | |
emilbayes/noise-protocol | symmetric-state.js | encryptAndHash | function encryptAndHash (state, ciphertext, plaintext) {
assert(state.byteLength === STATELEN)
assert(ciphertext.byteLength != null)
assert(plaintext.byteLength != null)
var cstate = state.subarray(CIPHER_BEGIN, CIPHER_END)
var h = state.subarray(HASH_BEGIN, HASH_END)
cipherState.encryptWithAd(cstate, cip... | javascript | function encryptAndHash (state, ciphertext, plaintext) {
assert(state.byteLength === STATELEN)
assert(ciphertext.byteLength != null)
assert(plaintext.byteLength != null)
var cstate = state.subarray(CIPHER_BEGIN, CIPHER_END)
var h = state.subarray(HASH_BEGIN, HASH_END)
cipherState.encryptWithAd(cstate, cip... | [
"function",
"encryptAndHash",
"(",
"state",
",",
"ciphertext",
",",
"plaintext",
")",
"{",
"assert",
"(",
"state",
".",
"byteLength",
"===",
"STATELEN",
")",
"assert",
"(",
"ciphertext",
".",
"byteLength",
"!=",
"null",
")",
"assert",
"(",
"plaintext",
".",
... | ciphertext is the output here | [
"ciphertext",
"is",
"the",
"output",
"here"
] | ad2f08fd09af1eb55433b9d34f71a85979cbbe9d | https://github.com/emilbayes/noise-protocol/blob/ad2f08fd09af1eb55433b9d34f71a85979cbbe9d/symmetric-state.js#L97-L109 | train |
rocjs/extensions | examples/web-app-react/complex/src/components/main/index.js | mapStateToProps | function mapStateToProps(state) {
return {
clicker: state.clicker,
repoUser: state.repoUser,
repositories: state.repositories,
errors: state.errors
};
} | javascript | function mapStateToProps(state) {
return {
clicker: state.clicker,
repoUser: state.repoUser,
repositories: state.repositories,
errors: state.errors
};
} | [
"function",
"mapStateToProps",
"(",
"state",
")",
"{",
"return",
"{",
"clicker",
":",
"state",
".",
"clicker",
",",
"repoUser",
":",
"state",
".",
"repoUser",
",",
"repositories",
":",
"state",
".",
"repositories",
",",
"errors",
":",
"state",
".",
"errors... | this maps values from redux store to props of this component | [
"this",
"maps",
"values",
"from",
"redux",
"store",
"to",
"props",
"of",
"this",
"component"
] | e9c364768c4edd30b789b94c51d20778d903d063 | https://github.com/rocjs/extensions/blob/e9c364768c4edd30b789b94c51d20778d903d063/examples/web-app-react/complex/src/components/main/index.js#L29-L36 | train |
CoinifySoftware/node-currency | src/index.js | computeRateBetweenSubunitAmounts | function computeRateBetweenSubunitAmounts(fromCurrency, fromAmount, toCurrency, toAmount) {
/*
* If currencies are equal, rate is 1
*/
if (fromCurrency === toCurrency) {
return 1;
}
/*
* If toAmount is 0, we don't want to divide by zero.
* In this case, return NaN
*/
if (toAmount === 0) {
... | javascript | function computeRateBetweenSubunitAmounts(fromCurrency, fromAmount, toCurrency, toAmount) {
/*
* If currencies are equal, rate is 1
*/
if (fromCurrency === toCurrency) {
return 1;
}
/*
* If toAmount is 0, we don't want to divide by zero.
* In this case, return NaN
*/
if (toAmount === 0) {
... | [
"function",
"computeRateBetweenSubunitAmounts",
"(",
"fromCurrency",
",",
"fromAmount",
",",
"toCurrency",
",",
"toAmount",
")",
"{",
"/*\n * If currencies are equal, rate is 1\n */",
"if",
"(",
"fromCurrency",
"===",
"toCurrency",
")",
"{",
"return",
"1",
";",
"}",... | Computes a rate between two amounts in two different currencies.
The result is fromAmount / toAmount (in the main units of their respective currencies)
@param {string} fromCurrency
@param {int} fromAmount Amount denominated in smallest sub-unit of fromCurrency
@param {string} toCurrency
@param {int} toAmount Amount d... | [
"Computes",
"a",
"rate",
"between",
"two",
"amounts",
"in",
"two",
"different",
"currencies",
"."
] | d4e84e34da0bcdc922a2696387bf6cc30b6791c9 | https://github.com/CoinifySoftware/node-currency/blob/d4e84e34da0bcdc922a2696387bf6cc30b6791c9/src/index.js#L86-L112 | train |
canjs/can-view-scope | can-view-scope.js | function(context, keys){
// If nothing can be found with the keys we are looking for, save the
// first possible match. This is where we will write to.
if(firstSearchedContext === undefined && !(context instanceof LetContext)) {
firstSearchedContext = context;
}
// If we have multiple keys ..... | javascript | function(context, keys){
// If nothing can be found with the keys we are looking for, save the
// first possible match. This is where we will write to.
if(firstSearchedContext === undefined && !(context instanceof LetContext)) {
firstSearchedContext = context;
}
// If we have multiple keys ..... | [
"function",
"(",
"context",
",",
"keys",
")",
"{",
"// If nothing can be found with the keys we are looking for, save the",
"// first possible match. This is where we will write to.",
"if",
"(",
"firstSearchedContext",
"===",
"undefined",
"&&",
"!",
"(",
"context",
"instanceof",... | This read is used by `._walk` to read from the scope. This will use `hasKey` on the last property instead of reading it. | [
"This",
"read",
"is",
"used",
"by",
".",
"_walk",
"to",
"read",
"from",
"the",
"scope",
".",
"This",
"will",
"use",
"hasKey",
"on",
"the",
"last",
"property",
"instead",
"of",
"reading",
"it",
"."
] | 5f6f517bc7de8726331872480c369fe6d27392c9 | https://github.com/canjs/can-view-scope/blob/5f6f517bc7de8726331872480c369fe6d27392c9/can-view-scope.js#L528-L570 | train | |
canjs/can-view-scope | can-view-scope.js | function() {
var top;
this.getScope(function(scope) {
if (scope._meta.viewModel) {
top = scope;
}
// walk entire scope tree
return false;
});
return top && top._context;
} | javascript | function() {
var top;
this.getScope(function(scope) {
if (scope._meta.viewModel) {
top = scope;
}
// walk entire scope tree
return false;
});
return top && top._context;
} | [
"function",
"(",
")",
"{",
"var",
"top",
";",
"this",
".",
"getScope",
"(",
"function",
"(",
"scope",
")",
"{",
"if",
"(",
"scope",
".",
"_meta",
".",
"viewModel",
")",
"{",
"top",
"=",
"scope",
";",
"}",
"// walk entire scope tree",
"return",
"false",... | _top_ viewModel scope | [
"_top_",
"viewModel",
"scope"
] | 5f6f517bc7de8726331872480c369fe6d27392c9 | https://github.com/canjs/can-view-scope/blob/5f6f517bc7de8726331872480c369fe6d27392c9/can-view-scope.js#L749-L762 | train | |
Rekord/rekord | build/rekord.js | toArray | function toArray(x, delimiter)
{
if ( x instanceof Array )
{
return x;
}
if ( isString( x ) )
{
return x.split( delimiter );
}
if ( isValue( x ) )
{
return [ x ];
}
return [];
} | javascript | function toArray(x, delimiter)
{
if ( x instanceof Array )
{
return x;
}
if ( isString( x ) )
{
return x.split( delimiter );
}
if ( isValue( x ) )
{
return [ x ];
}
return [];
} | [
"function",
"toArray",
"(",
"x",
",",
"delimiter",
")",
"{",
"if",
"(",
"x",
"instanceof",
"Array",
")",
"{",
"return",
"x",
";",
"}",
"if",
"(",
"isString",
"(",
"x",
")",
")",
"{",
"return",
"x",
".",
"split",
"(",
"delimiter",
")",
";",
"}",
... | Converts the given variable to an array of strings. If the variable is a
string it is split based on the delimiter given. If the variable is an
array then it is returned. If the variable is any other type it may result
in an error.
```javascript
Rekord.toArray([1, 2, 3]); // [1, 2, 3]
Rekord.toArray('1,2,3', ','); // ... | [
"Converts",
"the",
"given",
"variable",
"to",
"an",
"array",
"of",
"strings",
".",
"If",
"the",
"variable",
"is",
"a",
"string",
"it",
"is",
"split",
"based",
"on",
"the",
"delimiter",
"given",
".",
"If",
"the",
"variable",
"is",
"an",
"array",
"then",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L53-L69 | train |
Rekord/rekord | build/rekord.js | indexOf | function indexOf(arr, x, comparator)
{
var cmp = comparator || equalsStrict;
for (var i = 0, n = arr.length; i < n; i++)
{
if ( cmp( arr[i], x ) )
{
return i;
}
}
return false;
} | javascript | function indexOf(arr, x, comparator)
{
var cmp = comparator || equalsStrict;
for (var i = 0, n = arr.length; i < n; i++)
{
if ( cmp( arr[i], x ) )
{
return i;
}
}
return false;
} | [
"function",
"indexOf",
"(",
"arr",
",",
"x",
",",
"comparator",
")",
"{",
"var",
"cmp",
"=",
"comparator",
"||",
"equalsStrict",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"n",
"=",
"arr",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")"... | Finds the index of a variable in an array optionally using a custom
comparison function. If the variable is not found in the array then `false`
is returned.
```javascript
Rekord.indexOf([1, 2, 3], 1); // 0
Rekord.indexOf([1, 2, 3], 4); // false
Rekord.indexOf([1, 2, 2], 2); // 1
```
@memberof Rekord
@param {Array} a... | [
"Finds",
"the",
"index",
"of",
"a",
"variable",
"in",
"an",
"array",
"optionally",
"using",
"a",
"custom",
"comparison",
"function",
".",
"If",
"the",
"variable",
"is",
"not",
"found",
"in",
"the",
"array",
"then",
"false",
"is",
"returned",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L96-L109 | train |
Rekord/rekord | build/rekord.js | isRekord | function isRekord(x)
{
return !!(x && x.Database && isFunction( x ) && x.prototype instanceof Model);
} | javascript | function isRekord(x)
{
return !!(x && x.Database && isFunction( x ) && x.prototype instanceof Model);
} | [
"function",
"isRekord",
"(",
"x",
")",
"{",
"return",
"!",
"!",
"(",
"x",
"&&",
"x",
".",
"Database",
"&&",
"isFunction",
"(",
"x",
")",
"&&",
"x",
".",
"prototype",
"instanceof",
"Model",
")",
";",
"}"
] | Determines whether the given variable is a Rekord object. A Rekord object is a
constructor for a model and also has a Database variable. A Rekord object is
strictly created by the Rekord function.
```javascript
var Task = Rekord({
name: 'task',
fields: ['name', 'done', 'finished_at', 'created_at', 'assigned_to']
});
R... | [
"Determines",
"whether",
"the",
"given",
"variable",
"is",
"a",
"Rekord",
"object",
".",
"A",
"Rekord",
"object",
"is",
"a",
"constructor",
"for",
"a",
"model",
"and",
"also",
"has",
"a",
"Database",
"variable",
".",
"A",
"Rekord",
"object",
"is",
"strictl... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L460-L463 | train |
Rekord/rekord | build/rekord.js | createComparator | function createComparator(comparator, nullsFirst)
{
if ( isFunction( comparator ) )
{
return comparator;
}
else if ( isString( comparator ) )
{
if ( comparator in Comparators )
{
return Comparators[ comparator ];
}
if ( comparator.charAt(0) === '-' )
{
var parsed = createC... | javascript | function createComparator(comparator, nullsFirst)
{
if ( isFunction( comparator ) )
{
return comparator;
}
else if ( isString( comparator ) )
{
if ( comparator in Comparators )
{
return Comparators[ comparator ];
}
if ( comparator.charAt(0) === '-' )
{
var parsed = createC... | [
"function",
"createComparator",
"(",
"comparator",
",",
"nullsFirst",
")",
"{",
"if",
"(",
"isFunction",
"(",
"comparator",
")",
")",
"{",
"return",
"comparator",
";",
"}",
"else",
"if",
"(",
"isString",
"(",
"comparator",
")",
")",
"{",
"if",
"(",
"comp... | Creates a function which compares two values.
@memberof Rekord
@param {comparatorInput} comparator
The input which creates a comparison function.
@param {Boolean} [nullsFirst=false] -
True if null values should be sorted first.
@return {comparisonCallback} | [
"Creates",
"a",
"function",
"which",
"compares",
"two",
"values",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L844-L924 | train |
Rekord/rekord | build/rekord.js | on | function on(events, callback, context)
{
return onListeners( this, events, callback, context, EventNode.Types.Persistent );
} | javascript | function on(events, callback, context)
{
return onListeners( this, events, callback, context, EventNode.Types.Persistent );
} | [
"function",
"on",
"(",
"events",
",",
"callback",
",",
"context",
")",
"{",
"return",
"onListeners",
"(",
"this",
",",
"events",
",",
"callback",
",",
"context",
",",
"EventNode",
".",
"Types",
".",
"Persistent",
")",
";",
"}"
] | Listens for every occurrence of the given events and invokes the callback
each time any of them are triggered.
@method on
@memberof Rekord.Eventful#
@param {String|Array} events -
The event or events to listen to.
@param {Function} callback -
The function to invoke when any of the events are invoked.
@param {Object} [... | [
"Listens",
"for",
"every",
"occurrence",
"of",
"the",
"given",
"events",
"and",
"invokes",
"the",
"callback",
"each",
"time",
"any",
"of",
"them",
"are",
"triggered",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1361-L1364 | train |
Rekord/rekord | build/rekord.js | once | function once(events, callback, context)
{
return onListeners( this, events, callback, context, EventNode.Types.Once );
} | javascript | function once(events, callback, context)
{
return onListeners( this, events, callback, context, EventNode.Types.Once );
} | [
"function",
"once",
"(",
"events",
",",
"callback",
",",
"context",
")",
"{",
"return",
"onListeners",
"(",
"this",
",",
"events",
",",
"callback",
",",
"context",
",",
"EventNode",
".",
"Types",
".",
"Once",
")",
";",
"}"
] | Listens for the first of the given events to be triggered and invokes the
callback once.
@method once
@memberof Rekord.Eventful#
@param {String|Array} events -
The event or events to listen to.
@param {Function} callback -
The function to invoke when any of the events are invoked.
@param {Object} [context] -
The value... | [
"Listens",
"for",
"the",
"first",
"of",
"the",
"given",
"events",
"to",
"be",
"triggered",
"and",
"invokes",
"the",
"callback",
"once",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1400-L1403 | train |
Rekord/rekord | build/rekord.js | offListeners | function offListeners(listeners, event, callback)
{
if (listeners && event in listeners)
{
var eventListeners = listeners[ event ];
var next, node = eventListeners.next;
while (node !== eventListeners)
{
next = node.next;
if (node.callback === callback)
{
... | javascript | function offListeners(listeners, event, callback)
{
if (listeners && event in listeners)
{
var eventListeners = listeners[ event ];
var next, node = eventListeners.next;
while (node !== eventListeners)
{
next = node.next;
if (node.callback === callback)
{
... | [
"function",
"offListeners",
"(",
"listeners",
",",
"event",
",",
"callback",
")",
"{",
"if",
"(",
"listeners",
"&&",
"event",
"in",
"listeners",
")",
"{",
"var",
"eventListeners",
"=",
"listeners",
"[",
"event",
"]",
";",
"var",
"next",
",",
"node",
"=",... | Removes a listener from an array of listeners. | [
"Removes",
"a",
"listener",
"from",
"an",
"array",
"of",
"listeners",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1411-L1430 | train |
Rekord/rekord | build/rekord.js | off | function off(eventsInput, callback)
{
// Remove ALL listeners
if ( !isDefined( eventsInput ) )
{
deleteProperty( this, '$$on' );
}
else
{
var events = toArray( eventsInput, ' ' );
// Remove listeners for given events
if ( !isFunction( callback ) )
{
for (... | javascript | function off(eventsInput, callback)
{
// Remove ALL listeners
if ( !isDefined( eventsInput ) )
{
deleteProperty( this, '$$on' );
}
else
{
var events = toArray( eventsInput, ' ' );
// Remove listeners for given events
if ( !isFunction( callback ) )
{
for (... | [
"function",
"off",
"(",
"eventsInput",
",",
"callback",
")",
"{",
"// Remove ALL listeners",
"if",
"(",
"!",
"isDefined",
"(",
"eventsInput",
")",
")",
"{",
"deleteProperty",
"(",
"this",
",",
"'$$on'",
")",
";",
"}",
"else",
"{",
"var",
"events",
"=",
"... | Stops listening for a given callback for a given set of events.
**Examples:**
target.off(); // remove all listeners
target.off('a b'); // remove all listeners on events a & b
target.off(['a', 'b']); // remove all listeners on events a & b
target.off('a', x); // remove listener x from event a
@meth... | [
"Stops",
"listening",
"for",
"a",
"given",
"callback",
"for",
"a",
"given",
"set",
"of",
"events",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1457-L1487 | train |
Rekord/rekord | build/rekord.js | triggerListeners | function triggerListeners(listeners, event, args)
{
if (listeners && event in listeners)
{
var eventListeners = listeners[ event ];
var triggerGroup = ++triggerId;
var next, node = eventListeners.next;
while (node !== eventListeners)
{
next = node.next;
node.trig... | javascript | function triggerListeners(listeners, event, args)
{
if (listeners && event in listeners)
{
var eventListeners = listeners[ event ];
var triggerGroup = ++triggerId;
var next, node = eventListeners.next;
while (node !== eventListeners)
{
next = node.next;
node.trig... | [
"function",
"triggerListeners",
"(",
"listeners",
",",
"event",
",",
"args",
")",
"{",
"if",
"(",
"listeners",
"&&",
"event",
"in",
"listeners",
")",
"{",
"var",
"eventListeners",
"=",
"listeners",
"[",
"event",
"]",
";",
"var",
"triggerGroup",
"=",
"++",
... | Triggers listeneers for the given event | [
"Triggers",
"listeneers",
"for",
"the",
"given",
"event"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1490-L1514 | train |
Rekord/rekord | build/rekord.js | trigger | function trigger(eventsInput, args)
{
try
{
var events = toArray( eventsInput, ' ' );
for (var i = 0; i < events.length; i++)
{
triggerListeners( this.$$on, events[ i ], args );
}
}
catch (ex)
{
Rekord.trigger( Rekord.Events.Error, [ex] );
}
return t... | javascript | function trigger(eventsInput, args)
{
try
{
var events = toArray( eventsInput, ' ' );
for (var i = 0; i < events.length; i++)
{
triggerListeners( this.$$on, events[ i ], args );
}
}
catch (ex)
{
Rekord.trigger( Rekord.Events.Error, [ex] );
}
return t... | [
"function",
"trigger",
"(",
"eventsInput",
",",
"args",
")",
"{",
"try",
"{",
"var",
"events",
"=",
"toArray",
"(",
"eventsInput",
",",
"' '",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"events",
".",
"length",
";",
"i",
"++",
")"... | Triggers a single event optionally passing an argument to any listeners.
@method trigger
@for addEventful
@param {String} eventsInput
@param {Array} args
@chainable | [
"Triggers",
"a",
"single",
"event",
"optionally",
"passing",
"an",
"argument",
"to",
"any",
"listeners",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1525-L1542 | train |
Rekord/rekord | build/rekord.js | merge | function merge(dst, src, ignoreMap)
{
if (isObject( dst ) && isObject( src ))
{
for (var prop in src)
{
if (!ignoreMap || !ignoreMap[ prop ])
{
var adding = src[ prop ];
if (prop in dst)
{
var existing = dst[ prop ];
if (isArray( existing ))
... | javascript | function merge(dst, src, ignoreMap)
{
if (isObject( dst ) && isObject( src ))
{
for (var prop in src)
{
if (!ignoreMap || !ignoreMap[ prop ])
{
var adding = src[ prop ];
if (prop in dst)
{
var existing = dst[ prop ];
if (isArray( existing ))
... | [
"function",
"merge",
"(",
"dst",
",",
"src",
",",
"ignoreMap",
")",
"{",
"if",
"(",
"isObject",
"(",
"dst",
")",
"&&",
"isObject",
"(",
"src",
")",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"src",
")",
"{",
"if",
"(",
"!",
"ignoreMap",
"||",
"... | Given two objects, merge src into dst. - If a property in src has a truthy value in ignoreMap then skip merging it. - If a property exists in src and not in dst, the property is added to dst. - If an array property exists in src and in dst, the src elements are added to dst. - If an array property exists in dst and a n... | [
"Given",
"two",
"objects",
"merge",
"src",
"into",
"dst",
".",
"-",
"If",
"a",
"property",
"in",
"src",
"has",
"a",
"truthy",
"value",
"in",
"ignoreMap",
"then",
"skip",
"merging",
"it",
".",
"-",
"If",
"a",
"property",
"exists",
"in",
"src",
"and",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1585-L1628 | train |
Rekord/rekord | build/rekord.js | propsMatch | function propsMatch(test, testFields, expected, expectedFields, equals)
{
var equality = equals || Rekord.equals;
if ( isString( testFields ) ) // && isString( expectedFields )
{
return equality( test[ testFields ], expected[ expectedFields ] );
}
else // if ( isArray( testFields ) && isArray( expectedFi... | javascript | function propsMatch(test, testFields, expected, expectedFields, equals)
{
var equality = equals || Rekord.equals;
if ( isString( testFields ) ) // && isString( expectedFields )
{
return equality( test[ testFields ], expected[ expectedFields ] );
}
else // if ( isArray( testFields ) && isArray( expectedFi... | [
"function",
"propsMatch",
"(",
"test",
",",
"testFields",
",",
"expected",
",",
"expectedFields",
",",
"equals",
")",
"{",
"var",
"equality",
"=",
"equals",
"||",
"Rekord",
".",
"equals",
";",
"if",
"(",
"isString",
"(",
"testFields",
")",
")",
"// && isSt... | Determines whether the properties on one object equals the properties on
another object.
@memberof Rekord
@param {Object} test -
The object to test for matching.
@param {String|String[]} testFields -
The property name or array of properties to test for equality on `test`.
@param {Object} expected -
The object with the... | [
"Determines",
"whether",
"the",
"properties",
"on",
"one",
"object",
"equals",
"the",
"properties",
"on",
"another",
"object",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1694-L1719 | train |
Rekord/rekord | build/rekord.js | hasFields | function hasFields(model, fields, exists)
{
if ( isArray( fields ) )
{
for (var i = 0; i < fields.length; i++)
{
if ( !exists( model[ fields[ i ] ] ) )
{
return false;
}
}
return true;
}
else // isString( fields )
{
return exists( model[ fields ] );
}
} | javascript | function hasFields(model, fields, exists)
{
if ( isArray( fields ) )
{
for (var i = 0; i < fields.length; i++)
{
if ( !exists( model[ fields[ i ] ] ) )
{
return false;
}
}
return true;
}
else // isString( fields )
{
return exists( model[ fields ] );
}
} | [
"function",
"hasFields",
"(",
"model",
",",
"fields",
",",
"exists",
")",
"{",
"if",
"(",
"isArray",
"(",
"fields",
")",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
... | Determines whether the given model has the given fields | [
"Determines",
"whether",
"the",
"given",
"model",
"has",
"the",
"given",
"fields"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L1722-L1740 | train |
Rekord/rekord | build/rekord.js | createPropertyResolver | function createPropertyResolver(properties)
{
if ( isFunction( properties ) )
{
return properties;
}
else if ( isString( properties ) )
{
if ( properties in PropertyResolvers )
{
return PropertyResolvers[ properties ];
}
if ( isFormatInput( properties ) )
{
return createFo... | javascript | function createPropertyResolver(properties)
{
if ( isFunction( properties ) )
{
return properties;
}
else if ( isString( properties ) )
{
if ( properties in PropertyResolvers )
{
return PropertyResolvers[ properties ];
}
if ( isFormatInput( properties ) )
{
return createFo... | [
"function",
"createPropertyResolver",
"(",
"properties",
")",
"{",
"if",
"(",
"isFunction",
"(",
"properties",
")",
")",
"{",
"return",
"properties",
";",
"}",
"else",
"if",
"(",
"isString",
"(",
"properties",
")",
")",
"{",
"if",
"(",
"properties",
"in",
... | Creates a function which resolves a value from another value given an
expression. This is often used to get a property value of an object.
```javascript
// x = {age: 6, name: 'tom', user: {first: 'jack'}}
createPropertyResolver()( x ) // x
createPropertyResolver( 'age' )( x ) ... | [
"Creates",
"a",
"function",
"which",
"resolves",
"a",
"value",
"from",
"another",
"value",
"given",
"an",
"expression",
".",
"This",
"is",
"often",
"used",
"to",
"get",
"a",
"property",
"value",
"of",
"an",
"object",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L2166-L2234 | train |
Rekord/rekord | build/rekord.js | createWhere | function createWhere(properties, value, equals)
{
var equality = equals || equalsStrict;
if ( isFunction( properties ) )
{
return properties;
}
else if ( isArray( properties ) )
{
var parsed = [];
for (var i = 0; i < properties.length; i++)
{
var where = properties[ i ];
parse... | javascript | function createWhere(properties, value, equals)
{
var equality = equals || equalsStrict;
if ( isFunction( properties ) )
{
return properties;
}
else if ( isArray( properties ) )
{
var parsed = [];
for (var i = 0; i < properties.length; i++)
{
var where = properties[ i ];
parse... | [
"function",
"createWhere",
"(",
"properties",
",",
"value",
",",
"equals",
")",
"{",
"var",
"equality",
"=",
"equals",
"||",
"equalsStrict",
";",
"if",
"(",
"isFunction",
"(",
"properties",
")",
")",
"{",
"return",
"properties",
";",
"}",
"else",
"if",
"... | Creates a function which returns a true or false value given a test value.
This is also known as a filter function.
```javascript
Rekord.createWhere('field', true); // when an object has property where field=true
Rekord.createWhere('field'); // when an object has the property named field
Rekord.createWhere(function()... | [
"Creates",
"a",
"function",
"which",
"returns",
"a",
"true",
"or",
"false",
"value",
"given",
"a",
"test",
"value",
".",
"This",
"is",
"also",
"known",
"as",
"a",
"filter",
"function",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L2400-L2492 | train |
Rekord/rekord | build/rekord.js | Rekord | function Rekord(options)
{
var promise = Rekord.get( options.name );
if ( promise.isComplete() )
{
return promise.results[0];
}
Rekord.trigger( Rekord.Events.Options, [options] );
var database = new Database( options );
var model = Class.dynamic(
Model,
new Model( database ),
database.... | javascript | function Rekord(options)
{
var promise = Rekord.get( options.name );
if ( promise.isComplete() )
{
return promise.results[0];
}
Rekord.trigger( Rekord.Events.Options, [options] );
var database = new Database( options );
var model = Class.dynamic(
Model,
new Model( database ),
database.... | [
"function",
"Rekord",
"(",
"options",
")",
"{",
"var",
"promise",
"=",
"Rekord",
".",
"get",
"(",
"options",
".",
"name",
")",
";",
"if",
"(",
"promise",
".",
"isComplete",
"(",
")",
")",
"{",
"return",
"promise",
".",
"results",
"[",
"0",
"]",
";"... | Creates a Rekord object given a set of options. A Rekord object is also the
constructor for creating instances of the Rekord object defined.
@namespace
@param {Object} options
The options of | [
"Creates",
"a",
"Rekord",
"object",
"given",
"a",
"set",
"of",
"options",
".",
"A",
"Rekord",
"object",
"is",
"also",
"the",
"constructor",
"for",
"creating",
"instances",
"of",
"the",
"Rekord",
"object",
"defined",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L2578-L2626 | train |
Rekord/rekord | build/rekord.js | function(saving)
{
if ( !isObject( saving ) )
{
return false;
}
for (var prop in saving)
{
if ( !this.ignoredFields[ prop ] )
{
return true;
}
}
return false;
} | javascript | function(saving)
{
if ( !isObject( saving ) )
{
return false;
}
for (var prop in saving)
{
if ( !this.ignoredFields[ prop ] )
{
return true;
}
}
return false;
} | [
"function",
"(",
"saving",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"saving",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"prop",
"in",
"saving",
")",
"{",
"if",
"(",
"!",
"this",
".",
"ignoredFields",
"[",
"prop",
"]",
")",
... | Determines whether the given object has data to save | [
"Determines",
"whether",
"the",
"given",
"object",
"has",
"data",
"to",
"save"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L4051-L4067 | train | |
Rekord/rekord | build/rekord.js | function(input, callback, context, remoteData)
{
var db = this;
var promise = new Promise();
promise.success( callback, context || db );
function checkModel()
{
var result = db.parseModel( input, remoteData );
if ( result !== false && !promise.isComplete() && db.initialized )
... | javascript | function(input, callback, context, remoteData)
{
var db = this;
var promise = new Promise();
promise.success( callback, context || db );
function checkModel()
{
var result = db.parseModel( input, remoteData );
if ( result !== false && !promise.isComplete() && db.initialized )
... | [
"function",
"(",
"input",
",",
"callback",
",",
"context",
",",
"remoteData",
")",
"{",
"var",
"db",
"=",
"this",
";",
"var",
"promise",
"=",
"new",
"Promise",
"(",
")",
";",
"promise",
".",
"success",
"(",
"callback",
",",
"context",
"||",
"db",
")"... | Grab a model with the given input and notify the callback | [
"Grab",
"a",
"model",
"with",
"the",
"given",
"input",
"and",
"notify",
"the",
"callback"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L4070-L4124 | train | |
Rekord/rekord | build/rekord.js | function(revision)
{
if ( isFunction( revision ) )
{
this.revisionFunction = revision;
}
else if ( isString( revision ) )
{
this.revisionFunction = function(a, b)
{
var ar = isObject( a ) && revision in a ? a[ revision ] : undefined;
var br = isObject( b ) && revi... | javascript | function(revision)
{
if ( isFunction( revision ) )
{
this.revisionFunction = revision;
}
else if ( isString( revision ) )
{
this.revisionFunction = function(a, b)
{
var ar = isObject( a ) && revision in a ? a[ revision ] : undefined;
var br = isObject( b ) && revi... | [
"function",
"(",
"revision",
")",
"{",
"if",
"(",
"isFunction",
"(",
"revision",
")",
")",
"{",
"this",
".",
"revisionFunction",
"=",
"revision",
";",
"}",
"else",
"if",
"(",
"isString",
"(",
"revision",
")",
")",
"{",
"this",
".",
"revisionFunction",
... | Sets a revision comparision function for this database. It can be a field name or a function. This is used to avoid updating model data that is older than the model's current data. | [
"Sets",
"a",
"revision",
"comparision",
"function",
"for",
"this",
"database",
".",
"It",
"can",
"be",
"a",
"field",
"name",
"or",
"a",
"function",
".",
"This",
"is",
"used",
"to",
"avoid",
"updating",
"model",
"data",
"that",
"is",
"older",
"than",
"the... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L4216-L4239 | train | |
Rekord/rekord | build/rekord.js | function(key)
{
var db = this;
var model = db.all[ key ];
if ( db.cache === Cache.All )
{
return db.destroyLocalCachedModel( model, key );
}
else
{
return db.destroyLocalUncachedModel( model, key );
}
} | javascript | function(key)
{
var db = this;
var model = db.all[ key ];
if ( db.cache === Cache.All )
{
return db.destroyLocalCachedModel( model, key );
}
else
{
return db.destroyLocalUncachedModel( model, key );
}
} | [
"function",
"(",
"key",
")",
"{",
"var",
"db",
"=",
"this",
";",
"var",
"model",
"=",
"db",
".",
"all",
"[",
"key",
"]",
";",
"if",
"(",
"db",
".",
"cache",
"===",
"Cache",
".",
"All",
")",
"{",
"return",
"db",
".",
"destroyLocalCachedModel",
"("... | Destroys a model locally because it doesn't exist remotely | [
"Destroys",
"a",
"model",
"locally",
"because",
"it",
"doesn",
"t",
"exist",
"remotely"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L4626-L4639 | train | |
Rekord/rekord | build/rekord.js | function(callback, context)
{
var db = this;
var promise = new Promise();
var success = this.handleRefreshSuccess( promise );
var failure = this.handleRefreshFailure( promise );
promise.complete( callback, context || db );
batchExecute(function()
{
db.executeRefresh( success, failu... | javascript | function(callback, context)
{
var db = this;
var promise = new Promise();
var success = this.handleRefreshSuccess( promise );
var failure = this.handleRefreshFailure( promise );
promise.complete( callback, context || db );
batchExecute(function()
{
db.executeRefresh( success, failu... | [
"function",
"(",
"callback",
",",
"context",
")",
"{",
"var",
"db",
"=",
"this",
";",
"var",
"promise",
"=",
"new",
"Promise",
"(",
")",
";",
"var",
"success",
"=",
"this",
".",
"handleRefreshSuccess",
"(",
"promise",
")",
";",
"var",
"failure",
"=",
... | Loads all data remotely | [
"Loads",
"all",
"data",
"remotely"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L4904-L4919 | train | |
Rekord/rekord | build/rekord.js | function(model, cascade, options)
{
var db = this;
if ( model.$isDeleted() )
{
Rekord.debug( Rekord.Debugs.SAVE_DELETED, db, model );
return;
}
var key = model.$key();
var existing = db.models.has( key );
if ( existing )
{
db.trigger( Database.Events.ModelUpdated,... | javascript | function(model, cascade, options)
{
var db = this;
if ( model.$isDeleted() )
{
Rekord.debug( Rekord.Debugs.SAVE_DELETED, db, model );
return;
}
var key = model.$key();
var existing = db.models.has( key );
if ( existing )
{
db.trigger( Database.Events.ModelUpdated,... | [
"function",
"(",
"model",
",",
"cascade",
",",
"options",
")",
"{",
"var",
"db",
"=",
"this",
";",
"if",
"(",
"model",
".",
"$isDeleted",
"(",
")",
")",
"{",
"Rekord",
".",
"debug",
"(",
"Rekord",
".",
"Debugs",
".",
"SAVE_DELETED",
",",
"db",
",",... | Save the model | [
"Save",
"the",
"model"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L5020-L5050 | train | |
Rekord/rekord | build/rekord.js | function(model, cascade, options)
{
var db = this;
// If we have it in the models, remove it!
this.removeFromModels( model );
// If we're offline and we have a pending save - cancel the pending save.
if ( model.$status === Model.Status.SavePending )
{
Rekord.debug( Rekord.Debugs.REMOVE... | javascript | function(model, cascade, options)
{
var db = this;
// If we have it in the models, remove it!
this.removeFromModels( model );
// If we're offline and we have a pending save - cancel the pending save.
if ( model.$status === Model.Status.SavePending )
{
Rekord.debug( Rekord.Debugs.REMOVE... | [
"function",
"(",
"model",
",",
"cascade",
",",
"options",
")",
"{",
"var",
"db",
"=",
"this",
";",
"// If we have it in the models, remove it!",
"this",
".",
"removeFromModels",
"(",
"model",
")",
";",
"// If we're offline and we have a pending save - cancel the pending s... | Remove the model | [
"Remove",
"the",
"model"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L5053-L5069 | train | |
Rekord/rekord | build/rekord.js | function(key, value)
{
if ( key in this.indices )
{
this.values[ this.indices[ key ] ] = value;
}
else
{
this.indices[ key ] = this.values.length;
AP.push.call( this.values, value );
AP.push.call( this.keys, key );
}
return this;
} | javascript | function(key, value)
{
if ( key in this.indices )
{
this.values[ this.indices[ key ] ] = value;
}
else
{
this.indices[ key ] = this.values.length;
AP.push.call( this.values, value );
AP.push.call( this.keys, key );
}
return this;
} | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"key",
"in",
"this",
".",
"indices",
")",
"{",
"this",
".",
"values",
"[",
"this",
".",
"indices",
"[",
"key",
"]",
"]",
"=",
"value",
";",
"}",
"else",
"{",
"this",
".",
"indices",
"["... | Puts the value in the map by the given key.
@param {String} key
@param {V} value
@return {Rekord.Map} -
The reference to this map. | [
"Puts",
"the",
"value",
"in",
"the",
"map",
"by",
"the",
"given",
"key",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6087-L6101 | train | |
Rekord/rekord | build/rekord.js | function(index)
{
var key = this.keys[ index ];
var lastValue = AP.pop.apply( this.values );
var lastKey = AP.pop.apply( this.keys );
if ( index < this.values.length )
{
this.values[ index ] = lastValue;
this.keys[ index ] = lastKey;
this.indices[ lastKey ] = index;
}
d... | javascript | function(index)
{
var key = this.keys[ index ];
var lastValue = AP.pop.apply( this.values );
var lastKey = AP.pop.apply( this.keys );
if ( index < this.values.length )
{
this.values[ index ] = lastValue;
this.keys[ index ] = lastKey;
this.indices[ lastKey ] = index;
}
d... | [
"function",
"(",
"index",
")",
"{",
"var",
"key",
"=",
"this",
".",
"keys",
"[",
"index",
"]",
";",
"var",
"lastValue",
"=",
"AP",
".",
"pop",
".",
"apply",
"(",
"this",
".",
"values",
")",
";",
"var",
"lastKey",
"=",
"AP",
".",
"pop",
".",
"ap... | Removes the value & key at the given index.
@param {Number} index
@return {Rekord.Map} -
The reference to this map. | [
"Removes",
"the",
"value",
"&",
"key",
"at",
"the",
"given",
"index",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6140-L6156 | train | |
Rekord/rekord | build/rekord.js | function(callback, dest)
{
var out = dest || new Map();
var n = this.size();
var values = this.values;
var keys = this.keys;
for (var i = 0; i < n; i++)
{
var v = values[ i ];
var k = keys[ i ];
if ( callback( v, k ) )
{
out.put( k, v );
}
}
ret... | javascript | function(callback, dest)
{
var out = dest || new Map();
var n = this.size();
var values = this.values;
var keys = this.keys;
for (var i = 0; i < n; i++)
{
var v = values[ i ];
var k = keys[ i ];
if ( callback( v, k ) )
{
out.put( k, v );
}
}
ret... | [
"function",
"(",
"callback",
",",
"dest",
")",
"{",
"var",
"out",
"=",
"dest",
"||",
"new",
"Map",
"(",
")",
";",
"var",
"n",
"=",
"this",
".",
"size",
"(",
")",
";",
"var",
"values",
"=",
"this",
".",
"values",
";",
"var",
"keys",
"=",
"this",... | Passes all values & keys in this map to a callback and if it returns a
truthy value then the key and value are placed in the destination map.
@param {Function} callback [description]
@param {Rekord.Map} [dest] [description]
@return {Rekord.Map} [description] | [
"Passes",
"all",
"values",
"&",
"keys",
"in",
"this",
"map",
"to",
"a",
"callback",
"and",
"if",
"it",
"returns",
"a",
"truthy",
"value",
"then",
"the",
"key",
"and",
"value",
"are",
"placed",
"in",
"the",
"destination",
"map",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6208-L6227 | train | |
Rekord/rekord | build/rekord.js | function(comparator)
{
var map = this;
// Sort this partition!
function partition(left, right)
{
var pivot = map.values[ Math.floor((right + left) / 2) ];
var i = left;
var j = right;
while (i <= j)
{
while (comparator( map.values[i], pivot ) < 0)
{
... | javascript | function(comparator)
{
var map = this;
// Sort this partition!
function partition(left, right)
{
var pivot = map.values[ Math.floor((right + left) / 2) ];
var i = left;
var j = right;
while (i <= j)
{
while (comparator( map.values[i], pivot ) < 0)
{
... | [
"function",
"(",
"comparator",
")",
"{",
"var",
"map",
"=",
"this",
";",
"// Sort this partition!",
"function",
"partition",
"(",
"left",
",",
"right",
")",
"{",
"var",
"pivot",
"=",
"map",
".",
"values",
"[",
"Math",
".",
"floor",
"(",
"(",
"right",
"... | Sorts the underlying values & keys given a value compare function.
@param {function} comparator
A function which accepts two values and returns a number used for
sorting. If the first argument is less than the second argument, a
negative number should be returned. If the arguments are equivalent
then 0 should be retu... | [
"Sorts",
"the",
"underlying",
"values",
"&",
"keys",
"given",
"a",
"value",
"compare",
"function",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6267-L6328 | train | |
Rekord/rekord | build/rekord.js | partition | function partition(left, right)
{
var pivot = map.values[ Math.floor((right + left) / 2) ];
var i = left;
var j = right;
while (i <= j)
{
while (comparator( map.values[i], pivot ) < 0)
{
i++;
}
while (comparator( map.values[j], pivot ) > 0)
... | javascript | function partition(left, right)
{
var pivot = map.values[ Math.floor((right + left) / 2) ];
var i = left;
var j = right;
while (i <= j)
{
while (comparator( map.values[i], pivot ) < 0)
{
i++;
}
while (comparator( map.values[j], pivot ) > 0)
... | [
"function",
"partition",
"(",
"left",
",",
"right",
")",
"{",
"var",
"pivot",
"=",
"map",
".",
"values",
"[",
"Math",
".",
"floor",
"(",
"(",
"right",
"+",
"left",
")",
"/",
"2",
")",
"]",
";",
"var",
"i",
"=",
"left",
";",
"var",
"j",
"=",
"... | Sort this partition! | [
"Sort",
"this",
"partition!"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6272-L6299 | train |
Rekord/rekord | build/rekord.js | function()
{
this.indices = {};
for (var i = 0, l = this.keys.length; i < l; i++)
{
this.indices[ this.keys[ i ] ] = i;
}
return this;
} | javascript | function()
{
this.indices = {};
for (var i = 0, l = this.keys.length; i < l; i++)
{
this.indices[ this.keys[ i ] ] = i;
}
return this;
} | [
"function",
"(",
")",
"{",
"this",
".",
"indices",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"keys",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"this",
".",
"indices",
"[",
"this",
... | Rebuilds the index based on the keys.
@return {Rekord.Map} -
The reference to this map. | [
"Rebuilds",
"the",
"index",
"based",
"on",
"the",
"keys",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6336-L6346 | train | |
Rekord/rekord | build/rekord.js | function(out)
{
var target = out || {};
var keys = this.keys;
var values = this.values;
for (var i = 0; i < keys.length; i++)
{
target[ keys[ i ] ] = values[ i ];
}
return target;
} | javascript | function(out)
{
var target = out || {};
var keys = this.keys;
var values = this.values;
for (var i = 0; i < keys.length; i++)
{
target[ keys[ i ] ] = values[ i ];
}
return target;
} | [
"function",
"(",
"out",
")",
"{",
"var",
"target",
"=",
"out",
"||",
"{",
"}",
";",
"var",
"keys",
"=",
"this",
".",
"keys",
";",
"var",
"values",
"=",
"this",
".",
"values",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
... | Builds an object contain the keys and values in this map.
@return {Object} -
The built object. | [
"Builds",
"an",
"object",
"contain",
"the",
"keys",
"and",
"values",
"in",
"this",
"map",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6354-L6366 | train | |
Rekord/rekord | build/rekord.js | function(comparator, nullsFirst)
{
var cmp = comparator ? createComparator( comparator, nullsFirst ) : this.comparator;
return isSorted( cmp, this );
} | javascript | function(comparator, nullsFirst)
{
var cmp = comparator ? createComparator( comparator, nullsFirst ) : this.comparator;
return isSorted( cmp, this );
} | [
"function",
"(",
"comparator",
",",
"nullsFirst",
")",
"{",
"var",
"cmp",
"=",
"comparator",
"?",
"createComparator",
"(",
"comparator",
",",
"nullsFirst",
")",
":",
"this",
".",
"comparator",
";",
"return",
"isSorted",
"(",
"cmp",
",",
"this",
")",
";",
... | Determines if the collection is currently sorted based on the current
comparator of the collection unless a comparator is given
@method
@memberof Rekord.Collection#
@param {ComparatorInput} [comparator] -
The comparator input to convert to a comparison function.
@param {Boolean} [nullsFirst=false] -
When a comparison ... | [
"Determines",
"if",
"the",
"collection",
"is",
"currently",
"sorted",
"based",
"on",
"the",
"current",
"comparator",
"of",
"the",
"collection",
"unless",
"a",
"comparator",
"is",
"given"
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L7610-L7615 | train | |
Rekord/rekord | build/rekord.js | function(comparator, nullsFirst, ignorePrimitive)
{
var cmp = comparator ? createComparator( comparator, nullsFirst ) : this.comparator;
if ( !isSorted( cmp, this ) || ( !ignorePrimitive && !cmp && isPrimitiveArray( this ) ) )
{
AP.sort.call( this, cmp );
this.trigger( Collection.Events.Sort... | javascript | function(comparator, nullsFirst, ignorePrimitive)
{
var cmp = comparator ? createComparator( comparator, nullsFirst ) : this.comparator;
if ( !isSorted( cmp, this ) || ( !ignorePrimitive && !cmp && isPrimitiveArray( this ) ) )
{
AP.sort.call( this, cmp );
this.trigger( Collection.Events.Sort... | [
"function",
"(",
"comparator",
",",
"nullsFirst",
",",
"ignorePrimitive",
")",
"{",
"var",
"cmp",
"=",
"comparator",
"?",
"createComparator",
"(",
"comparator",
",",
"nullsFirst",
")",
":",
"this",
".",
"comparator",
";",
"if",
"(",
"!",
"isSorted",
"(",
"... | Sorts the elements in this collection based on the current comparator
unless a comparator is given. If a comparator is given it will not override
the current comparator, subsequent operations to the collection may trigger
a sort if the collection has a comparator.
@method
@memberof Rekord.Collection#
@param {Comparato... | [
"Sorts",
"the",
"elements",
"in",
"this",
"collection",
"based",
"on",
"the",
"current",
"comparator",
"unless",
"a",
"comparator",
"is",
"given",
".",
"If",
"a",
"comparator",
"is",
"given",
"it",
"will",
"not",
"override",
"the",
"current",
"comparator",
"... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L7639-L7651 | train | |
Rekord/rekord | build/rekord.js | function(values)
{
this.length = 0;
if ( isArray( values ) )
{
AP.push.apply( this, values );
}
else if ( isValue( values ) )
{
AP.push.call( this, values );
}
this.trigger( Collection.Events.Reset, [this] );
this.sort( undefined, undefined, true );
return this;
... | javascript | function(values)
{
this.length = 0;
if ( isArray( values ) )
{
AP.push.apply( this, values );
}
else if ( isValue( values ) )
{
AP.push.call( this, values );
}
this.trigger( Collection.Events.Reset, [this] );
this.sort( undefined, undefined, true );
return this;
... | [
"function",
"(",
"values",
")",
"{",
"this",
".",
"length",
"=",
"0",
";",
"if",
"(",
"isArray",
"(",
"values",
")",
")",
"{",
"AP",
".",
"push",
".",
"apply",
"(",
"this",
",",
"values",
")",
";",
"}",
"else",
"if",
"(",
"isValue",
"(",
"value... | Resets the values in this collection with a new collection of values.
@method
@memberof Rekord.Collection#
@param {Any[]} [values] -
The new array of values in this collection.
@return {Rekord.Collection} -
The reference to this collection.
@emits Rekord.Collection#reset | [
"Resets",
"the",
"values",
"in",
"this",
"collection",
"with",
"a",
"new",
"collection",
"of",
"values",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L7664-L7681 | train | |
Rekord/rekord | build/rekord.js | function(collection, out, equals)
{
var target = out || this.cloneEmpty();
var equality = equals || equalsStrict;
for (var i = 0; i < this.length; i++)
{
var a = this[ i ];
var exists = false;
for (var j = 0; j < collection.length && !exists; j++)
{
exists = equality(... | javascript | function(collection, out, equals)
{
var target = out || this.cloneEmpty();
var equality = equals || equalsStrict;
for (var i = 0; i < this.length; i++)
{
var a = this[ i ];
var exists = false;
for (var j = 0; j < collection.length && !exists; j++)
{
exists = equality(... | [
"function",
"(",
"collection",
",",
"out",
",",
"equals",
")",
"{",
"var",
"target",
"=",
"out",
"||",
"this",
".",
"cloneEmpty",
"(",
")",
";",
"var",
"equality",
"=",
"equals",
"||",
"equalsStrict",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i"... | Returns a collection with elements that exist in this collection but does
not exist in the given collection.
```javascript
var a = Rekord.collect(1, 2, 3, 4);
var b = Rekord.collect(1, 3, 5);
var c = a.subtract( b ); // [2, 4]
```
@method
@memberof Rekord.Collection#
@param {Array} collection -
The array of elements ... | [
"Returns",
"a",
"collection",
"with",
"elements",
"that",
"exist",
"in",
"this",
"collection",
"but",
"does",
"not",
"exist",
"in",
"the",
"given",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L7800-L7822 | train | |
Rekord/rekord | build/rekord.js | function()
{
var values = arguments;
AP.unshift.apply( this, values );
this.trigger( Collection.Events.Adds, [this, AP.slice.apply(values), 0] );
this.sort( undefined, undefined, true );
return this.length;
} | javascript | function()
{
var values = arguments;
AP.unshift.apply( this, values );
this.trigger( Collection.Events.Adds, [this, AP.slice.apply(values), 0] );
this.sort( undefined, undefined, true );
return this.length;
} | [
"function",
"(",
")",
"{",
"var",
"values",
"=",
"arguments",
";",
"AP",
".",
"unshift",
".",
"apply",
"(",
"this",
",",
"values",
")",
";",
"this",
".",
"trigger",
"(",
"Collection",
".",
"Events",
".",
"Adds",
",",
"[",
"this",
",",
"AP",
".",
... | Adds one or more elements to the beginning of this collection - sorting the
collection if a comparator is set on this collection.
```javascript
var a = Rekord.collect(1, 2, 3, 4);
a.unshift( 5, 6, 7 ); // 7
a // [5, 6, 7, 1, 2, 3, 4]
```
@method
@memberof Rekord.Collection#
@param {...Any} value -
The values to add t... | [
"Adds",
"one",
"or",
"more",
"elements",
"to",
"the",
"beginning",
"of",
"this",
"collection",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8036-L8047 | train | |
Rekord/rekord | build/rekord.js | function(values, delaySort)
{
if ( isArray( values ) && values.length )
{
var i = this.length;
AP.push.apply( this, values );
this.trigger( Collection.Events.Adds, [this, values, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
}
retu... | javascript | function(values, delaySort)
{
if ( isArray( values ) && values.length )
{
var i = this.length;
AP.push.apply( this, values );
this.trigger( Collection.Events.Adds, [this, values, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
}
retu... | [
"function",
"(",
"values",
",",
"delaySort",
")",
"{",
"if",
"(",
"isArray",
"(",
"values",
")",
"&&",
"values",
".",
"length",
")",
"{",
"var",
"i",
"=",
"this",
".",
"length",
";",
"AP",
".",
"push",
".",
"apply",
"(",
"this",
",",
"values",
")... | Adds all elements in the given array to this collection - sorting the
collection if a comparator is set on this collection and `delaySort` is
not specified or a true value.
```javascript
var a = Rekord.collect(1, 2, 3, 4);
a.addAll( [5, 6] ); // [1, 2, 3, 4, 5, 6]
```
@method
@memberof Rekord.Collection#
@param {Any[... | [
"Adds",
"all",
"elements",
"in",
"the",
"given",
"array",
"to",
"this",
"collection",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true",
"v... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8071-L8088 | train | |
Rekord/rekord | build/rekord.js | function(i, value, delaySort)
{
AP.splice.call( this, i, 0, value );
this.trigger( Collection.Events.Add, [this, value, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
return this;
} | javascript | function(i, value, delaySort)
{
AP.splice.call( this, i, 0, value );
this.trigger( Collection.Events.Add, [this, value, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
return this;
} | [
"function",
"(",
"i",
",",
"value",
",",
"delaySort",
")",
"{",
"AP",
".",
"splice",
".",
"call",
"(",
"this",
",",
"i",
",",
"0",
",",
"value",
")",
";",
"this",
".",
"trigger",
"(",
"Collection",
".",
"Events",
".",
"Add",
",",
"[",
"this",
"... | Inserts an element into this collection at the given index - sorting the
collection if a comparator is set on this collection and `delaySort` is not
specified or a true value.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.insertAt( 0, 0 ); // [0, 1, 2, 3, 4]
c.insertAt( 2, 1.5 ); // [0, 1, 1.5, 2, 3, 4]
```
@me... | [
"Inserts",
"an",
"element",
"into",
"this",
"collection",
"at",
"the",
"given",
"index",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8115-L8127 | train | |
Rekord/rekord | build/rekord.js | function(delaySort)
{
var removed = AP.pop.apply( this );
var i = this.length;
this.trigger( Collection.Events.Remove, [this, removed, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
return removed;
} | javascript | function(delaySort)
{
var removed = AP.pop.apply( this );
var i = this.length;
this.trigger( Collection.Events.Remove, [this, removed, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
return removed;
} | [
"function",
"(",
"delaySort",
")",
"{",
"var",
"removed",
"=",
"AP",
".",
"pop",
".",
"apply",
"(",
"this",
")",
";",
"var",
"i",
"=",
"this",
".",
"length",
";",
"this",
".",
"trigger",
"(",
"Collection",
".",
"Events",
".",
"Remove",
",",
"[",
... | Removes the last element in this collection and returns it - sorting the
collection if a comparator is set on this collection and `delaySort` is
no specified or a true value.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.pop(); // 4
```
@method
@memberof Rekord.Collection#
@param {Boolean} [delaySort=false] -
W... | [
"Removes",
"the",
"last",
"element",
"in",
"this",
"collection",
"and",
"returns",
"it",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"no",
"specified",
"or",
"a",
"true",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8149-L8162 | train | |
Rekord/rekord | build/rekord.js | function(delaySort)
{
var removed = AP.shift.apply( this );
this.trigger( Collection.Events.Remove, [this, removed, 0] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
return removed;
} | javascript | function(delaySort)
{
var removed = AP.shift.apply( this );
this.trigger( Collection.Events.Remove, [this, removed, 0] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
return removed;
} | [
"function",
"(",
"delaySort",
")",
"{",
"var",
"removed",
"=",
"AP",
".",
"shift",
".",
"apply",
"(",
"this",
")",
";",
"this",
".",
"trigger",
"(",
"Collection",
".",
"Events",
".",
"Remove",
",",
"[",
"this",
",",
"removed",
",",
"0",
"]",
")",
... | Removes the first element in this collection and returns it - sorting the
collection if a comparator is set on this collection and `delaySort` is
no specified or a true value.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.shift(); // 1
```
@method
@memberof Rekord.Collection#
@param {Boolean} [delaySort=false] ... | [
"Removes",
"the",
"first",
"element",
"in",
"this",
"collection",
"and",
"returns",
"it",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"no",
"specified",
"or",
"a",
"true",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8184-L8196 | train | |
Rekord/rekord | build/rekord.js | function(i, delaySort)
{
var removing;
if (i >= 0 && i < this.length)
{
removing = this[ i ];
AP.splice.call( this, i, 1 );
this.trigger( Collection.Events.Remove, [this, removing, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
}
... | javascript | function(i, delaySort)
{
var removing;
if (i >= 0 && i < this.length)
{
removing = this[ i ];
AP.splice.call( this, i, 1 );
this.trigger( Collection.Events.Remove, [this, removing, i] );
if ( !delaySort )
{
this.sort( undefined, undefined, true );
}
}
... | [
"function",
"(",
"i",
",",
"delaySort",
")",
"{",
"var",
"removing",
";",
"if",
"(",
"i",
">=",
"0",
"&&",
"i",
"<",
"this",
".",
"length",
")",
"{",
"removing",
"=",
"this",
"[",
"i",
"]",
";",
"AP",
".",
"splice",
".",
"call",
"(",
"this",
... | Removes the element in this collection at the given index `i` - sorting
the collection if a comparator is set on this collection and `delaySort` is
not specified or a true value.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.removeAt( 1 ); // 2
c.removeAt( 5 ); // undefined
c // [1, 3, 4]
```
@method
@memberof ... | [
"Removes",
"the",
"element",
"in",
"this",
"collection",
"at",
"the",
"given",
"index",
"i",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"tr... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8222-L8240 | train | |
Rekord/rekord | build/rekord.js | function(value, delaySort, equals)
{
var i = this.indexOf( value, equals );
var element = this[ i ];
if ( i !== -1 )
{
this.removeAt( i, delaySort );
}
return element;
} | javascript | function(value, delaySort, equals)
{
var i = this.indexOf( value, equals );
var element = this[ i ];
if ( i !== -1 )
{
this.removeAt( i, delaySort );
}
return element;
} | [
"function",
"(",
"value",
",",
"delaySort",
",",
"equals",
")",
"{",
"var",
"i",
"=",
"this",
".",
"indexOf",
"(",
"value",
",",
"equals",
")",
";",
"var",
"element",
"=",
"this",
"[",
"i",
"]",
";",
"if",
"(",
"i",
"!==",
"-",
"1",
")",
"{",
... | Removes the given value from this collection if it exists - sorting the
collection if a comparator is set on this collection and `delaySort` is not
specified or a true value.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.remove( 1 ); // 1
c.remove( 5 ); // undefined
c // [2, 3, 4]
```
@method
@memberof Rekord.C... | [
"Removes",
"the",
"given",
"value",
"from",
"this",
"collection",
"if",
"it",
"exists",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8269-L8280 | train | |
Rekord/rekord | build/rekord.js | function(values, delaySort, equals)
{
var removed = [];
var removedIndices = [];
if ( isArray( values ) && values.length )
{
for (var i = 0; i < values.length; i++)
{
var value = values[ i ];
var k = this.indexOf( value, equals );
if ( k !== -1 )
{
... | javascript | function(values, delaySort, equals)
{
var removed = [];
var removedIndices = [];
if ( isArray( values ) && values.length )
{
for (var i = 0; i < values.length; i++)
{
var value = values[ i ];
var k = this.indexOf( value, equals );
if ( k !== -1 )
{
... | [
"function",
"(",
"values",
",",
"delaySort",
",",
"equals",
")",
"{",
"var",
"removed",
"=",
"[",
"]",
";",
"var",
"removedIndices",
"=",
"[",
"]",
";",
"if",
"(",
"isArray",
"(",
"values",
")",
"&&",
"values",
".",
"length",
")",
"{",
"for",
"(",
... | Removes the given values from this collection - sorting the collection if
a comparator is set on this collection and `delaySort` is not specified or
a true value.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.removeAll( [1, 5] ); // [1]
c // [2, 3, 4]
```
@method
@memberof Rekord.Collection#
@param {Any[]} valu... | [
"Removes",
"the",
"given",
"values",
"from",
"this",
"collection",
"-",
"sorting",
"the",
"collection",
"if",
"a",
"comparator",
"is",
"set",
"on",
"this",
"collection",
"and",
"delaySort",
"is",
"not",
"specified",
"or",
"a",
"true",
"value",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8308-L8343 | train | |
Rekord/rekord | build/rekord.js | function()
{
if ( AP.reverse )
{
AP.reverse.apply( this );
}
else
{
reverse( this );
}
this.trigger( Collection.Events.Updates, [this] );
return this;
} | javascript | function()
{
if ( AP.reverse )
{
AP.reverse.apply( this );
}
else
{
reverse( this );
}
this.trigger( Collection.Events.Updates, [this] );
return this;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"AP",
".",
"reverse",
")",
"{",
"AP",
".",
"reverse",
".",
"apply",
"(",
"this",
")",
";",
"}",
"else",
"{",
"reverse",
"(",
"this",
")",
";",
"}",
"this",
".",
"trigger",
"(",
"Collection",
".",
"Events",
... | Reverses the order of elements in this collection.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.reverse(); // [4, 3, 2, 1]
```
@method
@memberof Rekord.Collection#
@return {Rekord.Collection} -
The reference to this collection.
@emits Rekord.Collection#updates | [
"Reverses",
"the",
"order",
"of",
"elements",
"in",
"this",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8468-L8482 | train | |
Rekord/rekord | build/rekord.js | function(value, equals)
{
var equality = equals || equalsStrict;
for (var i = 0; i < this.length; i++)
{
if ( equality( value, this[ i ] ) )
{
return i;
}
}
return -1;
} | javascript | function(value, equals)
{
var equality = equals || equalsStrict;
for (var i = 0; i < this.length; i++)
{
if ( equality( value, this[ i ] ) )
{
return i;
}
}
return -1;
} | [
"function",
"(",
"value",
",",
"equals",
")",
"{",
"var",
"equality",
"=",
"equals",
"||",
"equalsStrict",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"equality",
"(",
"value",... | Returns the index of the given element in this collection or returns -1
if the element doesn't exist in this collection.
```javascript
var c = Rekord.collect(1, 2, 3, 4);
c.indexOf( 1 ); // 0
c.indexOf( 2 ); // 1
c.indexOf( 5 ); // -1
```
@method
@memberof Rekord.Collection#
@param {Any} value -
The value to search f... | [
"Returns",
"the",
"index",
"of",
"the",
"given",
"element",
"in",
"this",
"collection",
"or",
"returns",
"-",
"1",
"if",
"the",
"element",
"doesn",
"t",
"exist",
"in",
"this",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8507-L8520 | train | |
Rekord/rekord | build/rekord.js | function(comparator, startingValue)
{
var cmp = createComparator( comparator || this.comparator, false );
var min = startingValue;
for (var i = 0; i < this.length; i++)
{
if ( cmp( min, this[i] ) > 0 )
{
min = this[i];
}
}
return min;
} | javascript | function(comparator, startingValue)
{
var cmp = createComparator( comparator || this.comparator, false );
var min = startingValue;
for (var i = 0; i < this.length; i++)
{
if ( cmp( min, this[i] ) > 0 )
{
min = this[i];
}
}
return min;
} | [
"function",
"(",
"comparator",
",",
"startingValue",
")",
"{",
"var",
"cmp",
"=",
"createComparator",
"(",
"comparator",
"||",
"this",
".",
"comparator",
",",
"false",
")",
";",
"var",
"min",
"=",
"startingValue",
";",
"for",
"(",
"var",
"i",
"=",
"0",
... | Returns the element with the minimum value given a comparator.
```javascript
var c = Rekord.collect({age: 4}, {age: 5}, {age: 6}, {age: 3});
c.minModel('age'); // {age: 3}
c.minModel('-age'); // {age: 6}
```
@method
@memberof Rekord.Collection#
@param {comparatorInput} comparator -
The comparator which calculates the... | [
"Returns",
"the",
"element",
"with",
"the",
"minimum",
"value",
"given",
"a",
"comparator",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8543-L8557 | train | |
Rekord/rekord | build/rekord.js | function(comparator, startingValue)
{
var cmp = createComparator( comparator || this.comparator, true );
var max = startingValue;
for (var i = 0; i < this.length; i++)
{
if ( cmp( max, this[i] ) < 0 )
{
max = this[i];
}
}
return max;
} | javascript | function(comparator, startingValue)
{
var cmp = createComparator( comparator || this.comparator, true );
var max = startingValue;
for (var i = 0; i < this.length; i++)
{
if ( cmp( max, this[i] ) < 0 )
{
max = this[i];
}
}
return max;
} | [
"function",
"(",
"comparator",
",",
"startingValue",
")",
"{",
"var",
"cmp",
"=",
"createComparator",
"(",
"comparator",
"||",
"this",
".",
"comparator",
",",
"true",
")",
";",
"var",
"max",
"=",
"startingValue",
";",
"for",
"(",
"var",
"i",
"=",
"0",
... | Returns the element with the maximum value given a comparator.
```javascript
var c = Rekord.collect({age: 4}, {age: 5}, {age: 6}, {age: 3});
c.maxModel('age'); // {age: 6}
c.maxModel('-age'); // {age: 3}
```
@method
@memberof Rekord.Collection#
@param {comparatorInput} comparator -
The comparator which calculates the... | [
"Returns",
"the",
"element",
"with",
"the",
"maximum",
"value",
"given",
"a",
"comparator",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8580-L8594 | train | |
Rekord/rekord | build/rekord.js | function(properties, startingValue, compareFunction)
{
var comparator = compareFunction || compare;
var resolver = createPropertyResolver( properties );
var min = startingValue;
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( comparator( min, resolv... | javascript | function(properties, startingValue, compareFunction)
{
var comparator = compareFunction || compare;
var resolver = createPropertyResolver( properties );
var min = startingValue;
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( comparator( min, resolv... | [
"function",
"(",
"properties",
",",
"startingValue",
",",
"compareFunction",
")",
"{",
"var",
"comparator",
"=",
"compareFunction",
"||",
"compare",
";",
"var",
"resolver",
"=",
"createPropertyResolver",
"(",
"properties",
")",
";",
"var",
"min",
"=",
"startingV... | Returns the minimum value for the given property expression out of all the
elements this collection.
```javascript
var c = Rekord.collect({age: 6}, {age: 5}, {notage: 5});
c.min('age'); // 5
```
@method
@memberof Rekord.Collection#
@param {propertyResolverInput} [properties] -
The expression which takes an element i... | [
"Returns",
"the",
"minimum",
"value",
"for",
"the",
"given",
"property",
"expression",
"out",
"of",
"all",
"the",
"elements",
"this",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8621-L8638 | train | |
Rekord/rekord | build/rekord.js | function(properties, startingValue, compareFunction)
{
var comparator = compareFunction || compare;
var resolver = createPropertyResolver( properties );
var max = startingValue;
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( comparator( max, resolv... | javascript | function(properties, startingValue, compareFunction)
{
var comparator = compareFunction || compare;
var resolver = createPropertyResolver( properties );
var max = startingValue;
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( comparator( max, resolv... | [
"function",
"(",
"properties",
",",
"startingValue",
",",
"compareFunction",
")",
"{",
"var",
"comparator",
"=",
"compareFunction",
"||",
"compare",
";",
"var",
"resolver",
"=",
"createPropertyResolver",
"(",
"properties",
")",
";",
"var",
"max",
"=",
"startingV... | Returns the maximum value for the given property expression out of all the
elements this collection.
```javascript
var c = Rekord.collect({age: 6}, {age: 5}, {notage: 5});
c.max('age'); // 6
```
@method
@memberof Rekord.Collection#
@param {propertyResolverInput} [properties] -
The expression which takes an element i... | [
"Returns",
"the",
"maximum",
"value",
"for",
"the",
"given",
"property",
"expression",
"out",
"of",
"all",
"the",
"elements",
"this",
"collection",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8665-L8682 | train | |
Rekord/rekord | build/rekord.js | function(whereProperties, whereValue, whereEquals)
{
var where = createWhere( whereProperties, whereValue, whereEquals );
for (var i = 0; i < this.length; i++)
{
var model = this[ i ];
if ( where( model ) )
{
return model;
}
}
return null;
} | javascript | function(whereProperties, whereValue, whereEquals)
{
var where = createWhere( whereProperties, whereValue, whereEquals );
for (var i = 0; i < this.length; i++)
{
var model = this[ i ];
if ( where( model ) )
{
return model;
}
}
return null;
} | [
"function",
"(",
"whereProperties",
",",
"whereValue",
",",
"whereEquals",
")",
"{",
"var",
"where",
"=",
"createWhere",
"(",
"whereProperties",
",",
"whereValue",
",",
"whereEquals",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
"."... | Returns the first element where the given expression is true.
```javascript
var c = Rekord.collect([{x: 5}, {y: 6}, {y: 6, age: 8}, {z: 7}]);
c.firstWhere('y', 6); // {x: 6}
c.firstWhere(); // {x: 5}
```
@method
@memberof Rekord.Collection#
@param {whereInput} [whereProperties] -
The expression used to create a funct... | [
"Returns",
"the",
"first",
"element",
"where",
"the",
"given",
"expression",
"is",
"true",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8708-L8723 | train | |
Rekord/rekord | build/rekord.js | function(properties)
{
var resolver = createPropertyResolver( properties );
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( isValue( resolved ) )
{
return resolved;
}
}
} | javascript | function(properties)
{
var resolver = createPropertyResolver( properties );
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( isValue( resolved ) )
{
return resolved;
}
}
} | [
"function",
"(",
"properties",
")",
"{",
"var",
"resolver",
"=",
"createPropertyResolver",
"(",
"properties",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"resolved",
"=",
"resolve... | Returns the first non-null value in this collection given a property
expression. If no non-null values exist for the given property expression,
then undefined will be returned.
```javascript
var c = Rekord.collect([{x: 5}, {y: 6}, {y: 4}, {z: 7}]);
c.first('y'); // 6
c.first(); // {x: 5}
```
@method
@memberof Rekord.... | [
"Returns",
"the",
"first",
"non",
"-",
"null",
"value",
"in",
"this",
"collection",
"given",
"a",
"property",
"expression",
".",
"If",
"no",
"non",
"-",
"null",
"values",
"exist",
"for",
"the",
"given",
"property",
"expression",
"then",
"undefined",
"will",
... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8744-L8757 | train | |
Rekord/rekord | build/rekord.js | function(properties, value, equals)
{
var where = createWhere( properties, value, equals );
for (var i = this.length - 1; i >= 0; i--)
{
var model = this[ i ];
if ( where( model ) )
{
return model;
}
}
return null;
} | javascript | function(properties, value, equals)
{
var where = createWhere( properties, value, equals );
for (var i = this.length - 1; i >= 0; i--)
{
var model = this[ i ];
if ( where( model ) )
{
return model;
}
}
return null;
} | [
"function",
"(",
"properties",
",",
"value",
",",
"equals",
")",
"{",
"var",
"where",
"=",
"createWhere",
"(",
"properties",
",",
"value",
",",
"equals",
")",
";",
"for",
"(",
"var",
"i",
"=",
"this",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
... | Returns the last element where the given expression is true.
```javascript
var c = Rekord.collect([{x: 5}, {y: 6}, {y: 6, age: 8}, {z: 7}]);
c.lastWhere('y', 6); // {x: 6, age: 8}
c.lastWhere(); // {z: 7}
```
@method
@memberof Rekord.Collection#
@param {whereInput} [properties] -
The expression used to create a funct... | [
"Returns",
"the",
"last",
"element",
"where",
"the",
"given",
"expression",
"is",
"true",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8783-L8798 | train | |
Rekord/rekord | build/rekord.js | function(resolver, validator, process, getResult)
{
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( validator( resolved ) )
{
process( resolved );
}
}
return getResult();
} | javascript | function(resolver, validator, process, getResult)
{
for (var i = 0; i < this.length; i++)
{
var resolved = resolver( this[ i ] );
if ( validator( resolved ) )
{
process( resolved );
}
}
return getResult();
} | [
"function",
"(",
"resolver",
",",
"validator",
",",
"process",
",",
"getResult",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"resolved",
"=",
"resolver",
"(",
"this",
"[",
"i"... | Iterates over all elements in this collection and passes them through the
`resolver` function. The returned value is passed through the `validator`
function and if that returns true the resolved value is passed through the
`process` function. After iteration, the `getResult` function is executed
and the returned value ... | [
"Iterates",
"over",
"all",
"elements",
"in",
"this",
"collection",
"and",
"passes",
"them",
"through",
"the",
"resolver",
"function",
".",
"The",
"returned",
"value",
"is",
"passed",
"through",
"the",
"validator",
"function",
"and",
"if",
"that",
"returns",
"t... | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8857-L8870 | train | |
Rekord/rekord | build/rekord.js | function(numbers)
{
var resolver = createNumberResolver( numbers );
var result = 0;
var total = 0;
function process(x)
{
result += x;
total++;
}
function getResult()
{
return total === 0 ? 0 : result / total;
}
return this.aggregate( resolver, isNumber, pro... | javascript | function(numbers)
{
var resolver = createNumberResolver( numbers );
var result = 0;
var total = 0;
function process(x)
{
result += x;
total++;
}
function getResult()
{
return total === 0 ? 0 : result / total;
}
return this.aggregate( resolver, isNumber, pro... | [
"function",
"(",
"numbers",
")",
"{",
"var",
"resolver",
"=",
"createNumberResolver",
"(",
"numbers",
")",
";",
"var",
"result",
"=",
"0",
";",
"var",
"total",
"=",
"0",
";",
"function",
"process",
"(",
"x",
")",
"{",
"result",
"+=",
"x",
";",
"total... | Averages all numbers resolved from the given property expression and
returns the result.
```javascript
var c = Rekord.collect([2, 3, 4]);
c.avg(); // 3
var d = Rekord.collect([{age: 5}, {age: 4}, {age: 2}]);
d.avg('age'); // 3.66666
```
@method
@memberof Rekord.Collection#
@param {propertyResolverInput} [numbers]
The... | [
"Averages",
"all",
"numbers",
"resolved",
"from",
"the",
"given",
"property",
"expression",
"and",
"returns",
"the",
"result",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L8928-L8946 | 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.