arktype 0.1.4 → 0.3.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 (106) hide show
  1. package/README.md +1 -1
  2. package/dist/api.cjs +4 -3
  3. package/dist/api.d.ts +3 -2
  4. package/dist/api.mjs +2 -1
  5. package/dist/cjs/nodes/{branches.js → branch.js} +56 -10
  6. package/dist/cjs/nodes/compose.js +1 -2
  7. package/dist/cjs/nodes/discriminate.js +7 -13
  8. package/dist/cjs/nodes/node.js +32 -4
  9. package/dist/cjs/nodes/predicate.js +7 -7
  10. package/dist/cjs/nodes/rules/class.js +10 -4
  11. package/dist/cjs/nodes/rules/divisor.js +1 -5
  12. package/dist/cjs/nodes/rules/props.js +75 -25
  13. package/dist/cjs/nodes/rules/range.js +1 -5
  14. package/dist/cjs/nodes/rules/regex.js +2 -44
  15. package/dist/cjs/nodes/rules/rules.js +21 -61
  16. package/dist/cjs/parse/definition.js +2 -2
  17. package/dist/cjs/parse/string/reduce/dynamic.js +1 -2
  18. package/dist/cjs/parse/string/shift/operator/bounds.js +1 -1
  19. package/dist/cjs/parse/string/string.js +2 -2
  20. package/dist/cjs/parse/tuple/keyof.js +37 -18
  21. package/dist/cjs/parse/tuple/morph.js +7 -6
  22. package/dist/cjs/parse/tuple/tuple.js +16 -9
  23. package/dist/cjs/scopes/cache.js +39 -0
  24. package/dist/cjs/scopes/jsObjects.js +133 -0
  25. package/dist/cjs/{main.js → scopes/scope.js} +31 -364
  26. package/dist/cjs/scopes/standard.js +44 -0
  27. package/dist/cjs/scopes/tsKeywords.js +113 -0
  28. package/dist/cjs/scopes/type.js +67 -0
  29. package/dist/cjs/scopes/validation.js +64 -0
  30. package/dist/cjs/traverse/problems.js +55 -95
  31. package/dist/cjs/traverse/traverse.js +127 -134
  32. package/dist/cjs/utils/numericLiterals.js +3 -0
  33. package/dist/cjs/utils/objectKinds.js +1 -2
  34. package/dist/mjs/nodes/{branches.js → branch.js} +45 -2
  35. package/dist/mjs/nodes/compose.js +1 -2
  36. package/dist/mjs/nodes/discriminate.js +6 -12
  37. package/dist/mjs/nodes/node.js +30 -3
  38. package/dist/mjs/nodes/predicate.js +2 -2
  39. package/dist/mjs/nodes/rules/class.js +10 -4
  40. package/dist/mjs/nodes/rules/divisor.js +1 -5
  41. package/dist/mjs/nodes/rules/props.js +74 -27
  42. package/dist/mjs/nodes/rules/range.js +1 -5
  43. package/dist/mjs/nodes/rules/regex.js +1 -43
  44. package/dist/mjs/nodes/rules/rules.js +22 -61
  45. package/dist/mjs/parse/definition.js +1 -1
  46. package/dist/mjs/parse/string/reduce/dynamic.js +2 -3
  47. package/dist/mjs/parse/string/shift/operator/bounds.js +1 -1
  48. package/dist/mjs/parse/string/string.js +2 -2
  49. package/dist/mjs/parse/tuple/keyof.js +38 -19
  50. package/dist/mjs/parse/tuple/morph.js +7 -6
  51. package/dist/mjs/parse/tuple/tuple.js +17 -10
  52. package/dist/mjs/scopes/cache.js +25 -0
  53. package/dist/mjs/scopes/jsObjects.js +119 -0
  54. package/dist/mjs/{main.js → scopes/scope.js} +15 -344
  55. package/dist/mjs/scopes/standard.js +27 -0
  56. package/dist/mjs/scopes/tsKeywords.js +99 -0
  57. package/dist/mjs/scopes/type.js +53 -0
  58. package/dist/mjs/scopes/validation.js +51 -0
  59. package/dist/mjs/traverse/problems.js +55 -95
  60. package/dist/mjs/traverse/traverse.js +129 -135
  61. package/dist/mjs/utils/numericLiterals.js +2 -1
  62. package/dist/mjs/utils/objectKinds.js +1 -1
  63. package/dist/tsconfig.temp.tsbuildinfo +1 -1
  64. package/dist/types/nodes/branch.d.ts +36 -0
  65. package/dist/types/nodes/compose.d.ts +6 -11
  66. package/dist/types/nodes/discriminate.d.ts +1 -1
  67. package/dist/types/nodes/infer.d.ts +16 -15
  68. package/dist/types/nodes/node.d.ts +18 -9
  69. package/dist/types/nodes/predicate.d.ts +18 -57
  70. package/dist/types/nodes/rules/class.d.ts +3 -2
  71. package/dist/types/nodes/rules/divisor.d.ts +2 -1
  72. package/dist/types/nodes/rules/props.d.ts +19 -11
  73. package/dist/types/nodes/rules/range.d.ts +2 -1
  74. package/dist/types/nodes/rules/regex.d.ts +2 -11
  75. package/dist/types/nodes/rules/rules.d.ts +11 -21
  76. package/dist/types/parse/definition.d.ts +1 -1
  77. package/dist/types/parse/string/ast.d.ts +4 -2
  78. package/dist/types/parse/string/reduce/shared.d.ts +1 -1
  79. package/dist/types/parse/string/reduce/static.d.ts +1 -1
  80. package/dist/types/parse/string/shift/operator/bounds.d.ts +1 -1
  81. package/dist/types/parse/string/string.d.ts +1 -1
  82. package/dist/types/parse/tuple/keyof.d.ts +2 -2
  83. package/dist/types/parse/tuple/morph.d.ts +1 -1
  84. package/dist/types/parse/tuple/narrow.d.ts +1 -1
  85. package/dist/types/parse/tuple/tuple.d.ts +1 -1
  86. package/dist/types/scopes/cache.d.ts +14 -0
  87. package/dist/types/scopes/jsObjects.d.ts +36 -0
  88. package/dist/types/scopes/scope.d.ts +76 -0
  89. package/dist/types/scopes/standard.d.ts +280 -0
  90. package/dist/types/scopes/tsKeywords.d.ts +32 -0
  91. package/dist/types/scopes/type.d.ts +47 -0
  92. package/dist/types/scopes/validation.d.ts +21 -0
  93. package/dist/types/traverse/problems.d.ts +35 -53
  94. package/dist/types/traverse/traverse.d.ts +30 -24
  95. package/dist/types/utils/generics.d.ts +0 -1
  96. package/dist/types/utils/numericLiterals.d.ts +2 -0
  97. package/dist/types/utils/objectKinds.d.ts +43 -43
  98. package/package.json +2 -3
  99. package/dist/cjs/nodes/functors.js +0 -35
  100. package/dist/cjs/nodes/rules/objectKind.js +0 -78
  101. package/dist/mjs/nodes/functors.js +0 -27
  102. package/dist/mjs/nodes/rules/objectKind.js +0 -63
  103. package/dist/types/main.d.ts +0 -324
  104. package/dist/types/nodes/branches.d.ts +0 -14
  105. package/dist/types/nodes/functors.d.ts +0 -6
  106. package/dist/types/nodes/rules/objectKind.d.ts +0 -15
