type-plus 3.15.0 → 4.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.
Files changed (210) hide show
  1. package/README.md +1 -55
  2. package/cjs/array/index.d.ts +17 -17
  3. package/cjs/array/index.js +5 -18
  4. package/cjs/array/index.js.map +1 -1
  5. package/cjs/assertion/index.js +5 -1
  6. package/cjs/assertion/index.js.map +1 -1
  7. package/cjs/class/index.d.ts +1 -1
  8. package/cjs/class/index.js +5 -2
  9. package/cjs/class/index.js.map +1 -1
  10. package/cjs/function/index.d.ts +1 -1
  11. package/cjs/function/index.js +0 -11
  12. package/cjs/function/index.js.map +1 -1
  13. package/cjs/functional/index.d.ts +1 -1
  14. package/cjs/functional/index.js +0 -12
  15. package/cjs/functional/index.js.map +1 -1
  16. package/cjs/index.d.ts +3 -7
  17. package/cjs/index.js +8 -22
  18. package/cjs/index.js.map +1 -1
  19. package/cjs/math/index.d.ts +7 -7
  20. package/cjs/math/index.js +0 -17
  21. package/cjs/math/index.js.map +1 -1
  22. package/cjs/nodejs/index.js +5 -1
  23. package/cjs/nodejs/index.js.map +1 -1
  24. package/cjs/nominal-types/index.js +5 -1
  25. package/cjs/nominal-types/index.js.map +1 -1
  26. package/cjs/object/index.d.ts +18 -18
  27. package/cjs/object/index.js +5 -19
  28. package/cjs/object/index.js.map +1 -1
  29. package/cjs/predicates/CanAssign.d.ts +1 -1
  30. package/cjs/predicates/{isEmptyObject.d.ts → IsEmptyObject.d.ts} +0 -0
  31. package/cjs/{types/AllType.js → predicates/IsEmptyObject.js} +1 -1
  32. package/cjs/predicates/IsEmptyObject.js.map +1 -0
  33. package/cjs/predicates/index.d.ts +5 -5
  34. package/cjs/predicates/index.js +5 -6
  35. package/cjs/predicates/index.js.map +1 -1
  36. package/cjs/promise/index.d.ts +2 -2
  37. package/cjs/promise/index.js +5 -3
  38. package/cjs/promise/index.js.map +1 -1
  39. package/cjs/utils/index.d.ts +1 -1
  40. package/cjs/utils/index.js +5 -2
  41. package/cjs/utils/index.js.map +1 -1
  42. package/esm/array/index.js +0 -17
  43. package/esm/array/index.js.map +1 -1
  44. package/esm/class/index.js +0 -1
  45. package/esm/class/index.js.map +1 -1
  46. package/esm/function/index.js +1 -1
  47. package/esm/function/index.js.map +1 -1
  48. package/esm/functional/index.js +1 -2
  49. package/esm/functional/index.js.map +1 -1
  50. package/esm/index.js +2 -7
  51. package/esm/index.js.map +1 -1
  52. package/esm/math/index.js +1 -7
  53. package/esm/math/index.js.map +1 -1
  54. package/esm/object/index.js +0 -18
  55. package/esm/object/index.js.map +1 -1
  56. package/esm/predicates/IsEmptyObject.js +2 -0
  57. package/esm/predicates/IsEmptyObject.js.map +1 -0
  58. package/esm/predicates/index.js +0 -5
  59. package/esm/predicates/index.js.map +1 -1
  60. package/esm/promise/index.js +0 -2
  61. package/esm/promise/index.js.map +1 -1
  62. package/esm/utils/index.js +0 -1
  63. package/esm/utils/index.js.map +1 -1
  64. package/package.json +20 -18
  65. package/ts/array/index.ts +19 -19
  66. package/ts/binary/_binary.ts +1 -1
  67. package/ts/class/index.ts +1 -1
  68. package/ts/function/index.ts +1 -1
  69. package/ts/functional/ChainFn.ts +6 -6
  70. package/ts/functional/index.ts +2 -2
  71. package/ts/index.spec.ts +6 -4
  72. package/ts/index.ts +7 -7
  73. package/ts/math/index.ts +7 -7
  74. package/ts/object/Partial.spec.ts +49 -49
  75. package/ts/object/index.ts +35 -35
  76. package/ts/predicates/CanAssign.ts +1 -1
  77. package/ts/predicates/{isEmptyObject.spec.ts → IsEmptyObject.spec.ts} +0 -0
  78. package/ts/predicates/{isEmptyObject.ts → IsEmptyObject.ts} +0 -0
  79. package/ts/predicates/index.ts +17 -17
  80. package/ts/promise/index.ts +2 -2
  81. package/ts/type-checker/typeChecker.spec.ts +2 -1
  82. package/ts/types/check.spec.ts +1 -1
  83. package/ts/types/conform.spec.ts +1 -1
  84. package/ts/types/index.ts +28 -28
  85. package/ts/types/satisfy.accept.ts +39 -38
  86. package/ts/types/satisfy.spec.ts +2 -1
  87. package/ts/utils/index.ts +2 -2
  88. package/cjs/predicates/isEmptyObject.js +0 -3
  89. package/cjs/predicates/isEmptyObject.js.map +0 -1
  90. package/cjs/types/AllType.d.ts +0 -18
  91. package/cjs/types/AllType.js.map +0 -1
  92. package/cjs/types/Any.d.ts +0 -6
  93. package/cjs/types/Any.js +0 -5
  94. package/cjs/types/Any.js.map +0 -1
  95. package/cjs/types/Array.d.ts +0 -28
  96. package/cjs/types/Array.js +0 -30
  97. package/cjs/types/Array.js.map +0 -1
  98. package/cjs/types/Boolean.d.ts +0 -29
  99. package/cjs/types/Boolean.js +0 -28
  100. package/cjs/types/Boolean.js.map +0 -1
  101. package/cjs/types/Generate.d.ts +0 -32
  102. package/cjs/types/Generate.js +0 -3
  103. package/cjs/types/Generate.js.map +0 -1
  104. package/cjs/types/Null.d.ts +0 -8
  105. package/cjs/types/Null.js +0 -10
  106. package/cjs/types/Null.js.map +0 -1
  107. package/cjs/types/Number.d.ts +0 -36
  108. package/cjs/types/Number.js +0 -50
  109. package/cjs/types/Number.js.map +0 -1
  110. package/cjs/types/Object.d.ts +0 -313
  111. package/cjs/types/Object.js +0 -35
  112. package/cjs/types/Object.js.map +0 -1
  113. package/cjs/types/Record.d.ts +0 -16
  114. package/cjs/types/Record.js +0 -17
  115. package/cjs/types/Record.js.map +0 -1
  116. package/cjs/types/String.d.ts +0 -36
  117. package/cjs/types/String.js +0 -51
  118. package/cjs/types/String.js.map +0 -1
  119. package/cjs/types/Symbol.d.ts +0 -8
  120. package/cjs/types/Symbol.js +0 -13
  121. package/cjs/types/Symbol.js.map +0 -1
  122. package/cjs/types/Tuple.d.ts +0 -35
  123. package/cjs/types/Tuple.js +0 -43
  124. package/cjs/types/Tuple.js.map +0 -1
  125. package/cjs/types/Undefined.d.ts +0 -6
  126. package/cjs/types/Undefined.js +0 -5
  127. package/cjs/types/Undefined.js.map +0 -1
  128. package/cjs/types/Union.d.ts +0 -20
  129. package/cjs/types/Union.js +0 -52
  130. package/cjs/types/Union.js.map +0 -1
  131. package/cjs/types/Unknown.d.ts +0 -6
  132. package/cjs/types/Unknown.js +0 -5
  133. package/cjs/types/Unknown.js.map +0 -1
  134. package/cjs/types/analyze.d.ts +0 -13
  135. package/cjs/types/analyze.js +0 -159
  136. package/cjs/types/analyze.js.map +0 -1
  137. package/cjs/types/check.d.ts +0 -14
  138. package/cjs/types/check.js +0 -25
  139. package/cjs/types/check.js.map +0 -1
  140. package/cjs/types/conform.d.ts +0 -15
  141. package/cjs/types/conform.js +0 -26
  142. package/cjs/types/conform.js.map +0 -1
  143. package/cjs/types/getPlainAnalysisReport.d.ts +0 -2
  144. package/cjs/types/getPlainAnalysisReport.js +0 -120
  145. package/cjs/types/getPlainAnalysisReport.js.map +0 -1
  146. package/cjs/types/index.d.ts +0 -26
  147. package/cjs/types/index.js +0 -45
  148. package/cjs/types/index.js.map +0 -1
  149. package/cjs/types/optional.d.ts +0 -328
  150. package/cjs/types/optional.js +0 -33
  151. package/cjs/types/optional.js.map +0 -1
  152. package/cjs/types/required.d.ts +0 -664
  153. package/cjs/types/required.js +0 -33
  154. package/cjs/types/required.js.map +0 -1
  155. package/cjs/types/satisfy.d.ts +0 -15
  156. package/cjs/types/satisfy.js +0 -26
  157. package/cjs/types/satisfy.js.map +0 -1
  158. package/cjs/types/types.d.ts +0 -9
  159. package/cjs/types/types.js +0 -3
  160. package/cjs/types/types.js.map +0 -1
  161. package/esm/predicates/isEmptyObject.js +0 -2
  162. package/esm/predicates/isEmptyObject.js.map +0 -1
  163. package/esm/types/AllType.js +0 -2
  164. package/esm/types/AllType.js.map +0 -1
  165. package/esm/types/Any.js +0 -2
  166. package/esm/types/Any.js.map +0 -1
  167. package/esm/types/Array.js +0 -27
  168. package/esm/types/Array.js.map +0 -1
  169. package/esm/types/Boolean.js +0 -25
  170. package/esm/types/Boolean.js.map +0 -1
  171. package/esm/types/Generate.js +0 -2
  172. package/esm/types/Generate.js.map +0 -1
  173. package/esm/types/Null.js +0 -7
  174. package/esm/types/Null.js.map +0 -1
  175. package/esm/types/Number.js +0 -30
  176. package/esm/types/Number.js.map +0 -1
  177. package/esm/types/Object.js +0 -31
  178. package/esm/types/Object.js.map +0 -1
  179. package/esm/types/Record.js +0 -14
  180. package/esm/types/Record.js.map +0 -1
  181. package/esm/types/String.js +0 -31
  182. package/esm/types/String.js.map +0 -1
  183. package/esm/types/Symbol.js +0 -10
  184. package/esm/types/Symbol.js.map +0 -1
  185. package/esm/types/Tuple.js +0 -23
  186. package/esm/types/Tuple.js.map +0 -1
  187. package/esm/types/Undefined.js +0 -2
  188. package/esm/types/Undefined.js.map +0 -1
  189. package/esm/types/Union.js +0 -32
  190. package/esm/types/Union.js.map +0 -1
  191. package/esm/types/Unknown.js +0 -2
  192. package/esm/types/Unknown.js.map +0 -1
  193. package/esm/types/analyze.js +0 -142
  194. package/esm/types/analyze.js.map +0 -1
  195. package/esm/types/check.js +0 -21
  196. package/esm/types/check.js.map +0 -1
  197. package/esm/types/conform.js +0 -22
  198. package/esm/types/conform.js.map +0 -1
  199. package/esm/types/getPlainAnalysisReport.js +0 -106
  200. package/esm/types/getPlainAnalysisReport.js.map +0 -1
  201. package/esm/types/index.js +0 -28
  202. package/esm/types/index.js.map +0 -1
  203. package/esm/types/optional.js +0 -30
  204. package/esm/types/optional.js.map +0 -1
  205. package/esm/types/required.js +0 -30
  206. package/esm/types/required.js.map +0 -1
  207. package/esm/types/satisfy.js +0 -22
  208. package/esm/types/satisfy.js.map +0 -1
  209. package/esm/types/types.js +0 -2
  210. package/esm/types/types.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { NotExtendable } from './Extends'
