_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21400 | train | function(el, options) {
var eHandler = function(e) {
e.mfpEl = this;
mfp._openClick(e, el, options);
};
if(!options) {
options = {};
}
var eName = 'click.magnificPopup';
options.mainEl = el;
if(options.items) {
options.isObj = true;
el.off(eName).on(eName, eHandler);
} else {
option... | javascript | {
"resource": ""
} | |
q21401 | train | function(status, text) {
if(mfp.preloader) {
if(_prevStatus !== status) {
mfp.container.removeClass('mfp-s-'+_prevStatus);
}
if(!text && status === 'loading') {
text = mfp.st.tLoading;
}
var data = {
status: status,
text: text
};
// allows to modify status
_mfpTrigger('Updat... | javascript | {
"resource": ""
} | |
q21402 | deserializeValue | train | function deserializeValue(value) {
var num
try {
return value ?
value == "true" ||
( value == "false" ? false :
value == "null" ? null :
!isNaN(num = Number(value)) ? num :
/^[\[\{]/.test(value) ? $.parseJSON(value) :
value )
: value
} ca... | javascript | {
"resource": ""
} |
q21403 | fix | train | function fix(event) {
if (!('defaultPrevented' in event)) {
event.defaultPrevented = false
var prevent = event.preventDefault
event.preventDefault = function() {
this.defaultPrevented = true
prevent.call(this)
}
}
} | javascript | {
"resource": ""
} |
q21404 | train | function(item) {
var counter = 0,
img = item.img[0],
mfpSetInterval = function(delay) {
if(_imgInterval) {
clearInterval(_imgInterval);
}
// decelerating interval that checks for size of an image
_imgInterval = setInterval(function() {
if(img.naturalWidth > 0) {
mfp._... | javascript | {
"resource": ""
} | |
q21405 | createCountUp | train | function createCountUp() {
establishOptionsFromInputs();
demo = new CountUp('myTargetElement', endVal, options);
if (!demo.error) {
errorSection.style.display = 'none';
if (input('useOnComplete').checked) {
demo.start(methodToCallOnComplete);
}
else {
demo.start();
... | javascript | {
"resource": ""
} |
q21406 | train | function(self) {
if (self.resumeToken) {
self.options.resumeAfter = self.resumeToken;
}
var changeStreamCursor = buildChangeStreamAggregationCommand(self);
/**
* Fired for each new matching change in the specified namespace. Attaching a `change`
* event listener to a Change Stream will switch the st... | javascript | {
"resource": ""
} | |
q21407 | GridFSBucket | train | function GridFSBucket(db, options) {
Emitter.apply(this);
this.setMaxListeners(0);
if (options && typeof options === 'object') {
options = shallowClone(options);
var keys = Object.keys(DEFAULT_GRIDFS_BUCKET_OPTIONS);
for (var i = 0; i < keys.length; ++i) {
if (!options[keys[i]]) {
optio... | javascript | {
"resource": ""
} |
q21408 | collections | train | function collections(db, options, callback) {
let Collection = loadCollection();
options = Object.assign({}, options, { nameOnly: true });
// Let's get the collection names
db.listCollections({}, options).toArray((err, documents) => {
if (err != null) return handleCallback(callback, err, null);
// Filt... | javascript | {
"resource": ""
} |
q21409 | createIndex | train | function createIndex(db, name, fieldOrSpec, options, callback) {
// Get the write concern options
let finalOptions = Object.assign({}, { readPreference: ReadPreference.PRIMARY }, options);
finalOptions = applyWriteConcern(finalOptions, { db }, options);
// Ensure we have a callback
if (finalOptions.writeConc... | javascript | {
"resource": ""
} |
q21410 | createListener | train | function createListener(db, e, object) {
function listener(err) {
if (object.listeners(e).length > 0) {
object.emit(e, err, db);
// Emit on all associated db's if available
for (let i = 0; i < db.s.children.length; i++) {
db.s.children[i].emit(e, err, db.s.children[i]);
}
}
... | javascript | {
"resource": ""
} |
q21411 | dropCollection | train | function dropCollection(db, name, options, callback) {
executeCommand(db, name, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if (err) return handleCallback(ca... | javascript | {
"resource": ""
} |
q21412 | dropDatabase | train | function dropDatabase(db, cmd, options, callback) {
executeCommand(db, cmd, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if (callback == null) return;
if ... | javascript | {
"resource": ""
} |
q21413 | ensureIndex | train | function ensureIndex(db, name, fieldOrSpec, options, callback) {
// Get the write concern options
const finalOptions = applyWriteConcern({}, { db }, options);
// Create command
const selector = createCreateIndexCommand(db, name, fieldOrSpec, options);
const index_name = selector.name;
// Did the user destr... | javascript | {
"resource": ""
} |
q21414 | evaluate | train | function evaluate(db, code, parameters, options, callback) {
let finalCode = code;
let finalParameters = [];
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
// If not a code object translate to one
if... | javascript | {
"resource": ""
} |
q21415 | executeDbAdminCommand | train | function executeDbAdminCommand(db, command, options, callback) {
db.s.topology.command('admin.$cmd', command, options, (err, result) => {
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed()) {
return callback(new MongoError('topology was destroyed'));
}
if ... | javascript | {
"resource": ""
} |
q21416 | indexInformation | train | function indexInformation(db, name, options, callback) {
// If we specified full information
const full = options['full'] == null ? false : options['full'];
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was destroyed'));
... | javascript | {
"resource": ""
} |
q21417 | processResults | train | function processResults(indexes) {
// Contains all the information
let info = {};
// Process all the indexes
for (let i = 0; i < indexes.length; i++) {
const index = indexes[i];
// Let's unpack the object
info[index.name] = [];
for (let name in index.key) {
info[index.nam... | javascript | {
"resource": ""
} |
q21418 | listCollectionsTransforms | train | function listCollectionsTransforms(databaseName) {
const matching = `${databaseName}.`;
return {
doc: doc => {
const index = doc.name.indexOf(matching);
// Remove database name if available
if (doc.name && index === 0) {
doc.name = doc.name.substr(index + matching.length);
}
... | javascript | {
"resource": ""
} |
q21419 | profilingInfo | train | function profilingInfo(db, options, callback) {
try {
db
.collection('system.profile')
.find({}, options)
.toArray(callback);
} catch (err) {
return callback(err, null);
}
} | javascript | {
"resource": ""
} |
q21420 | profilingLevel | train | function profilingLevel(db, options, callback) {
executeCommand(db, { profile: -1 }, options, (err, doc) => {
if (err == null && doc.ok === 1) {
const was = doc.was;
if (was === 0) return callback(null, 'off');
if (was === 1) return callback(null, 'slow_only');
if (was === 2) return callba... | javascript | {
"resource": ""
} |
q21421 | removeUser | train | function removeUser(db, username, options, callback) {
let Db = loadDb();
// Attempt to execute command
executeAuthRemoveUserCommand(db, username, options, (err, result) => {
if (err && err.code === -5000) {
const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options);
// I... | javascript | {
"resource": ""
} |
q21422 | setProfilingLevel | train | function setProfilingLevel(db, level, options, callback) {
const command = {};
let profile = 0;
if (level === 'off') {
profile = 0;
} else if (level === 'slow_only') {
profile = 1;
} else if (level === 'all') {
profile = 2;
} else {
return callback(new Error('Error: illegal profiling level ... | javascript | {
"resource": ""
} |
q21423 | validateDatabaseName | train | function validateDatabaseName(databaseName) {
if (typeof databaseName !== 'string')
throw MongoError.create({ message: 'database name must be a string', driver: true });
if (databaseName.length === 0)
throw MongoError.create({ message: 'database name cannot be the empty string', driver: true });
if (datab... | javascript | {
"resource": ""
} |
q21424 | createCreateIndexCommand | train | function createCreateIndexCommand(db, name, fieldOrSpec, options) {
const indexParameters = parseIndexOptions(fieldOrSpec);
const fieldHash = indexParameters.fieldHash;
// Generate the index name
const indexName = typeof options.name === 'string' ? options.name : indexParameters.name;
const selector = {
... | javascript | {
"resource": ""
} |
q21425 | createIndexUsingCreateIndexes | train | function createIndexUsingCreateIndexes(db, name, fieldOrSpec, options, callback) {
// Build the index
const indexParameters = parseIndexOptions(fieldOrSpec);
// Generate the index name
const indexName = typeof options.name === 'string' ? options.name : indexParameters.name;
// Set up the index
const indexes... | javascript | {
"resource": ""
} |
q21426 | executeAuthCreateUserCommand | train | function executeAuthCreateUserCommand(db, username, password, options, callback) {
// Special case where there is no password ($external users)
if (typeof username === 'string' && password != null && typeof password === 'object') {
options = password;
password = null;
}
// Unpack all options
if (type... | javascript | {
"resource": ""
} |
q21427 | executeAuthRemoveUserCommand | train | function executeAuthRemoveUserCommand(db, username, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
// Did the user destroy the topology
if (db.serverConfig && db.serverConfig.isDestroyed())
return callback(new MongoError('topology was ... | javascript | {
"resource": ""
} |
q21428 | checkForAtomicOperators | train | function checkForAtomicOperators(update) {
const keys = Object.keys(update);
// same errors as the server would give for update doc lacking atomic operators
if (keys.length === 0) {
return toError('The update operation document must contain at least one atomic operator.');
}
if (keys[0][0] !== '$') {
... | javascript | {
"resource": ""
} |
q21429 | count | train | function count(coll, query, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = Object.assign({}, options);
options.collectionName = coll.s.name;
options.readPreference = resolveReadPreference(options, {
db: coll.s.db,
collection: coll
});
let cm... | javascript | {
"resource": ""
} |
q21430 | buildCountCommand | train | function buildCountCommand(collectionOrCursor, query, options) {
const skip = options.skip;
const limit = options.limit;
let hint = options.hint;
const maxTimeMS = options.maxTimeMS;
query = query || {};
// Final query
const cmd = {
count: options.collectionName,
query: query
};
// check if ... | javascript | {
"resource": ""
} |
q21431 | createIndex | train | function createIndex(coll, fieldOrSpec, options, callback) {
createIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | javascript | {
"resource": ""
} |
q21432 | deleteMany | train | function deleteMany(coll, filter, options, callback) {
options.single = false;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | javascript | {
"resource": ""
} |
q21433 | deleteOne | train | function deleteOne(coll, filter, options, callback) {
options.single = true;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | javascript | {
"resource": ""
} |
q21434 | distinct | train | function distinct(coll, key, query, options, callback) {
// maxTimeMS option
const maxTimeMS = options.maxTimeMS;
// Distinct command
const cmd = {
distinct: coll.s.name,
key: key,
query: query
};
options = Object.assign({}, options);
// Ensure we have the right read preference inheritance
... | javascript | {
"resource": ""
} |
q21435 | dropIndex | train | function dropIndex(coll, indexName, options, callback) {
// Delete index command
const cmd = { dropIndexes: coll.s.name, index: indexName };
// Decorate command with writeConcern if supported
applyWriteConcern(cmd, { db: coll.s.db, collection: coll }, options);
// Execute command
executeCommand(coll.s.db,... | javascript | {
"resource": ""
} |
q21436 | dropIndexes | train | function dropIndexes(coll, options, callback) {
dropIndex(coll, '*', options, err => {
if (err) return handleCallback(callback, err, false);
handleCallback(callback, null, true);
});
} | javascript | {
"resource": ""
} |
q21437 | ensureIndex | train | function ensureIndex(coll, fieldOrSpec, options, callback) {
ensureIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | javascript | {
"resource": ""
} |
q21438 | findAndModify | train | function findAndModify(coll, query, sort, doc, options, callback) {
// Create findAndModify command object
const queryObject = {
findAndModify: coll.s.name,
query: query
};
sort = formattedOrderClause(sort);
if (sort) {
queryObject.sort = sort;
}
queryObject.new = options.new ? true : false;... | javascript | {
"resource": ""
} |
q21439 | findAndRemove | train | function findAndRemove(coll, query, sort, options, callback) {
// Add the remove option
options.remove = true;
// Execute the callback
findAndModify(coll, query, sort, null, options, callback);
} | javascript | {
"resource": ""
} |
q21440 | findOne | train | function findOne(coll, query, options, callback) {
const cursor = coll
.find(query, options)
.limit(-1)
.batchSize(1);
// Return the item
cursor.next((err, item) => {
if (err != null) return handleCallback(callback, toError(err), null);
handleCallback(callback, null, item);
});
} | javascript | {
"resource": ""
} |
q21441 | findOneAndDelete | train | function findOneAndDelete(coll, filter, options, callback) {
// Final options
const finalOptions = Object.assign({}, options);
finalOptions.fields = options.projection;
finalOptions.remove = true;
// Execute find and Modify
findAndModify(coll, filter, options.sort, null, finalOptions, callback);
} | javascript | {
"resource": ""
} |
q21442 | findOneAndReplace | train | function findOneAndReplace(coll, filter, replacement, options, callback) {
// Final options
const finalOptions = Object.assign({}, options);
finalOptions.fields = options.projection;
finalOptions.update = true;
finalOptions.new = options.returnOriginal !== void 0 ? !options.returnOriginal : false;
finalOpti... | javascript | {
"resource": ""
} |
q21443 | geoHaystackSearch | train | function geoHaystackSearch(coll, x, y, options, callback) {
// Build command object
let commandObject = {
geoSearch: coll.s.name,
near: [x, y]
};
// Remove read preference from hash if it exists
commandObject = decorateCommand(commandObject, options, ['readPreference', 'session']);
options = Objec... | javascript | {
"resource": ""
} |
q21444 | group | train | function group(coll, keys, condition, initial, reduce, finalize, command, options, callback) {
// Execute using the command
if (command) {
const reduceFunction = reduce && reduce._bsontype === 'Code' ? reduce : new Code(reduce);
const selector = {
group: {
ns: coll.s.name,
$reduce: re... | javascript | {
"resource": ""
} |
q21445 | indexes | train | function indexes(coll, options, callback) {
options = Object.assign({}, { full: true }, options);
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | javascript | {
"resource": ""
} |
q21446 | indexExists | train | function indexExists(coll, indexes, options, callback) {
indexInformation(coll, options, (err, indexInformation) => {
// If we have an error return
if (err != null) return handleCallback(callback, err, null);
// Let's check for the index names
if (!Array.isArray(indexes))
return handleCallback(c... | javascript | {
"resource": ""
} |
q21447 | indexInformation | train | function indexInformation(coll, options, callback) {
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | javascript | {
"resource": ""
} |
q21448 | insertOne | train | function insertOne(coll, doc, options, callback) {
if (Array.isArray(doc)) {
return callback(
MongoError.create({ message: 'doc parameter must be an object', driver: true })
);
}
insertDocuments(coll, [doc], options, (err, r) => {
if (callback == null) return;
if (err && callback) return ca... | javascript | {
"resource": ""
} |
q21449 | isCapped | train | function isCapped(coll, options, callback) {
optionsOp(coll, options, (err, document) => {
if (err) return handleCallback(callback, err);
handleCallback(callback, null, !!(document && document.capped));
});
} | javascript | {
"resource": ""
} |
q21450 | optionsOp | train | function optionsOp(coll, opts, callback) {
coll.s.db.listCollections({ name: coll.s.name }, opts).toArray((err, collections) => {
if (err) return handleCallback(callback, err);
if (collections.length === 0) {
return handleCallback(
callback,
MongoError.create({ message: `collection ${col... | javascript | {
"resource": ""
} |
q21451 | parallelCollectionScan | train | function parallelCollectionScan(coll, options, callback) {
// Create command object
const commandObject = {
parallelCollectionScan: coll.s.name,
numCursors: options.numCursors
};
// Do we have a readConcern specified
decorateWithReadConcern(commandObject, coll, options);
// Store the raw value
c... | javascript | {
"resource": ""
} |
q21452 | prepareDocs | train | function prepareDocs(coll, docs, options) {
const forceServerObjectId =
typeof options.forceServerObjectId === 'boolean'
? options.forceServerObjectId
: coll.s.db.options.forceServerObjectId;
// no need to modify the docs if server sets the ObjectId
if (forceServerObjectId === true) {
return ... | javascript | {
"resource": ""
} |
q21453 | processScope | train | function processScope(scope) {
if (!isObject(scope) || scope._bsontype === 'ObjectID') {
return scope;
}
const keys = Object.keys(scope);
let key;
const new_scope = {};
for (let i = keys.length - 1; i >= 0; i--) {
key = keys[i];
if ('function' === typeof scope[key]) {
new_scope[key] = ne... | javascript | {
"resource": ""
} |
q21454 | reIndex | train | function reIndex(coll, options, callback) {
// Reindex
const cmd = { reIndex: coll.s.name };
// Execute the command
executeCommand(coll.s.db, cmd, options, (err, result) => {
if (callback == null) return;
if (err) return handleCallback(callback, err, null);
handleCallback(callback, null, result.ok ... | javascript | {
"resource": ""
} |
q21455 | replaceOne | train | function replaceOne(coll, filter, doc, options, callback) {
// Set single document update
options.multi = false;
// Execute update
updateDocuments(coll, filter, doc, options, (err, r) => {
if (callback == null) return;
if (err && callback) return callback(err);
if (r == null) return callback(null, ... | javascript | {
"resource": ""
} |
q21456 | save | train | function save(coll, doc, options, callback) {
// Get the write concern options
const finalOptions = applyWriteConcern(
Object.assign({}, options),
{ db: coll.s.db, collection: coll },
options
);
// Establish if we need to perform an insert or update
if (doc._id != null) {
finalOptions.upsert =... | javascript | {
"resource": ""
} |
q21457 | stats | train | function stats(coll, options, callback) {
// Build command object
const commandObject = {
collStats: coll.s.name
};
// Check if we have the scale value
if (options['scale'] != null) commandObject['scale'] = options['scale'];
options = Object.assign({}, options);
// Ensure we have the right read pref... | javascript | {
"resource": ""
} |
q21458 | updateMany | train | function updateMany(coll, filter, update, options, callback) {
// Set single document update
options.multi = true;
// Execute update
updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
} | javascript | {
"resource": ""
} |
q21459 | updateOne | train | function updateOne(coll, filter, update, options, callback) {
// Set single document update
options.multi = false;
// Execute update
updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
} | javascript | {
"resource": ""
} |
q21460 | train | function(topology, storeOptions) {
var self = this;
var storedOps = [];
storeOptions = storeOptions || { force: false, bufferMaxEntries: -1 };
// Internal state
this.s = {
storedOps: storedOps,
storeOptions: storeOptions,
topology: topology
};
Object.defineProperty(this, 'length', {
enum... | javascript | {
"resource": ""
} | |
q21461 | GridFSBucketWriteStream | train | function GridFSBucketWriteStream(bucket, filename, options) {
options = options || {};
this.bucket = bucket;
this.chunks = bucket.s._chunksCollection;
this.filename = filename;
this.files = bucket.s._filesCollection;
this.options = options;
// Signals the write is all done
this.done = false;
this.id ... | javascript | {
"resource": ""
} |
q21462 | train | function(options) {
var r = null;
if (options.readPreference) {
r = options.readPreference;
} else {
return options;
}
if (typeof r === 'string') {
options.readPreference = new ReadPreference(r);
} else if (r && !(r instanceof ReadPreference) && typeof r === 'object') {
const mode = r.mode ... | javascript | {
"resource": ""
} | |
q21463 | train | function(obj, name, value) {
Object.defineProperty(obj, name, {
enumerable: true,
get: function() {
return value;
}
});
} | javascript | {
"resource": ""
} | |
q21464 | train | function(error) {
if (error instanceof Error) return error;
var msg = error.err || error.errmsg || error.errMessage || error;
var e = MongoError.create({ message: msg, driver: true });
// Get all object keys
var keys = typeof error === 'object' ? Object.keys(error) : [];
for (var i = 0; i < keys.length; ... | javascript | {
"resource": ""
} | |
q21465 | train | function(fieldOrSpec) {
var fieldHash = {};
var indexes = [];
var keys;
// Get all the fields accordingly
if ('string' === typeof fieldOrSpec) {
// 'type'
indexes.push(fieldOrSpec + '_' + 1);
fieldHash[fieldOrSpec] = 1;
} else if (Array.isArray(fieldOrSpec)) {
fieldOrSpec.forEach(function(f... | javascript | {
"resource": ""
} | |
q21466 | train | function(target, source) {
var translations = {
// SSL translation options
sslCA: 'ca',
sslCRL: 'crl',
sslValidate: 'rejectUnauthorized',
sslKey: 'key',
sslCert: 'cert',
sslPass: 'passphrase',
// SocketTimeout translation options
socketTimeoutMS: 'socketTimeout',
connectTimeout... | javascript | {
"resource": ""
} | |
q21467 | train | function(targetOptions, sourceOptions, keys, mergeWriteConcern) {
// Mix in any allowed options
for (var i = 0; i < keys.length; i++) {
if (!targetOptions[keys[i]] && sourceOptions[keys[i]] !== undefined) {
targetOptions[keys[i]] = sourceOptions[keys[i]];
}
}
// No merging of write concern
if (... | javascript | {
"resource": ""
} | |
q21468 | applyWriteConcern | train | function applyWriteConcern(target, sources, options) {
options = options || {};
const db = sources.db;
const coll = sources.collection;
if (options.session && options.session.inTransaction()) {
// writeConcern is not allowed within a multi-statement transaction
if (target.writeConcern) {
delete t... | javascript | {
"resource": ""
} |
q21469 | deprecateOptions | train | function deprecateOptions(config, fn) {
if (process.noDeprecation === true) {
return fn;
}
const msgHandler = config.msgHandler ? config.msgHandler : defaultMsgHandler;
const optionsWarned = new Set();
function deprecated() {
const options = arguments[config.optionsIndex];
// ensure options is ... | javascript | {
"resource": ""
} |
q21470 | count | train | function count(cursor, applySkipLimit, opts, callback) {
if (applySkipLimit) {
if (typeof cursor.cursorSkip() === 'number') opts.skip = cursor.cursorSkip();
if (typeof cursor.cursorLimit() === 'number') opts.limit = cursor.cursorLimit();
}
// Ensure we have the right read preference inheritance
if (opt... | javascript | {
"resource": ""
} |
q21471 | each | train | function each(cursor, callback) {
let Cursor = loadCursor();
if (!callback) throw MongoError.create({ message: 'callback is mandatory', driver: true });
if (cursor.isNotified()) return;
if (cursor.s.state === Cursor.CLOSED || cursor.isDead()) {
return handleCallback(
callback,
MongoError.create... | javascript | {
"resource": ""
} |
q21472 | next | train | function next(cursor, callback) {
// Return the currentDoc if someone called hasNext first
if (cursor.s.currentDoc) {
const doc = cursor.s.currentDoc;
cursor.s.currentDoc = null;
return callback(null, doc);
}
// Return the next object
nextObject(cursor, callback);
} | javascript | {
"resource": ""
} |
q21473 | train | function(file, mongoObject, writeConcern) {
if (!(this instanceof Chunk)) return new Chunk(file, mongoObject);
this.file = file;
var mongoObjectFinal = mongoObject == null ? {} : mongoObject;
this.writeConcern = writeConcern || { w: 1 };
this.objectId = mongoObjectFinal._id == null ? new ObjectID() : mongoOb... | javascript | {
"resource": ""
} | |
q21474 | train | function(bson, ns, cmd, options, topology, topologyOptions) {
CoreCursor.apply(this, Array.prototype.slice.call(arguments, 0));
var state = CommandCursor.INIT;
var streamOptions = {};
// MaxTimeMS
var maxTimeMS = null;
// Get the promiseLibrary
var promiseLibrary = options.promiseLibrary || Promise;
... | javascript | {
"resource": ""
} | |
q21475 | train | function(self, callback) {
// Calcuate the length
var mongoObject = {
_id: self.fileId,
filename: self.filename,
contentType: self.contentType,
length: self.position ? self.position : 0,
chunkSize: self.chunkSize,
uploadDate: self.uploadDate,
aliases: self.aliases,
metadata: self.met... | javascript | {
"resource": ""
} | |
q21476 | train | function(self, chunkNumber, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || self.writeConcern;
options.readPreference = self.readPreference;
// Get the nth chunk
self
.chunkCollection()
.findOne({ files_id: self.fileId, n: c... | javascript | {
"resource": ""
} | |
q21477 | train | function(self, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || self.writeConcern;
if (self.fileId != null) {
self.chunkCollection().remove({ files_id: self.fileId }, options, function(err) {
if (err) return callback(err, fals... | javascript | {
"resource": ""
} | |
q21478 | GridFSBucketReadStream | train | function GridFSBucketReadStream(chunks, files, readPreference, filter, options) {
this.s = {
bytesRead: 0,
chunks: chunks,
cursor: null,
expected: 0,
files: files,
filter: filter,
init: false,
expectedEnd: 0,
file: null,
options: options,
readPreference: readPreference
};... | javascript | {
"resource": ""
} |
q21479 | replSetGetStatus | train | function replSetGetStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { replSetGetStatus: 1 }, options, callback);
} | javascript | {
"resource": ""
} |
q21480 | serverStatus | train | function serverStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { serverStatus: 1 }, options, callback);
} | javascript | {
"resource": ""
} |
q21481 | validateCollection | train | function validateCollection(admin, collectionName, options, callback) {
const command = { validate: collectionName };
const keys = Object.keys(options);
// Decorate command with extra options
for (let i = 0; i < keys.length; i++) {
if (options.hasOwnProperty(keys[i]) && keys[i] !== 'session') {
comma... | javascript | {
"resource": ""
} |
q21482 | collectEvents | train | function collectEvents(mongoClient, topology) {
let MongoClient = loadClient();
const collectedEvents = [];
if (mongoClient instanceof MongoClient) {
monitoringEvents.forEach(event => {
topology.on(event, (object1, object2) => {
if (event === 'open') {
collectedEvents.push({ event: ev... | javascript | {
"resource": ""
} |
q21483 | replayEvents | train | function replayEvents(mongoClient, events) {
for (let i = 0; i < events.length; i++) {
mongoClient.emit(events[i].event, events[i].object1, events[i].object2);
}
} | javascript | {
"resource": ""
} |
q21484 | MongoClient | train | function MongoClient(url, options) {
if (!(this instanceof MongoClient)) return new MongoClient(url, options);
// Set up event emitter
EventEmitter.call(this);
// The internal state
this.s = {
url: url,
options: options || {},
promiseLibrary: null,
dbCache: {},
sessions: []
};
// Get... | javascript | {
"resource": ""
} |
q21485 | Db | train | function Db(databaseName, topology, options) {
options = options || {};
if (!(this instanceof Db)) return new Db(databaseName, topology, options);
EventEmitter.call(this);
// Get the promiseLibrary
const promiseLibrary = options.promiseLibrary || Promise;
// Filter the options
options = filterOptions(op... | javascript | {
"resource": ""
} |
q21486 | createItemString | train | function createItemString(data, limit) {
let count = 0;
let hasMore = false;
if (Number.isSafeInteger(data.size)) {
count = data.size;
} else {
// eslint-disable-next-line no-unused-vars
for (const entry of data) {
if (limit && count + 1 > limit) {
hasMore = true;
break;
... | javascript | {
"resource": ""
} |
q21487 | computeWithTryCatch | train | function computeWithTryCatch(reducer, action, state) {
let nextState = state;
let nextError;
try {
nextState = reducer(state, action);
} catch (err) {
nextError = err.toString();
if (isChrome) {
// In Chrome, rethrowing provides better source map support
setTimeout(() => {
throw ... | javascript | {
"resource": ""
} |
q21488 | computeNextEntry | train | function computeNextEntry(reducer, action, state, shouldCatchErrors) {
if (!shouldCatchErrors) {
return { state: reducer(state, action) };
}
return computeWithTryCatch(reducer, action, state);
} | javascript | {
"resource": ""
} |
q21489 | recomputeStates | train | function recomputeStates(
computedStates,
minInvalidatedStateIndex,
reducer,
committedState,
actionsById,
stagedActionIds,
skippedActionIds,
shouldCatchErrors
) {
// Optimization: exit early and return the same reference
// if we know nothing could have changed.
if (
!computedStates ||
min... | javascript | {
"resource": ""
} |
q21490 | AbstractMediaLoader | train | function AbstractMediaLoader(loadItem, preferXHR, type) {
this.AbstractLoader_constructor(loadItem, preferXHR, type);
// public properties
this.resultFormatter = this._formatResult;
// protected properties
this._tagSrcAttribute = "src";
this.on("initialize", this._updateXHR, this);
} | javascript | {
"resource": ""
} |
q21491 | XHRRequest | train | function XHRRequest (item) {
this.AbstractRequest_constructor(item);
// protected properties
/**
* A reference to the XHR request used to load the content.
* @property _request
* @type {XMLHttpRequest | XDomainRequest | ActiveX.XMLHTTP}
* @private
*/
this._request = null;
/**
* A manual lo... | javascript | {
"resource": ""
} |
q21492 | LoadQueue | train | function LoadQueue (preferXHR, basePath, crossOrigin) {
this.AbstractLoader_constructor();
/**
* An array of the plugins registered using {{#crossLink "LoadQueue/installPlugin"}}{{/crossLink}}.
* @property _plugins
* @type {Array}
* @private
* @since 0.6.1
*/
this._plugins = [];
/**
* An ... | javascript | {
"resource": ""
} |
q21493 | BinaryLoader | train | function BinaryLoader(loadItem) {
this.AbstractLoader_constructor(loadItem, true, createjs.Types.BINARY);
this.on("initialize", this._updateXHR, this);
} | javascript | {
"resource": ""
} |
q21494 | train | function(escapable) {
var i;
var unrolled = {};
var c = [];
for (i = 0; i < 65536; i++) {
c.push( String.fromCharCode(i) );
}
escapable.lastIndex = 0;
c.join('').replace(escapable, function(a) {
unrolled[ a ] = '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
return '';
});
escap... | javascript | {
"resource": ""
} | |
q21495 | mount | train | function mount(glide, extensions, events) {
var components = {};
for (var name in extensions) {
if (isFunction(extensions[name])) {
components[name] = extensions[name](glide, components, events);
} else {
warn('Extension must be a function');
}
}
for (var _name in components) {
if ... | javascript | {
"resource": ""
} |
q21496 | sortKeys | train | function sortKeys(obj) {
return Object.keys(obj).sort().reduce(function (r, k) {
r[k] = obj[k];
return r[k], r;
}, {});
} | javascript | {
"resource": ""
} |
q21497 | mergeOptions | train | function mergeOptions(defaults, settings) {
var options = _extends({}, defaults, settings);
// `Object.assign` do not deeply merge objects, so we
// have to do it manually for every nested object
// in options. Although it does not look smart,
// it's smaller and faster than some fancy
// merging deep-merg... | javascript | {
"resource": ""
} |
q21498 | EventsBus | train | function EventsBus() {
var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
classCallCheck(this, EventsBus);
this.events = events;
this.hop = events.hasOwnProperty;
} | javascript | {
"resource": ""
} |
q21499 | Glide | train | function Glide(selector) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Glide);
this._c = {};
this._t = [];
this._e = new EventsBus();
this.disabled = false;
this.selector = selector;
this.settings = mergeOptions(defaults, o... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.