@@ -9,56 +9,23 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- branchIntersection: ()=>branchIntersection,
13
12
  rulesIntersection: ()=>rulesIntersection,
14
13
  narrowableRulesIntersection: ()=>narrowableRulesIntersection,
14
+ flattenRules: ()=>flattenRules,
15
15
  precedenceMap: ()=>precedenceMap,
16
- flattenBranch: ()=>flattenBranch,
17
16
  literalSatisfiesRules: ()=>literalSatisfiesRules
18
17
  });
19
- const _astTs = require("../../parse/string/ast.js");
20
- const _errorsTs = require("../../utils/errors.js");
21
18
  const _genericsTs = require("../../utils/generics.js");
22
19
  const _composeTs = require("../compose.js");
23
20
  const _classTs = require("./class.js");
24
21
  const _collapsibleSetTs = require("./collapsibleSet.js");
25
22
  const _divisorTs = require("./divisor.js");
26
- const _objectKindTs = require("./objectKind.js");
27
23
  const _propsTs = require("./props.js");
28
24
  const _rangeTs = require("./range.js");
29
25
  const _regexTs = require("./regex.js");
30
- const rulesOf = (branch)=>branch.input ?? branch;
31
- const branchIntersection = (l, r, state)=>{
32
- const lRules = rulesOf(l);
33
- const rRules = rulesOf(r);
34
- const rulesResult = rulesIntersection(lRules, rRules, state);
35
- if ("morph" in l) {
36
- if ("morph" in r) {
37
- if (l.morph === r.morph) {
38
- return (0, _composeTs.isEquality)(rulesResult) || (0, _composeTs.isDisjoint)(rulesResult) ? rulesResult : {
39
- input: rulesResult,
40
- morph: l.morph
41
- };
42
- }
43
- return state.lastOperator === "&" ? (0, _errorsTs.throwParseError)((0, _astTs.writeImplicitNeverMessage)(state.path, "Intersection", "of morphs")) : {};
44
- }
45
- return (0, _composeTs.isDisjoint)(rulesResult) ? rulesResult : {
46
- input: (0, _composeTs.isEquality)(rulesResult) ? l.input : rulesResult,
47
- morph: l.morph
48
- };
49
- }
50
- if ("morph" in r) {
51
- return (0, _composeTs.isDisjoint)(rulesResult) ? rulesResult : {
52
- input: (0, _composeTs.isEquality)(rulesResult) ? r.input : rulesResult,
53
- morph: r.morph
54
- };
55
- }
56
- return rulesResult;
57
- };
58
26
  const rulesIntersection = (l, r, state)=>"value" in l ? "value" in r ? l.value === r.value ? (0, _composeTs.equality)() : state.addDisjoint("value", l.value, r.value) : literalSatisfiesRules(l.value, r, state) ? l : state.addDisjoint("leftAssignability", l, r) : "value" in r ? literalSatisfiesRules(r.value, l, state) ? r : state.addDisjoint("rightAssignability", l, r) : narrowableRulesIntersection(l, r, state);
