fast-equals 5.3.1 → 5.3.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/index.cjs +9 -3
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/types/{comparator.d.ts → comparator.d.cts} +1 -1
  6. package/dist/{esm/types/equals.d.ts → cjs/types/equals.d.cts} +2 -2
  7. package/dist/cjs/types/{index.d.ts → index.d.cts} +3 -3
  8. package/dist/{esm/types/utils.d.ts → cjs/types/utils.d.cts} +1 -1
  9. package/dist/esm/index.mjs +9 -3
  10. package/dist/esm/index.mjs.map +1 -1
  11. package/dist/esm/types/{comparator.d.ts → comparator.d.mts} +1 -1
  12. package/dist/{cjs/types/equals.d.ts → esm/types/equals.d.mts} +2 -2
  13. package/dist/esm/types/{index.d.ts → index.d.mts} +3 -3
  14. package/dist/{cjs/types/utils.d.ts → esm/types/utils.d.mts} +1 -1
  15. package/dist/min/index.js +1 -1
  16. package/dist/min/types/comparator.d.ts +1 -1
  17. package/dist/min/types/equals.d.ts +1 -1
  18. package/dist/min/types/index.d.ts +2 -2
  19. package/dist/min/types/utils.d.ts +1 -1
  20. package/dist/umd/index.js +9 -3
  21. package/dist/umd/index.js.map +1 -1
  22. package/dist/umd/types/comparator.d.ts +1 -1
  23. package/dist/umd/types/equals.d.ts +1 -1
  24. package/dist/umd/types/index.d.ts +2 -2
  25. package/dist/umd/types/utils.d.ts +1 -1
  26. package/index.d.ts +1 -1
  27. package/package.json +51 -41
  28. package/src/comparator.ts +7 -7
  29. package/src/equals.ts +8 -4
  30. package/src/index.ts +4 -4
  31. package/src/internalTypes.ts +1 -1
  32. package/src/utils.ts +2 -1
  33. package/.babelrc +0 -34
  34. package/.prettierrc +0 -8
  35. package/.release-it.beta.json +0 -18
  36. package/.release-it.json +0 -14
  37. package/.yarnrc.yml +0 -5
  38. package/BUILD.md +0 -37
  39. package/config/rollup/config.base.js +0 -49
  40. package/config/rollup/config.cjs.js +0 -10
  41. package/config/rollup/config.esm.js +0 -10
  42. package/config/rollup/config.min.js +0 -13
  43. package/config/rollup/config.umd.js +0 -10
  44. package/config/tsconfig/base.json +0 -32
  45. package/config/tsconfig/cjs.json +0 -8
  46. package/config/tsconfig/declarations.json +0 -9
  47. package/config/tsconfig/esm.json +0 -8
  48. package/config/tsconfig/min.json +0 -8
  49. package/config/tsconfig/umd.json +0 -8
  50. package/config/webpack.config.js +0 -57
  51. package/recipes/explicit-property-check.md +0 -26
  52. package/recipes/legacy-circular-equal-support.md +0 -75
  53. package/recipes/legacy-regexp-support.md +0 -24
  54. package/recipes/non-standard-properties.md +0 -48
  55. package/recipes/special-objects.md +0 -25
  56. package/recipes/using-meta-in-comparison.md +0 -20
  57. package/scripts/apply-type-file-extensions.mjs +0 -33
  58. package/scripts/fallback-types.mjs +0 -64
  59. /package/dist/cjs/types/{internalTypes.d.ts → internalTypes.d.cts} +0 -0
  60. /package/dist/esm/types/{internalTypes.d.ts → internalTypes.d.mts} +0 -0
