@guanghechen/equal 2.0.0 → 2.0.2

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.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,35 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: vitest config auto-load aliases and coverage thresholds; style/doc formatting updates
8
+
3
9
  All notable changes to this project will be documented in this file. See
4
10
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
11
 
12
+ ## 2.0.1 (2025-02-07)
13
+
14
+ ### Improvements
15
+
16
+ - Clean up build configs and standardize package exports
17
+
18
+ ### Documentation
19
+
20
+ - Update README.md
21
+
22
+ ### Miscellaneous
23
+
24
+ - Add LICENSE file
25
+ - Migrate from lerna to changesets
26
+
27
+ ## 2.0.0 (2025-01-15)
28
+
29
+ ### Improvements
30
+
31
+ - Switch to recommended ESLint stack
32
+
6
33
  ## 1.0.0-alpha.7 (2024-09-18)
7
34
 
8
35
  - :wrench: chore: upgrade devDependencies and fix configs
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present guanghechen (https://github.com/guanghechen)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -49,20 +49,83 @@
49
49
  </header>
50
50
  <br/>
51
51
 
52
- Inspired by https://github.com/epoberezkin/fast-deep-equal, re-published because it doesn't support ESM.
52
+ The fastest deep equal with ES6 Map, Set and Typed arrays support. Inspired by
53
+ [fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal), re-published with ESM support.
53
54
 
54
- ## Usage
55
+ ## Install
55
56
 
56
- - Use within ESM.
57
+ - npm
57
58
 
58
- ```javascript
59
- import isEqual from '@guanghechen/equal'
60
- console.log(isEqual({foo: 'bar'}, {foo: 'bar'})); // true
59
+ ```bash
60
+ npm install --save @guanghechen/equal
61
61
  ```
62
62
 
63
- - Use within CommonJS.
63
+ - yarn
64
64
 
65
- ```javascript
66
- const isEqual = require('@guanghechen/equal')
67
- console.log(isEqual({foo: 'bar'}, {foo: 'bar'})); // true
65
+ ```bash
66
+ yarn add @guanghechen/equal
68
67
  ```
68
+
69
+ ## Usage
70
+
71
+ ### Basic Comparison
72
+
73
+ ```typescript
74
+ import isEqual from '@guanghechen/equal'
75
+
76
+ // Primitives
77
+ isEqual(1, 1) // true
78
+ isEqual('a', 'a') // true
79
+ isEqual(null, null) // true
80
+ isEqual(undefined, undefined) // true
81
+
82
+ // Objects
83
+ isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }) // true
84
+ isEqual({ a: 1 }, { a: 2 }) // false
85
+
86
+ // Arrays
87
+ isEqual([1, 2, 3], [1, 2, 3]) // true
88
+ isEqual([1, 2], [1, 2, 3]) // false
89
+
90
+ // Nested structures
91
+ isEqual(
92
+ { user: { name: 'John', tags: ['admin'] } },
93
+ { user: { name: 'John', tags: ['admin'] } }
94
+ ) // true
95
+ ```
96
+
97
+ ### Named Export
98
+
99
+ ```typescript
100
+ import { isEqual } from '@guanghechen/equal'
101
+
102
+ isEqual({ foo: 'bar' }, { foo: 'bar' }) // true
103
+ ```
104
+
105
+ ### Special Types
106
+
107
+ ```typescript
108
+ import isEqual from '@guanghechen/equal'
109
+
110
+ // RegExp
111
+ isEqual(/abc/gi, /abc/gi) // true
112
+ isEqual(/abc/g, /abc/i) // false
113
+
114
+ // Date
115
+ isEqual(new Date('2024-01-01'), new Date('2024-01-01')) // true
116
+
117
+ // Custom valueOf/toString
118
+ class Point {
119
+ constructor(public x: number, public y: number) {}
120
+ valueOf() { return this.x * 1000 + this.y }
121
+ }
122
+ isEqual(new Point(1, 2), new Point(1, 2)) // true
123
+ ```
124
+
125
+ ## Reference
126
+
127
+ - [homepage][homepage]
128
+ - Inspired by [fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal)
129
+
130
+ [homepage]:
131
+ https://github.com/guanghechen/sora/tree/@guanghechen/equal@2.0.0/packages/equal#readme
package/lib/cjs/index.cjs CHANGED
@@ -32,12 +32,11 @@ function isEqual(x, y) {
32
32
  const keys = Object.keys(x);
33
33
  if (keys.length !== Object.keys(y).length)
34
34
  return false;
35
- for (let i = 0; i < keys.length; ++i) {
36
- if (!Object.prototype.hasOwnProperty.call(y, keys[i]))
35
+ for (const key of keys) {
36
+ if (!Object.prototype.hasOwnProperty.call(y, key))
37
37
  return false;
38
38
  }
39
- for (let i = 0; i < keys.length; ++i) {
40
- const key = keys[i];
39
+ for (const key of keys) {
41
40
  if (key === '_owner' && x.$$typeof)
42
41
  continue;
43
42
  if (!isEqual(x[key], y[key]))
package/lib/esm/index.mjs CHANGED
@@ -28,12 +28,11 @@ function isEqual(x, y) {
28
28
  const keys = Object.keys(x);
29
29
  if (keys.length !== Object.keys(y).length)
30
30
  return false;
31
- for (let i = 0; i < keys.length; ++i) {
32
- if (!Object.prototype.hasOwnProperty.call(y, keys[i]))
31
+ for (const key of keys) {
32
+ if (!Object.prototype.hasOwnProperty.call(y, key))
33
33
  return false;
34
34
  }
35
- for (let i = 0; i < keys.length; ++i) {
36
- const key = keys[i];
35
+ for (const key of keys) {
37
36
  if (key === '_owner' && x.$$typeof)
38
37
  continue;
39
38
  if (!isEqual(x[key], y[key]))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanghechen/equal",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "The fastest deep equal with ES6 Map, Set and Typed arrays support.",
5
5
  "author": {
6
6
  "name": "guanghechen",
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/guanghechen/sora/tree/@guanghechen/equal@1.0.3",
11
+ "url": "https://github.com/guanghechen/sora/tree/@guanghechen/equal@2.0.0",
12
12
  "directory": "packages/equal"
13
13
  },
14
- "homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/equal@1.0.3/packages/equal#readme",
14
+ "homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/equal@2.0.0/packages/equal#readme",
15
15
  "keywords": [
16
16
  "equal",
17
17
  "fast deep equal"
@@ -19,10 +19,10 @@
19
19
  "type": "module",
20
20
  "exports": {
21
21
  ".": {
22
+ "types": "./lib/types/index.d.ts",
22
23
  "source": "./src/index.ts",
23
24
  "import": "./lib/esm/index.mjs",
24
- "require": "./lib/cjs/index.cjs",
25
- "types": "./lib/types/index.d.ts"
25
+ "require": "./lib/cjs/index.cjs"
26
26
  }
27
27
  },
28
28
  "source": "./src/index.ts",
@@ -30,13 +30,6 @@
30
30
  "module": "./lib/esm/index.mjs",
31
31
  "types": "./lib/types/index.d.ts",
32
32
  "license": "MIT",
33
- "scripts": {
34
- "build": "rollup -c ../../rollup.config.mjs",
35
- "clean": "rimraf lib",
36
- "test": "vitest run --config ../../vitest.config.ts",
37
- "test:coverage": "vitest run --config ../../vitest.config.ts --coverage",
38
- "test:update": "vitest run --config ../../vitest.config.ts -u"
39
- },
40
33
  "files": [
41
34
  "lib/",
42
35
  "!lib/**/*.map",
@@ -45,5 +38,11 @@
45
38
  "LICENSE",
46
39
  "README.md"
47
40
  ],
48
- "gitHead": "12990a720b31d50d217e2e17a6191256dc94eda6"
49
- }
41
+ "scripts": {
42
+ "build": "rollup -c ../../rollup.config.mjs",
43
+ "clean": "rimraf lib",
44
+ "test": "vitest run --config ../../vitest.config.ts",
45
+ "test:coverage": "vitest run --config ../../vitest.config.ts --coverage",
46
+ "test:update": "vitest run --config ../../vitest.config.ts -u"
47
+ }
48
+ }