repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
dimsemenov/Magnific-Popup | src/js/core.js | 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 | 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... | [
"function",
"(",
"el",
",",
"options",
")",
"{",
"var",
"eHandler",
"=",
"function",
"(",
"e",
")",
"{",
"e",
".",
"mfpEl",
"=",
"this",
";",
"mfp",
".",
"_openClick",
"(",
"e",
",",
"el",
",",
"options",
")",
";",
"}",
";",
"if",
"(",
"!",
"... | Initializes single popup or a group of popups | [
"Initializes",
"single",
"popup",
"or",
"a",
"group",
"of",
"popups"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L590-L615 | train | |
dimsemenov/Magnific-Popup | src/js/core.js | 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 | 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... | [
"function",
"(",
"status",
",",
"text",
")",
"{",
"if",
"(",
"mfp",
".",
"preloader",
")",
"{",
"if",
"(",
"_prevStatus",
"!==",
"status",
")",
"{",
"mfp",
".",
"container",
".",
"removeClass",
"(",
"'mfp-s-'",
"+",
"_prevStatus",
")",
";",
"}",
"if"... | Updates text on preloader | [
"Updates",
"text",
"on",
"preloader"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/core.js#L658-L688 | train | |
dimsemenov/Magnific-Popup | website/third-party-libs/zepto.js | deserializeValue | 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 | 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... | [
"function",
"deserializeValue",
"(",
"value",
")",
"{",
"var",
"num",
"try",
"{",
"return",
"value",
"?",
"value",
"==",
"\"true\"",
"||",
"(",
"value",
"==",
"\"false\"",
"?",
"false",
":",
"value",
"==",
"\"null\"",
"?",
"null",
":",
"!",
"isNaN",
"(... | "true" => true "false" => false "null" => null "42" => 42 "42.5" => 42.5 JSON => parse if valid String => self | [
"true",
"=",
">",
"true",
"false",
"=",
">",
"false",
"null",
"=",
">",
"null",
"42",
"=",
">",
"42",
"42",
".",
"5",
"=",
">",
"42",
".",
"5",
"JSON",
"=",
">",
"parse",
"if",
"valid",
"String",
"=",
">",
"self"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/website/third-party-libs/zepto.js#L289-L303 | train |
dimsemenov/Magnific-Popup | website/third-party-libs/zepto.js | fix | function fix(event) {
if (!('defaultPrevented' in event)) {
event.defaultPrevented = false
var prevent = event.preventDefault
event.preventDefault = function() {
this.defaultPrevented = true
prevent.call(this)
}
}
} | javascript | function fix(event) {
if (!('defaultPrevented' in event)) {
event.defaultPrevented = false
var prevent = event.preventDefault
event.preventDefault = function() {
this.defaultPrevented = true
prevent.call(this)
}
}
} | [
"function",
"fix",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"(",
"'defaultPrevented'",
"in",
"event",
")",
")",
"{",
"event",
".",
"defaultPrevented",
"=",
"false",
"var",
"prevent",
"=",
"event",
".",
"preventDefault",
"event",
".",
"preventDefault",
"=",
... | emulates the 'defaultPrevented' property for browsers that have none | [
"emulates",
"the",
"defaultPrevented",
"property",
"for",
"browsers",
"that",
"have",
"none"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/website/third-party-libs/zepto.js#L1012-L1021 | train |
dimsemenov/Magnific-Popup | src/js/image.js | 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 | 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._... | [
"function",
"(",
"item",
")",
"{",
"var",
"counter",
"=",
"0",
",",
"img",
"=",
"item",
".",
"img",
"[",
"0",
"]",
",",
"mfpSetInterval",
"=",
"function",
"(",
"delay",
")",
"{",
"if",
"(",
"_imgInterval",
")",
"{",
"clearInterval",
"(",
"_imgInterva... | Function that loops until the image has size to display elements that rely on it asap | [
"Function",
"that",
"loops",
"until",
"the",
"image",
"has",
"size",
"to",
"display",
"elements",
"that",
"rely",
"on",
"it",
"asap"
] | c8f6b8549ebff2306c5f1179c9d112308185fe2c | https://github.com/dimsemenov/Magnific-Popup/blob/c8f6b8549ebff2306c5f1179c9d112308185fe2c/src/js/image.js#L103-L135 | train | |
inorganik/countUp.js | demo.js | createCountUp | 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 | 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();
... | [
"function",
"createCountUp",
"(",
")",
"{",
"establishOptionsFromInputs",
"(",
")",
";",
"demo",
"=",
"new",
"CountUp",
"(",
"'myTargetElement'",
",",
"endVal",
",",
"options",
")",
";",
"if",
"(",
"!",
"demo",
".",
"error",
")",
"{",
"errorSection",
".",
... | COUNTUP AND CODE VISUALIZER | [
"COUNTUP",
"AND",
"CODE",
"VISUALIZER"
] | 29ba37c1f4f02a00ef19c9abbdc58d1b610f7d38 | https://github.com/inorganik/countUp.js/blob/29ba37c1f4f02a00ef19c9abbdc58d1b610f7d38/demo.js#L108-L126 | train |
mongodb/node-mongodb-native | lib/change_stream.js | 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 | 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... | [
"function",
"(",
"self",
")",
"{",
"if",
"(",
"self",
".",
"resumeToken",
")",
"{",
"self",
".",
"options",
".",
"resumeAfter",
"=",
"self",
".",
"resumeToken",
";",
"}",
"var",
"changeStreamCursor",
"=",
"buildChangeStreamAggregationCommand",
"(",
"self",
"... | Create a new change stream cursor based on self's configuration | [
"Create",
"a",
"new",
"change",
"stream",
"cursor",
"based",
"on",
"self",
"s",
"configuration"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/change_stream.js#L224-L283 | train | |
mongodb/node-mongodb-native | lib/gridfs-stream/index.js | GridFSBucket | 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 | 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... | [
"function",
"GridFSBucket",
"(",
"db",
",",
"options",
")",
"{",
"Emitter",
".",
"apply",
"(",
"this",
")",
";",
"this",
".",
"setMaxListeners",
"(",
"0",
")",
";",
"if",
"(",
"options",
"&&",
"typeof",
"options",
"===",
"'object'",
")",
"{",
"options"... | Constructor for a streaming GridFS interface
@class
@param {Db} db A db handle
@param {object} [options] Optional settings.
@param {string} [options.bucketName="fs"] The 'files' and 'chunks' collections will be prefixed with the bucket name followed by a dot.
@param {number} [options.chunkSizeBytes=255 * 1024] Number o... | [
"Constructor",
"for",
"a",
"streaming",
"GridFS",
"interface"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs-stream/index.js#L31-L56 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | collections | 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 | 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... | [
"function",
"collections",
"(",
"db",
",",
"options",
",",
"callback",
")",
"{",
"let",
"Collection",
"=",
"loadCollection",
"(",
")",
";",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
",",
"{",
"nameOnly",
":",
"true",
"}",
... | Fetch all collections for the current db.
@method
@param {Db} db The Db instance on which to fetch collections.
@param {object} [options] Optional settings. See Db.prototype.collections for a list of options.
@param {Db~collectionsResultCallback} [callback] The results callback | [
"Fetch",
"all",
"collections",
"for",
"the",
"current",
"db",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L149-L177 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | createIndex | 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 | 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... | [
"function",
"createIndex",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"// Get the write concern options",
"let",
"finalOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"readPreference",
":",
"ReadPref... | Creates an index on the db and collection.
@method
@param {Db} db The Db instance on which to create an index.
@param {string} name Name of the collection to create the index on.
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Db.prototype.createIndex for a list ... | [
"Creates",
"an",
"index",
"on",
"the",
"db",
"and",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L274-L334 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | createListener | 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 | 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]);
}
}
... | [
"function",
"createListener",
"(",
"db",
",",
"e",
",",
"object",
")",
"{",
"function",
"listener",
"(",
"err",
")",
"{",
"if",
"(",
"object",
".",
"listeners",
"(",
"e",
")",
".",
"length",
">",
"0",
")",
"{",
"object",
".",
"emit",
"(",
"e",
",... | Add listeners to topology | [
"Add",
"listeners",
"to",
"topology"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L337-L349 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | dropCollection | 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 | 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... | [
"function",
"dropCollection",
"(",
"db",
",",
"name",
",",
"options",
",",
"callback",
")",
"{",
"executeCommand",
"(",
"db",
",",
"name",
",",
"options",
",",
"(",
"err",
",",
"result",
")",
"=>",
"{",
"// Did the user destroy the topology",
"if",
"(",
"d... | Drop a collection from the database, removing it permanently. New accesses will create a new collection.
@method
@param {Db} db The Db instance on which to drop the collection.
@param {string} name Name of collection to drop
@param {Object} [options] Optional settings. See Db.prototype.dropCollection for a list of opt... | [
"Drop",
"a",
"collection",
"from",
"the",
"database",
"removing",
"it",
"permanently",
".",
"New",
"accesses",
"will",
"create",
"a",
"new",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L360-L371 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | dropDatabase | 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 | 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 ... | [
"function",
"dropDatabase",
"(",
"db",
",",
"cmd",
",",
"options",
",",
"callback",
")",
"{",
"executeCommand",
"(",
"db",
",",
"cmd",
",",
"options",
",",
"(",
"err",
",",
"result",
")",
"=>",
"{",
"// Did the user destroy the topology",
"if",
"(",
"db",
... | Drop a database, removing it permanently from the server.
@method
@param {Db} db The Db instance to drop.
@param {Object} cmd The command document.
@param {Object} [options] Optional settings. See Db.prototype.dropDatabase for a list of options.
@param {Db~resultCallback} [callback] The results callback | [
"Drop",
"a",
"database",
"removing",
"it",
"permanently",
"from",
"the",
"server",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L382-L393 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | ensureIndex | 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 | 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... | [
"function",
"ensureIndex",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"// Get the write concern options",
"const",
"finalOptions",
"=",
"applyWriteConcern",
"(",
"{",
"}",
",",
"{",
"db",
"}",
",",
"options",
")",
... | Ensures that an index exists. If it does not, creates it.
@method
@param {Db} db The Db instance on which to ensure the index.
@param {string} name The index name
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Db.prototype.ensureIndex for a list of options.
@pa... | [
"Ensures",
"that",
"an",
"index",
"exists",
".",
"If",
"it",
"does",
"not",
"creates",
"it",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L405-L429 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | evaluate | 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 | 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... | [
"function",
"evaluate",
"(",
"db",
",",
"code",
",",
"parameters",
",",
"options",
",",
"callback",
")",
"{",
"let",
"finalCode",
"=",
"code",
";",
"let",
"finalParameters",
"=",
"[",
"]",
";",
"// Did the user destroy the topology",
"if",
"(",
"db",
".",
... | Evaluate JavaScript on the server
@method
@param {Db} db The Db instance.
@param {Code} code JavaScript to execute on server.
@param {(object|array)} parameters The parameters for the call.
@param {object} [options] Optional settings. See Db.prototype.eval for a list of options.
@param {Db~resultCallback} [callback] T... | [
"Evaluate",
"JavaScript",
"on",
"the",
"server"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L442-L481 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | executeDbAdminCommand | 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 | 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 ... | [
"function",
"executeDbAdminCommand",
"(",
"db",
",",
"command",
",",
"options",
",",
"callback",
")",
"{",
"db",
".",
"s",
".",
"topology",
".",
"command",
"(",
"'admin.$cmd'",
",",
"command",
",",
"options",
",",
"(",
"err",
",",
"result",
")",
"=>",
... | Runs a command on the database as admin.
@method
@param {Db} db The Db instance on which to execute the command.
@param {object} command The command hash
@param {object} [options] Optional settings. See Db.prototype.executeDbAdminCommand for a list of options.
@param {Db~resultCallback} [callback] The command result c... | [
"Runs",
"a",
"command",
"on",
"the",
"database",
"as",
"admin",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L529-L539 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | indexInformation | 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 | 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'));
... | [
"function",
"indexInformation",
"(",
"db",
",",
"name",
",",
"options",
",",
"callback",
")",
"{",
"// If we specified full information",
"const",
"full",
"=",
"options",
"[",
"'full'",
"]",
"==",
"null",
"?",
"false",
":",
"options",
"[",
"'full'",
"]",
";"... | Retrieves this collections index info.
@method
@param {Db} db The Db instance on which to retrieve the index info.
@param {string} name The name of the collection.
@param {object} [options] Optional settings. See Db.prototype.indexInformation for a list of options.
@param {Db~resultCallback} [callback] The command res... | [
"Retrieves",
"this",
"collections",
"index",
"info",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L550-L584 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | processResults | 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 | 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... | [
"function",
"processResults",
"(",
"indexes",
")",
"{",
"// Contains all the information",
"let",
"info",
"=",
"{",
"}",
";",
"// Process all the indexes",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"indexes",
".",
"length",
";",
"i",
"++",
")",
"{",... | Process all the results from the index command and collection | [
"Process",
"all",
"the",
"results",
"from",
"the",
"index",
"command",
"and",
"collection"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L558-L572 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | listCollectionsTransforms | 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 | 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);
}
... | [
"function",
"listCollectionsTransforms",
"(",
"databaseName",
")",
"{",
"const",
"matching",
"=",
"`",
"${",
"databaseName",
"}",
"`",
";",
"return",
"{",
"doc",
":",
"doc",
"=>",
"{",
"const",
"index",
"=",
"doc",
".",
"name",
".",
"indexOf",
"(",
"matc... | Transformation methods for cursor results | [
"Transformation",
"methods",
"for",
"cursor",
"results"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L587-L601 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | profilingInfo | function profilingInfo(db, options, callback) {
try {
db
.collection('system.profile')
.find({}, options)
.toArray(callback);
} catch (err) {
return callback(err, null);
}
} | javascript | function profilingInfo(db, options, callback) {
try {
db
.collection('system.profile')
.find({}, options)
.toArray(callback);
} catch (err) {
return callback(err, null);
}
} | [
"function",
"profilingInfo",
"(",
"db",
",",
"options",
",",
"callback",
")",
"{",
"try",
"{",
"db",
".",
"collection",
"(",
"'system.profile'",
")",
".",
"find",
"(",
"{",
"}",
",",
"options",
")",
".",
"toArray",
"(",
"callback",
")",
";",
"}",
"ca... | Retrieve the current profiling information for MongoDB
@method
@param {Db} db The Db instance on which to retrieve the profiling info.
@param {Object} [options] Optional settings. See Db.protoype.profilingInfo for a list of options.
@param {Db~resultCallback} [callback] The command result callback.
@deprecated Query t... | [
"Retrieve",
"the",
"current",
"profiling",
"information",
"for",
"MongoDB"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L612-L621 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | profilingLevel | 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 | 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... | [
"function",
"profilingLevel",
"(",
"db",
",",
"options",
",",
"callback",
")",
"{",
"executeCommand",
"(",
"db",
",",
"{",
"profile",
":",
"-",
"1",
"}",
",",
"options",
",",
"(",
"err",
",",
"doc",
")",
"=>",
"{",
"if",
"(",
"err",
"==",
"null",
... | Retrieve the current profiling level for MongoDB
@method
@param {Db} db The Db instance on which to retrieve the profiling level.
@param {Object} [options] Optional settings. See Db.prototype.profilingLevel for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Retrieve",
"the",
"current",
"profiling",
"level",
"for",
"MongoDB"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L631-L643 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | removeUser | 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 | 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... | [
"function",
"removeUser",
"(",
"db",
",",
"username",
",",
"options",
",",
"callback",
")",
"{",
"let",
"Db",
"=",
"loadDb",
"(",
")",
";",
"// Attempt to execute command",
"executeAuthRemoveUserCommand",
"(",
"db",
",",
"username",
",",
"options",
",",
"(",
... | Remove a user from a database
@method
@param {Db} db The Db instance on which to remove the user.
@param {string} username The username.
@param {object} [options] Optional settings. See Db.prototype.removeUser for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Remove",
"a",
"user",
"from",
"a",
"database"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L654-L681 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | setProfilingLevel | 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 | 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 ... | [
"function",
"setProfilingLevel",
"(",
"db",
",",
"level",
",",
"options",
",",
"callback",
")",
"{",
"const",
"command",
"=",
"{",
"}",
";",
"let",
"profile",
"=",
"0",
";",
"if",
"(",
"level",
"===",
"'off'",
")",
"{",
"profile",
"=",
"0",
";",
"}... | Set the current profiling level of MongoDB
@method
@param {Db} db The Db instance on which to execute the command.
@param {string} level The new profiling level (off, slow_only, all).
@param {Object} [options] Optional settings. See Db.prototype.setProfilingLevel for a list of options.
@param {Db~resultCallback} [call... | [
"Set",
"the",
"current",
"profiling",
"level",
"of",
"MongoDB"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L692-L715 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | validateDatabaseName | 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 | 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... | [
"function",
"validateDatabaseName",
"(",
"databaseName",
")",
"{",
"if",
"(",
"typeof",
"databaseName",
"!==",
"'string'",
")",
"throw",
"MongoError",
".",
"create",
"(",
"{",
"message",
":",
"'database name must be a string'",
",",
"driver",
":",
"true",
"}",
"... | Validate the database name | [
"Validate",
"the",
"database",
"name"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L718-L733 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | createCreateIndexCommand | 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 | 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 = {
... | [
"function",
"createCreateIndexCommand",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
")",
"{",
"const",
"indexParameters",
"=",
"parseIndexOptions",
"(",
"fieldOrSpec",
")",
";",
"const",
"fieldHash",
"=",
"indexParameters",
".",
"fieldHash",
";",
... | Create the command object for Db.prototype.createIndex.
@param {Db} db The Db instance on which to create the command.
@param {string} name Name of the collection to create the index on.
@param {(string|object)} fieldOrSpec Defines the index.
@param {Object} [options] Optional settings. See Db.prototype.createIndex fo... | [
"Create",
"the",
"command",
"object",
"for",
"Db",
".",
"prototype",
".",
"createIndex",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L744-L779 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | createIndexUsingCreateIndexes | 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 | 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... | [
"function",
"createIndexUsingCreateIndexes",
"(",
"db",
",",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"// Build the index",
"const",
"indexParameters",
"=",
"parseIndexOptions",
"(",
"fieldOrSpec",
")",
";",
"// Generate the index name",
... | Create index using the createIndexes command.
@param {Db} db The Db instance on which to execute the command.
@param {string} name Name of the collection to create the index on.
@param {(string|object)} fieldOrSpec Defines the index.
@param {Object} [options] Optional settings. See Db.prototype.createIndex for a list ... | [
"Create",
"index",
"using",
"the",
"createIndexes",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L790-L839 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | executeAuthCreateUserCommand | 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 | 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... | [
"function",
"executeAuthCreateUserCommand",
"(",
"db",
",",
"username",
",",
"password",
",",
"options",
",",
"callback",
")",
"{",
"// Special case where there is no password ($external users)",
"if",
"(",
"typeof",
"username",
"===",
"'string'",
"&&",
"password",
"!="... | Run the createUser command.
@param {Db} db The Db instance on which to execute the command.
@param {string} username The username of the user to add.
@param {string} password The password of the user to add.
@param {object} [options] Optional settings. See Db.prototype.addUser for a list of options.
@param {Db~resultC... | [
"Run",
"the",
"createUser",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L850-L941 | train |
mongodb/node-mongodb-native | lib/operations/db_ops.js | executeAuthRemoveUserCommand | 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 | 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 ... | [
"function",
"executeAuthRemoveUserCommand",
"(",
"db",
",",
"username",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"(",
"callback",
"=",
"options",
")",
",",
"(",
"options",
"=",
"{",
"}",
")",
";... | Run the dropUser command.
@param {Db} db The Db instance on which to execute the command.
@param {string} username The username of the user to remove.
@param {object} [options] Optional settings. See Db.prototype.removeUser for a list of options.
@param {Db~resultCallback} [callback] The command result callback | [
"Run",
"the",
"dropUser",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/db_ops.js#L951-L985 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | checkForAtomicOperators | 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 | 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] !== '$') {
... | [
"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",
")",
... | Check the update operation to ensure it has atomic operators. | [
"Check",
"the",
"update",
"operation",
"to",
"ensure",
"it",
"has",
"atomic",
"operators",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L167-L178 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | count | 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 | 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... | [
"function",
"count",
"(",
"coll",
",",
"query",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"(",
"callback",
"=",
"options",
")",
",",
"(",
"options",
"=",
"{",
"}",
")",
";",
"options",
"=",
... | Count the number of documents in the collection that match the query.
@method
@param {Collection} a Collection instance.
@param {object} query The query for the count.
@param {object} [options] Optional settings. See Collection.prototype.count for a list of options.
@param {Collection~countCallback} [callback] The com... | [
"Count",
"the",
"number",
"of",
"documents",
"in",
"the",
"collection",
"that",
"match",
"the",
"query",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L189-L210 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | buildCountCommand | 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 | 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 ... | [
"function",
"buildCountCommand",
"(",
"collectionOrCursor",
",",
"query",
",",
"options",
")",
"{",
"const",
"skip",
"=",
"options",
".",
"skip",
";",
"const",
"limit",
"=",
"options",
".",
"limit",
";",
"let",
"hint",
"=",
"options",
".",
"hint",
";",
"... | Build the count command.
@method
@param {collectionOrCursor} an instance of a collection or cursor
@param {object} query The query for the count.
@param {object} [options] Optional settings. See Collection.prototype.count and Cursor.prototype.count for a list of options. | [
"Build",
"the",
"count",
"command",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L247-L282 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | createIndex | function createIndex(coll, fieldOrSpec, options, callback) {
createIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | javascript | function createIndex(coll, fieldOrSpec, options, callback) {
createIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | [
"function",
"createIndex",
"(",
"coll",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"createIndexDb",
"(",
"coll",
".",
"s",
".",
"db",
",",
"coll",
".",
"s",
".",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
";",... | Create an index on the db and collection.
@method
@param {Collection} a Collection instance.
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Collection.prototype.createIndex for a list of options.
@param {Collection~resultCallback} [callback] The command result ... | [
"Create",
"an",
"index",
"on",
"the",
"db",
"and",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L293-L295 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | deleteMany | function deleteMany(coll, filter, options, callback) {
options.single = false;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | javascript | function deleteMany(coll, filter, options, callback) {
options.single = false;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | [
"function",
"deleteMany",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"callback",
")",
"{",
"options",
".",
"single",
"=",
"false",
";",
"removeDocuments",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"(",
"err",
",",
"r",
")",
"=>",
"deleteCa... | Delete multiple documents from the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the documents to remove
@param {object} [options] Optional settings. See Collection.prototype.deleteMany for a list of options.
@param {Collection~deleteWriteOpCallback} [c... | [
"Delete",
"multiple",
"documents",
"from",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L361-L365 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | deleteOne | function deleteOne(coll, filter, options, callback) {
options.single = true;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | javascript | function deleteOne(coll, filter, options, callback) {
options.single = true;
removeDocuments(coll, filter, options, (err, r) => deleteCallback(err, r, callback));
} | [
"function",
"deleteOne",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"callback",
")",
"{",
"options",
".",
"single",
"=",
"true",
";",
"removeDocuments",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"(",
"err",
",",
"r",
")",
"=>",
"deleteCall... | Delete a single document from the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the document to remove
@param {object} [options] Optional settings. See Collection.prototype.deleteOne for a list of options.
@param {Collection~deleteWriteOpCallback} [call... | [
"Delete",
"a",
"single",
"document",
"from",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L376-L379 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | distinct | 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 | 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
... | [
"function",
"distinct",
"(",
"coll",
",",
"key",
",",
"query",
",",
"options",
",",
"callback",
")",
"{",
"// maxTimeMS option",
"const",
"maxTimeMS",
"=",
"options",
".",
"maxTimeMS",
";",
"// Distinct command",
"const",
"cmd",
"=",
"{",
"distinct",
":",
"c... | Return a list of distinct values for the given key across a collection.
@method
@param {Collection} a Collection instance.
@param {string} key Field of the document to find distinct values for.
@param {object} query The query for filtering the set of documents to which we apply the distinct filter.
@param {object} [op... | [
"Return",
"a",
"list",
"of",
"distinct",
"values",
"for",
"the",
"given",
"key",
"across",
"a",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L391-L424 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | dropIndex | 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 | 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,... | [
"function",
"dropIndex",
"(",
"coll",
",",
"indexName",
",",
"options",
",",
"callback",
")",
"{",
"// Delete index command",
"const",
"cmd",
"=",
"{",
"dropIndexes",
":",
"coll",
".",
"s",
".",
"name",
",",
"index",
":",
"indexName",
"}",
";",
"// Decorat... | Drop an index from this collection.
@method
@param {Collection} a Collection instance.
@param {string} indexName Name of the index to drop.
@param {object} [options] Optional settings. See Collection.prototype.dropIndex for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Drop",
"an",
"index",
"from",
"this",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L435-L448 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | dropIndexes | function dropIndexes(coll, options, callback) {
dropIndex(coll, '*', options, err => {
if (err) return handleCallback(callback, err, false);
handleCallback(callback, null, true);
});
} | javascript | function dropIndexes(coll, options, callback) {
dropIndex(coll, '*', options, err => {
if (err) return handleCallback(callback, err, false);
handleCallback(callback, null, true);
});
} | [
"function",
"dropIndexes",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"dropIndex",
"(",
"coll",
",",
"'*'",
",",
"options",
",",
"err",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
",",
"false"... | Drop all indexes from this collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.dropIndexes for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Drop",
"all",
"indexes",
"from",
"this",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L458-L463 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | ensureIndex | function ensureIndex(coll, fieldOrSpec, options, callback) {
ensureIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | javascript | function ensureIndex(coll, fieldOrSpec, options, callback) {
ensureIndexDb(coll.s.db, coll.s.name, fieldOrSpec, options, callback);
} | [
"function",
"ensureIndex",
"(",
"coll",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
"{",
"ensureIndexDb",
"(",
"coll",
".",
"s",
".",
"db",
",",
"coll",
".",
"s",
".",
"name",
",",
"fieldOrSpec",
",",
"options",
",",
"callback",
")",
";",... | Ensure that an index exists. If the index does not exist, this function creates it.
@method
@param {Collection} a Collection instance.
@param {(string|object)} fieldOrSpec Defines the index.
@param {object} [options] Optional settings. See Collection.prototype.ensureIndex for a list of options.
@param {Collection~resu... | [
"Ensure",
"that",
"an",
"index",
"exists",
".",
"If",
"the",
"index",
"does",
"not",
"exist",
"this",
"function",
"creates",
"it",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L474-L476 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | findAndModify | 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 | 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;... | [
"function",
"findAndModify",
"(",
"coll",
",",
"query",
",",
"sort",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"// Create findAndModify command object",
"const",
"queryObject",
"=",
"{",
"findAndModify",
":",
"coll",
".",
"s",
".",
"name",
",",
... | Find and update a document.
@method
@param {Collection} a Collection instance.
@param {object} query Query object to locate the object to modify.
@param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
@param {object} doc The fields/vals to be updated.
... | [
"Find",
"and",
"update",
"a",
"document",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L490-L560 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | findAndRemove | 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 | function findAndRemove(coll, query, sort, options, callback) {
// Add the remove option
options.remove = true;
// Execute the callback
findAndModify(coll, query, sort, null, options, callback);
} | [
"function",
"findAndRemove",
"(",
"coll",
",",
"query",
",",
"sort",
",",
"options",
",",
"callback",
")",
"{",
"// Add the remove option",
"options",
".",
"remove",
"=",
"true",
";",
"// Execute the callback",
"findAndModify",
"(",
"coll",
",",
"query",
",",
... | Find and remove a document.
@method
@param {Collection} a Collection instance.
@param {object} query Query object to locate the object to modify.
@param {array} sort If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
@param {object} [options] Optional settings. See Co... | [
"Find",
"and",
"remove",
"a",
"document",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L573-L578 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | findOne | 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 | 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);
});
} | [
"function",
"findOne",
"(",
"coll",
",",
"query",
",",
"options",
",",
"callback",
")",
"{",
"const",
"cursor",
"=",
"coll",
".",
"find",
"(",
"query",
",",
"options",
")",
".",
"limit",
"(",
"-",
"1",
")",
".",
"batchSize",
"(",
"1",
")",
";",
"... | Fetch the first document that matches the query.
@method
@param {Collection} a Collection instance.
@param {object} query Query for find Operation
@param {object} [options] Optional settings. See Collection.prototype.findOne for a list of options.
@param {Collection~resultCallback} [callback] The command result callba... | [
"Fetch",
"the",
"first",
"document",
"that",
"matches",
"the",
"query",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L589-L600 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | findOneAndDelete | 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 | 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);
} | [
"function",
"findOneAndDelete",
"(",
"coll",
",",
"filter",
",",
"options",
",",
"callback",
")",
"{",
"// Final options",
"const",
"finalOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
";",
"finalOptions",
".",
"fields",
"=",
"... | Find a document and delete it in one atomic operation. This requires a write lock for the duration of the operation.
@method
@param {Collection} a Collection instance.
@param {object} filter Document selection filter.
@param {object} [options] Optional settings. See Collection.prototype.findOneAndDelete for a list of ... | [
"Find",
"a",
"document",
"and",
"delete",
"it",
"in",
"one",
"atomic",
"operation",
".",
"This",
"requires",
"a",
"write",
"lock",
"for",
"the",
"duration",
"of",
"the",
"operation",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L611-L618 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | findOneAndReplace | 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 | 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... | [
"function",
"findOneAndReplace",
"(",
"coll",
",",
"filter",
",",
"replacement",
",",
"options",
",",
"callback",
")",
"{",
"// Final options",
"const",
"finalOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
";",
"finalOptions",
".... | Find a document and replace it in one atomic operation. This requires a write lock for the duration of the operation.
@method
@param {Collection} a Collection instance.
@param {object} filter Document selection filter.
@param {object} replacement Document replacing the matching document.
@param {object} [options] Opti... | [
"Find",
"a",
"document",
"and",
"replace",
"it",
"in",
"one",
"atomic",
"operation",
".",
"This",
"requires",
"a",
"write",
"lock",
"for",
"the",
"duration",
"of",
"the",
"operation",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L630-L640 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | geoHaystackSearch | 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 | 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... | [
"function",
"geoHaystackSearch",
"(",
"coll",
",",
"x",
",",
"y",
",",
"options",
",",
"callback",
")",
"{",
"// Build command object",
"let",
"commandObject",
"=",
"{",
"geoSearch",
":",
"coll",
".",
"s",
".",
"name",
",",
"near",
":",
"[",
"x",
",",
... | Execute a geo search using a geo haystack index on a collection.
@method
@param {Collection} a Collection instance.
@param {number} x Point to search on the x axis, ensure the indexes are ordered in the same order.
@param {number} y Point to search on the y axis, ensure the indexes are ordered in the same order.
@para... | [
"Execute",
"a",
"geo",
"search",
"using",
"a",
"geo",
"haystack",
"index",
"on",
"a",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L674-L699 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | group | 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 | 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... | [
"function",
"group",
"(",
"coll",
",",
"keys",
",",
"condition",
",",
"initial",
",",
"reduce",
",",
"finalize",
",",
"command",
",",
"options",
",",
"callback",
")",
"{",
"// Execute using the command",
"if",
"(",
"command",
")",
"{",
"const",
"reduceFuncti... | Run a group command across a collection.
@method
@param {Collection} a Collection instance.
@param {(object|array|function|code)} keys An object, array or function expressing the keys to group by.
@param {object} condition An optional condition that must be true for a row to be considered.
@param {object} initial Init... | [
"Run",
"a",
"group",
"command",
"across",
"a",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L716-L780 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | indexes | function indexes(coll, options, callback) {
options = Object.assign({}, { full: true }, options);
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | javascript | function indexes(coll, options, callback) {
options = Object.assign({}, { full: true }, options);
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | [
"function",
"indexes",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"full",
":",
"true",
"}",
",",
"options",
")",
";",
"indexInformationDb",
"(",
"coll",
".",
"s",
".",
"... | Retrieve all the indexes on the collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.indexes for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Retrieve",
"all",
"the",
"indexes",
"on",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L790-L793 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | indexExists | 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 | 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... | [
"function",
"indexExists",
"(",
"coll",
",",
"indexes",
",",
"options",
",",
"callback",
")",
"{",
"indexInformation",
"(",
"coll",
",",
"options",
",",
"(",
"err",
",",
"indexInformation",
")",
"=>",
"{",
"// If we have an error return",
"if",
"(",
"err",
"... | Check if one or more indexes exist on the collection. This fails on the first index that doesn't exist.
@method
@param {Collection} a Collection instance.
@param {(string|array)} indexes One or more index names to check.
@param {Object} [options] Optional settings. See Collection.prototype.indexExists for a list of op... | [
"Check",
"if",
"one",
"or",
"more",
"indexes",
"exist",
"on",
"the",
"collection",
".",
"This",
"fails",
"on",
"the",
"first",
"index",
"that",
"doesn",
"t",
"exist",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L804-L821 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | indexInformation | function indexInformation(coll, options, callback) {
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | javascript | function indexInformation(coll, options, callback) {
indexInformationDb(coll.s.db, coll.s.name, options, callback);
} | [
"function",
"indexInformation",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"indexInformationDb",
"(",
"coll",
".",
"s",
".",
"db",
",",
"coll",
".",
"s",
".",
"name",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Retrieve this collection's index info.
@method
@param {Collection} a Collection instance.
@param {object} [options] Optional settings. See Collection.prototype.indexInformation for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Retrieve",
"this",
"collection",
"s",
"index",
"info",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L831-L833 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | insertOne | 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 | 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... | [
"function",
"insertOne",
"(",
"coll",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"doc",
")",
")",
"{",
"return",
"callback",
"(",
"MongoError",
".",
"create",
"(",
"{",
"message",
":",
"'doc paramete... | Insert a single document into the collection. See Collection.prototype.insertOne for more information.
@method
@param {Collection} a Collection instance.
@param {object} doc Document to insert.
@param {object} [options] Optional settings. See Collection.prototype.insertOne for a list of options.
@param {Collection~ins... | [
"Insert",
"a",
"single",
"document",
"into",
"the",
"collection",
".",
"See",
"Collection",
".",
"prototype",
".",
"insertOne",
"for",
"more",
"information",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L876-L893 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | isCapped | function isCapped(coll, options, callback) {
optionsOp(coll, options, (err, document) => {
if (err) return handleCallback(callback, err);
handleCallback(callback, null, !!(document && document.capped));
});
} | javascript | function isCapped(coll, options, callback) {
optionsOp(coll, options, (err, document) => {
if (err) return handleCallback(callback, err);
handleCallback(callback, null, !!(document && document.capped));
});
} | [
"function",
"isCapped",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"optionsOp",
"(",
"coll",
",",
"options",
",",
"(",
"err",
",",
"document",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
... | Determine whether the collection is a capped collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.isCapped for a list of options.
@param {Collection~resultCallback} [callback] The results callback | [
"Determine",
"whether",
"the",
"collection",
"is",
"a",
"capped",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L954-L959 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | optionsOp | 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 | 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... | [
"function",
"optionsOp",
"(",
"coll",
",",
"opts",
",",
"callback",
")",
"{",
"coll",
".",
"s",
".",
"db",
".",
"listCollections",
"(",
"{",
"name",
":",
"coll",
".",
"s",
".",
"name",
"}",
",",
"opts",
")",
".",
"toArray",
"(",
"(",
"err",
",",
... | Return the options of the collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.options for a list of options.
@param {Collection~resultCallback} [callback] The results callback | [
"Return",
"the",
"options",
"of",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1083-L1095 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | parallelCollectionScan | 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 | 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... | [
"function",
"parallelCollectionScan",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"// Create command object",
"const",
"commandObject",
"=",
"{",
"parallelCollectionScan",
":",
"coll",
".",
"s",
".",
"name",
",",
"numCursors",
":",
"options",
".",
"n... | Return N parallel cursors for a collection to allow parallel reading of the entire collection. There are
no ordering guarantees for returned results.
@method
@param {Collection} a Collection instance.
@param {object} [options] Optional settings. See Collection.prototype.parallelCollectionScan for a list of options.
@p... | [
"Return",
"N",
"parallel",
"cursors",
"for",
"a",
"collection",
"to",
"allow",
"parallel",
"reading",
"of",
"the",
"entire",
"collection",
".",
"There",
"are",
"no",
"ordering",
"guarantees",
"for",
"returned",
"results",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1106-L1146 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | prepareDocs | 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 | 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 ... | [
"function",
"prepareDocs",
"(",
"coll",
",",
"docs",
",",
"options",
")",
"{",
"const",
"forceServerObjectId",
"=",
"typeof",
"options",
".",
"forceServerObjectId",
"===",
"'boolean'",
"?",
"options",
".",
"forceServerObjectId",
":",
"coll",
".",
"s",
".",
"db... | modifies documents before being inserted or updated | [
"modifies",
"documents",
"before",
"being",
"inserted",
"or",
"updated"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1149-L1167 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | processScope | 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 | 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... | [
"function",
"processScope",
"(",
"scope",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"scope",
")",
"||",
"scope",
".",
"_bsontype",
"===",
"'ObjectID'",
")",
"{",
"return",
"scope",
";",
"}",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"scope",
... | Functions that are passed as scope args must
be converted to Code instances.
@ignore | [
"Functions",
"that",
"are",
"passed",
"as",
"scope",
"args",
"must",
"be",
"converted",
"to",
"Code",
"instances",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1174-L1193 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | reIndex | 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 | 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 ... | [
"function",
"reIndex",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"// Reindex",
"const",
"cmd",
"=",
"{",
"reIndex",
":",
"coll",
".",
"s",
".",
"name",
"}",
";",
"// Execute the command",
"executeCommand",
"(",
"coll",
".",
"s",
".",
"db",
... | Reindex all indexes on the collection.
@method
@param {Collection} a Collection instance.
@param {Object} [options] Optional settings. See Collection.prototype.reIndex for a list of options.
@param {Collection~resultCallback} [callback] The command result callback | [
"Reindex",
"all",
"indexes",
"on",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1203-L1213 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | replaceOne | 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 | 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, ... | [
"function",
"replaceOne",
"(",
"coll",
",",
"filter",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"// Set single document update",
"options",
".",
"multi",
"=",
"false",
";",
"// Execute update",
"updateDocuments",
"(",
"coll",
",",
"filter",
",",
"... | Replace a document in the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the document to update
@param {object} doc The Document that replaces the matching document
@param {object} [options] Optional settings. See Collection.prototype.replaceOne for a li... | [
"Replace",
"a",
"document",
"in",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1319-L1341 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | save | 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 | 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 =... | [
"function",
"save",
"(",
"coll",
",",
"doc",
",",
"options",
",",
"callback",
")",
"{",
"// Get the write concern options",
"const",
"finalOptions",
"=",
"applyWriteConcern",
"(",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
",",
"{",
"db",
... | Save a document.
@method
@param {Collection} a Collection instance.
@param {object} doc Document to save
@param {object} [options] Optional settings. See Collection.prototype.save for a list of options.
@param {Collection~writeOpCallback} [callback] The command result callback
@deprecated use insertOne, insertMany, up... | [
"Save",
"a",
"document",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1353-L1373 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | stats | 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 | 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... | [
"function",
"stats",
"(",
"coll",
",",
"options",
",",
"callback",
")",
"{",
"// Build command object",
"const",
"commandObject",
"=",
"{",
"collStats",
":",
"coll",
".",
"s",
".",
"name",
"}",
";",
"// Check if we have the scale value",
"if",
"(",
"options",
... | Get all the collection statistics.
@method
@param {Collection} a Collection instance.
@param {object} [options] Optional settings. See Collection.prototype.stats for a list of options.
@param {Collection~resultCallback} [callback] The collection result callback | [
"Get",
"all",
"the",
"collection",
"statistics",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1383-L1398 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | updateMany | 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 | 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));
} | [
"function",
"updateMany",
"(",
"coll",
",",
"filter",
",",
"update",
",",
"options",
",",
"callback",
")",
"{",
"// Set single document update",
"options",
".",
"multi",
"=",
"true",
";",
"// Execute update",
"updateDocuments",
"(",
"coll",
",",
"filter",
",",
... | Update multiple documents in the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the documents to update
@param {object} update The update operations to be applied to the document
@param {object} [options] Optional settings. See Collection.prototype.updat... | [
"Update",
"multiple",
"documents",
"in",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1481-L1486 | train |
mongodb/node-mongodb-native | lib/operations/collection_ops.js | updateOne | 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 | 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));
} | [
"function",
"updateOne",
"(",
"coll",
",",
"filter",
",",
"update",
",",
"options",
",",
"callback",
")",
"{",
"// Set single document update",
"options",
".",
"multi",
"=",
"false",
";",
"// Execute update",
"updateDocuments",
"(",
"coll",
",",
"filter",
",",
... | Update a single document in the collection.
@method
@param {Collection} a Collection instance.
@param {object} filter The Filter used to select the document to update
@param {object} update The update operations to be applied to the document
@param {object} [options] Optional settings. See Collection.prototype.updateO... | [
"Update",
"a",
"single",
"document",
"in",
"the",
"collection",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/collection_ops.js#L1498-L1503 | train |
mongodb/node-mongodb-native | lib/topologies/topology_base.js | 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 | 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... | [
"function",
"(",
"topology",
",",
"storeOptions",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"storedOps",
"=",
"[",
"]",
";",
"storeOptions",
"=",
"storeOptions",
"||",
"{",
"force",
":",
"false",
",",
"bufferMaxEntries",
":",
"-",
"1",
"}",
";"... | The store of ops | [
"The",
"store",
"of",
"ops"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/topologies/topology_base.js#L11-L29 | train | |
mongodb/node-mongodb-native | lib/gridfs-stream/upload.js | GridFSBucketWriteStream | 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 | 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 ... | [
"function",
"GridFSBucketWriteStream",
"(",
"bucket",
",",
"filename",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"bucket",
"=",
"bucket",
";",
"this",
".",
"chunks",
"=",
"bucket",
".",
"s",
".",
"_chunksColle... | A writable stream that enables you to write buffers to GridFS.
Do not instantiate this class directly. Use `openUploadStream()` instead.
@class
@param {GridFSBucket} bucket Handle for this stream's corresponding bucket
@param {string} filename The value of the 'filename' key in the files doc
@param {object} [options]... | [
"A",
"writable",
"stream",
"that",
"enables",
"you",
"to",
"write",
"buffers",
"to",
"GridFS",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs-stream/upload.js#L33-L67 | train |
mongodb/node-mongodb-native | lib/utils.js | 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 | 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 ... | [
"function",
"(",
"options",
")",
"{",
"var",
"r",
"=",
"null",
";",
"if",
"(",
"options",
".",
"readPreference",
")",
"{",
"r",
"=",
"options",
".",
"readPreference",
";",
"}",
"else",
"{",
"return",
"options",
";",
"}",
"if",
"(",
"typeof",
"r",
"... | Figure out the read preference | [
"Figure",
"out",
"the",
"read",
"preference"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L13-L35 | train | |
mongodb/node-mongodb-native | lib/utils.js | function(obj, name, value) {
Object.defineProperty(obj, name, {
enumerable: true,
get: function() {
return value;
}
});
} | javascript | function(obj, name, value) {
Object.defineProperty(obj, name, {
enumerable: true,
get: function() {
return value;
}
});
} | [
"function",
"(",
"obj",
",",
"name",
",",
"value",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"obj",
",",
"name",
",",
"{",
"enumerable",
":",
"true",
",",
"get",
":",
"function",
"(",
")",
"{",
"return",
"value",
";",
"}",
"}",
")",
";",
"}... | Set simple property | [
"Set",
"simple",
"property"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L38-L45 | train | |
mongodb/node-mongodb-native | lib/utils.js | 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 | 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; ... | [
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
"instanceof",
"Error",
")",
"return",
"error",
";",
"var",
"msg",
"=",
"error",
".",
"err",
"||",
"error",
".",
"errmsg",
"||",
"error",
".",
"errMessage",
"||",
"error",
";",
"var",
"e",
"=",
... | Wrap a Mongo error document in an Error instance
@ignore
@api private | [
"Wrap",
"a",
"Mongo",
"error",
"document",
"in",
"an",
"Error",
"instance"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L145-L163 | train | |
mongodb/node-mongodb-native | lib/utils.js | 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 | 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... | [
"function",
"(",
"fieldOrSpec",
")",
"{",
"var",
"fieldHash",
"=",
"{",
"}",
";",
"var",
"indexes",
"=",
"[",
"]",
";",
"var",
"keys",
";",
"// Get all the fields accordingly",
"if",
"(",
"'string'",
"===",
"typeof",
"fieldOrSpec",
")",
"{",
"// 'type'",
"... | Create index name based on field spec
@ignore
@api private | [
"Create",
"index",
"name",
"based",
"on",
"field",
"spec"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L195-L240 | train | |
mongodb/node-mongodb-native | lib/utils.js | 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 | 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... | [
"function",
"(",
"target",
",",
"source",
")",
"{",
"var",
"translations",
"=",
"{",
"// SSL translation options",
"sslCA",
":",
"'ca'",
",",
"sslCRL",
":",
"'crl'",
",",
"sslValidate",
":",
"'rejectUnauthorized'",
",",
"sslKey",
":",
"'key'",
",",
"sslCert",
... | Merge options with translation | [
"Merge",
"options",
"with",
"translation"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L272-L302 | train | |
mongodb/node-mongodb-native | lib/utils.js | 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 | 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 (... | [
"function",
"(",
"targetOptions",
",",
"sourceOptions",
",",
"keys",
",",
"mergeWriteConcern",
")",
"{",
"// Mix in any allowed options",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
... | Merge the write concern options | [
"Merge",
"the",
"write",
"concern",
"options"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L319-L348 | train | |
mongodb/node-mongodb-native | lib/utils.js | applyWriteConcern | 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 | 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... | [
"function",
"applyWriteConcern",
"(",
"target",
",",
"sources",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"const",
"db",
"=",
"sources",
".",
"db",
";",
"const",
"coll",
"=",
"sources",
".",
"collection",
";",
"if",
"(",... | Applies a write concern to a command based on well defined inheritance rules, optionally
detecting support for the write concern in the first place.
@param {Object} target the target command we will be applying the write concern to
@param {Object} sources sources where we can inherit default write concerns from
@param... | [
"Applies",
"a",
"write",
"concern",
"to",
"a",
"command",
"based",
"on",
"well",
"defined",
"inheritance",
"rules",
"optionally",
"detecting",
"support",
"for",
"the",
"write",
"concern",
"in",
"the",
"first",
"place",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L463-L501 | train |
mongodb/node-mongodb-native | lib/utils.js | deprecateOptions | 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 | 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 ... | [
"function",
"deprecateOptions",
"(",
"config",
",",
"fn",
")",
"{",
"if",
"(",
"process",
".",
"noDeprecation",
"===",
"true",
")",
"{",
"return",
"fn",
";",
"}",
"const",
"msgHandler",
"=",
"config",
".",
"msgHandler",
"?",
"config",
".",
"msgHandler",
... | Deprecates a given function's options.
@param {object} config configuration for deprecation
@param {string} config.name function name
@param {Array} config.deprecatedOptions options to deprecate
@param {number} config.optionsIndex index of options object in function arguments array
@param {function} [config.msgHandler... | [
"Deprecates",
"a",
"given",
"function",
"s",
"options",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/utils.js#L647-L691 | train |
mongodb/node-mongodb-native | lib/operations/cursor_ops.js | count | 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 | 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... | [
"function",
"count",
"(",
"cursor",
",",
"applySkipLimit",
",",
"opts",
",",
"callback",
")",
"{",
"if",
"(",
"applySkipLimit",
")",
"{",
"if",
"(",
"typeof",
"cursor",
".",
"cursorSkip",
"(",
")",
"===",
"'number'",
")",
"opts",
".",
"skip",
"=",
"cur... | Get the count of documents for this cursor.
@method
@param {Cursor} cursor The Cursor instance on which to count.
@param {boolean} [applySkipLimit=true] Specifies whether the count command apply limit and skip settings should be applied on the cursor or in the provided options.
@param {object} [options] Optional setti... | [
"Get",
"the",
"count",
"of",
"documents",
"for",
"this",
"cursor",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/cursor_ops.js#L26-L74 | train |
mongodb/node-mongodb-native | lib/operations/cursor_ops.js | each | 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 | 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... | [
"function",
"each",
"(",
"cursor",
",",
"callback",
")",
"{",
"let",
"Cursor",
"=",
"loadCursor",
"(",
")",
";",
"if",
"(",
"!",
"callback",
")",
"throw",
"MongoError",
".",
"create",
"(",
"{",
"message",
":",
"'callback is mandatory'",
",",
"driver",
":... | Iterates over all the documents for this cursor. See Cursor.prototype.each for more information.
@method
@deprecated
@param {Cursor} cursor The Cursor instance on which to run.
@param {Cursor~resultCallback} callback The result callback. | [
"Iterates",
"over",
"all",
"the",
"documents",
"for",
"this",
"cursor",
".",
"See",
"Cursor",
".",
"prototype",
".",
"each",
"for",
"more",
"information",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/cursor_ops.js#L84-L115 | train |
mongodb/node-mongodb-native | lib/operations/cursor_ops.js | next | 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 | 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);
} | [
"function",
"next",
"(",
"cursor",
",",
"callback",
")",
"{",
"// Return the currentDoc if someone called hasNext first",
"if",
"(",
"cursor",
".",
"s",
".",
"currentDoc",
")",
"{",
"const",
"doc",
"=",
"cursor",
".",
"s",
".",
"currentDoc",
";",
"cursor",
"."... | Get the next available document from the cursor. Returns null if no more documents are available.
@method
@param {Cursor} cursor The Cursor instance from which to get the next document.
@param {Cursor~resultCallback} [callback] The result callback. | [
"Get",
"the",
"next",
"available",
"document",
"from",
"the",
"cursor",
".",
"Returns",
"null",
"if",
"no",
"more",
"documents",
"are",
"available",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/cursor_ops.js#L162-L172 | train |
mongodb/node-mongodb-native | lib/gridfs/chunk.js | 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 | 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... | [
"function",
"(",
"file",
",",
"mongoObject",
",",
"writeConcern",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Chunk",
")",
")",
"return",
"new",
"Chunk",
"(",
"file",
",",
"mongoObject",
")",
";",
"this",
".",
"file",
"=",
"file",
";",
"var... | Class for representing a single chunk in GridFS.
@class
@param file {GridStore} The {@link GridStore} object holding this chunk.
@param mongoObject {object} The mongo object representation of this chunk.
@throws Error when the type of data field for {@link mongoObject} is not
supported. Currently supported types for... | [
"Class",
"for",
"representing",
"a",
"single",
"chunk",
"in",
"GridFS",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/chunk.js#L23-L50 | train | |
mongodb/node-mongodb-native | lib/command_cursor.js | 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 | 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;
... | [
"function",
"(",
"bson",
",",
"ns",
",",
"cmd",
",",
"options",
",",
"topology",
",",
"topologyOptions",
")",
"{",
"CoreCursor",
".",
"apply",
"(",
"this",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
")... | Namespace provided by the browser.
@external Readable
Creates a new Command Cursor instance (INTERNAL TYPE, do not instantiate directly)
@class CommandCursor
@extends external:Readable
@fires CommandCursor#data
@fires CommandCursor#end
@fires CommandCursor#close
@fires CommandCursor#readable
@return {CommandCursor} a... | [
"Namespace",
"provided",
"by",
"the",
"browser",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/command_cursor.js#L57-L96 | train | |
mongodb/node-mongodb-native | lib/gridfs/grid_store.js | 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 | 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... | [
"function",
"(",
"self",
",",
"callback",
")",
"{",
"// Calcuate the length",
"var",
"mongoObject",
"=",
"{",
"_id",
":",
"self",
".",
"fileId",
",",
"filename",
":",
"self",
".",
"filename",
",",
"contentType",
":",
"self",
".",
"contentType",
",",
"lengt... | Creates a mongoDB object representation of this object.
<pre><code>
{
'_id' : , // {number} id for this file
'filename' : , // {string} name for this file
'contentType' : , // {string} mime type for this file
'length' : , // {number} size of this file?
'chunksize' : , // {number} chunk size used by this file
'uploadDa... | [
"Creates",
"a",
"mongoDB",
"object",
"representation",
"of",
"this",
"object",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/grid_store.js#L1155-L1175 | train | |
mongodb/node-mongodb-native | lib/gridfs/grid_store.js | 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 | 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... | [
"function",
"(",
"self",
",",
"chunkNumber",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"options",
"=",
"options",
"||",... | Gets the nth chunk of this file.
@ignore | [
"Gets",
"the",
"nth",
"chunk",
"of",
"this",
"file",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/grid_store.js#L1181-L1198 | train | |
mongodb/node-mongodb-native | lib/gridfs/grid_store.js | 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 | 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... | [
"function",
"(",
"self",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"options",
"=",
"options",
"||",
"self",
".",
"wri... | Deletes all the chunks of this file in the database.
@ignore | [
"Deletes",
"all",
"the",
"chunks",
"of",
"this",
"file",
"in",
"the",
"database",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs/grid_store.js#L1212-L1228 | train | |
mongodb/node-mongodb-native | lib/gridfs-stream/download.js | GridFSBucketReadStream | 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 | 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
};... | [
"function",
"GridFSBucketReadStream",
"(",
"chunks",
",",
"files",
",",
"readPreference",
",",
"filter",
",",
"options",
")",
"{",
"this",
".",
"s",
"=",
"{",
"bytesRead",
":",
"0",
",",
"chunks",
":",
"chunks",
",",
"cursor",
":",
"null",
",",
"expected... | A readable stream that enables you to read buffers from GridFS.
Do not instantiate this class directly. Use `openDownloadStream()` instead.
@class
@param {Collection} chunks Handle for chunks collection
@param {Collection} files Handle for files collection
@param {Object} readPreference The read preference to use
@pa... | [
"A",
"readable",
"stream",
"that",
"enables",
"you",
"to",
"read",
"buffers",
"from",
"GridFS",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/gridfs-stream/download.js#L28-L44 | train |
mongodb/node-mongodb-native | lib/operations/admin_ops.js | replSetGetStatus | function replSetGetStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { replSetGetStatus: 1 }, options, callback);
} | javascript | function replSetGetStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { replSetGetStatus: 1 }, options, callback);
} | [
"function",
"replSetGetStatus",
"(",
"admin",
",",
"options",
",",
"callback",
")",
"{",
"executeDbAdminCommand",
"(",
"admin",
".",
"s",
".",
"db",
",",
"{",
"replSetGetStatus",
":",
"1",
"}",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Get ReplicaSet status
@param {Admin} a collection instance.
@param {Object} [options] Optional settings. See Admin.prototype.replSetGetStatus for a list of options.
@param {Admin~resultCallback} [callback] The command result callback. | [
"Get",
"ReplicaSet",
"status"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/admin_ops.js#L13-L15 | train |
mongodb/node-mongodb-native | lib/operations/admin_ops.js | serverStatus | function serverStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { serverStatus: 1 }, options, callback);
} | javascript | function serverStatus(admin, options, callback) {
executeDbAdminCommand(admin.s.db, { serverStatus: 1 }, options, callback);
} | [
"function",
"serverStatus",
"(",
"admin",
",",
"options",
",",
"callback",
")",
"{",
"executeDbAdminCommand",
"(",
"admin",
".",
"s",
".",
"db",
",",
"{",
"serverStatus",
":",
"1",
"}",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Retrieve this db's server status.
@param {Admin} a collection instance.
@param {Object} [options] Optional settings. See Admin.prototype.serverStatus for a list of options.
@param {Admin~resultCallback} [callback] The command result callback | [
"Retrieve",
"this",
"db",
"s",
"server",
"status",
"."
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/admin_ops.js#L24-L26 | train |
mongodb/node-mongodb-native | lib/operations/admin_ops.js | validateCollection | 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 | 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... | [
"function",
"validateCollection",
"(",
"admin",
",",
"collectionName",
",",
"options",
",",
"callback",
")",
"{",
"const",
"command",
"=",
"{",
"validate",
":",
"collectionName",
"}",
";",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"options",
")",
"... | Validate an existing collection
@param {Admin} a collection instance.
@param {string} collectionName The name of the collection to validate.
@param {Object} [options] Optional settings. See Admin.prototype.validateCollection for a list of options.
@param {Admin~resultCallback} [callback] The command result callback. | [
"Validate",
"an",
"existing",
"collection"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/admin_ops.js#L36-L60 | train |
mongodb/node-mongodb-native | lib/operations/mongo_client_ops.js | collectEvents | 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 | 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... | [
"function",
"collectEvents",
"(",
"mongoClient",
",",
"topology",
")",
"{",
"let",
"MongoClient",
"=",
"loadClient",
"(",
")",
";",
"const",
"collectedEvents",
"=",
"[",
"]",
";",
"if",
"(",
"mongoClient",
"instanceof",
"MongoClient",
")",
"{",
"monitoringEven... | Collect all events in order from SDAM | [
"Collect",
"all",
"events",
"in",
"order",
"from",
"SDAM"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/mongo_client_ops.js#L144-L161 | train |
mongodb/node-mongodb-native | lib/operations/mongo_client_ops.js | replayEvents | function replayEvents(mongoClient, events) {
for (let i = 0; i < events.length; i++) {
mongoClient.emit(events[i].event, events[i].object1, events[i].object2);
}
} | javascript | function replayEvents(mongoClient, events) {
for (let i = 0; i < events.length; i++) {
mongoClient.emit(events[i].event, events[i].object1, events[i].object2);
}
} | [
"function",
"replayEvents",
"(",
"mongoClient",
",",
"events",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"events",
".",
"length",
";",
"i",
"++",
")",
"{",
"mongoClient",
".",
"emit",
"(",
"events",
"[",
"i",
"]",
".",
"event",
"... | Replay any events due to single server connection switching to Mongos | [
"Replay",
"any",
"events",
"due",
"to",
"single",
"server",
"connection",
"switching",
"to",
"Mongos"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/operations/mongo_client_ops.js#L502-L506 | train |
mongodb/node-mongodb-native | lib/mongo_client.js | MongoClient | 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 | 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... | [
"function",
"MongoClient",
"(",
"url",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"MongoClient",
")",
")",
"return",
"new",
"MongoClient",
"(",
"url",
",",
"options",
")",
";",
"// Set up event emitter",
"EventEmitter",
".",
"call",... | A string specifying the level of a ReadConcern
@typedef {'local'|'available'|'majority'|'linearizable'|'snapshot'} ReadConcernLevel
@see https://docs.mongodb.com/manual/reference/read-concern/index.html#read-concern-levels
Creates a new MongoClient instance
@class
@param {string} url The connection URI string
@param ... | [
"A",
"string",
"specifying",
"the",
"level",
"of",
"a",
"ReadConcern"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/mongo_client.js#L123-L142 | train |
mongodb/node-mongodb-native | lib/db.js | Db | 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 | 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... | [
"function",
"Db",
"(",
"databaseName",
",",
"topology",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Db",
")",
")",
"return",
"new",
"Db",
"(",
"databaseName",
",",
"topology",
... | Creates a new Db instance
@class
@param {string} databaseName The name of the database this instance represents.
@param {(Server|ReplSet|Mongos)} topology The server topology for the database.
@param {object} [options] Optional settings.
@param {string} [options.authSource] If the database authentication is dependent o... | [
"Creates",
"a",
"new",
"Db",
"instance"
] | 0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5 | https://github.com/mongodb/node-mongodb-native/blob/0afbbccf1bd7d437610c33cbd5523f01bc6bc6e5/lib/db.js#L133-L202 | train |
reduxjs/redux-devtools | packages/react-json-tree/src/JSONIterableNode.js | createItemString | 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 | 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;
... | [
"function",
"createItemString",
"(",
"data",
",",
"limit",
")",
"{",
"let",
"count",
"=",
"0",
";",
"let",
"hasMore",
"=",
"false",
";",
"if",
"(",
"Number",
".",
"isSafeInteger",
"(",
"data",
".",
"size",
")",
")",
"{",
"count",
"=",
"data",
".",
... | Returns the "n Items" string for this node, generating and caching it if it hasn't been created yet. | [
"Returns",
"the",
"n",
"Items",
"string",
"for",
"this",
"node",
"generating",
"and",
"caching",
"it",
"if",
"it",
"hasn",
"t",
"been",
"created",
"yet",
"."
] | 03d1448dc3c47ffd75a8cf07f21399b86d557988 | https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/react-json-tree/src/JSONIterableNode.js#L6-L22 | train |
reduxjs/redux-devtools | packages/redux-devtools-instrument/src/instrument.js | computeWithTryCatch | 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 | 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 ... | [
"function",
"computeWithTryCatch",
"(",
"reducer",
",",
"action",
",",
"state",
")",
"{",
"let",
"nextState",
"=",
"state",
";",
"let",
"nextError",
";",
"try",
"{",
"nextState",
"=",
"reducer",
"(",
"state",
",",
"action",
")",
";",
"}",
"catch",
"(",
... | Computes the next entry with exceptions catching. | [
"Computes",
"the",
"next",
"entry",
"with",
"exceptions",
"catching",
"."
] | 03d1448dc3c47ffd75a8cf07f21399b86d557988 | https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/redux-devtools-instrument/src/instrument.js#L153-L174 | train |
reduxjs/redux-devtools | packages/redux-devtools-instrument/src/instrument.js | computeNextEntry | function computeNextEntry(reducer, action, state, shouldCatchErrors) {
if (!shouldCatchErrors) {
return { state: reducer(state, action) };
}
return computeWithTryCatch(reducer, action, state);
} | javascript | function computeNextEntry(reducer, action, state, shouldCatchErrors) {
if (!shouldCatchErrors) {
return { state: reducer(state, action) };
}
return computeWithTryCatch(reducer, action, state);
} | [
"function",
"computeNextEntry",
"(",
"reducer",
",",
"action",
",",
"state",
",",
"shouldCatchErrors",
")",
"{",
"if",
"(",
"!",
"shouldCatchErrors",
")",
"{",
"return",
"{",
"state",
":",
"reducer",
"(",
"state",
",",
"action",
")",
"}",
";",
"}",
"retu... | Computes the next entry in the log by applying an action. | [
"Computes",
"the",
"next",
"entry",
"in",
"the",
"log",
"by",
"applying",
"an",
"action",
"."
] | 03d1448dc3c47ffd75a8cf07f21399b86d557988 | https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/redux-devtools-instrument/src/instrument.js#L179-L184 | train |
reduxjs/redux-devtools | packages/redux-devtools-instrument/src/instrument.js | recomputeStates | 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 | 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... | [
"function",
"recomputeStates",
"(",
"computedStates",
",",
"minInvalidatedStateIndex",
",",
"reducer",
",",
"committedState",
",",
"actionsById",
",",
"stagedActionIds",
",",
"skippedActionIds",
",",
"shouldCatchErrors",
")",
"{",
"// Optimization: exit early and return the s... | Runs the reducer on invalidated actions to get a fresh computation log. | [
"Runs",
"the",
"reducer",
"on",
"invalidated",
"actions",
"to",
"get",
"a",
"fresh",
"computation",
"log",
"."
] | 03d1448dc3c47ffd75a8cf07f21399b86d557988 | https://github.com/reduxjs/redux-devtools/blob/03d1448dc3c47ffd75a8cf07f21399b86d557988/packages/redux-devtools-instrument/src/instrument.js#L189-L241 | train |
CreateJS/PreloadJS | lib/preloadjs.js | AbstractMediaLoader | 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 | 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);
} | [
"function",
"AbstractMediaLoader",
"(",
"loadItem",
",",
"preferXHR",
",",
"type",
")",
"{",
"this",
".",
"AbstractLoader_constructor",
"(",
"loadItem",
",",
"preferXHR",
",",
"type",
")",
";",
"// public properties",
"this",
".",
"resultFormatter",
"=",
"this",
... | constructor
The AbstractMediaLoader is a base class that handles some of the shared methods and properties of loaders that
handle HTML media elements, such as Video and Audio.
@class AbstractMediaLoader
@param {LoadItem|Object} loadItem
@param {Boolean} preferXHR
@param {String} type The type of media to load. Usually... | [
"constructor",
"The",
"AbstractMediaLoader",
"is",
"a",
"base",
"class",
"that",
"handles",
"some",
"of",
"the",
"shared",
"methods",
"and",
"properties",
"of",
"loaders",
"that",
"handle",
"HTML",
"media",
"elements",
"such",
"as",
"Video",
"and",
"Audio",
".... | eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083 | https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L3429-L3439 | train |
CreateJS/PreloadJS | lib/preloadjs.js | XHRRequest | 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 | 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... | [
"function",
"XHRRequest",
"(",
"item",
")",
"{",
"this",
".",
"AbstractRequest_constructor",
"(",
"item",
")",
";",
"// protected properties",
"/**\n\t\t * A reference to the XHR request used to load the content.\n\t\t * @property _request\n\t\t * @type {XMLHttpRequest | XDomainRequest |... | constructor
A preloader that loads items using XHR requests, usually XMLHttpRequest. However XDomainRequests will be used
for cross-domain requests if possible, and older versions of IE fall back on to ActiveX objects when necessary.
XHR requests load the content as text or binary data, provide progress and consistent... | [
"constructor",
"A",
"preloader",
"that",
"loads",
"items",
"using",
"XHR",
"requests",
"usually",
"XMLHttpRequest",
".",
"However",
"XDomainRequests",
"will",
"be",
"used",
"for",
"cross",
"-",
"domain",
"requests",
"if",
"possible",
"and",
"older",
"versions",
... | eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083 | https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L3839-L3903 | train |
CreateJS/PreloadJS | lib/preloadjs.js | LoadQueue | 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 | 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 ... | [
"function",
"LoadQueue",
"(",
"preferXHR",
",",
"basePath",
",",
"crossOrigin",
")",
"{",
"this",
".",
"AbstractLoader_constructor",
"(",
")",
";",
"/**\n\t\t * An array of the plugins registered using {{#crossLink \"LoadQueue/installPlugin\"}}{{/crossLink}}.\n\t\t * @property _plugi... | constructor
The LoadQueue class is the main API for preloading content. LoadQueue is a load manager, which can preload either
a single file, or queue of files.
<b>Creating a Queue</b><br />
To use LoadQueue, create a LoadQueue instance. If you want to force tag loading where possible, set the preferXHR
argument to fa... | [
"constructor",
"The",
"LoadQueue",
"class",
"is",
"the",
"main",
"API",
"for",
"preloading",
"content",
".",
"LoadQueue",
"is",
"a",
"load",
"manager",
"which",
"can",
"preload",
"either",
"a",
"single",
"file",
"or",
"queue",
"of",
"files",
"."
] | eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083 | https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L4542-L4677 | train |
CreateJS/PreloadJS | lib/preloadjs.js | BinaryLoader | function BinaryLoader(loadItem) {
this.AbstractLoader_constructor(loadItem, true, createjs.Types.BINARY);
this.on("initialize", this._updateXHR, this);
} | javascript | function BinaryLoader(loadItem) {
this.AbstractLoader_constructor(loadItem, true, createjs.Types.BINARY);
this.on("initialize", this._updateXHR, this);
} | [
"function",
"BinaryLoader",
"(",
"loadItem",
")",
"{",
"this",
".",
"AbstractLoader_constructor",
"(",
"loadItem",
",",
"true",
",",
"createjs",
".",
"Types",
".",
"BINARY",
")",
";",
"this",
".",
"on",
"(",
"\"initialize\"",
",",
"this",
".",
"_updateXHR",
... | constructor
A loader for binary files. This is useful for loading web audio, or content that requires an ArrayBuffer.
@class BinaryLoader
@param {LoadItem|Object} loadItem
@extends AbstractLoader
@constructor | [
"constructor",
"A",
"loader",
"for",
"binary",
"files",
".",
"This",
"is",
"useful",
"for",
"loading",
"web",
"audio",
"or",
"content",
"that",
"requires",
"an",
"ArrayBuffer",
"."
] | eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083 | https://github.com/CreateJS/PreloadJS/blob/eab00cf50fe2f6993c75e04ad7f7e5e9c9e9f083/lib/preloadjs.js#L6129-L6132 | train |
sockjs/sockjs-client | lib/utils/escape.js | 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 | 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... | [
"function",
"(",
"escapable",
")",
"{",
"var",
"i",
";",
"var",
"unrolled",
"=",
"{",
"}",
";",
"var",
"c",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"65536",
";",
"i",
"++",
")",
"{",
"c",
".",
"push",
"(",
"String",
... | This may be quite slow, so let's delay until user actually uses bad characters. | [
"This",
"may",
"be",
"quite",
"slow",
"so",
"let",
"s",
"delay",
"until",
"user",
"actually",
"uses",
"bad",
"characters",
"."
] | 477e30d4d1ba61d9d995c991aef89627c1c14aed | https://github.com/sockjs/sockjs-client/blob/477e30d4d1ba61d9d995c991aef89627c1c14aed/lib/utils/escape.js#L13-L27 | train | |
glidejs/glide | dist/glide.esm.js | mount | 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 | 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 ... | [
"function",
"mount",
"(",
"glide",
",",
"extensions",
",",
"events",
")",
"{",
"var",
"components",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"name",
"in",
"extensions",
")",
"{",
"if",
"(",
"isFunction",
"(",
"extensions",
"[",
"name",
"]",
")",
")",
... | Creates and initializes specified collection of extensions.
Each extension receives access to instance of glide and rest of components.
@param {Object} glide
@param {Object} extensions
@returns {Object} | [
"Creates",
"and",
"initializes",
"specified",
"collection",
"of",
"extensions",
".",
"Each",
"extension",
"receives",
"access",
"to",
"instance",
"of",
"glide",
"and",
"rest",
"of",
"components",
"."
] | 593ad78d0f85bd7bcb6ac6ef487c607718605a89 | https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L408-L426 | train |
glidejs/glide | dist/glide.esm.js | sortKeys | function sortKeys(obj) {
return Object.keys(obj).sort().reduce(function (r, k) {
r[k] = obj[k];
return r[k], r;
}, {});
} | javascript | function sortKeys(obj) {
return Object.keys(obj).sort().reduce(function (r, k) {
r[k] = obj[k];
return r[k], r;
}, {});
} | [
"function",
"sortKeys",
"(",
"obj",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"sort",
"(",
")",
".",
"reduce",
"(",
"function",
"(",
"r",
",",
"k",
")",
"{",
"r",
"[",
"k",
"]",
"=",
"obj",
"[",
"k",
"]",
";",
"return",... | Sorts aphabetically object keys.
@param {Object} obj
@return {Object} | [
"Sorts",
"aphabetically",
"object",
"keys",
"."
] | 593ad78d0f85bd7bcb6ac6ef487c607718605a89 | https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L446-L452 | train |
glidejs/glide | dist/glide.esm.js | mergeOptions | 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 | 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... | [
"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 objec... | Merges passed settings object with default options.
@param {Object} defaults
@param {Object} settings
@return {Object} | [
"Merges",
"passed",
"settings",
"object",
"with",
"default",
"options",
"."
] | 593ad78d0f85bd7bcb6ac6ef487c607718605a89 | https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L461-L482 | train |
glidejs/glide | dist/glide.esm.js | EventsBus | function EventsBus() {
var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
classCallCheck(this, EventsBus);
this.events = events;
this.hop = events.hasOwnProperty;
} | javascript | function EventsBus() {
var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
classCallCheck(this, EventsBus);
this.events = events;
this.hop = events.hasOwnProperty;
} | [
"function",
"EventsBus",
"(",
")",
"{",
"var",
"events",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"classCallCheck",
"(",
"this",
",",
"Events... | Construct a EventBus instance.
@param {Object} events | [
"Construct",
"a",
"EventBus",
"instance",
"."
] | 593ad78d0f85bd7bcb6ac6ef487c607718605a89 | https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L490-L496 | train |
glidejs/glide | dist/glide.esm.js | Glide | 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 | 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... | [
"function",
"Glide",
"(",
"selector",
")",
"{",
"var",
"options",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"{",
"}",
";",
"classCallCheck",
"(",
"this",
","... | Construct glide.
@param {String} selector
@param {Object} options | [
"Construct",
"glide",
"."
] | 593ad78d0f85bd7bcb6ac6ef487c607718605a89 | https://github.com/glidejs/glide/blob/593ad78d0f85bd7bcb6ac6ef487c607718605a89/dist/glide.esm.js#L568-L580 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.