_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q49500 | train | function(libraries) {
var deferred = null,
promiseWrapper = null,
$ = null;
promiseWrapper = new this.Deferred();
if (mixitup.features.has.promises) {
// ES6 native promise or polyfill
promiseWrappe... | javascript | {
"resource": ""
} | |
q49501 | train | function(obj, stringKey) {
var parts = stringKey.split('.'),
returnCurrent = null,
current = '',
i = 0;
if (!stringKey) {
return obj;
}
returnCurrent = function(obj) {
... | javascript | {
"resource": ""
} | |
q49502 | train | 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 | {
"resource": ""
} | |
q49503 | train | 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 | {
"resource": ""
} | |
q49504 | train | 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 | {
"resource": ""
} | |
q49505 | train | function() {
var self = this,
target = null,
el = null,
dataset = null,
i = -1;
self.callActions('beforeIndexTargets', arguments);
self.dom.targets = self.config.l... | javascript | {
"resource": ""
} | |
q49506 | train | function() {
var self = this,
delineator = self.config.controls.toggleLogic === 'or' ? ', ' : '',
toggleSelector = '';
self.callActions('beforeGetToggleSelector', arguments);
self.toggleArray = h.clean(self.toggleArray);
... | javascript | {
"resource": ""
} | |
q49507 | train | function(command, state) {
var self = this,
activeFilterSelector = '';
self.callActions('beforeBuildToggleArray', arguments);
if (command && command.filter) {
activeFilterSelector = command.filter.selector.replace(/\s/g, '');
... | javascript | {
"resource": ""
} | |
q49508 | train | 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 | {
"resource": ""
} | |
q49509 | train | 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 | {
"resource": ""
} | |
q49510 | train | 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 | {
"resource": ""
} | |
q49511 | train | 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 | {
"resource": ""
} | |
q49512 | train | function() {
var self = this,
instruction = self.parseFilterArgs(arguments);
return self.multimix({
filter: instruction.command
}, instruction.animate, instruction.callback);
} | javascript | {
"resource": ""
} | |
q49513 | train | function() {
var self = this,
instruction = self.parseFilterArgs(arguments),
selector = instruction.command.selector,
toggleSelector = '';
self.isToggling = true;
if (self.toggleArray.indexOf(selector) < 0) {
... | javascript | {
"resource": ""
} | |
q49514 | train | function() {
var self = this,
instruction = self.parseSortArgs(arguments);
return self.multimix({
sort: instruction.command
}, instruction.animate, instruction.callback);
} | javascript | {
"resource": ""
} | |
q49515 | train | function() {
var self = this,
instruction = self.parseChangeLayoutArgs(arguments);
return self.multimix({
changeLayout: instruction.command
}, instruction.animate, instruction.callback);
} | javascript | {
"resource": ""
} | |
q49516 | train | function() {
var self = this,
instruction = self.parseDatasetArgs(arguments),
operation = null,
queueItem = null,
animate = false;
self.callActions('beforeDataset', arguments);
if (!self.isBusy) {
... | javascript | {
"resource": ""
} | |
q49517 | train | function() {
var self = this,
operation = null,
animate = false,
queueItem = null,
instruction = self.parseMultimixArgs(arguments);
self.callActions('beforeMultimix', arguments);
if (!self.isBusy) {
... | javascript | {
"resource": ""
} | |
q49518 | train | 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 | {
"resource": ""
} | |
q49519 | train | function() {
var self = this,
args = self.parseInsertArgs(arguments);
return self.multimix({
insert: args.command
}, args.animate, args.callback);
} | javascript | {
"resource": ""
} | |
q49520 | train | function() {
var self = this,
args = self.parseRemoveArgs(arguments);
return self.multimix({
remove: args.command
}, args.animate, args.callback);
} | javascript | {
"resource": ""
} | |
q49521 | train | 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 | {
"resource": ""
} | |
q49522 | train | function(config) {
var self = this;
self.callActions('beforeConfigure', arguments);
h.extend(self.config, config, true, true);
self.callActions('afterConfigure', arguments);
} | javascript | {
"resource": ""
} | |
q49523 | train | 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 | {
"resource": ""
} | |
q49524 | train | 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 | {
"resource": ""
} | |
q49525 | train | 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 | {
"resource": ""
} | |
q49526 | train | 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 | {
"resource": ""
} | |
q49527 | train | function(el) {
var self = this;
self.callActions('beforeCacheDom', arguments);
self.dom.el = el;
self.callActions('afterCacheDom', arguments);
} | javascript | {
"resource": ""
} | |
q49528 | train | function(moveData) {
var self = this,
posIn = moveData.posIn,
isFading = self.mixer.effectsIn.opacity !== 1,
transformValues = [];
self.callActions('beforeApplyStylesIn', arguments);
transformValues.push('t... | javascript | {
"resource": ""
} | |
q49529 | train | 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 | {
"resource": ""
} | |
q49530 | train | function(methodName) {
var self = this,
instance = null,
args = Array.prototype.slice.call(arguments),
tasks = [],
i = -1;
this.callActions('beforeMixitup');
args.shift();
... | javascript | {
"resource": ""
} | |
q49531 | buildModelWithBias | train | 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 | {
"resource": ""
} |
q49532 | train | 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 | {
"resource": ""
} |
q49533 | calculateError | train | 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 | {
"resource": ""
} |
q49534 | calculateTotalError | train | 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 | {
"resource": ""
} |
q49535 | calculateBias | train | 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 | {
"resource": ""
} |
q49536 | Bias | train | 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 | {
"resource": ""
} |
q49537 | calculateMatrixAverage | train | 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 | {
"resource": ""
} |
q49538 | calculateColumnAverage | train | 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 | {
"resource": ""
} |
q49539 | Model | train | 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 | {
"resource": ""
} |
q49540 | train | 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 | {
"resource": ""
} | |
q49541 | train | 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 | {
"resource": ""
} | |
q49542 | createCsvDelimiterDetector | train | 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 | {
"resource": ""
} |
q49543 | getComponentsInEventRegistry | train | 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 | {
"resource": ""
} |
q49544 | fireViewportChangeEvent | train | 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 | {
"resource": ""
} |
q49545 | convertBreakpointsToEm | train | function convertBreakpointsToEm(breakpointsInPx) {
var breakpointsInEm = {};
var breakpointNames = Object.keys(breakpointsInPx);
breakpointNames.forEach(function (breakpointName) {
breakpointsInEm[breakpointName] = px2em(breakpointsInPx[breakpointName]);
});
return breakpointsInEm;
} | javascript | {
"resource": ""
} |
q49546 | generateMediaQueries | train | 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 | {
"resource": ""
} |
q49547 | setupViewportChangeEvent | train | 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 | {
"resource": ""
} |
q49548 | setupCurrentViewportHelper | train | 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 | {
"resource": ""
} |
q49549 | startResizeWatching | train | 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 | {
"resource": ""
} |
q49550 | fireComponentResizeEvent | train | function fireComponentResizeEvent(event) {
frameIsRequested = false;
if (!componentInformation) {
return;
}
var newSizes = componentInformation.map(function (_a) {
var node = _a.node;
return ({
width: node.clientWidth,
h... | javascript | {
"resource": ""
} |
q49551 | fireWindowResizeEvent | train | function fireWindowResizeEvent(event) {
frameIsRequested = false;
if (!componentInformation) {
return;
}
var handlerResults = [];
componentInformation.forEach(function (componentInformation, i) {
// Skip if the component is not running anymore
... | javascript | {
"resource": ""
} |
q49552 | convertPropertyKeyToDataAttributeKey | train | 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 | {
"resource": ""
} |
q49553 | train | 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 | {
"resource": ""
} | |
q49554 | handleEvent | train | function handleEvent(namespace, attributeName, eventHandlerRegistry, event) {
var target = event.target;
var handlers = getHandlers(attributeName, eventHandlerRegistry, target);
executeHandlers(handlers, event, namespace);
} | javascript | {
"resource": ""
} |
q49555 | getNewComponents | train | 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 | {
"resource": ""
} |
q49556 | getAll | train | 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 | {
"resource": ""
} |
q49557 | bufferToString | train | function bufferToString (buf) {
const a = bufferToTuples(buf)
const b = tuplesToStringTuples(a)
return stringTuplesToString(b)
} | javascript | {
"resource": ""
} |
q49558 | stringToBuffer | train | function stringToBuffer (str) {
str = cleanPath(str)
const a = stringToStringTuples(str)
const b = stringTuplesToTuples(a)
return tuplesToBuffer(b)
} | javascript | {
"resource": ""
} |
q49559 | fromBuffer | train | function fromBuffer (buf) {
const err = validateBuffer(buf)
if (err) throw err
return Buffer.from(buf) // copy
} | javascript | {
"resource": ""
} |
q49560 | decrypt | train | 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 | {
"resource": ""
} |
q49561 | encrypt | train | 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 | {
"resource": ""
} |
q49562 | train | 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 | {
"resource": ""
} | |
q49563 | parse_description | train | 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 | {
"resource": ""
} |
q49564 | generate | train | 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 | {
"resource": ""
} |
q49565 | globWithPromsie | train | 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 | {
"resource": ""
} |
q49566 | getProp | train | 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 | {
"resource": ""
} |
q49567 | setProp | train | 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 | {
"resource": ""
} |
q49568 | matchModel | train | function matchModel(item, type, id) {
/* istanbul ignore next */
return getType(item) === type && getProp(item, item.static.idAttribute) === id;
} | javascript | {
"resource": ""
} |
q49569 | train | function() {
var script = doc.createElement('script');
script.onreadystatechange = function() {
script.parentNode.removeChild(script);
script = script.onreadystatechange = null;
callFns();
};
... | javascript | {
"resource": ""
} | |
q49570 | train | 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 | {
"resource": ""
} | |
q49571 | train | function(onFulfilled, onRejected, onProgress, ctx) {
this._shouldEmitUnhandledRejection = false;
var defer = new Deferred();
this._addCallbacks(defer, onFulfilled, onRejected, onProgress, ctx);
return defer.promise();
} | javascript | {
"resource": ""
} | |
q49572 | train | function(onFulfilled, onRejected, ctx) {
return this.then(
function(val) {
return onFulfilled.apply(this, val);
},
onRejected,
ctx);
} | javascript | {
"resource": ""
} | |
q49573 | train | function(onFulfilled, onRejected, onProgress, ctx) {
this
.then(onFulfilled, onRejected, onProgress, ctx)
.fail(throwException);
} | javascript | {
"resource": ""
} | |
q49574 | train | function(delay) {
var timer,
promise = this.then(function(val) {
var defer = new Deferred();
timer = setTimeout(
function() {
defer.resolve(val);
},
delay);
return def... | javascript | {
"resource": ""
} | |
q49575 | train | 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 | {
"resource": ""
} | |
q49576 | train | function(value, onFulfilled, onRejected, onProgress, ctx) {
return vow.cast(value).then(onFulfilled, onRejected, onProgress, ctx);
} | javascript | {
"resource": ""
} | |
q49577 | train | function(value, onFulfilled, onRejected, ctx) {
return vow.when(value).spread(onFulfilled, onRejected, ctx);
} | javascript | {
"resource": ""
} | |
q49578 | train | function(value, onFulfilled, onRejected, onProgress, ctx) {
vow.when(value).done(onFulfilled, onRejected, onProgress, ctx);
} | javascript | {
"resource": ""
} | |
q49579 | train | 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 | {
"resource": ""
} | |
q49580 | train | function(iterable) {
var defer = new Deferred(),
isPromisesArray = isArray(iterable),
keys = isPromisesArray?
getArrayKeys(iterable) :
getObjectKeys(iterable),
len = keys.length,
res = isPromisesArray? [] : {};
if(!len) {
... | javascript | {
"resource": ""
} | |
q49581 | train | function(iterable) {
var defer = new Deferred(),
isPromisesArray = isArray(iterable),
keys = isPromisesArray?
getArrayKeys(iterable) :
getObjectKeys(iterable),
i = keys.length,
res = isPromisesArray? [] : {};
if(!i) {
... | javascript | {
"resource": ""
} | |
q49582 | compilePlainObject | train | 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 | {
"resource": ""
} |
q49583 | get_sequence | train | function get_sequence(self, weight) {
if (undefined === self.__sequences__[weight]) {
self.__sequences__[weight] = [];
}
return self.__sequences__[weight];
} | javascript | {
"resource": ""
} |
q49584 | waitForEvaluate | train | 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 | {
"resource": ""
} |
q49585 | waitForEvent | train | 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 | {
"resource": ""
} |
q49586 | train | 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 | {
"resource": ""
} | |
q49587 | train | function (cb) {
if (done || !localSentWants || !localSentHeads || !remoteSentWants || !remoteSentHeads) return cb()
done = true
if (!live) return stream.finalize(cb)
sendChanges()
cb()
} | javascript | {
"resource": ""
} | |
q49588 | train | 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 | {
"resource": ""
} | |
q49589 | train | 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 | {
"resource": ""
} | |
q49590 | train | 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 | {
"resource": ""
} | |
q49591 | train | function (nodes, batchOps, done) {
self.db.batch(batchOps, function (err) {
if (err) {
nodes.forEach(rejectNode)
return done(err)
}
done(null, nodes)
})
} | javascript | {
"resource": ""
} | |
q49592 | computeNodeBatchOp | train | 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 | {
"resource": ""
} |
q49593 | train | 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 | {
"resource": ""
} | |
q49594 | train | function() {
var args = slice.call(arguments);
args.unshift(this);
return _.extend.apply(this, args);
} | javascript | {
"resource": ""
} | |
q49595 | compare | train | 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 | {
"resource": ""
} |
q49596 | _getUserOption | train | 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 | {
"resource": ""
} |
q49597 | saveFile | train | 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 | {
"resource": ""
} |
q49598 | openFile | train | function openFile(filename) {
return new Promise((resolve, reject) => {
opener(filename, null, err => err === null ? resolve(filename) : reject(err));
});
} | javascript | {
"resource": ""
} |
q49599 | getOptions | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.