Commit
This commit is contained in:
commit
d1c8cae2c1
1417 changed files with 326736 additions and 0 deletions
32
node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js
generated
vendored
Normal file
32
node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Compares two index specifications to determine if they are equal.
|
||||
*
|
||||
* #### Example:
|
||||
* isIndexSpecEqual({ a: 1, b: 1 }, { a: 1, b: 1 }); // true
|
||||
* isIndexSpecEqual({ a: 1, b: 1 }, { b: 1, a: 1 }); // false
|
||||
* isIndexSpecEqual({ a: 1, b: -1 }, { a: 1, b: 1 }); // false
|
||||
*
|
||||
* @param {Object} spec1 The first index specification to compare.
|
||||
* @param {Object} spec2 The second index specification to compare.
|
||||
* @returns {Boolean} Returns true if the index specifications are equal, otherwise returns false.
|
||||
*/
|
||||
|
||||
module.exports = function isIndexSpecEqual(spec1, spec2) {
|
||||
const spec1Keys = Object.keys(spec1);
|
||||
const spec2Keys = Object.keys(spec2);
|
||||
|
||||
if (spec1Keys.length !== spec2Keys.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < spec1Keys.length; i++) {
|
||||
const key = spec1Keys[i];
|
||||
if (key !== spec2Keys[i] || spec1[key] !== spec2[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue