type-plus 3.15.0 → 4.0.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 (133) hide show
  1. package/README.md +1 -55
  2. package/cjs/index.d.ts +0 -4
  3. package/cjs/index.js +5 -18
  4. package/cjs/index.js.map +1 -1
  5. package/esm/index.js +4 -4
  6. package/esm/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/ts/index.ts +4 -4
  9. package/ts/type-checker/typeChecker.spec.ts +2 -1
  10. package/ts/types/check.spec.ts +1 -1
  11. package/ts/types/conform.spec.ts +1 -1
  12. package/ts/types/satisfy.accept.ts +39 -38
  13. package/ts/types/satisfy.spec.ts +2 -1
  14. package/cjs/types/AllType.d.ts +0 -18
  15. package/cjs/types/AllType.js +0 -3
  16. package/cjs/types/AllType.js.map +0 -1
  17. package/cjs/types/Any.d.ts +0 -6
  18. package/cjs/types/Any.js +0 -5
  19. package/cjs/types/Any.js.map +0 -1
  20. package/cjs/types/Array.d.ts +0 -28
  21. package/cjs/types/Array.js +0 -30
  22. package/cjs/types/Array.js.map +0 -1
  23. package/cjs/types/Boolean.d.ts +0 -29
  24. package/cjs/types/Boolean.js +0 -28
  25. package/cjs/types/Boolean.js.map +0 -1
  26. package/cjs/types/Generate.d.ts +0 -32
  27. package/cjs/types/Generate.js +0 -3
  28. package/cjs/types/Generate.js.map +0 -1
  29. package/cjs/types/Null.d.ts +0 -8
  30. package/cjs/types/Null.js +0 -10
  31. package/cjs/types/Null.js.map +0 -1
  32. package/cjs/types/Number.d.ts +0 -36
  33. package/cjs/types/Number.js +0 -50
  34. package/cjs/types/Number.js.map +0 -1
  35. package/cjs/types/Object.d.ts +0 -313
  36. package/cjs/types/Object.js +0 -35
  37. package/cjs/types/Object.js.map +0 -1
  38. package/cjs/types/Record.d.ts +0 -16
  39. package/cjs/types/Record.js +0 -17
  40. package/cjs/types/Record.js.map +0 -1
  41. package/cjs/types/String.d.ts +0 -36
  42. package/cjs/types/String.js +0 -51
  43. package/cjs/types/String.js.map +0 -1
  44. package/cjs/types/Symbol.d.ts +0 -8
  45. package/cjs/types/Symbol.js +0 -13
  46. package/cjs/types/Symbol.js.map +0 -1
  47. package/cjs/types/Tuple.d.ts +0 -35
  48. package/cjs/types/Tuple.js +0 -43
  49. package/cjs/types/Tuple.js.map +0 -1
  50. package/cjs/types/Undefined.d.ts +0 -6
  51. package/cjs/types/Undefined.js +0 -5
  52. package/cjs/types/Undefined.js.map +0 -1
  53. package/cjs/types/Union.d.ts +0 -20
  54. package/cjs/types/Union.js +0 -52
  55. package/cjs/types/Union.js.map +0 -1
  56. package/cjs/types/Unknown.d.ts +0 -6
  57. package/cjs/types/Unknown.js +0 -5
  58. package/cjs/types/Unknown.js.map +0 -1
  59. package/cjs/types/analyze.d.ts +0 -13
  60. package/cjs/types/analyze.js +0 -159
  61. package/cjs/types/analyze.js.map +0 -1
  62. package/cjs/types/check.d.ts +0 -14
  63. package/cjs/types/check.js +0 -25
  64. package/cjs/types/check.js.map +0 -1
  65. package/cjs/types/conform.d.ts +0 -15
  66. package/cjs/types/conform.js +0 -26
  67. package/cjs/types/conform.js.map +0 -1
  68. package/cjs/types/getPlainAnalysisReport.d.ts +0 -2
  69. package/cjs/types/getPlainAnalysisReport.js +0 -120
  70. package/cjs/types/getPlainAnalysisReport.js.map +0 -1
  71. package/cjs/types/index.d.ts +0 -26
  72. package/cjs/types/index.js +0 -45
  73. package/cjs/types/index.js.map +0 -1
  74. package/cjs/types/optional.d.ts +0 -328
  75. package/cjs/types/optional.js +0 -33
  76. package/cjs/types/optional.js.map +0 -1
  77. package/cjs/types/required.d.ts +0 -664
  78. package/cjs/types/required.js +0 -33
  79. package/cjs/types/required.js.map +0 -1
  80. package/cjs/types/satisfy.d.ts +0 -15
  81. package/cjs/types/satisfy.js +0 -26
  82. package/cjs/types/satisfy.js.map +0 -1
  83. package/cjs/types/types.d.ts +0 -9
  84. package/cjs/types/types.js +0 -3
  85. package/cjs/types/types.js.map +0 -1
  86. package/esm/types/AllType.js +0 -2
  87. package/esm/types/AllType.js.map +0 -1
  88. package/esm/types/Any.js +0 -2
  89. package/esm/types/Any.js.map +0 -1
  90. package/esm/types/Array.js +0 -27
  91. package/esm/types/Array.js.map +0 -1
  92. package/esm/types/Boolean.js +0 -25
  93. package/esm/types/Boolean.js.map +0 -1
  94. package/esm/types/Generate.js +0 -2
  95. package/esm/types/Generate.js.map +0 -1
  96. package/esm/types/Null.js +0 -7
  97. package/esm/types/Null.js.map +0 -1
  98. package/esm/types/Number.js +0 -30
  99. package/esm/types/Number.js.map +0 -1
  100. package/esm/types/Object.js +0 -31
  101. package/esm/types/Object.js.map +0 -1
  102. package/esm/types/Record.js +0 -14
  103. package/esm/types/Record.js.map +0 -1
  104. package/esm/types/String.js +0 -31
  105. package/esm/types/String.js.map +0 -1
  106. package/esm/types/Symbol.js +0 -10
  107. package/esm/types/Symbol.js.map +0 -1
  108. package/esm/types/Tuple.js +0 -23
  109. package/esm/types/Tuple.js.map +0 -1
  110. package/esm/types/Undefined.js +0 -2
  111. package/esm/types/Undefined.js.map +0 -1
  112. package/esm/types/Union.js +0 -32
  113. package/esm/types/Union.js.map +0 -1
  114. package/esm/types/Unknown.js +0 -2
  115. package/esm/types/Unknown.js.map +0 -1
  116. package/esm/types/analyze.js +0 -142
  117. package/esm/types/analyze.js.map +0 -1
  118. package/esm/types/check.js +0 -21
  119. package/esm/types/check.js.map +0 -1
  120. package/esm/types/conform.js +0 -22
  121. package/esm/types/conform.js.map +0 -1
  122. package/esm/types/getPlainAnalysisReport.js +0 -106
  123. package/esm/types/getPlainAnalysisReport.js.map +0 -1
  124. package/esm/types/index.js +0 -28
  125. package/esm/types/index.js.map +0 -1
  126. package/esm/types/optional.js +0 -30
  127. package/esm/types/optional.js.map +0 -1
  128. package/esm/types/required.js +0 -30
  129. package/esm/types/required.js.map +0 -1
  130. package/esm/types/satisfy.js +0 -22
  131. package/esm/types/satisfy.js.map +0 -1
  132. package/esm/types/types.js +0 -2
  133. package/esm/types/types.js.map +0 -1
