Skip to content

Commit

Permalink
Fix order of sort operation
Browse files Browse the repository at this point in the history
  • Loading branch information
erikolson186 committed Aug 24, 2017
1 parent 3d15946 commit e7222d5
Show file tree
Hide file tree
Showing 12 changed files with 4,679 additions and 3,727 deletions.
2 changes: 1 addition & 1 deletion build/src/collection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

Expand Down
4 changes: 2 additions & 2 deletions build/src/create_next_fn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

Expand Down Expand Up @@ -329,7 +329,7 @@ var initSort = function initSort(config) {
if (new_clauses.length) {
config.clauses = new_clauses;
} else {
pipeline.push([sort, spec]);
pipeline.unshift([sort, spec]);
}
};

Expand Down
2 changes: 1 addition & 1 deletion build/src/db.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

Expand Down
2 changes: 1 addition & 1 deletion build/src/group.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };

Expand Down
2 changes: 1 addition & 1 deletion build/src/project.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

Expand Down
49 changes: 18 additions & 31 deletions build/src/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ var unknownOp = _require.unknownOp;
var getIDBError = _require.getIDBError;


var $set = function $set(path_pieces, value) {
var ops = {};

ops.$set = function (path_pieces, value) {
return function (doc) {
set(doc, path_pieces, value);
};
};

var $unset = function $unset(path_pieces) {
ops.$unset = function (path_pieces) {
return function (doc) {
return remove1(doc, path_pieces);
};
};

var $rename = function $rename(path_pieces, new_name) {
ops.$rename = function (path_pieces, new_name) {
return function (doc) {
rename(doc, path_pieces, new_name);
};
Expand Down Expand Up @@ -55,10 +57,10 @@ var arithOp = function arithOp(fn) {
};
};

var $inc = arithOp(function (a, b) {
ops.$inc = arithOp(function (a, b) {
return a + b;
});
var $mul = arithOp(function (a, b) {
ops.$mul = arithOp(function (a, b) {
return a * b;
});

Expand All @@ -78,14 +80,14 @@ var compareOp = function compareOp(fn) {
};
};

var $min = compareOp(function (a, b) {
ops.$min = compareOp(function (a, b) {
return a < b;
});
var $max = compareOp(function (a, b) {
ops.$max = compareOp(function (a, b) {
return a > b;
});

var $push = function $push(path_pieces, value) {
ops.$push = function (path_pieces, value) {
var update = function update(obj, field) {
var elements = obj[field];

Expand All @@ -101,7 +103,7 @@ var $push = function $push(path_pieces, value) {
return modifyOp(path_pieces, update, init);
};

var $pop = function $pop(path_pieces, direction) {
ops.$pop = function (path_pieces, direction) {
var pop = void 0;

if (direction < 1) {
Expand All @@ -125,7 +127,7 @@ var $pop = function $pop(path_pieces, direction) {
};
};

var $pullAll = function $pullAll(path_pieces, values) {
ops.$pullAll = function (path_pieces, values) {
return function (doc) {
get(doc, path_pieces, function (obj, field) {
var elements = obj[field];
Expand Down Expand Up @@ -196,11 +198,11 @@ var $pullAll = function $pullAll(path_pieces, values) {
};
};

var $pull = function $pull(path_pieces, value) {
return $pullAll(path_pieces, [value]);
ops.$pull = function (path_pieces, value) {
return ops.$pullAll(path_pieces, [value]);
};

var $addToSet = function $addToSet(path_pieces, value) {
ops.$addToSet = function (path_pieces, value) {
return function (doc) {
get(doc, path_pieces, function (obj, field) {
var elements = obj[field];
Expand All @@ -214,9 +216,9 @@ var $addToSet = function $addToSet(path_pieces, value) {

try {
for (var _iterator3 = elements[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var el = _step3.value;
var element = _step3.value;

if (equal(el, value)) {
if (equal(element, value)) {
return;
}
}
Expand All @@ -240,24 +242,9 @@ var $addToSet = function $addToSet(path_pieces, value) {
};
};

var ops = {
$set: $set,
$unset: $unset,
$rename: $rename,
$inc: $inc,
$mul: $mul,
$min: $min,
$max: $max,
$push: $push,
$pop: $pop,
$pullAll: $pullAll,
$pull: $pull,
$addToSet: $addToSet
};

var build = function build(steps, field, value) {
if (field[0] !== '$') {
return steps.push($set(toPathPieces(field), value));
return steps.push(ops.$set(toPathPieces(field), value));
}

var op = ops[field];
Expand Down
4 changes: 2 additions & 2 deletions build/src/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var deepMerge = require('deepmerge'),
clone = require('clone'),
Expand Down Expand Up @@ -61,7 +61,7 @@ var isObject = function isObject(obj) {
return (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null;
};

// Update a value or create it and it's path if it doesn't exist.
// Update a value or create it and its path if it doesn't exist.
var modify = function modify(obj, path_pieces, update, init) {
var last = path_pieces[path_pieces.length - 1];

Expand Down
2 changes: 1 addition & 1 deletion build/test/lang/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('arithmetic', function () {
expect(build({ y: { $trunc: 4 } }).has_refs).to.be.false;
});

it("should truncate a number to it's integer", function () {
it("should truncate a number to its integer", function () {
expect(evalExpr({ $trunc: 0 })).to.equal(0);
expect(evalExpr({ $trunc: 7.80 })).to.equal(7);
expect(evalExpr({ $trunc: '$x' }, { x: -2.3 })).to.equal(-2);
Expand Down
Loading

0 comments on commit e7222d5

Please sign in to comment.