@ts-type/is-array 1.0.5 → 1.0.6
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 +21 -0
- package/package.json +8 -4
- package/src/index.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.6](https://github.com/bluelovers/ws-ts-type/compare/@ts-type/is-array@1.0.5...@ts-type/is-array@1.0.6) (2022-10-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 🛠 Build System
|
|
11
|
+
|
|
12
|
+
* update typescript ([eb59d89](https://github.com/bluelovers/ws-ts-type/commit/eb59d897c2888c7a45406ffcad4b9033608b0b66))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 📌 Dependencies
|
|
16
|
+
|
|
17
|
+
* update deps ([ab5f3e4](https://github.com/bluelovers/ws-ts-type/commit/ab5f3e48da1f10ddd4445ba6dda9a0a68c5f656f))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### 🔖 Miscellaneous
|
|
21
|
+
|
|
22
|
+
* . ([ed63e32](https://github.com/bluelovers/ws-ts-type/commit/ed63e326e593f2aac0258db1c6cf15db3d73d943))
|
|
23
|
+
* . ([9219017](https://github.com/bluelovers/ws-ts-type/commit/92190178fcf30f881c1d0d36fb141a3394ab3b38))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
## [1.0.5](https://github.com/bluelovers/ws-ts-type/compare/@ts-type/is-array@1.0.4...@ts-type/is-array@1.0.5) (2022-08-10)
|
|
7
28
|
|
|
8
29
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-type/is-array",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "better typescript type for Array.isArray",
|
|
5
5
|
"keywords": [
|
|
6
6
|
".d.ts",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/bluelovers/ws-ts-type.git"
|
|
38
|
+
"url": "git+https://github.com/bluelovers/ws-ts-type.git",
|
|
39
|
+
"directory": "packages/@ts-type/is-array"
|
|
39
40
|
},
|
|
40
41
|
"license": "ISC",
|
|
41
42
|
"author": "bluelovers",
|
|
@@ -62,7 +63,10 @@
|
|
|
62
63
|
"pretest": "echo pretest",
|
|
63
64
|
"test": "ts-node ./test/spec/issues-17002.spec.ts",
|
|
64
65
|
"test:jest": "jest --passWithNoTests",
|
|
66
|
+
"test:jest:snapshot": "yarn run test:jest -- -u",
|
|
65
67
|
"test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
|
|
68
|
+
"test:snapshot": "yarn run test -- -u",
|
|
69
|
+
"test:tsd": "ynpx tsd",
|
|
66
70
|
"test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
|
|
67
71
|
"posttest": "yarn run build",
|
|
68
72
|
"build": "yarn run build:tsdx && yarn run build:dts:tsc",
|
|
@@ -92,11 +96,11 @@
|
|
|
92
96
|
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
93
97
|
},
|
|
94
98
|
"dependencies": {
|
|
95
|
-
"ts-type": "^
|
|
99
|
+
"ts-type": "^3.0.1"
|
|
96
100
|
},
|
|
97
101
|
"packageManager": "yarn@^1.22.11",
|
|
98
102
|
"publishConfig": {
|
|
99
103
|
"access": "public"
|
|
100
104
|
},
|
|
101
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "fa34eea119b9bcbb363061ddffcfe9d78c2d0ddd"
|
|
102
106
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ITSArrayListMaybeReadonly } from 'ts-type/lib/type/base';
|
|
2
|
+
import { AssertionError } from 'assert';
|
|
3
|
+
import { ITSToReadonlyArray, ITSToWriteableArray } from 'ts-type/lib/helper/array/readonly';
|
|
4
|
+
|
|
5
|
+
declare global
|
|
6
|
+
{
|
|
7
|
+
interface ArrayConstructor
|
|
8
|
+
{
|
|
9
|
+
isArray<T extends ITSArrayListMaybeReadonly<any>>(arg: T | unknown): arg is T
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isArray<T extends ITSArrayListMaybeReadonly<any>>(arg: T | unknown): arg is T
|
|
14
|
+
{
|
|
15
|
+
return Array.isArray(arg)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
export function typePredicatesAsWriteableArray<T extends ITSArrayListMaybeReadonly<any>>(value: T): asserts value is ITSToWriteableArray<T>
|
|
20
|
+
{
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
export function typePredicatesAsReadonlyArray<T extends ITSArrayListMaybeReadonly<any>>(value: T): asserts value is ITSToReadonlyArray<T>
|
|
26
|
+
{
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isArrayPredicates<T extends ITSArrayListMaybeReadonly<any>>(actual: T | unknown, message?: string): asserts actual is T
|
|
31
|
+
{
|
|
32
|
+
const expression = Array.isArray(actual);
|
|
33
|
+
if (!expression)
|
|
34
|
+
{
|
|
35
|
+
throw new AssertionError({
|
|
36
|
+
message: message ?? `actual ${actual} not as expected`,
|
|
37
|
+
actual,
|
|
38
|
+
expected: expression,
|
|
39
|
+
operator: 'fail',
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { isArray as isArrayNarrowed }
|
|
45
|
+
|
|
46
|
+
export default isArray
|