2
- import { IsEmptyObject } from './isEmptyObject'
2
+ import { IsEmptyObject } from './IsEmptyObject'
3
3
 
4
4
  /**
5
5
  * Can `A` assign to `B`
@@ -1,17 +1,17 @@
1
- export * from './CanAssign'
2
- export * from './Equal'
3
- export * from './Extends'
4
- export * from './If'
5
- export * from './isType'
6
- export * from './logical'
7
- export * from './isEmptyObject'
8
-
9
- import { IsExtend } from './Extends'
10
-
11
- export type IsLiteral<T extends number | string, Then = true, Else = false> = number extends T ?
12
- Else :
13
- string extends T ? Else : Then
14
-
15
- export type IsBoolean<T, Then = true, Else = false> = boolean extends T ? Then : Else
16
-
17
- export type IsAny<T, Then = true, Else = false> = boolean extends IsExtend<T, string> ? Then : Else
1
+ export * from './CanAssign'
2
+ export type { Equal, IsEqual, IsNotEqual, NotEqual } from './Equal'
3
+ export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends'
4
+ export type { If } from './If'
5
+ export * from './isType'
6
+ export type { And, Not, Or, Xor } from './logical'
7
+ export type { IsEmptyObject } from './IsEmptyObject'
8
+
9
+ import { IsExtend } from './Extends'
10
+
11
+ export type IsLiteral<T extends number | string, Then = true, Else = false> = number extends T ?
12
+ Else :
13
+ string extends T ? Else : Then
14
+
15
+ export type IsBoolean<T, Then = true, Else = false> = boolean extends T ? Then : Else
16
+
17
+ export type IsAny<T, Then = true, Else = false> = boolean extends IsExtend<T, string> ? Then : Else
@@ -1,4 +1,4 @@
1
1
  export * from './isPromise'
2
- export * from './PromiseValue'
3
- export * from './PromiseValueMerge'
2
+ export type { PromiseValue } from './PromiseValue'
3
+ export type { PromiseValueMerge } from './PromiseValueMerge'
4
4
  export * from './mapSeries'
@@ -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', () => {
package/ts/types/index.ts CHANGED
@@ -1,28 +1,28 @@
1
- /**
2
- * A turing complete solution inspired by many.
3
- * The types is in Pascal Cases
4
- * because lower case type names (e.g. true) is a reserved keyword.
5
- * https://github.com/microsoft/TypeScript/issues/14833
6
- * https://github.com/tycho01/typical
7
- */
8
-
9
- // export * from './BigInt'
10
- export * from './AllType'
11
- export * from './Any'
12
- export * from './Array'
13
- export * from './Boolean'
14
- export * from './check'
15
- export * from './conform'
16
- export * from './Generate'
17
- export { nil as null, Null } from './Null'
18
- export * from './Number'
19
- export { keys, object, ObjectType as Object } from './Object'
20
- export * from './Record'
21
- export * from './satisfy'
22
- export * from './String'
23
- export * from './Symbol'
24
- export * from './Tuple'
25
- export * from './types'
26
- export { undef as undefined, Undefined } from './Undefined'
27
- export * from './Union'
28
- export * from './Unknown'
1
+ /**
2
+ * A turing complete solution inspired by many.
3
+ * The types is in Pascal Cases
4
+ * because lower case type names (e.g. true) is a reserved keyword.
5
+ * https://github.com/microsoft/TypeScript/issues/14833
6
+ * https://github.com/tycho01/typical
7
+ */
8
+
9
+ // export * from './BigInt'
10
+ export type { AllType } from './AllType'
11
+ export * from './Any'
12
+ export * from './Array'
13
+ export * from './Boolean'
14
+ export * from './check'
15
+ export * from './conform'
16
+ export type { Generate } from './Generate'
17
+ export { nil as null, Null } from './Null'
18
+ export * from './Number'
19
+ export { keys, object, ObjectType as Object } from './Object'
20
+ export * from './Record'
21
+ export * from './satisfy'
22
+ export * from './String'
23
+ export * from './Symbol'
24
+ export * from './Tuple'
25
+ export * from './types'
26
+ export { undef as undefined, Undefined } from './Undefined'
27
+ export * from './Union'
28
+ export * from './Unknown'
@@ -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', () => {
package/ts/utils/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './as'
2
- export * from './Widen'
1
+ export * from './as'
2
+ export type { Widen } from './Widen'
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=isEmptyObject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isEmptyObject.js","sourceRoot":"","sources":["../../ts/predicates/isEmptyObject.ts"],"names":[],"mappings":""}
@@ -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 +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"}