mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge branch 'jankapunkt-patch-2' into release-2.6.1
This commit is contained in:
@@ -486,10 +486,16 @@ EJSON.equals = (a, b, options) => {
|
||||
return b.equals(a, options);
|
||||
}
|
||||
|
||||
if (a instanceof Array) {
|
||||
if (!(b instanceof Array)) {
|
||||
return false;
|
||||
}
|
||||
// Array.isArray works across iframes while instanceof won't
|
||||
const aIsArray = Array.isArray(a);
|
||||
const bIsArray = Array.isArray(b);
|
||||
|
||||
// if not both or none are array they are not equal
|
||||
if (aIsArray !== bIsArray) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aIsArray && bIsArray) {
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,14 @@ Tinytest.add('ejson - some equality tests', test => {
|
||||
test.isFalse(EJSON.equals({a: 1, b: 2, c: 3}, {a: 1, c: 3, b: 4}));
|
||||
test.isFalse(EJSON.equals({a: {}}, {a: {b: 2}}));
|
||||
test.isFalse(EJSON.equals({a: {b: 2}}, {a: {}}));
|
||||
// XXX: Object and Array were previously mistaken, which is why
|
||||
// we add some extra tests for them here
|
||||
test.isTrue(EJSON.equals([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]));
|
||||
test.isFalse(EJSON.equals([1, 2, 3, 4, 5], [1, 2, 3, 4]));
|
||||
test.isFalse(EJSON.equals([1,2,3,4], {0: 1, 1: 2, 2: 3, 3: 4}));
|
||||
test.isFalse(EJSON.equals({0: 1, 1: 2, 2: 3, 3: 4}, [1,2,3,4]));
|
||||
test.isFalse(EJSON.equals({}, []));
|
||||
test.isFalse(EJSON.equals([], {}));
|
||||
});
|
||||
|
||||
Tinytest.add('ejson - equality and falsiness', test => {
|
||||
|
||||
@@ -94,12 +94,11 @@ function flattenObject(ob) {
|
||||
for (const i in ob) {
|
||||
if (!ob.hasOwnProperty(i)) continue;
|
||||
|
||||
if (typeof ob[i] == 'object' && ob[i] !== null) {
|
||||
if (!Array.isArray(ob[i]) && typeof ob[i] == 'object' && ob[i] !== null) {
|
||||
const flatObject = flattenObject(ob[i]);
|
||||
if(Object.keys(flatObject).length === 0) { return ob; }
|
||||
for (const x in flatObject) {
|
||||
if (!flatObject.hasOwnProperty(x)) continue;
|
||||
|
||||
let objectKeys = Object.keys(flatObject);
|
||||
if(objectKeys.length === 0) { return ob; }
|
||||
for (const x of objectKeys) {
|
||||
toReturn[i + '.' + x] = flatObject[x];
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -98,6 +98,12 @@ Tinytest.add('oplog - v2/v1 conversion', function(test) {
|
||||
JSON.stringify({ $v: 2, $set: { 'services.resume.loginTokens': [] } })
|
||||
);
|
||||
|
||||
const entry91 = { "$v" : 2, "diff" : { "i" : { "tShirt" : { "sizes" : [ "small", "medium", "large" ] } } } };
|
||||
test.equal(
|
||||
JSON.stringify(oplogV2V1Converter(entry91)),
|
||||
JSON.stringify({ $v: 2, $set: { "tShirt.sizes" : [ "small", "medium", "large" ] } })
|
||||
);
|
||||
|
||||
const entry10 = {
|
||||
$v: 2,
|
||||
$set: {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
Package.describe({
|
||||
summary: "Adaptor for using MongoDB and Minimongo over DDP",
|
||||
version: '1.14.1'
|
||||
version: '1.14.2'
|
||||
});
|
||||
|
||||
Npm.depends({
|
||||
|
||||
Reference in New Issue
Block a user