package/README.md CHANGED
@@ -15,7 +15,6 @@ Provides additional types and type adjusted utilities for [TypeScript](https://w
15
15
 
16
16
  ## Feature Highlights
17
17
 
18
- - [Runtime type checker](#runtime-type-checker)
19
18
  - [Type assertion](#type-assertion)
20
19
  - [Nominal Types](#nominal-type)
21
20
  - [Type Utilities](#type-utilities)
@@ -28,59 +27,6 @@ npm install type-plus
28
27
  yarn add type-plus
29
28
  ```
30
29
 
31
- ## Runtime type checker
32
-
33
- Bringing the power of TypeScript to JavaScript runtime.
34
- At the moment, this provides some basic functionalities.
35
- If you need more features, I would recommend other excellent type checking libraries such as [zod](https://github.com/colinhacks/zod).
36
-
37
- ```ts
38
- const eslintConfig = T.object.create({
39
- env: O.object.create({
40
- es6: O.boolean
41
- }),
42
- parseOptions: O.object.create({
43
- ecmaVersion: O.number.list(3, 5, 6, 7, 8, 9, 10, 11, 12),
44
- sourceType: O.string.list('script', 'module'),
45
- ecmaFeatures: O.object.create({
46
- globalReturn: O.boolean,
47
- impliedStrict: O.boolean,
48
- jsx: O.boolean
49
- })
50
- }),
51
- ...
52
- })
53
-
54
- const config: unknown = require('.eslintrc.json')
55
- if (T.satisfy(eslintConfig, config)) {
56
- // `config` is typed here
57
- config.parseOptions?.ecmaVersion // 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
58
- }
59
- else {
60
- console.error(T.satisfy.getReport())
61
- }
62
-
63
- ```
64
-
65
- All type checker functionalities are exposed as `types` (alias to `T`).
66
- In addition, `O` and `R` are exposed to make it easier to access optional types and required types respectively.
67
-
68
- Types supported: `any`, `array`, `boolean`, `null`, `number`, `object`, `record`, `string`, `symbol`, `tuple`, `undefined`, `union`, `unknown`.
69
-
70
- i.e., most of the basic types are supported except `bigint`.
71
- It is left out for backward compatibility reasons.
72
-
73
- You can use one of the three functions to perform type-check:
74
-
75
- `satisfy(type, subject)`:
76
- A loose type check that permits extra elements in `Tuple` and properties in `Object`.
77
-
78
- `conform(type, subject)`:
79
- A strict type check that does not allow extra elements in `Tuple` and properties in `Object`.
80
-
81
- `check(options, type, subject)`:
82
- A general form of `satisfy()` and `conform()`.
83
-
84
30
  ## Type Assertion
85
31
 
86
32
  Besides the [runtime type checker](#runtime-type-checker),
@@ -120,7 +66,7 @@ a standard `TypeError` will be thrown and provide better error info.
120
66
  For example:
121
67
 
122
68
  ```ts
123
- const s: any = 1
69
+ const s: unknown = 1
124
70
 
125
71
  // TypeError: subject fails to satisfy s => typeof s === 'boolean'
126
72
  assertType<boolean>(s, s => typeof s === 'boolean')
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as types from './types';
2
1
  export { required, requiredDeep } from 'unpartial';
3
2
  export * from './array';
4
3
  export * from './assertion';
@@ -14,8 +13,5 @@ export * from './object';
14
13
  export * from './predicates';
15
14
  export * from './PrimitiveTypes';
16
15
  export * from './promise';
17
- export * from './types/optional';
18
- export * from './types/required';
19
16
  export * from './UnionKeys';
20
17
  export * from './utils';
21
- export { types, types as T };
package/cjs/index.js CHANGED
@@ -6,26 +6,12 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
6
6
  if (k2 === undefined) k2 = k;
7
7
  o[k2] = m[k];
8
8
  }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
11
  };
24
12
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.T = exports.types = exports.requiredDeep = exports.required = void 0;
26
- var types = __importStar(require("./types"));
27
- exports.types = types;
28
- exports.T = types;
13
+ exports.requiredDeep = exports.required = void 0;
14
+ // import * as types from './types'
29
15
  var unpartial_1 = require("unpartial");
30
16
  Object.defineProperty(exports, "required", { enumerable: true, get: function () { return unpartial_1.required; } });
31
17
  Object.defineProperty(exports, "requiredDeep", { enumerable: true, get: function () { return unpartial_1.requiredDeep; } });
@@ -43,8 +29,9 @@ __exportStar(require("./object"), exports);
43
29
  __exportStar(require("./predicates"), exports);
44
30
  __exportStar(require("./PrimitiveTypes"), exports);
45
31
  __exportStar(require("./promise"), exports);
46
- __exportStar(require("./types/optional"), exports);
47
- __exportStar(require("./types/required"), exports);
32
+ // export * from './types/optional'
33
+ // export * from './types/required'
48
34
  __exportStar(require("./UnionKeys"), exports);
49
35
  __exportStar(require("./utils"), exports);
36
+ // export { types, types as T }
50
37
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgC;AAoBvB,sBAAK;AAAW,kBAAC;AAnB1B,uCAAkD;AAAzC,qGAAA,QAAQ,OAAA;AAAE,yGAAA,YAAY,OAAA;AAC/B,0CAAuB;AACvB,8CAA2B;AAC3B,0CAAuB;AACvB,oDAAiC;AACjC,6CAA0B;AAC1B,+CAA4B;AAC5B,8CAA2B;AAC3B,yCAAsB;AACtB,2CAAwB;AACxB,kDAA+B;AAC/B,2CAAwB;AACxB,+CAA4B;AAC5B,mDAAgC;AAChC,4CAAyB;AACzB,mDAAgC;AAChC,mDAAgC;AAChC,8CAA2B;AAC3B,0CAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mCAAmC;AACnC,uCAAkD;AAAzC,qGAAA,QAAQ,OAAA;AAAE,yGAAA,YAAY,OAAA;AAC/B,0CAAuB;AACvB,8CAA2B;AAC3B,0CAAuB;AACvB,oDAAiC;AACjC,6CAA0B;AAC1B,+CAA4B;AAC5B,8CAA2B;AAC3B,yCAAsB;AACtB,2CAAwB;AACxB,kDAA+B;AAC/B,2CAAwB;AACxB,+CAA4B;AAC5B,mDAAgC;AAChC,4CAAyB;AACzB,mCAAmC;AACnC,mCAAmC;AACnC,8CAA2B;AAC3B,0CAAuB;AACvB,+BAA+B"}
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as types from './types';
1
+ // import * as types from './types'
2
2
  export { required, requiredDeep } from 'unpartial';
3
3
  export * from './array';
4
4
  export * from './assertion';
@@ -14,9 +14,9 @@ export * from './object';
14
14
  export * from './predicates';
15
15
  export * from './PrimitiveTypes';
16
16
  export * from './promise';
17
- export * from './types/optional';
18
- export * from './types/required';
17
+ // export * from './types/optional'
18
+ // export * from './types/required'
19
19
  export * from './UnionKeys';
20
20
  export * from './utils';
21
- export { types, types as T };
21
+ // export { types, types as T }
22
22
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAClD,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC,EAAE,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAClD,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,mCAAmC;AACnC,mCAAmC;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,+BAA+B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-plus",
3
- "version": "3.15.0",
3
+ "version": "4.0.0",
4
4
  "description": "Provides additional types for `typescript`.",
5
5
  "homepage": "https://github.com/unional/type-plus",
6
6
  "bugs": {
package/ts/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as types from './types'
1
+ // import * as types from './types'
2
2
  export { required, requiredDeep } from 'unpartial'
3
3
  export * from './array'
4
4
  export * from './assertion'
@@ -14,8 +14,8 @@ export * from './object'
14
14
  export * from './predicates'
15
15
  export * from './PrimitiveTypes'
16
16
  export * from './promise'
17
- export * from './types/optional'
18
- export * from './types/required'
17
+ // export * from './types/optional'
18
+ // export * from './types/required'
19
19
  export * from './UnionKeys'
20
20
  export * from './utils'
21
- export { types, types as T }
21
+ // export { types, types as T }
@@ -1,4 +1,5 @@
1
- import { assertType, T } from '..'
1
+ import { assertType } from '..'
2
+ import * as T from '../types'
2
3
  import { createTypeChecker } from './typeChecker'
3
4
 
4
5
  describe('check()', () => {
@@ -1,4 +1,4 @@
1
- import { T } from '..'
1
+ import * as T from '.'
2
2
  import { check } from './check'
3
3
 
4
4
  test('check without strict', () => {
@@ -1,4 +1,4 @@
1
- import { T } from '..'
1
+ import * as T from '.'
2
2
  import { conform } from './conform'
3
3
 
4
4
  test('conform is strict', () => {
@@ -1,38 +1,39 @@
1
- import { baseline } from '@unional/fixture'
2
- import fs from 'fs'
3
- import path from 'path'
4
- import { T, O } from '..'
5
-
6
- const eslint = T.object.create({
7
- env: O.object.create({
8
- es6: O.boolean
9
- }),
10
- parseOptions: O.object.create({
11
- ecmaVersion: O.number.list(3, 5, 6, 7, 8, 9, 10, 11, 12),
12
- sourceType: O.string.list('script', 'module'),
13
- ecmaFeatures: O.object.create({
14
- globalReturn: O.boolean,
15
- impliedStrict: O.boolean,
16
- jsx: O.boolean
17
- })
18
- }),
19
- plugins: O.array.create(O.string),
20
- overrides: O.array.create(
21
- T.object.create({
22
- files: O.array.create(O.string),
23
- processor: O.string,
24
- rules: O.record.create(O.string.create('error'))
25
- })
26
- ),
27
- rules: O.record.create(O.string.create('error'))
28
- })
29
-
30
- baseline('fixtures/eslint', ({ caseName, caseFolder }) => {
31
- test(`eslint ${caseName}`, () => {
32
- const config: unknown = JSON.parse(
33
- fs.readFileSync(`${path.join(caseFolder, caseName)}`, 'utf-8')
34
- )
35
-
36
- if (!T.satisfy(eslint, config)) fail('should satisfy')
37
- })
38
- })
1
+ import { baseline } from '@unional/fixture'
2
+ import fs from 'fs'
3
+ import path from 'path'
4
+ import * as T from '.'
5
+ import { O } from './optional'
6
+
7
+ const eslint = T.object.create({
8
+ env: O.object.create({
9
+ es6: O.boolean
10
+ }),
11
+ parseOptions: O.object.create({
12
+ ecmaVersion: O.number.list(3, 5, 6, 7, 8, 9, 10, 11, 12),
13
+ sourceType: O.string.list('script', 'module'),
14
+ ecmaFeatures: O.object.create({
15
+ globalReturn: O.boolean,
16
+ impliedStrict: O.boolean,
17
+ jsx: O.boolean
18
+ })
19
+ }),
20
+ plugins: O.array.create(O.string),
21
+ overrides: O.array.create(
22
+ T.object.create({
23
+ files: O.array.create(O.string),
24
+ processor: O.string,
25
+ rules: O.record.create(O.string.create('error'))
26
+ })
27
+ ),
28
+ rules: O.record.create(O.string.create('error'))
29
+ })
30
+
31
+ baseline('fixtures/eslint', ({ caseName, caseFolder }) => {
32
+ test(`eslint ${caseName}`, () => {
33
+ const config: unknown = JSON.parse(
34
+ fs.readFileSync(`${path.join(caseFolder, caseName)}`, 'utf-8')
35
+ )
36
+
37
+ if (!T.satisfy(eslint, config)) fail('should satisfy')
38
+ })
39
+ })
@@ -1,5 +1,6 @@
1
1
  import { satisfies } from 'satisfier'
2
- import { assertType, T, Equal } from '..'
2
+ import { assertType, Equal } from '..'
3
+ import * as T from '.'
3
4
 
4
5
  describe('undefined', () => {
5
6
  test('satisfies only undefined', () => {
@@ -1,18 +0,0 @@
1
- import { Any } from './Any';
2
- import { Array } from './Array';
3
- import { Boolean } from './Boolean';
4
- import { Null } from './Null';
5
- import { Number } from './Number';
6
- import { ObjectType } from './Object';
7
- import { Record } from './Record';
8
- import { String } from './String';
9
- import { Symbol } from './Symbol';
10
- import { Tuple } from './Tuple';
11
- import { Undefined } from './Undefined';
12
- import { Union } from './Union';
13
- import { Unknown } from './Unknown';
14
- export declare type AllType = Undefined | Null | Boolean | Number | String | ObjectType | Record | Array | Tuple | Union | Unknown | Any | Symbol;
15
- export declare namespace AllType {
16
- type PrimitiveValues = boolean | number | string;
17
- type Analysis = Any.Analysis | Unknown.Analysis | Undefined.Analysis | Null.Analysis | Boolean.Analysis | Number.Analysis | String.Analysis | Symbol.Analysis | ObjectType.Analysis | Record.Analysis | Array.Analysis | Tuple.Analysis | Union.Analysis;
18
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AllType.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AllType.js","sourceRoot":"","sources":["../../ts/types/AllType.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- import { Type, TypeAnalysis } from './types';
2
- export declare type Any = Type<'any', undefined>;
3
- export declare namespace Any {
4
- type Analysis = TypeAnalysis<'any'>;
5
- }
6
- export declare const any: Any;
package/cjs/types/Any.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.any = void 0;
4
- exports.any = { type: 'any', value: undefined };
5
- //# sourceMappingURL=Any.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Any.js","sourceRoot":"","sources":["../../ts/types/Any.ts"],"names":[],"mappings":";;;AAMa,QAAA,GAAG,GAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA"}
@@ -1,28 +0,0 @@
1
- import { AllType } from './AllType';
2
- import { Type } from './types';
3
- import { Undefined } from './Undefined';
4
- import { Union } from './Union';
5
- export declare type Array<Value extends AllType = any> = Type<'array', Value>;
6
- export declare namespace Array {
7
- type Analysis<Value extends AllType.PrimitiveValues | AllType.Analysis = any> = {
8
- type: 'array';
9
- value?: Value;
10
- fail?: true;
11
- };
12
- }
13
- /**
14
- * Creates an array type.
15
- */
16
- declare function create<Value extends AllType>(value: Value): Array<Value>;
17
- export declare const array: Array<any> & {
18
- any: Array<any>;
19
- create: typeof create;
20
- optional: Union<[Array<any>, Undefined]> & {
21
- /**
22
- * Creates an optional array type.
23
- */
24
- create<Value extends AllType>(value: Value): Union<[Array<Value>, Undefined]>;
25
- };
26
- unknown: Array<import("./Unknown").Unknown>;
27
- };
28
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.array = void 0;
4
- var Undefined_1 = require("./Undefined");
5
- var Union_1 = require("./Union");
6
- var Unknown_1 = require("./Unknown");
7
- /**
8
- * Creates an array type.
9
- */
10
- function create(value) {
11
- return {
12
- type: 'array',
13
- value: value
14
- };
15
- }
16
- var any = create(undefined);
17
- exports.array = Object.assign({}, any, {
18
- any: any,
19
- create: create,
20
- optional: Object.assign(Union_1.union.create(any, Undefined_1.undef), {
21
- /**
22
- * Creates an optional array type.
23
- */
24
- create: function (value) {
25
- return Union_1.union.create(create(value), Undefined_1.undef);
26
- }
27
- }),
28
- unknown: create(Unknown_1.unknown)
29
- });
30
- //# sourceMappingURL=Array.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Array.js","sourceRoot":"","sources":["../../ts/types/Array.ts"],"names":[],"mappings":";;;AAGA,yCAA8C;AAC9C,iCAAsC;AACtC,qCAAmC;AAanC;;GAEG;AACH,SAAS,MAAM,CAAwB,KAAY;IACjD,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK,OAAA;KACN,CAAA;AACH,CAAC;AAED,IAAM,GAAG,GAAG,MAAM,CAAC,SAA2B,CAAC,CAAA;AAElC,QAAA,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE;IAC1C,GAAG,KAAA;IACH,MAAM,QAAA;IACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,aAAK,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAK,CAAC,EAAE;QAChD;;WAEG;QACH,MAAM,EAAN,UAA8B,KAAY;YACxC,OAAO,aAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,iBAAK,CAAC,CAAA;QAC3C,CAAC;KACF,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,iBAAO,CAAC;CACzB,CAAC,CAAA"}
@@ -1,29 +0,0 @@
1
- import { Type } from './types';
2
- import { Undefined } from './Undefined';
3
- import { Union } from './Union';
4
- export declare type Boolean<Value extends boolean = boolean> = Type<'boolean', Value>;
5
- export declare namespace Boolean {
6
- type Analysis = {
7
- type: 'boolean';
8
- value?: boolean;
9
- fail?: true;
10
- };
11
- }
12
- export declare type True = Boolean<true>;
13
- export declare type False = Boolean<false>;
14
- declare function create<Value extends boolean>(value: Value): Boolean<Value>;
15
- export declare const boolean: Boolean<boolean> & {
16
- any: Boolean<boolean>;
17
- true: Boolean<true>;
18
- false: Boolean<false>;
19
- create: typeof create;
20
- optional: Union<[Boolean<boolean>, Undefined]> & {
21
- /**
22
- * Creates an optional boolean type.
23
- */
24
- create<Value extends boolean>(value: Value): Union<[Boolean<Value>, Undefined]>;
25
- true: Union<[Boolean<true>, Undefined]>;
26
- false: Union<[Boolean<false>, Undefined]>;
27
- };
28
- };
29
- export {};
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.boolean = void 0;
4
- var Undefined_1 = require("./Undefined");
5
- var Union_1 = require("./Union");
6
- function create(value) {
7
- return { type: 'boolean', value: value };
8
- }
9
- var any = create(undefined);
10
- var t = create(true);
11
- var f = create(false);
12
- exports.boolean = Object.assign(any, {
13
- any: any,
14
- true: t,
15
- false: f,
16
- create: create,
17
- optional: Object.assign(Union_1.union.create(any, Undefined_1.undef), {
18
- /**
19
- * Creates an optional boolean type.
20
- */
21
- create: function (value) {
22
- return Union_1.union.create(create(value), Undefined_1.undef);
23
- },
24
- true: Union_1.union.create(t, Undefined_1.undef),
25
- false: Union_1.union.create(f, Undefined_1.undef),
26
- })
27
- });
28
- //# sourceMappingURL=Boolean.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Boolean.js","sourceRoot":"","sources":["../../ts/types/Boolean.ts"],"names":[],"mappings":";;;AACA,yCAA8C;AAC9C,iCAAsC;AAUtC,SAAS,MAAM,CAAwB,KAAY;IACjD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,OAAA,EAAE,CAAA;AACnC,CAAC;AAED,IAAM,GAAG,GAAG,MAAM,CAAC,SAA+B,CAAC,CAAA;AACnD,IAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;AACtB,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AAEV,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;IACxC,GAAG,KAAA;IACH,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,MAAM,QAAA;IACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,aAAK,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAK,CAAC,EAAE;QAChD;;WAEG;QACH,MAAM,EAAN,UAA8B,KAAY;YACxC,OAAO,aAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,iBAAK,CAAC,CAAA;QAC3C,CAAC;QACD,IAAI,EAAE,aAAK,CAAC,MAAM,CAAC,CAAC,EAAE,iBAAK,CAAC;QAC5B,KAAK,EAAE,aAAK,CAAC,MAAM,CAAC,CAAC,EAAE,iBAAK,CAAC;KAC9B,CAAC;CACH,CAAC,CAAA"}
@@ -1,32 +0,0 @@
1
- import { Tail } from '../array';
2
- import { AllType } from './AllType';
3
- import { Any } from './Any';
4
- import { Array } from './Array';
5
- import { Boolean, False, True } from './Boolean';
6
- import { Null } from './Null';
7
- import { Number } from './Number';
8
- import { ObjectType } from './Object';
9
- import { Record } from './Record';
10
- import { String } from './String';
11
- import { Symbol } from './Symbol';
12
- import { Tuple } from './Tuple';
13
- import { Undefined } from './Undefined';
14
- import { Union } from './Union';
15
- import { Unknown } from './Unknown';
16
- export declare type Generate<T extends AllType> = T extends Undefined ? undefined : T extends Null ? null : T extends True ? true : T extends False ? false : T extends Boolean ? boolean : T extends Symbol ? symbol : T extends Any ? any : T extends Unknown ? unknown : T extends Number ? T['value'] : T extends String ? T['value'] : T extends ObjectType ? {
17
- [K in keyof T['value']]: Generate<T['value'][K]>;
18
- } : T extends Record ? {
19
- [K: string]: Generate<T['value']>;
20
- } : T extends Array ? Generate<T['value']>[] : T extends Tuple ? Generate._TupleDevice<T['value']>['result'] : T extends Union ? Generate._UnionDevice<T['value']>['result'] : unknown;
21
- export declare namespace Generate {
22
- type _UnionDevice<T extends AllType[]> = T['length'] extends 0 ? {
23
- result: never;
24
- } : {
25
- result: Generate<T[0]> | _UnionDevice<Tail<T>>['result'];
26
- };
27
- type _TupleDevice<T extends AllType[]> = T['length'] extends 0 ? {
28
- result: [];
29
- } : {
30
- result: [Generate<T[0]>, ..._TupleDevice<Tail<T>>['result']];
31
- };
32
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Generate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Generate.js","sourceRoot":"","sources":["../../ts/types/Generate.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- import { TypeAnalysis, Type } from './types';
2
- export declare type Null = Type<'null', undefined>;
3
- export declare namespace Null {
4
- type Analysis = TypeAnalysis<'null'>;
5
- }
6
- export declare const nil: Null & {
7
- optional: import("./Union").Union<[Null, import("./Undefined").Undefined]>;
8
- };
package/cjs/types/Null.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nil = void 0;
4
- var Undefined_1 = require("./Undefined");
5
- var Union_1 = require("./Union");
6
- var any = { type: 'null', value: undefined };
7
- exports.nil = Object.assign({}, any, {
8
- optional: Union_1.union.create(any, Undefined_1.undef)
9
- });
10
- //# sourceMappingURL=Null.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Null.js","sourceRoot":"","sources":["../../ts/types/Null.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,iCAA+B;AAO/B,IAAM,GAAG,GAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA;AAEvC,QAAA,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE;IACxC,QAAQ,EAAE,aAAK,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAK,CAAC;CACnC,CAAC,CAAA"}
@@ -1,36 +0,0 @@
1
- import { Tail } from '../array';
2
- import { Type } from './types';
3
- import { Undefined } from './Undefined';
4
- import { Union } from './Union';
5
- export declare type Number<Value extends number = number> = Type<'number', Value>;
6
- export declare namespace Number {
7
- type Analysis = {
8
- type: 'number';
9
- value?: number;
10
- fail?: true;
11
- };
12
- }
13
- declare type NumberListDevice<Values extends number[] = number[]> = Values['length'] extends 0 ? {
14
- result: [];
15
- } : Values['length'] extends 1 ? {
16
- result: [Number<Values[0]>];
17
- } : {
18
- result: [Number<Values[0]>, Number<Values[1]>, ...NumberListDevice<Tail<Tail<Values>>>['result']];
19
- };
20
- /**
21
- * Creates a single number type.
22
- */
23
- declare function create<Value extends number>(value: Value): Number<Value>;
24
- export declare const number: Number<number> & {
25
- any: Number<number>;
26
- create: typeof create;
27
- list<Value extends number, Values extends number[]>(value: Value, ...values: Values): Union<NumberListDevice<[Value, ...Values]>["result"]>;
28
- optional: Union<[Number<number>, Undefined]> & {
29
- /**
30
- * Creates an optional number constant type.
31
- */
32
- create<Value_1 extends number>(value: Value_1): Union<[Number<Value_1>, Undefined]>;
33
- list<Value_2 extends number, Values_1 extends number[]>(value: Value_2, ...values: Values_1): Union<[...NumberListDevice<[Value_2, ...Values_1]>["result"], Undefined]>;
34
- };
35
- };
36
- export {};
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.number = void 0;
13
- var Undefined_1 = require("./Undefined");
14
- var Union_1 = require("./Union");
15
- /**
16
- * Creates a single number type.
17
- */
18
- function create(value) {
19
- return { type: 'number', value: value };
20
- }
21
- var any = create(undefined);
22
- exports.number = Object.assign(any, {
23
- any: any,
24
- create: create,
25
- // @ts-ignore we know that this can be infinite
26
- list: function (value) {
27
- var values = [];
28
- for (var _i = 1; _i < arguments.length; _i++) {
29
- values[_i - 1] = arguments[_i];
30
- }
31
- return Union_1.union.create.apply(Union_1.union, __spreadArray([create(value)], values.map(create), false));
32
- },
33
- optional: Object.assign(Union_1.union.create(any, Undefined_1.undef), {
34
- /**
35
- * Creates an optional number constant type.
36
- */
37
- create: function (value) {
38
- return Union_1.union.create(create(value), Undefined_1.undef);
39
- },
40
- // @ts-ignore we know that this can be infinite
41
- list: function (value) {
42
- var values = [];
43
- for (var _i = 1; _i < arguments.length; _i++) {
44
- values[_i - 1] = arguments[_i];
45
- }
46
- return Union_1.union.create.apply(Union_1.union, __spreadArray(__spreadArray([create(value)], values.map(create), false), [Undefined_1.undef], false));
47
- }
48
- })
49
- });
50
- //# sourceMappingURL=Number.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Number.js","sourceRoot":"","sources":["../../ts/types/Number.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAA8C;AAC9C,iCAAsC;AAiBtC;;GAEG;AACH,SAAS,MAAM,CAAuB,KAAY;IAChD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAA,EAAE,CAAA;AAClC,CAAC;AAED,IAAM,GAAG,GAAG,MAAM,CAAC,SAA8B,CAAC,CAAA;AAErC,QAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;IACvC,GAAG,KAAA;IACH,MAAM,QAAA;IACN,+CAA+C;IAC/C,IAAI,EAAJ,UAAoD,KAAY;QAAE,gBAAiB;aAAjB,UAAiB,EAAjB,qBAAiB,EAAjB,IAAiB;YAAjB,+BAAiB;;QAKjF,OAAO,aAAK,CAAC,MAAM,OAAZ,aAAK,iBAAQ,MAAM,CAAC,KAAK,CAAC,GAAK,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,SAAQ,CAAA;IAClE,CAAC;IACD,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,aAAK,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAK,CAAC,EAAE;QAChD;;WAEG;QACH,MAAM,EAAN,UAA6B,KAAY;YACvC,OAAO,aAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,iBAAK,CAAC,CAAA;QAC3C,CAAC;QACD,+CAA+C;QAC/C,IAAI,EAAJ,UAAoD,KAAY;YAAE,gBAAiB;iBAAjB,UAAiB,EAAjB,qBAAiB,EAAjB,IAAiB;gBAAjB,+BAAiB;;YAIjF,OAAO,aAAK,CAAC,MAAM,OAAZ,aAAK,+BAAQ,MAAM,CAAC,KAAK,CAAC,GAAK,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,WAAE,iBAAK,UAAQ,CAAA;QACzE,CAAC;KACF,CAAC;CACH,CAAC,CAAA"}