59
27
  const narrowIntersection = (0, _composeTs.composeIntersection)(_collapsibleSetTs.collapsibleListUnion);
60
28
  const narrowableRulesIntersection = (0, _composeTs.composeKeyedIntersection)({
61
- objectKind: _objectKindTs.objectKindIntersection,
62
29
  divisor: _divisorTs.divisorIntersection,
63
30
  regex: _regexTs.regexIntersection,
64
31
  props: _propsTs.propsIntersection,
@@ -68,13 +35,20 @@ const narrowableRulesIntersection = (0, _composeTs.composeKeyedIntersection)({
68
35
  }, {
69
36
  onEmpty: "bubble"
70
37
  });
38
+ const flattenRules = (rules, ctx)=>{
39
+ const entries = [];
40
+ let k;
41
+ for(k in rules){
42
+ ruleFlatteners[k](entries, rules[k], ctx);
43
+ }
44
+ return entries.sort((l, r)=>precedenceMap[l[0]] - precedenceMap[r[0]]);
45
+ };
71
46
  const ruleFlatteners = {
72
- objectKind: _objectKindTs.flattenObjectKind,
73
47
  regex: (entries, rule)=>{
74
48
  for (const source of (0, _genericsTs.listFrom)(rule)){
75
49
  entries.push([
76
50
  "regex",
77
- (0, _regexTs.getRegex)(source)
51
+ source
78
52
  ]);
79
53
  }
80
54
  },
@@ -109,44 +83,30 @@ const ruleFlatteners = {
109
83
  };
110
84
  const precedenceMap = {
111
85
  // Critical: No other checks are performed if these fail
86
+ config: 0,
112
87
  domain: 0,
113
88
  value: 0,
114
89
  domains: 0,
115
90
  branches: 0,
116
- objectKind: 0,
117
91
  switch: 0,
118
92
  alias: 0,
93
+ class: 0,
119
94
  // Shallow: All shallow checks will be performed even if one or more fail
120
- class: 1,
121
95
  regex: 1,
122
96
  divisor: 1,
123
97
  bound: 1,
98
+ // Prerequisite: These are deep checks with special priority, e.g. the
99
+ // length of a tuple, which causes other deep props not to be checked if it
100
+ // is invalid
101
+ prerequisiteProp: 2,
124
102
  // Deep: Performed if all shallow checks pass, even if one or more deep checks fail
125
- requiredProps: 2,
126
- optionalProps: 2,
103
+ requiredProp: 3,
104
+ optionalProp: 3,
105
+ indexProp: 3,
127
106
  // Narrow: Only performed if all shallow and deep checks pass
128
- narrow: 3,
107
+ narrow: 4,
129
108
  // Morph: Only performed if all validation passes
130
- morph: 4
131
- };
132
- const flattenBranch = (branch, ctx)=>{
133
- if ("morph" in branch) {
134
- const result = flattenRules(branch.input, ctx);
135
- result.push([
136
- "morph",
137
- branch.morph
138
- ]);
139
- return result;
140
- }
141
- return flattenRules(branch, ctx);
142
- };
143
- const flattenRules = (rules, ctx)=>{
144
- const entries = [];
145
- let k;
146
- for(k in rules){
147
- ruleFlatteners[k](entries, rules[k], ctx);
148
- }
149
- return entries.sort((l, r)=>precedenceMap[l[0]] - precedenceMap[r[0]]);
109
+ morph: 5
150
110
  };
151
111
  const literalSatisfiesRules = (data, rules, state)=>!state.type.meta.scope.type([
152
112
  "node",
@@ -14,7 +14,7 @@ _export(exports, {
14
14
  unknownDefinitionMessage: ()=>unknownDefinitionMessage,
15
15
  writeBadDefinitionTypeMessage: ()=>writeBadDefinitionTypeMessage
16
16
  });
17
- const _mainTs = require("../main.js");
17
+ const _typeTs = require("../scopes/type.js");
18
18
  const _domainsTs = require("../utils/domains.js");
19
19
  const _errorsTs = require("../utils/errors.js");
20
20
  const _objectKindsTs = require("../utils/objectKinds.js");
@@ -43,7 +43,7 @@ const parseDefinition = (def, ctx)=>{
43
43
  }
44
44
  };
45
45
  case "Function":
46
- return (0, _mainTs.isType)(def) ? def.node : (0, _errorsTs.throwParseError)(writeBadDefinitionTypeMessage("Function"));
46
+ return (0, _typeTs.isType)(def) ? def.node : (0, _errorsTs.throwParseError)(writeBadDefinitionTypeMessage("Function"));
47
47
  default:
48
48
  return (0, _errorsTs.throwParseError)(writeBadDefinitionTypeMessage(objectKind ?? (0, _serializeTs.stringify)(def)));
49
49
  }
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "DynamicState", {
6
6
  enumerable: true,
7
7
  get: ()=>DynamicState
8
8
  });
9
- const _functorsTs = require("../../../nodes/functors.js");
10
9
  const _nodeTs = require("../../../nodes/node.js");
11
10
  const _rangeTs = require("../../../nodes/rules/range.js");
12
11
  const _errorsTs = require("../../../utils/errors.js");
@@ -60,7 +59,7 @@ class DynamicState {
60
59
  this.root = node;
61
60
  }
62
61
  rootToArray() {
63
- this.root = _functorsTs.functors.Array(this.ejectRoot());
62
+ this.root = (0, _nodeTs.arrayOf)(this.ejectRoot());
64
63
  }
65
64
  intersect(node) {
66
65
  this.root = (0, _nodeTs.intersection)(this.ejectRoot(), node, this.ctx.type);
@@ -71,7 +71,7 @@ const distributeRange = (range, s)=>{
71
71
  if (resolution.object === true) {
72
72
  return false;
73
73
  }
74
- return (0, _genericsTs.listFrom)(resolution.object).every((branch)=>(0, _genericsTs.hasKey)(branch, "objectKind") && (branch.objectKind === "Array" || branch.objectKind[0] === "Array"));
74
+ return (0, _genericsTs.listFrom)(resolution.object).every((branch)=>(0, _genericsTs.hasKey)(branch, "class") && branch.class === "Array");
75
75
  default:
76
76
  return false;
77
77
  }
@@ -13,7 +13,7 @@ _export(exports, {
13
13
  maybeNaiveParse: ()=>maybeNaiveParse,
14
14
  fullStringParse: ()=>fullStringParse
15
15
  });
16
- const _functorsTs = require("../../nodes/functors.js");
16
+ const _nodeTs = require("../../nodes/node.js");
17
17
  const _dynamicTs = require("./reduce/dynamic.js");
18
18
  const _operandTs = require("./shift/operand/operand.js");
19
19
  const _operatorTs = require("./shift/operator/operator.js");
@@ -25,7 +25,7 @@ const maybeNaiveParse = (def, ctx)=>{
25
25
  if (def.endsWith("[]")) {
26
26
  const elementDef = def.slice(0, -2);
27
27
  if (ctx.type.meta.scope.addReferenceIfResolvable(def, ctx)) {
28
- return _functorsTs.functors.Array(elementDef);
28
+ return (0, _nodeTs.arrayOf)(elementDef);
29
29
  }
30
30
  }
31
31
  };
@@ -7,10 +7,15 @@ Object.defineProperty(exports, "parseKeyOfTuple", {
7
7
  get: ()=>parseKeyOfTuple
8
8
  });
9
9
  const _predicateTs = require("../../nodes/predicate.js");
10
+ const _propsTs = require("../../nodes/rules/props.js");
10
11
  const _errorsTs = require("../../utils/errors.js");
11
12
  const _genericsTs = require("../../utils/generics.js");
13
+ const _numericLiteralsTs = require("../../utils/numericLiterals.js");
12
14
  const _definitionTs = require("../definition.js");
13
15
  const _astTs = require("../string/ast.js");
16
+ const numericIndexKey = {
17
+ regex: _numericLiteralsTs.wellFormedNonNegativeIntegerMatcher.source
18
+ };
14
19
  const parseKeyOfTuple = (def, ctx)=>{
15
20
  const resolution = ctx.type.meta.scope.resolveNode((0, _definitionTs.parseDefinition)(def[1], ctx));
16
21
  if (!(0, _predicateTs.resolutionExtendsDomain)(resolution, "object")) {
@@ -19,27 +24,41 @@ const parseKeyOfTuple = (def, ctx)=>{
19
24
  if (resolution.object === true) {
20
25
  return (0, _astTs.writeImplicitNeverMessage)(ctx.path, "keyof");
21
26
  }
22
- const branchKeys = [];
23
27
  const objectBranches = (0, _genericsTs.listFrom)(resolution.object);
24
- const initialKeys = getPropsFromBranch(objectBranches[0]);
28
+ let sharedKeys = keysOfBranch(objectBranches[0]);
25
29
  for(let i = 1; i < objectBranches.length; i++){
26
- const keys = getPropsFromBranch(objectBranches[i]);
27
- if (!keys.length) {
28
- return (0, _astTs.writeImplicitNeverMessage)(ctx.path, "keyof");
29
- }
30
- branchKeys.push(keys);
30
+ const branchKeys = keysOfBranch(objectBranches[i]);
31
+ // we can filter directly by equality here because the RegExp we're
32
+ // using will always be reference equal to
33
+ // wellFormedNonNegativeIntegerMatcher
34
+ sharedKeys = sharedKeys.filter((k)=>branchKeys.includes(k));
31
35
  }
32
- const result = [];
33
- initialKeys.forEach((key)=>{
34
- const hasKey = branchKeys.every((keySet)=>keySet.includes(key));
35
- if (hasKey) {
36
- result.push({
37
- value: key
38
- });
39
- }
40
- });
36
+ const result = sharedKeys.map((k)=>typeof k === "string" ? {
37
+ value: k
38
+ } : {
39
+ regex: k.source
40
+ });
41
41
  return result.length ? {
42
- string: result
42
+ string: result.length === 1 ? result[0] : result
43
43
  } : (0, _astTs.writeImplicitNeverMessage)(ctx.path, "keyof");
44
44
  };
45
- const getPropsFromBranch = (branch)=>(0, _genericsTs.hasKey)(branch, "props") ? Object.keys(branch.props) : [];
45
+ const keysOfBranch = (branch)=>{
46
+ if (!("props" in branch)) {
47
+ return [];
48
+ }
49
+ if (branch.class !== "Array") {
50
+ return Object.keys(branch.props);
51
+ }
52
+ const arrayProps = [];
53
+ for (const key of Object.keys(branch.props)){
54
+ if (key === "length") {
55
+ continue;
56
+ }
57
+ if (key === _propsTs.mappedKeys.index) {
58
+ arrayProps.push(_numericLiteralsTs.wellFormedNonNegativeIntegerMatcher);
59
+ } else {
60
+ arrayProps.push(key);
61
+ }
62
+ }
63
+ return arrayProps;
64
+ };
@@ -12,6 +12,7 @@ _export(exports, {
12
12
  parseMorphTuple: ()=>parseMorphTuple,
13
13
  writeMalformedMorphExpressionMessage: ()=>writeMalformedMorphExpressionMessage
14
14
  });
15
+ const _branchTs = require("../../nodes/branch.js");
15
16
  const _errorsTs = require("../../utils/errors.js");
16
17
  const _objectKindsTs = require("../../utils/objectKinds.js");
17
18
  const _serializeTs = require("../../utils/serialize.js");
@@ -29,7 +30,7 @@ const parseMorphTuple = (def, ctx)=>{
29
30
  const predicate = resolution[domain];
30
31
  if (predicate === true) {
31
32
  result[domain] = {
32
- input: {},
33
+ rules: {},
33
34
  morph
34
35
  };
35
36
  } else if (typeof predicate === "object") {
@@ -40,17 +41,17 @@ const parseMorphTuple = (def, ctx)=>{
40
41
  }
41
42
  return result;
42
43
  };
43
- const applyMorph = (branch, morph)=>branch.morph ? {
44
- input: branch.input,
45
- morph: Array.isArray(branch.morph) ? [
44
+ const applyMorph = (branch, morph)=>(0, _branchTs.isMorphBranch)(branch) ? {
45
+ ...branch,
46
+ morph: branch.morph ? Array.isArray(branch.morph) ? [
46
47
  ...branch.morph,
47
48
  morph
48
49
  ] : [
49
50
  branch.morph,
50
51
  morph
51
- ]
52
+ ] : morph
52
53
  } : {
53
- input: branch,
54
+ rules: branch,
54
55
  morph
55
56
  };
56
57
  const writeMalformedMorphExpressionMessage = (value)=>`Morph expression requires a function following '=>' (was ${typeof value})`;
@@ -12,7 +12,6 @@ _export(exports, {
12
12
  parseTuple: ()=>parseTuple,
13
13
  writeMalformedFunctionalExpressionMessage: ()=>writeMalformedFunctionalExpressionMessage
14
14
  });
15
- const _functorsTs = require("../../nodes/functors.js");
16
15
  const _nodeTs = require("../../nodes/node.js");
17
16
  const _domainsTs = require("../../utils/domains.js");
18
17
  const _errorsTs = require("../../utils/errors.js");
@@ -28,7 +27,19 @@ const parseTuple = (def, ctx)=>{
28
27
  if (isPrefixExpression(def)) {
29
28
  return prefixParsers[def[0]](def, ctx);
30
29
  }
31
- const props = {};
30
+ const props = {
31
+ // length is created as a prerequisite prop, ensuring if it is invalid,
32
+ // no other props will be checked, which is usually desirable for tuple
33
+ // definitions.
34
+ length: [
35
+ "!",
36
+ {
37
+ number: {
38
+ value: def.length
39
+ }
40
+ }
41
+ ]
42
+ };
32
43
  for(let i = 0; i < def.length; i++){
33
44
  ctx.path.push(`${i}`);
34
45
  props[i] = (0, _definitionTs.parseDefinition)(def[i], ctx);
@@ -36,12 +47,8 @@ const parseTuple = (def, ctx)=>{
36
47
  }
37
48
  return {
38
49
  object: {
39
- objectKind: "Array",
40
- props,
41
- range: {
42
- comparator: "==",
43
- limit: def.length
44
- }
50
+ class: "Array",
51
+ props
45
52
  }
46
53
  };
47
54
  };
@@ -53,7 +60,7 @@ const parseBranchTuple = (def, ctx)=>{
53
60
  const r = (0, _definitionTs.parseDefinition)(def[2], ctx);
54
61
  return def[1] === "&" ? (0, _nodeTs.intersection)(l, r, ctx.type) : (0, _nodeTs.union)(l, r, ctx.type);
55
62
  };
56
- const parseArrayTuple = (def, scope)=>_functorsTs.functors.Array((0, _definitionTs.parseDefinition)(def[0], scope));
63
+ const parseArrayTuple = (def, scope)=>(0, _nodeTs.arrayOf)((0, _definitionTs.parseDefinition)(def[0], scope));
57
64
  const writeMalformedFunctionalExpressionMessage = (operator, rightDef)=>`Expression requires a function following '${operator}' (was ${typeof rightDef})`;
58
65
  const isPostfixExpression = (def)=>postfixParsers[def[1]] !== undefined;
59
66
  const postfixParsers = {
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ Cache: ()=>Cache,
13
+ FreezingCache: ()=>FreezingCache
14
+ });
15
+ const _freezeTs = require("../utils/freeze.js");
16
+ class Cache {
17
+ get root() {
18
+ return this.cache;
19
+ }
20
+ has(name) {
21
+ return name in this.cache;
22
+ }
23
+ get(name) {
24
+ return this.cache[name];
25
+ }
26
+ set(name, item) {
27
+ this.cache[name] = item;
28
+ return item;
29
+ }
30
+ constructor(){
31
+ this.cache = {};
32
+ }
33
+ }
34
+ class FreezingCache extends Cache {
35
+ set(name, item) {
36
+ this.cache[name] = (0, _freezeTs.deepFreeze)(item);
37
+ return item;
38
+ }
39
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ jsObjectsScope: ()=>jsObjectsScope,
13
+ jsObjects: ()=>jsObjects
14
+ });
15
+ const _scopeTs = require("./scope.js");
16
+ const jsObjectsScope = (0, _scopeTs.scope)({
17
+ Function: [
18
+ "node",
19
+ {
20
+ object: {
21
+ class: "Function"
22
+ }
23
+ }
24
+ ],
25
+ Array: [
26
+ "node",
27
+ {
28
+ object: {
29
+ class: "Array"
30
+ }
31
+ }
32
+ ],
33
+ Date: [
34
+ "node",
35
+ {
36
+ object: {
37
+ class: "Date"
38
+ }
39
+ }
40
+ ],
41
+ Error: [
42
+ "node",
43
+ {
44
+ object: {
45
+ class: "Error"
46
+ }
47
+ }
48
+ ],
49
+ Map: [
50
+ "node",
51
+ {
52
+ object: {
53
+ class: "Map"
54
+ }
55
+ }
56
+ ],
57
+ RegExp: [
58
+ "node",
59
+ {
60
+ object: {
61
+ class: "RegExp"
62
+ }
63
+ }
64
+ ],
65
+ Set: [
66
+ "node",
67
+ {
68
+ object: {
69
+ class: "Set"
70
+ }
71
+ }
72
+ ],
73
+ Object: [
74
+ "node",
75
+ {
76
+ object: {
77
+ class: "Object"
78
+ }
79
+ }
80
+ ],
81
+ String: [
82
+ "node",
83
+ {
84
+ object: {
85
+ class: "String"
86
+ }
87
+ }
88
+ ],
89
+ Number: [
90
+ "node",
91
+ {
92
+ object: {
93
+ class: "Number"
94
+ }
95
+ }
96
+ ],
97
+ Boolean: [
98
+ "node",
99
+ {
100
+ object: {
101
+ class: "Boolean"
102
+ }
103
+ }
104
+ ],
105
+ WeakMap: [
106
+ "node",
107
+ {
108
+ object: {
109
+ class: "WeakMap"
110
+ }
111
+ }
112
+ ],
113
+ WeakSet: [
114
+ "node",
115
+ {
116
+ object: {
117
+ class: "WeakSet"
118
+ }
119
+ }
120
+ ],
121
+ Promise: [
122
+ "node",
123
+ {
124
+ object: {
125
+ class: "Promise"
126
+ }
127
+ }
128
+ ]
129
+ }, {
130
+ name: "jsObjects",
131
+ standard: false
132
+ });
133
+ const jsObjects = jsObjectsScope.compile();