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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(libraries) {
var deferred = null,
promiseWrapper = null,
$ = null;
promiseWrapper = new this.Deferred();
if (mixitup.features.has.promises) {
// ES6 native promise or polyfill
promiseWrappe... | javascript | function(libraries) {
var deferred = null,
promiseWrapper = null,
$ = null;
promiseWrapper = new this.Deferred();
if (mixitup.features.has.promises) {
// ES6 native promise or polyfill
promiseWrappe... | [
"function",
"(",
"libraries",
")",
"{",
"var",
"deferred",
"=",
"null",
",",
"promiseWrapper",
"=",
"null",
",",
"$",
"=",
"null",
";",
"promiseWrapper",
"=",
"new",
"this",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"mixitup",
".",
"features",
".",
... | Abstracts an ES6 promise into a q-like deferred interface for storage and deferred resolution.
@private
@param {object} libraries
@return {h.Deferred} | [
"Abstracts",
"an",
"ES6",
"promise",
"into",
"a",
"q",
"-",
"like",
"deferred",
"interface",
"for",
"storage",
"and",
"deferred",
"resolution",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1207-L1236 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(obj, stringKey) {
var parts = stringKey.split('.'),
returnCurrent = null,
current = '',
i = 0;
if (!stringKey) {
return obj;
}
returnCurrent = function(obj) {
... | javascript | function(obj, stringKey) {
var parts = stringKey.split('.'),
returnCurrent = null,
current = '',
i = 0;
if (!stringKey) {
return obj;
}
returnCurrent = function(obj) {
... | [
"function",
"(",
"obj",
",",
"stringKey",
")",
"{",
"var",
"parts",
"=",
"stringKey",
".",
"split",
"(",
"'.'",
")",
",",
"returnCurrent",
"=",
"null",
",",
"current",
"=",
"''",
",",
"i",
"=",
"0",
";",
"if",
"(",
"!",
"stringKey",
")",
"{",
"re... | Returns the value of a property on a given object via its string key.
@param {object} obj
@param {string} stringKey
@return {*} value | [
"Returns",
"the",
"value",
"of",
"a",
"property",
"on",
"a",
"given",
"object",
"via",
"its",
"string",
"key",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1477-L1508 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(actionName, args) {
var self = this,
hooks = self.constructor.actions[actionName],
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return;
for (extensionName in hooks) {
hooks[extensionName].a... | javascript | function(actionName, args) {
var self = this,
hooks = self.constructor.actions[actionName],
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return;
for (extensionName in hooks) {
hooks[extensionName].a... | [
"function",
"(",
"actionName",
",",
"args",
")",
"{",
"var",
"self",
"=",
"this",
",",
"hooks",
"=",
"self",
".",
"constructor",
".",
"actions",
"[",
"actionName",
"]",
",",
"extensionName",
"=",
"''",
";",
"if",
"(",
"!",
"hooks",
"||",
"h",
".",
... | Calls any registered hooks for the provided action.
@memberof mixitup.Base
@private
@instance
@since 2.0.0
@param {string} actionName
@param {Array<*>} args
@return {void} | [
"Calls",
"any",
"registered",
"hooks",
"for",
"the",
"provided",
"action",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1541-L1551 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(filterName, input, args) {
var self = this,
hooks = self.constructor.filters[filterName],
output = input,
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return output;
args = args ||... | javascript | function(filterName, input, args) {
var self = this,
hooks = self.constructor.filters[filterName],
output = input,
extensionName = '';
if (!hooks || h.isEmptyObject(hooks)) return output;
args = args ||... | [
"function",
"(",
"filterName",
",",
"input",
",",
"args",
")",
"{",
"var",
"self",
"=",
"this",
",",
"hooks",
"=",
"self",
".",
"constructor",
".",
"filters",
"[",
"filterName",
"]",
",",
"output",
"=",
"input",
",",
"extensionName",
"=",
"''",
";",
... | Calls any registered hooks for the provided filter.
@memberof mixitup.Base
@private
@instance
@since 2.0.0
@param {string} filterName
@param {*} input
@param {Array<*>} args
@return {*} | [
"Calls",
"any",
"registered",
"hooks",
"for",
"the",
"provided",
"filter",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L1566-L1585 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(el, document) {
var self = this;
self.callActions('beforeCacheDom', arguments);
self.dom.document = document;
self.dom.body = self.dom.document.querySelector('body');
self.dom.container = el;
self.dom.parent = el;
... | javascript | function(el, document) {
var self = this;
self.callActions('beforeCacheDom', arguments);
self.dom.document = document;
self.dom.body = self.dom.document.querySelector('body');
self.dom.container = el;
self.dom.parent = el;
... | [
"function",
"(",
"el",
",",
"document",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"callActions",
"(",
"'beforeCacheDom'",
",",
"arguments",
")",
";",
"self",
".",
"dom",
".",
"document",
"=",
"document",
";",
"self",
".",
"dom",
".",
"b... | Caches references of DOM elements neccessary for the mixer's functionality.
@private
@instance
@since 3.0.0
@param {HTMLElement} el
@param {HTMLHtmlElement} document
@return {void} | [
"Caches",
"references",
"of",
"DOM",
"elements",
"neccessary",
"for",
"the",
"mixer",
"s",
"functionality",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5138-L5149 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
target = null,
el = null,
dataset = null,
i = -1;
self.callActions('beforeIndexTargets', arguments);
self.dom.targets = self.config.l... | javascript | function() {
var self = this,
target = null,
el = null,
dataset = null,
i = -1;
self.callActions('beforeIndexTargets', arguments);
self.dom.targets = self.config.l... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"target",
"=",
"null",
",",
"el",
"=",
"null",
",",
"dataset",
"=",
"null",
",",
"i",
"=",
"-",
"1",
";",
"self",
".",
"callActions",
"(",
"'beforeIndexTargets'",
",",
"arguments",
")",
";... | Indexes all child elements of the mixer matching the `selectors.target`
selector, instantiating a mixitup.Target for each one.
@private
@instance
@since 3.0.0
@return {void} | [
"Indexes",
"all",
"child",
"elements",
"of",
"the",
"mixer",
"matching",
"the",
"selectors",
".",
"target",
"selector",
"instantiating",
"a",
"mixitup",
".",
"Target",
"for",
"each",
"one",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5161-L5201 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
delineator = self.config.controls.toggleLogic === 'or' ? ', ' : '',
toggleSelector = '';
self.callActions('beforeGetToggleSelector', arguments);
self.toggleArray = h.clean(self.toggleArray);
... | javascript | function() {
var self = this,
delineator = self.config.controls.toggleLogic === 'or' ? ', ' : '',
toggleSelector = '';
self.callActions('beforeGetToggleSelector', arguments);
self.toggleArray = h.clean(self.toggleArray);
... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"delineator",
"=",
"self",
".",
"config",
".",
"controls",
".",
"toggleLogic",
"===",
"'or'",
"?",
"', '",
":",
"''",
",",
"toggleSelector",
"=",
"''",
";",
"self",
".",
"callActions",
"(",
... | Creates a compound selector by joining the `toggleArray` value as per the
defined toggle logic.
@private
@instance
@since 3.0.0
@return {string} | [
"Creates",
"a",
"compound",
"selector",
"by",
"joining",
"the",
"toggleArray",
"value",
"as",
"per",
"the",
"defined",
"toggle",
"logic",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5329-L5345 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(command, state) {
var self = this,
activeFilterSelector = '';
self.callActions('beforeBuildToggleArray', arguments);
if (command && command.filter) {
activeFilterSelector = command.filter.selector.replace(/\s/g, '');
... | javascript | function(command, state) {
var self = this,
activeFilterSelector = '';
self.callActions('beforeBuildToggleArray', arguments);
if (command && command.filter) {
activeFilterSelector = command.filter.selector.replace(/\s/g, '');
... | [
"function",
"(",
"command",
",",
"state",
")",
"{",
"var",
"self",
"=",
"this",
",",
"activeFilterSelector",
"=",
"''",
";",
"self",
".",
"callActions",
"(",
"'beforeBuildToggleArray'",
",",
"arguments",
")",
";",
"if",
"(",
"command",
"&&",
"command",
"."... | Breaks compound selector strings in an array of discreet selectors,
as per the active `controls.toggleLogic` configuration option. Accepts
either a dynamic command object, or a state object.
@private
@instance
@since 2.0.0
@param {object} [command]
@param {mixitup.State} [state]
@return {void} | [
"Breaks",
"compound",
"selector",
"strings",
"in",
"an",
"array",
"of",
"discreet",
"selectors",
"as",
"per",
"the",
"active",
"controls",
".",
"toggleLogic",
"configuration",
"option",
".",
"Accepts",
"either",
"a",
"dynamic",
"command",
"object",
"or",
"a",
... | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5360-L5387 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(target, attribute) {
var self = this,
value = '';
value = target.dom.el.getAttribute('data-' + attribute);
if (value === null) {
if (self.config.debug.showWarnings) {
// Encourage users to assign values to all target... | javascript | function(target, attribute) {
var self = this,
value = '';
value = target.dom.el.getAttribute('data-' + attribute);
if (value === null) {
if (self.config.debug.showWarnings) {
// Encourage users to assign values to all target... | [
"function",
"(",
"target",
",",
"attribute",
")",
"{",
"var",
"self",
"=",
"this",
",",
"value",
"=",
"''",
";",
"value",
"=",
"target",
".",
"dom",
".",
"el",
".",
"getAttribute",
"(",
"'data-'",
"+",
"attribute",
")",
";",
"if",
"(",
"value",
"==... | Reads the values of any data attributes present the provided target element
which match the current sort command.
@private
@instance
@since 3.0.0
@param {mixitup.Target} target
@param {string} [attribute]
@return {(String|Number)} | [
"Reads",
"the",
"values",
"of",
"any",
"data",
"attributes",
"present",
"the",
"provided",
"target",
"element",
"which",
"match",
"the",
"current",
"sort",
"command",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5807-L5827 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(isResetting, operation) {
var self = this,
startOrder = isResetting ? operation.newOrder : operation.startOrder,
newOrder = isResetting ? operation.startOrder : operation.newOrder,
nextSibling = startOrder.length ? startOrder[startOrder.len... | javascript | function(isResetting, operation) {
var self = this,
startOrder = isResetting ? operation.newOrder : operation.startOrder,
newOrder = isResetting ? operation.startOrder : operation.newOrder,
nextSibling = startOrder.length ? startOrder[startOrder.len... | [
"function",
"(",
"isResetting",
",",
"operation",
")",
"{",
"var",
"self",
"=",
"this",
",",
"startOrder",
"=",
"isResetting",
"?",
"operation",
".",
"newOrder",
":",
"operation",
".",
"startOrder",
",",
"newOrder",
"=",
"isResetting",
"?",
"operation",
".",... | Inserts elements into the DOM in the appropriate
order using a document fragment for minimal
DOM thrashing
@private
@instance
@since 2.0.0
@param {boolean} isResetting
@param {Operation} operation
@return {void} | [
"Inserts",
"elements",
"into",
"the",
"DOM",
"in",
"the",
"appropriate",
"order",
"using",
"a",
"document",
"fragment",
"for",
"minimal",
"DOM",
"thrashing"
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5842-L5901 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
transformName = '',
effectsIn = self.config.animation.effectsIn || self.config.animation.effects,
effectsOut = self.config.animation.effectsOut || self.config.animation.effects;
self.callAction... | javascript | function() {
var self = this,
transformName = '',
effectsIn = self.config.animation.effectsIn || self.config.animation.effects,
effectsOut = self.config.animation.effectsOut || self.config.animation.effects;
self.callAction... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"transformName",
"=",
"''",
",",
"effectsIn",
"=",
"self",
".",
"config",
".",
"animation",
".",
"effectsIn",
"||",
"self",
".",
"config",
".",
"animation",
".",
"effects",
",",
"effectsOut",
... | Parses all effects out of the user-defined `animation.effects` string into
their respective properties and units.
@private
@instance
@since 2.0.0
@return {void} | [
"Parses",
"all",
"effects",
"out",
"of",
"the",
"user",
"-",
"defined",
"animation",
".",
"effects",
"string",
"into",
"their",
"respective",
"properties",
"and",
"units",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L5972-L6003 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(statusChange, hasEffect, posIn, posOut) {
var self = this,
result = false;
if (!h.isVisible(self.dom.container)) {
// If the container is not visible, the transitionEnd
// event will not occur and MixItUp will hang
re... | javascript | function(statusChange, hasEffect, posIn, posOut) {
var self = this,
result = false;
if (!h.isVisible(self.dom.container)) {
// If the container is not visible, the transitionEnd
// event will not occur and MixItUp will hang
re... | [
"function",
"(",
"statusChange",
",",
"hasEffect",
",",
"posIn",
",",
"posOut",
")",
"{",
"var",
"self",
"=",
"this",
",",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"h",
".",
"isVisible",
"(",
"self",
".",
"dom",
".",
"container",
")",
")",
"{",... | Determines if a target element will transition in
some fasion and therefore requires binding of
transitionEnd
@private
@instance
@since 3.0.0
@param {string} statusChange
@param {boolean} hasEffect
@param {StyleData} posIn
@param {StyleData} posOut
@return {boolean} | [
"Determines",
"if",
"a",
"target",
"element",
"will",
"transition",
"in",
"some",
"fasion",
"and",
"therefore",
"requires",
"binding",
"of",
"transitionEnd"
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L6815-L6846 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
instruction = self.parseFilterArgs(arguments);
return self.multimix({
filter: instruction.command
}, instruction.animate, instruction.callback);
} | javascript | function() {
var self = this,
instruction = self.parseFilterArgs(arguments);
return self.multimix({
filter: instruction.command
}, instruction.animate, instruction.callback);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"instruction",
"=",
"self",
".",
"parseFilterArgs",
"(",
"arguments",
")",
";",
"return",
"self",
".",
"multimix",
"(",
"{",
"filter",
":",
"instruction",
".",
"command",
"}",
",",
"instruction"... | Filters all targets in the container by a provided selector string, or the values `'all'`
or `'none'`. Only targets matching the selector will be shown.
@example
.filter(selector [, animate] [, callback])
@example <caption>Example 1: Filtering targets by a class selector</caption>
mixer.filter('.category-a')
.then(... | [
"Filters",
"all",
"targets",
"in",
"the",
"container",
"by",
"a",
"provided",
"selector",
"string",
"or",
"the",
"values",
"all",
"or",
"none",
".",
"Only",
"targets",
"matching",
"the",
"selector",
"will",
"be",
"shown",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L7920-L7927 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
instruction = self.parseFilterArgs(arguments),
selector = instruction.command.selector,
toggleSelector = '';
self.isToggling = true;
if (self.toggleArray.indexOf(selector) < 0) {
... | javascript | function() {
var self = this,
instruction = self.parseFilterArgs(arguments),
selector = instruction.command.selector,
toggleSelector = '';
self.isToggling = true;
if (self.toggleArray.indexOf(selector) < 0) {
... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"instruction",
"=",
"self",
".",
"parseFilterArgs",
"(",
"arguments",
")",
",",
"selector",
"=",
"instruction",
".",
"command",
".",
"selector",
",",
"toggleSelector",
"=",
"''",
";",
"self",
".... | Adds an additional selector to the currently active filter selector, concatenating
as per the logic defined in `controls.toggleLogic`.
@example
.toggleOn(selector [, animate] [, callback])
@example <caption>Example: Toggling on a filter selector</caption>
console.log(mixer.getState().activeFilter.selector); // '.ca... | [
"Adds",
"an",
"additional",
"selector",
"to",
"the",
"currently",
"active",
"filter",
"selector",
"concatenating",
"as",
"per",
"the",
"logic",
"defined",
"in",
"controls",
".",
"toggleLogic",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L7959-L7976 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
instruction = self.parseSortArgs(arguments);
return self.multimix({
sort: instruction.command
}, instruction.animate, instruction.callback);
} | javascript | function() {
var self = this,
instruction = self.parseSortArgs(arguments);
return self.multimix({
sort: instruction.command
}, instruction.animate, instruction.callback);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"instruction",
"=",
"self",
".",
"parseSortArgs",
"(",
"arguments",
")",
";",
"return",
"self",
".",
"multimix",
"(",
"{",
"sort",
":",
"instruction",
".",
"command",
"}",
",",
"instruction",
... | Sorts all targets in the container according to a provided sort string.
@example
.sort(sortString [, animate] [, callback])
@example <caption>Example 1: Sorting by the default DOM order</caption>
// Reverse the default order of the targets
mixer.sort('default:desc')
.then(function(state) {
console.log(state.active... | [
"Sorts",
"all",
"targets",
"in",
"the",
"container",
"according",
"to",
"a",
"provided",
"sort",
"string",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8102-L8109 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
instruction = self.parseChangeLayoutArgs(arguments);
return self.multimix({
changeLayout: instruction.command
}, instruction.animate, instruction.callback);
} | javascript | function() {
var self = this,
instruction = self.parseChangeLayoutArgs(arguments);
return self.multimix({
changeLayout: instruction.command
}, instruction.animate, instruction.callback);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"instruction",
"=",
"self",
".",
"parseChangeLayoutArgs",
"(",
"arguments",
")",
";",
"return",
"self",
".",
"multimix",
"(",
"{",
"changeLayout",
":",
"instruction",
".",
"command",
"}",
",",
"... | Changes the layout of the container by adding, removing or updating a
layout-specific class name. If `animation.animateResizetargets` is
enabled, MixItUp will attempt to gracefully animate the width, height,
and position of targets between layout states.
@example
.changeLayout(containerClassName [, animate] [, callba... | [
"Changes",
"the",
"layout",
"of",
"the",
"container",
"by",
"adding",
"removing",
"or",
"updating",
"a",
"layout",
"-",
"specific",
"class",
"name",
".",
"If",
"animation",
".",
"animateResizetargets",
"is",
"enabled",
"MixItUp",
"will",
"attempt",
"to",
"grac... | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8148-L8155 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
instruction = self.parseDatasetArgs(arguments),
operation = null,
queueItem = null,
animate = false;
self.callActions('beforeDataset', arguments);
if (!self.isBusy) {
... | javascript | function() {
var self = this,
instruction = self.parseDatasetArgs(arguments),
operation = null,
queueItem = null,
animate = false;
self.callActions('beforeDataset', arguments);
if (!self.isBusy) {
... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"instruction",
"=",
"self",
".",
"parseDatasetArgs",
"(",
"arguments",
")",
",",
"operation",
"=",
"null",
",",
"queueItem",
"=",
"null",
",",
"animate",
"=",
"false",
";",
"self",
".",
"callA... | Updates the contents and order of the container to reflect the provided dataset,
if the dataset API is in use.
The dataset API is designed for use in API-driven JavaScript applications, and
can be used instead of DOM-based methods such as `.filter()`, `.sort()`,
`.insert()`, etc. When used, insertion, removal, sorting... | [
"Updates",
"the",
"contents",
"and",
"order",
"of",
"the",
"container",
"to",
"reflect",
"the",
"provided",
"dataset",
"if",
"the",
"dataset",
"API",
"is",
"in",
"use",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8221-L8246 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
operation = null,
animate = false,
queueItem = null,
instruction = self.parseMultimixArgs(arguments);
self.callActions('beforeMultimix', arguments);
if (!self.isBusy) {
... | javascript | function() {
var self = this,
operation = null,
animate = false,
queueItem = null,
instruction = self.parseMultimixArgs(arguments);
self.callActions('beforeMultimix', arguments);
if (!self.isBusy) {
... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"operation",
"=",
"null",
",",
"animate",
"=",
"false",
",",
"queueItem",
"=",
"null",
",",
"instruction",
"=",
"self",
".",
"parseMultimixArgs",
"(",
"arguments",
")",
";",
"self",
".",
"call... | Performs simultaneous `filter`, `sort`, `insert`, `remove` and `changeLayout`
operations as requested.
@example
.multimix(multimixCommand [, animate] [, callback])
@example <caption>Example 1: Performing simultaneous filtering and sorting</caption>
mixer.multimix({
filter: '.category-b',
sort: 'published-date:desc'... | [
"Performs",
"simultaneous",
"filter",
"sort",
"insert",
"remove",
"and",
"changeLayout",
"operations",
"as",
"requested",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8301-L8350 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(operation, multiplier) {
var target = null,
posData = null,
toHideIndex = -1,
i = -1;
multiplier = Math.min(multiplier, 1);
multiplier = Math.max(multiplier, 0);
for (i = 0; targ... | javascript | function(operation, multiplier) {
var target = null,
posData = null,
toHideIndex = -1,
i = -1;
multiplier = Math.min(multiplier, 1);
multiplier = Math.max(multiplier, 0);
for (i = 0; targ... | [
"function",
"(",
"operation",
",",
"multiplier",
")",
"{",
"var",
"target",
"=",
"null",
",",
"posData",
"=",
"null",
",",
"toHideIndex",
"=",
"-",
"1",
",",
"i",
"=",
"-",
"1",
";",
"multiplier",
"=",
"Math",
".",
"min",
"(",
"multiplier",
",",
"1... | Renders a previously created operation at a specific point in its path, as
determined by a multiplier between 0 and 1.
@example
.tween(operation, multiplier)
@private
@instance
@since 3.0.0
@param {mixitup.Operation} operation
An operation object created via the `getOperation` method
@param {Float} ... | [
"Renders",
"a",
"previously",
"created",
"operation",
"at",
"a",
"specific",
"point",
"in",
"its",
"path",
"as",
"determined",
"by",
"a",
"multiplier",
"between",
"0",
"and",
"1",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8478-L8508 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
args = self.parseInsertArgs(arguments);
return self.multimix({
insert: args.command
}, args.animate, args.callback);
} | javascript | function() {
var self = this,
args = self.parseInsertArgs(arguments);
return self.multimix({
insert: args.command
}, args.animate, args.callback);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"args",
"=",
"self",
".",
"parseInsertArgs",
"(",
"arguments",
")",
";",
"return",
"self",
".",
"multimix",
"(",
"{",
"insert",
":",
"args",
".",
"command",
"}",
",",
"args",
".",
"animate",... | Inserts one or more new target elements into the container at a specified
index.
To be indexed as targets, new elements must match the `selectors.target`
selector (`'.mix'` by default).
@example
.insert(newElements [, index] [, animate], [, callback])
@example <caption>Example 1: Inserting a single element via refe... | [
"Inserts",
"one",
"or",
"more",
"new",
"target",
"elements",
"into",
"the",
"container",
"at",
"a",
"specified",
"index",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8603-L8610 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
args = self.parseRemoveArgs(arguments);
return self.multimix({
remove: args.command
}, args.animate, args.callback);
} | javascript | function() {
var self = this,
args = self.parseRemoveArgs(arguments);
return self.multimix({
remove: args.command
}, args.animate, args.callback);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"args",
"=",
"self",
".",
"parseRemoveArgs",
"(",
"arguments",
")",
";",
"return",
"self",
".",
"multimix",
"(",
"{",
"remove",
":",
"args",
".",
"command",
"}",
",",
"args",
".",
"animate",... | Removes one or more existing target elements from the container.
@example
.remove(elements [, animate] [, callback])
@example <caption>Example 1: Removing an element by reference</caption>
var elementToRemove = containerEl.firstElementChild;
mixer.remove(elementToRemove)
.then(function(state) {
console.log(state.t... | [
"Removes",
"one",
"or",
"more",
"existing",
"target",
"elements",
"from",
"the",
"container",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8852-L8859 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(stringKey) {
var self = this,
value = null;
if (!stringKey) {
value = self.config;
} else {
value = h.getProperty(self.config, stringKey);
}
return self.callFilters('valueGetConfig', value, argume... | javascript | function(stringKey) {
var self = this,
value = null;
if (!stringKey) {
value = self.config;
} else {
value = h.getProperty(self.config, stringKey);
}
return self.callFilters('valueGetConfig', value, argume... | [
"function",
"(",
"stringKey",
")",
"{",
"var",
"self",
"=",
"this",
",",
"value",
"=",
"null",
";",
"if",
"(",
"!",
"stringKey",
")",
"{",
"value",
"=",
"self",
".",
"config",
";",
"}",
"else",
"{",
"value",
"=",
"h",
".",
"getProperty",
"(",
"se... | Retrieves the the value of any property or sub-object within the current
mixitup configuration, or the whole configuration object.
@example
.getConfig([stringKey])
@example <caption>Example 1: retrieve the entire configuration object</caption>
var config = mixer.getConfig(); // Config { ... }
@example <caption>Exa... | [
"Retrieves",
"the",
"the",
"value",
"of",
"any",
"property",
"or",
"sub",
"-",
"object",
"within",
"the",
"current",
"mixitup",
"configuration",
"or",
"the",
"whole",
"configuration",
"object",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8888-L8899 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(config) {
var self = this;
self.callActions('beforeConfigure', arguments);
h.extend(self.config, config, true, true);
self.callActions('afterConfigure', arguments);
} | javascript | function(config) {
var self = this;
self.callActions('beforeConfigure', arguments);
h.extend(self.config, config, true, true);
self.callActions('afterConfigure', arguments);
} | [
"function",
"(",
"config",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"callActions",
"(",
"'beforeConfigure'",
",",
"arguments",
")",
";",
"h",
".",
"extend",
"(",
"self",
".",
"config",
",",
"config",
",",
"true",
",",
"true",
")",
";",... | Updates the configuration of the mixer, after it has been instantiated.
See the Configuration Object documentation for a full list of avilable
configuration options.
@example
.configure(config)
@example <caption>Example 1: Updating animation options</caption>
mixer.configure({
animation: {
effects: 'fade translate... | [
"Updates",
"the",
"configuration",
"of",
"the",
"mixer",
"after",
"it",
"has",
"been",
"instantiated",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8952-L8960 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function() {
var self = this,
state = null;
state = new mixitup.State();
h.extend(state, self.state);
h.freeze(state);
return self.callFilters('stateGetState', state, arguments);
} | javascript | function() {
var self = this,
state = null;
state = new mixitup.State();
h.extend(state, self.state);
h.freeze(state);
return self.callFilters('stateGetState', state, arguments);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"state",
"=",
"null",
";",
"state",
"=",
"new",
"mixitup",
".",
"State",
"(",
")",
";",
"h",
".",
"extend",
"(",
"state",
",",
"self",
".",
"state",
")",
";",
"h",
".",
"freeze",
"(",
... | Returns an object containing information about the current state of the
mixer. See the State Object documentation for more information.
NB: State objects are immutable and should therefore be regenerated
after any operation.
@example
.getState();
@example <caption>Example: Retrieving a state object</caption>
var s... | [
"Returns",
"an",
"object",
"containing",
"information",
"about",
"the",
"current",
"state",
"of",
"the",
"mixer",
".",
"See",
"the",
"State",
"Object",
"documentation",
"for",
"more",
"information",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L8985-L8996 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(cleanUp) {
var self = this,
control = null,
target = null,
i = 0;
self.callActions('beforeDestroy', arguments);
for (i = 0; control = self.controls[i]; i++) {
control.removeBinding(self);
... | javascript | function(cleanUp) {
var self = this,
control = null,
target = null,
i = 0;
self.callActions('beforeDestroy', arguments);
for (i = 0; control = self.controls[i]; i++) {
control.removeBinding(self);
... | [
"function",
"(",
"cleanUp",
")",
"{",
"var",
"self",
"=",
"this",
",",
"control",
"=",
"null",
",",
"target",
"=",
"null",
",",
"i",
"=",
"0",
";",
"self",
".",
"callActions",
"(",
"'beforeDestroy'",
",",
"arguments",
")",
";",
"for",
"(",
"i",
"="... | Removes mixitup functionality from the container, unbinds all control
event handlers, and deletes the mixer instance from MixItUp's internal
cache.
This should be performed whenever a mixer's container is removed from
the DOM, such as during a page change in a single page application,
or React's `componentWillUnmount(... | [
"Removes",
"mixitup",
"functionality",
"from",
"the",
"container",
"unbinds",
"all",
"control",
"event",
"handlers",
"and",
"deletes",
"the",
"mixer",
"instance",
"from",
"MixItUp",
"s",
"internal",
"cache",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L9069-L9096 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(el, mixer, data) {
var self = this,
id = '';
self.callActions('beforeInit', arguments);
self.mixer = mixer;
if (!el) {
// If no element is provided, render it
el = self.render(data);
}
... | javascript | function(el, mixer, data) {
var self = this,
id = '';
self.callActions('beforeInit', arguments);
self.mixer = mixer;
if (!el) {
// If no element is provided, render it
el = self.render(data);
}
... | [
"function",
"(",
"el",
",",
"mixer",
",",
"data",
")",
"{",
"var",
"self",
"=",
"this",
",",
"id",
"=",
"''",
";",
"self",
".",
"callActions",
"(",
"'beforeInit'",
",",
"arguments",
")",
";",
"self",
".",
"mixer",
"=",
"mixer",
";",
"if",
"(",
"!... | Initialises a newly instantiated Target.
@private
@instance
@since 3.0.0
@param {(Element|null)} el
@param {object} mixer
@param {object} [data]
@return {void} | [
"Initialises",
"a",
"newly",
"instantiated",
"Target",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L9205-L9241 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(data) {
var self = this,
render = null,
el = null,
temp = null,
output = '';
self.callActions('beforeRender', arguments);
render = self.callFilters('renderRender', self.mixer.config.render.target,... | javascript | function(data) {
var self = this,
render = null,
el = null,
temp = null,
output = '';
self.callActions('beforeRender', arguments);
render = self.callFilters('renderRender', self.mixer.config.render.target,... | [
"function",
"(",
"data",
")",
"{",
"var",
"self",
"=",
"this",
",",
"render",
"=",
"null",
",",
"el",
"=",
"null",
",",
"temp",
"=",
"null",
",",
"output",
"=",
"''",
";",
"self",
".",
"callActions",
"(",
"'beforeRender'",
",",
"arguments",
")",
";... | Renders the target element using a user-defined renderer function.
@private
@instance
@since 3.1.4
@param {object} data
@return {void} | [
"Renders",
"the",
"target",
"element",
"using",
"a",
"user",
"-",
"defined",
"renderer",
"function",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L9253-L9280 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(el) {
var self = this;
self.callActions('beforeCacheDom', arguments);
self.dom.el = el;
self.callActions('afterCacheDom', arguments);
} | javascript | function(el) {
var self = this;
self.callActions('beforeCacheDom', arguments);
self.dom.el = el;
self.callActions('afterCacheDom', arguments);
} | [
"function",
"(",
"el",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"callActions",
"(",
"'beforeCacheDom'",
",",
"arguments",
")",
";",
"self",
".",
"dom",
".",
"el",
"=",
"el",
";",
"self",
".",
"callActions",
"(",
"'afterCacheDom'",
",",
... | Caches references of DOM elements neccessary for the target's functionality.
@private
@instance
@since 3.0.0
@param {Element} el
@return {void} | [
"Caches",
"references",
"of",
"DOM",
"elements",
"neccessary",
"for",
"the",
"target",
"s",
"functionality",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L9292-L9300 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(moveData) {
var self = this,
posIn = moveData.posIn,
isFading = self.mixer.effectsIn.opacity !== 1,
transformValues = [];
self.callActions('beforeApplyStylesIn', arguments);
transformValues.push('t... | javascript | function(moveData) {
var self = this,
posIn = moveData.posIn,
isFading = self.mixer.effectsIn.opacity !== 1,
transformValues = [];
self.callActions('beforeApplyStylesIn', arguments);
transformValues.push('t... | [
"function",
"(",
"moveData",
")",
"{",
"var",
"self",
"=",
"this",
",",
"posIn",
"=",
"moveData",
".",
"posIn",
",",
"isFading",
"=",
"self",
".",
"mixer",
".",
"effectsIn",
".",
"opacity",
"!==",
"1",
",",
"transformValues",
"=",
"[",
"]",
";",
"sel... | Applies the initial styling to a target element before any transition
is applied.
@private
@instance
@param {mixitup.IMoveData} moveData
@return {void} | [
"Applies",
"the",
"initial",
"styling",
"to",
"a",
"target",
"element",
"before",
"any",
"transition",
"is",
"applied",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L9474-L9505 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(property, staggerIndex, duration) {
var self = this,
delay = self.getDelay(staggerIndex),
rule = '';
rule = property + ' ' +
(duration > 0 ? duration : self.mixer.config.animation.duration) + 'ms ' +
delay + 'ms ' +
... | javascript | function(property, staggerIndex, duration) {
var self = this,
delay = self.getDelay(staggerIndex),
rule = '';
rule = property + ' ' +
(duration > 0 ? duration : self.mixer.config.animation.duration) + 'ms ' +
delay + 'ms ' +
... | [
"function",
"(",
"property",
",",
"staggerIndex",
",",
"duration",
")",
"{",
"var",
"self",
"=",
"this",
",",
"delay",
"=",
"self",
".",
"getDelay",
"(",
"staggerIndex",
")",
",",
"rule",
"=",
"''",
";",
"rule",
"=",
"property",
"+",
"' '",
"+",
"(",... | Combines the name of a CSS property with the appropriate duration and delay
values to created a valid transition rule.
@private
@instance
@since 3.0.0
@param {string} property
@param {number} staggerIndex
@param {number} duration
@return {string} | [
"Combines",
"the",
"name",
"of",
"a",
"CSS",
"property",
"with",
"the",
"appropriate",
"duration",
"and",
"delay",
"values",
"to",
"created",
"a",
"valid",
"transition",
"rule",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L9658-L9669 | train | |
octoblu/meshblu | docs/vendor/mixitup/mixitup.js | function(methodName) {
var self = this,
instance = null,
args = Array.prototype.slice.call(arguments),
tasks = [],
i = -1;
this.callActions('beforeMixitup');
args.shift();
... | javascript | function(methodName) {
var self = this,
instance = null,
args = Array.prototype.slice.call(arguments),
tasks = [],
i = -1;
this.callActions('beforeMixitup');
args.shift();
... | [
"function",
"(",
"methodName",
")",
"{",
"var",
"self",
"=",
"this",
",",
"instance",
"=",
"null",
",",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"tasks",
"=",
"[",
"]",
",",
"i",
"=",
"-",
"1"... | Calls a method on all instances in the collection by passing the method
name as a string followed by any applicable parameters to be curried into
to the method.
@example
.mixitup(methodName[,arg1][,arg2..]);
@example
var collection = new Collection([mixer1, mixer2]);
return collection.mixitup('filter', '.category-a'... | [
"Calls",
"a",
"method",
"on",
"all",
"instances",
"in",
"the",
"collection",
"by",
"passing",
"the",
"method",
"name",
"as",
"a",
"string",
"followed",
"by",
"any",
"applicable",
"parameters",
"to",
"be",
"curried",
"into",
"to",
"the",
"method",
"."
] | 4e7a5a0460b4eb097dfe9ff2db15853eccc779d7 | https://github.com/octoblu/meshblu/blob/4e7a5a0460b4eb097dfe9ff2db15853eccc779d7/docs/vendor/mixitup/mixitup.js#L9950-L9966 | train | |
sbyrnes/likely.js | likely.js | buildModelWithBias | function buildModelWithBias(inputArray, bias, rowLabels, colLabels)
{
var model = new Model($M(inputArray), rowLabels, colLabels);
model.estimated = train(sylvester.Matrix.create(inputArray), bias);
return model
} | javascript | function buildModelWithBias(inputArray, bias, rowLabels, colLabels)
{
var model = new Model($M(inputArray), rowLabels, colLabels);
model.estimated = train(sylvester.Matrix.create(inputArray), bias);
return model
} | [
"function",
"buildModelWithBias",
"(",
"inputArray",
",",
"bias",
",",
"rowLabels",
",",
"colLabels",
")",
"{",
"var",
"model",
"=",
"new",
"Model",
"(",
"$M",
"(",
"inputArray",
")",
",",
"rowLabels",
",",
"colLabels",
")",
";",
"model",
".",
"estimated",... | Builds a complete model from the input array with bias
@param inputArray A two dimensional array of the input, where each cell is the rating given to Col by Row
@param bias A two dimensional matrix of the bias of the inputArray
@param [optional] rowLabels A one dimensional array of string labels for each row of inputA... | [
"Builds",
"a",
"complete",
"model",
"from",
"the",
"input",
"array",
"with",
"bias"
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L35-L41 | train |
sbyrnes/likely.js | likely.js | train | function train(inputMatrix, bias)
{
N = inputMatrix.rows(); // number of rows
M = inputMatrix.cols(); // number of columns
// Generate random P and Q based on the dimensions of inputMatrix
var P_model = generateRandomMatrix(N, K);
var Q_model = generateRandomMatrix(K, M);
var i = 0
for(i = 0; i ... | javascript | function train(inputMatrix, bias)
{
N = inputMatrix.rows(); // number of rows
M = inputMatrix.cols(); // number of columns
// Generate random P and Q based on the dimensions of inputMatrix
var P_model = generateRandomMatrix(N, K);
var Q_model = generateRandomMatrix(K, M);
var i = 0
for(i = 0; i ... | [
"function",
"train",
"(",
"inputMatrix",
",",
"bias",
")",
"{",
"N",
"=",
"inputMatrix",
".",
"rows",
"(",
")",
";",
"// number of rows ",
"M",
"=",
"inputMatrix",
".",
"cols",
"(",
")",
";",
"// number of columns",
"// Generate random P and Q based on the dimensi... | Trains the model on the given input by composing two matrices P and Q which
approximate the input through their product.
@param inputMatrix A two dimensional array representing input values
@returns Model A model entity, with estimated values based on the input | [
"Trains",
"the",
"model",
"on",
"the",
"given",
"input",
"by",
"composing",
"two",
"matrices",
"P",
"and",
"Q",
"which",
"approximate",
"the",
"input",
"through",
"their",
"product",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L49-L147 | train |
sbyrnes/likely.js | likely.js | calculateError | function calculateError(estimated, input, bias)
{
var adjustedInput = input.dup();
var adjustedElements = adjustedInput.elements;
// If bias adjustment is provided, adjust for it
if(bias)
{
// subtract the row and column bias from each row
for(var i = 0; i <= adjustedInput.rows()-1; i++)
{
for(var ... | javascript | function calculateError(estimated, input, bias)
{
var adjustedInput = input.dup();
var adjustedElements = adjustedInput.elements;
// If bias adjustment is provided, adjust for it
if(bias)
{
// subtract the row and column bias from each row
for(var i = 0; i <= adjustedInput.rows()-1; i++)
{
for(var ... | [
"function",
"calculateError",
"(",
"estimated",
",",
"input",
",",
"bias",
")",
"{",
"var",
"adjustedInput",
"=",
"input",
".",
"dup",
"(",
")",
";",
"var",
"adjustedElements",
"=",
"adjustedInput",
".",
"elements",
";",
"// If bias adjustment is provided, adjust ... | Computes the error from model matrices P and Q against the given input.
@param estimated A matrix of the estimated values.
@param input A matrix of the input values
@returns A matrix of size input.rows by input.columns where each entry is the difference between the input and estimated values. | [
"Computes",
"the",
"error",
"from",
"model",
"matrices",
"P",
"and",
"Q",
"against",
"the",
"given",
"input",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L166-L208 | train |
sbyrnes/likely.js | likely.js | calculateTotalError | function calculateTotalError(errorMatrix)
{
var totError = 0.0;
for(var i = 1; i <= errorMatrix.rows(); i++)
{
for(var j = 1; j <= errorMatrix.cols(); j++)
{
totError += Math.pow(errorMatrix.e(i, j), 2);
}
}
return totError;
} | javascript | function calculateTotalError(errorMatrix)
{
var totError = 0.0;
for(var i = 1; i <= errorMatrix.rows(); i++)
{
for(var j = 1; j <= errorMatrix.cols(); j++)
{
totError += Math.pow(errorMatrix.e(i, j), 2);
}
}
return totError;
} | [
"function",
"calculateTotalError",
"(",
"errorMatrix",
")",
"{",
"var",
"totError",
"=",
"0.0",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<=",
"errorMatrix",
".",
"rows",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"1... | Computes the total error based on a matrix of error values.
@param errorMatrix A matrix of the error values.
@returns float Total error, defined as the sum of the squared errors. | [
"Computes",
"the",
"total",
"error",
"based",
"on",
"a",
"matrix",
"of",
"error",
"values",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L226-L238 | train |
sbyrnes/likely.js | likely.js | calculateBias | function calculateBias(input)
{
var inputMatrix = $M(input);
var average = calculateMatrixAverage(inputMatrix);
var rowAverages = calculateRowAverage(inputMatrix);
var colAverages = calculateColumnAverage(inputMatrix);
var rowBiases = new Array();
var colBiases = new Array();
// The row bias is the differenc... | javascript | function calculateBias(input)
{
var inputMatrix = $M(input);
var average = calculateMatrixAverage(inputMatrix);
var rowAverages = calculateRowAverage(inputMatrix);
var colAverages = calculateColumnAverage(inputMatrix);
var rowBiases = new Array();
var colBiases = new Array();
// The row bias is the differenc... | [
"function",
"calculateBias",
"(",
"input",
")",
"{",
"var",
"inputMatrix",
"=",
"$M",
"(",
"input",
")",
";",
"var",
"average",
"=",
"calculateMatrixAverage",
"(",
"inputMatrix",
")",
";",
"var",
"rowAverages",
"=",
"calculateRowAverage",
"(",
"inputMatrix",
"... | Computes the biases from a matrix of values.
@param input A matrix of the input values
@returns Bias Object containing the average, bias for rows and bias for columns. | [
"Computes",
"the",
"biases",
"from",
"a",
"matrix",
"of",
"values",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L245-L270 | train |
sbyrnes/likely.js | likely.js | Bias | function Bias(average, rowBiases, colBiases) {
this.average = average; // Overall value average
this.rowBiases = rowBiases; // Bias for each row
this.colBiases = colBiases; // Bias for each column
} | javascript | function Bias(average, rowBiases, colBiases) {
this.average = average; // Overall value average
this.rowBiases = rowBiases; // Bias for each row
this.colBiases = colBiases; // Bias for each column
} | [
"function",
"Bias",
"(",
"average",
",",
"rowBiases",
",",
"colBiases",
")",
"{",
"this",
".",
"average",
"=",
"average",
";",
"// Overall value average",
"this",
".",
"rowBiases",
"=",
"rowBiases",
";",
"// Bias for each row",
"this",
".",
"colBiases",
"=",
"... | Bias representation object. Contains all bias elements. | [
"Bias",
"representation",
"object",
".",
"Contains",
"all",
"bias",
"elements",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L275-L279 | train |
sbyrnes/likely.js | likely.js | calculateMatrixAverage | function calculateMatrixAverage(inputMatrix)
{
var cells = inputMatrix.rows() * inputMatrix.cols();
var sum = 0;
for(var i = 1; i <= inputMatrix.rows(); i++)
{
for(var j = 1; j <= inputMatrix.cols(); j++)
{
sum += inputMatrix.e(i, j);
}
}
return sum/cells;
} | javascript | function calculateMatrixAverage(inputMatrix)
{
var cells = inputMatrix.rows() * inputMatrix.cols();
var sum = 0;
for(var i = 1; i <= inputMatrix.rows(); i++)
{
for(var j = 1; j <= inputMatrix.cols(); j++)
{
sum += inputMatrix.e(i, j);
}
}
return sum/cells;
} | [
"function",
"calculateMatrixAverage",
"(",
"inputMatrix",
")",
"{",
"var",
"cells",
"=",
"inputMatrix",
".",
"rows",
"(",
")",
"*",
"inputMatrix",
".",
"cols",
"(",
")",
";",
"var",
"sum",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
... | Computes the overall average value from a matrix of values.
@param input A matrix of the input values
@returns float Average value. | [
"Computes",
"the",
"overall",
"average",
"value",
"from",
"a",
"matrix",
"of",
"values",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L286-L300 | train |
sbyrnes/likely.js | likely.js | calculateColumnAverage | function calculateColumnAverage(inputMatrix)
{
var rows = inputMatrix.rows();
var averages = new Array();
for(var i = 1; i <= inputMatrix.cols(); i++)
{
var sum = 0;
for(var j = 1; j <= inputMatrix.rows(); j++)
{
sum += inputMatrix.e(j, i);
}
averages[i-1] = sum/rows;
}
return $V(averages);
} | javascript | function calculateColumnAverage(inputMatrix)
{
var rows = inputMatrix.rows();
var averages = new Array();
for(var i = 1; i <= inputMatrix.cols(); i++)
{
var sum = 0;
for(var j = 1; j <= inputMatrix.rows(); j++)
{
sum += inputMatrix.e(j, i);
}
averages[i-1] = sum/rows;
}
return $V(averages);
} | [
"function",
"calculateColumnAverage",
"(",
"inputMatrix",
")",
"{",
"var",
"rows",
"=",
"inputMatrix",
".",
"rows",
"(",
")",
";",
"var",
"averages",
"=",
"new",
"Array",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<=",
"inputMatrix",
... | Computes the average value for each column of a matrix of values.
@param input A matrix of the input values
@returns Vector Average value for each column. Vector[i] is the average for column i. | [
"Computes",
"the",
"average",
"value",
"for",
"each",
"column",
"of",
"a",
"matrix",
"of",
"values",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L307-L323 | train |
sbyrnes/likely.js | likely.js | Model | function Model(inputMatrix, rowLabels, colLabels) {
this.rowLabels = rowLabels; // labels for the rows
this.colLabels = colLabels; // labels for the columns
this.input = inputMatrix; // input data
// estimated data, initialized to all zeros
this.estimated = sylvester.Matrix.Zeros(this.input.rows(),this.input.col... | javascript | function Model(inputMatrix, rowLabels, colLabels) {
this.rowLabels = rowLabels; // labels for the rows
this.colLabels = colLabels; // labels for the columns
this.input = inputMatrix; // input data
// estimated data, initialized to all zeros
this.estimated = sylvester.Matrix.Zeros(this.input.rows(),this.input.col... | [
"function",
"Model",
"(",
"inputMatrix",
",",
"rowLabels",
",",
"colLabels",
")",
"{",
"this",
".",
"rowLabels",
"=",
"rowLabels",
";",
"// labels for the rows",
"this",
".",
"colLabels",
"=",
"colLabels",
";",
"// labels for the columns",
"this",
".",
"input",
... | Model representation object. Contains both input and estimated values. | [
"Model",
"representation",
"object",
".",
"Contains",
"both",
"input",
"and",
"estimated",
"values",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L351-L358 | train |
sbyrnes/likely.js | likely.js | function(row)
{
var rowIndex = row; // assume row is a number
// If we're using labels we have to look up the row index
if(this.rowLabels)
{
rowIndex = findInArray(this.rowLabels, row);
}
// estimates for this user
var ratingElements = this.estimated.row(rowIndex+1).elements;
// build a two di... | javascript | function(row)
{
var rowIndex = row; // assume row is a number
// If we're using labels we have to look up the row index
if(this.rowLabels)
{
rowIndex = findInArray(this.rowLabels, row);
}
// estimates for this user
var ratingElements = this.estimated.row(rowIndex+1).elements;
// build a two di... | [
"function",
"(",
"row",
")",
"{",
"var",
"rowIndex",
"=",
"row",
";",
"// assume row is a number",
"// If we're using labels we have to look up the row index",
"if",
"(",
"this",
".",
"rowLabels",
")",
"{",
"rowIndex",
"=",
"findInArray",
"(",
"this",
".",
"rowLabel... | Returns all items for a given row, sorted by rating.
@param row The row to return values for
@returns Array An array of arrays, each containing two entries. [0] is the index and [1] is the value, sorted by value. | [
"Returns",
"all",
"items",
"for",
"a",
"given",
"row",
"sorted",
"by",
"rating",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L365-L393 | train | |
sbyrnes/likely.js | likely.js | function(row)
{
var recommendedItems = new Array();
var allItems = this.rankAllItems(row);
var rowIndex = row; // assume row is a number
// If we're using labels we have to look up the row index
if(this.rowLabels)
{
rowIndex = findInArray(this.rowLabels, row);
}
for(var i=0; i< allItems.lengt... | javascript | function(row)
{
var recommendedItems = new Array();
var allItems = this.rankAllItems(row);
var rowIndex = row; // assume row is a number
// If we're using labels we have to look up the row index
if(this.rowLabels)
{
rowIndex = findInArray(this.rowLabels, row);
}
for(var i=0; i< allItems.lengt... | [
"function",
"(",
"row",
")",
"{",
"var",
"recommendedItems",
"=",
"new",
"Array",
"(",
")",
";",
"var",
"allItems",
"=",
"this",
".",
"rankAllItems",
"(",
"row",
")",
";",
"var",
"rowIndex",
"=",
"row",
";",
"// assume row is a number",
"// If we're using la... | Returns all items for the given row where there was no input value, sorted by rating.
@param row The row to return values for
@returns Array An array of arrays, each containing two entries. [0] is the index and [1] is the value, sorted by value. | [
"Returns",
"all",
"items",
"for",
"the",
"given",
"row",
"where",
"there",
"was",
"no",
"input",
"value",
"sorted",
"by",
"rating",
"."
] | 15077ae61b66eb6a61438cac8cb1dc9ec4edf558 | https://github.com/sbyrnes/likely.js/blob/15077ae61b66eb6a61438cac8cb1dc9ec4edf558/likely.js#L400-L432 | train | |
frictionlessdata/tableschema-js | src/table.js | createCsvDelimiterDetector | function createCsvDelimiterDetector(csvParser) {
const detector = PassThrough()
const sniffer = new CSVSniffer()
let done = false
detector.on('data', (chunk) => {
if (!done) {
const result = sniffer.sniff(chunk.toString())
csvParser.options.delimiter = result.delimiter
done = true
}
... | javascript | function createCsvDelimiterDetector(csvParser) {
const detector = PassThrough()
const sniffer = new CSVSniffer()
let done = false
detector.on('data', (chunk) => {
if (!done) {
const result = sniffer.sniff(chunk.toString())
csvParser.options.delimiter = result.delimiter
done = true
}
... | [
"function",
"createCsvDelimiterDetector",
"(",
"csvParser",
")",
"{",
"const",
"detector",
"=",
"PassThrough",
"(",
")",
"const",
"sniffer",
"=",
"new",
"CSVSniffer",
"(",
")",
"let",
"done",
"=",
"false",
"detector",
".",
"on",
"(",
"'data'",
",",
"(",
"c... | Detects the CSV delimiter, updating the received `csvParser` options.
It will use the first chunk to detect the CSV delimiter, and update it on
`csvParser.options.delimiter`. After this is finished, no further processing
will be done.
@param {module:csv/parse} csvParser - The csv.parse() instance
@return {module:stre... | [
"Detects",
"the",
"CSV",
"delimiter",
"updating",
"the",
"received",
"csvParser",
"options",
"."
] | fb088a6346315eda7cd51b1a9e3a57dd31cdf872 | https://github.com/frictionlessdata/tableschema-js/blob/fb088a6346315eda7cd51b1a9e3a57dd31cdf872/src/table.js#L330-L344 | train |
namics/gondel | packages/plugins/media-queries/dist/index.js | getComponentsInEventRegistry | function getComponentsInEventRegistry(eventRegistry, namespace) {
var selector = Object.keys(eventRegistry)
.map(function (componentName) { return "[data-" + namespace + "-name=\"" + componentName + "\"]"; })
.join(",");
if (!selector) {
return [];
}
var componentElements = docum... | javascript | function getComponentsInEventRegistry(eventRegistry, namespace) {
var selector = Object.keys(eventRegistry)
.map(function (componentName) { return "[data-" + namespace + "-name=\"" + componentName + "\"]"; })
.join(",");
if (!selector) {
return [];
}
var componentElements = docum... | [
"function",
"getComponentsInEventRegistry",
"(",
"eventRegistry",
",",
"namespace",
")",
"{",
"var",
"selector",
"=",
"Object",
".",
"keys",
"(",
"eventRegistry",
")",
".",
"map",
"(",
"function",
"(",
"componentName",
")",
"{",
"return",
"\"[data-\"",
"+",
"n... | This function returns all components for the given eventRegistry which can be found in the dom. | [
"This",
"function",
"returns",
"all",
"components",
"for",
"the",
"given",
"eventRegistry",
"which",
"can",
"be",
"found",
"in",
"the",
"dom",
"."
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/media-queries/dist/index.js#L13-L29 | train |
namics/gondel | packages/plugins/media-queries/dist/index.js | fireViewportChangeEvent | function fireViewportChangeEvent(viewport, eventRegistry, namespace) {
var components = getComponentsInEventRegistry(eventRegistry, namespace);
var handlerResults = [];
components.forEach(function (component) {
Object.keys(eventRegistry[component._componentName]).forEach(function (selector) {
... | javascript | function fireViewportChangeEvent(viewport, eventRegistry, namespace) {
var components = getComponentsInEventRegistry(eventRegistry, namespace);
var handlerResults = [];
components.forEach(function (component) {
Object.keys(eventRegistry[component._componentName]).forEach(function (selector) {
... | [
"function",
"fireViewportChangeEvent",
"(",
"viewport",
",",
"eventRegistry",
",",
"namespace",
")",
"{",
"var",
"components",
"=",
"getComponentsInEventRegistry",
"(",
"eventRegistry",
",",
"namespace",
")",
";",
"var",
"handlerResults",
"=",
"[",
"]",
";",
"comp... | This function fire's a custom gondel event to all registered components | [
"This",
"function",
"fire",
"s",
"a",
"custom",
"gondel",
"event",
"to",
"all",
"registered",
"components"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/media-queries/dist/index.js#L33-L50 | train |
namics/gondel | packages/plugins/media-queries/dist/index.js | convertBreakpointsToEm | function convertBreakpointsToEm(breakpointsInPx) {
var breakpointsInEm = {};
var breakpointNames = Object.keys(breakpointsInPx);
breakpointNames.forEach(function (breakpointName) {
breakpointsInEm[breakpointName] = px2em(breakpointsInPx[breakpointName]);
});
return breakpointsInEm;
} | javascript | function convertBreakpointsToEm(breakpointsInPx) {
var breakpointsInEm = {};
var breakpointNames = Object.keys(breakpointsInPx);
breakpointNames.forEach(function (breakpointName) {
breakpointsInEm[breakpointName] = px2em(breakpointsInPx[breakpointName]);
});
return breakpointsInEm;
} | [
"function",
"convertBreakpointsToEm",
"(",
"breakpointsInPx",
")",
"{",
"var",
"breakpointsInEm",
"=",
"{",
"}",
";",
"var",
"breakpointNames",
"=",
"Object",
".",
"keys",
"(",
"breakpointsInPx",
")",
";",
"breakpointNames",
".",
"forEach",
"(",
"function",
"(",... | Converts the given pixel breakpoint object into a em breakpoint object | [
"Converts",
"the",
"given",
"pixel",
"breakpoint",
"object",
"into",
"a",
"em",
"breakpoint",
"object"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/media-queries/dist/index.js#L60-L67 | train |
namics/gondel | packages/plugins/media-queries/dist/index.js | generateMediaQueries | function generateMediaQueries(breakPoints, unit) {
// Sort breakpoints by size
var breakpointNames = Object.keys(breakPoints).sort(function (breakpointNameA, breakpointNameB) {
if (breakPoints[breakpointNameA] > breakPoints[breakpointNameB]) {
return 1;
}
if (breakPoints[brea... | javascript | function generateMediaQueries(breakPoints, unit) {
// Sort breakpoints by size
var breakpointNames = Object.keys(breakPoints).sort(function (breakpointNameA, breakpointNameB) {
if (breakPoints[breakpointNameA] > breakPoints[breakpointNameB]) {
return 1;
}
if (breakPoints[brea... | [
"function",
"generateMediaQueries",
"(",
"breakPoints",
",",
"unit",
")",
"{",
"// Sort breakpoints by size",
"var",
"breakpointNames",
"=",
"Object",
".",
"keys",
"(",
"breakPoints",
")",
".",
"sort",
"(",
"function",
"(",
"breakpointNameA",
",",
"breakpointNameB",... | This function generate mediaQueries from breakPoints | [
"This",
"function",
"generate",
"mediaQueries",
"from",
"breakPoints"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/media-queries/dist/index.js#L77-L112 | train |
namics/gondel | packages/plugins/media-queries/dist/index.js | setupViewportChangeEvent | function setupViewportChangeEvent(mediaQueries, eventRegistry, namespace) {
var _loop_1 = function (viewport) {
matchMedia(viewport.query).addListener(function (mediaQueryList) {
if (mediaQueryList.matches) {
fireViewportChangeEvent(viewport.name, eventRegistry, namespace);
... | javascript | function setupViewportChangeEvent(mediaQueries, eventRegistry, namespace) {
var _loop_1 = function (viewport) {
matchMedia(viewport.query).addListener(function (mediaQueryList) {
if (mediaQueryList.matches) {
fireViewportChangeEvent(viewport.name, eventRegistry, namespace);
... | [
"function",
"setupViewportChangeEvent",
"(",
"mediaQueries",
",",
"eventRegistry",
",",
"namespace",
")",
"{",
"var",
"_loop_1",
"=",
"function",
"(",
"viewport",
")",
"{",
"matchMedia",
"(",
"viewport",
".",
"query",
")",
".",
"addListener",
"(",
"function",
... | Use enquire.js to listen for viewport changes
Once a viewport changed call all gondel plugins which are listening | [
"Use",
"enquire",
".",
"js",
"to",
"listen",
"for",
"viewport",
"changes",
"Once",
"a",
"viewport",
"changed",
"call",
"all",
"gondel",
"plugins",
"which",
"are",
"listening"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/media-queries/dist/index.js#L117-L129 | train |
namics/gondel | packages/plugins/media-queries/dist/index.js | setupCurrentViewportHelper | function setupCurrentViewportHelper(mediaQueries) {
var _loop_2 = function (viewport) {
var viewportMediaQueryList = matchMedia(viewport.query);
// Set initial viewport
if (viewportMediaQueryList.matches) {
currentViewport = viewport.name;
}
// Watch for media que... | javascript | function setupCurrentViewportHelper(mediaQueries) {
var _loop_2 = function (viewport) {
var viewportMediaQueryList = matchMedia(viewport.query);
// Set initial viewport
if (viewportMediaQueryList.matches) {
currentViewport = viewport.name;
}
// Watch for media que... | [
"function",
"setupCurrentViewportHelper",
"(",
"mediaQueries",
")",
"{",
"var",
"_loop_2",
"=",
"function",
"(",
"viewport",
")",
"{",
"var",
"viewportMediaQueryList",
"=",
"matchMedia",
"(",
"viewport",
".",
"query",
")",
";",
"// Set initial viewport",
"if",
"("... | Use enquire.js to listen for viewport changes
for the getCurrentViewport helper method | [
"Use",
"enquire",
".",
"js",
"to",
"listen",
"for",
"viewport",
"changes",
"for",
"the",
"getCurrentViewport",
"helper",
"method"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/media-queries/dist/index.js#L134-L152 | train |
namics/gondel | packages/plugins/resize/dist/index.js | startResizeWatching | function startResizeWatching(event) {
var components = getComponentsInEventRegistry(eventRegistry, namespace);
isRunning = true;
// The resize listener is fired very often
// for performance optimisations we search and store
// all components during the initial start event
... | javascript | function startResizeWatching(event) {
var components = getComponentsInEventRegistry(eventRegistry, namespace);
isRunning = true;
// The resize listener is fired very often
// for performance optimisations we search and store
// all components during the initial start event
... | [
"function",
"startResizeWatching",
"(",
"event",
")",
"{",
"var",
"components",
"=",
"getComponentsInEventRegistry",
"(",
"eventRegistry",
",",
"namespace",
")",
";",
"isRunning",
"=",
"true",
";",
"// The resize listener is fired very often",
"// for performance optimisati... | This handler is called if a new resize event happens.
A resize event is new if no resize occurred for 250ms | [
"This",
"handler",
"is",
"called",
"if",
"a",
"new",
"resize",
"event",
"happens",
".",
"A",
"resize",
"event",
"is",
"new",
"if",
"no",
"resize",
"occurred",
"for",
"250ms"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/resize/dist/index.js#L49-L72 | train |
namics/gondel | packages/plugins/resize/dist/index.js | fireComponentResizeEvent | function fireComponentResizeEvent(event) {
frameIsRequested = false;
if (!componentInformation) {
return;
}
var newSizes = componentInformation.map(function (_a) {
var node = _a.node;
return ({
width: node.clientWidth,
h... | javascript | function fireComponentResizeEvent(event) {
frameIsRequested = false;
if (!componentInformation) {
return;
}
var newSizes = componentInformation.map(function (_a) {
var node = _a.node;
return ({
width: node.clientWidth,
h... | [
"function",
"fireComponentResizeEvent",
"(",
"event",
")",
"{",
"frameIsRequested",
"=",
"false",
";",
"if",
"(",
"!",
"componentInformation",
")",
"{",
"return",
";",
"}",
"var",
"newSizes",
"=",
"componentInformation",
".",
"map",
"(",
"function",
"(",
"_a",... | Check which modules changed in size, are still running and call their event handler | [
"Check",
"which",
"modules",
"changed",
"in",
"size",
"are",
"still",
"running",
"and",
"call",
"their",
"event",
"handler"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/resize/dist/index.js#L90-L128 | train |
namics/gondel | packages/plugins/resize/dist/index.js | fireWindowResizeEvent | function fireWindowResizeEvent(event) {
frameIsRequested = false;
if (!componentInformation) {
return;
}
var handlerResults = [];
componentInformation.forEach(function (componentInformation, i) {
// Skip if the component is not running anymore
... | javascript | function fireWindowResizeEvent(event) {
frameIsRequested = false;
if (!componentInformation) {
return;
}
var handlerResults = [];
componentInformation.forEach(function (componentInformation, i) {
// Skip if the component is not running anymore
... | [
"function",
"fireWindowResizeEvent",
"(",
"event",
")",
"{",
"frameIsRequested",
"=",
"false",
";",
"if",
"(",
"!",
"componentInformation",
")",
"{",
"return",
";",
"}",
"var",
"handlerResults",
"=",
"[",
"]",
";",
"componentInformation",
".",
"forEach",
"(",
... | Check if the components are still running and call their event handler | [
"Check",
"if",
"the",
"components",
"are",
"still",
"running",
"and",
"call",
"their",
"event",
"handler"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/resize/dist/index.js#L132-L154 | train |
namics/gondel | packages/plugins/data/dist/DataDecorator.js | convertPropertyKeyToDataAttributeKey | function convertPropertyKeyToDataAttributeKey(propertyKey) {
if (propertyKey.substr(0, 1) === "_") {
propertyKey = propertyKey.substr(1);
}
if (propertyKey.substr(0, 4) !== "data") {
throw new Error(propertyKey + "\" has an invalid format please use @data dataSomeProp (data-some-prop) for va... | javascript | function convertPropertyKeyToDataAttributeKey(propertyKey) {
if (propertyKey.substr(0, 1) === "_") {
propertyKey = propertyKey.substr(1);
}
if (propertyKey.substr(0, 4) !== "data") {
throw new Error(propertyKey + "\" has an invalid format please use @data dataSomeProp (data-some-prop) for va... | [
"function",
"convertPropertyKeyToDataAttributeKey",
"(",
"propertyKey",
")",
"{",
"if",
"(",
"propertyKey",
".",
"substr",
"(",
"0",
",",
"1",
")",
"===",
"\"_\"",
")",
"{",
"propertyKey",
"=",
"propertyKey",
".",
"substr",
"(",
"1",
")",
";",
"}",
"if",
... | Will convert any possible property to a valid data attribute
@param {string} propertyKey the prop to convert | [
"Will",
"convert",
"any",
"possible",
"property",
"to",
"a",
"valid",
"data",
"attribute"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/plugins/data/dist/DataDecorator.js#L40-L48 | train |
namics/gondel | packages/core/dist/GondelEventRegistry.js | function (element, selector) {
var elementPrototype = window.Element.prototype;
/* istanbul ignore next : Browser polyfill can't be tested */
var elementMatches = elementPrototype.matches ||
elementPrototype.matchesSelector ||
elementPrototype.mozMatchesSelector ||
elementPrototype.m... | javascript | function (element, selector) {
var elementPrototype = window.Element.prototype;
/* istanbul ignore next : Browser polyfill can't be tested */
var elementMatches = elementPrototype.matches ||
elementPrototype.matchesSelector ||
elementPrototype.mozMatchesSelector ||
elementPrototype.m... | [
"function",
"(",
"element",
",",
"selector",
")",
"{",
"var",
"elementPrototype",
"=",
"window",
".",
"Element",
".",
"prototype",
";",
"/* istanbul ignore next : Browser polyfill can't be tested */",
"var",
"elementMatches",
"=",
"elementPrototype",
".",
"matches",
"||... | Polyfill for element.prototype.matches | [
"Polyfill",
"for",
"element",
".",
"prototype",
".",
"matches"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/core/dist/GondelEventRegistry.js#L16-L28 | train | |
namics/gondel | packages/core/dist/GondelEventRegistry.js | handleEvent | function handleEvent(namespace, attributeName, eventHandlerRegistry, event) {
var target = event.target;
var handlers = getHandlers(attributeName, eventHandlerRegistry, target);
executeHandlers(handlers, event, namespace);
} | javascript | function handleEvent(namespace, attributeName, eventHandlerRegistry, event) {
var target = event.target;
var handlers = getHandlers(attributeName, eventHandlerRegistry, target);
executeHandlers(handlers, event, namespace);
} | [
"function",
"handleEvent",
"(",
"namespace",
",",
"attributeName",
",",
"eventHandlerRegistry",
",",
"event",
")",
"{",
"var",
"target",
"=",
"event",
".",
"target",
";",
"var",
"handlers",
"=",
"getHandlers",
"(",
"attributeName",
",",
"eventHandlerRegistry",
"... | The handler which will catch every event at the documentElement | [
"The",
"handler",
"which",
"will",
"catch",
"every",
"event",
"at",
"the",
"documentElement"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/core/dist/GondelEventRegistry.js#L96-L100 | train |
namics/gondel | packages/core/dist/GondelComponentStarter.js | getNewComponents | function getNewComponents(components, registry) {
var componentNameHelper = {};
components.forEach(function (component) { return (componentNameHelper[component._componentName] = true); });
var componentNames = Object.keys(componentNameHelper);
return componentNames.filter(function (componentName) { retu... | javascript | function getNewComponents(components, registry) {
var componentNameHelper = {};
components.forEach(function (component) { return (componentNameHelper[component._componentName] = true); });
var componentNames = Object.keys(componentNameHelper);
return componentNames.filter(function (componentName) { retu... | [
"function",
"getNewComponents",
"(",
"components",
",",
"registry",
")",
"{",
"var",
"componentNameHelper",
"=",
"{",
"}",
";",
"components",
".",
"forEach",
"(",
"function",
"(",
"component",
")",
"{",
"return",
"(",
"componentNameHelper",
"[",
"component",
"... | Filters the given component list and returns the names of those components which have never been started before | [
"Filters",
"the",
"given",
"component",
"list",
"and",
"returns",
"the",
"names",
"of",
"those",
"components",
"which",
"have",
"never",
"been",
"started",
"before"
] | 34257f71f47b820e53a49ee22b4f96a0ede2ab05 | https://github.com/namics/gondel/blob/34257f71f47b820e53a49ee22b4f96a0ede2ab05/packages/core/dist/GondelComponentStarter.js#L128-L133 | train |
micro-analytics/micro-analytics-cli | packages/adapter-flat-file-db/index.js | getAll | async function getAll(options) {
const data = {};
const keys = filterPaths(await module.exports.keys(), options);
for (let key of keys) {
data[key] = await module.exports.get(key, {
before: options.before,
after: options.after,
});
}
await Promise.all(keys);
return... | javascript | async function getAll(options) {
const data = {};
const keys = filterPaths(await module.exports.keys(), options);
for (let key of keys) {
data[key] = await module.exports.get(key, {
before: options.before,
after: options.after,
});
}
await Promise.all(keys);
return... | [
"async",
"function",
"getAll",
"(",
"options",
")",
"{",
"const",
"data",
"=",
"{",
"}",
";",
"const",
"keys",
"=",
"filterPaths",
"(",
"await",
"module",
".",
"exports",
".",
"keys",
"(",
")",
",",
"options",
")",
";",
"for",
"(",
"let",
"key",
"o... | Get all values starting with a certain pathname and filter their views | [
"Get",
"all",
"values",
"starting",
"with",
"a",
"certain",
"pathname",
"and",
"filter",
"their",
"views"
] | 65a2f302747ad650fb1363b961e5a69552d631d1 | https://github.com/micro-analytics/micro-analytics-cli/blob/65a2f302747ad650fb1363b961e5a69552d631d1/packages/adapter-flat-file-db/index.js#L57-L71 | train |
multiformats/js-multiaddr | src/codec.js | bufferToString | function bufferToString (buf) {
const a = bufferToTuples(buf)
const b = tuplesToStringTuples(a)
return stringTuplesToString(b)
} | javascript | function bufferToString (buf) {
const a = bufferToTuples(buf)
const b = tuplesToStringTuples(a)
return stringTuplesToString(b)
} | [
"function",
"bufferToString",
"(",
"buf",
")",
"{",
"const",
"a",
"=",
"bufferToTuples",
"(",
"buf",
")",
"const",
"b",
"=",
"tuplesToStringTuples",
"(",
"a",
")",
"return",
"stringTuplesToString",
"(",
"b",
")",
"}"
] | Buffer -> String | [
"Buffer",
"-",
">",
"String"
] | 2bb0f1d80080942255d5c9a45d8bc552e0a9e232 | https://github.com/multiformats/js-multiaddr/blob/2bb0f1d80080942255d5c9a45d8bc552e0a9e232/src/codec.js#L171-L175 | train |
multiformats/js-multiaddr | src/codec.js | stringToBuffer | function stringToBuffer (str) {
str = cleanPath(str)
const a = stringToStringTuples(str)
const b = stringTuplesToTuples(a)
return tuplesToBuffer(b)
} | javascript | function stringToBuffer (str) {
str = cleanPath(str)
const a = stringToStringTuples(str)
const b = stringTuplesToTuples(a)
return tuplesToBuffer(b)
} | [
"function",
"stringToBuffer",
"(",
"str",
")",
"{",
"str",
"=",
"cleanPath",
"(",
"str",
")",
"const",
"a",
"=",
"stringToStringTuples",
"(",
"str",
")",
"const",
"b",
"=",
"stringTuplesToTuples",
"(",
"a",
")",
"return",
"tuplesToBuffer",
"(",
"b",
")",
... | String -> Buffer | [
"String",
"-",
">",
"Buffer"
] | 2bb0f1d80080942255d5c9a45d8bc552e0a9e232 | https://github.com/multiformats/js-multiaddr/blob/2bb0f1d80080942255d5c9a45d8bc552e0a9e232/src/codec.js#L178-L184 | train |
multiformats/js-multiaddr | src/codec.js | fromBuffer | function fromBuffer (buf) {
const err = validateBuffer(buf)
if (err) throw err
return Buffer.from(buf) // copy
} | javascript | function fromBuffer (buf) {
const err = validateBuffer(buf)
if (err) throw err
return Buffer.from(buf) // copy
} | [
"function",
"fromBuffer",
"(",
"buf",
")",
"{",
"const",
"err",
"=",
"validateBuffer",
"(",
"buf",
")",
"if",
"(",
"err",
")",
"throw",
"err",
"return",
"Buffer",
".",
"from",
"(",
"buf",
")",
"// copy",
"}"
] | Buffer -> Buffer | [
"Buffer",
"-",
">",
"Buffer"
] | 2bb0f1d80080942255d5c9a45d8bc552e0a9e232 | https://github.com/multiformats/js-multiaddr/blob/2bb0f1d80080942255d5c9a45d8bc552e0a9e232/src/codec.js#L192-L196 | train |
web-push-libs/encrypted-content-encoding | nodejs/ece.js | decrypt | function decrypt(buffer, params, keyLookupCallback) {
var header = parseParams(params);
if (header.version === 'aes128gcm') {
var headerLength = readHeader(buffer, header);
buffer = buffer.slice(headerLength);
}
var key = deriveKeyAndNonce(header, MODE_DECRYPT, keyLookupCallback);
var start = 0;
var... | javascript | function decrypt(buffer, params, keyLookupCallback) {
var header = parseParams(params);
if (header.version === 'aes128gcm') {
var headerLength = readHeader(buffer, header);
buffer = buffer.slice(headerLength);
}
var key = deriveKeyAndNonce(header, MODE_DECRYPT, keyLookupCallback);
var start = 0;
var... | [
"function",
"decrypt",
"(",
"buffer",
",",
"params",
",",
"keyLookupCallback",
")",
"{",
"var",
"header",
"=",
"parseParams",
"(",
"params",
")",
";",
"if",
"(",
"header",
".",
"version",
"===",
"'aes128gcm'",
")",
"{",
"var",
"headerLength",
"=",
"readHea... | Decrypt some bytes. This uses the parameters to determine the key and block
size, which are described in the draft. Binary values are base64url encoded.
|params.version| contains the version of encoding to use: aes128gcm is the latest,
but aesgcm is also accepted (though the latter might
disappear in a future releas... | [
"Decrypt",
"some",
"bytes",
".",
"This",
"uses",
"the",
"parameters",
"to",
"determine",
"the",
"key",
"and",
"block",
"size",
"which",
"are",
"described",
"in",
"the",
"draft",
".",
"Binary",
"values",
"are",
"base64url",
"encoded",
"."
] | 849aebea751752e17fc84a64ce1bbf65dc994e6c | https://github.com/web-push-libs/encrypted-content-encoding/blob/849aebea751752e17fc84a64ce1bbf65dc994e6c/nodejs/ece.js#L366-L396 | train |
web-push-libs/encrypted-content-encoding | nodejs/ece.js | encrypt | function encrypt(buffer, params, keyLookupCallback) {
if (!Buffer.isBuffer(buffer)) {
throw new Error('buffer argument must be a Buffer');
}
var header = parseParams(params);
if (!header.salt) {
header.salt = crypto.randomBytes(KEY_LENGTH);
}
var result;
if (header.version === 'aes128gcm') {
... | javascript | function encrypt(buffer, params, keyLookupCallback) {
if (!Buffer.isBuffer(buffer)) {
throw new Error('buffer argument must be a Buffer');
}
var header = parseParams(params);
if (!header.salt) {
header.salt = crypto.randomBytes(KEY_LENGTH);
}
var result;
if (header.version === 'aes128gcm') {
... | [
"function",
"encrypt",
"(",
"buffer",
",",
"params",
",",
"keyLookupCallback",
")",
"{",
"if",
"(",
"!",
"Buffer",
".",
"isBuffer",
"(",
"buffer",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'buffer argument must be a Buffer'",
")",
";",
"}",
"var",
"hea... | Encrypt some bytes. This uses the parameters to determine the key and block
size, which are described in the draft.
|params.version| contains the version of encoding to use: aes128gcm is the latest,
but aesgcm is also accepted (though the latter two might
disappear in a future release). If omitted, assume aes128gcm.... | [
"Encrypt",
"some",
"bytes",
".",
"This",
"uses",
"the",
"parameters",
"to",
"determine",
"the",
"key",
"and",
"block",
"size",
"which",
"are",
"described",
"in",
"the",
"draft",
"."
] | 849aebea751752e17fc84a64ce1bbf65dc994e6c | https://github.com/web-push-libs/encrypted-content-encoding/blob/849aebea751752e17fc84a64ce1bbf65dc994e6c/nodejs/ece.js#L459-L519 | train |
EnotionZ/gpio | lib/gpio.js | function(path, interval, fn) {
if(typeof fn === 'undefined') {
fn = interval;
interval = 100;
}
if(typeof interval !== 'number') return false;
if(typeof fn !== 'function') return false;
var value;
var readTimer = setInterval(function() {
_read(path, function(val) {
if(value !== val) {
if(typeof valu... | javascript | function(path, interval, fn) {
if(typeof fn === 'undefined') {
fn = interval;
interval = 100;
}
if(typeof interval !== 'number') return false;
if(typeof fn !== 'function') return false;
var value;
var readTimer = setInterval(function() {
_read(path, function(val) {
if(value !== val) {
if(typeof valu... | [
"function",
"(",
"path",
",",
"interval",
",",
"fn",
")",
"{",
"if",
"(",
"typeof",
"fn",
"===",
"'undefined'",
")",
"{",
"fn",
"=",
"interval",
";",
"interval",
"=",
"100",
";",
"}",
"if",
"(",
"typeof",
"interval",
"!==",
"'number'",
")",
"return",... | fs.watch doesn't get fired because the file never gets 'accessed' when setting header via hardware manually watching value changes | [
"fs",
".",
"watch",
"doesn",
"t",
"get",
"fired",
"because",
"the",
"file",
"never",
"gets",
"accessed",
"when",
"setting",
"header",
"via",
"hardware",
"manually",
"watching",
"value",
"changes"
] | 2336386afc7b1eeea5ef0317e75e10af2d2767ad | https://github.com/EnotionZ/gpio/blob/2336386afc7b1eeea5ef0317e75e10af2d2767ad/lib/gpio.js#L74-L93 | train | |
straker/livingcss | lib/parseComments.js | parse_description | function parse_description(str, data) {
if (data.errors && data.errors.length) { return null; }
var result = str.match(/^\s+([\s\S]+)?/);
if (result) {
return {
source: result[0],
data: {description: result[1] === undefined ? '' : result[1].replace(trimNewline... | javascript | function parse_description(str, data) {
if (data.errors && data.errors.length) { return null; }
var result = str.match(/^\s+([\s\S]+)?/);
if (result) {
return {
source: result[0],
data: {description: result[1] === undefined ? '' : result[1].replace(trimNewline... | [
"function",
"parse_description",
"(",
"str",
",",
"data",
")",
"{",
"if",
"(",
"data",
".",
"errors",
"&&",
"data",
".",
"errors",
".",
"length",
")",
"{",
"return",
"null",
";",
"}",
"var",
"result",
"=",
"str",
".",
"match",
"(",
"/",
"^\\s+([\\s\\... | remove any trailing and preceding newline characters. Modified from PARSERS.parse_description. @see https://github.com/yavorskiy/comment-parser/blob/master/parser.js | [
"remove",
"any",
"trailing",
"and",
"preceding",
"newline",
"characters",
".",
"Modified",
"from",
"PARSERS",
".",
"parse_description",
"."
] | d3722bb40c428be74127ed9993935781fff60e75 | https://github.com/straker/livingcss/blob/d3722bb40c428be74127ed9993935781fff60e75/lib/parseComments.js#L46-L59 | train |
straker/livingcss | lib/generate.js | generate | function generate(dest, template, context, options) {
options = options || {};
// find all root sections (sections with no parent) by removing all number
// indices but keeping the named indices
for (var i = 0; i < context.sections.length; ) {
if (context.sections[i].parent) {
context.sections.splice... | javascript | function generate(dest, template, context, options) {
options = options || {};
// find all root sections (sections with no parent) by removing all number
// indices but keeping the named indices
for (var i = 0; i < context.sections.length; ) {
if (context.sections[i].parent) {
context.sections.splice... | [
"function",
"generate",
"(",
"dest",
",",
"template",
",",
"context",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// find all root sections (sections with no parent) by removing all number",
"// indices but keeping the named indices",
"for",
... | Generate an HTML page.
@param {string} dest - Path of the file for the generated HTML.
@param {string} template - Handlebars template.
@param {object} context - Context to pass to handlebars.
@param {string} context.page - Name of the current page.
@param {object[]} context.pages - List of pages.
@param {object[]} con... | [
"Generate",
"an",
"HTML",
"page",
"."
] | d3722bb40c428be74127ed9993935781fff60e75 | https://github.com/straker/livingcss/blob/d3722bb40c428be74127ed9993935781fff60e75/lib/generate.js#L23-L95 | train |
straker/livingcss | lib/utils.js | globWithPromsie | function globWithPromsie(pattern) {
return new Promise((resolve, reject) => {
glob(pattern, function(err, files) {
if (err) {
reject(err);
}
if (files.length === 0) {
console.warn('pattern "' + pattern + '" does not match any file');
}
resolve(files);
});
});
... | javascript | function globWithPromsie(pattern) {
return new Promise((resolve, reject) => {
glob(pattern, function(err, files) {
if (err) {
reject(err);
}
if (files.length === 0) {
console.warn('pattern "' + pattern + '" does not match any file');
}
resolve(files);
});
});
... | [
"function",
"globWithPromsie",
"(",
"pattern",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"glob",
"(",
"pattern",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"if",
"(",
"err",
")",
"{",
"reject"... | Read a glob string and return a promise.
@param {string} pattern - Glob file pattern
@returns Promise | [
"Read",
"a",
"glob",
"string",
"and",
"return",
"a",
"promise",
"."
] | d3722bb40c428be74127ed9993935781fff60e75 | https://github.com/straker/livingcss/blob/d3722bb40c428be74127ed9993935781fff60e75/lib/utils.js#L32-L46 | train |
infinum/mobx-collection-store | dist/utils.js | getProp | function getProp(obj, key) {
var path = [].concat(key);
var val = obj;
for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
var pathKey = path_1[_i];
if (val[pathKey] === undefined) {
return undefined;
}
val = val[pathKey];
}
return val;
} | javascript | function getProp(obj, key) {
var path = [].concat(key);
var val = obj;
for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
var pathKey = path_1[_i];
if (val[pathKey] === undefined) {
return undefined;
}
val = val[pathKey];
}
return val;
} | [
"function",
"getProp",
"(",
"obj",
",",
"key",
")",
"{",
"var",
"path",
"=",
"[",
"]",
".",
"concat",
"(",
"key",
")",
";",
"var",
"val",
"=",
"obj",
";",
"for",
"(",
"var",
"_i",
"=",
"0",
",",
"path_1",
"=",
"path",
";",
"_i",
"<",
"path_1"... | Get the specific nested property
@export
@template T Type of the property value
@param {object} obj Source object
@param {(string|Array<string>)} key Key value
@returns {T} The nested property value | [
"Get",
"the",
"specific",
"nested",
"property"
] | 9a7d8320e29f037b54c76b445f0d9ffa78e7435e | https://github.com/infinum/mobx-collection-store/blob/9a7d8320e29f037b54c76b445f0d9ffa78e7435e/dist/utils.js#L40-L51 | train |
infinum/mobx-collection-store | dist/utils.js | setProp | function setProp(obj, key, value) {
var path = [].concat(key);
var lastKey = path.pop();
var val = obj;
for (var _i = 0, path_2 = path; _i < path_2.length; _i++) {
var pathKey = path_2[_i];
if (typeof val[pathKey] !== 'object') {
val[pathKey] = {};
}
val = val... | javascript | function setProp(obj, key, value) {
var path = [].concat(key);
var lastKey = path.pop();
var val = obj;
for (var _i = 0, path_2 = path; _i < path_2.length; _i++) {
var pathKey = path_2[_i];
if (typeof val[pathKey] !== 'object') {
val[pathKey] = {};
}
val = val... | [
"function",
"setProp",
"(",
"obj",
",",
"key",
",",
"value",
")",
"{",
"var",
"path",
"=",
"[",
"]",
".",
"concat",
"(",
"key",
")",
";",
"var",
"lastKey",
"=",
"path",
".",
"pop",
"(",
")",
";",
"var",
"val",
"=",
"obj",
";",
"for",
"(",
"va... | Set the specific nested property
@export
@param {object} obj Destination object
@param {(string|Array<string>)} key Key value
@param {value} any Value to be set | [
"Set",
"the",
"specific",
"nested",
"property"
] | 9a7d8320e29f037b54c76b445f0d9ffa78e7435e | https://github.com/infinum/mobx-collection-store/blob/9a7d8320e29f037b54c76b445f0d9ffa78e7435e/dist/utils.js#L61-L74 | train |
infinum/mobx-collection-store | dist/utils.js | matchModel | function matchModel(item, type, id) {
/* istanbul ignore next */
return getType(item) === type && getProp(item, item.static.idAttribute) === id;
} | javascript | function matchModel(item, type, id) {
/* istanbul ignore next */
return getType(item) === type && getProp(item, item.static.idAttribute) === id;
} | [
"function",
"matchModel",
"(",
"item",
",",
"type",
",",
"id",
")",
"{",
"/* istanbul ignore next */",
"return",
"getType",
"(",
"item",
")",
"===",
"type",
"&&",
"getProp",
"(",
"item",
",",
"item",
".",
"static",
".",
"idAttribute",
")",
"===",
"id",
"... | Match a model to defined parameters
@private
@param {IModel} item - Model that's beeing matched
@param {IType} type - Model type to match
@param {(string|number)} id - Model ID to match
@returns {boolean} True if the model matches the parameters
@memberOf Collection | [
"Match",
"a",
"model",
"to",
"defined",
"parameters"
] | 9a7d8320e29f037b54c76b445f0d9ffa78e7435e | https://github.com/infinum/mobx-collection-store/blob/9a7d8320e29f037b54c76b445f0d9ffa78e7435e/dist/utils.js#L87-L90 | train |
dfilatov/vow | lib/vow.js | function() {
var script = doc.createElement('script');
script.onreadystatechange = function() {
script.parentNode.removeChild(script);
script = script.onreadystatechange = null;
callFns();
};
... | javascript | function() {
var script = doc.createElement('script');
script.onreadystatechange = function() {
script.parentNode.removeChild(script);
script = script.onreadystatechange = null;
callFns();
};
... | [
"function",
"(",
")",
"{",
"var",
"script",
"=",
"doc",
".",
"createElement",
"(",
"'script'",
")",
";",
"script",
".",
"onreadystatechange",
"=",
"function",
"(",
")",
"{",
"script",
".",
"parentNode",
".",
"removeChild",
"(",
"script",
")",
";",
"scrip... | ie6-ie8 | [
"ie6",
"-",
"ie8"
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L84-L92 | train | |
dfilatov/vow | lib/vow.js | function(reason) {
if(this._promise.isResolved()) {
return;
}
if(vow.isPromise(reason)) {
reason = reason.then(function(val) {
var defer = vow.defer();
defer.reject(val);
return defer.promise();
});
... | javascript | function(reason) {
if(this._promise.isResolved()) {
return;
}
if(vow.isPromise(reason)) {
reason = reason.then(function(val) {
var defer = vow.defer();
defer.reject(val);
return defer.promise();
});
... | [
"function",
"(",
"reason",
")",
"{",
"if",
"(",
"this",
".",
"_promise",
".",
"isResolved",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"vow",
".",
"isPromise",
"(",
"reason",
")",
")",
"{",
"reason",
"=",
"reason",
".",
"then",
"(",
"func... | Rejects the corresponding promise with the given `reason`.
@param {*} reason
@example
```js
var defer = vow.defer(),
promise = defer.promise();
promise.fail(function(reason) {
// reason is "'something is wrong'" here
});
defer.reject('something is wrong');
``` | [
"Rejects",
"the",
"corresponding",
"promise",
"with",
"the",
"given",
"reason",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L229-L245 | train | |
dfilatov/vow | lib/vow.js | function(onFulfilled, onRejected, onProgress, ctx) {
this._shouldEmitUnhandledRejection = false;
var defer = new Deferred();
this._addCallbacks(defer, onFulfilled, onRejected, onProgress, ctx);
return defer.promise();
} | javascript | function(onFulfilled, onRejected, onProgress, ctx) {
this._shouldEmitUnhandledRejection = false;
var defer = new Deferred();
this._addCallbacks(defer, onFulfilled, onRejected, onProgress, ctx);
return defer.promise();
} | [
"function",
"(",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
",",
"ctx",
")",
"{",
"this",
".",
"_shouldEmitUnhandledRejection",
"=",
"false",
";",
"var",
"defer",
"=",
"new",
"Deferred",
"(",
")",
";",
"this",
".",
"_addCallbacks",
"(",
"defer",
... | Adds reactions to the promise.
@param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled
@param {Function} [onRejected] Callback that will be invoked with a provided reason after the promise has been rejected
@param {Function} [onProgress] Callback that wi... | [
"Adds",
"reactions",
"to",
"the",
"promise",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L392-L397 | train | |
dfilatov/vow | lib/vow.js | function(onFulfilled, onRejected, ctx) {
return this.then(
function(val) {
return onFulfilled.apply(this, val);
},
onRejected,
ctx);
} | javascript | function(onFulfilled, onRejected, ctx) {
return this.then(
function(val) {
return onFulfilled.apply(this, val);
},
onRejected,
ctx);
} | [
"function",
"(",
"onFulfilled",
",",
"onRejected",
",",
"ctx",
")",
"{",
"return",
"this",
".",
"then",
"(",
"function",
"(",
"val",
")",
"{",
"return",
"onFulfilled",
".",
"apply",
"(",
"this",
",",
"val",
")",
";",
"}",
",",
"onRejected",
",",
"ctx... | Like `promise.then`, but "spreads" the array into a variadic value handler.
It is useful with the `vow.all` and the `vow.allResolved` methods.
@param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled
@param {Function} [onRejected] Callback that will be in... | [
"Like",
"promise",
".",
"then",
"but",
"spreads",
"the",
"array",
"into",
"a",
"variadic",
"value",
"handler",
".",
"It",
"is",
"useful",
"with",
"the",
"vow",
".",
"all",
"and",
"the",
"vow",
".",
"allResolved",
"methods",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L489-L496 | train | |
dfilatov/vow | lib/vow.js | function(onFulfilled, onRejected, onProgress, ctx) {
this
.then(onFulfilled, onRejected, onProgress, ctx)
.fail(throwException);
} | javascript | function(onFulfilled, onRejected, onProgress, ctx) {
this
.then(onFulfilled, onRejected, onProgress, ctx)
.fail(throwException);
} | [
"function",
"(",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
",",
"ctx",
")",
"{",
"this",
".",
"then",
"(",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
",",
"ctx",
")",
".",
"fail",
"(",
"throwException",
")",
";",
"}"
] | Like `then`, but terminates a chain of promises.
If the promise has been rejected, this method throws it's "reason" as an exception in a future turn of the event loop.
@param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled
@param {Function} [onRejected]... | [
"Like",
"then",
"but",
"terminates",
"a",
"chain",
"of",
"promises",
".",
"If",
"the",
"promise",
"has",
"been",
"rejected",
"this",
"method",
"throws",
"it",
"s",
"reason",
"as",
"an",
"exception",
"in",
"a",
"future",
"turn",
"of",
"the",
"event",
"loo... | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L514-L518 | train | |
dfilatov/vow | lib/vow.js | function(delay) {
var timer,
promise = this.then(function(val) {
var defer = new Deferred();
timer = setTimeout(
function() {
defer.resolve(val);
},
delay);
return def... | javascript | function(delay) {
var timer,
promise = this.then(function(val) {
var defer = new Deferred();
timer = setTimeout(
function() {
defer.resolve(val);
},
delay);
return def... | [
"function",
"(",
"delay",
")",
"{",
"var",
"timer",
",",
"promise",
"=",
"this",
".",
"then",
"(",
"function",
"(",
"val",
")",
"{",
"var",
"defer",
"=",
"new",
"Deferred",
"(",
")",
";",
"timer",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
... | Returns a new promise that will be fulfilled in `delay` milliseconds if the promise is fulfilled,
or immediately rejected if the promise is rejected.
@param {Number} delay
@returns {vow:Promise} | [
"Returns",
"a",
"new",
"promise",
"that",
"will",
"be",
"fulfilled",
"in",
"delay",
"milliseconds",
"if",
"the",
"promise",
"is",
"fulfilled",
"or",
"immediately",
"rejected",
"if",
"the",
"promise",
"is",
"rejected",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L527-L545 | train | |
dfilatov/vow | lib/vow.js | function(timeout) {
var defer = new Deferred(),
timer = setTimeout(
function() {
defer.reject(new vow.TimedOutError('timed out'));
},
timeout);
this.then(
function(val) {
defer.resolve(val);
... | javascript | function(timeout) {
var defer = new Deferred(),
timer = setTimeout(
function() {
defer.reject(new vow.TimedOutError('timed out'));
},
timeout);
this.then(
function(val) {
defer.resolve(val);
... | [
"function",
"(",
"timeout",
")",
"{",
"var",
"defer",
"=",
"new",
"Deferred",
"(",
")",
",",
"timer",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"defer",
".",
"reject",
"(",
"new",
"vow",
".",
"TimedOutError",
"(",
"'timed out'",
")",
")",
";... | Returns a new promise that will be rejected in `timeout` milliseconds
if the promise is not resolved beforehand.
@param {Number} timeout
@returns {vow:Promise}
@example
```js
var defer = vow.defer(),
promiseWithTimeout1 = defer.promise().timeout(50),
promiseWithTimeout2 = defer.promise().timeout(200);
setTimeout(
fu... | [
"Returns",
"a",
"new",
"promise",
"that",
"will",
"be",
"rejected",
"in",
"timeout",
"milliseconds",
"if",
"the",
"promise",
"is",
"not",
"resolved",
"beforehand",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L575-L596 | train | |
dfilatov/vow | lib/vow.js | function(value, onFulfilled, onRejected, onProgress, ctx) {
return vow.cast(value).then(onFulfilled, onRejected, onProgress, ctx);
} | javascript | function(value, onFulfilled, onRejected, onProgress, ctx) {
return vow.cast(value).then(onFulfilled, onRejected, onProgress, ctx);
} | [
"function",
"(",
"value",
",",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
",",
"ctx",
")",
"{",
"return",
"vow",
".",
"cast",
"(",
"value",
")",
".",
"then",
"(",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
",",
"ctx",
")",
";",
"}"
... | Static equivalent to `promise.then`.
If `value` is not a promise, then `value` is treated as a fulfilled promise.
@param {*} value
@param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled
@param {Function} [onRejected] Callback that will be invoked with a... | [
"Static",
"equivalent",
"to",
"promise",
".",
"then",
".",
"If",
"value",
"is",
"not",
"a",
"promise",
"then",
"value",
"is",
"treated",
"as",
"a",
"fulfilled",
"promise",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L885-L887 | train | |
dfilatov/vow | lib/vow.js | function(value, onFulfilled, onRejected, ctx) {
return vow.when(value).spread(onFulfilled, onRejected, ctx);
} | javascript | function(value, onFulfilled, onRejected, ctx) {
return vow.when(value).spread(onFulfilled, onRejected, ctx);
} | [
"function",
"(",
"value",
",",
"onFulfilled",
",",
"onRejected",
",",
"ctx",
")",
"{",
"return",
"vow",
".",
"when",
"(",
"value",
")",
".",
"spread",
"(",
"onFulfilled",
",",
"onRejected",
",",
"ctx",
")",
";",
"}"
] | Static equivalent to `promise.spread`.
If `value` is not a promise, then `value` is treated as a fulfilled promise.
@param {*} value
@param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled
@param {Function} [onRejected] Callback that will be invoked with... | [
"Static",
"equivalent",
"to",
"promise",
".",
"spread",
".",
"If",
"value",
"is",
"not",
"a",
"promise",
"then",
"value",
"is",
"treated",
"as",
"a",
"fulfilled",
"promise",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L938-L940 | train | |
dfilatov/vow | lib/vow.js | function(value, onFulfilled, onRejected, onProgress, ctx) {
vow.when(value).done(onFulfilled, onRejected, onProgress, ctx);
} | javascript | function(value, onFulfilled, onRejected, onProgress, ctx) {
vow.when(value).done(onFulfilled, onRejected, onProgress, ctx);
} | [
"function",
"(",
"value",
",",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
",",
"ctx",
")",
"{",
"vow",
".",
"when",
"(",
"value",
")",
".",
"done",
"(",
"onFulfilled",
",",
"onRejected",
",",
"onProgress",
",",
"ctx",
")",
";",
"}"
] | Static equivalent to `promise.done`.
If `value` is not a promise, then `value` is treated as a fulfilled promise.
@param {*} value
@param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled
@param {Function} [onRejected] Callback that will be invoked with a... | [
"Static",
"equivalent",
"to",
"promise",
".",
"done",
".",
"If",
"value",
"is",
"not",
"a",
"promise",
"then",
"value",
"is",
"treated",
"as",
"a",
"fulfilled",
"promise",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L952-L954 | train | |
dfilatov/vow | lib/vow.js | function(fn, args) {
var len = Math.max(arguments.length - 1, 0),
callArgs;
if(len) { // optimization for V8
callArgs = Array(len);
var i = 0;
while(i < len) {
callArgs[i++] = arguments[i];
}
}
try {
... | javascript | function(fn, args) {
var len = Math.max(arguments.length - 1, 0),
callArgs;
if(len) { // optimization for V8
callArgs = Array(len);
var i = 0;
while(i < len) {
callArgs[i++] = arguments[i];
}
}
try {
... | [
"function",
"(",
"fn",
",",
"args",
")",
"{",
"var",
"len",
"=",
"Math",
".",
"max",
"(",
"arguments",
".",
"length",
"-",
"1",
",",
"0",
")",
",",
"callArgs",
";",
"if",
"(",
"len",
")",
"{",
"// optimization for V8",
"callArgs",
"=",
"Array",
"("... | Invokes the given function `fn` with arguments `args`
@param {Function} fn
@param {...*} [args]
@returns {vow:Promise}
@example
```js
var promise1 = vow.invoke(function(value) {
return value;
}, 'ok'),
promise2 = vow.invoke(function() {
throw Error();
});
promise1.isFulfilled(); // true
promise1.valueOf(); // 'ok'
p... | [
"Invokes",
"the",
"given",
"function",
"fn",
"with",
"arguments",
"args"
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L1097-L1116 | train | |
dfilatov/vow | lib/vow.js | function(iterable) {
var defer = new Deferred(),
isPromisesArray = isArray(iterable),
keys = isPromisesArray?
getArrayKeys(iterable) :
getObjectKeys(iterable),
len = keys.length,
res = isPromisesArray? [] : {};
if(!len) {
... | javascript | function(iterable) {
var defer = new Deferred(),
isPromisesArray = isArray(iterable),
keys = isPromisesArray?
getArrayKeys(iterable) :
getObjectKeys(iterable),
len = keys.length,
res = isPromisesArray? [] : {};
if(!len) {
... | [
"function",
"(",
"iterable",
")",
"{",
"var",
"defer",
"=",
"new",
"Deferred",
"(",
")",
",",
"isPromisesArray",
"=",
"isArray",
"(",
"iterable",
")",
",",
"keys",
"=",
"isPromisesArray",
"?",
"getArrayKeys",
"(",
"iterable",
")",
":",
"getObjectKeys",
"("... | Returns a promise, that will be fulfilled only after all the items in `iterable` are fulfilled.
If any of the `iterable` items gets rejected, the promise will be rejected.
@param {Array|Object} iterable
@returns {vow:Promise}
@example
with array:
```js
var defer1 = vow.defer(),
defer2 = vow.defer();
vow.all([defer1.... | [
"Returns",
"a",
"promise",
"that",
"will",
"be",
"fulfilled",
"only",
"after",
"all",
"the",
"items",
"in",
"iterable",
"are",
"fulfilled",
".",
"If",
"any",
"of",
"the",
"iterable",
"items",
"gets",
"rejected",
"the",
"promise",
"will",
"be",
"rejected",
... | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L1155-L1184 | train | |
dfilatov/vow | lib/vow.js | function(iterable) {
var defer = new Deferred(),
isPromisesArray = isArray(iterable),
keys = isPromisesArray?
getArrayKeys(iterable) :
getObjectKeys(iterable),
i = keys.length,
res = isPromisesArray? [] : {};
if(!i) {
... | javascript | function(iterable) {
var defer = new Deferred(),
isPromisesArray = isArray(iterable),
keys = isPromisesArray?
getArrayKeys(iterable) :
getObjectKeys(iterable),
i = keys.length,
res = isPromisesArray? [] : {};
if(!i) {
... | [
"function",
"(",
"iterable",
")",
"{",
"var",
"defer",
"=",
"new",
"Deferred",
"(",
")",
",",
"isPromisesArray",
"=",
"isArray",
"(",
"iterable",
")",
",",
"keys",
"=",
"isPromisesArray",
"?",
"getArrayKeys",
"(",
"iterable",
")",
":",
"getObjectKeys",
"("... | Returns a promise, that will be fulfilled only after all the items in `iterable` are resolved.
@param {Array|Object} iterable
@returns {vow:Promise}
@example
```js
var defer1 = vow.defer(),
defer2 = vow.defer();
vow.allResolved([defer1.promise(), defer2.promise()]).spread(function(promise1, promise2) {
promise1.isRe... | [
"Returns",
"a",
"promise",
"that",
"will",
"be",
"fulfilled",
"only",
"after",
"all",
"the",
"items",
"in",
"iterable",
"are",
"resolved",
"."
] | 5e0fb3596f52ec35f3889c888d3f01a7057a17b3 | https://github.com/dfilatov/vow/blob/5e0fb3596f52ec35f3889c888d3f01a7057a17b3/lib/vow.js#L1208-L1235 | train | |
bojand/lounge | lib/model.js | compilePlainObject | function compilePlainObject (schema, options) {
class PlainModelInstance extends PlainBaseModel {
constructor (data, options = {}) {
super(data, options, schema)
}
}
PlainModelInstance.schema = schema
// if the user wants to allow modifications
if (options.freeze !== false) {
Object.freeze... | javascript | function compilePlainObject (schema, options) {
class PlainModelInstance extends PlainBaseModel {
constructor (data, options = {}) {
super(data, options, schema)
}
}
PlainModelInstance.schema = schema
// if the user wants to allow modifications
if (options.freeze !== false) {
Object.freeze... | [
"function",
"compilePlainObject",
"(",
"schema",
",",
"options",
")",
"{",
"class",
"PlainModelInstance",
"extends",
"PlainBaseModel",
"{",
"constructor",
"(",
"data",
",",
"options",
"=",
"{",
"}",
")",
"{",
"super",
"(",
"data",
",",
"options",
",",
"schem... | Compiles a schema into a Model
@param schema
@param options
@returns {ObjectInstance}
@private | [
"Compiles",
"a",
"schema",
"into",
"a",
"Model"
] | c25b42b0a41546525adc81e617e57f76188322ce | https://github.com/bojand/lounge/blob/c25b42b0a41546525adc81e617e57f76188322ce/lib/model.js#L29-L44 | train |
nodeca/types | lib/types/sorted_list.js | get_sequence | function get_sequence(self, weight) {
if (undefined === self.__sequences__[weight]) {
self.__sequences__[weight] = [];
}
return self.__sequences__[weight];
} | javascript | function get_sequence(self, weight) {
if (undefined === self.__sequences__[weight]) {
self.__sequences__[weight] = [];
}
return self.__sequences__[weight];
} | [
"function",
"get_sequence",
"(",
"self",
",",
"weight",
")",
"{",
"if",
"(",
"undefined",
"===",
"self",
".",
"__sequences__",
"[",
"weight",
"]",
")",
"{",
"self",
".",
"__sequences__",
"[",
"weight",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"self",
... | returns sequence array for given weight | [
"returns",
"sequence",
"array",
"for",
"given",
"weight"
] | c85d3b680fbef7cb5dbdd33f05783bdddfe48c53 | https://github.com/nodeca/types/blob/c85d3b680fbef7cb5dbdd33f05783bdddfe48c53/lib/types/sorted_list.js#L31-L37 | train |
redco/goose-parser | lib/tools/wait.js | waitForEvaluate | async function waitForEvaluate(env, evalFunction, checkerFunction, breakerFunction, args, timeout, interval) {
args = args || [];
checkerFunction = checkerFunction || function(result) {
return !!result
};
timeout = timeout || 5000;
interval = interval || 10;
let timeoutId, intervalId;
... | javascript | async function waitForEvaluate(env, evalFunction, checkerFunction, breakerFunction, args, timeout, interval) {
args = args || [];
checkerFunction = checkerFunction || function(result) {
return !!result
};
timeout = timeout || 5000;
interval = interval || 10;
let timeoutId, intervalId;
... | [
"async",
"function",
"waitForEvaluate",
"(",
"env",
",",
"evalFunction",
",",
"checkerFunction",
",",
"breakerFunction",
",",
"args",
",",
"timeout",
",",
"interval",
")",
"{",
"args",
"=",
"args",
"||",
"[",
"]",
";",
"checkerFunction",
"=",
"checkerFunction"... | Wait until function evalFunction expected in checkerFunction result
@param {AbstractEnvironment} env
@param {Function} evalFunction
@param {Function} [checkerFunction]
@param {Function} [breakerFunction]
@param {Array} [args]
@param {number} [timeout]
@param {number} [interval]
@returns {Promise} | [
"Wait",
"until",
"function",
"evalFunction",
"expected",
"in",
"checkerFunction",
"result"
] | b18b184c5a7ce8adccec000578c48644d9307f11 | https://github.com/redco/goose-parser/blob/b18b184c5a7ce8adccec000578c48644d9307f11/lib/tools/wait.js#L12-L60 | train |
redco/goose-parser | lib/tools/wait.js | waitForEvent | async function waitForEvent(env, event, breakerFunction, timeout = 5000, interval = 10) {
const { type, urlPattern } = event;
let intervalId, timeoutId;
await new Promise((resolve, reject) => {
const callback = {
fn: ({ error }) => {
clearTimeout(timeoutId);
... | javascript | async function waitForEvent(env, event, breakerFunction, timeout = 5000, interval = 10) {
const { type, urlPattern } = event;
let intervalId, timeoutId;
await new Promise((resolve, reject) => {
const callback = {
fn: ({ error }) => {
clearTimeout(timeoutId);
... | [
"async",
"function",
"waitForEvent",
"(",
"env",
",",
"event",
",",
"breakerFunction",
",",
"timeout",
"=",
"5000",
",",
"interval",
"=",
"10",
")",
"{",
"const",
"{",
"type",
",",
"urlPattern",
"}",
"=",
"event",
";",
"let",
"intervalId",
",",
"timeoutI... | Wait until event happens
@param {ChromeEnvironment} env
@param {Object} event
@param {Function} [breakerFunction]
@param {number} [timeout]
@param {number} [interval]
@returns {Promise} | [
"Wait",
"until",
"event",
"happens"
] | b18b184c5a7ce8adccec000578c48644d9307f11 | https://github.com/redco/goose-parser/blob/b18b184c5a7ce8adccec000578c48644d9307f11/lib/tools/wait.js#L71-L109 | train |
mafintosh/hyperlog | lib/replicate.js | function () {
var write = function (node, enc, cb) {
node.value = encoder.encode(node.value, dag.valueEncoding)
stream.node(node, cb)
}
stream.emit('live')
pipe(dag.createReadStream({since: changes, live: true}), through.obj(write))
} | javascript | function () {
var write = function (node, enc, cb) {
node.value = encoder.encode(node.value, dag.valueEncoding)
stream.node(node, cb)
}
stream.emit('live')
pipe(dag.createReadStream({since: changes, live: true}), through.obj(write))
} | [
"function",
"(",
")",
"{",
"var",
"write",
"=",
"function",
"(",
"node",
",",
"enc",
",",
"cb",
")",
"{",
"node",
".",
"value",
"=",
"encoder",
".",
"encode",
"(",
"node",
".",
"value",
",",
"dag",
".",
"valueEncoding",
")",
"stream",
".",
"node",
... | For live replication. Reads live from the local hyperlog and continues to send new nodes to the other end. | [
"For",
"live",
"replication",
".",
"Reads",
"live",
"from",
"the",
"local",
"hyperlog",
"and",
"continues",
"to",
"send",
"new",
"nodes",
"to",
"the",
"other",
"end",
"."
] | df15dc61e913f5db6cf7a31c1c1d0da1d1580be9 | https://github.com/mafintosh/hyperlog/blob/df15dc61e913f5db6cf7a31c1c1d0da1d1580be9/lib/replicate.js#L81-L89 | train | |
mafintosh/hyperlog | lib/replicate.js | function (cb) {
if (done || !localSentWants || !localSentHeads || !remoteSentWants || !remoteSentHeads) return cb()
done = true
if (!live) return stream.finalize(cb)
sendChanges()
cb()
} | javascript | function (cb) {
if (done || !localSentWants || !localSentHeads || !remoteSentWants || !remoteSentHeads) return cb()
done = true
if (!live) return stream.finalize(cb)
sendChanges()
cb()
} | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"done",
"||",
"!",
"localSentWants",
"||",
"!",
"localSentHeads",
"||",
"!",
"remoteSentWants",
"||",
"!",
"remoteSentHeads",
")",
"return",
"cb",
"(",
")",
"done",
"=",
"true",
"if",
"(",
"!",
"live",
")",
... | Check if replication is finished. | [
"Check",
"if",
"replication",
"is",
"finished",
"."
] | df15dc61e913f5db6cf7a31c1c1d0da1d1580be9 | https://github.com/mafintosh/hyperlog/blob/df15dc61e913f5db6cf7a31c1c1d0da1d1580be9/lib/replicate.js#L92-L98 | train | |
mafintosh/hyperlog | lib/replicate.js | function (log, seq, cb) {
dag.logs.get(log, seq, function (err, entry) {
if (err && err.notFound) return cb()
if (err) return cb(err)
if (entry.change > changes) return cb() // ensure snapshot
entry.log = log
entry.seq = seq
var i = 0
var loop = function () {
if (... | javascript | function (log, seq, cb) {
dag.logs.get(log, seq, function (err, entry) {
if (err && err.notFound) return cb()
if (err) return cb(err)
if (entry.change > changes) return cb() // ensure snapshot
entry.log = log
entry.seq = seq
var i = 0
var loop = function () {
if (... | [
"function",
"(",
"log",
",",
"seq",
",",
"cb",
")",
"{",
"dag",
".",
"logs",
".",
"get",
"(",
"log",
",",
"seq",
",",
"function",
"(",
"err",
",",
"entry",
")",
"{",
"if",
"(",
"err",
"&&",
"err",
".",
"notFound",
")",
"return",
"cb",
"(",
")... | Send a specific entry in a specific log to the other side. If the node links to other nodes, inform the other side we have those, too. | [
"Send",
"a",
"specific",
"entry",
"in",
"a",
"specific",
"log",
"to",
"the",
"other",
"side",
".",
"If",
"the",
"node",
"links",
"to",
"other",
"nodes",
"inform",
"the",
"other",
"side",
"we",
"have",
"those",
"too",
"."
] | df15dc61e913f5db6cf7a31c1c1d0da1d1580be9 | https://github.com/mafintosh/hyperlog/blob/df15dc61e913f5db6cf7a31c1c1d0da1d1580be9/lib/replicate.js#L117-L135 | train | |
mafintosh/hyperlog | index.js | function (dag, node, logLinks, batch, opts, cb) {
if (opts.hash && node.key !== opts.hash) return cb(CHECKSUM_MISMATCH)
if (opts.seq && node.seq !== opts.seq) return cb(INVALID_LOG)
var log = {
change: node.change,
node: node.key,
links: logLinks
}
var onclone = function (clone) {
if (!opts.... | javascript | function (dag, node, logLinks, batch, opts, cb) {
if (opts.hash && node.key !== opts.hash) return cb(CHECKSUM_MISMATCH)
if (opts.seq && node.seq !== opts.seq) return cb(INVALID_LOG)
var log = {
change: node.change,
node: node.key,
links: logLinks
}
var onclone = function (clone) {
if (!opts.... | [
"function",
"(",
"dag",
",",
"node",
",",
"logLinks",
",",
"batch",
",",
"opts",
",",
"cb",
")",
"{",
"if",
"(",
"opts",
".",
"hash",
"&&",
"node",
".",
"key",
"!==",
"opts",
".",
"hash",
")",
"return",
"cb",
"(",
"CHECKSUM_MISMATCH",
")",
"if",
... | Adds a new hyperlog node to an existing array of leveldb batch insertions. This includes performing crypto signing and verification. Performs deduplication; returns the existing node if alreay present in the hyperlog. | [
"Adds",
"a",
"new",
"hyperlog",
"node",
"to",
"an",
"existing",
"array",
"of",
"leveldb",
"batch",
"insertions",
".",
"This",
"includes",
"performing",
"crypto",
"signing",
"and",
"verification",
".",
"Performs",
"deduplication",
";",
"returns",
"the",
"existing... | df15dc61e913f5db6cf7a31c1c1d0da1d1580be9 | https://github.com/mafintosh/hyperlog/blob/df15dc61e913f5db6cf7a31c1c1d0da1d1580be9/index.js#L152-L203 | train | |
mafintosh/hyperlog | index.js | function (dag, opts) {
var since = opts.since || 0
var limit = opts.limit || -1
var wait = null
var read = function (size, cb) {
if (dag.changes <= since) {
wait = cb
return
}
if (!limit) return cb(null, null)
dag.db.get(CHANGES + lexint.pack(since + 1, 'hex'), function (err, hash... | javascript | function (dag, opts) {
var since = opts.since || 0
var limit = opts.limit || -1
var wait = null
var read = function (size, cb) {
if (dag.changes <= since) {
wait = cb
return
}
if (!limit) return cb(null, null)
dag.db.get(CHANGES + lexint.pack(since + 1, 'hex'), function (err, hash... | [
"function",
"(",
"dag",
",",
"opts",
")",
"{",
"var",
"since",
"=",
"opts",
".",
"since",
"||",
"0",
"var",
"limit",
"=",
"opts",
".",
"limit",
"||",
"-",
"1",
"var",
"wait",
"=",
"null",
"var",
"read",
"=",
"function",
"(",
"size",
",",
"cb",
... | Produce a readable stream of all nodes added from this point onward, in topographic order. | [
"Produce",
"a",
"readable",
"stream",
"of",
"all",
"nodes",
"added",
"from",
"this",
"point",
"onward",
"in",
"topographic",
"order",
"."
] | df15dc61e913f5db6cf7a31c1c1d0da1d1580be9 | https://github.com/mafintosh/hyperlog/blob/df15dc61e913f5db6cf7a31c1c1d0da1d1580be9/index.js#L227-L268 | train | |
mafintosh/hyperlog | index.js | function (nodes, batchOps, done) {
self.db.batch(batchOps, function (err) {
if (err) {
nodes.forEach(rejectNode)
return done(err)
}
done(null, nodes)
})
} | javascript | function (nodes, batchOps, done) {
self.db.batch(batchOps, function (err) {
if (err) {
nodes.forEach(rejectNode)
return done(err)
}
done(null, nodes)
})
} | [
"function",
"(",
"nodes",
",",
"batchOps",
",",
"done",
")",
"{",
"self",
".",
"db",
".",
"batch",
"(",
"batchOps",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"nodes",
".",
"forEach",
"(",
"rejectNode",
")",
"return",
"done"... | 10. perform the leveldb batch op | [
"10",
".",
"perform",
"the",
"leveldb",
"batch",
"op"
] | df15dc61e913f5db6cf7a31c1c1d0da1d1580be9 | https://github.com/mafintosh/hyperlog/blob/df15dc61e913f5db6cf7a31c1c1d0da1d1580be9/index.js#L376-L384 | train | |
mafintosh/hyperlog | index.js | computeNodeBatchOp | function computeNodeBatchOp (node, done) {
var batch = []
var links = logLinks[node.key]
addBatchAndDedupe(self, node, links, batch, opts, function (err, newNode) {
if (err) return done(err)
newNode.value = encoder.decode(newNode.value, opts.valueEncoding || self.valueEncoding)
... | javascript | function computeNodeBatchOp (node, done) {
var batch = []
var links = logLinks[node.key]
addBatchAndDedupe(self, node, links, batch, opts, function (err, newNode) {
if (err) return done(err)
newNode.value = encoder.decode(newNode.value, opts.valueEncoding || self.valueEncoding)
... | [
"function",
"computeNodeBatchOp",
"(",
"node",
",",
"done",
")",
"{",
"var",
"batch",
"=",
"[",
"]",
"var",
"links",
"=",
"logLinks",
"[",
"node",
".",
"key",
"]",
"addBatchAndDedupe",
"(",
"self",
",",
"node",
",",
"links",
",",
"batch",
",",
"opts",
... | Create a new leveldb batch operation for this node. | [
"Create",
"a",
"new",
"leveldb",
"batch",
"operation",
"for",
"this",
"node",
"."
] | df15dc61e913f5db6cf7a31c1c1d0da1d1580be9 | https://github.com/mafintosh/hyperlog/blob/df15dc61e913f5db6cf7a31c1c1d0da1d1580be9/index.js#L535-L543 | train |
hay/stapes | stapes.js | function() {
var args = slice.call(arguments);
var object = args.shift();
for (var i = 0, l = args.length; i < l; i++) {
var props = args[i];
for (var key in props) {
object[key] = props[key];
}
}
... | javascript | function() {
var args = slice.call(arguments);
var object = args.shift();
for (var i = 0, l = args.length; i < l; i++) {
var props = args[i];
for (var key in props) {
object[key] = props[key];
}
}
... | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"object",
"=",
"args",
".",
"shift",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"args",
".",
"length",
";",
"i",
"<",... | Extend an object with more objects | [
"Extend",
"an",
"object",
"with",
"more",
"objects"
] | 4852e68192941a3dde75d335bc7243bebe6099a5 | https://github.com/hay/stapes/blob/4852e68192941a3dde75d335bc7243bebe6099a5/stapes.js#L209-L221 | train | |
hay/stapes | stapes.js | function() {
var args = slice.call(arguments);
args.unshift(this);
return _.extend.apply(this, args);
} | javascript | function() {
var args = slice.call(arguments);
args.unshift(this);
return _.extend.apply(this, args);
} | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"args",
".",
"unshift",
"(",
"this",
")",
";",
"return",
"_",
".",
"extend",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"}"
] | The same as extend, but uses the this value as the scope | [
"The",
"same",
"as",
"extend",
"but",
"uses",
"the",
"this",
"value",
"as",
"the",
"scope"
] | 4852e68192941a3dde75d335bc7243bebe6099a5 | https://github.com/hay/stapes/blob/4852e68192941a3dde75d335bc7243bebe6099a5/stapes.js#L224-L228 | train | |
Phrogz/svg-path-to-polygons | svg-path-to-polygons.js | compare | function compare(pathData,opts={}) {
var polys = svgPathToPolygons(pathData,opts);
var minX=Infinity, maxX=-Infinity, minY=Infinity, maxY=-Infinity;
polys.forEach(poly => {
poly.forEach(pt => {
if (pt[0]<minX) minX=pt[0];
if (pt[1]<minY) minY=pt[1];
if (pt[0]>maxX) maxX=pt[0];
if (pt[1]>maxY) maxY=pt[1... | javascript | function compare(pathData,opts={}) {
var polys = svgPathToPolygons(pathData,opts);
var minX=Infinity, maxX=-Infinity, minY=Infinity, maxY=-Infinity;
polys.forEach(poly => {
poly.forEach(pt => {
if (pt[0]<minX) minX=pt[0];
if (pt[1]<minY) minY=pt[1];
if (pt[0]>maxX) maxX=pt[0];
if (pt[1]>maxY) maxY=pt[1... | [
"function",
"compare",
"(",
"pathData",
",",
"opts",
"=",
"{",
"}",
")",
"{",
"var",
"polys",
"=",
"svgPathToPolygons",
"(",
"pathData",
",",
"opts",
")",
";",
"var",
"minX",
"=",
"Infinity",
",",
"maxX",
"=",
"-",
"Infinity",
",",
"minY",
"=",
"Infi... | OMG YOU FOUND THE SECRET UNDOCUMENTED FEATURE | [
"OMG",
"YOU",
"FOUND",
"THE",
"SECRET",
"UNDOCUMENTED",
"FEATURE"
] | 1b55802ee39022315759201f9a13a6d45cbc3942 | https://github.com/Phrogz/svg-path-to-polygons/blob/1b55802ee39022315759201f9a13a6d45cbc3942/svg-path-to-polygons.js#L94-L115 | train |
adamgruber/mochawesome-report-generator | lib/src/options.js | _getUserOption | function _getUserOption(userOptions, optToGet, isBool) {
const envVar = `MOCHAWESOME_${optToGet.toUpperCase()}`;
if (userOptions && typeof userOptions[optToGet] !== 'undefined') {
return (isBool && typeof userOptions[optToGet] === 'string')
? userOptions[optToGet] === 'true'
: userOptions[optToGet];... | javascript | function _getUserOption(userOptions, optToGet, isBool) {
const envVar = `MOCHAWESOME_${optToGet.toUpperCase()}`;
if (userOptions && typeof userOptions[optToGet] !== 'undefined') {
return (isBool && typeof userOptions[optToGet] === 'string')
? userOptions[optToGet] === 'true'
: userOptions[optToGet];... | [
"function",
"_getUserOption",
"(",
"userOptions",
",",
"optToGet",
",",
"isBool",
")",
"{",
"const",
"envVar",
"=",
"`",
"${",
"optToGet",
".",
"toUpperCase",
"(",
")",
"}",
"`",
";",
"if",
"(",
"userOptions",
"&&",
"typeof",
"userOptions",
"[",
"optToGet"... | Retrieve the value of a user supplied option.
Order of precedence
1. User-supplied option
2. Environment variable
@param {object} userOptions Options to parse through
@param {string} optToGet Option name
@param {boolean} isBool Treat option as Boolean
@return {string|boolean|undefined} Option value | [
"Retrieve",
"the",
"value",
"of",
"a",
"user",
"supplied",
"option",
".",
"Order",
"of",
"precedence",
"1",
".",
"User",
"-",
"supplied",
"option",
"2",
".",
"Environment",
"variable"
] | 186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8 | https://github.com/adamgruber/mochawesome-report-generator/blob/186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8/lib/src/options.js#L167-L180 | train |
adamgruber/mochawesome-report-generator | lib/src/main.js | saveFile | function saveFile(filename, data, overwrite) {
if (overwrite) {
return fs.outputFile(filename, data)
.then(() => filename);
} else {
return new Promise((resolve, reject) => {
fsu.writeFileUnique(
filename.replace(fileExtRegex, '{_###}$&'),
data,
{ force: true },
(... | javascript | function saveFile(filename, data, overwrite) {
if (overwrite) {
return fs.outputFile(filename, data)
.then(() => filename);
} else {
return new Promise((resolve, reject) => {
fsu.writeFileUnique(
filename.replace(fileExtRegex, '{_###}$&'),
data,
{ force: true },
(... | [
"function",
"saveFile",
"(",
"filename",
",",
"data",
",",
"overwrite",
")",
"{",
"if",
"(",
"overwrite",
")",
"{",
"return",
"fs",
".",
"outputFile",
"(",
"filename",
",",
"data",
")",
".",
"then",
"(",
"(",
")",
"=>",
"filename",
")",
";",
"}",
"... | Saves a file
@param {string} filename Name of file to save
@param {string} data Data to be saved
@param {boolean} overwrite Overwrite existing files (default: true)
@return {Promise} Resolves with filename if successfully saved | [
"Saves",
"a",
"file"
] | 186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8 | https://github.com/adamgruber/mochawesome-report-generator/blob/186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8/lib/src/main.js#L24-L38 | train |
adamgruber/mochawesome-report-generator | lib/src/main.js | openFile | function openFile(filename) {
return new Promise((resolve, reject) => {
opener(filename, null, err => err === null ? resolve(filename) : reject(err));
});
} | javascript | function openFile(filename) {
return new Promise((resolve, reject) => {
opener(filename, null, err => err === null ? resolve(filename) : reject(err));
});
} | [
"function",
"openFile",
"(",
"filename",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"opener",
"(",
"filename",
",",
"null",
",",
"err",
"=>",
"err",
"===",
"null",
"?",
"resolve",
"(",
"filename",
")",
"... | Opens a file
@param {string} filename Name of file to open
@return {Promise} Resolves with filename if successfully opened | [
"Opens",
"a",
"file"
] | 186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8 | https://github.com/adamgruber/mochawesome-report-generator/blob/186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8/lib/src/main.js#L47-L51 | train |
adamgruber/mochawesome-report-generator | lib/src/main.js | getOptions | function getOptions(opts) {
const mergedOptions = getMergedOptions(opts || {});
// For saving JSON from mochawesome reporter
if (mergedOptions.saveJson) {
mergedOptions.jsonFile = `${getFilename(mergedOptions)}.json`;
}
mergedOptions.htmlFile = `${getFilename(mergedOptions)}.html`;
return mergedOption... | javascript | function getOptions(opts) {
const mergedOptions = getMergedOptions(opts || {});
// For saving JSON from mochawesome reporter
if (mergedOptions.saveJson) {
mergedOptions.jsonFile = `${getFilename(mergedOptions)}.json`;
}
mergedOptions.htmlFile = `${getFilename(mergedOptions)}.html`;
return mergedOption... | [
"function",
"getOptions",
"(",
"opts",
")",
"{",
"const",
"mergedOptions",
"=",
"getMergedOptions",
"(",
"opts",
"||",
"{",
"}",
")",
";",
"// For saving JSON from mochawesome reporter",
"if",
"(",
"mergedOptions",
".",
"saveJson",
")",
"{",
"mergedOptions",
".",
... | Get report options by extending base options
with user provided options
@param {Object} opts Report options
@return {Object} User options merged with default options | [
"Get",
"report",
"options",
"by",
"extending",
"base",
"options",
"with",
"user",
"provided",
"options"
] | 186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8 | https://github.com/adamgruber/mochawesome-report-generator/blob/186a31a0dc15d1a81f88ed3afd37bb7010f4c8b8/lib/src/main.js#L116-L126 | 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.