util-map-includes.js 428 B

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