repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | createPredicateFn | function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
var predicateFn;
if (comparator === true) {
comparator = equals;
} else if (!isFunction(comparator)) {
comparator = function(actual, expected) {
if (isObject(actual) || isObject(expected)) {
// Prevent an object to be... | javascript | function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
var predicateFn;
if (comparator === true) {
comparator = equals;
} else if (!isFunction(comparator)) {
comparator = function(actual, expected) {
if (isObject(actual) || isObject(expected)) {
// Prevent an object to be... | [
"function",
"createPredicateFn",
"(",
"expression",
",",
"comparator",
",",
"matchAgainstAnyProp",
")",
"{",
"var",
"predicateFn",
";",
"if",
"(",
"comparator",
"===",
"true",
")",
"{",
"comparator",
"=",
"equals",
";",
"}",
"else",
"if",
"(",
"!",
"isFuncti... | Helper functions for `filterFilter` | [
"Helper",
"functions",
"for",
"filterFilter"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L24483-L24506 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | regExpPrefix | function regExpPrefix(re) {
var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source);
return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : '';
} | javascript | function regExpPrefix(re) {
var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source);
return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : '';
} | [
"function",
"regExpPrefix",
"(",
"re",
")",
"{",
"var",
"prefix",
"=",
"/",
"^\\^((?:\\\\[^a-zA-Z0-9]|[^\\\\\\[\\]\\^$*+?.()|{}]+)*)",
"/",
".",
"exec",
"(",
"re",
".",
"source",
")",
";",
"return",
"(",
"prefix",
"!=",
"null",
")",
"?",
"prefix",
"[",
"1",
... | Returns a string that is a prefix of all strings matching the RegExp | [
"Returns",
"a",
"string",
"that",
"is",
"a",
"prefix",
"of",
"all",
"strings",
"matching",
"the",
"RegExp"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L38394-L38397 | train |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | function(scope, element, attr) {
attr.$observe(ngAttrName, function(value) {
if (!value) {
element[0].removeAttribute(attrName);
}
});
} | javascript | function(scope, element, attr) {
attr.$observe(ngAttrName, function(value) {
if (!value) {
element[0].removeAttribute(attrName);
}
});
} | [
"function",
"(",
"scope",
",",
"element",
",",
"attr",
")",
"{",
"attr",
".",
"$observe",
"(",
"ngAttrName",
",",
"function",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"value",
")",
"{",
"element",
"[",
"0",
"]",
".",
"removeAttribute",
"(",
"attrName"... | it needs to run after the attributes are interpolated | [
"it",
"needs",
"to",
"run",
"after",
"the",
"attributes",
"are",
"interpolated"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L48701-L48707 | train | |
ionic-team/ng-cordova | demo/www/lib/ionic/js/ionic.bundle.js | onContentTap | function onContentTap(gestureEvt) {
if (sideMenuCtrl.getOpenAmount() !== 0) {
sideMenuCtrl.close();
gestureEvt.gesture.srcEvent.preventDefault();
startCoord = null;
primaryScrollAxis = null;
} else if (!startCoord) {
startCoord = ionic.tap.... | javascript | function onContentTap(gestureEvt) {
if (sideMenuCtrl.getOpenAmount() !== 0) {
sideMenuCtrl.close();
gestureEvt.gesture.srcEvent.preventDefault();
startCoord = null;
primaryScrollAxis = null;
} else if (!startCoord) {
startCoord = ionic.tap.... | [
"function",
"onContentTap",
"(",
"gestureEvt",
")",
"{",
"if",
"(",
"sideMenuCtrl",
".",
"getOpenAmount",
"(",
")",
"!==",
"0",
")",
"{",
"sideMenuCtrl",
".",
"close",
"(",
")",
";",
"gestureEvt",
".",
"gesture",
".",
"srcEvent",
".",
"preventDefault",
"("... | Listen for taps on the content to close the menu | [
"Listen",
"for",
"taps",
"on",
"the",
"content",
"to",
"close",
"the",
"menu"
] | 2a401e063eda2889cd54abf17365c22286e32285 | https://github.com/ionic-team/ng-cordova/blob/2a401e063eda2889cd54abf17365c22286e32285/demo/www/lib/ionic/js/ionic.bundle.js#L51354-L51363 | train |
twbs/bootlint | src/bootlint.js | sortedColumnClasses | function sortedColumnClasses(classes) {
// extract column classes
var colClasses = [];
while (true) {
var match = COL_REGEX.exec(classes);
if (!match) {
break;
}
var colClass = match[0];
colClasses.push(colClass);
... | javascript | function sortedColumnClasses(classes) {
// extract column classes
var colClasses = [];
while (true) {
var match = COL_REGEX.exec(classes);
if (!match) {
break;
}
var colClass = match[0];
colClasses.push(colClass);
... | [
"function",
"sortedColumnClasses",
"(",
"classes",
")",
"{",
"// extract column classes",
"var",
"colClasses",
"=",
"[",
"]",
";",
"while",
"(",
"true",
")",
"{",
"var",
"match",
"=",
"COL_REGEX",
".",
"exec",
"(",
"classes",
")",
";",
"if",
"(",
"!",
"m... | Moves any grid column classes to the end of the class string and sorts the grid classes by ascending screen size.
@param {string} classes The "class" attribute of a DOM node
@returns {string} The processed "class" attribute value | [
"Moves",
"any",
"grid",
"column",
"classes",
"to",
"the",
"end",
"of",
"the",
"class",
"string",
"and",
"sorts",
"the",
"grid",
"classes",
"by",
"ascending",
"screen",
"size",
"."
] | c3f24dcfd3f5f341cc34682c2e487ac3dab6ab78 | https://github.com/twbs/bootlint/blob/c3f24dcfd3f5f341cc34682c2e487ac3dab6ab78/src/bootlint.js#L107-L122 | train |
twbs/bootlint | src/location.js | LocationIndex | function LocationIndex(string) {
// ensure newline termination
if (string[string.length - 1] !== '\n') {
string += '\n';
}
this._stringLength = string.length;
/*
* Each triple in _lineStartEndTriples consists of:
* [0], the 0-based line index of the ... | javascript | function LocationIndex(string) {
// ensure newline termination
if (string[string.length - 1] !== '\n') {
string += '\n';
}
this._stringLength = string.length;
/*
* Each triple in _lineStartEndTriples consists of:
* [0], the 0-based line index of the ... | [
"function",
"LocationIndex",
"(",
"string",
")",
"{",
"// ensure newline termination",
"if",
"(",
"string",
"[",
"string",
".",
"length",
"-",
"1",
"]",
"!==",
"'\\n'",
")",
"{",
"string",
"+=",
"'\\n'",
";",
"}",
"this",
".",
"_stringLength",
"=",
"string... | Maps code unit indices into the string to line numbers and column numbers.
@param {string} string String to construct the index for
@class | [
"Maps",
"code",
"unit",
"indices",
"into",
"the",
"string",
"to",
"line",
"numbers",
"and",
"column",
"numbers",
"."
] | c3f24dcfd3f5f341cc34682c2e487ac3dab6ab78 | https://github.com/twbs/bootlint/blob/c3f24dcfd3f5f341cc34682c2e487ac3dab6ab78/src/location.js#L23-L53 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | w | function w(d, outer) {
var width = self.options.cellSize*self._domainType[self.options.subDomain].column(d) + self.options.cellPadding*self._domainType[self.options.subDomain].column(d);
if (arguments.length === 2 && outer === true) {
return width += self.domainHorizontalLabelWidth + self.options.domainGutter + ... | javascript | function w(d, outer) {
var width = self.options.cellSize*self._domainType[self.options.subDomain].column(d) + self.options.cellPadding*self._domainType[self.options.subDomain].column(d);
if (arguments.length === 2 && outer === true) {
return width += self.domainHorizontalLabelWidth + self.options.domainGutter + ... | [
"function",
"w",
"(",
"d",
",",
"outer",
")",
"{",
"var",
"width",
"=",
"self",
".",
"options",
".",
"cellSize",
"*",
"self",
".",
"_domainType",
"[",
"self",
".",
"options",
".",
"subDomain",
"]",
".",
"column",
"(",
"d",
")",
"+",
"self",
".",
... | Return the width of the domain block, without the domain gutter @param int d Domain start timestamp | [
"Return",
"the",
"width",
"of",
"the",
"domain",
"block",
"without",
"the",
"domain",
"gutter"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L685-L691 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | h | function h(d, outer) {
var height = self.options.cellSize*self._domainType[self.options.subDomain].row(d) + self.options.cellPadding*self._domainType[self.options.subDomain].row(d);
if (arguments.length === 2 && outer === true) {
height += self.options.domainGutter + self.domainVerticalLabelHeight + self.options... | javascript | function h(d, outer) {
var height = self.options.cellSize*self._domainType[self.options.subDomain].row(d) + self.options.cellPadding*self._domainType[self.options.subDomain].row(d);
if (arguments.length === 2 && outer === true) {
height += self.options.domainGutter + self.domainVerticalLabelHeight + self.options... | [
"function",
"h",
"(",
"d",
",",
"outer",
")",
"{",
"var",
"height",
"=",
"self",
".",
"options",
".",
"cellSize",
"*",
"self",
".",
"_domainType",
"[",
"self",
".",
"options",
".",
"subDomain",
"]",
".",
"row",
"(",
"d",
")",
"+",
"self",
".",
"o... | Return the height of the domain block, without the domain gutter | [
"Return",
"the",
"height",
"of",
"the",
"domain",
"block",
"without",
"the",
"domain",
"gutter"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L694-L700 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | validateSelector | function validateSelector(selector, canBeFalse, name) {
if (((canBeFalse && selector === false) || selector instanceof Element || typeof selector === "string") && selector !== "") {
return true;
}
throw new Error("The " + name + " is not valid");
} | javascript | function validateSelector(selector, canBeFalse, name) {
if (((canBeFalse && selector === false) || selector instanceof Element || typeof selector === "string") && selector !== "") {
return true;
}
throw new Error("The " + name + " is not valid");
} | [
"function",
"validateSelector",
"(",
"selector",
",",
"canBeFalse",
",",
"name",
")",
"{",
"if",
"(",
"(",
"(",
"canBeFalse",
"&&",
"selector",
"===",
"false",
")",
"||",
"selector",
"instanceof",
"Element",
"||",
"typeof",
"selector",
"===",
"\"string\"",
"... | Validate that a queryString is valid
@param {Element|string|bool} selector The queryString to test
@param {bool} canBeFalse Whether false is an accepted and valid value
@param {string} name Name of the tested selector
@throws {Error} If the selector is not valid
@return {bool} True if the selector is a val... | [
"Validate",
"that",
"a",
"queryString",
"is",
"valid"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1171-L1176 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | validateDomainType | function validateDomainType() {
if (!parent._domainType.hasOwnProperty(options.domain) || options.domain === "min" || options.domain.substring(0, 2) === "x_") {
throw new Error("The domain '" + options.domain + "' is not valid");
}
if (!parent._domainType.hasOwnProperty(options.subDomain) || options.subDo... | javascript | function validateDomainType() {
if (!parent._domainType.hasOwnProperty(options.domain) || options.domain === "min" || options.domain.substring(0, 2) === "x_") {
throw new Error("The domain '" + options.domain + "' is not valid");
}
if (!parent._domainType.hasOwnProperty(options.subDomain) || options.subDo... | [
"function",
"validateDomainType",
"(",
")",
"{",
"if",
"(",
"!",
"parent",
".",
"_domainType",
".",
"hasOwnProperty",
"(",
"options",
".",
"domain",
")",
"||",
"options",
".",
"domain",
"===",
"\"min\"",
"||",
"options",
".",
"domain",
".",
"substring",
"(... | Ensure that the domain and subdomain are valid
@throw {Error} when domain or subdomain are not valid
@return {bool} True if domain and subdomain are valid and compatible | [
"Ensure",
"that",
"the",
"domain",
"and",
"subdomain",
"are",
"valid"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1205-L1219 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | autoAlignLabel | function autoAlignLabel() {
// Auto-align label, depending on it's position
if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("align"))) {
switch(options.label.position) {
case "left":
options.label.align = "right";
break;
case "righ... | javascript | function autoAlignLabel() {
// Auto-align label, depending on it's position
if (!settings.hasOwnProperty("label") || (settings.hasOwnProperty("label") && !settings.label.hasOwnProperty("align"))) {
switch(options.label.position) {
case "left":
options.label.align = "right";
break;
case "righ... | [
"function",
"autoAlignLabel",
"(",
")",
"{",
"// Auto-align label, depending on it's position",
"if",
"(",
"!",
"settings",
".",
"hasOwnProperty",
"(",
"\"label\"",
")",
"||",
"(",
"settings",
".",
"hasOwnProperty",
"(",
"\"label\"",
")",
"&&",
"!",
"settings",
".... | Fine-tune the label alignement depending on its position
@return void | [
"Fine",
"-",
"tune",
"the",
"label",
"alignement",
"depending",
"on",
"its",
"position"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1226-L1255 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | autoAddLegendMargin | function autoAddLegendMargin() {
switch(options.legendVerticalPosition) {
case "top":
options.legendMargin[2] = parent.DEFAULT_LEGEND_MARGIN;
break;
case "bottom":
options.legendMargin[0] = parent.DEFAULT_LEGEND_MARGIN;
break;
case "middle":
case "center":
options.legendMargin[options... | javascript | function autoAddLegendMargin() {
switch(options.legendVerticalPosition) {
case "top":
options.legendMargin[2] = parent.DEFAULT_LEGEND_MARGIN;
break;
case "bottom":
options.legendMargin[0] = parent.DEFAULT_LEGEND_MARGIN;
break;
case "middle":
case "center":
options.legendMargin[options... | [
"function",
"autoAddLegendMargin",
"(",
")",
"{",
"switch",
"(",
"options",
".",
"legendVerticalPosition",
")",
"{",
"case",
"\"top\"",
":",
"options",
".",
"legendMargin",
"[",
"2",
"]",
"=",
"parent",
".",
"DEFAULT_LEGEND_MARGIN",
";",
"break",
";",
"case",
... | If not specified, add some margin around the legend depending on its position
@return void | [
"If",
"not",
"specified",
"add",
"some",
"margin",
"around",
"the",
"legend",
"depending",
"on",
"its",
"position"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1262-L1274 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | expandMarginSetting | function expandMarginSetting(value) {
if (typeof value === "number") {
value = [value];
}
if (!Array.isArray(value)) {
console.log("Margin only takes an integer or an array of integers");
value = [0];
}
switch(value.length) {
case 1:
return [value[0], value[0], value[0], value[0]];
... | javascript | function expandMarginSetting(value) {
if (typeof value === "number") {
value = [value];
}
if (!Array.isArray(value)) {
console.log("Margin only takes an integer or an array of integers");
value = [0];
}
switch(value.length) {
case 1:
return [value[0], value[0], value[0], value[0]];
... | [
"function",
"expandMarginSetting",
"(",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"\"number\"",
")",
"{",
"value",
"=",
"[",
"value",
"]",
";",
"}",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"console",
".",
... | Expand a number of an array of numbers to an usable 4 values array
@param {integer|array} value
@return {array} array | [
"Expand",
"a",
"number",
"of",
"an",
"array",
"of",
"numbers",
"to",
"an",
"usable",
"4",
"values",
"array"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1282-L1304 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | addStyle | function addStyle(element) {
if (parent.legendScale === null) {
return false;
}
element.attr("fill", function(d) {
if (d.v === null && (options.hasOwnProperty("considerMissingDataAsZero") && !options.considerMissingDataAsZero)) {
if (options.legendColors.hasOwnProperty("base")) {
return opt... | javascript | function addStyle(element) {
if (parent.legendScale === null) {
return false;
}
element.attr("fill", function(d) {
if (d.v === null && (options.hasOwnProperty("considerMissingDataAsZero") && !options.considerMissingDataAsZero)) {
if (options.legendColors.hasOwnProperty("base")) {
return opt... | [
"function",
"addStyle",
"(",
"element",
")",
"{",
"if",
"(",
"parent",
".",
"legendScale",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"element",
".",
"attr",
"(",
"\"fill\"",
",",
"function",
"(",
"d",
")",
"{",
"if",
"(",
"d",
".",
"v",... | Colorize the cell via a style attribute if enabled | [
"Colorize",
"the",
"cell",
"via",
"a",
"style",
"attribute",
"if",
"enabled"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1395-L1419 | train |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(start) {
"use strict";
var parent = this;
return this.triggerEvent("afterLoadPreviousDomain", function() {
var subDomain = parent.getSubDomain(start);
return [subDomain.shift(), subDomain.pop()];
});
} | javascript | function(start) {
"use strict";
var parent = this;
return this.triggerEvent("afterLoadPreviousDomain", function() {
var subDomain = parent.getSubDomain(start);
return [subDomain.shift(), subDomain.pop()];
});
} | [
"function",
"(",
"start",
")",
"{",
"\"use strict\"",
";",
"var",
"parent",
"=",
"this",
";",
"return",
"this",
".",
"triggerEvent",
"(",
"\"afterLoadPreviousDomain\"",
",",
"function",
"(",
")",
"{",
"var",
"subDomain",
"=",
"parent",
".",
"getSubDomain",
"... | Event triggered after shifting the calendar one domain back
@param Date start Domain start date
@param Date end Domain end date | [
"Event",
"triggered",
"after",
"shifting",
"the",
"calendar",
"one",
"domain",
"back"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1564-L1572 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(n) {
"use strict";
if (this._minDomainReached || n === 0) {
return false;
}
var bound = this.loadNewDomains(this.NAVIGATE_LEFT, this.getDomain(this.getDomainKeys()[0], -n).reverse());
this.afterLoadPreviousDomain(bound.start);
this.checkIfMinDomainIsReached(bound.start, bound.end);
return ... | javascript | function(n) {
"use strict";
if (this._minDomainReached || n === 0) {
return false;
}
var bound = this.loadNewDomains(this.NAVIGATE_LEFT, this.getDomain(this.getDomainKeys()[0], -n).reverse());
this.afterLoadPreviousDomain(bound.start);
this.checkIfMinDomainIsReached(bound.start, bound.end);
return ... | [
"function",
"(",
"n",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"this",
".",
"_minDomainReached",
"||",
"n",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"var",
"bound",
"=",
"this",
".",
"loadNewDomains",
"(",
"this",
".",
"NAVIGATE_LEFT",
","... | Shift the calendar one domain backward
The previous domain is loaded only if it's not beyond the minDate
@param int n Number of domains to load
@return bool True if the previous domain was loaded, else false | [
"Shift",
"the",
"calendar",
"one",
"domain",
"backward"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1727-L1740 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function() {
"use strict";
return this._domains.keys()
.map(function(d) { return parseInt(d, 10); })
.sort(function(a,b) { return a-b; });
} | javascript | function() {
"use strict";
return this._domains.keys()
.map(function(d) { return parseInt(d, 10); })
.sort(function(a,b) { return a-b; });
} | [
"function",
"(",
")",
"{",
"\"use strict\"",
";",
"return",
"this",
".",
"_domains",
".",
"keys",
"(",
")",
".",
"map",
"(",
"function",
"(",
"d",
")",
"{",
"return",
"parseInt",
"(",
"d",
",",
"10",
")",
";",
"}",
")",
".",
"sort",
"(",
"functio... | Return the list of the calendar's domain timestamp
@return Array a sorted array of timestamp | [
"Return",
"the",
"list",
"of",
"the",
"calendar",
"s",
"domain",
"timestamp"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1830-L1836 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(d) {
"use strict";
d = new Date(d);
if (this.options.highlight.length > 0) {
for (var i in this.options.highlight) {
if (this.dateIsEqual(this.options.highlight[i], d)) {
return this.isNow(this.options.highlight[i]) ? " highlight-now": " highlight";
}
}
}
return "";
} | javascript | function(d) {
"use strict";
d = new Date(d);
if (this.options.highlight.length > 0) {
for (var i in this.options.highlight) {
if (this.dateIsEqual(this.options.highlight[i], d)) {
return this.isNow(this.options.highlight[i]) ? " highlight-now": " highlight";
}
}
}
return "";
} | [
"function",
"(",
"d",
")",
"{",
"\"use strict\"",
";",
"d",
"=",
"new",
"Date",
"(",
"d",
")",
";",
"if",
"(",
"this",
".",
"options",
".",
"highlight",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"this",
".",
"options",
".... | Return a classname if the specified date should be highlighted
@param timestamp date Date of the current subDomain
@return String the highlight class | [
"Return",
"a",
"classname",
"if",
"the",
"specified",
"date",
"should",
"be",
"highlighted"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1900-L1913 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(dateA, dateB) {
"use strict";
if(!(dateA instanceof Date)) {
dateA = new Date(dateA);
}
if (!(dateB instanceof Date)) {
dateB = new Date(dateB);
}
switch(this.options.subDomain) {
case "x_min":
case "min":
return dateA.getFullYear() === dateB.getFullYear() &&
dateA.getMonth() ==... | javascript | function(dateA, dateB) {
"use strict";
if(!(dateA instanceof Date)) {
dateA = new Date(dateA);
}
if (!(dateB instanceof Date)) {
dateB = new Date(dateB);
}
switch(this.options.subDomain) {
case "x_min":
case "min":
return dateA.getFullYear() === dateB.getFullYear() &&
dateA.getMonth() ==... | [
"function",
"(",
"dateA",
",",
"dateB",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"!",
"(",
"dateA",
"instanceof",
"Date",
")",
")",
"{",
"dateA",
"=",
"new",
"Date",
"(",
"dateA",
")",
";",
"}",
"if",
"(",
"!",
"(",
"dateB",
"instanceof",
"Date"... | Return whether 2 dates are equals
This function is subdomain-aware,
and dates comparison are dependent of the subdomain
@param Date dateA First date to compare
@param Date dateB Secon date to compare
@return bool true if the 2 dates are equals
/* jshint maxcomplexity: false | [
"Return",
"whether",
"2",
"dates",
"are",
"equals",
"This",
"function",
"is",
"subdomain",
"-",
"aware",
"and",
"dates",
"comparison",
"are",
"dependent",
"of",
"the",
"subdomain"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1938-L1979 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(dateA, dateB) {
"use strict";
if(!(dateA instanceof Date)) {
dateA = new Date(dateA);
}
if (!(dateB instanceof Date)) {
dateB = new Date(dateB);
}
function normalizedMillis(date, subdomain) {
switch(subdomain) {
case "x_min":
case "min":
return new Date(date.getFullYear(), da... | javascript | function(dateA, dateB) {
"use strict";
if(!(dateA instanceof Date)) {
dateA = new Date(dateA);
}
if (!(dateB instanceof Date)) {
dateB = new Date(dateB);
}
function normalizedMillis(date, subdomain) {
switch(subdomain) {
case "x_min":
case "min":
return new Date(date.getFullYear(), da... | [
"function",
"(",
"dateA",
",",
"dateB",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"!",
"(",
"dateA",
"instanceof",
"Date",
")",
")",
"{",
"dateA",
"=",
"new",
"Date",
"(",
"dateA",
")",
";",
"}",
"if",
"(",
"!",
"(",
"dateB",
"instanceof",
"Date"... | Returns wether or not dateA is less than or equal to dateB. This function is subdomain aware.
Performs automatic conversion of values.
@param dateA may be a number or a Date
@param dateB may be a number or a Date
@returns {boolean} | [
"Returns",
"wether",
"or",
"not",
"dateA",
"is",
"less",
"than",
"or",
"equal",
"to",
"dateB",
".",
"This",
"function",
"is",
"subdomain",
"aware",
".",
"Performs",
"automatic",
"conversion",
"of",
"values",
"."
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L1989-L2023 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(d) {
"use strict";
var f = this.options.weekStartOnMonday === true ? d3.time.format("%W"): d3.time.format("%U");
return f(d);
} | javascript | function(d) {
"use strict";
var f = this.options.weekStartOnMonday === true ? d3.time.format("%W"): d3.time.format("%U");
return f(d);
} | [
"function",
"(",
"d",
")",
"{",
"\"use strict\"",
";",
"var",
"f",
"=",
"this",
".",
"options",
".",
"weekStartOnMonday",
"===",
"true",
"?",
"d3",
".",
"time",
".",
"format",
"(",
"\"%W\"",
")",
":",
"d3",
".",
"time",
".",
"format",
"(",
"\"%U\"",
... | Return the week number of the year
Monday as the first day of the week
@return int Week number [0-53] | [
"Return",
"the",
"week",
"number",
"of",
"the",
"year",
"Monday",
"as",
"the",
"first",
"day",
"of",
"the",
"week"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2042-L2047 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function (d) {
"use strict";
if (typeof d === "number") {
d = new Date(d);
}
var monthFirstWeekNumber = this.getWeekNumber(new Date(d.getFullYear(), d.getMonth()));
return this.getWeekNumber(d) - monthFirstWeekNumber - 1;
} | javascript | function (d) {
"use strict";
if (typeof d === "number") {
d = new Date(d);
}
var monthFirstWeekNumber = this.getWeekNumber(new Date(d.getFullYear(), d.getMonth()));
return this.getWeekNumber(d) - monthFirstWeekNumber - 1;
} | [
"function",
"(",
"d",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"typeof",
"d",
"===",
"\"number\"",
")",
"{",
"d",
"=",
"new",
"Date",
"(",
"d",
")",
";",
"}",
"var",
"monthFirstWeekNumber",
"=",
"this",
".",
"getWeekNumber",
"(",
"new",
"Date",
"(... | Return the week number, relative to its month
@param int|Date d Date or timestamp in milliseconds
@return int Week number, relative to the month [0-5] | [
"Return",
"the",
"week",
"number",
"relative",
"to",
"its",
"month"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2055-L2064 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(d) {
"use strict";
if (this.options.weekStartOnMonday === false) {
return d.getDay();
}
return d.getDay() === 0 ? 6 : (d.getDay()-1);
} | javascript | function(d) {
"use strict";
if (this.options.weekStartOnMonday === false) {
return d.getDay();
}
return d.getDay() === 0 ? 6 : (d.getDay()-1);
} | [
"function",
"(",
"d",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"this",
".",
"options",
".",
"weekStartOnMonday",
"===",
"false",
")",
"{",
"return",
"d",
".",
"getDay",
"(",
")",
";",
"}",
"return",
"d",
".",
"getDay",
"(",
")",
"===",
"0",
"?",... | Get the weekday from a date
Return the week day number (0-6) of a date,
depending on whether the week start on monday or sunday
@param Date d
@return int The week day number (0-6) | [
"Get",
"the",
"weekday",
"from",
"a",
"date"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2116-L2123 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(d) {
"use strict";
if (typeof d === "number") {
d = new Date(d);
}
return new Date(d.getFullYear(), d.getMonth()+1, 0);
} | javascript | function(d) {
"use strict";
if (typeof d === "number") {
d = new Date(d);
}
return new Date(d.getFullYear(), d.getMonth()+1, 0);
} | [
"function",
"(",
"d",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"typeof",
"d",
"===",
"\"number\"",
")",
"{",
"d",
"=",
"new",
"Date",
"(",
"d",
")",
";",
"}",
"return",
"new",
"Date",
"(",
"d",
".",
"getFullYear",
"(",
")",
",",
"d",
".",
"g... | Get the last day of the month
@param Date|int d Date or timestamp in milliseconds
@return Date Last day of the month | [
"Get",
"the",
"last",
"day",
"of",
"the",
"month"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2130-L2137 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function (d, range) {
"use strict";
var start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), range.getMonth(), range.getDate(), range.getHours());
} else {
stop = new Date(start);
stop.setHours(... | javascript | function (d, range) {
"use strict";
var start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), range.getMonth(), range.getDate(), range.getHours());
} else {
stop = new Date(start);
stop.setHours(... | [
"function",
"(",
"d",
",",
"range",
")",
"{",
"\"use strict\"",
";",
"var",
"start",
"=",
"new",
"Date",
"(",
"d",
".",
"getFullYear",
"(",
")",
",",
"d",
".",
"getMonth",
"(",
")",
",",
"d",
".",
"getDate",
"(",
")",
",",
"d",
".",
"getHours",
... | Return all the hours between 2 dates
@param Date d A date
@param int|date range Number of hours in the range, or a stop date
@return array An array of hours | [
"Return",
"all",
"the",
"hours",
"between",
"2",
"dates"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2201-L2235 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function (d, range) {
"use strict";
var start = new Date(d.getFullYear(), d.getMonth(), d.getDate());
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), range.getMonth(), range.getDate());
} else {
stop = new Date(start);
stop = new Date(stop.setDate(stop.getDate() + ... | javascript | function (d, range) {
"use strict";
var start = new Date(d.getFullYear(), d.getMonth(), d.getDate());
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), range.getMonth(), range.getDate());
} else {
stop = new Date(start);
stop = new Date(stop.setDate(stop.getDate() + ... | [
"function",
"(",
"d",
",",
"range",
")",
"{",
"\"use strict\"",
";",
"var",
"start",
"=",
"new",
"Date",
"(",
"d",
".",
"getFullYear",
"(",
")",
",",
"d",
".",
"getMonth",
"(",
")",
",",
"d",
".",
"getDate",
"(",
")",
")",
";",
"var",
"stop",
"... | Return all the days between 2 dates
@param Date d A date
@param int|date range Number of days in the range, or a stop date
@return array An array of weeks | [
"Return",
"all",
"the",
"days",
"between",
"2",
"dates"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2244-L2257 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function (d, range) {
"use strict";
var weekStart;
if (this.options.weekStartOnMonday === false) {
weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate() - d.getDay());
} else {
if (d.getDay() === 1) {
weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate());
} else if (d.getDay(... | javascript | function (d, range) {
"use strict";
var weekStart;
if (this.options.weekStartOnMonday === false) {
weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate() - d.getDay());
} else {
if (d.getDay() === 1) {
weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate());
} else if (d.getDay(... | [
"function",
"(",
"d",
",",
"range",
")",
"{",
"\"use strict\"",
";",
"var",
"weekStart",
";",
"if",
"(",
"this",
".",
"options",
".",
"weekStartOnMonday",
"===",
"false",
")",
"{",
"weekStart",
"=",
"new",
"Date",
"(",
"d",
".",
"getFullYear",
"(",
")"... | Return all the weeks between 2 dates
@param Date d A date
@param int|date range Number of minutes in the range, or a stop date
@return array An array of weeks | [
"Return",
"all",
"the",
"weeks",
"between",
"2",
"dates"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2266-L2295 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function (d, range) {
"use strict";
var start = new Date(d.getFullYear(), d.getMonth());
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), range.getMonth());
} else {
stop = new Date(start);
stop = stop.setMonth(stop.getMonth()+range);
}
return d3.time.months(Ma... | javascript | function (d, range) {
"use strict";
var start = new Date(d.getFullYear(), d.getMonth());
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), range.getMonth());
} else {
stop = new Date(start);
stop = stop.setMonth(stop.getMonth()+range);
}
return d3.time.months(Ma... | [
"function",
"(",
"d",
",",
"range",
")",
"{",
"\"use strict\"",
";",
"var",
"start",
"=",
"new",
"Date",
"(",
"d",
".",
"getFullYear",
"(",
")",
",",
"d",
".",
"getMonth",
"(",
")",
")",
";",
"var",
"stop",
"=",
"null",
";",
"if",
"(",
"range",
... | Return all the months between 2 dates
@param Date d A date
@param int|date range Number of months in the range, or a stop date
@return array An array of months | [
"Return",
"all",
"the",
"months",
"between",
"2",
"dates"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2304-L2317 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(d, range){
"use strict";
var start = new Date(d.getFullYear(), 0);
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), 0);
} else {
stop = new Date(d.getFullYear()+range, 0);
}
return d3.time.years(Math.min(start, stop), Math.max(start, stop));
} | javascript | function(d, range){
"use strict";
var start = new Date(d.getFullYear(), 0);
var stop = null;
if (range instanceof Date) {
stop = new Date(range.getFullYear(), 0);
} else {
stop = new Date(d.getFullYear()+range, 0);
}
return d3.time.years(Math.min(start, stop), Math.max(start, stop));
} | [
"function",
"(",
"d",
",",
"range",
")",
"{",
"\"use strict\"",
";",
"var",
"start",
"=",
"new",
"Date",
"(",
"d",
".",
"getFullYear",
"(",
")",
",",
"0",
")",
";",
"var",
"stop",
"=",
"null",
";",
"if",
"(",
"range",
"instanceof",
"Date",
")",
"... | Return all the years between 2 dates
@param Date d date A date
@param int|date range Number of minutes in the range, or a stop date
@return array An array of hours | [
"Return",
"all",
"the",
"years",
"between",
"2",
"dates"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2326-L2338 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(date, range) {
"use strict";
if (typeof date === "number") {
date = new Date(date);
}
if (arguments.length < 2) {
range = this.options.range;
}
switch(this.options.domain) {
case "hour" :
var domains = this.getHourDomain(date, range);
// Case where an hour is missing, when passing... | javascript | function(date, range) {
"use strict";
if (typeof date === "number") {
date = new Date(date);
}
if (arguments.length < 2) {
range = this.options.range;
}
switch(this.options.domain) {
case "hour" :
var domains = this.getHourDomain(date, range);
// Case where an hour is missing, when passing... | [
"function",
"(",
"date",
",",
"range",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"typeof",
"date",
"===",
"\"number\"",
")",
"{",
"date",
"=",
"new",
"Date",
"(",
"date",
")",
";",
"}",
"if",
"(",
"arguments",
".",
"length",
"<",
"2",
")",
"{",
... | Get an array of domain start dates
@param int|Date date A random date included in the wanted domain
@param int|Date range Number of dates to get, or a stop date
@return Array of dates | [
"Get",
"an",
"array",
"of",
"domain",
"start",
"dates"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2347-L2381 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(data, updateMode, startDate, endDate) {
"use strict";
if (updateMode === this.RESET_ALL_ON_UPDATE) {
this._domains.forEach(function(key, value) {
value.forEach(function(element, index, array) {
array[index].v = null;
});
});
}
var temp = {};
var extractTime = function(d) { retur... | javascript | function(data, updateMode, startDate, endDate) {
"use strict";
if (updateMode === this.RESET_ALL_ON_UPDATE) {
this._domains.forEach(function(key, value) {
value.forEach(function(element, index, array) {
array[index].v = null;
});
});
}
var temp = {};
var extractTime = function(d) { retur... | [
"function",
"(",
"data",
",",
"updateMode",
",",
"startDate",
",",
"endDate",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"updateMode",
"===",
"this",
".",
"RESET_ALL_ON_UPDATE",
")",
"{",
"this",
".",
"_domains",
".",
"forEach",
"(",
"function",
"(",
"key... | Populate the calendar internal data
@param object data
@param constant updateMode
@param Date startDate
@param Date endDate
@return void | [
"Populate",
"the",
"calendar",
"internal",
"data"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2615-L2669 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function() {
"use strict";
var parent = this;
var options = parent.options;
var legendWidth = options.displayLegend ? (parent.Legend.getDim("width") + options.legendMargin[1] + options.legendMargin[3]) : 0;
var legendHeight = options.displayLegend ? (parent.Legend.getDim("height") + options.legendMargin[0] +... | javascript | function() {
"use strict";
var parent = this;
var options = parent.options;
var legendWidth = options.displayLegend ? (parent.Legend.getDim("width") + options.legendMargin[1] + options.legendMargin[3]) : 0;
var legendHeight = options.displayLegend ? (parent.Legend.getDim("height") + options.legendMargin[0] +... | [
"function",
"(",
")",
"{",
"\"use strict\"",
";",
"var",
"parent",
"=",
"this",
";",
"var",
"options",
"=",
"parent",
".",
"options",
";",
"var",
"legendWidth",
"=",
"options",
".",
"displayLegend",
"?",
"(",
"parent",
".",
"Legend",
".",
"getDim",
"(",
... | Handle the calendar layout and dimension
Expand and shrink the container depending on its children dimension
Also rearrange the children position depending on their dimension,
and the legend position
@return void | [
"Handle",
"the",
"calendar",
"layout",
"and",
"dimension"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2706-L2749 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(date, reset) {
"use strict";
if (arguments.length < 2) {
reset = false;
}
var domains = this.getDomainKeys();
var firstDomain = domains[0];
var lastDomain = domains[domains.length-1];
if (date < firstDomain) {
return this.loadPreviousDomain(this.getDomain(firstDomain, date).length);
} e... | javascript | function(date, reset) {
"use strict";
if (arguments.length < 2) {
reset = false;
}
var domains = this.getDomainKeys();
var firstDomain = domains[0];
var lastDomain = domains[domains.length-1];
if (date < firstDomain) {
return this.loadPreviousDomain(this.getDomain(firstDomain, date).length);
} e... | [
"function",
"(",
"date",
",",
"reset",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"arguments",
".",
"length",
"<",
"2",
")",
"{",
"reset",
"=",
"false",
";",
"}",
"var",
"domains",
"=",
"this",
".",
"getDomainKeys",
"(",
")",
";",
"var",
"firstDomai... | Jump directly to a specific date
JumpTo will scroll the calendar until the wanted domain with the specified
date is visible. Unless you set reset to true, the wanted domain
will not necessarily be the first (leftmost) domain of the calendar.
@param Date date Jump to the domain containing that date
@param bool reset W... | [
"Jump",
"directly",
"to",
"a",
"specific",
"date"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2790-L2813 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(dataSource, afterLoad, updateMode) {
"use strict";
if (arguments.length === 0) {
dataSource = this.options.data;
}
if (arguments.length < 2) {
afterLoad = true;
}
if (arguments.length < 3) {
updateMode = this.RESET_ALL_ON_UPDATE;
}
var domains = this.getDomainKeys();
var self = thi... | javascript | function(dataSource, afterLoad, updateMode) {
"use strict";
if (arguments.length === 0) {
dataSource = this.options.data;
}
if (arguments.length < 2) {
afterLoad = true;
}
if (arguments.length < 3) {
updateMode = this.RESET_ALL_ON_UPDATE;
}
var domains = this.getDomainKeys();
var self = thi... | [
"function",
"(",
"dataSource",
",",
"afterLoad",
",",
"updateMode",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"dataSource",
"=",
"this",
".",
"options",
".",
"data",
";",
"}",
"if",
"(",
"arguments",
... | Update the calendar with new data
@param object|string dataSource The calendar's datasource, same type as this.options.data
@param boolean|function afterLoad Whether to execute afterLoad() on the data. Pass directly a function
if you don't want to use the afterLoad() callback | [
"Update",
"the",
"calendar",
"with",
"new",
"data"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2834-L2860 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | function(callback) {
"use strict";
this.root.transition().duration(this.options.animationDuration)
.attr("width", 0)
.attr("height", 0)
.remove()
.each("end", function() {
if (typeof callback === "function") {
callback();
} else if (typeof callback !== "undefined") {
console.log("Prov... | javascript | function(callback) {
"use strict";
this.root.transition().duration(this.options.animationDuration)
.attr("width", 0)
.attr("height", 0)
.remove()
.each("end", function() {
if (typeof callback === "function") {
callback();
} else if (typeof callback !== "undefined") {
console.log("Prov... | [
"function",
"(",
"callback",
")",
"{",
"\"use strict\"",
";",
"this",
".",
"root",
".",
"transition",
"(",
")",
".",
"duration",
"(",
"this",
".",
"options",
".",
"animationDuration",
")",
".",
"attr",
"(",
"\"width\"",
",",
"0",
")",
".",
"attr",
"(",... | Destroy the calendar
Usage: cal = cal.destroy();
@since 3.3.6
@param function A callback function to trigger after destroying the calendar
@return null | [
"Destroy",
"the",
"calendar"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L2951-L2968 | train | |
wa0x6e/cal-heatmap | src/cal-heatmap.js | arrayEquals | function arrayEquals(arrayA, arrayB) {
"use strict";
// if the other array is a falsy value, return
if (!arrayB || !arrayA) {
return false;
}
// compare lengths - can save a lot of time
if (arrayA.length !== arrayB.length) {
return false;
}
for (var i = 0; i < arrayA.length; i++) {
// Check if we have ... | javascript | function arrayEquals(arrayA, arrayB) {
"use strict";
// if the other array is a falsy value, return
if (!arrayB || !arrayA) {
return false;
}
// compare lengths - can save a lot of time
if (arrayA.length !== arrayB.length) {
return false;
}
for (var i = 0; i < arrayA.length; i++) {
// Check if we have ... | [
"function",
"arrayEquals",
"(",
"arrayA",
",",
"arrayB",
")",
"{",
"\"use strict\"",
";",
"// if the other array is a falsy value, return",
"if",
"(",
"!",
"arrayB",
"||",
"!",
"arrayA",
")",
"{",
"return",
"false",
";",
"}",
"// compare lengths - can save a lot of ti... | Check if 2 arrays are equals
@link http://stackoverflow.com/a/14853974/805649
@param array array the array to compare to
@return bool true of the 2 arrays are equals | [
"Check",
"if",
"2",
"arrays",
"are",
"equals"
] | 0b594620104e0b11a94cc45feb0a76b58a038e0e | https://github.com/wa0x6e/cal-heatmap/blob/0b594620104e0b11a94cc45feb0a76b58a038e0e/src/cal-heatmap.js#L3466-L3493 | train |
stjohnjohnson/smartthings-mqtt-bridge | server.js | loadSavedState | function loadSavedState () {
var output;
try {
output = jsonfile.readFileSync(STATE_FILE);
} catch (ex) {
winston.info('No previous state found, continuing');
output = {
subscriptions: [],
callback: '',
history: {},
version: '0.0.0'
... | javascript | function loadSavedState () {
var output;
try {
output = jsonfile.readFileSync(STATE_FILE);
} catch (ex) {
winston.info('No previous state found, continuing');
output = {
subscriptions: [],
callback: '',
history: {},
version: '0.0.0'
... | [
"function",
"loadSavedState",
"(",
")",
"{",
"var",
"output",
";",
"try",
"{",
"output",
"=",
"jsonfile",
".",
"readFileSync",
"(",
"STATE_FILE",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"winston",
".",
"info",
"(",
"'No previous state found, continuing'... | Load the saved previous state from disk
@method loadSavedState
@return {Object} Configuration | [
"Load",
"the",
"saved",
"previous",
"state",
"from",
"disk"
] | 066d3f492e2f9d9016964bef191230b99cb4e0c8 | https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/066d3f492e2f9d9016964bef191230b99cb4e0c8/server.js#L71-L85 | train |
stjohnjohnson/smartthings-mqtt-bridge | server.js | saveState | function saveState () {
winston.info('Saving current state');
jsonfile.writeFileSync(STATE_FILE, {
subscriptions: subscriptions,
callback: callback,
history: history,
version: CURRENT_VERSION
}, {
spaces: 4
});
} | javascript | function saveState () {
winston.info('Saving current state');
jsonfile.writeFileSync(STATE_FILE, {
subscriptions: subscriptions,
callback: callback,
history: history,
version: CURRENT_VERSION
}, {
spaces: 4
});
} | [
"function",
"saveState",
"(",
")",
"{",
"winston",
".",
"info",
"(",
"'Saving current state'",
")",
";",
"jsonfile",
".",
"writeFileSync",
"(",
"STATE_FILE",
",",
"{",
"subscriptions",
":",
"subscriptions",
",",
"callback",
":",
"callback",
",",
"history",
":"... | Resubscribe on a periodic basis
@method saveState | [
"Resubscribe",
"on",
"a",
"periodic",
"basis"
] | 066d3f492e2f9d9016964bef191230b99cb4e0c8 | https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/066d3f492e2f9d9016964bef191230b99cb4e0c8/server.js#L91-L101 | train |
stjohnjohnson/smartthings-mqtt-bridge | server.js | migrateState | function migrateState (version) {
// Make sure the object exists
if (!config.mqtt) {
config.mqtt = {};
}
// This is the previous default, but it's totally wrong
if (!config.mqtt.preface) {
config.mqtt.preface = '/smartthings';
}
// Default Suffixes
if (!config.mqtt[SUFF... | javascript | function migrateState (version) {
// Make sure the object exists
if (!config.mqtt) {
config.mqtt = {};
}
// This is the previous default, but it's totally wrong
if (!config.mqtt.preface) {
config.mqtt.preface = '/smartthings';
}
// Default Suffixes
if (!config.mqtt[SUFF... | [
"function",
"migrateState",
"(",
"version",
")",
"{",
"// Make sure the object exists",
"if",
"(",
"!",
"config",
".",
"mqtt",
")",
"{",
"config",
".",
"mqtt",
"=",
"{",
"}",
";",
"}",
"// This is the previous default, but it's totally wrong",
"if",
"(",
"!",
"c... | Migrate the configuration from the current version to the latest version
@method migrateState
@param {String} version Version the state was written in before | [
"Migrate",
"the",
"configuration",
"from",
"the",
"current",
"version",
"to",
"the",
"latest",
"version"
] | 066d3f492e2f9d9016964bef191230b99cb4e0c8 | https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/066d3f492e2f9d9016964bef191230b99cb4e0c8/server.js#L108-L154 | train |
stjohnjohnson/smartthings-mqtt-bridge | server.js | handleSubscribeEvent | function handleSubscribeEvent (req, res) {
// Subscribe to all events
subscriptions = [];
Object.keys(req.body.devices).forEach(function (property) {
req.body.devices[property].forEach(function (device) {
subscriptions.push(getTopicFor(device, property, TOPIC_COMMAND));
subsc... | javascript | function handleSubscribeEvent (req, res) {
// Subscribe to all events
subscriptions = [];
Object.keys(req.body.devices).forEach(function (property) {
req.body.devices[property].forEach(function (device) {
subscriptions.push(getTopicFor(device, property, TOPIC_COMMAND));
subsc... | [
"function",
"handleSubscribeEvent",
"(",
"req",
",",
"res",
")",
"{",
"// Subscribe to all events",
"subscriptions",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"req",
".",
"body",
".",
"devices",
")",
".",
"forEach",
"(",
"function",
"(",
"property",
... | Handle Subscribe event from SmartThings
@method handleSubscribeEvent
@param {Request} req
@param {Object} req.body
@param {Object} req.body.devices List of properties => device names
@param {String} req.body.callback Host and port for SmartThings Hub
@param {Result} res Result Object | [
"Handle",
"Subscribe",
"event",
"from",
"SmartThings"
] | 066d3f492e2f9d9016964bef191230b99cb4e0c8 | https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/066d3f492e2f9d9016964bef191230b99cb4e0c8/server.js#L193-L216 | train |
stjohnjohnson/smartthings-mqtt-bridge | server.js | getTopicFor | function getTopicFor (device, property, type) {
var tree = [config.mqtt.preface, device, property],
suffix;
if (type === TOPIC_COMMAND) {
suffix = config.mqtt[SUFFIX_COMMAND];
} else if (type === TOPIC_READ_STATE) {
suffix = config.mqtt[SUFFIX_READ_STATE];
} else if (type === TO... | javascript | function getTopicFor (device, property, type) {
var tree = [config.mqtt.preface, device, property],
suffix;
if (type === TOPIC_COMMAND) {
suffix = config.mqtt[SUFFIX_COMMAND];
} else if (type === TOPIC_READ_STATE) {
suffix = config.mqtt[SUFFIX_READ_STATE];
} else if (type === TO... | [
"function",
"getTopicFor",
"(",
"device",
",",
"property",
",",
"type",
")",
"{",
"var",
"tree",
"=",
"[",
"config",
".",
"mqtt",
".",
"preface",
",",
"device",
",",
"property",
"]",
",",
"suffix",
";",
"if",
"(",
"type",
"===",
"TOPIC_COMMAND",
")",
... | Get the topic name for a given item
@method getTopicFor
@param {String} device Device Name
@param {String} property Property
@param {String} type Type of topic (command or state)
@return {String} MQTT Topic name | [
"Get",
"the",
"topic",
"name",
"for",
"a",
"given",
"item"
] | 066d3f492e2f9d9016964bef191230b99cb4e0c8 | https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/066d3f492e2f9d9016964bef191230b99cb4e0c8/server.js#L227-L244 | train |
stjohnjohnson/smartthings-mqtt-bridge | server.js | parseMQTTMessage | function parseMQTTMessage (topic, message) {
var contents = message.toString();
winston.info('Incoming message from MQTT: %s = %s', topic, contents);
// Remove the preface from the topic before splitting it
var pieces = topic.substr(config.mqtt.preface.length + 1).split('/'),
device = pieces[0]... | javascript | function parseMQTTMessage (topic, message) {
var contents = message.toString();
winston.info('Incoming message from MQTT: %s = %s', topic, contents);
// Remove the preface from the topic before splitting it
var pieces = topic.substr(config.mqtt.preface.length + 1).split('/'),
device = pieces[0]... | [
"function",
"parseMQTTMessage",
"(",
"topic",
",",
"message",
")",
"{",
"var",
"contents",
"=",
"message",
".",
"toString",
"(",
")",
";",
"winston",
".",
"info",
"(",
"'Incoming message from MQTT: %s = %s'",
",",
"topic",
",",
"contents",
")",
";",
"// Remove... | Parse incoming message from MQTT
@method parseMQTTMessage
@param {String} topic Topic channel the event came from
@param {String} message Contents of the event | [
"Parse",
"incoming",
"message",
"from",
"MQTT"
] | 066d3f492e2f9d9016964bef191230b99cb4e0c8 | https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/066d3f492e2f9d9016964bef191230b99cb4e0c8/server.js#L252-L306 | train |
publiclab/PublicLab.Editor | src/modules/PublicLab.TitleModule.Related.js | build | function build() {
module.el.find('.ple-module-content').append('<div style="display:none;" class="ple-title-related"></div>');
relatedEl = module.el.find('.ple-title-related');
relatedEl.append('<p class="ple-help">Does your work relate to one of these? Click to alert those contributors.</p><hr style="ma... | javascript | function build() {
module.el.find('.ple-module-content').append('<div style="display:none;" class="ple-title-related"></div>');
relatedEl = module.el.find('.ple-title-related');
relatedEl.append('<p class="ple-help">Does your work relate to one of these? Click to alert those contributors.</p><hr style="ma... | [
"function",
"build",
"(",
")",
"{",
"module",
".",
"el",
".",
"find",
"(",
"'.ple-module-content'",
")",
".",
"append",
"(",
"'<div style=\"display:none;\" class=\"ple-title-related\"></div>'",
")",
";",
"relatedEl",
"=",
"module",
".",
"el",
".",
"find",
"(",
"... | make an area for "related posts" to connect to | [
"make",
"an",
"area",
"for",
"related",
"posts",
"to",
"connect",
"to"
] | 03b7b24682aa860f6f589e93098dd12c496687b3 | https://github.com/publiclab/PublicLab.Editor/blob/03b7b24682aa860f6f589e93098dd12c496687b3/src/modules/PublicLab.TitleModule.Related.js#L34-L40 | train |
publiclab/PublicLab.Editor | src/adapters/PublicLab.Formatter.js | function() {
var _formatter = this;
// functions that accept standard <data> and output form data for known services
_formatter.schemas = {
"publiclab": function(data) {
var output = {};
output.title = data.title || null;
output.body = data.body... | javascript | function() {
var _formatter = this;
// functions that accept standard <data> and output form data for known services
_formatter.schemas = {
"publiclab": function(data) {
var output = {};
output.title = data.title || null;
output.body = data.body... | [
"function",
"(",
")",
"{",
"var",
"_formatter",
"=",
"this",
";",
"// functions that accept standard <data> and output form data for known services",
"_formatter",
".",
"schemas",
"=",
"{",
"\"publiclab\"",
":",
"function",
"(",
"data",
")",
"{",
"var",
"output",
"=",... | eventually we could accept both a format and a URL | [
"eventually",
"we",
"could",
"accept",
"both",
"a",
"format",
"and",
"a",
"URL"
] | 03b7b24682aa860f6f589e93098dd12c496687b3 | https://github.com/publiclab/PublicLab.Editor/blob/03b7b24682aa860f6f589e93098dd12c496687b3/src/adapters/PublicLab.Formatter.js#L12-L61 | train | |
PhilWaldmann/openrecord | lib/base/save.js | function(options) {
var self = this
options = options || {}
if (typeof options === 'function') throw new Error('then!')
return self
.validate()
.then(function() {
return self._create_or_update(options)
})
.then(function() {
// eliminate changes -> we just saved i... | javascript | function(options) {
var self = this
options = options || {}
if (typeof options === 'function') throw new Error('then!')
return self
.validate()
.then(function() {
return self._create_or_update(options)
})
.then(function() {
// eliminate changes -> we just saved i... | [
"function",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
"options",
"=",
"options",
"||",
"{",
"}",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"throw",
"new",
"Error",
"(",
"'then!'",
")",
"return",
"self",
".",
"validate",
"(",... | Save the current record
@class Record
@method save | [
"Save",
"the",
"current",
"record"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/save.js#L10-L27 | train | |
PhilWaldmann/openrecord | lib/base/json.js | function(allowedAttributes, exportObject) {
var definition = this.definition
var tmp = exportObject || definition.store.utils.clone(this.attributes)
for (var i in definition.relations) {
var relation = definition.relations[i]
if (this['_' + relation.name]) {
tmp[relation.name] = this['_... | javascript | function(allowedAttributes, exportObject) {
var definition = this.definition
var tmp = exportObject || definition.store.utils.clone(this.attributes)
for (var i in definition.relations) {
var relation = definition.relations[i]
if (this['_' + relation.name]) {
tmp[relation.name] = this['_... | [
"function",
"(",
"allowedAttributes",
",",
"exportObject",
")",
"{",
"var",
"definition",
"=",
"this",
".",
"definition",
"var",
"tmp",
"=",
"exportObject",
"||",
"definition",
".",
"store",
".",
"utils",
".",
"clone",
"(",
"this",
".",
"attributes",
")",
... | Returns an object which represent the record in plain json
@class Record
@method toJson
@param {array} allowedAttributes - Optional: Only export the given attributes and/or relations
@param {object} exportObject - Optional: By default, OpenRecord clones the `attributes` object. If you specify the `exportObject` it wil... | [
"Returns",
"an",
"object",
"which",
"represent",
"the",
"record",
"in",
"plain",
"json"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/json.js#L12-L52 | train | |
PhilWaldmann/openrecord | lib/base/json.js | function(allowedAttributes) {
var tmp = []
this.forEach(function(record) {
tmp.push(record.toJson(allowedAttributes))
})
return tmp
} | javascript | function(allowedAttributes) {
var tmp = []
this.forEach(function(record) {
tmp.push(record.toJson(allowedAttributes))
})
return tmp
} | [
"function",
"(",
"allowedAttributes",
")",
"{",
"var",
"tmp",
"=",
"[",
"]",
"this",
".",
"forEach",
"(",
"function",
"(",
"record",
")",
"{",
"tmp",
".",
"push",
"(",
"record",
".",
"toJson",
"(",
"allowedAttributes",
")",
")",
"}",
")",
"return",
"... | Returns an array of objects which represent the records in plain json
@class Collection
@method toJson
@param {array} allowedAttributes - Optional: Only export the given attributes and/or relations
@return {array} | [
"Returns",
"an",
"array",
"of",
"objects",
"which",
"represent",
"the",
"records",
"in",
"plain",
"json"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/json.js#L70-L76 | train | |
PhilWaldmann/openrecord | lib/base/scope.js | function(name, fn, lazy) {
const Utils = this.store.utils
if (!fn && this.model) fn = this.model[name]
if (!fn)
throw new Error('You need to provide a function in order to use a scope')
var tmp = function() {
var args = Utils.args(arguments)
const self = this.chain()._unresolve() // ... | javascript | function(name, fn, lazy) {
const Utils = this.store.utils
if (!fn && this.model) fn = this.model[name]
if (!fn)
throw new Error('You need to provide a function in order to use a scope')
var tmp = function() {
var args = Utils.args(arguments)
const self = this.chain()._unresolve() // ... | [
"function",
"(",
"name",
",",
"fn",
",",
"lazy",
")",
"{",
"const",
"Utils",
"=",
"this",
".",
"store",
".",
"utils",
"if",
"(",
"!",
"fn",
"&&",
"this",
".",
"model",
")",
"fn",
"=",
"this",
".",
"model",
"[",
"name",
"]",
"if",
"(",
"!",
"f... | scope callback function
@public
@callback scopeFN
@param {*} args - All caller arguments
@return *
@this Model
Creates a custom chained Model method
@public
@memberof Definition
@method scope
@param {string} name - The name of the scope
@param {scopeFN} callback - The scope function
@return {Definition} | [
"scope",
"callback",
"function"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/scope.js#L35-L60 | train | |
PhilWaldmann/openrecord | lib/base/chainable.js | function(options) {
options = options || {}
if (this.chained && options.clone !== true) return this
var ChainModel = new this.definition.ChainGenerator(options)
if (this.chained && options.clone === true) {
ChainModel._internal_attributes = this.definition.store.utils.clone(
this._intern... | javascript | function(options) {
options = options || {}
if (this.chained && options.clone !== true) return this
var ChainModel = new this.definition.ChainGenerator(options)
if (this.chained && options.clone === true) {
ChainModel._internal_attributes = this.definition.store.utils.clone(
this._intern... | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
"if",
"(",
"this",
".",
"chained",
"&&",
"options",
".",
"clone",
"!==",
"true",
")",
"return",
"this",
"var",
"ChainModel",
"=",
"new",
"this",
".",
"definition",
".",
... | Returns a Collection, which is in fact a cloned Model - or a chained Model
A Collectioin is an Array with all of Models' methods. All `where`, `limit`, `setContext`, ... information will be stored in this chained Model to allow asynchronous usage.
@class Model
@method chain
@param {object} options - The options hash
@... | [
"Returns",
"a",
"Collection",
"which",
"is",
"in",
"fact",
"a",
"cloned",
"Model",
"-",
"or",
"a",
"chained",
"Model",
"A",
"Collectioin",
"is",
"an",
"Array",
"with",
"all",
"of",
"Models",
"methods",
".",
"All",
"where",
"limit",
"setContext",
"...",
"... | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/chainable.js#L82-L98 | train | |
PhilWaldmann/openrecord | lib/base/relations.js | function() {
var self = this
Object.keys(this.definition.relations).forEach(function(key) {
delete self.relations[key]
})
return this
} | javascript | function() {
var self = this
Object.keys(this.definition.relations).forEach(function(key) {
delete self.relations[key]
})
return this
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
"Object",
".",
"keys",
"(",
"this",
".",
"definition",
".",
"relations",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"delete",
"self",
".",
"relations",
"[",
"key",
"]",
"}",
")... | clear all loadede relations | [
"clear",
"all",
"loadede",
"relations"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/relations.js#L276-L284 | train | |
PhilWaldmann/openrecord | lib/base/attributes.js | function(name, type, options) {
const Store = require('../store')
options = options || {}
type = type || String
if (typeof type === 'string') {
type = type.toLowerCase()
}
var fieldType = this.store.getType(type)
if (!fieldType) {
throw new Store.UnknownAttributeTypeError(type)... | javascript | function(name, type, options) {
const Store = require('../store')
options = options || {}
type = type || String
if (typeof type === 'string') {
type = type.toLowerCase()
}
var fieldType = this.store.getType(type)
if (!fieldType) {
throw new Store.UnknownAttributeTypeError(type)... | [
"function",
"(",
"name",
",",
"type",
",",
"options",
")",
"{",
"const",
"Store",
"=",
"require",
"(",
"'../store'",
")",
"options",
"=",
"options",
"||",
"{",
"}",
"type",
"=",
"type",
"||",
"String",
"if",
"(",
"typeof",
"type",
"===",
"'string'",
... | Add a new attribute to your Model
@public
@memberof Definition
@method attribute
@param {string} name - The attribute name
@param {string} type - The attribute type (e.g. `text`, `integer`, or sql language specific. e.g. `blob`)
@param {object} [options] - Optional options
@param {boolean} [options.writable=true] - ma... | [
"Add",
"a",
"new",
"attribute",
"to",
"your",
"Model"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/attributes.js#L56-L106 | train | |
PhilWaldmann/openrecord | lib/base/attributes.js | function(name, fn) {
const externalName = this.store.toExternalAttributeName(name)
this.instanceMethods.__defineSetter__(name, fn)
if(externalName !== name) this.instanceMethods.__defineSetter__(externalName, fn)
return this
} | javascript | function(name, fn) {
const externalName = this.store.toExternalAttributeName(name)
this.instanceMethods.__defineSetter__(name, fn)
if(externalName !== name) this.instanceMethods.__defineSetter__(externalName, fn)
return this
} | [
"function",
"(",
"name",
",",
"fn",
")",
"{",
"const",
"externalName",
"=",
"this",
".",
"store",
".",
"toExternalAttributeName",
"(",
"name",
")",
"this",
".",
"instanceMethods",
".",
"__defineSetter__",
"(",
"name",
",",
"fn",
")",
"if",
"(",
"externalNa... | Add a custom setter to your record
@class Definition
@method setter
@param {string} name - The setter name
@param {function} fn - The method to call
@return {Definition} | [
"Add",
"a",
"custom",
"setter",
"to",
"your",
"record"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/attributes.js#L169-L174 | train | |
PhilWaldmann/openrecord | lib/base/attributes.js | function(name, fn) {
const _name = this.store.toInternalAttributeName(name)
const Store = require('../store')
if (!this.attributes[_name]) throw new Store.UnknownAttributeError(name)
this.attributes[_name].variant = fn
this[name + '$'] = function(args) {
return fn.call(this, this[_name], arg... | javascript | function(name, fn) {
const _name = this.store.toInternalAttributeName(name)
const Store = require('../store')
if (!this.attributes[_name]) throw new Store.UnknownAttributeError(name)
this.attributes[_name].variant = fn
this[name + '$'] = function(args) {
return fn.call(this, this[_name], arg... | [
"function",
"(",
"name",
",",
"fn",
")",
"{",
"const",
"_name",
"=",
"this",
".",
"store",
".",
"toInternalAttributeName",
"(",
"name",
")",
"const",
"Store",
"=",
"require",
"(",
"'../store'",
")",
"if",
"(",
"!",
"this",
".",
"attributes",
"[",
"_nam... | Add a variant method to the specified attribute
@class Definition
@method variant
@param {string} name - The attribute name
@param {function} fn - The method to call
@return {Definition} | [
"Add",
"a",
"variant",
"method",
"to",
"the",
"specified",
"attribute"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/attributes.js#L186-L198 | train | |
PhilWaldmann/openrecord | lib/base/attributes.js | function(name, value) {
if (!name && !value) return
var values = name
var castType = value
var singleAssign = false
if (typeof name === 'string') {
values = {}
values[name] = value
castType = 'input'
singleAssign = true
}
for (var field in this.definition.attributes... | javascript | function(name, value) {
if (!name && !value) return
var values = name
var castType = value
var singleAssign = false
if (typeof name === 'string') {
values = {}
values[name] = value
castType = 'input'
singleAssign = true
}
for (var field in this.definition.attributes... | [
"function",
"(",
"name",
",",
"value",
")",
"{",
"if",
"(",
"!",
"name",
"&&",
"!",
"value",
")",
"return",
"var",
"values",
"=",
"name",
"var",
"castType",
"=",
"value",
"var",
"singleAssign",
"=",
"false",
"if",
"(",
"typeof",
"name",
"===",
"'stri... | Set one or multiple attributes of a Record.
@class Record
@method set
@param {string} name - The attributes name
@param {VALUE} value - The attributes value
@or
@param {object} attributes - Multiple attribute as an object
@param {string} cast_type - Optional cast_type name (Default: `input`)
@return {Record} | [
"Set",
"one",
"or",
"multiple",
"attributes",
"of",
"a",
"Record",
"."
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/attributes.js#L229-L337 | train | |
PhilWaldmann/openrecord | lib/base/attributes.js | function(name) {
var attr = this.definition.attributes[name]
if (attr) {
// set undefined values to null
if (this.attributes[name] === undefined) {
this.attributes[name] = null
}
return this.definition.cast(name, this.attributes[name], 'output', this)
}
return null
} | javascript | function(name) {
var attr = this.definition.attributes[name]
if (attr) {
// set undefined values to null
if (this.attributes[name] === undefined) {
this.attributes[name] = null
}
return this.definition.cast(name, this.attributes[name], 'output', this)
}
return null
} | [
"function",
"(",
"name",
")",
"{",
"var",
"attr",
"=",
"this",
".",
"definition",
".",
"attributes",
"[",
"name",
"]",
"if",
"(",
"attr",
")",
"{",
"// set undefined values to null",
"if",
"(",
"this",
".",
"attributes",
"[",
"name",
"]",
"===",
"undefin... | Get an attributes.
@class Record
@method get
@param {string} name - The attributes name
@return {VALUE} | [
"Get",
"an",
"attributes",
"."
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/attributes.js#L348-L361 | train | |
PhilWaldmann/openrecord | lib/base/attributes.js | function() {
this.checkObjectChanges()
var tmp = {}
for (var name in this.changes) {
if (this.changes.hasOwnProperty(name)) {
if (
!this.allowed_attributes ||
(this.allowed_attributes &&
this.allowed_attributes.indexOf(name) !== -1)
) {
tmp[nam... | javascript | function() {
this.checkObjectChanges()
var tmp = {}
for (var name in this.changes) {
if (this.changes.hasOwnProperty(name)) {
if (
!this.allowed_attributes ||
(this.allowed_attributes &&
this.allowed_attributes.indexOf(name) !== -1)
) {
tmp[nam... | [
"function",
"(",
")",
"{",
"this",
".",
"checkObjectChanges",
"(",
")",
"var",
"tmp",
"=",
"{",
"}",
"for",
"(",
"var",
"name",
"in",
"this",
".",
"changes",
")",
"{",
"if",
"(",
"this",
".",
"changes",
".",
"hasOwnProperty",
"(",
"name",
")",
")",... | Returns an object with all the changes. One attribute will always include the original and current value
@class Record
@method getChanges
@return {object} | [
"Returns",
"an",
"object",
"with",
"all",
"the",
"changes",
".",
"One",
"attribute",
"will",
"always",
"include",
"the",
"original",
"and",
"current",
"value"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/attributes.js#L397-L412 | train | |
PhilWaldmann/openrecord | lib/base/attributes.js | function() {
for (var name in this.changes) {
if (this.changes.hasOwnProperty(name)) {
this.attributes[name] = this.changes[name][0]
}
}
this.changes = {}
return this
} | javascript | function() {
for (var name in this.changes) {
if (this.changes.hasOwnProperty(name)) {
this.attributes[name] = this.changes[name][0]
}
}
this.changes = {}
return this
} | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"this",
".",
"changes",
")",
"{",
"if",
"(",
"this",
".",
"changes",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"this",
".",
"attributes",
"[",
"name",
"]",
"=",
"this",
".",
"ch... | Resets all changes to the original values
@class Record
@method resetChanges
@return {Record} | [
"Resets",
"all",
"changes",
"to",
"the",
"original",
"values"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/attributes.js#L447-L456 | train | |
PhilWaldmann/openrecord | lib/base/conditions.js | function() {
const Utils = this.definition.store.utils
const self = this.chain()._unresolve() // if the collection is already resolved, return a unresolved and empty copy!
const existingConditions = self.getInternal('conditions') || []
const existingMap = {}
existingConditions.forEach(function(con... | javascript | function() {
const Utils = this.definition.store.utils
const self = this.chain()._unresolve() // if the collection is already resolved, return a unresolved and empty copy!
const existingConditions = self.getInternal('conditions') || []
const existingMap = {}
existingConditions.forEach(function(con... | [
"function",
"(",
")",
"{",
"const",
"Utils",
"=",
"this",
".",
"definition",
".",
"store",
".",
"utils",
"const",
"self",
"=",
"this",
".",
"chain",
"(",
")",
".",
"_unresolve",
"(",
")",
"// if the collection is already resolved, return a unresolved and empty cop... | Set some conditions
@public
@memberof Model
@method where
@param {(object|array)} conditions - every key-value pair will be translated into a condition
@return {Model} | [
"Set",
"some",
"conditions"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/conditions.js#L97-L165 | train | |
PhilWaldmann/openrecord | lib/base/exec.js | function(resolve) {
var self = this.chain()
// if .find(null) was called
if (self.getInternal('exec_null')) {
return Promise.resolve(null)
}
var relation = self.getInternal('relation')
if (relation && typeof relation.loadWithCollection === 'function') {
const promise = relation.lo... | javascript | function(resolve) {
var self = this.chain()
// if .find(null) was called
if (self.getInternal('exec_null')) {
return Promise.resolve(null)
}
var relation = self.getInternal('relation')
if (relation && typeof relation.loadWithCollection === 'function') {
const promise = relation.lo... | [
"function",
"(",
"resolve",
")",
"{",
"var",
"self",
"=",
"this",
".",
"chain",
"(",
")",
"// if .find(null) was called",
"if",
"(",
"self",
".",
"getInternal",
"(",
"'exec_null'",
")",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"null",
")",
"}"... | Executes the find
@class Model
@method exec
@callback
@param {array|object} result - Either a Collection of records or a single Record
@this Collection | [
"Executes",
"the",
"find"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/exec.js#L12-L47 | train | |
PhilWaldmann/openrecord | lib/base/validations.js | function() {
var self = this
var validations = []
return self
.callInterceptors('beforeValidation', [self])
.then(function() {
for (var field in self.definition.validations) {
var fieldValidations = self.definition.validations[field]
// set the scope of all validato... | javascript | function() {
var self = this
var validations = []
return self
.callInterceptors('beforeValidation', [self])
.then(function() {
for (var field in self.definition.validations) {
var fieldValidations = self.definition.validations[field]
// set the scope of all validato... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
"var",
"validations",
"=",
"[",
"]",
"return",
"self",
".",
"callInterceptors",
"(",
"'beforeValidation'",
",",
"[",
"self",
"]",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"for",
"(",
"va... | validates the record
@class Record
@method validate
@this Promise | [
"validates",
"the",
"record"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/validations.js#L296-L322 | train | |
PhilWaldmann/openrecord | lib/base/validations.js | function(resolve) {
var self = this
return this.validate()
.then(function() {
return true
})
.catch(function(error) {
if (error instanceof self.store.ValidationError) return false
throw error
})
.then(resolve)
} | javascript | function(resolve) {
var self = this
return this.validate()
.then(function() {
return true
})
.catch(function(error) {
if (error instanceof self.store.ValidationError) return false
throw error
})
.then(resolve)
} | [
"function",
"(",
"resolve",
")",
"{",
"var",
"self",
"=",
"this",
"return",
"this",
".",
"validate",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"true",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"error",
")",
"{",
"if",
"... | validates the record and returns true or false
@class Record
@method validate
@this Promise | [
"validates",
"the",
"record",
"and",
"returns",
"true",
"or",
"false"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/validations.js#L332-L343 | train | |
PhilWaldmann/openrecord | lib/stores/sql/destroy.js | function(options) {
const Store = require('../../store')
var self = this
var primaryKeys = this.definition.primaryKeys
var condition = {}
options = options || {}
for (var i = 0; i < primaryKeys.length; i++) {
condition[primaryKeys[i]] = this[primaryKeys[i]]
}
return self.store.... | javascript | function(options) {
const Store = require('../../store')
var self = this
var primaryKeys = this.definition.primaryKeys
var condition = {}
options = options || {}
for (var i = 0; i < primaryKeys.length; i++) {
condition[primaryKeys[i]] = this[primaryKeys[i]]
}
return self.store.... | [
"function",
"(",
"options",
")",
"{",
"const",
"Store",
"=",
"require",
"(",
"'../../store'",
")",
"var",
"self",
"=",
"this",
"var",
"primaryKeys",
"=",
"this",
".",
"definition",
".",
"primaryKeys",
"var",
"condition",
"=",
"{",
"}",
"options",
"=",
"o... | Destroy a record
@class Record
@method destroy
@return {Record} | [
"Destroy",
"a",
"record"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/stores/sql/destroy.js#L16-L54 | train | |
PhilWaldmann/openrecord | lib/base/collection.js | function(data, options) {
var self = this
if (Array.isArray(data)) {
return this.chain()
.add(data)
.save()
}
return this.runScopes().then(function() {
return self.new(data).save(options)
})
} | javascript | function(data, options) {
var self = this
if (Array.isArray(data)) {
return this.chain()
.add(data)
.save()
}
return this.runScopes().then(function() {
return self.new(data).save(options)
})
} | [
"function",
"(",
"data",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
"if",
"(",
"Array",
".",
"isArray",
"(",
"data",
")",
")",
"{",
"return",
"this",
".",
"chain",
"(",
")",
".",
"add",
"(",
"data",
")",
".",
"save",
"(",
")",
"}",
... | Creates a new record and saves it
@class Model
@method create
@param {object} data - The data of the new record | [
"Creates",
"a",
"new",
"record",
"and",
"saves",
"it"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/collection.js#L54-L65 | train | |
PhilWaldmann/openrecord | lib/base/collection.js | function(index) {
var self = this.chain()
if (typeof index !== 'number') {
index = self.indexOf(index)
}
const record = self[index]
var relation = self.getInternal('relation')
var parentRecord = self.getInternal('relation_to')
if (
record &&
relation &&
parentRecor... | javascript | function(index) {
var self = this.chain()
if (typeof index !== 'number') {
index = self.indexOf(index)
}
const record = self[index]
var relation = self.getInternal('relation')
var parentRecord = self.getInternal('relation_to')
if (
record &&
relation &&
parentRecor... | [
"function",
"(",
"index",
")",
"{",
"var",
"self",
"=",
"this",
".",
"chain",
"(",
")",
"if",
"(",
"typeof",
"index",
"!==",
"'number'",
")",
"{",
"index",
"=",
"self",
".",
"indexOf",
"(",
"index",
")",
"}",
"const",
"record",
"=",
"self",
"[",
... | Removes a Record from the Collection
@class Collection
@method remove
@param {integer} index - Removes the Record on the given index
@or
@param {Record} record - Removes given Record from the Collection
@return {Collection} | [
"Removes",
"a",
"Record",
"from",
"the",
"Collection"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/base/collection.js#L282-L305 | train | |
PhilWaldmann/openrecord | lib/stores/sql/save.js | save | function save(options) {
const self = this
options = options || {}
if (self.options.polymorph) return this.callParent(options)
return Promise.all(
this.map(function(record) {
// validate all records at once.
return record.validate()
})
)
.then(function() {
... | javascript | function save(options) {
const self = this
options = options || {}
if (self.options.polymorph) return this.callParent(options)
return Promise.all(
this.map(function(record) {
// validate all records at once.
return record.validate()
})
)
.then(function() {
... | [
"function",
"save",
"(",
"options",
")",
"{",
"const",
"self",
"=",
"this",
"options",
"=",
"options",
"||",
"{",
"}",
"if",
"(",
"self",
".",
"options",
".",
"polymorph",
")",
"return",
"this",
".",
"callParent",
"(",
"options",
")",
"return",
"Promis... | create multiple records at once | [
"create",
"multiple",
"records",
"at",
"once"
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/stores/sql/save.js#L217-L247 | train |
PhilWaldmann/openrecord | lib/definition.js | function(store, modelName) {
this.store = store
this.modelName = modelName
this.model = null
this.middleware = []
this.instanceMethods = {}
this.staticMethods = {}
events.EventEmitter.call(this)
} | javascript | function(store, modelName) {
this.store = store
this.modelName = modelName
this.model = null
this.middleware = []
this.instanceMethods = {}
this.staticMethods = {}
events.EventEmitter.call(this)
} | [
"function",
"(",
"store",
",",
"modelName",
")",
"{",
"this",
".",
"store",
"=",
"store",
"this",
".",
"modelName",
"=",
"modelName",
"this",
".",
"model",
"=",
"null",
"this",
".",
"middleware",
"=",
"[",
"]",
"this",
".",
"instanceMethods",
"=",
"{",... | There are two ways to define a model.
```js
var store = new OpenRecord({
//my store config
})
store.model('MyModel', function(){
//model definition scope
});
```
or via the `models` config option:
```js
var store = new OpenRecord({
//my store config
models: __dirname + '/models/*'
});
```
```js
// ./models/mymodel... | [
"There",
"are",
"two",
"ways",
"to",
"define",
"a",
"model",
"."
] | 779fdfcd8c7d2e7dba5429938d6847eeaefd20a5 | https://github.com/PhilWaldmann/openrecord/blob/779fdfcd8c7d2e7dba5429938d6847eeaefd20a5/lib/definition.js#L66-L77 | train | |
pixijs/pixi-filters | tools/screenshots/renderer.js | nextAnim | function nextAnim() {
const anim = config.animations[++index];
if (anim) {
const encoder = new GIFEncoder(app.view.width, app.view.height);
// Stream output
encoder.createReadStream().pipe(fs.createWriteStream(
path.join(outputPath, anim.filename + '.gif')
));
... | javascript | function nextAnim() {
const anim = config.animations[++index];
if (anim) {
const encoder = new GIFEncoder(app.view.width, app.view.height);
// Stream output
encoder.createReadStream().pipe(fs.createWriteStream(
path.join(outputPath, anim.filename + '.gif')
));
... | [
"function",
"nextAnim",
"(",
")",
"{",
"const",
"anim",
"=",
"config",
".",
"animations",
"[",
"++",
"index",
"]",
";",
"if",
"(",
"anim",
")",
"{",
"const",
"encoder",
"=",
"new",
"GIFEncoder",
"(",
"app",
".",
"view",
".",
"width",
",",
"app",
".... | Combine a bunch of frames | [
"Combine",
"a",
"bunch",
"of",
"frames"
] | caeac3f2ff85077befaeb18990e7fede6defc61e | https://github.com/pixijs/pixi-filters/blob/caeac3f2ff85077befaeb18990e7fede6defc61e/tools/screenshots/renderer.js#L131-L161 | train |
pixijs/pixi-filters | rollup.config.js | dedupeDefaultVert | function dedupeDefaultVert() {
const defaultVert = path.join(__dirname, 'tools/fragments/default.vert');
const fragment = fs.readFileSync(defaultVert, 'utf8')
.replace(/\n/g, '\\\\n')
.replace(/([()*=.])/g, '\\$1');
const pattern = new RegExp(`(var ([^=\\s]+)\\s?=\\s?)"${fragment}"`, 'g');
... | javascript | function dedupeDefaultVert() {
const defaultVert = path.join(__dirname, 'tools/fragments/default.vert');
const fragment = fs.readFileSync(defaultVert, 'utf8')
.replace(/\n/g, '\\\\n')
.replace(/([()*=.])/g, '\\$1');
const pattern = new RegExp(`(var ([^=\\s]+)\\s?=\\s?)"${fragment}"`, 'g');
... | [
"function",
"dedupeDefaultVert",
"(",
")",
"{",
"const",
"defaultVert",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'tools/fragments/default.vert'",
")",
";",
"const",
"fragment",
"=",
"fs",
".",
"readFileSync",
"(",
"defaultVert",
",",
"'utf8'",
")",
".... | This plugin is a filesize optimization for the pixi-filters bundle
it removes all the successive occurances of the default vertex fragment
and reassigns the name of the vertex variable
@function dedupeDefaultVert
@private | [
"This",
"plugin",
"is",
"a",
"filesize",
"optimization",
"for",
"the",
"pixi",
"-",
"filters",
"bundle",
"it",
"removes",
"all",
"the",
"successive",
"occurances",
"of",
"the",
"default",
"vertex",
"fragment",
"and",
"reassigns",
"the",
"name",
"of",
"the",
... | caeac3f2ff85077befaeb18990e7fede6defc61e | https://github.com/pixijs/pixi-filters/blob/caeac3f2ff85077befaeb18990e7fede6defc61e/rollup.config.js#L21-L63 | train |
pixijs/pixi-filters | rollup.config.js | getSortedPackages | async function getSortedPackages() {
// Support --scope and --ignore globs
const {scope, ignore} = minimist(process.argv.slice(2));
// Standard Lerna plumbing getting packages
const packages = await getPackages(__dirname);
const filtered = filterPackages(
packages,
scope,
ig... | javascript | async function getSortedPackages() {
// Support --scope and --ignore globs
const {scope, ignore} = minimist(process.argv.slice(2));
// Standard Lerna plumbing getting packages
const packages = await getPackages(__dirname);
const filtered = filterPackages(
packages,
scope,
ig... | [
"async",
"function",
"getSortedPackages",
"(",
")",
"{",
"// Support --scope and --ignore globs",
"const",
"{",
"scope",
",",
"ignore",
"}",
"=",
"minimist",
"(",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
")",
";",
"// Standard Lerna plumbing getting pa... | Get a list of the non-private sorted packages with Lerna v3
@see https://github.com/lerna/lerna/issues/1848
@return {Promise<Package[]>} List of packages | [
"Get",
"a",
"list",
"of",
"the",
"non",
"-",
"private",
"sorted",
"packages",
"with",
"Lerna",
"v3"
] | caeac3f2ff85077befaeb18990e7fede6defc61e | https://github.com/pixijs/pixi-filters/blob/caeac3f2ff85077befaeb18990e7fede6defc61e/rollup.config.js#L70-L85 | train |
3rd-Eden/useragent | index.js | Agent | function Agent(family, major, minor, patch, source) {
this.family = family || 'Other';
this.major = major || '0';
this.minor = minor || '0';
this.patch = patch || '0';
this.source = source || '';
} | javascript | function Agent(family, major, minor, patch, source) {
this.family = family || 'Other';
this.major = major || '0';
this.minor = minor || '0';
this.patch = patch || '0';
this.source = source || '';
} | [
"function",
"Agent",
"(",
"family",
",",
"major",
",",
"minor",
",",
"patch",
",",
"source",
")",
"{",
"this",
".",
"family",
"=",
"family",
"||",
"'Other'",
";",
"this",
".",
"major",
"=",
"major",
"||",
"'0'",
";",
"this",
".",
"minor",
"=",
"min... | The representation of a parsed user agent.
@constructor
@param {String} family The name of the browser
@param {String} major Major version of the browser
@param {String} minor Minor version of the browser
@param {String} patch Patch version of the browser
@param {String} source The actual user agent string
@api public | [
"The",
"representation",
"of",
"a",
"parsed",
"user",
"agent",
"."
] | 187c17255028bd30d82e3af108846ce73a8197fb | https://github.com/3rd-Eden/useragent/blob/187c17255028bd30d82e3af108846ce73a8197fb/index.js#L34-L40 | train |
3rd-Eden/useragent | index.js | set | function set(os) {
if (!(os instanceof OperatingSystem)) return false;
return Object.defineProperty(this, 'os', {
value: os
}).os;
} | javascript | function set(os) {
if (!(os instanceof OperatingSystem)) return false;
return Object.defineProperty(this, 'os', {
value: os
}).os;
} | [
"function",
"set",
"(",
"os",
")",
"{",
"if",
"(",
"!",
"(",
"os",
"instanceof",
"OperatingSystem",
")",
")",
"return",
"false",
";",
"return",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'os'",
",",
"{",
"value",
":",
"os",
"}",
")",
".",
... | Bypass the OnDemand parsing and set an OperatingSystem instance.
@param {OperatingSystem} os
@api public | [
"Bypass",
"the",
"OnDemand",
"parsing",
"and",
"set",
"an",
"OperatingSystem",
"instance",
"."
] | 187c17255028bd30d82e3af108846ce73a8197fb | https://github.com/3rd-Eden/useragent/blob/187c17255028bd30d82e3af108846ce73a8197fb/index.js#L84-L90 | train |
3rd-Eden/useragent | index.js | set | function set(device) {
if (!(device instanceof Device)) return false;
return Object.defineProperty(this, 'device', {
value: device
}).device;
} | javascript | function set(device) {
if (!(device instanceof Device)) return false;
return Object.defineProperty(this, 'device', {
value: device
}).device;
} | [
"function",
"set",
"(",
"device",
")",
"{",
"if",
"(",
"!",
"(",
"device",
"instanceof",
"Device",
")",
")",
"return",
"false",
";",
"return",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'device'",
",",
"{",
"value",
":",
"device",
"}",
")",
... | Bypass the OnDemand parsing and set an Device instance.
@param {Device} device
@api public | [
"Bypass",
"the",
"OnDemand",
"parsing",
"and",
"set",
"an",
"Device",
"instance",
"."
] | 187c17255028bd30d82e3af108846ce73a8197fb | https://github.com/3rd-Eden/useragent/blob/187c17255028bd30d82e3af108846ce73a8197fb/index.js#L135-L141 | train |
3rd-Eden/useragent | index.js | OperatingSystem | function OperatingSystem(family, major, minor, patch) {
this.family = family || 'Other';
this.major = major || '0';
this.minor = minor || '0';
this.patch = patch || '0';
} | javascript | function OperatingSystem(family, major, minor, patch) {
this.family = family || 'Other';
this.major = major || '0';
this.minor = minor || '0';
this.patch = patch || '0';
} | [
"function",
"OperatingSystem",
"(",
"family",
",",
"major",
",",
"minor",
",",
"patch",
")",
"{",
"this",
".",
"family",
"=",
"family",
"||",
"'Other'",
";",
"this",
".",
"major",
"=",
"major",
"||",
"'0'",
";",
"this",
".",
"minor",
"=",
"minor",
"|... | The representation of a parsed Operating System.
@constructor
@param {String} family The name of the os
@param {String} major Major version of the os
@param {String} minor Minor version of the os
@param {String} patch Patch version of the os
@api public | [
"The",
"representation",
"of",
"a",
"parsed",
"Operating",
"System",
"."
] | 187c17255028bd30d82e3af108846ce73a8197fb | https://github.com/3rd-Eden/useragent/blob/187c17255028bd30d82e3af108846ce73a8197fb/index.js#L222-L227 | train |
3rd-Eden/useragent | index.js | Device | function Device(family, major, minor, patch) {
this.family = family || 'Other';
this.major = major || '0';
this.minor = minor || '0';
this.patch = patch || '0';
} | javascript | function Device(family, major, minor, patch) {
this.family = family || 'Other';
this.major = major || '0';
this.minor = minor || '0';
this.patch = patch || '0';
} | [
"function",
"Device",
"(",
"family",
",",
"major",
",",
"minor",
",",
"patch",
")",
"{",
"this",
".",
"family",
"=",
"family",
"||",
"'Other'",
";",
"this",
".",
"major",
"=",
"major",
"||",
"'0'",
";",
"this",
".",
"minor",
"=",
"minor",
"||",
"'0... | The representation of a parsed Device.
@constructor
@param {String} family The name of the device
@param {String} major Major version of the device
@param {String} minor Minor version of the device
@param {String} patch Patch version of the device
@api public | [
"The",
"representation",
"of",
"a",
"parsed",
"Device",
"."
] | 187c17255028bd30d82e3af108846ce73a8197fb | https://github.com/3rd-Eden/useragent/blob/187c17255028bd30d82e3af108846ce73a8197fb/index.js#L295-L300 | train |
3rd-Eden/useragent | index.js | isSafe | function isSafe(userAgent) {
var consecutive = 0
, code = 0;
if (userAgent.length > 1000) return false;
for (var i = 0; i < userAgent.length; i++) {
code = userAgent.charCodeAt(i);
// numbers between 0 and 9, letters between a and z, spaces and control
if ((code >= 48 && code <= 57) || (code >= ... | javascript | function isSafe(userAgent) {
var consecutive = 0
, code = 0;
if (userAgent.length > 1000) return false;
for (var i = 0; i < userAgent.length; i++) {
code = userAgent.charCodeAt(i);
// numbers between 0 and 9, letters between a and z, spaces and control
if ((code >= 48 && code <= 57) || (code >= ... | [
"function",
"isSafe",
"(",
"userAgent",
")",
"{",
"var",
"consecutive",
"=",
"0",
",",
"code",
"=",
"0",
";",
"if",
"(",
"userAgent",
".",
"length",
">",
"1000",
")",
"return",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"userA... | Check if the userAgent is something we want to parse with regexp's.
@param {String} userAgent The userAgent.
@returns {Boolean} | [
"Check",
"if",
"the",
"userAgent",
"is",
"something",
"we",
"want",
"to",
"parse",
"with",
"regexp",
"s",
"."
] | 187c17255028bd30d82e3af108846ce73a8197fb | https://github.com/3rd-Eden/useragent/blob/187c17255028bd30d82e3af108846ce73a8197fb/index.js#L414-L435 | train |
aws/aws-xray-sdk-node | packages/core/lib/segments/attributes/aws.js | setAWSWhitelist | function setAWSWhitelist(source) {
if (!source || source instanceof String || !(typeof source === 'string' || (source instanceof Object)))
throw new Error('Please specify a path to the local whitelist file, or supply a whitelist source object.');
capturer = new CallCapturer(source);
} | javascript | function setAWSWhitelist(source) {
if (!source || source instanceof String || !(typeof source === 'string' || (source instanceof Object)))
throw new Error('Please specify a path to the local whitelist file, or supply a whitelist source object.');
capturer = new CallCapturer(source);
} | [
"function",
"setAWSWhitelist",
"(",
"source",
")",
"{",
"if",
"(",
"!",
"source",
"||",
"source",
"instanceof",
"String",
"||",
"!",
"(",
"typeof",
"source",
"===",
"'string'",
"||",
"(",
"source",
"instanceof",
"Object",
")",
")",
")",
"throw",
"new",
"... | Overrides the default whitelisting file to specify what params to capture on each AWS Service call.
@param {string|Object} source - The path to the custom whitelist file, or a whitelist source JSON object.
@exports setAWSWhitelist | [
"Overrides",
"the",
"default",
"whitelisting",
"file",
"to",
"specify",
"what",
"params",
"to",
"capture",
"on",
"each",
"AWS",
"Service",
"call",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/segments/attributes/aws.js#L42-L47 | train |
aws/aws-xray-sdk-node | packages/core/lib/segments/attributes/aws.js | appendAWSWhitelist | function appendAWSWhitelist(source) {
if (!source || source instanceof String || !(typeof source === 'string' || (source instanceof Object)))
throw new Error('Please specify a path to the local whitelist file, or supply a whitelist source object.');
capturer.append(source);
} | javascript | function appendAWSWhitelist(source) {
if (!source || source instanceof String || !(typeof source === 'string' || (source instanceof Object)))
throw new Error('Please specify a path to the local whitelist file, or supply a whitelist source object.');
capturer.append(source);
} | [
"function",
"appendAWSWhitelist",
"(",
"source",
")",
"{",
"if",
"(",
"!",
"source",
"||",
"source",
"instanceof",
"String",
"||",
"!",
"(",
"typeof",
"source",
"===",
"'string'",
"||",
"(",
"source",
"instanceof",
"Object",
")",
")",
")",
"throw",
"new",
... | Appends to the default whitelisting file to specify what params to capture on each AWS Service call.
@param {string|Object} source - The path to the custom whitelist file, or a whitelist source JSON object.
@exports appendAWSWhitelist | [
"Appends",
"to",
"the",
"default",
"whitelisting",
"file",
"to",
"specify",
"what",
"params",
"to",
"capture",
"on",
"each",
"AWS",
"Service",
"call",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/segments/attributes/aws.js#L55-L60 | train |
aws/aws-xray-sdk-node | packages/core/lib/segment_emitter.js | batchSendData | function batchSendData (ops, callback) {
var client = dgram.createSocket('udp4');
executeSendData(client, ops, 0, function () {
try {
client.close();
} finally {
callback();
}
});
} | javascript | function batchSendData (ops, callback) {
var client = dgram.createSocket('udp4');
executeSendData(client, ops, 0, function () {
try {
client.close();
} finally {
callback();
}
});
} | [
"function",
"batchSendData",
"(",
"ops",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"dgram",
".",
"createSocket",
"(",
"'udp4'",
")",
";",
"executeSendData",
"(",
"client",
",",
"ops",
",",
"0",
",",
"function",
"(",
")",
"{",
"try",
"{",
"client... | Sends a collection of data over a UDP socket. This method
is designed to be used by `atomic-batcher` as a way to share
a single UDP socket for sending multiple data blocks.
@param {object} ops - Details of the data to send
@param {Function} callback - The function to call when done | [
"Sends",
"a",
"collection",
"of",
"data",
"over",
"a",
"UDP",
"socket",
".",
"This",
"method",
"is",
"designed",
"to",
"be",
"used",
"by",
"atomic",
"-",
"batcher",
"as",
"a",
"way",
"to",
"share",
"a",
"single",
"UDP",
"socket",
"for",
"sending",
"mul... | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/segment_emitter.js#L17-L27 | train |
aws/aws-xray-sdk-node | packages/core/lib/segment_emitter.js | executeSendData | function executeSendData (client, ops, index, callback) {
if (index >= ops.length) {
callback();
return;
}
sendMessage(client, ops[index], function () {
executeSendData(client, ops, index+1, callback);
});
} | javascript | function executeSendData (client, ops, index, callback) {
if (index >= ops.length) {
callback();
return;
}
sendMessage(client, ops[index], function () {
executeSendData(client, ops, index+1, callback);
});
} | [
"function",
"executeSendData",
"(",
"client",
",",
"ops",
",",
"index",
",",
"callback",
")",
"{",
"if",
"(",
"index",
">=",
"ops",
".",
"length",
")",
"{",
"callback",
"(",
")",
";",
"return",
";",
"}",
"sendMessage",
"(",
"client",
",",
"ops",
"[",... | Execute sending data starting at the specified index and
using the provided client.
@param {Socket} client - Socket to send data with
@param {object} ops - Details of data to send
@param {number} index - Starting index for sending
@param {Function} callback - Function to call when done | [
"Execute",
"sending",
"data",
"starting",
"at",
"the",
"specified",
"index",
"and",
"using",
"the",
"provided",
"client",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/segment_emitter.js#L38-L47 | train |
aws/aws-xray-sdk-node | packages/core/lib/segment_emitter.js | sendMessage | function sendMessage (client, data, batchCallback) {
var msg = data.msg;
var offset = data.offset;
var length = data.length;
var port = data.port;
var address = data.address;
var callback = data.callback;
client.send(msg, offset, length, port, address, function(err) {
try {
callback(err);
}... | javascript | function sendMessage (client, data, batchCallback) {
var msg = data.msg;
var offset = data.offset;
var length = data.length;
var port = data.port;
var address = data.address;
var callback = data.callback;
client.send(msg, offset, length, port, address, function(err) {
try {
callback(err);
}... | [
"function",
"sendMessage",
"(",
"client",
",",
"data",
",",
"batchCallback",
")",
"{",
"var",
"msg",
"=",
"data",
".",
"msg",
";",
"var",
"offset",
"=",
"data",
".",
"offset",
";",
"var",
"length",
"=",
"data",
".",
"length",
";",
"var",
"port",
"=",... | Send a single message over a UDP socket.
@param {Socket} client - Socket to send data with
@param {object} data - Details of the data to send
@param {Function} batchCallback - Function to call when done | [
"Send",
"a",
"single",
"message",
"over",
"a",
"UDP",
"socket",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/segment_emitter.js#L56-L71 | train |
aws/aws-xray-sdk-node | packages/core/lib/segment_emitter.js | send | function send(segment) {
var client = this.socket;
var formatted = segment.format();
var data = PROTOCOL_HEADER + PROTOCOL_DELIMITER + formatted;
var message = new Buffer(data);
var short = '{"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}';
var type = segment.type === 'subsegme... | javascript | function send(segment) {
var client = this.socket;
var formatted = segment.format();
var data = PROTOCOL_HEADER + PROTOCOL_DELIMITER + formatted;
var message = new Buffer(data);
var short = '{"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}';
var type = segment.type === 'subsegme... | [
"function",
"send",
"(",
"segment",
")",
"{",
"var",
"client",
"=",
"this",
".",
"socket",
";",
"var",
"formatted",
"=",
"segment",
".",
"format",
"(",
")",
";",
"var",
"data",
"=",
"PROTOCOL_HEADER",
"+",
"PROTOCOL_DELIMITER",
"+",
"formatted",
";",
"va... | Creates a UDP socket connection and send the formatted segment.
@param {Segment} segment - The segment to send to the daemon. | [
"Creates",
"a",
"UDP",
"socket",
"connection",
"and",
"send",
"the",
"formatted",
"segment",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/segment_emitter.js#L121-L141 | train |
aws/aws-xray-sdk-node | packages/core/lib/patchers/aws_p.js | captureAWS | function captureAWS(awssdk) {
if (!semver.gte(awssdk.VERSION, minVersion))
throw new Error ('AWS SDK version ' + minVersion + ' or greater required.');
for (var prop in awssdk) {
if (awssdk[prop].serviceIdentifier) {
var Service = awssdk[prop];
Service.prototype.customizeRequests(captureAWSRequ... | javascript | function captureAWS(awssdk) {
if (!semver.gte(awssdk.VERSION, minVersion))
throw new Error ('AWS SDK version ' + minVersion + ' or greater required.');
for (var prop in awssdk) {
if (awssdk[prop].serviceIdentifier) {
var Service = awssdk[prop];
Service.prototype.customizeRequests(captureAWSRequ... | [
"function",
"captureAWS",
"(",
"awssdk",
")",
"{",
"if",
"(",
"!",
"semver",
".",
"gte",
"(",
"awssdk",
".",
"VERSION",
",",
"minVersion",
")",
")",
"throw",
"new",
"Error",
"(",
"'AWS SDK version '",
"+",
"minVersion",
"+",
"' or greater required.'",
")",
... | Configures the AWS SDK to automatically capture information for the segment.
All created clients will automatically be captured. See 'captureAWSClient'
for additional details.
@param {AWS} awssdk - The Javascript AWS SDK.
@alias module:aws_p.captureAWS
@returns {AWS}
@see https://github.com/aws/aws-sdk-js | [
"Configures",
"the",
"AWS",
"SDK",
"to",
"automatically",
"capture",
"information",
"for",
"the",
"segment",
".",
"All",
"created",
"clients",
"will",
"automatically",
"be",
"captured",
".",
"See",
"captureAWSClient",
"for",
"additional",
"details",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/patchers/aws_p.js#L31-L43 | train |
aws/aws-xray-sdk-node | packages/core/lib/database/sql_data.js | SqlData | function SqlData(databaseVer, driverVer, user, url, queryType) {
this.init(databaseVer, driverVer, user, url, queryType);
} | javascript | function SqlData(databaseVer, driverVer, user, url, queryType) {
this.init(databaseVer, driverVer, user, url, queryType);
} | [
"function",
"SqlData",
"(",
"databaseVer",
",",
"driverVer",
",",
"user",
",",
"url",
",",
"queryType",
")",
"{",
"this",
".",
"init",
"(",
"databaseVer",
",",
"driverVer",
",",
"user",
",",
"url",
",",
"queryType",
")",
";",
"}"
] | Represents a SQL database call.
@constructor
@param {string} databaseVer - The version on the database (user supplied).
@param {string} driverVer - The version on the database driver (user supplied).
@param {string} user - The user associated to the database call.
@param {string} queryType - The SQL query type. | [
"Represents",
"a",
"SQL",
"database",
"call",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/database/sql_data.js#L10-L12 | train |
aws/aws-xray-sdk-node | packages/core/lib/capture.js | captureFunc | function captureFunc(name, fcn, parent) {
validate(name, fcn);
var current, executeFcn;
var parentSeg = contextUtils.resolveSegment(parent);
if (!parentSeg) {
logger.getLogger().warn('Failed to capture function.');
return fcn();
}
current = parentSeg.addNewSubsegment(name);
executeFcn = captur... | javascript | function captureFunc(name, fcn, parent) {
validate(name, fcn);
var current, executeFcn;
var parentSeg = contextUtils.resolveSegment(parent);
if (!parentSeg) {
logger.getLogger().warn('Failed to capture function.');
return fcn();
}
current = parentSeg.addNewSubsegment(name);
executeFcn = captur... | [
"function",
"captureFunc",
"(",
"name",
",",
"fcn",
",",
"parent",
")",
"{",
"validate",
"(",
"name",
",",
"fcn",
")",
";",
"var",
"current",
",",
"executeFcn",
";",
"var",
"parentSeg",
"=",
"contextUtils",
".",
"resolveSegment",
"(",
"parent",
")",
";",... | Wrap to automatically capture information for the segment.
@param {string} name - The name of the new subsegment.
@param {function} fcn - The function context to wrap. Can take a single 'subsegment' argument.
@param {Segment|Subsegment} [parent] - The parent for the new subsegment, for manual mode.
@alias module:captur... | [
"Wrap",
"to",
"automatically",
"capture",
"information",
"for",
"the",
"segment",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/capture.js#L18-L40 | train |
aws/aws-xray-sdk-node | packages/core/lib/middleware/sampling/sampling_rule.js | SamplingRule | function SamplingRule(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType) {
this.init(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType);
} | javascript | function SamplingRule(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType) {
this.init(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType);
} | [
"function",
"SamplingRule",
"(",
"name",
",",
"priority",
",",
"rate",
",",
"reservoirSize",
",",
"host",
",",
"httpMethod",
",",
"urlPath",
",",
"serviceName",
",",
"serviceType",
")",
"{",
"this",
".",
"init",
"(",
"name",
",",
"priority",
",",
"rate",
... | The data model for a sampling rule defined using X-Ray API CreateSamplingRules.
It should be only instantiated directly from the X-Ray API response.
@constructor | [
"The",
"data",
"model",
"for",
"a",
"sampling",
"rule",
"defined",
"using",
"X",
"-",
"Ray",
"API",
"CreateSamplingRules",
".",
"It",
"should",
"be",
"only",
"instantiated",
"directly",
"from",
"the",
"X",
"-",
"Ray",
"API",
"response",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/middleware/sampling/sampling_rule.js#L10-L14 | train |
aws/aws-xray-sdk-node | packages/core/lib/aws-xray.js | function(plugins) {
var pluginData = {};
plugins.forEach(function(plugin) {
plugin.getData(function(data) {
if (data) {
for (var attribute in data) { pluginData[attribute] = data[attribute]; }
}
});
segmentUtils.setOrigin(plugin.originName);
segmentUtils.setPlug... | javascript | function(plugins) {
var pluginData = {};
plugins.forEach(function(plugin) {
plugin.getData(function(data) {
if (data) {
for (var attribute in data) { pluginData[attribute] = data[attribute]; }
}
});
segmentUtils.setOrigin(plugin.originName);
segmentUtils.setPlug... | [
"function",
"(",
"plugins",
")",
"{",
"var",
"pluginData",
"=",
"{",
"}",
";",
"plugins",
".",
"forEach",
"(",
"function",
"(",
"plugin",
")",
"{",
"plugin",
".",
"getData",
"(",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
")",
"{",
"for"... | Enables use of plugins to capture additional data for segments.
@param {Array} plugins - A configurable subset of AWSXRay.plugins.
@memberof AWSXRay
@see AWSXRay.plugins | [
"Enables",
"use",
"of",
"plugins",
"to",
"capture",
"additional",
"data",
"for",
"segments",
"."
] | ad817e5ccfbb803ec4140cd8a457be579ea3cc1c | https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/aws-xray.js#L56-L67 | train | |
nats-io/node-nats-streaming | lib/stan.js | Message | function Message(stanClient, msg, subscription) {
this.stanClient = stanClient;
this.msg = msg;
this.subscription = subscription;
} | javascript | function Message(stanClient, msg, subscription) {
this.stanClient = stanClient;
this.msg = msg;
this.subscription = subscription;
} | [
"function",
"Message",
"(",
"stanClient",
",",
"msg",
",",
"subscription",
")",
"{",
"this",
".",
"stanClient",
"=",
"stanClient",
";",
"this",
".",
"msg",
"=",
"msg",
";",
"this",
".",
"subscription",
"=",
"subscription",
";",
"}"
] | Represents a message received from the streaming server.
@param stanClient
@param msg
@param subscription
@constructor | [
"Represents",
"a",
"message",
"received",
"from",
"the",
"streaming",
"server",
"."
] | d7a3cdc758c1c8a7f08f5aa8d8311fd5f189c6dd | https://github.com/nats-io/node-nats-streaming/blob/d7a3cdc758c1c8a7f08f5aa8d8311fd5f189c6dd/lib/stan.js#L881-L885 | train |
BabylonJS/Spector.js | sample/js/transient.js | runTransient | function runTransient() {
var c = document.createElement('canvas');
var gl = c.getContext('webgl');
var ext = gl.getExtension('WEBGL_debug_renderer_info');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
console.log(renderer);
} | javascript | function runTransient() {
var c = document.createElement('canvas');
var gl = c.getContext('webgl');
var ext = gl.getExtension('WEBGL_debug_renderer_info');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
console.log(renderer);
} | [
"function",
"runTransient",
"(",
")",
"{",
"var",
"c",
"=",
"document",
".",
"createElement",
"(",
"'canvas'",
")",
";",
"var",
"gl",
"=",
"c",
".",
"getContext",
"(",
"'webgl'",
")",
";",
"var",
"ext",
"=",
"gl",
".",
"getExtension",
"(",
"'WEBGL_debu... | start Called when the canvas is created to get the ball rolling. | [
"start",
"Called",
"when",
"the",
"canvas",
"is",
"created",
"to",
"get",
"the",
"ball",
"rolling",
"."
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/transient.js#L51-L57 | train |
BabylonJS/Spector.js | sample/js/transient.js | initWebGL | function initWebGL() {
gl = null;
try {
gl = canvas.getContext("experimental-webgl");
}
catch(e) {
alert(e);
}
// If we don't have a GL context, give up now
if (!gl) {
alert("Unable to initialize WebGL. Your browser may not support it.");
}
} | javascript | function initWebGL() {
gl = null;
try {
gl = canvas.getContext("experimental-webgl");
}
catch(e) {
alert(e);
}
// If we don't have a GL context, give up now
if (!gl) {
alert("Unable to initialize WebGL. Your browser may not support it.");
}
} | [
"function",
"initWebGL",
"(",
")",
"{",
"gl",
"=",
"null",
";",
"try",
"{",
"gl",
"=",
"canvas",
".",
"getContext",
"(",
"\"experimental-webgl\"",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"alert",
"(",
"e",
")",
";",
"}",
"// If we don't have a GL c... | initWebGL Initialize WebGL, returning the GL context or null if WebGL isn't available or could not be initialized. | [
"initWebGL",
"Initialize",
"WebGL",
"returning",
"the",
"GL",
"context",
"or",
"null",
"if",
"WebGL",
"isn",
"t",
"available",
"or",
"could",
"not",
"be",
"initialized",
"."
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/transient.js#L95-L110 | train |
BabylonJS/Spector.js | sample/js/transient.js | getShader | function getShader(gl, source, isVertex) {
var shader = gl.createShader(isVertex ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
gl.shaderSource(shader, source);
gl.compileShader(shader);
// See if it compiled successfully
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert("An error occurred compi... | javascript | function getShader(gl, source, isVertex) {
var shader = gl.createShader(isVertex ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
gl.shaderSource(shader, source);
gl.compileShader(shader);
// See if it compiled successfully
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert("An error occurred compi... | [
"function",
"getShader",
"(",
"gl",
",",
"source",
",",
"isVertex",
")",
"{",
"var",
"shader",
"=",
"gl",
".",
"createShader",
"(",
"isVertex",
"?",
"gl",
".",
"VERTEX_SHADER",
":",
"gl",
".",
"FRAGMENT_SHADER",
")",
";",
"gl",
".",
"shaderSource",
"(",
... | getShader Loads a shader program | [
"getShader",
"Loads",
"a",
"shader",
"program"
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/transient.js#L345-L358 | train |
BabylonJS/Spector.js | sample/assets/js/babylon.objFileLoader.js | function (arr, obj) {
if (!arr[obj[0]])
arr[obj[0]] = { normals: [], idx: [] };
var idx = arr[obj[0]].normals.indexOf(obj[1]);
return idx === -1 ? -1 : arr[obj[0]].idx[idx];
} | javascript | function (arr, obj) {
if (!arr[obj[0]])
arr[obj[0]] = { normals: [], idx: [] };
var idx = arr[obj[0]].normals.indexOf(obj[1]);
return idx === -1 ? -1 : arr[obj[0]].idx[idx];
} | [
"function",
"(",
"arr",
",",
"obj",
")",
"{",
"if",
"(",
"!",
"arr",
"[",
"obj",
"[",
"0",
"]",
"]",
")",
"arr",
"[",
"obj",
"[",
"0",
"]",
"]",
"=",
"{",
"normals",
":",
"[",
"]",
",",
"idx",
":",
"[",
"]",
"}",
";",
"var",
"idx",
"=",... | Search for obj in the given array.
This function is called to check if a couple of data already exists in an array.
If found, returns the index of the founded tuple index. Returns -1 if not found
@param arr Array<{ normals: Array<number>, idx: Array<number> }>
@param obj Array<number>
@returns {boolean} | [
"Search",
"for",
"obj",
"in",
"the",
"given",
"array",
".",
"This",
"function",
"is",
"called",
"to",
"check",
"if",
"a",
"couple",
"of",
"data",
"already",
"exists",
"in",
"an",
"array",
"."
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L305-L310 | train | |
BabylonJS/Spector.js | sample/assets/js/babylon.objFileLoader.js | function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
//For each element in the triangles array.
//This var could contains 1 to an infinity of triangles
for (var k = 0; k < triangles.length; k++) {
... | javascript | function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
//For each element in the triangles array.
//This var could contains 1 to an infinity of triangles
for (var k = 0; k < triangles.length; k++) {
... | [
"function",
"(",
"face",
",",
"v",
")",
"{",
"//Get the indices of triangles for each polygon",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"//For each element in the triangles array.",
"//This var could contains 1 to an infinity of triangles",
"for",
"(",
"var",
"k",
... | Create triangles and push the data for each polygon for the pattern 1
In this pattern we get vertice positions
@param face
@param v | [
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"1",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions"
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L430-L445 | train | |
BabylonJS/Spector.js | sample/assets/js/babylon.objFileLoader.js | function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1"
//Split the data for getting position and uv
var poin... | javascript | function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1"
//Split the data for getting position and uv
var poin... | [
"function",
"(",
"face",
",",
"v",
")",
"{",
"//Get the indices of triangles for each polygon",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"triangles",
".",
"length",
";",
"k",
"++",
")",
"{",
"//t... | Create triangles and push the data for each polygon for the pattern 2
In this pattern we get vertice positions and uvsu
@param face
@param v | [
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"2",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions",
"and",
"uvsu"
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L452-L470 | train | |
BabylonJS/Spector.js | sample/assets/js/babylon.objFileLoader.js | function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1/1"
//Split the data for getting position, uv, and normals
... | javascript | function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1/1"
//Split the data for getting position, uv, and normals
... | [
"function",
"(",
"face",
",",
"v",
")",
"{",
"//Get the indices of triangles for each polygon",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"triangles",
".",
"length",
";",
"k",
"++",
")",
"{",
"//t... | Create triangles and push the data for each polygon for the pattern 3
In this pattern we get vertice positions, uvs and normals
@param face
@param v | [
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"3",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions",
"uvs",
"and",
"normals"
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L477-L495 | train | |
BabylonJS/Spector.js | sample/assets/js/babylon.objFileLoader.js | function (face, v) {
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1//1"
//Split the data for getting position and normals
var point = triangles[k].split("//"); // ["1", "1"]
... | javascript | function (face, v) {
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1//1"
//Split the data for getting position and normals
var point = triangles[k].split("//"); // ["1", "1"]
... | [
"function",
"(",
"face",
",",
"v",
")",
"{",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"triangles",
".",
"length",
";",
"k",
"++",
")",
"{",
"//triangle[k] = \"1//1\"",
"//Split the data for getti... | Create triangles and push the data for each polygon for the pattern 4
In this pattern we get vertice positions and normals
@param face
@param v | [
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"4",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions",
"and",
"normals"
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L502-L517 | train | |
BabylonJS/Spector.js | sample/assets/js/babylon.max.js | Color3 | function Color3(r, g, b) {
if (r === void 0) { r = 0; }
if (g === void 0) { g = 0; }
if (b === void 0) { b = 0; }
this.r = r;
this.g = g;
this.b = b;
} | javascript | function Color3(r, g, b) {
if (r === void 0) { r = 0; }
if (g === void 0) { g = 0; }
if (b === void 0) { b = 0; }
this.r = r;
this.g = g;
this.b = b;
} | [
"function",
"Color3",
"(",
"r",
",",
"g",
",",
"b",
")",
"{",
"if",
"(",
"r",
"===",
"void",
"0",
")",
"{",
"r",
"=",
"0",
";",
"}",
"if",
"(",
"g",
"===",
"void",
"0",
")",
"{",
"g",
"=",
"0",
";",
"}",
"if",
"(",
"b",
"===",
"void",
... | Creates a new Color3 object from red, green, blue values, all between 0 and 1. | [
"Creates",
"a",
"new",
"Color3",
"object",
"from",
"red",
"green",
"blue",
"values",
"all",
"between",
"0",
"and",
"1",
"."
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L183-L190 | train |
BabylonJS/Spector.js | sample/assets/js/babylon.max.js | Quaternion | function Quaternion(x, y, z, w) {
if (x === void 0) { x = 0.0; }
if (y === void 0) { y = 0.0; }
if (z === void 0) { z = 0.0; }
if (w === void 0) { w = 1.0; }
this.x = x;
this.y = y;
this.z = z;
this.w = w;
} | javascript | function Quaternion(x, y, z, w) {
if (x === void 0) { x = 0.0; }
if (y === void 0) { y = 0.0; }
if (z === void 0) { z = 0.0; }
if (w === void 0) { w = 1.0; }
this.x = x;
this.y = y;
this.z = z;
this.w = w;
} | [
"function",
"Quaternion",
"(",
"x",
",",
"y",
",",
"z",
",",
"w",
")",
"{",
"if",
"(",
"x",
"===",
"void",
"0",
")",
"{",
"x",
"=",
"0.0",
";",
"}",
"if",
"(",
"y",
"===",
"void",
"0",
")",
"{",
"y",
"=",
"0.0",
";",
"}",
"if",
"(",
"z"... | Creates a new Quaternion from the passed floats. | [
"Creates",
"a",
"new",
"Quaternion",
"from",
"the",
"passed",
"floats",
"."
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L2393-L2402 | train |
BabylonJS/Spector.js | sample/assets/js/babylon.max.js | Path2 | function Path2(x, y) {
this._points = new Array();
this._length = 0.0;
this.closed = false;
this._points.push(new Vector2(x, y));
} | javascript | function Path2(x, y) {
this._points = new Array();
this._length = 0.0;
this.closed = false;
this._points.push(new Vector2(x, y));
} | [
"function",
"Path2",
"(",
"x",
",",
"y",
")",
"{",
"this",
".",
"_points",
"=",
"new",
"Array",
"(",
")",
";",
"this",
".",
"_length",
"=",
"0.0",
";",
"this",
".",
"closed",
"=",
"false",
";",
"this",
".",
"_points",
".",
"push",
"(",
"new",
"... | Creates a Path2 object from the starting 2D coordinates x and y. | [
"Creates",
"a",
"Path2",
"object",
"from",
"the",
"starting",
"2D",
"coordinates",
"x",
"and",
"y",
"."
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L4376-L4381 | train |
BabylonJS/Spector.js | sample/assets/js/babylon.max.js | getMergedStore | function getMergedStore(target) {
var classKey = target.getClassName();
if (__mergedStore[classKey]) {
return __mergedStore[classKey];
}
__mergedStore[classKey] = {};
var store = __mergedStore[classKey];
var currentTarget = target;
var currentKey = cla... | javascript | function getMergedStore(target) {
var classKey = target.getClassName();
if (__mergedStore[classKey]) {
return __mergedStore[classKey];
}
__mergedStore[classKey] = {};
var store = __mergedStore[classKey];
var currentTarget = target;
var currentKey = cla... | [
"function",
"getMergedStore",
"(",
"target",
")",
"{",
"var",
"classKey",
"=",
"target",
".",
"getClassName",
"(",
")",
";",
"if",
"(",
"__mergedStore",
"[",
"classKey",
"]",
")",
"{",
"return",
"__mergedStore",
"[",
"classKey",
"]",
";",
"}",
"__mergedSto... | Return the list of properties flagged as serializable
@param target: host object | [
"Return",
"the",
"list",
"of",
"properties",
"flagged",
"as",
"serializable"
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L5104-L5138 | train |
BabylonJS/Spector.js | sample/assets/js/babylon.max.js | function () {
var boundingBox = this.boundingBox;
var size = boundingBox.maximumWorld.subtract(boundingBox.minimumWorld);
return size.length();
} | javascript | function () {
var boundingBox = this.boundingBox;
var size = boundingBox.maximumWorld.subtract(boundingBox.minimumWorld);
return size.length();
} | [
"function",
"(",
")",
"{",
"var",
"boundingBox",
"=",
"this",
".",
"boundingBox",
";",
"var",
"size",
"=",
"boundingBox",
".",
"maximumWorld",
".",
"subtract",
"(",
"boundingBox",
".",
"minimumWorld",
")",
";",
"return",
"size",
".",
"length",
"(",
")",
... | Gets the world distance between the min and max points of the bounding box | [
"Gets",
"the",
"world",
"distance",
"between",
"the",
"min",
"and",
"max",
"points",
"of",
"the",
"bounding",
"box"
] | 42602c83a0515b60338edad27c3330a7c0523bbe | https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L12235-L12239 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.