@sequencemedia/dupe 0.0.3 → 0.0.5
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/package.json +6 -6
- package/src/index.d.mts +5 -5
- package/src/index.mjs +8 -12
- package/src/node/index.d.mts +5 -5
- package/src/node/index.mjs +4 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequencemedia/dupe",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"dupe",
|
|
6
6
|
"duplicate",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"debug": "^4.4.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"chai": "^5.1.2",
|
|
32
|
-
"mocha": "^11.0.1",
|
|
33
31
|
"@babel/core": "^7.26.0",
|
|
34
32
|
"@babel/preset-env": "^7.26.0",
|
|
35
|
-
"@sequencemedia/eslint-config-standard": "^0.2.
|
|
36
|
-
"@sequencemedia/eslint-config-typescript": "^0.1.
|
|
33
|
+
"@sequencemedia/eslint-config-standard": "^0.2.4",
|
|
34
|
+
"@sequencemedia/eslint-config-typescript": "^0.1.4",
|
|
37
35
|
"@types/debug": "^4.1.12",
|
|
38
36
|
"@types/mocha": "^10.0.10",
|
|
39
37
|
"@types/node": "^22.10.1",
|
|
38
|
+
"chai": "^5.1.2",
|
|
40
39
|
"core-js": "^3.39.0",
|
|
41
40
|
"cross-env": "^7.0.3",
|
|
42
41
|
"eslint": "^9.16.0",
|
|
43
42
|
"globals": "^15.13.0",
|
|
44
|
-
"husky": "^9.1.7"
|
|
43
|
+
"husky": "^9.1.7",
|
|
44
|
+
"mocha": "^11.0.1"
|
|
45
45
|
},
|
|
46
46
|
"imports": {
|
|
47
47
|
"#dupe": "./src/index.mjs",
|
package/src/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type ArrayLiteralType = unknown[] | never[]
|
|
2
|
-
type ObjectLiteralType = Record<PropertyKey, unknown> | Record<PropertyKey, never>
|
|
1
|
+
export type ArrayLiteralType = unknown[] | never[]
|
|
2
|
+
export type ObjectLiteralType = Record<PropertyKey, unknown> | Record<PropertyKey, never>
|
|
3
|
+
export type ValueType = string | number | ArrayLiteralType | ObjectLiteralType | null | undefined
|
|
4
|
+
export type WeakMapType = WeakMap<WeakKey, ArrayLiteralType | ObjectLiteralType>
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default function dupe (v: ValueType | ValueType[]): ValueType | ValueType[]
|
|
6
|
+
export default function toDuplicate (v: ValueType | ValueType[]): ValueType | ValueType[]
|
package/src/index.mjs
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {
|
|
3
|
-
*
|
|
4
|
-
* @typedef {
|
|
5
|
-
*
|
|
6
|
-
* @typedef {string | number | ArrayLiteralType | ObjectLiteralType | null | undefined} ValueType
|
|
7
|
-
*
|
|
8
|
-
* @typedef {WeakMap<WeakKey, ArrayLiteralType | ObjectLiteralType>} WeakMapType
|
|
2
|
+
* @typedef {import('#dupe').ArrayLiteralType} ArrayLiteralType
|
|
3
|
+
* @typedef {import('#dupe').ObjectLiteralType} ObjectLiteralType
|
|
4
|
+
* @typedef {import('#dupe').ValueType} ValueType
|
|
5
|
+
* @typedef {import('#dupe').WeakMapType} WeakMapType
|
|
9
6
|
*/
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* @param {ValueType | ValueType[]} v
|
|
13
10
|
* @returns {boolean}
|
|
14
11
|
*/
|
|
15
|
-
|
|
12
|
+
function isArray (v) {
|
|
16
13
|
return Array.isArray(v)
|
|
17
14
|
}
|
|
18
15
|
|
|
@@ -20,7 +17,7 @@ export function isArray (v) {
|
|
|
20
17
|
* @param {ValueType | ValueType[]} v
|
|
21
18
|
* @returns {boolean}
|
|
22
19
|
*/
|
|
23
|
-
|
|
20
|
+
function isObject (v) {
|
|
24
21
|
return (v || false) instanceof Object && !Array.isArray(v)
|
|
25
22
|
}
|
|
26
23
|
|
|
@@ -28,9 +25,10 @@ export function isObject (v) {
|
|
|
28
25
|
* @param {ValueType | ValueType[]} v
|
|
29
26
|
* @returns {boolean}
|
|
30
27
|
*/
|
|
31
|
-
|
|
28
|
+
function isFunction (v) {
|
|
32
29
|
return v instanceof Function
|
|
33
30
|
}
|
|
31
|
+
|
|
34
32
|
/**
|
|
35
33
|
* @param {ValueType | ValueType[]} v
|
|
36
34
|
* @returns {boolean}
|
|
@@ -52,7 +50,6 @@ function getArray (v, weakMap) {
|
|
|
52
50
|
const a = []
|
|
53
51
|
|
|
54
52
|
weakMap.set(v, a)
|
|
55
|
-
|
|
56
53
|
return v.reduce(getReduceArray(weakMap), a)
|
|
57
54
|
}
|
|
58
55
|
|
|
@@ -65,7 +62,6 @@ function getObject (v, weakMap) {
|
|
|
65
62
|
const o = {}
|
|
66
63
|
|
|
67
64
|
weakMap.set(v, o)
|
|
68
|
-
|
|
69
65
|
return Object.assign(o, Object.fromEntries(Object.entries(v).map(getMapEntries(weakMap))))
|
|
70
66
|
}
|
|
71
67
|
|
package/src/node/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type ArrayLiteralType = unknown[] | never[]
|
|
2
|
-
type ObjectLiteralType = Record<PropertyKey, unknown> | Record<PropertyKey, never>
|
|
1
|
+
export type ArrayLiteralType = unknown[] | never[]
|
|
2
|
+
export type ObjectLiteralType = Record<PropertyKey, unknown> | Record<PropertyKey, never>
|
|
3
|
+
export type ValueType = string | number | ArrayLiteralType | ObjectLiteralType | Buffer | null | undefined
|
|
4
|
+
export type WeakMapType = WeakMap<WeakKey, ArrayLiteralType | ObjectLiteralType>
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export default function dupe (v: ValueType | ValueType[]): ValueType | ValueType[]
|
|
6
|
+
export default function toDuplicate (v: ValueType | ValueType[]): ValueType | ValueType[]
|
package/src/node/index.mjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {
|
|
3
|
-
*
|
|
4
|
-
* @typedef {
|
|
5
|
-
*
|
|
6
|
-
* @typedef {string | number | ArrayLiteralType | ObjectLiteralType | Buffer | null | undefined} ValueType
|
|
7
|
-
*
|
|
8
|
-
* @typedef {WeakMap<WeakKey, ArrayLiteralType | ObjectLiteralType>} WeakMapType
|
|
2
|
+
* @typedef {import('#dupe/node').ArrayLiteralType} ArrayLiteralType
|
|
3
|
+
* @typedef {import('#dupe/node').ObjectLiteralType} ObjectLiteralType
|
|
4
|
+
* @typedef {import('#dupe/node').ValueType} ValueType
|
|
5
|
+
* @typedef {import('#dupe/node').WeakMapType} WeakMapType
|
|
9
6
|
*/
|
|
10
7
|
|
|
11
8
|
/**
|
|
@@ -68,7 +65,6 @@ function getArray (v, weakMap) {
|
|
|
68
65
|
const a = []
|
|
69
66
|
|
|
70
67
|
weakMap.set(v, a)
|
|
71
|
-
|
|
72
68
|
return v.reduce(getReduceArray(weakMap), a)
|
|
73
69
|
}
|
|
74
70
|
|
|
@@ -81,7 +77,6 @@ function getObject (v, weakMap) {
|
|
|
81
77
|
const o = {}
|
|
82
78
|
|
|
83
79
|
weakMap.set(v, o)
|
|
84
|
-
|
|
85
80
|
return Object.assign(o, Object.fromEntries(Object.entries(v).map(getMapEntries(weakMap))))
|
|
86
81
|
}
|
|
87
82
|
|