@ditojs/utils 3.0.0 → 3.1.1
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 +5 -3
- package/src/__snapshots__/index.test.js.snap +0 -90
- package/src/array/flattten.test.js +0 -29
- package/src/array/shuffle.test.js +0 -25
- package/src/base/base.test.js +0 -590
- package/src/class/mixin.test.js +0 -70
- package/src/dataPath/getEntriesAtDataPath.test.js +0 -204
- package/src/dataPath/getValueAtDataPath.test.js +0 -140
- package/src/dataPath/normalizeDataPath.test.js +0 -36
- package/src/dataPath/parseDataPath.test.js +0 -67
- package/src/dataPath/setDataPathEntries.test.js +0 -36
- package/src/dataPath/setValueAtDataPath.test.js +0 -34
- package/src/function/toAsync.test.js +0 -31
- package/src/function/toCallback.test.js +0 -29
- package/src/function/toPromiseCallback.test.js +0 -24
- package/src/html/escapeHtml.test.js +0 -19
- package/src/html/stripHtml.test.js +0 -37
- package/src/index.test.js +0 -7
- package/src/object/clone.test.js +0 -131
- package/src/object/equals.test.js +0 -278
- package/src/object/groupBy.test.js +0 -70
- package/src/object/mapKeys.test.js +0 -16
- package/src/object/mapValues.test.js +0 -38
- package/src/object/mergeDeeply.test.js +0 -152
- package/src/object/pick.test.js +0 -23
- package/src/object/pickBy.test.js +0 -48
- package/src/string/camelize.test.js +0 -37
- package/src/string/capitalize.test.js +0 -33
- package/src/string/decamelize.test.js +0 -83
- package/src/string/deindent.test.js +0 -181
- package/src/string/format.test.js +0 -196
- package/src/string/formatDate.test.js +0 -28
- package/src/string/formatPlainDate.test.js +0 -13
- package/src/string/getCommonPrefix.test.js +0 -23
- package/src/string/isAbsoluteUrl.test.js +0 -15
- package/src/string/isCreditCard.test.js +0 -50
- package/src/string/isDomain.test.js +0 -24
- package/src/string/isEmail.test.js +0 -37
- package/src/string/isHostname.test.js +0 -12
- package/src/string/isUrl.test.js +0 -1595
- package/src/string/labelize.test.js +0 -39
- package/src/string/parsePlainDate.test.js +0 -20
- package/src/timer/debounce.test.js +0 -101
- package/src/timer/debounceAsync.test.js +0 -143
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Utility Functions – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/main/packages/utils",
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"src/",
|
|
20
|
-
"types/"
|
|
20
|
+
"types/",
|
|
21
|
+
"!src/**/*.test.js",
|
|
22
|
+
"!src/**/__snapshots__/"
|
|
21
23
|
],
|
|
22
24
|
"engines": {
|
|
23
25
|
"node": ">= 24.0.0"
|
|
@@ -32,5 +34,5 @@
|
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"typescript": "^6.0.3"
|
|
34
36
|
},
|
|
35
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "acce85bb38d817aab18f9d5d03b3aa9dff00c3f9"
|
|
36
38
|
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`index > exports all symbols 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"asArray": [Function],
|
|
6
|
-
"asFunction": [Function],
|
|
7
|
-
"asObject": [Function],
|
|
8
|
-
"assignDeeply": [Function],
|
|
9
|
-
"camelize": [Function],
|
|
10
|
-
"capitalize": [Function],
|
|
11
|
-
"clone": [Function],
|
|
12
|
-
"debounce": [Function],
|
|
13
|
-
"debounceAsync": [Function],
|
|
14
|
-
"decamelize": [Function],
|
|
15
|
-
"defaultFormats": {
|
|
16
|
-
"date": {
|
|
17
|
-
"day": "numeric",
|
|
18
|
-
"month": "long",
|
|
19
|
-
"year": "numeric",
|
|
20
|
-
},
|
|
21
|
-
"number": {
|
|
22
|
-
"style": "decimal",
|
|
23
|
-
},
|
|
24
|
-
"time": {
|
|
25
|
-
"hour": "2-digit",
|
|
26
|
-
"minute": "2-digit",
|
|
27
|
-
"second": "2-digit",
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
"deindent": [Function],
|
|
31
|
-
"deprecate": [Function],
|
|
32
|
-
"equals": [Function],
|
|
33
|
-
"escapeHtml": [Function],
|
|
34
|
-
"escapeRegexp": [Function],
|
|
35
|
-
"flatten": [Function],
|
|
36
|
-
"format": [Function],
|
|
37
|
-
"formatDate": [Function],
|
|
38
|
-
"formatPlainDate": [Function],
|
|
39
|
-
"getCommonOffset": [Function],
|
|
40
|
-
"getCommonPrefix": [Function],
|
|
41
|
-
"getEntriesAtDataPath": [Function],
|
|
42
|
-
"getValueAtDataPath": [Function],
|
|
43
|
-
"groupBy": [Function],
|
|
44
|
-
"hyphenate": [Function],
|
|
45
|
-
"is": [Function],
|
|
46
|
-
"isAbsoluteUrl": [Function],
|
|
47
|
-
"isArray": [Function],
|
|
48
|
-
"isArrayLike": [Function],
|
|
49
|
-
"isAsync": [Function],
|
|
50
|
-
"isBoolean": [Function],
|
|
51
|
-
"isCreditCard": [Function],
|
|
52
|
-
"isDate": [Function],
|
|
53
|
-
"isDomain": [Function],
|
|
54
|
-
"isEmail": [Function],
|
|
55
|
-
"isEmpty": [Function],
|
|
56
|
-
"isFunction": [Function],
|
|
57
|
-
"isHostname": [Function],
|
|
58
|
-
"isInteger": [Function],
|
|
59
|
-
"isModule": [Function],
|
|
60
|
-
"isNumber": [Function],
|
|
61
|
-
"isObject": [Function],
|
|
62
|
-
"isPlainArray": [Function],
|
|
63
|
-
"isPlainObject": [Function],
|
|
64
|
-
"isPromise": [Function],
|
|
65
|
-
"isRegExp": [Function],
|
|
66
|
-
"isString": [Function],
|
|
67
|
-
"isUrl": [Function],
|
|
68
|
-
"labelize": [Function],
|
|
69
|
-
"mapConcurrently": [Function],
|
|
70
|
-
"mapKeys": [Function],
|
|
71
|
-
"mapSequentially": [Function],
|
|
72
|
-
"mapValues": [Function],
|
|
73
|
-
"mergeDeeply": [Function],
|
|
74
|
-
"mixin": [Function],
|
|
75
|
-
"normalizeDataPath": [Function],
|
|
76
|
-
"parseDataPath": [Function],
|
|
77
|
-
"parsePlainDate": [Function],
|
|
78
|
-
"pick": [Function],
|
|
79
|
-
"pickBy": [Function],
|
|
80
|
-
"setDataPathEntries": [Function],
|
|
81
|
-
"setValueAtDataPath": [Function],
|
|
82
|
-
"shuffle": [Function],
|
|
83
|
-
"stripHtml": [Function],
|
|
84
|
-
"stripTags": [Function],
|
|
85
|
-
"toAsync": [Function],
|
|
86
|
-
"toCallback": [Function],
|
|
87
|
-
"toPromiseCallback": [Function],
|
|
88
|
-
"underscore": [Function],
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { flatten } from './flatten.js'
|
|
2
|
-
|
|
3
|
-
describe('flatten()', () => {
|
|
4
|
-
it('should support flattening of nested arrays', () => {
|
|
5
|
-
const array = [1, [2, [3, [4]], 5]]
|
|
6
|
-
expect(flatten(array)).toStrictEqual([1, 2, 3, 4, 5])
|
|
7
|
-
expect(flatten(array, 1)).toStrictEqual([1, 2, [3, [4]], 5])
|
|
8
|
-
expect(flatten(array, 2)).toStrictEqual([1, 2, 3, [4], 5])
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('should work with empty arrays', () => {
|
|
12
|
-
const array = [[], [[]], [[], [[[]]]]]
|
|
13
|
-
|
|
14
|
-
expect(flatten(array)).toStrictEqual([])
|
|
15
|
-
expect(flatten(array, 1)).toStrictEqual([[], [], [[[]]]])
|
|
16
|
-
expect(flatten(array, 2)).toStrictEqual([[[]]])
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('should treat sparse arrays as dense', () => {
|
|
20
|
-
const array = [[1, 2, 3], Array(3)]
|
|
21
|
-
const expected = [1, 2, 3]
|
|
22
|
-
expected.push(undefined, undefined, undefined)
|
|
23
|
-
expect(flatten(array)).toStrictEqual(expected)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('should return an empty array for non array-like objects', () => {
|
|
27
|
-
expect(flatten({ 0: 'a' })).toStrictEqual([])
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { shuffle } from './shuffle.js'
|
|
2
|
-
|
|
3
|
-
describe('shuffle()', () => {
|
|
4
|
-
const array = [1, 2, 3]
|
|
5
|
-
|
|
6
|
-
it('should return a new array', () => {
|
|
7
|
-
expect(shuffle(array)).not.toBe(array)
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it(`should contain the same elements after a collection is shuffled and sorted again`, () => {
|
|
11
|
-
expect(shuffle(array).sort()).toStrictEqual(array)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('should shuffle small collections', () => {
|
|
15
|
-
const results = {}
|
|
16
|
-
for (let i = 0; i < 1000; i++) {
|
|
17
|
-
const res = shuffle([1, 2])
|
|
18
|
-
results[res] = res
|
|
19
|
-
}
|
|
20
|
-
const sorted = Object.entries(results)
|
|
21
|
-
.sort()
|
|
22
|
-
.map(([, value]) => value)
|
|
23
|
-
expect(sorted).toStrictEqual([[1, 2], [2, 1]])
|
|
24
|
-
})
|
|
25
|
-
})
|