util-map-includes.js 471 B

123456789101112131415
  1. 'use strict';
  2. var identity = require('../nodes/identity.js');
  3. function mapIncludes(ctx, items, search) {
  4. const { uniqueKeys } = ctx.options;
  5. if (uniqueKeys === false)
  6. return false;
  7. const isEqual = typeof uniqueKeys === 'function'
  8. ? uniqueKeys
  9. : (a, b) => a === b || (identity.isScalar(a) && identity.isScalar(b) && a.value === b.value);
  10. return items.some(pair => isEqual(pair.key, search));
  11. }
  12. exports.mapIncludes = mapIncludes;