UNPKG

2.62 kBJavaScriptView Raw
1"use strict";
2
3var _getIterator2 = require("babel-runtime/core-js/get-iterator");
4
5var _getIterator3 = _interopRequireDefault(_getIterator2);
6
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
9exports.compare = function () {
10 for (var _len = arguments.length, props = Array(_len), _key = 0; _key < _len; _key++) {
11 props[_key] = arguments[_key];
12 }
13
14 return function (a, b) {
15 var _iteratorNormalCompletion = true;
16 var _didIteratorError = false;
17 var _iteratorError = undefined;
18
19 try {
20 for (var _iterator = (0, _getIterator3.default)(props), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
21 var prop = _step.value;
22
23 if (a[prop] === undefined) return -1;
24 if (b[prop] === undefined) return 1;
25 if (a[prop] < b[prop]) return -1;
26 if (a[prop] > b[prop]) return 1;
27 }
28 } catch (err) {
29 _didIteratorError = true;
30 _iteratorError = err;
31 } finally {
32 try {
33 if (!_iteratorNormalCompletion && _iterator.return) {
34 _iterator.return();
35 }
36 } finally {
37 if (_didIteratorError) {
38 throw _iteratorError;
39 }
40 }
41 }
42
43 return 0;
44 };
45};
46//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlsLmpzIl0sIm5hbWVzIjpbImV4cG9ydHMiLCJjb21wYXJlIiwicHJvcHMiLCJhIiwiYiIsInByb3AiLCJ1bmRlZmluZWQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBQUFBLFFBQVFDLE9BQVIsR0FBa0IsWUFBYztBQUFBLG9DQUFWQyxLQUFVO0FBQVZBLFNBQVU7QUFBQTs7QUFDOUIsU0FBTyxVQUFDQyxDQUFELEVBQUlDLENBQUosRUFBVTtBQUFBO0FBQUE7QUFBQTs7QUFBQTtBQUNmLHNEQUFpQkYsS0FBakIsNEdBQXdCO0FBQUEsWUFBZkcsSUFBZTs7QUFDdEIsWUFBSUYsRUF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