@@ -1,20 +0,0 @@
1
- # Using `meta` in comparison
2
-
3
- Sometimes a "pure" equality between two objects is insufficient, because the comparison relies on some external state. While these kinds of scenarios should generally be avoided, it is possible to handle them with a custom internal comparator that checks `meta` values.
4
-
5
- ```ts
6
- import { createCustomEqual } from 'fast-equals';
7
-
8
- interface Meta {
9
- value: string;
10
- }
11
-
12
- const meta: Meta = { value: 'baz' };
13
-
14
- const deepEqual = createCustomEqual<Meta>({
15
- createInternalComparator:
16
- (compare) => (a, b, _keyA, _keyB, _parentA, _parentB, state) =>
17
- compare(a, b, state) || a === state.meta.value || b === state.meta.value,
18
- createState: () => ({ meta }),
19
- });
20
- ```
@@ -1,33 +0,0 @@
1
- import glob from 'fast-glob';
2
- import { readFileSync, writeFileSync } from 'node:fs';
3
- import { join } from 'node:path';
4
-
5
- const IMPORT_STATEMENT_REGEXP =
6
- /import([ \n\t]*(?:[^ \n\t\{\}]+[ \n\t]*,?)?(?:[ \n\t]*\{(?:[ \n\t]*[^ \n\t"'\{\}]+[ \n\t]*,?)+\})?[ \n\t]*)from[ \n\t]*(['"])([^'"\n]+)(?:['"])/g;
7
-
8
- const EXPORT_STATEMENT_REGEXP =
9
- /export([ \n\t]*(?:[^ \n\t\{\}]+[ \n\t]*,?)?(?:[ \n\t]*\{(?:[ \n\t]*[^ \n\t"'\{\}]+[ \n\t]*,?)+\})?[ \n\t]*)from[ \n\t]*(['"])([^'"\n]+)(?:['"])/g;
10
-
11
- const files = glob.sync(
12
- join(import.meta.dirname, '..', 'dist', '*', 'types', '*.d.ts'),
13
- );
14
-
15
- function getReplacement(type) {
16
- return function (line, dependencies, _quoteType, location) {
17
- const extension = line.startsWith(`${type} type`) ? 'd.ts' : 'ts';
18
-
19
- return `${type}${dependencies}from '${location}.${extension}'`;
20
- };
21
- }
22
-
23
- function getReplacedContents(contents) {
24
- return contents
25
- .replaceAll(IMPORT_STATEMENT_REGEXP, getReplacement('import'))
26
- .replaceAll(EXPORT_STATEMENT_REGEXP, getReplacement('export'));
27
- }
28
-
29
- for (const file of files) {
30
- const contents = readFileSync(file, 'utf-8');
31
-
32
- writeFileSync(file, getReplacedContents(contents), 'utf-8');
33
- }
@@ -1,64 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
-
4
- const METHODS = `
5
- /**
6
- * Whether the values passed are strictly equal or both NaN.
7
- */
8
- export declare const sameValueZeroEqual: <A, B>(a: A, b: B) => boolean;
9
-
10
- /**
11
- * Whether the items passed are deeply-equal in value.
12
- */
13
- export declare const deepEqual: <A, B>(a: A, b: B) => boolean;
14
- /**
15
- * Whether the items passed are deeply-equal in value based on strict comparison.
16
- */
17
- export declare const strictDeepEqual: <A, B>(a: A, b: B) => boolean;
18
- /**
19
- * Whether the items passed are deeply-equal in value, including circular references.
20
- */
21
- export declare const circularDeepEqual: <A, B>(a: A, b: B) => boolean;
22
- /**
23
- * Whether the items passed are deeply-equal in value, including circular references,
24
- * based on strict comparison.
25
- */
26
- export declare const strictCircularDeepEqual: <A, B>(a: A, b: B) => boolean;
27
- /**
28
- * Whether the items passed are shallowly-equal in value.
29
- */
30
- export declare const shallowEqual: <A, B>(a: A, b: B) => boolean;
31
- /**
32
- * Whether the items passed are shallowly-equal in value based on strict comparison
33
- */
34
- export declare const strictShallowEqual: <A, B>(a: A, b: B) => boolean;
35
- /**
36
- * Whether the items passed are shallowly-equal in value, including circular references.
37
- */
38
- export declare const circularShallowEqual: <A, B>(a: A, b: B) => boolean;
39
- /**
40
- * Whether the items passed are shallowly-equal in value, including circular references,
41
- * based on strict comparison.
42
- */
43
- export declare const strictCircularShallowEqual: <A, B>(a: A, b: B) => boolean;
44
- /**
45
- * Create a custom equality comparison method.
46
- *
47
- * This can be done to create very targeted comparisons in extreme hot-path scenarios
48
- * where the standard methods are not performant enough, but can also be used to provide
49
- * support for legacy environments that cannot polyfill for modern features expected by
50
- * \`fast-equals\`, such as \`WeakMap\` or \`RegExp.prototype.flags\`.
51
- */
52
- export declare function createCustomEqual<Meta = undefined>(
53
- options?: CustomEqualCreatorOptions<Meta>,
54
- ): <A, B>(a: A, b: B) => boolean;
55
- `;
56
-
57
- const INTERNAL_TYPES = fs.readFileSync(
58
- path.join(import.meta.dirname, '..', 'src', 'internalTypes.ts'),
59
- );
60
-
61
- const OUTPUT = `${INTERNAL_TYPES}\n${METHODS}`.trim();
62
- const OUTPUT_DESTINATION = path.join(import.meta.dirname, '..', 'index.d.ts');
63
-
64
- fs.writeFileSync(OUTPUT_DESTINATION, OUTPUT, 'utf-8');