id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1 value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,200 | Jam3/ae-to-json | src/util/getNonObjectValues.js | getTypeOf | function getTypeOf(item) {
var type = null;
if(item) {
var strValue = item.toString();
var isObject = /\[object/.test(strValue);
var isFunction = /function/.test(strValue);
var isArray = Array.isArray(item);
if(isArray) {
type = Array;
} else if(isFunction) {
type = Function;
} else if(isObject) {
type = Object;
} else {
type = null;
}
} else {
type = null;
}
return type;
} | javascript | function getTypeOf(item) {
var type = null;
if(item) {
var strValue = item.toString();
var isObject = /\[object/.test(strValue);
var isFunction = /function/.test(strValue);
var isArray = Array.isArray(item);
if(isArray) {
type = Array;
} else if(isFunction) {
type = Function;
} else if(isObject) {
type = Object;
} else {
type = null;
}
} else {
type = null;
}
return type;
} | [
"function",
"getTypeOf",
"(",
"item",
")",
"{",
"var",
"type",
"=",
"null",
";",
"if",
"(",
"item",
")",
"{",
"var",
"strValue",
"=",
"item",
".",
"toString",
"(",
")",
";",
"var",
"isObject",
"=",
"/",
"\\[object",
"/",
".",
"test",
"(",
"strValue... | for some reason typeof is breaking in AE | [
"for",
"some",
"reason",
"typeof",
"is",
"breaking",
"in",
"AE"
] | 9c7cf53287c90b9d3d7c72c302a076badf589758 | https://github.com/Jam3/ae-to-json/blob/9c7cf53287c90b9d3d7c72c302a076badf589758/src/util/getNonObjectValues.js#L40-L63 |
30,201 | timbeadle/tv4-reporter | lib/reporter.js | extractSchemaLabel | function extractSchemaLabel(schema, limit) {
limit = typeof limit === 'undefined' ? strimLimit : limit;
var label = '';
if (schema.id) {
label = style.accent(schema.id);
}
if (schema.title) {
label += style.accent(label ? ' (' + schema.title + ')' : style.accent(schema.title));
}
if (!label) {
if (schema.description) {
label = style.accent('<no id>') + ' ' + valueStrim(schema.description, limit);
}
else {
label = style.accent('<no id>') + ' ' + valueStrim(schema, limit);
}
}
return label;
} | javascript | function extractSchemaLabel(schema, limit) {
limit = typeof limit === 'undefined' ? strimLimit : limit;
var label = '';
if (schema.id) {
label = style.accent(schema.id);
}
if (schema.title) {
label += style.accent(label ? ' (' + schema.title + ')' : style.accent(schema.title));
}
if (!label) {
if (schema.description) {
label = style.accent('<no id>') + ' ' + valueStrim(schema.description, limit);
}
else {
label = style.accent('<no id>') + ' ' + valueStrim(schema, limit);
}
}
return label;
} | [
"function",
"extractSchemaLabel",
"(",
"schema",
",",
"limit",
")",
"{",
"limit",
"=",
"typeof",
"limit",
"===",
"'undefined'",
"?",
"strimLimit",
":",
"limit",
";",
"var",
"label",
"=",
"''",
";",
"if",
"(",
"schema",
".",
"id",
")",
"{",
"label",
"="... | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - best-effort | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"... | d489eaa4d4f16d2ac6256785eca2c40031980c1e | https://github.com/timbeadle/tv4-reporter/blob/d489eaa4d4f16d2ac6256785eca2c40031980c1e/lib/reporter.js#L118-L137 |
30,202 | timbeadle/tv4-reporter | lib/reporter.js | extractCTXLabel | function extractCTXLabel(test, limit) {
limit = typeof limit === 'undefined' ? strimLimit : limit;
var label;
if (test.label) {
label = style.accent(test.label);
}
if (!label) {
label = style.accent('<no label>') + ' ' + valueStrim(test.value, limit);
}
return label;
} | javascript | function extractCTXLabel(test, limit) {
limit = typeof limit === 'undefined' ? strimLimit : limit;
var label;
if (test.label) {
label = style.accent(test.label);
}
if (!label) {
label = style.accent('<no label>') + ' ' + valueStrim(test.value, limit);
}
return label;
} | [
"function",
"extractCTXLabel",
"(",
"test",
",",
"limit",
")",
"{",
"limit",
"=",
"typeof",
"limit",
"===",
"'undefined'",
"?",
"strimLimit",
":",
"limit",
";",
"var",
"label",
";",
"if",
"(",
"test",
".",
"label",
")",
"{",
"label",
"=",
"style",
".",... | best-effort | [
"best",
"-",
"effort"
] | d489eaa4d4f16d2ac6256785eca2c40031980c1e | https://github.com/timbeadle/tv4-reporter/blob/d489eaa4d4f16d2ac6256785eca2c40031980c1e/lib/reporter.js#L140-L150 |
30,203 | YR/time | index.js | init | function init() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
dayStartsAt = options.dayStartsAt || DEFAULT_DAY_STARTS_AT;
nightStartsAt = options.nightStartsAt || DEFAULT_NIGHT_STARTS_AT;
} | javascript | function init() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
dayStartsAt = options.dayStartsAt || DEFAULT_DAY_STARTS_AT;
nightStartsAt = options.nightStartsAt || DEFAULT_NIGHT_STARTS_AT;
} | [
"function",
"init",
"(",
")",
"{",
"var",
"options",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"dayStartsAt",
"=",
"options",
".",
"dayStartsA... | Initialize with defaults
@param {Object} [options]
- {Number} dayStartsAt
- {Number} nightStartsAt
- {Array} parseKeys | [
"Initialize",
"with",
"defaults"
] | d5507b8edc0ba1c828256c0d732b8e51033ad82d | https://github.com/YR/time/blob/d5507b8edc0ba1c828256c0d732b8e51033ad82d/index.js#L50-L55 |
30,204 | YR/time | index.js | clientNow | function clientNow() {
var d = new Date();
var offset = -1 * d.getTimezoneOffset();
d.setUTCMinutes(d.getUTCMinutes() + offset);
return d.toISOString().replace('Z', minutesToOffsetString(offset));
} | javascript | function clientNow() {
var d = new Date();
var offset = -1 * d.getTimezoneOffset();
d.setUTCMinutes(d.getUTCMinutes() + offset);
return d.toISOString().replace('Z', minutesToOffsetString(offset));
} | [
"function",
"clientNow",
"(",
")",
"{",
"var",
"d",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"offset",
"=",
"-",
"1",
"*",
"d",
".",
"getTimezoneOffset",
"(",
")",
";",
"d",
".",
"setUTCMinutes",
"(",
"d",
".",
"getUTCMinutes",
"(",
")",
"+",
"o... | Retrieve timestring for client "now"
@returns {String} | [
"Retrieve",
"timestring",
"for",
"client",
"now"
] | d5507b8edc0ba1c828256c0d732b8e51033ad82d | https://github.com/YR/time/blob/d5507b8edc0ba1c828256c0d732b8e51033ad82d/index.js#L798-L804 |
30,205 | YR/time | index.js | update | function update(instance) {
instance.isValid = isValid(instance._date);
instance.timeString = instance.toString();
return instance;
} | javascript | function update(instance) {
instance.isValid = isValid(instance._date);
instance.timeString = instance.toString();
return instance;
} | [
"function",
"update",
"(",
"instance",
")",
"{",
"instance",
".",
"isValid",
"=",
"isValid",
"(",
"instance",
".",
"_date",
")",
";",
"instance",
".",
"timeString",
"=",
"instance",
".",
"toString",
"(",
")",
";",
"return",
"instance",
";",
"}"
] | Update 'instance' state
@param {Time} instance
@returns {Time} | [
"Update",
"instance",
"state"
] | d5507b8edc0ba1c828256c0d732b8e51033ad82d | https://github.com/YR/time/blob/d5507b8edc0ba1c828256c0d732b8e51033ad82d/index.js#L811-L815 |
30,206 | YR/time | index.js | isValid | function isValid(date) {
return Object.prototype.toString.call(date) == '[object Date]' && !isNaN(date.getTime());
} | javascript | function isValid(date) {
return Object.prototype.toString.call(date) == '[object Date]' && !isNaN(date.getTime());
} | [
"function",
"isValid",
"(",
"date",
")",
"{",
"return",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"date",
")",
"==",
"'[object Date]'",
"&&",
"!",
"isNaN",
"(",
"date",
".",
"getTime",
"(",
")",
")",
";",
"}"
] | Validate 'date' object
@param {Date} date
@returns {Boolean} | [
"Validate",
"date",
"object"
] | d5507b8edc0ba1c828256c0d732b8e51033ad82d | https://github.com/YR/time/blob/d5507b8edc0ba1c828256c0d732b8e51033ad82d/index.js#L867-L869 |
30,207 | YR/time | index.js | isTime | function isTime(time) {
return time != null && time._manipulate != null && time._date != null;
} | javascript | function isTime(time) {
return time != null && time._manipulate != null && time._date != null;
} | [
"function",
"isTime",
"(",
"time",
")",
"{",
"return",
"time",
"!=",
"null",
"&&",
"time",
".",
"_manipulate",
"!=",
"null",
"&&",
"time",
".",
"_date",
"!=",
"null",
";",
"}"
] | Determine if 'time' is a Time instance
@param {Time} time
@returns {Boolean} | [
"Determine",
"if",
"time",
"is",
"a",
"Time",
"instance"
] | d5507b8edc0ba1c828256c0d732b8e51033ad82d | https://github.com/YR/time/blob/d5507b8edc0ba1c828256c0d732b8e51033ad82d/index.js#L876-L878 |
30,208 | YR/time | index.js | pad | function pad(value, length) {
value = String(value);
length = length || 2;
while (value.length < length) {
value = '0' + value;
}
return value;
} | javascript | function pad(value, length) {
value = String(value);
length = length || 2;
while (value.length < length) {
value = '0' + value;
}
return value;
} | [
"function",
"pad",
"(",
"value",
",",
"length",
")",
"{",
"value",
"=",
"String",
"(",
"value",
")",
";",
"length",
"=",
"length",
"||",
"2",
";",
"while",
"(",
"value",
".",
"length",
"<",
"length",
")",
"{",
"value",
"=",
"'0'",
"+",
"value",
"... | Pad 'value' with zeros up to desired 'length'
@param {String|Number} value
@param {Number} [length]
@returns {String} | [
"Pad",
"value",
"with",
"zeros",
"up",
"to",
"desired",
"length"
] | d5507b8edc0ba1c828256c0d732b8e51033ad82d | https://github.com/YR/time/blob/d5507b8edc0ba1c828256c0d732b8e51033ad82d/index.js#L896-L905 |
30,209 | YR/time | index.js | minutesToOffsetString | function minutesToOffsetString(minutes) {
var t = String(Math.abs(minutes / 60)).split('.');
var H = pad(t[0]);
var m = t[1] ? parseInt(t[1], 10) * 0.6 : 0;
var sign = minutes < 0 ? '-' : '+';
return '' + sign + H + ':' + pad(m);
} | javascript | function minutesToOffsetString(minutes) {
var t = String(Math.abs(minutes / 60)).split('.');
var H = pad(t[0]);
var m = t[1] ? parseInt(t[1], 10) * 0.6 : 0;
var sign = minutes < 0 ? '-' : '+';
return '' + sign + H + ':' + pad(m);
} | [
"function",
"minutesToOffsetString",
"(",
"minutes",
")",
"{",
"var",
"t",
"=",
"String",
"(",
"Math",
".",
"abs",
"(",
"minutes",
"/",
"60",
")",
")",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"H",
"=",
"pad",
"(",
"t",
"[",
"0",
"]",
")",
";... | Convert 'minutes' to offset string
@param {Number} minutes
@returns {String} | [
"Convert",
"minutes",
"to",
"offset",
"string"
] | d5507b8edc0ba1c828256c0d732b8e51033ad82d | https://github.com/YR/time/blob/d5507b8edc0ba1c828256c0d732b8e51033ad82d/index.js#L912-L919 |
30,210 | ryanwalters/sticky-events | sticky-events.js | addSentinels | function addSentinels(container, className, stickySelector = STICKY_SELECTOR) {
return Array.from(container.querySelectorAll(stickySelector)).map((stickyElement) => {
const sentinel = document.createElement('div');
const stickyParent = stickyElement.parentElement;
// Apply styles to the sticky element
stickyElement.style.cssText = `
position: -webkit-sticky;
position: sticky;
`;
// Apply default sentinel styles
sentinel.classList.add(ClassName.SENTINEL, className);
Object.assign(sentinel.style,{
left: 0,
position: 'absolute',
right: 0,
visibility: 'hidden',
});
switch (className) {
case ClassName.SENTINEL_TOP: {
stickyParent.insertBefore(sentinel, stickyElement);
// Apply styles specific to the top sentinel
Object.assign(
sentinel.style,
getSentinelPosition(stickyElement, sentinel, className),
{ position: 'relative' },
);
break;
}
case ClassName.SENTINEL_BOTTOM: {
stickyParent.appendChild(sentinel);
// Apply styles specific to the bottom sentinel
Object.assign(sentinel.style, getSentinelPosition(stickyElement, sentinel, className));
break;
}
}
return sentinel;
});
} | javascript | function addSentinels(container, className, stickySelector = STICKY_SELECTOR) {
return Array.from(container.querySelectorAll(stickySelector)).map((stickyElement) => {
const sentinel = document.createElement('div');
const stickyParent = stickyElement.parentElement;
// Apply styles to the sticky element
stickyElement.style.cssText = `
position: -webkit-sticky;
position: sticky;
`;
// Apply default sentinel styles
sentinel.classList.add(ClassName.SENTINEL, className);
Object.assign(sentinel.style,{
left: 0,
position: 'absolute',
right: 0,
visibility: 'hidden',
});
switch (className) {
case ClassName.SENTINEL_TOP: {
stickyParent.insertBefore(sentinel, stickyElement);
// Apply styles specific to the top sentinel
Object.assign(
sentinel.style,
getSentinelPosition(stickyElement, sentinel, className),
{ position: 'relative' },
);
break;
}
case ClassName.SENTINEL_BOTTOM: {
stickyParent.appendChild(sentinel);
// Apply styles specific to the bottom sentinel
Object.assign(sentinel.style, getSentinelPosition(stickyElement, sentinel, className));
break;
}
}
return sentinel;
});
} | [
"function",
"addSentinels",
"(",
"container",
",",
"className",
",",
"stickySelector",
"=",
"STICKY_SELECTOR",
")",
"{",
"return",
"Array",
".",
"from",
"(",
"container",
".",
"querySelectorAll",
"(",
"stickySelector",
")",
")",
".",
"map",
"(",
"(",
"stickyEl... | Add sticky sentinels
@param {Element|HTMLDocument} container
@param {String} className
@param {string} stickySelector The CSS selector applied to the sticky DOM elements
@returns {Array<Element>} | [
"Add",
"sticky",
"sentinels"
] | 39a7a2be10ccc7c51f98231377a57ccafa23f35d | https://github.com/ryanwalters/sticky-events/blob/39a7a2be10ccc7c51f98231377a57ccafa23f35d/sticky-events.js#L230-L281 |
30,211 | ryanwalters/sticky-events | sticky-events.js | getSentinelPosition | function getSentinelPosition(stickyElement, sentinel, className) {
const stickyStyle = window.getComputedStyle(stickyElement);
const parentStyle = window.getComputedStyle(stickyElement.parentElement);
switch (className) {
case ClassName.SENTINEL_TOP:
return {
top: `calc(${stickyStyle.getPropertyValue('top')} * -1)`,
height: 0,
};
case ClassName.SENTINEL_BOTTOM:
const parentPadding = parseInt(parentStyle.paddingTop);
return {
bottom: stickyStyle.top,
height: `${stickyElement.getBoundingClientRect().height + parentPadding}px`,
};
}
} | javascript | function getSentinelPosition(stickyElement, sentinel, className) {
const stickyStyle = window.getComputedStyle(stickyElement);
const parentStyle = window.getComputedStyle(stickyElement.parentElement);
switch (className) {
case ClassName.SENTINEL_TOP:
return {
top: `calc(${stickyStyle.getPropertyValue('top')} * -1)`,
height: 0,
};
case ClassName.SENTINEL_BOTTOM:
const parentPadding = parseInt(parentStyle.paddingTop);
return {
bottom: stickyStyle.top,
height: `${stickyElement.getBoundingClientRect().height + parentPadding}px`,
};
}
} | [
"function",
"getSentinelPosition",
"(",
"stickyElement",
",",
"sentinel",
",",
"className",
")",
"{",
"const",
"stickyStyle",
"=",
"window",
".",
"getComputedStyle",
"(",
"stickyElement",
")",
";",
"const",
"parentStyle",
"=",
"window",
".",
"getComputedStyle",
"(... | Determine the position of the sentinel
@param {Element|Node} stickyElement
@param {Element|Node} sentinel
@param {String} className
@returns {Object} | [
"Determine",
"the",
"position",
"of",
"the",
"sentinel"
] | 39a7a2be10ccc7c51f98231377a57ccafa23f35d | https://github.com/ryanwalters/sticky-events/blob/39a7a2be10ccc7c51f98231377a57ccafa23f35d/sticky-events.js#L293-L312 |
30,212 | ryanwalters/sticky-events | sticky-events.js | isSticking | function isSticking(stickyElement) {
const topSentinel = stickyElement.previousElementSibling;
const stickyOffset = stickyElement.getBoundingClientRect().top;
const topSentinelOffset = topSentinel.getBoundingClientRect().top;
const difference = Math.round(Math.abs(stickyOffset - topSentinelOffset));
const topSentinelTopPosition = Math.abs(parseInt(window.getComputedStyle(topSentinel).getPropertyValue('top')));
return difference !== topSentinelTopPosition;
} | javascript | function isSticking(stickyElement) {
const topSentinel = stickyElement.previousElementSibling;
const stickyOffset = stickyElement.getBoundingClientRect().top;
const topSentinelOffset = topSentinel.getBoundingClientRect().top;
const difference = Math.round(Math.abs(stickyOffset - topSentinelOffset));
const topSentinelTopPosition = Math.abs(parseInt(window.getComputedStyle(topSentinel).getPropertyValue('top')));
return difference !== topSentinelTopPosition;
} | [
"function",
"isSticking",
"(",
"stickyElement",
")",
"{",
"const",
"topSentinel",
"=",
"stickyElement",
".",
"previousElementSibling",
";",
"const",
"stickyOffset",
"=",
"stickyElement",
".",
"getBoundingClientRect",
"(",
")",
".",
"top",
";",
"const",
"topSentinelO... | Determine if the sticky element is currently sticking in the browser
@param {Element} stickyElement
@returns {boolean} | [
"Determine",
"if",
"the",
"sticky",
"element",
"is",
"currently",
"sticking",
"in",
"the",
"browser"
] | 39a7a2be10ccc7c51f98231377a57ccafa23f35d | https://github.com/ryanwalters/sticky-events/blob/39a7a2be10ccc7c51f98231377a57ccafa23f35d/sticky-events.js#L322-L332 |
30,213 | intelie/immutable-js-diff | src/lcs.js | computeLcsMatrix | function computeLcsMatrix(xs, ys) {
var n = xs.size||0;
var m = ys.size||0;
var a = makeMatrix(n + 1, m + 1, 0);
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
if (Immutable.is(xs.get(i), ys.get(j))) {
a[i + 1][j + 1] = a[i][j] + 1;
}
else {
a[i + 1][j + 1] = Math.max(a[i + 1][j], a[i][j + 1]);
}
}
}
return a;
} | javascript | function computeLcsMatrix(xs, ys) {
var n = xs.size||0;
var m = ys.size||0;
var a = makeMatrix(n + 1, m + 1, 0);
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
if (Immutable.is(xs.get(i), ys.get(j))) {
a[i + 1][j + 1] = a[i][j] + 1;
}
else {
a[i + 1][j + 1] = Math.max(a[i + 1][j], a[i][j + 1]);
}
}
}
return a;
} | [
"function",
"computeLcsMatrix",
"(",
"xs",
",",
"ys",
")",
"{",
"var",
"n",
"=",
"xs",
".",
"size",
"||",
"0",
";",
"var",
"m",
"=",
"ys",
".",
"size",
"||",
"0",
";",
"var",
"a",
"=",
"makeMatrix",
"(",
"n",
"+",
"1",
",",
"m",
"+",
"1",
"... | Computes the Longest Common Subsequence table
@param xs Indexed Sequence 1
@param ys Indexed Sequence 2 | [
"Computes",
"the",
"Longest",
"Common",
"Subsequence",
"table"
] | 0c1b48516368c6c955a36cba10d74dcffa361ec8 | https://github.com/intelie/immutable-js-diff/blob/0c1b48516368c6c955a36cba10d74dcffa361ec8/src/lcs.js#L100-L117 |
30,214 | intelie/immutable-js-diff | src/lcs.js | function(xs, ys, matrix){
var lcs = [];
for(var i = xs.size, j = ys.size; i !== 0 && j !== 0;){
if (matrix[i][j] === matrix[i-1][j]){ i--; }
else if (matrix[i][j] === matrix[i][j-1]){ j--; }
else{
if(Immutable.is(xs.get(i-1), ys.get(j-1))){
lcs.push(xs.get(i-1));
i--;
j--;
}
}
}
return lcs.reverse();
} | javascript | function(xs, ys, matrix){
var lcs = [];
for(var i = xs.size, j = ys.size; i !== 0 && j !== 0;){
if (matrix[i][j] === matrix[i-1][j]){ i--; }
else if (matrix[i][j] === matrix[i][j-1]){ j--; }
else{
if(Immutable.is(xs.get(i-1), ys.get(j-1))){
lcs.push(xs.get(i-1));
i--;
j--;
}
}
}
return lcs.reverse();
} | [
"function",
"(",
"xs",
",",
"ys",
",",
"matrix",
")",
"{",
"var",
"lcs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"xs",
".",
"size",
",",
"j",
"=",
"ys",
".",
"size",
";",
"i",
"!==",
"0",
"&&",
"j",
"!==",
"0",
";",
")",
"{",
"... | Extracts a LCS from matrix M
@param xs Indexed Sequence 1
@param ys Indexed Sequence 2
@param matrix LCS Matrix
@returns {Array.<T>} Longest Common Subsequence | [
"Extracts",
"a",
"LCS",
"from",
"matrix",
"M"
] | 0c1b48516368c6c955a36cba10d74dcffa361ec8 | https://github.com/intelie/immutable-js-diff/blob/0c1b48516368c6c955a36cba10d74dcffa361ec8/src/lcs.js#L126-L140 | |
30,215 | nolanlawson/vdom-serialized-patch | lib/serialize/index.js | serializeCurrentNode | function serializeCurrentNode(currentNode) {
var children = currentNode.children;
if (!children) {
return null;
}
var len = children.length;
var arr = new Array(len);
var i = -1;
while (++i < len) {
arr[i] = serializeCurrentNode(children[i]);
}
if (currentNode.count) {
return [arr, currentNode.count];
} else {
return [arr];
}
} | javascript | function serializeCurrentNode(currentNode) {
var children = currentNode.children;
if (!children) {
return null;
}
var len = children.length;
var arr = new Array(len);
var i = -1;
while (++i < len) {
arr[i] = serializeCurrentNode(children[i]);
}
if (currentNode.count) {
return [arr, currentNode.count];
} else {
return [arr];
}
} | [
"function",
"serializeCurrentNode",
"(",
"currentNode",
")",
"{",
"var",
"children",
"=",
"currentNode",
".",
"children",
";",
"if",
"(",
"!",
"children",
")",
"{",
"return",
"null",
";",
"}",
"var",
"len",
"=",
"children",
".",
"length",
";",
"var",
"ar... | traverse the thing that the original patch structure called "a', i.e. the virtual tree representing the current node structure. this thing only really needs two properties - "children" and "count", so trim out everything else | [
"traverse",
"the",
"thing",
"that",
"the",
"original",
"patch",
"structure",
"called",
"a",
"i",
".",
"e",
".",
"the",
"virtual",
"tree",
"representing",
"the",
"current",
"node",
"structure",
".",
"this",
"thing",
"only",
"really",
"needs",
"two",
"properti... | 158af827e062dac63a626b938f7fa32e55b70b46 | https://github.com/nolanlawson/vdom-serialized-patch/blob/158af827e062dac63a626b938f7fa32e55b70b46/lib/serialize/index.js#L8-L24 |
30,216 | 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 |
30,217 | 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);
let resolved = conf[key];
if (!resolved) {
throw `Could not resolve ${key} - make sure this key is defined in _config.yml.`;
}
if (CONFIG_VAR_REGEX.test(resolved)) {
resolved = resolve(resolved, conf, ring);
}
value = value.replace(variable, resolved);
ring.pop();
});
return value;
} | 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);
let resolved = conf[key];
if (!resolved) {
throw `Could not resolve ${key} - make sure this key is defined in _config.yml.`;
}
if (CONFIG_VAR_REGEX.test(resolved)) {
resolved = resolve(resolved, conf, ring);
}
value = value.replace(variable, resolved);
ring.pop();
});
return value;
} | [
"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 |
30,218 | 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 |
30,219 | 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 |
30,220 | 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(original) !== -1) return;
allFuncs.push(original);
if (item[prop] instanceof Function) {
infect(item, prop, path);
if (item[prop].prototype) {
bootstrap(item[prop], 'prototype', path+'.prototype');
}
for (var i in original) {
if (!original.hasOwnProperty(i) || Object.getOwnPropertyDescriptor(original, i).get) return;
item[prop][i] = original[i];
}
}
if (item[prop] instanceof Object) {
for (var i in item[prop]) {
bootstrap(item[prop], i, path+'.'+i);
}
}
return item;
} | 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(original) !== -1) return;
allFuncs.push(original);
if (item[prop] instanceof Function) {
infect(item, prop, path);
if (item[prop].prototype) {
bootstrap(item[prop], 'prototype', path+'.prototype');
}
for (var i in original) {
if (!original.hasOwnProperty(i) || Object.getOwnPropertyDescriptor(original, i).get) return;
item[prop][i] = original[i];
}
}
if (item[prop] instanceof Object) {
for (var i in item[prop]) {
bootstrap(item[prop], i, path+'.'+i);
}
}
return item;
} | [
"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 |
30,221 | 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 |
30,222 | 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 |
30,223 | 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 |
30,224 | 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');
while (Object.keys(stats).length > 0) {
var biggest = 0;
var biggestPath = Object.keys(stats)[0];
for (var path in stats) {
if (stats[path].average >= biggest) {
biggestPath = path;
biggest = stats[path].average;
}
}
console.error("TRACER TOTAL",
stats[biggestPath].min.toFixed(2)+'ms',
stats[biggestPath].average.toFixed(2)+'ms',
stats[biggestPath].max.toFixed(2)+'ms',
stats[biggestPath].count,
biggestPath);
delete stats[biggestPath];
}
} | 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');
while (Object.keys(stats).length > 0) {
var biggest = 0;
var biggestPath = Object.keys(stats)[0];
for (var path in stats) {
if (stats[path].average >= biggest) {
biggestPath = path;
biggest = stats[path].average;
}
}
console.error("TRACER TOTAL",
stats[biggestPath].min.toFixed(2)+'ms',
stats[biggestPath].average.toFixed(2)+'ms',
stats[biggestPath].max.toFixed(2)+'ms',
stats[biggestPath].count,
biggestPath);
delete stats[biggestPath];
}
} | [
"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 |
30,225 | 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 |
30,226 | 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;
}
if (options.errorCallback && typeof options.errorCallback !== 'function') {
throw new Error(TAG + 'Error callback must be a function.');
} else {
options.errorCallback = options.errorCallback || 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;
}
if (options.errorCallback && typeof options.errorCallback !== 'function') {
throw new Error(TAG + 'Error callback must be a function.');
} else {
options.errorCallback = options.errorCallback || 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 |
30,227 | 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;
}
return false;
} catch (e) {}
return false;
} | 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;
}
return false;
} catch (e) {}
return false;
} | [
"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 |
30,228 | 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 Error('Transport options must be an object.');
}
} | 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 Error('Transport options must be an object.');
}
} | [
"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 | |
30,229 | 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 || angular.noop;
options.successCallback = function (result) {
scope.$apply(function () {
defer.resolve(result);
onSuccess(result);
});
};
options.errorCallback = function (result) {
scope.$apply(function () {
defer.reject(result);
onError(result);
});
};
// Call the original transport method
// but use our promise as the return value
original.call(transport, options);
return defer.promise;
};
} | 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 || angular.noop;
options.successCallback = function (result) {
scope.$apply(function () {
defer.resolve(result);
onSuccess(result);
});
};
options.errorCallback = function (result) {
scope.$apply(function () {
defer.reject(result);
onError(result);
});
};
// Call the original transport method
// but use our promise as the return value
original.call(transport, options);
return defer.promise;
};
} | [
"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 |
30,230 | 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 | |
30,231 | 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 |
30,232 | 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`);
console.log(`IPFS: ${ ipfsHash }`);
console.log(`IPNS: ${ ipnsHash }`);
} catch (ex) {
console.error(ex);
}
} | 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`);
console.log(`IPFS: ${ ipfsHash }`);
console.log(`IPNS: ${ ipnsHash }`);
} catch (ex) {
console.error(ex);
}
} | [
"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 |
30,233 | 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 points
@private | [
"Calculates",
"the",
"distance",
"between",
"two",
"points"
] | b9baebf8c62cdc38e3ee5dd6063c46c95cfcbc92 | https://github.com/nickschot/ember-mobile-core/blob/b9baebf8c62cdc38e3ee5dd6063c46c95cfcbc92/addon/utils/parse-touch-data.js#L155-L157 |
30,234 | 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 |
30,235 | 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 `RegExp.name` or `MyClass.name`. | [
"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 |
30,236 | 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) {
Class[_GQLBase.META_KEY][tag] = Class[_GQLBase.META_KEY][tag] || {};
Class[_GQLBase.META_KEY][tag][fieldName] = descriptor;
});
} | 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) {
Class[_GQLBase.META_KEY][tag] = Class[_GQLBase.META_KEY][tag] || {};
Class[_GQLBase.META_KEY][tag][fieldName] = descriptor;
});
} | [
"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 the developer using lattice and something auto
generated such as auto-props.
@param {GQLBase} Class an instance of GQLBase to apply the tags tp
@param {Array<string|Symbol>} addTags an array of Symbols or strings to be
wrapped in Symbols that will be used as tag keys
@param {string} fieldName the name of the field being decorated
@param {Object} descriptor the JavaScript descriptor object to associate
with this tagged field. | [
"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 |
30,237 | 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 http://www.unicode.org/faq/utf_bom.html#bom1
csvStream.write(new Buffer([0xFF, 0xFE]));
return encoder.pipe(converter).pipe(csvStream);
} | 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 http://www.unicode.org/faq/utf_bom.html#bom1
csvStream.write(new Buffer([0xFF, 0xFE]));
return encoder.pipe(converter).pipe(csvStream);
} | [
"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 |
30,238 | 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 path file.
const jsonPath = file.originalPath
.replace(`${basePath}/`, '')
.replace(stripPrefix, '');
const template = createTemplate(conf.varName || '__json__');
// Update file path
file.path = `${file.path}.js`;
try {
const o = JSON.parse(content.trim());
done(util.format(template, jsonPath, JSON.stringify(o)));
} catch (e) {
log.error('Json representation of %s is not valid !', file.originalPath);
done('');
}
};
} | 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 path file.
const jsonPath = file.originalPath
.replace(`${basePath}/`, '')
.replace(stripPrefix, '');
const template = createTemplate(conf.varName || '__json__');
// Update file path
file.path = `${file.path}.js`;
try {
const o = JSON.parse(content.trim());
done(util.format(template, jsonPath, JSON.stringify(o)));
} catch (e) {
log.error('Json representation of %s is not valid !', file.originalPath);
done('');
}
};
} | [
"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 |
30,239 | 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;
key = key.substr(0, key.length - 1); // eslint-disable-line
}
if (isString(obj)) {
obj = {
alias: obj,
};
}
return {
name: key,
onlyModule,
...obj,
};
});
}
return (request) => {
for (const alias of aliases) {
if ((!alias.onlyModule && request.indexOf(`${alias.name}/`) === 0) || request === alias.name) {
if (request.indexOf(`${alias.alias}/`) !== 0 && request !== alias.alias) {
return alias.alias + request.substr(alias.name.length);
}
}
}
return request;
};
} | 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;
key = key.substr(0, key.length - 1); // eslint-disable-line
}
if (isString(obj)) {
obj = {
alias: obj,
};
}
return {
name: key,
onlyModule,
...obj,
};
});
}
return (request) => {
for (const alias of aliases) {
if ((!alias.onlyModule && request.indexOf(`${alias.name}/`) === 0) || request === alias.name) {
if (request.indexOf(`${alias.alias}/`) !== 0 && request !== alias.alias) {
return alias.alias + request.substr(alias.name.length);
}
}
}
return request;
};
} | [
"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 |
30,240 | 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} value the value for the checklist item to set | [
"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 |
30,241 | 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++) {
var item = items[_i2];
if (!checklist[item]) {
return false;
}
}
return true;
}
return checklist;
} | 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++) {
var item = items[_i2];
if (!checklist[item]) {
return false;
}
}
return true;
}
return checklist;
} | [
"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<Symbol>} items any of CHECK_SCHEMA, CHECK_RESOLVERS, or
CHECK_API_DOCS
@return {Boolean} true if the checklist and/or all items are true and
present. | [
"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 |
30,242 | 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$CHECK, CHECK_RESOLVERS, false), (0, _defineProperty2.default)(_Class$META_KEY$CHECK, CHECK_API_DOCS, false), _keys = "keys", _mutatorMap = {}, _mutatorMap[_keys] = _mutatorMap[_keys] || {}, _mutatorMap[_keys].get = function () {
return [CHECK_SCHEMA, CHECK_RESOLVERS, CHECK_API_DOCS];
}, _complete = "complete", _mutatorMap[_complete] = _mutatorMap[_complete] || {}, _mutatorMap[_complete].get = function () {
var _this = this;
return this.keys.reduce(function (p, c, i, a) {
if (!p || !_this[c]) {
return false;
}
}, true);
}, (0, _defineEnumerableProperties2.default)(_Class$META_KEY$CHECK, _mutatorMap), _Class$META_KEY$CHECK);
} else {
throw new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject()));
}
} | 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$CHECK, CHECK_RESOLVERS, false), (0, _defineProperty2.default)(_Class$META_KEY$CHECK, CHECK_API_DOCS, false), _keys = "keys", _mutatorMap = {}, _mutatorMap[_keys] = _mutatorMap[_keys] || {}, _mutatorMap[_keys].get = function () {
return [CHECK_SCHEMA, CHECK_RESOLVERS, CHECK_API_DOCS];
}, _complete = "complete", _mutatorMap[_complete] = _mutatorMap[_complete] || {}, _mutatorMap[_complete].get = function () {
var _this = this;
return this.keys.reduce(function (p, c, i, a) {
if (!p || !_this[c]) {
return false;
}
}, true);
}, (0, _defineEnumerableProperties2.default)(_Class$META_KEY$CHECK, _mutatorMap), _Class$META_KEY$CHECK);
} else {
throw new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject()));
}
} | [
"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 |
30,243 | 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;
var space = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' ';
return string.split('\n').map(function (s) {
return s.trim().replace(/(^)/gm, "$1".concat(space.repeat(count)));
}).join('\n');
};
if (typeof template.name === 'undefined') {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject2())));
}
if (!(0, _neTypes.extendsFrom)(template.name, String)) {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject3())));
}
if (typeof template.schema === 'undefined') {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject4())));
}
if (!(0, _neTypes.extendsFrom)(template.schema, String)) {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject5())));
}
if (!(0, _neTypes.extendsFrom)(template.resolvers, Object) // Supports 95% of objects
|| (0, _typeof2.default)(template.resolvers) !== 'object' // Supports Object.create(null)
) {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject6())));
}
if (typeof template.docs === 'undefined') {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject7())));
}
if (!(0, _neTypes.extendsFrom)(template.docs, Object) // Supports 95% of objects
|| (0, _typeof2.default)(template.docs) !== 'object' // Supports Object.create(null)
) {
var dr = '\x1b[31m',
br = '\x1b[91m';
var b1 = '\x1b[1m',
b0 = '\x1b[22m';
var bb = '\x1b[90m';
var dg = '\x1b[37m',
bg = '\x1b[97m';
var a0 = '\x1b[0m';
var gr = '\x1b[32m',
bgr = '\x1b[92m';
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject8(), bb, dg, b1, b0, gr, dg, b1, b0, b1, b0, gr, dg, gr, dg, gr, dg, b1, b0, gr, dg, b1, b0, gr, dg)));
}
if (!results.valid) {
var errorStrings = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = results.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _error = _step.value;
var message = _error.message,
stack = _error.stack;
stack = stack.trim().split('\n').splice(message.split('\n').length).map(function (s) {
return s.trim();
}).join('\n');
message = message.replace(/(Error:\s)/, '$1\n').trim();
errorStrings.push("\x1B[31;1m".concat(message, "\x1B[0m\n") + indent(stack));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var error = new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject9()).replace(/@template/, indent(_i(template))).replace(/@errors/, errorStrings.join('\n\n')));
error.stack = error.message;
error.message = '';
if (!hide) throw error;
}
return results;
} | 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;
var space = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' ';
return string.split('\n').map(function (s) {
return s.trim().replace(/(^)/gm, "$1".concat(space.repeat(count)));
}).join('\n');
};
if (typeof template.name === 'undefined') {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject2())));
}
if (!(0, _neTypes.extendsFrom)(template.name, String)) {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject3())));
}
if (typeof template.schema === 'undefined') {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject4())));
}
if (!(0, _neTypes.extendsFrom)(template.schema, String)) {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject5())));
}
if (!(0, _neTypes.extendsFrom)(template.resolvers, Object) // Supports 95% of objects
|| (0, _typeof2.default)(template.resolvers) !== 'object' // Supports Object.create(null)
) {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject6())));
}
if (typeof template.docs === 'undefined') {
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject7())));
}
if (!(0, _neTypes.extendsFrom)(template.docs, Object) // Supports 95% of objects
|| (0, _typeof2.default)(template.docs) !== 'object' // Supports Object.create(null)
) {
var dr = '\x1b[31m',
br = '\x1b[91m';
var b1 = '\x1b[1m',
b0 = '\x1b[22m';
var bb = '\x1b[90m';
var dg = '\x1b[37m',
bg = '\x1b[97m';
var a0 = '\x1b[0m';
var gr = '\x1b[32m',
bgr = '\x1b[92m';
results.errors.push(new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject8(), bb, dg, b1, b0, gr, dg, b1, b0, b1, b0, gr, dg, gr, dg, gr, dg, b1, b0, gr, dg, b1, b0, gr, dg)));
}
if (!results.valid) {
var errorStrings = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = results.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _error = _step.value;
var message = _error.message,
stack = _error.stack;
stack = stack.trim().split('\n').splice(message.split('\n').length).map(function (s) {
return s.trim();
}).join('\n');
message = message.replace(/(Error:\s)/, '$1\n').trim();
errorStrings.push("\x1B[31;1m".concat(message, "\x1B[0m\n") + indent(stack));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var error = new Error((0, _neTagFns.customDedent)({
dropLowest: true
})(_templateObject9()).replace(/@template/, indent(_i(template))).replace(/@errors/, errorStrings.join('\n\n')));
error.stack = error.message;
error.message = '';
if (!hide) throw error;
}
return results;
} | [
"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 {boolean} hide if true, an invalid template will NOT throw errors
@return {ValidationResults} a `ValidationResults` object containing the
collected errors and a `valid` that is dynamically calculated. | [
"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 |
30,244 | 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.val("dummy");
}
})
} | 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.val("dummy");
}
})
} | [
"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 | |
30,245 | 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 |
30,246 | 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 containing this element | [
"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 |
30,247 | 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 |
30,248 | 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.map(LatticeLogs.argMapper)));
} | 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.map(LatticeLogs.argMapper)));
} | [
"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 |
30,249 | 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)(args.map(LatticeLogs.argMapper)));
} | 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)(args.map(LatticeLogs.argMapper)));
} | [
"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 |
30,250 | 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.default)(args.map(LatticeLogs.argMapper)));
} | 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.default)(args.map(LatticeLogs.argMapper)));
} | [
"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 |
30,251 | 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)(args.map(LatticeLogs.argMapper)));
} | 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)(args.map(LatticeLogs.argMapper)));
} | [
"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 |
30,252 | 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.default)(args.map(LatticeLogs.argMapper)));
} | 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.default)(args.map(LatticeLogs.argMapper)));
} | [
"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 |
30,253 | 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} keySupplied a value, coerced `toString()`, to compare to
`keyToTest`
@param {mixed} instance an object instance to check `hasOwnProperty` on for
the `keyToTest` supplied.
@return {Boolean} true if the property matches the supplied key and that
property is not an ownedProperty of the instance supplied. | [
"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 |
30,254 | 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(proto, propName);
var result;
if (!descriptor) {
return null;
}
if (descriptor) {
if (descriptor.initializer || descriptor.get) {
var what = descriptor.initializer || descriptor.get;
if (bindGetters) {
result = what.bind(bindTo || this);
} else {
result = what;
}
} else if (descriptor.value) {
result = descriptor.value;
}
}
return result;
} | 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(proto, propName);
var result;
if (!descriptor) {
return null;
}
if (descriptor) {
if (descriptor.initializer || descriptor.get) {
var what = descriptor.initializer || descriptor.get;
if (bindGetters) {
result = what.bind(bindTo || this);
} else {
result = what;
}
} else if (descriptor.value) {
result = descriptor.value;
}
}
return result;
} | [
"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 method tends to lessen that boilerplate.
Errors raised will be thrown.
@instance
@memberof GQLBase
@method ⌾⠀getProp
@param {string|Symbol} propName the name of the property in question
@param {boolean} bindGetters true, by default, if the `get` or
`initializer` descriptor values should be bound to the current instance
or an object of the programmers choice before returning
@param {mixed} bindTo the `this` object to use for binding when
`bindGetters` is set to true.
@return {mixed} the value of the `propName` as a Function or something
else when the requested property name exists
@throws {Error} errors raised in awaiting results will be thrown | [
"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 |
30,255 | 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 supplied path should it not
already exist.
@return Symbol
@see {@link GQLBase#SCHEMA} | [
"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 |
30,256 | 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 nodeToString(arg);
}).toString();
return nodeToString(node.callee) + "(" + args + ")";
}
case ("ConditionalExpression"): {
return nodeToString(node.test) + "?" + nodeToString(node.consequent) + ":" + nodeToString(node.alternate);
}
case ("Identifier"): {
return node.name.toString();
}
case ("Literal"): {
return node.value.toString();
}
case ("MemberExpression"): {
return nodeToString(node.object) + "[" + nodeToString(node.property) + "]";
}
case ("TemplateElement"): {
return node.value.raw.toString();
}
case ("TemplateLiteral"): {
// interleave quasis with expressions
var s = [];
node.quasis.forEach(function(quasi, i) {
if (quasi.value.raw) {
s.push(nodeToString(quasi));
}
var expression = node.expressions[i];
if (expression) {
s.push(nodeToString(expression));
}
});
return s.join("");
}
default: {
// Silently ignore Nodes with types we don't handle
return "";
}
}
} | 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 nodeToString(arg);
}).toString();
return nodeToString(node.callee) + "(" + args + ")";
}
case ("ConditionalExpression"): {
return nodeToString(node.test) + "?" + nodeToString(node.consequent) + ":" + nodeToString(node.alternate);
}
case ("Identifier"): {
return node.name.toString();
}
case ("Literal"): {
return node.value.toString();
}
case ("MemberExpression"): {
return nodeToString(node.object) + "[" + nodeToString(node.property) + "]";
}
case ("TemplateElement"): {
return node.value.raw.toString();
}
case ("TemplateLiteral"): {
// interleave quasis with expressions
var s = [];
node.quasis.forEach(function(quasi, i) {
if (quasi.value.raw) {
s.push(nodeToString(quasi));
}
var expression = node.expressions[i];
if (expression) {
s.push(nodeToString(expression));
}
});
return s.join("");
}
default: {
// Silently ignore Nodes with types we don't handle
return "";
}
}
} | [
"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 |
30,257 | 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 hash table vs
// sort and uniq:
//
// Suppose you've got a million positions in a 100x100x100 grid.
//
// Using a uniqueness hash table, you're doing 1M array reads,
// 3M hash table lookups from 100-element hashes, 300 hash table inserts, then
// sorting three 100-element arrays and iterating over them.
// Roughly, 1M + 3M * ln(100) + 300 * ln(100/2) + 3 * 100 * ln(100) + 3 * 100 =
// 1M + 13.8M + 0.0012M + 0.0014M + 0.0003M
// =~ 15M
//
// Sort and uniq solution would do 1M array reads, 3M array inserts,
// sort three 1M-element arrays and iterate over them.
// Roughly, 1M + 3M + 3 * 1M * ln(1M) + 3 * 1M =
// 1M + 3M + 41.4M + 3M
// =~ 48.4M
//
// Guessing that a hard-coded sort & uniq would be faster due to not having
// to run a hashing function on everything. More memory usage though
// (bunch of small hash tables vs. duplicating the input array.)
//
// In JS-land, who knows. Maybe xi[x] casts x to string and destroys perf,
// maybe numeric keys get special-cased, maybe the object lookups run at near O(1)-speeds.
// Maybe the sorting comparison function is expensive to call, maybe it gets inlined or special-cased.
//
// ... You're probably not going to call this with more than 10k positions anyhow, so this is very academic.
//
if (!xi[x]) {
xs.push(x);
xi[x] = true;
}
if (!yi[y]) {
ys.push(y);
yi[y] = true;
}
if (!zi[z]) {
zs.push(z);
zi[z] = true;
}
}
var xSep = findMinSeparation(xs);
var ySep = findMinSeparation(ys);
var zSep = findMinSeparation(zs);
var minSeparation = Math.min(xSep, ySep, zSep);
if (!isFinite(minSeparation)) {
return 1;
}
return minSeparation;
} | 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 hash table vs
// sort and uniq:
//
// Suppose you've got a million positions in a 100x100x100 grid.
//
// Using a uniqueness hash table, you're doing 1M array reads,
// 3M hash table lookups from 100-element hashes, 300 hash table inserts, then
// sorting three 100-element arrays and iterating over them.
// Roughly, 1M + 3M * ln(100) + 300 * ln(100/2) + 3 * 100 * ln(100) + 3 * 100 =
// 1M + 13.8M + 0.0012M + 0.0014M + 0.0003M
// =~ 15M
//
// Sort and uniq solution would do 1M array reads, 3M array inserts,
// sort three 1M-element arrays and iterate over them.
// Roughly, 1M + 3M + 3 * 1M * ln(1M) + 3 * 1M =
// 1M + 3M + 41.4M + 3M
// =~ 48.4M
//
// Guessing that a hard-coded sort & uniq would be faster due to not having
// to run a hashing function on everything. More memory usage though
// (bunch of small hash tables vs. duplicating the input array.)
//
// In JS-land, who knows. Maybe xi[x] casts x to string and destroys perf,
// maybe numeric keys get special-cased, maybe the object lookups run at near O(1)-speeds.
// Maybe the sorting comparison function is expensive to call, maybe it gets inlined or special-cased.
//
// ... You're probably not going to call this with more than 10k positions anyhow, so this is very academic.
//
if (!xi[x]) {
xs.push(x);
xi[x] = true;
}
if (!yi[y]) {
ys.push(y);
yi[y] = true;
}
if (!zi[z]) {
zs.push(z);
zi[z] = true;
}
}
var xSep = findMinSeparation(xs);
var ySep = findMinSeparation(ys);
var zSep = findMinSeparation(zs);
var minSeparation = Math.min(xSep, ySep, zSep);
if (!isFinite(minSeparation)) {
return 1;
}
return minSeparation;
} | [
"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 | |
30,258 | 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, ciphertext, h, plaintext)
encryptAndHash.bytesRead = cipherState.encryptWithAd.bytesRead
encryptAndHash.bytesWritten = cipherState.encryptWithAd.bytesWritten
mixHash(state, ciphertext.subarray(0, encryptAndHash.bytesWritten))
} | 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, ciphertext, h, plaintext)
encryptAndHash.bytesRead = cipherState.encryptWithAd.bytesRead
encryptAndHash.bytesWritten = cipherState.encryptWithAd.bytesWritten
mixHash(state, ciphertext.subarray(0, encryptAndHash.bytesWritten))
} | [
"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 |
30,259 | 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 |
30,260 | 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) {
return NaN;
}
/*
* Convert both amounts to main units
*/
const fromAmountMainUnit = fromSmallestSubunit(fromAmount, fromCurrency);
const toAmountMainUnit = fromSmallestSubunit(toAmount, toCurrency);
/*
* Compute and return rate
*/
return fromAmountMainUnit / toAmountMainUnit;
} | 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) {
return NaN;
}
/*
* Convert both amounts to main units
*/
const fromAmountMainUnit = fromSmallestSubunit(fromAmount, fromCurrency);
const toAmountMainUnit = fromSmallestSubunit(toAmount, toCurrency);
/*
* Compute and return rate
*/
return fromAmountMainUnit / toAmountMainUnit;
} | [
"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 denominated in smallest sub-unit of toCurrency | [
"Computes",
"a",
"rate",
"between",
"two",
"amounts",
"in",
"two",
"different",
"currencies",
"."
] | d4e84e34da0bcdc922a2696387bf6cc30b6791c9 | https://github.com/CoinifySoftware/node-currency/blob/d4e84e34da0bcdc922a2696387bf6cc30b6791c9/src/index.js#L86-L112 |
30,261 | 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 ...
if(keys.length > 1) {
// see if we can find the parent ...
var parentKeys = keys.slice(0, keys.length-1);
var parent = stacheKey.read(context, parentKeys, options).value;
// If there is a parent, see if it has the last key
if( parent != null && canReflect.hasKey(parent, keys[keys.length-1].key ) ) {
return {
parent: parent,
parentHasKey: true,
value: undefined
};
} else {
return {};
}
}
// If we have only one key, try to find a context with this key
else if(keys.length === 1) {
if( canReflect.hasKey(context, keys[0].key ) ) {
return {
parent: context,
parentHasKey: true,
value: undefined
};
} else {
return {};
}
}
// If we have no keys, we are reading `this`.
else {
return {
value: context
};
}
} | 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 ...
if(keys.length > 1) {
// see if we can find the parent ...
var parentKeys = keys.slice(0, keys.length-1);
var parent = stacheKey.read(context, parentKeys, options).value;
// If there is a parent, see if it has the last key
if( parent != null && canReflect.hasKey(parent, keys[keys.length-1].key ) ) {
return {
parent: parent,
parentHasKey: true,
value: undefined
};
} else {
return {};
}
}
// If we have only one key, try to find a context with this key
else if(keys.length === 1) {
if( canReflect.hasKey(context, keys[0].key ) ) {
return {
parent: context,
parentHasKey: true,
value: undefined
};
} else {
return {};
}
}
// If we have no keys, we are reading `this`.
else {
return {
value: context
};
}
} | [
"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 | |
30,262 | 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 | |
30,263 | 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', ','); // ['1', '2', '3']
Rekord.toArray(1); // [1]
Rekord.toArray(null); // []
```
@memberof Rekord
@param {String|String[]} x
The variable to convert to an Array.
@param {String} [delimiter]
The delimiter to split if the given variable is a string.
@return {String[]} -
The array of strings created. | [
"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 |
30,264 | 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} arr
The array to search through.
@param {Any} x
The variable to search for.
@param {Function} [comparator]
The function to use which compares two values and returns a truthy
value if they are considered equivalent. If a comparator is not given
then strict comparison is used to determine equivalence.
@return {Number|Boolean} -
The index in the array the variable exists at, otherwise false if
the variable wasn't found in the array. | [
"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 |
30,265 | 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']
});
Rekord.isRekord( Task ); // true
```
@memberof Rekord
@param {Any} x
The variable to test.
@return {Boolean} -
True if the variable is a Rekord object, otherwise false. | [
"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 |
30,266 | 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 = createComparator( comparator.substring( 1 ), !nullsFirst );
return function compareObjectsReversed(a, b)
{
return -parsed( a, b );
};
}
else if ( isFormatInput( comparator ) )
{
var formatter = createFormatter( comparator );
return function compareFormatted(a, b)
{
var af = formatter( a );
var bf = formatter( b );
return af.localeCompare( bf );
};
}
else if ( isParseInput( comparator ) )
{
var parser = createParser( comparator );
return function compareExpression(a, b)
{
var ap = parser( a );
var bp = parser( b );
return compare( ap, bp, nullsFirst );
};
}
else
{
return function compareObjects(a, b)
{
var av = isValue( a ) ? a[ comparator ] : a;
var bv = isValue( b ) ? b[ comparator ] : b;
return compare( av, bv, nullsFirst );
};
}
}
else if ( isArray( comparator ) )
{
var parsedChain = [];
for (var i = 0; i < comparator.length; i++)
{
parsedChain[ i ] = createComparator( comparator[ i ], nullsFirst );
}
return function compareObjectsCascade(a, b)
{
var d = 0;
for (var i = 0; i < parsedChain.length && d === 0; i++)
{
d = parsedChain[ i ]( a, b );
}
return d;
};
}
return null;
} | 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 = createComparator( comparator.substring( 1 ), !nullsFirst );
return function compareObjectsReversed(a, b)
{
return -parsed( a, b );
};
}
else if ( isFormatInput( comparator ) )
{
var formatter = createFormatter( comparator );
return function compareFormatted(a, b)
{
var af = formatter( a );
var bf = formatter( b );
return af.localeCompare( bf );
};
}
else if ( isParseInput( comparator ) )
{
var parser = createParser( comparator );
return function compareExpression(a, b)
{
var ap = parser( a );
var bp = parser( b );
return compare( ap, bp, nullsFirst );
};
}
else
{
return function compareObjects(a, b)
{
var av = isValue( a ) ? a[ comparator ] : a;
var bv = isValue( b ) ? b[ comparator ] : b;
return compare( av, bv, nullsFirst );
};
}
}
else if ( isArray( comparator ) )
{
var parsedChain = [];
for (var i = 0; i < comparator.length; i++)
{
parsedChain[ i ] = createComparator( comparator[ i ], nullsFirst );
}
return function compareObjectsCascade(a, b)
{
var d = 0;
for (var i = 0; i < parsedChain.length && d === 0; i++)
{
d = parsedChain[ i ]( a, b );
}
return d;
};
}
return null;
} | [
"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 |
30,267 | 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} [context] -
The value of `this` when the callback is invoked. If not specified, the
reference of the object this function exists on will be `this`.
@return {Function} -
A function to invoke to stop listening to all of the events given.
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} [context] -
The value of `this` when the callback is invoked. If not specified, the
reference of the object this function exists on will be `this`.
@return {Function} -
A function to invoke to stop listening to all of the events given. | [
"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 |
30,268 | 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 of `this` when the callback is invoked. If not specified, the
reference of the object this function exists on will be `this`.
@return {Function} -
A function to invoke to stop listening to all of the events given.
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 of `this` when the callback is invoked. If not specified, the
reference of the object this function exists on will be `this`.
@return {Function} -
A function to invoke to stop listening to all of the events given. | [
"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 |
30,269 | 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)
{
node.remove();
}
node = next;
}
}
} | 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)
{
node.remove();
}
node = next;
}
}
} | [
"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 |
30,270 | 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 (var i = 0; i < events.length; i++)
{
deleteProperty( this.$$on, events[i] );
}
}
// Remove specific listener
else
{
for (var i = 0; i < events.length; i++)
{
offListeners( this.$$on, events[i], callback );
}
}
}
return this;
} | 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 (var i = 0; i < events.length; i++)
{
deleteProperty( this.$$on, events[i] );
}
}
// Remove specific listener
else
{
for (var i = 0; i < events.length; i++)
{
offListeners( this.$$on, events[i], callback );
}
}
}
return this;
} | [
"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
@method off
@for addEventful
@param {String|Array|Object} [eventsInput]
@param {Function} [callback]
@chainable | [
"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 |
30,271 | 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.trigger( triggerGroup, args, false );
node = next;
}
node = eventListeners.next;
while (node !== eventListeners)
{
next = node.next;
node.trigger( triggerGroup, args, true );
node = next;
}
}
} | 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.trigger( triggerGroup, args, false );
node = next;
}
node = eventListeners.next;
while (node !== eventListeners)
{
next = node.next;
node.trigger( triggerGroup, args, true );
node = next;
}
}
} | [
"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 |
30,272 | 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 this;
} | 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 this;
} | [
"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 |
30,273 | 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 ))
{
if (isArray( adding ))
{
existing.push.apply( existing, adding );
}
else
{
existing.push( adding );
}
}
else if (isObject( existing ))
{
merge( existing, adding, ignoreMap );
}
else
{
dst[ prop ] = copy( adding, true );
}
}
else
{
dst[ prop ] = copy( adding, true );
}
}
}
}
return dst;
} | 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 ))
{
if (isArray( adding ))
{
existing.push.apply( existing, adding );
}
else
{
existing.push( adding );
}
}
else if (isObject( existing ))
{
merge( existing, adding, ignoreMap );
}
else
{
dst[ prop ] = copy( adding, true );
}
}
else
{
dst[ prop ] = copy( adding, true );
}
}
}
}
return dst;
} | [
"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 non array value exists in src, added the value to the dst array. - If a property in dst is an object, try to merge the property from src into it. - If a property exists in dst that is not an object or array, replace it with the value in src. | [
"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 |
30,274 | 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( expectedFields ) )
{
for (var i = 0; i < testFields.length; i++)
{
var testProp = testFields[ i ];
var expectedProp = expectedFields[ i ];
if ( !equality( test[ testProp ], expected[ expectedProp ] ) )
{
return false;
}
}
return true;
}
return false;
} | 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( expectedFields ) )
{
for (var i = 0; i < testFields.length; i++)
{
var testProp = testFields[ i ];
var expectedProp = expectedFields[ i ];
if ( !equality( test[ testProp ], expected[ expectedProp ] ) )
{
return false;
}
}
return true;
}
return false;
} | [
"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 expected values.
@param {String|String[]} expectedFields -
The property name or array of properties to test for equality on `expected`.
@param {equalityCallback} [equals] -
The equality function which compares two values and returns whether they
are considered equivalent.
@return {Boolean} -
True if the `testFields` properties on `test` are equivalent to the
`expectedFields` on `expected` according to the `equals` function. | [
"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 |
30,275 | 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 |
30,276 | 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 createFormatter( properties );
}
else if ( isParseInput( properties ) )
{
return createParser( properties );
}
else
{
return function resolveProperty(model)
{
return model ? model[ properties ] : undefined;
};
}
}
else if ( isArray( properties ) )
{
return function resolveProperties(model)
{
return pull( model, properties );
};
}
else if ( isObject( properties ) )
{
var propsArray = [];
var propsResolver = [];
for (var prop in properties)
{
propsArray.push( prop );
propsResolver.push( createPropertyResolver( properties[ prop ] ) );
}
return function resolvePropertyObject(model)
{
var resolved = {};
for (var i = 0; i < propsArray.length; i++)
{
var prop = propsArray[ i ];
resolved[ prop ] = propsResolver[ i ]( model[ prop ] );
}
return resolved;
};
}
else
{
return function resolveNone(model)
{
return model;
};
}
} | javascript | function createPropertyResolver(properties)
{
if ( isFunction( properties ) )
{
return properties;
}
else if ( isString( properties ) )
{
if ( properties in PropertyResolvers )
{
return PropertyResolvers[ properties ];
}
if ( isFormatInput( properties ) )
{
return createFormatter( properties );
}
else if ( isParseInput( properties ) )
{
return createParser( properties );
}
else
{
return function resolveProperty(model)
{
return model ? model[ properties ] : undefined;
};
}
}
else if ( isArray( properties ) )
{
return function resolveProperties(model)
{
return pull( model, properties );
};
}
else if ( isObject( properties ) )
{
var propsArray = [];
var propsResolver = [];
for (var prop in properties)
{
propsArray.push( prop );
propsResolver.push( createPropertyResolver( properties[ prop ] ) );
}
return function resolvePropertyObject(model)
{
var resolved = {};
for (var i = 0; i < propsArray.length; i++)
{
var prop = propsArray[ i ];
resolved[ prop ] = propsResolver[ i ]( model[ prop ] );
}
return resolved;
};
}
else
{
return function resolveNone(model)
{
return model;
};
}
} | [
"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 ) // 6
createPropertyResolver( 'user.first' )( x ) // 'jack'
createPropertyResolver( '{name} & {user.first}')( x ) // 'tom & jack'
createPropertyResolver( ['name', 'age'] )( x ) // ['tom', 6]
createPropertyResolver( {age:null, user:'first'})( x ) // {age: 6, user:'jack'}
```
@memberof Rekord
@param {propertyResolverInput} [properties] -
The expression which converts one value into another.
@return {propertyResolverCallback} -
A function to take values and resolve new ones. | [
"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 |
30,277 | 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 ];
parsed.push( isArray( where ) ? createWhere.apply( this, where ) : createWhere( where ) );
}
return function whereMultiple(model)
{
for (var i = 0; i < parsed.length; i++)
{
if ( !parsed[ i ]( model ) )
{
return false;
}
}
return true;
};
}
else if ( isObject( properties ) )
{
var props = [];
for (var prop in properties)
{
props.push({
tester: exprEqualsTester( properties[ prop ], equality ),
resolver: createPropertyResolver( prop )
});
}
return function whereEqualsObject(model)
{
for (var i = 0; i < props.length; i++)
{
var prop = props[ i ];
if ( !prop.tester( prop.resolver( model ) ) )
{
return false;
}
}
return true;
};
}
else if ( isString( properties ) )
{
if ( properties in Wheres )
{
return Wheres[ properties ];
}
var resolver = createPropertyResolver( properties );
if ( isValue( value ) )
{
var tester = exprEqualsTester( value, equality );
return function whereEqualsValue(model)
{
return tester( resolver( model ) );
};
}
else
{
return function whereHasValue(model)
{
return isValue( resolver( model ) );
};
}
}
else
{
return function whereAll(model)
{
return true;
};
}
} | 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 ];
parsed.push( isArray( where ) ? createWhere.apply( this, where ) : createWhere( where ) );
}
return function whereMultiple(model)
{
for (var i = 0; i < parsed.length; i++)
{
if ( !parsed[ i ]( model ) )
{
return false;
}
}
return true;
};
}
else if ( isObject( properties ) )
{
var props = [];
for (var prop in properties)
{
props.push({
tester: exprEqualsTester( properties[ prop ], equality ),
resolver: createPropertyResolver( prop )
});
}
return function whereEqualsObject(model)
{
for (var i = 0; i < props.length; i++)
{
var prop = props[ i ];
if ( !prop.tester( prop.resolver( model ) ) )
{
return false;
}
}
return true;
};
}
else if ( isString( properties ) )
{
if ( properties in Wheres )
{
return Wheres[ properties ];
}
var resolver = createPropertyResolver( properties );
if ( isValue( value ) )
{
var tester = exprEqualsTester( value, equality );
return function whereEqualsValue(model)
{
return tester( resolver( model ) );
};
}
else
{
return function whereHasValue(model)
{
return isValue( resolver( model ) );
};
}
}
else
{
return function whereAll(model)
{
return true;
};
}
} | [
"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(){}); // a function can be given which is immediately returned
Rekord.createWhere(['field', function(){}, ['field', true]]); // when an object meets all of the above criteria
Rekord.createWhere({foo: 1, bar: 2}); // when an object has foo=1 and bar=2
Rekord.createWhere('field', true, myEquals); // A custom comparison function can be given.
Rekord.createWhere(); // always returns true
```
@memberof Rekord
@param {whereInput} [properties] -
The first expression used to generate a filter function.
@param {Any} [value] -
When the first argument is a string this argument will be treated as a
value to compare to the value of the named property on the object passed
through the filter function.
@param {equalityCallback} [equals=Rekord.equalsStrict] -
An alternative function can be used to compare to values.
@return {whereCallback} -
A function which takes a value (typically an object) and returns a true
or false value.
@see Rekord.saveWhere | [
"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 |
30,278 | 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.className,
'(props, remoteData) { this.$init( props, remoteData ) }'
);
database.Model = model;
model.Database = database;
Rekord.classes[ database.name ] = model;
Rekord.trigger( Rekord.Events.Plugins, [model, database, options] );
if ( Rekord.autoload )
{
database.loadBegin(function onLoadFinish(success)
{
if ( success )
{
database.loadFinish();
}
});
}
else
{
Rekord.unloaded.push( database );
}
Rekord.get( database.name ).resolve( model );
Rekord.get( database.className ).resolve( model );
Rekord.debug( Rekord.Debugs.CREATION, database, options );
return model;
} | 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.className,
'(props, remoteData) { this.$init( props, remoteData ) }'
);
database.Model = model;
model.Database = database;
Rekord.classes[ database.name ] = model;
Rekord.trigger( Rekord.Events.Plugins, [model, database, options] );
if ( Rekord.autoload )
{
database.loadBegin(function onLoadFinish(success)
{
if ( success )
{
database.loadFinish();
}
});
}
else
{
Rekord.unloaded.push( database );
}
Rekord.get( database.name ).resolve( model );
Rekord.get( database.className ).resolve( model );
Rekord.debug( Rekord.Debugs.CREATION, database, options );
return model;
} | [
"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 |
30,279 | 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 | |
30,280 | 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 )
{
var remoteLoaded = db.remoteLoaded || !db.hasLoad( Load.All );
var missingModel = (result === null || !result.$isSaved());
var lazyLoad = db.hasLoad( Load.Lazy );
if ( lazyLoad && remoteLoaded && missingModel )
{
if ( !result )
{
result = db.keyHandler.buildObjectFromKey( db.keyHandler.buildKeyFromInput( input ) );
}
result.$once( Model.Events.RemoteGets, function()
{
if ( !promise.isComplete() )
{
if ( isObject( input ) )
{
result.$set( input );
}
promise.resolve( result.$isSaved() ? result : null );
}
});
result.$refresh( Cascade.All, db.fetchOptions );
}
else
{
promise.resolve( result );
}
}
return promise.isComplete() ? false : true;
}
if ( checkModel() )
{
db.ready( checkModel, db, true );
}
return promise;
} | 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 )
{
var remoteLoaded = db.remoteLoaded || !db.hasLoad( Load.All );
var missingModel = (result === null || !result.$isSaved());
var lazyLoad = db.hasLoad( Load.Lazy );
if ( lazyLoad && remoteLoaded && missingModel )
{
if ( !result )
{
result = db.keyHandler.buildObjectFromKey( db.keyHandler.buildKeyFromInput( input ) );
}
result.$once( Model.Events.RemoteGets, function()
{
if ( !promise.isComplete() )
{
if ( isObject( input ) )
{
result.$set( input );
}
promise.resolve( result.$isSaved() ? result : null );
}
});
result.$refresh( Cascade.All, db.fetchOptions );
}
else
{
promise.resolve( result );
}
}
return promise.isComplete() ? false : true;
}
if ( checkModel() )
{
db.ready( checkModel, db, true );
}
return promise;
} | [
"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 | |
30,281 | 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 ) && revision in b ? b[ revision ] : undefined;
return ar === undefined || br === undefined ? false : compare( ar, br ) > 0;
};
}
else
{
this.revisionFunction = function(a, b)
{
return false;
};
}
} | 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 ) && revision in b ? b[ revision ] : undefined;
return ar === undefined || br === undefined ? false : compare( ar, br ) > 0;
};
}
else
{
this.revisionFunction = function(a, b)
{
return false;
};
}
} | [
"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 | |
30,282 | 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 | |
30,283 | 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, failure );
});
return promise;
} | 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, failure );
});
return promise;
} | [
"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 | |
30,284 | 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, [model] );
model.$trigger( Model.Events.UpdateAndSave );
}
else
{
db.saveReference( model, key );
db.trigger( Database.Events.ModelAdded, [model] );
db.updated();
model.$trigger( Model.Events.CreateAndSave );
}
model.$addOperation( SaveLocal, cascade, options );
} | 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, [model] );
model.$trigger( Model.Events.UpdateAndSave );
}
else
{
db.saveReference( model, key );
db.trigger( Database.Events.ModelAdded, [model] );
db.updated();
model.$trigger( Model.Events.CreateAndSave );
}
model.$addOperation( SaveLocal, cascade, options );
} | [
"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 | |
30,285 | 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_CANCEL_SAVE, db, model );
}
model.$status = Model.Status.RemovePending;
model.$addOperation( RemoveLocal, cascade, options );
} | 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_CANCEL_SAVE, db, model );
}
model.$status = Model.Status.RemovePending;
model.$addOperation( RemoveLocal, cascade, options );
} | [
"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 | |
30,286 | 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 | |
30,287 | 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;
}
delete this.indices[ key ];
return this;
} | 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;
}
delete this.indices[ key ];
return this;
} | [
"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 | |
30,288 | 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 );
}
}
return out;
} | 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 );
}
}
return out;
} | [
"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 | |
30,289 | 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)
{
i++;
}
while (comparator( map.values[j], pivot ) > 0)
{
j--;
}
if (i <= j)
{
swap( map.values, i, j );
swap( map.keys, i, j );
i++;
j--;
}
}
return i;
}
// Quicksort
function qsort(left, right)
{
var index = partition( left, right );
if (left < index - 1)
{
qsort( left, index - 1 );
}
if (index < right)
{
qsort( index, right );
}
}
var right = this.size() - 1;
// Are there elements to sort?
if ( right > 0 )
{
qsort( 0, right );
this.rebuildIndex();
}
return this;
} | 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)
{
i++;
}
while (comparator( map.values[j], pivot ) > 0)
{
j--;
}
if (i <= j)
{
swap( map.values, i, j );
swap( map.keys, i, j );
i++;
j--;
}
}
return i;
}
// Quicksort
function qsort(left, right)
{
var index = partition( left, right );
if (left < index - 1)
{
qsort( left, index - 1 );
}
if (index < right)
{
qsort( index, right );
}
}
var right = this.size() - 1;
// Are there elements to sort?
if ( right > 0 )
{
qsort( 0, right );
this.rebuildIndex();
}
return this;
} | [
"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 returned, otherwise a positive number should be
returned.
@return {Map} -
The reference to this map. | [
"Sorts",
"the",
"underlying",
"values",
"&",
"keys",
"given",
"a",
"value",
"compare",
"function",
"."
] | 6663dbedad865549a6b9bccaa9a993b2074483e6 | https://github.com/Rekord/rekord/blob/6663dbedad865549a6b9bccaa9a993b2074483e6/build/rekord.js#L6267-L6328 | |
30,290 | 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)
{
j--;
}
if (i <= j)
{
swap( map.values, i, j );
swap( map.keys, i, j );
i++;
j--;
}
}
return i;
} | 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)
{
j--;
}
if (i <= j)
{
swap( map.values, i, j );
swap( map.keys, i, j );
i++;
j--;
}
}
return i;
} | [
"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 |
30,291 | 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 | |
30,292 | 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 | |
30,293 | 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 is done involving a null/undefined value this can
determine which is ordered before the other.
@see Rekord.createComparator
@return {Boolean} | [
"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 | |
30,294 | 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, [this] );
}
return this;
} | 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, [this] );
}
return this;
} | [
"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 {ComparatorInput} [comparator] -
The comparator input to convert to a comparison function.
@param {Boolean} [nullsFirst=false] -
When a comparison is done involving a null/undefined value this can
determine which is ordered before the other.
@param {Boolean} [ignorePrimitive=false] -
Sorting is automatically done for non-primitive collections if a
comparator exists. This flag ensures primitive collections aren't sorted
after every operation.
@return {Rekord.Collection} -
The reference to this collection.
@emits Rekord.Collection#sort
@see Rekord.createComparator | [
"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 | |
30,295 | 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 | |
30,296 | 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( a, collection[ j ] );
}
if (!exists)
{
target.push( a );
}
}
return target;
} | 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( a, collection[ j ] );
}
if (!exists)
{
target.push( a );
}
}
return target;
} | [
"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 that shouldn't exist in the resulting collection.
@param {Array} [out=this.cloneEmpty()] -
The array to place the elements that exist in this collection but not in
the given collection. If this is not given - a collection of this type
will be created.
@param {equalityCallback} [equals=Rekord.equalsStrict] -
The function which determines whether one of the elements that exist in
this collection are equivalent to an element that exists in the given
collection.
@return {Array} -
The collection of elements that exist in this collection and not the
given collection. | [
"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 | |
30,297 | 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 to this collection.
@return {Number} -
The new length of this collection.
@emits Rekord.Collection#adds
@emits Rekord.Collection#sort | [
"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 | |
30,298 | 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 );
}
}
return this;
} | 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 );
}
}
return this;
} | [
"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[]} values -
The values to add to this collection.
@param {Boolean} [delaySort=false] -
Whether automatic sorting should be delayed until the user manually
calls {@link Rekord.Collection#sort sort}.
@return {Rekord.Collection} -
The reference to this collection.
@emits Rekord.Collection#adds
@emits Rekord.Collection#sort | [
"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 | |
30,299 | 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]
```
@method
@memberof Rekord.Collection#
@param {Number} i -
The index to insert the element at.
@param {Any} value -
The value to insert into the collection.
@param {Boolean} [delaySort=false] -
Whether automatic sorting should be delayed until the user manually
calls {@link Rekord.Collection#sort sort}.
@return {Rekord.Collection} -
The reference to this collection.
@emits Rekord.Collection#add
@emits Rekord.Collection#sort | [
"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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.