You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
911 B

4 years ago
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _differenceWith2 = require('lodash/differenceWith');
  6. var _differenceWith3 = _interopRequireDefault(_differenceWith2);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  9. function mergeUnique(key, uniques) {
  10. var getter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (a) {
  11. return a;
  12. };
  13. return function (a, b, k) {
  14. return k === key && [].concat(_toConsumableArray(a), _toConsumableArray((0, _differenceWith3.default)(b, a, function (item) {
  15. return uniques.indexOf(getter(item)) >= 0;
  16. })));
  17. };
  18. }
  19. exports.default = mergeUnique;