_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q60300 | validation | function (next) {
var options = {
type: ctx.type,
count: ctx.count,
now: ctx.now,
nowISOString: ctx.nowISOString,
params: {
pk: Model.getIdName(),
id: ctx.params.id,
relation: ctx.params.relation,
custom: ctx.param... | javascript | {
"resource": ""
} | |
q60301 | validation | function (query, next) {
switch (ctx.type) {
case 'model':
Model.find(query, next);
break;
case 'relation':
Model.findOne(query, function (err, instance) {
if (err) return next(err);
var builder = new _queryBuilder2.default({
... | javascript | {
"resource": ""
} | |
q60302 | validation | function(sourceFileName, code) {
// If we're processing a block of code,
// let's try to find a class name in the block to specify the sourceFileName
var re = /class\s?([^\s]+)(\s?{|\s.*)|\s([^\s]+)\s?=\s?class/;
var m = re.exec(code);
return (sourceFileName || "") + (m && m[1] || nonce());
} | javascript | {
"resource": ""
} | |
q60303 | validation | function(options, code) {
var rst = JSON.parse(JSON.stringify(options)); // Let's clone options
// In the case were source maps are activated, we need to make some verifications
if (rst.sourceMaps) {
// 1. If we're processing a block of code, we need to ensure that the block will have a specific ... | javascript | {
"resource": ""
} | |
q60304 | get | validation | function get(self, steamObj, key) {
steamObj = steamObj || {};
if (steamObj[key] !== undefined) {
return steamObj[key];
}
else if (self[key] !== undefined) {
return self[key];
}
else if (Steam[key] !== undefined) {
return Steam[key];
}
else {
throw new Err... | javascript | {
"resource": ""
} |
q60305 | request | validation | function request(self, options, callback) {
var _http = get(self, options, 'secure')? https : http;
if (Steam.devMode) console.log(options);
var req = _http.request(options, function(res) {
var data, dataStr = '';
res.on('data', function (chunk) {
dataStr += chunk;
});... | javascript | {
"resource": ""
} |
q60306 | getParams | validation | function getParams(self, steamObj, requiredParams, optionalParams) {
// Required params will throw exception if they don't exist
var paramObj = {};
for (var i = 0, len = requiredParams.length; i < len; i++) {
var paramName = requiredParams[i];
// Support array arguments
paramName = ... | javascript | {
"resource": ""
} |
q60307 | addInterfaceMethod | validation | function addInterfaceMethod(interfaceName, funcName, fN) {
// Store a reference to every interface/method
if (Steam.INTERFACES[interfaceName] === undefined) {
Steam.INTERFACES[interfaceName] = {};
}
Steam.INTERFACES[interfaceName][funcName] = fN;
// Camel case the method name
var name ... | javascript | {
"resource": ""
} |
q60308 | buildSteamWrapperMethod | validation | function buildSteamWrapperMethod(interfaceName, funcName, defaultVersion, httpMethod, requiredParams, optionalParams) {
// Always include the key and language fields, if available
// GetSupportedAPIList doesn't always list them.
optionalParams.push('key');
optionalParams.push('language');
// Requi... | javascript | {
"resource": ""
} |
q60309 | retrieveSteamAPIMethods | validation | function retrieveSteamAPIMethods(key, callback) {
var _steam = new Steam();
_steam.getSupportedAPIList({key:key}, function(err, data) {
if (err) return callback(err);
var apiList = data.apilist;
if (apiList === undefined) return callback(new Error('No data returned'));
apiLis... | javascript | {
"resource": ""
} |
q60310 | filterElement | validation | function filterElement(flJson){
var returnJson = {"photo":{}};
returnJson.photo.title = flJson.photo.title;
returnJson.photo.description = flJson.photo.description;
returnJson.photo.farm = flJson.photo.farm;
returnJson.photo.id = flJson.photo.id;
returnJson.photo.media = flJso... | javascript | {
"resource": ""
} |
q60311 | getFlickrCacheJson | validation | function getFlickrCacheJson(photoId){
if(!enabledCache)return null;
var d = new Date();
for(var i = 0; i < cacheJson.length; i++){
if(cacheJson[i].fl.photo.id == photoId){
if( cacheJson[i].expires > d.getTime() ){
return cacheJson[i].fl;
}
break;
}
}
return null;
} | javascript | {
"resource": ""
} |
q60312 | getImageSize | validation | function getImageSize( flickrJson, photo_id, photo_size ){
var sizeInfo = {"width":0, "height":0};
var sizeTable = {
"s": "Square",
"q": "Large Square",
"t": "Thumbnail",
"m": "Small",
"n": "Small 320",
"-" : "Medium",
"z": "Medium 640",
"c": "Medium 800",
"b... | javascript | {
"resource": ""
} |
q60313 | hasClass | validation | function hasClass(el, className) {
var test;
if (el.classList) {
test = el.classList.contains(className);
} else {
var className = new RegExp('(^| )' + className + '( |$)', 'gi');
test = new RegExp(className).test(el.className);
}
return test;
} | javascript | {
"resource": ""
} |
q60314 | LeipzigEvent | validation | function LeipzigEvent(name, data) {
var leipzigEvent = undefined;
if (window.CustomEvent) {
leipzigEvent = new CustomEvent(name, {
detail: data,
bubbles: true,
cancelable: true
});
} else {
// For Internet Explorer & PhantomJS
leipzigEvent = document.createEv... | javascript | {
"resource": ""
} |
q60315 | triggerEvent | validation | function triggerEvent(el, name, data) {
var e = new LeipzigEvent(name, data);
el.dispatchEvent(e);
} | javascript | {
"resource": ""
} |
q60316 | processGloss | validation | function processGloss(gloss, callback) {
if (!(gloss instanceof Element)) {
var err = new Error('Invalid gloss element');
if (typeof callback === 'function') {
callback(err);
} else {
throw err;
}
}
var lines = Array.prototype.slice.call(gloss.chil... | javascript | {
"resource": ""
} |
q60317 | UrlHelper | validation | function UrlHelper(params){
this.url = "http://store.steampowered.com/search/?";
if(!!params.tags){
for(i = 0; i < params.tags.length; i++)
params.tags[i] = parameters.tags.get(params.tags[i]).value
this.url += "tags=" + params.tags.join(",") + "&";
}
if(!!params.os){
for(i = 0; i < params.os.length; i+... | javascript | {
"resource": ""
} |
q60318 | serializeState | validation | function serializeState(){
var data = model.data,
scale = model.scale,
translate = model.translate;
model.state = {
nodes: data.nodes.map(function(node){
return {
type: node.type,
property: node.property,
fixed: node.fixed,
... | javascript | {
"resource": ""
} |
q60319 | track | validation | function track(property){
if(!(property in trackedProperties)){
trackedProperties[property] = true;
values[property] = model[property];
Object.defineProperty(model, property, {
get: function () { return values[property]; },
set: function(value) {
values[prop... | javascript | {
"resource": ""
} |
q60320 | randomDate | validation | function randomDate(start, end) {
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
} | javascript | {
"resource": ""
} |
q60321 | randomPrice | validation | function randomPrice(oldPrice, volatility) {
const rnd = randomNumber();
let changePercent = 2 * volatility * rnd;
if (changePercent > volatility) {
changePercent -= (2 * volatility);
}
const changeAmount = oldPrice * changePercent;
const newPrice = oldPrice + changeAmount;
return newPrice;
} | javascript | {
"resource": ""
} |
q60322 | randomIncident | validation | function randomIncident(types, start, end) {
const x1 = randomDate(start, end);
const x2 = new Date(x1);
x2.setDate(x1.getDate() + (Math.floor(Math.random() * 45)));
Incidents.insert({
x1: x1.getTime(),
x2: x2.getTime(),
y1: (Math.floor(Math.random() * 99)),
type: types[(Math.floor(Math.random()... | javascript | {
"resource": ""
} |
q60323 | getDatetimeUnit | validation | function getDatetimeUnit(min, max) {
const diff = max.diff(min, 'days');
let unit = 'month';
if (diff <= 14) {
unit = 'day';
} else if (diff > 14 && diff <= 183) {
unit = 'week';
}
return unit;
} | javascript | {
"resource": ""
} |
q60324 | getRenderedTemplate | validation | function getRenderedTemplate(template, data, variableRegex) {
return template.replace(variableRegex, (match, captured) => {
const replacement = valueForProperty(data, captured.trim());
// If a template variable is found but nothing is supplied to fill it, remove it
if (replacement == null) {
return ... | javascript | {
"resource": ""
} |
q60325 | getProcessedPath | validation | function getProcessedPath(file, data) {
return file.replace(/__([A-Za-z0-9-]+_?[A-Za-z0-9-]+)+__/g, (match) => {
const dataKey = match.substring(2, match.length - 2);
const dataVal = data[dataKey];
if (dataVal) {
return dataVal;
}
return match;
});
} | javascript | {
"resource": ""
} |
q60326 | scaffold | validation | function scaffold(
{
source = '',
destination = 'destination',
onlyFiles = false,
exclude = [],
variableRegex = /\{\{\s?([A-Za-z0-9-]+_?[A-Za-z0-9-]+)+\s?\}\}/g,
} = {},
data = {},
) {
const cwd = process.cwd();
const thisSource = pathIsAbsolute(source) ? source : path.join(cwd, source);
... | javascript | {
"resource": ""
} |
q60327 | validation | function (lookup) {
var matches = tmplRegExp.exec(lookup);
if (matches) {
return {
src: matches && matches[0],
prop: matches && matches[1] || matches[2],
};
} else {
return false;
}
} | javascript | {
"resource": ""
} | |
q60328 | validation | function (data, lookup, options) {
var property;
// as long as this contains a template string, keep traversing
while(property = findProperty(lookup)) {
// if this doesn't solely contain a template lookup (e.g. '<%= key %>'), then
// recursively process it as a template to handle interpolated strings (e.g... | javascript | {
"resource": ""
} | |
q60329 | validation | function (data, arr, options) {
return arr.map(function(lookup) {
return expander.process(data, lookup, options);
});
} | javascript | {
"resource": ""
} | |
q60330 | validation | function (data, obj, options) {
var result = {};
Object.keys(obj).forEach(function(key) {
result[key] = expander.process(data, obj[key], options);
});
return result;
} | javascript | {
"resource": ""
} | |
q60331 | _set | validation | function _set(obj, keypath, value) {
var parts = _keyPathNormalize(keypath).split('.')
var last = parts.pop()
var dest = obj
var hasError
var errorInfo
util.some(parts, function(key) {
var t = util.type(dest)
if (t != 'object' && t != 'array') {
hasError = true
... | javascript | {
"resource": ""
} |
q60332 | validation | function(text) {
if (!text || !text.replace) return text
return text.replace(/(&[#a-zA-Z0-9]+;)/g, function (m, s) {
return _convertEntity(s)
})
} | javascript | {
"resource": ""
} | |
q60333 | compute | validation | function compute () {
// set value
util.forEach(expressions, function(exp, index) {
var v = that.$exec(exp)
if (!v[0]) caches[index] = v[1]
})
// get content
var str = ''
util.forEach(... | javascript | {
"resource": ""
} |
q60334 | patchFileObjects | validation | function patchFileObjects( formData ) {
// There are several landmines to avoid when making file uploads work on all browsers:
// - the `new File()` constructor trick breaks file uploads on Safari 10 in a way that's
// impossible to detect: it will send empty files in the multipart/form-data body.
// Therefore ... | javascript | {
"resource": ""
} |
q60335 | onmessage | validation | function onmessage( e ) {
debug( 'onmessage' );
// safeguard...
if ( e.origin !== proxyOrigin ) {
debug( 'ignoring message... %o !== %o', e.origin, proxyOrigin );
return;
}
let { data } = e;
if ( ! data ) {
return debug( 'no `data`, bailing' );
}
// Once the iframe is loaded, we can start using it.
if... | javascript | {
"resource": ""
} |
q60336 | onprogress | validation | function onprogress( data ) {
debug( 'got "progress" event: %o', data );
const xhr = requests[ data.callbackId ];
if ( xhr ) {
const prog = new ProgressEvent( 'progress', data );
const target = data.upload ? xhr.upload : xhr;
target.dispatchEvent( prog );
}
} | javascript | {
"resource": ""
} |
q60337 | resolve | validation | function resolve( xhr, body, headers ) {
const e = new ProgressEvent( 'load' );
e.data = e.body = e.response = body;
e.headers = headers;
xhr.dispatchEvent( e );
} | javascript | {
"resource": ""
} |
q60338 | reject | validation | function reject( xhr, err, headers ) {
const e = new ProgressEvent( 'error' );
e.error = e.err = err;
e.headers = headers;
xhr.dispatchEvent( e );
} | javascript | {
"resource": ""
} |
q60339 | instanceScopedDirective | validation | function instanceScopedDirective(tar, dec, dname) {
// don't compile child scope
if (scopedChilds && scopedChilds.length && util.some(scopedChilds, function (item) {
return tar == item
})) return
var drefs = tar._diretives || []
// prevent repetitive binding
... | javascript | {
"resource": ""
} |
q60340 | _safelyCall | validation | function _safelyCall(isCatch, fn, ctx) {
if (!fn) return
if (isCatch) {
try {
fn.call(ctx)
} catch(e) {
consoler.errorTrace(e)
}
} else {
fn.call(ctx)
}
} | javascript | {
"resource": ""
} |
q60341 | loadMiddlewareFilters | validation | function loadMiddlewareFilters(filters) {
var result = [],
index,
num = filters.length,
filter,
modulePath,
middleware;
function startsWith(string, searchString, position) {
position = position || 0;
return string.indexOf(searchString, position) === position;
}
for (inde... | javascript | {
"resource": ""
} |
q60342 | loadResources | validation | function loadResources(resources, providerIndex) {
var result = [],
index,
num = resources.length,
resource,
prefilters, postfilters;
for (index = 0; index < num; index++ ) {
resource = resources[index];
prefilters = [];
postfilters = [];
// Check resource has required pro... | javascript | {
"resource": ""
} |
q60343 | loadProviders | validation | function loadProviders(providers) {
var result = [],
index,
num = providers.length,
provider,
prefilters, postfilters, resources;
for (index = 0; index < num; index++ ) {
provider = providers[index];
prefilters = [];
postfilters = [];
resources = [];
// Check provider ... | javascript | {
"resource": ""
} |
q60344 | load | validation | function load(config) {
var configuration = {
prefilters: [],
providers: [],
postfilters: []
};
// Check a valid object
if (typeof config !== "object") {
throw new InvalidConfiguration(InvalidConfiguration.EMPTY_MESSAGE);
}
// Check at least one provider
if (!config.providers || !config... | javascript | {
"resource": ""
} |
q60345 | Currencies | validation | function Currencies (currencies) {
if (!currencies) {
throw new Error('Missing currencies object');
}
this.keys = parseInt(currencies.keys || 0);
this.metal = parseFloat(currencies.metal || 0);
if (isNaN(this.keys) || isNaN(this.metal)) {
throw new Error('Not a valid currencies obj... | javascript | {
"resource": ""
} |
q60346 | getOptions | validation | function getOptions() {
//
// Defines and parses the command line interface to start Clyde server.
//
var argv = yargs
.usage("Usage: $0 [options] config_file")
.example("$0 config.json", "Start clyde reading configuration from 'config.json' file.")
.example("$0 --log debug config.json", "Start cly... | javascript | {
"resource": ""
} |
q60347 | getWindowForElement | validation | function getWindowForElement(element) {
var doc = element.ownerDocument || element;
return doc.defaultView || doc.parentWindow || window;
} | javascript | {
"resource": ""
} |
q60348 | createInputInstance | validation | function createInputInstance(manager) {
var Type;
var inputClass = manager.options.inputClass;
if (inputClass) {
Type = inputClass;
} else if (SUPPORT_POINTER_EVENTS) {
Type = PointerEventInput;
} else if (SUPPORT_ONLY_TOUCH) {
Type = TouchInp... | javascript | {
"resource": ""
} |
q60349 | inputHandler | validation | function inputHandler(manager, eventType, input) {
var pointersLen = input.pointers.length;
var changedPointersLen = input.changedPointers.length;
var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && poin... | javascript | {
"resource": ""
} |
q60350 | computeInputData | validation | function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleClon... | javascript | {
"resource": ""
} |
q60351 | TMEhandler | validation | function TMEhandler(manager, inputEvent, inputData) {
var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH,
isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
ret... | javascript | {
"resource": ""
} |
q60352 | validation | function (input) {
var srcEvent = input.srcEvent;
var direction = input.offsetDirection;
// if the touch action did prevented once this session
if (this.manager.session.prevented) {
srcEvent.preventDefault();
return;
}
... | javascript | {
"resource": ""
} | |
q60353 | validation | function (tId, partialTree) {
if (tId === void 0) { tId = ''; }
if (partialTree === void 0) { partialTree = tree; }
if (!tId) {
return undefined;
}
var found;
partialTree.some(function (treeItem) {
if (treeItem[id] =... | javascript | {
"resource": ""
} | |
q60354 | validation | function (el) {
return el.id ? el.id : el.parentElement ? findId(el.parentElement) : null;
} | javascript | {
"resource": ""
} | |
q60355 | listLocalDatasetClientData | validation | function listLocalDatasetClientData(datasetClient, cb) {
syncStorage.readDatasetClientWithRecords(datasetClient.getId(), function(err, datasetClientsWithRecords) {
if (err) {
return cb(err);
}
//no one sync loop has completed yet, return null
if (!datasetClientsWithRecords || !datasetClientsWith... | javascript | {
"resource": ""
} |
q60356 | listAppliedChangeSinceLastSync | validation | function listAppliedChangeSinceLastSync(datasetId, lastSyncEndTime, clientInfo, cb) {
syncStorage.listUpdates(datasetId, {
type: SYNC_UPDATE_TYPES.APPLIED,
cuid: clientInfo.cuid,
timestamp: {$gt: lastSyncEndTime}
}, null, cb);
} | javascript | {
"resource": ""
} |
q60357 | listPendingChangesForClient | validation | function listPendingChangesForClient(datasetId, clientInfo, cb) {
pendingQueue.search({datasetId: datasetId, cuid: clientInfo.cuid}, cb);
} | javascript | {
"resource": ""
} |
q60358 | removePendingChanges | validation | function removePendingChanges(clientRecords, localDatasetClient, pendingChanges) {
_.each(pendingChanges, function(pendingChange, uid) {
if (clientRecords[uid]) {
delete clientRecords[uid];
}
if (localDatasetClient[uid]) {
delete localDatasetClient[uid];
}
});
} | javascript | {
"resource": ""
} |
q60359 | computeDelta | validation | function computeDelta(datasetId, clientRecords, serverRecords) {
var creates = {};
var updates = {};
var deletes = {};
_.each(serverRecords, function(serverRecord, serverRecordUid) {
var serverRecHash = serverRecord.hash;
//record is in both client and server
if (clientRecords[serverRecordUid]) {
... | javascript | {
"resource": ""
} |
q60360 | syncRecords | validation | function syncRecords(datasetId, params, cb) {
debug('[%s] process syncRecords request', datasetId);
var queryParams = params.query_params || {};
var metaData = params.meta_data || {}; //NOTE: the client doesn't send in this value for syncRecords ATM
var cuid = syncConfig.cuidProducer(params);
var datasetClien... | javascript | {
"resource": ""
} |
q60361 | validation | function(metric, records) {
var returnValue = {message: 'no stats available', name: metric.displayName};
if (records && records.length > 0) {
returnValue = _.chain(records).map(function(recordStr) {
return JSON.parse(recordStr);
}).groupBy(function(record) {
return record.tags[metric.groupByTag]... | javascript | {
"resource": ""
} | |
q60362 | init | validation | function init(dataset_id, options, cb) {
debug('[%s] init sync with options %j', dataset_id, options);
datasets.init(dataset_id, options);
//make sure we use the exported version here as the start function should be called only ONCE
module.exports.api.start(function(err) {
if (err) {
return cb(err);
... | javascript | {
"resource": ""
} |
q60363 | stop | validation | function stop(dataset_id, cb) {
if (!syncStarted) {
return cb();
}
debug('[%s] stop sync for dataset', dataset_id);
syncStorage.updateManyDatasetClients({datasetId: dataset_id}, {stopped: true}, cb);
} | javascript | {
"resource": ""
} |
q60364 | stopAll | validation | function stopAll(cb) {
//sync is not started yet, but connect could be called already. In this case, just reset a few things
if (!syncStarted) {
interceptors.restore();
dataHandlers.restore();
hashProvider.restore();
mongoDbClient = null;
redisClient = null;
metricsClient = null;
return ... | javascript | {
"resource": ""
} |
q60365 | removeCollision | validation | function removeCollision(datasetId, params, cb) {
debug('[%s] removeCollision');
dataHandlers.removeCollision(datasetId, params.hash, params.meta_data, cb);
} | javascript | {
"resource": ""
} |
q60366 | doListDatasetClients | validation | function doListDatasetClients(filter, cb) {
debug('doListDatasetClients');
var col = mongoClient.collection(DATASETCLIENTS_COLLECTION);
col.find(filter).toArray(function(err, datasetClients) {
if (err) {
debugError('Failed to list datasetClients due to error %s', err);
}
return cb(err, datasetCl... | javascript | {
"resource": ""
} |
q60367 | doRemoveDatasetClients | validation | function doRemoveDatasetClients(datasetClientsToRemove, cb) {
var removeIds = _.pluck(datasetClientsToRemove, 'id');
var datasetIds = _.uniq(_.pluck(datasetClientsToRemove, 'datasetId'));
debug('doRemoveDatasetClients: removed datasetClients = %d, datasets = %d', removeIds.length, datasetIds.length);
async.seri... | javascript | {
"resource": ""
} |
q60368 | doRemoveDatasetClientWithRecords | validation | function doRemoveDatasetClientWithRecords(datasetClientId, cb) {
debug('doRemoveDatasetClientWithRecords datasetClientId = %s', datasetClientId);
async.waterfall([
async.apply(doReadDatasetClient, datasetClientId),
function removeRefs(datasetClientJson, next) {
var datasetId = datasetClientJson.datas... | javascript | {
"resource": ""
} |
q60369 | doReadDatasetClient | validation | function doReadDatasetClient(datasetClientId, cb) {
debug('doReadDatasetClient datasetClientId = %s', datasetClientId);
var col = mongoClient.collection(DATASETCLIENTS_COLLECTION);
col.findOne({id: datasetClientId}, function(err, datasetClient) {
if (err) {
debugError('Failed to read datasetClient due t... | javascript | {
"resource": ""
} |
q60370 | doUpdateDatasetClient | validation | function doUpdateDatasetClient(datasetClientId, fields, upsert, cb) {
debug('doUpdateDatasetClient datasetClientId = %s :: fields = %j', datasetClientId, fields);
var col = mongoClient.collection(DATASETCLIENTS_COLLECTION);
delete fields._id;
col.findOneAndUpdate({id: datasetClientId}, {'$set': fields}, {upsert... | javascript | {
"resource": ""
} |
q60371 | createIndexForCollection | validation | function createIndexForCollection(collectionName, indexField, indexOpts) {
var collection = mongoClient.collection(collectionName);
collection.createIndex(indexField, indexOpts, function(err) {
if (err) {
debugError('Failed to create index for collection. collection = %s :: index = %j :: error = %j',colle... | javascript | {
"resource": ""
} |
q60372 | ensureIndexesForDataset | validation | function ensureIndexesForDataset(datasetId) {
createIndexForCollection(getDatasetRecordsCollectionName(datasetId), {'uid': 1}, {});
createIndexForCollection(getDatasetRecordsCollectionName(datasetId), {'refs': 1}, {});
createIndexForCollection(require('./sync-updates').getDatasetUpdatesCollectionName(datasetId), ... | javascript | {
"resource": ""
} |
q60373 | diffRecords | validation | function diffRecords(localRecords, newRecords) {
var recordsDiff = {};
_.each(newRecords, function(record, uid) {
if (localRecords[uid]) {
if (localRecords[uid].hash !== record.hash) {
record.op = "update";
recordsDiff[uid] = record;
}
} else {
record.op = "update";
r... | javascript | {
"resource": ""
} |
q60374 | diff | validation | function diff(datasetClientJson, localRecords, next) {
var recordsDiff = diffRecords(syncUtil.convertToObject(localRecords), syncUtil.convertToObject(records));
return next(null, datasetClientJson, recordsDiff);
} | javascript | {
"resource": ""
} |
q60375 | validation | function(filter, callback) {
metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doListDatasetClients)(filter, callback);
} | javascript | {
"resource": ""
} | |
q60376 | validation | function(datasetClientsToRemove, callback) {
if (!datasetClientsToRemove.length) {
return callback();
}
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doRemoveDatasetClients)(datasetClientsToRemove, callback);
} | javascript | {
"resource": ""
} | |
q60377 | validation | function(datasetClientId, fieldsToUpdate, callback) {
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doUpdateDatasetClient)(datasetClientId, fieldsToUpdate, false, callback);
} | javascript | {
"resource": ""
} | |
q60378 | validation | function(datasetClientId, fields, callback) {
fields.id = datasetClientId;
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doUpdateDatasetClient)(datasetClientId, fields, true, callback);
} | javascript | {
"resource": ""
} | |
q60379 | validation | function(datasetClientId, fields, records, callback) {
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doUpdateDatasetClientWithRecords)(datasetClientId, fields, records, callback);
} | javascript | {
"resource": ""
} | |
q60380 | validation | function(datasetClientId, callback) {
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doReadDatasetClientWithRecordsUseCache)(datasetClientId, callback);
} | javascript | {
"resource": ""
} | |
q60381 | doFindAndDeleteUpdate | validation | function doFindAndDeleteUpdate(datasetId, acknowledgement, callback) {
debug('[%s] doFindAndDeleteUpdate acknowledgement = %j',datasetId,acknowledgement);
var updatesCollection = mongoClient.collection(getDatasetUpdatesCollectionName(datasetId));
updatesCollection.findOneAndDelete({cuid: acknowledgement.cuid, has... | javascript | {
"resource": ""
} |
q60382 | doListUpdates | validation | function doListUpdates(datasetId, criteria, options, callback) {
debug('[%s] doListUpdates criteria = %j',datasetId,criteria);
var updatesCollection = mongoClient.collection(getDatasetUpdatesCollectionName(datasetId));
var docLimit = options && options.limit;
var cursor = updatesCollection.find(criteria);
if ... | javascript | {
"resource": ""
} |
q60383 | validation | function(datasetId, acknowledgement, callback) {
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doFindAndDeleteUpdate)(datasetId, acknowledgement, callback);
} | javascript | {
"resource": ""
} | |
q60384 | validation | function(datasetId, acknowledgementFields, callback) {
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doSaveUpdate)(datasetId, acknowledgementFields, callback);
} | javascript | {
"resource": ""
} | |
q60385 | validation | function(datasetId, criteria, options, callback) {
return metrics.timeAsyncFunc(metrics.KEYS.MONGODB_OPERATION_TIME, doListUpdates)(datasetId, criteria, options, callback);
} | javascript | {
"resource": ""
} | |
q60386 | DatasetClient | validation | function DatasetClient(datasetId, opts){
opts = opts || {};
this.datasetId = datasetId;
this.queryParams = opts.queryParams || {};
this.metaData = opts.metaData || {};
this.id = generateDatasetClientId(this);
this.config = opts.config || datasets.getDatasetConfig(datasetId);
this.collisionCount = opts.col... | javascript | {
"resource": ""
} |
q60387 | invoke | validation | function invoke(dataset_id, params, callback) {
debug('invoke');
if (arguments.length < 3) throw new Error('invoke requires 3 arguments');
// Verify that fn param has been passed
if (!params || !params.fn) {
var err = new Error('no fn parameter provided in params "' + util.inspect(params) + '"');
debu... | javascript | {
"resource": ""
} |
q60388 | convertToObject | validation | function convertToObject(itemArr) {
var obj = {};
_.each(itemArr, function(item) {
obj[item.uid] = item;
});
return obj;
} | javascript | {
"resource": ""
} |
q60389 | SyncScheduler | validation | function SyncScheduler(syncQueueImpl, options) {
if (!syncQueueImpl) {
throw new Error('syncQueueImpl is required');
}
this.syncQueue = syncQueueImpl;
options = options || {};
this.syncSchedulerLockName = options.syncSchedulerLockName || 'locks:sync:SyncScheduler';
this.timeBetweenChecks = options.timeB... | javascript | {
"resource": ""
} |
q60390 | updateDatasetClients | validation | function updateDatasetClients(wcb) {
var datasetClientIds = _.pluck(datasetClientsToSync, 'id');
syncStorage.updateManyDatasetClients({id: {$in: datasetClientIds}}, {syncScheduled: Date.now()}, wcb);
} | javascript | {
"resource": ""
} |
q60391 | insertDocsToDb | validation | function insertDocsToDb(dburl, collectionName, docs, cb) {
MongoClient.connect(dburl, function(err, db){
if (err) {
return cb(err);
}
var col = db.collection(collectionName);
col.insertMany(docs, function(err, result){
if (err) {
return cb(err);
}
return cb(null, result... | javascript | {
"resource": ""
} |
q60392 | set | validation | function set(key, value, cb) {
if (!syncConfig.useCache || !redisClient) {
return cb && cb();
}
return redisClient.set(key, value, cb);
} | javascript | {
"resource": ""
} |
q60393 | get | validation | function get(key, cb) {
if (!syncConfig.useCache || !redisClient) {
return cb && cb();
}
return redisClient.get(key, cb);
} | javascript | {
"resource": ""
} |
q60394 | del | validation | function del(key, cb) {
if (!syncConfig.useCache || !redisClient) {
return cb && cb();
}
return redisClient.del(key, cb);
} | javascript | {
"resource": ""
} |
q60395 | syncWithBackend | validation | function syncWithBackend(payload, tries, callback) {
var datasetClientId = payload.id;
var datasetId = payload.datasetId;
var startTime = payload.startTime;
if (!datasetClientId || !datasetId) {
recordProcessTime(startTime, false);
debugError("no datasetId value found in sync request payload %j" ,paylo... | javascript | {
"resource": ""
} |
q60396 | doCreate | validation | function doCreate(datasetId, pendingChange, callback) {
var record = pendingChange.post;
var metaData = pendingChange.meta_data;
debug('[%s] CREATE Start data = %j', datasetId, record);
dataHandlers.doCreate(datasetId, record, metaData, function(err, data) {
if (err) {
debugError('[%s] CREATE Failed -... | javascript | {
"resource": ""
} |
q60397 | doDelete | validation | function doDelete(datasetId, pendingChange, callback) {
debug('[%s] DELETE Start', datasetId);
var metaData = pendingChange.meta_data;
var uid = pendingChange.uid;
dataHandlers.doRead(datasetId, uid, metaData, function(err, data) {
if (err) {
debugError('READ for DELETE Failed - uid = %s : err = %s', ... | javascript | {
"resource": ""
} |
q60398 | applyPendingChange | validation | function applyPendingChange(pendingChange, tries, callback) {
var datasetId = pendingChange.datasetId;
if (!datasetId || !pendingChange.action || !pendingChange.uid || !pendingChange.cuid || !pendingChange.hash) {
debugError("[%s] invalid pendingChange request dropped :: item = %j", datasetId, pendingChange);
... | javascript | {
"resource": ""
} |
q60399 | MongodbQueue | validation | function MongodbQueue(name, metrics, lock, opts) {
if (!name) {
throw new Error('name is required to create a mongodb queue');
}
if (!opts || !opts.mongodb) {
throw new Error('mongodb is not specified to create mongodb queue');
}
this.queueName = name;
this.metrics = metrics;
this.lock = lock;
t... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.