inferred-types 0.18.1 → 0.18.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.
package/dist/index.js CHANGED
@@ -1,11 +1,9 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
6
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
8
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
9
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -23,28 +21,29 @@ var __spreadValues = (a, b) => {
23
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
22
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
23
  var __export = (target, all) => {
26
- __markAsModule(target);
27
24
  for (var name in all)
28
25
  __defProp(target, name, { get: all[name], enumerable: true });
29
26
  };
30
- var __reExport = (target, module2, desc) => {
27
+ var __reExport = (target, module2, copyDefault, desc) => {
31
28
  if (module2 && typeof module2 === "object" || typeof module2 === "function") {
32
29
  for (let key of __getOwnPropNames(module2))
33
- if (!__hasOwnProp.call(target, key) && key !== "default")
30
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
34
31
  __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
35
32
  }
36
33
  return target;
37
34
  };
38
- var __toModule = (module2) => {
39
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
40
- };
35
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
36
+ return (module2, temp) => {
37
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
38
+ };
39
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
41
40
 
42
41
  // src/index.ts
43
- __export(exports, {
42
+ var src_exports = {};
43
+ __export(src_exports, {
44
44
  Configurator: () => Configurator,
45
45
  ExplicitFunction: () => ExplicitFunction,
46
46
  FluentConfigurator: () => FluentConfigurator,
47
- InferenceError: () => InferenceError,
48
47
  KeyStorage: () => KeyStorage,
49
48
  Model: () => Model,
50
49
  MutationIdentity: () => MutationIdentity,
@@ -72,7 +71,6 @@ __export(exports, {
72
71
  isBoolean: () => isBoolean,
73
72
  isFalse: () => isFalse,
74
73
  isFunction: () => isFunction,
75
- isInferenceError: () => isInferenceError,
76
74
  isLiteral: () => isLiteral,
77
75
  isNull: () => isNull,
78
76
  isNumber: () => isNumber,
@@ -91,10 +89,13 @@ __export(exports, {
91
89
  mapValues: () => mapValues,
92
90
  nameLiteral: () => nameLiteral,
93
91
  or: () => or,
92
+ randomString: () => randomString,
94
93
  ruleSet: () => ruleSet,
95
94
  strArrayToDict: () => strArrayToDict,
96
95
  type: () => type,
97
96
  typeApi: () => typeApi,
97
+ uuid: () => uuid,
98
+ valueTypes: () => valueTypes,
98
99
  valuesOfProp: () => valuesOfProp,
99
100
  withValue: () => withValue
100
101
  });
@@ -113,9 +114,34 @@ function MutationIdentity() {
113
114
  };
114
115
  }
115
116
 
116
- // src/errors/InferenceError.ts
117
- var import_brilliant_errors = __toModule(require("brilliant-errors"));
118
- var [InferenceError, isInferenceError] = (0, import_brilliant_errors.createError)("InferenceError", "inferred-types")()()()();
117
+ // src/shared/randomString.ts
118
+ function randomString() {
119
+ return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
120
+ }
121
+
122
+ // src/shared/uuid.ts
123
+ function uuid() {
124
+ return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
125
+ }
126
+
127
+ // src/shared/valueTypes.ts
128
+ var valueTypes = {
129
+ string: ["", false],
130
+ boolean: [true, false],
131
+ number: [0, false],
132
+ function: [() => "", false],
133
+ object: [{}, false],
134
+ array: (arr = []) => [arr, false],
135
+ null: [null, false],
136
+ symbol: [Symbol("type"), false],
137
+ undefined: [void 0, false],
138
+ true: [true, true],
139
+ false: [false, true],
140
+ literal: (v) => {
141
+ return [v, true];
142
+ },
143
+ literalArray: (arr) => [arr, true]
144
+ };
119
145
 
120
146
  // src/utility/keys.ts
121
147
  function keys(obj, ...without) {
@@ -156,7 +182,7 @@ function arrayToKeyLookup(...keys2) {
156
182
  }
157
183
 
158
184
  // src/utility/dictionary/dictFilter.ts
159
- var import_native_dash = __toModule(require("native-dash"));
185
+ var import_native_dash = require("native-dash");
160
186
  function dictFilter(obj, cb) {
161
187
  const remove = keys(obj).filter((k) => !cb(k, obj));
162
188
  return (0, import_native_dash.omit)(obj, ...keys(obj).filter((k) => !cb(k, obj)));
@@ -207,7 +233,7 @@ function dictToKv(obj, _makeTuple = false) {
207
233
  }
208
234
 
209
235
  // src/utility/state/Configurator.ts
210
- var import_native_dash2 = __toModule(require("native-dash"));
236
+ var import_native_dash2 = require("native-dash");
211
237
  function Configurator() {
212
238
  let configuration = () => ({});
213
239
  const api2 = () => {
@@ -410,7 +436,7 @@ function runtimeExtendsCheck(val, base, narrow = false) {
410
436
  return true;
411
437
  case "function":
412
438
  if (narrow) {
413
- throw new InferenceError(`Use of narrowlyExtends with a function is not possible!`, "ifTypeOf/not-allowed");
439
+ throw new Error(`Use of narrowlyExtends with a function is not possible!`);
414
440
  }
415
441
  return true;
416
442
  case "object":
@@ -598,12 +624,12 @@ function withValue(td) {
598
624
  }));
599
625
  };
600
626
  }
627
+ module.exports = __toCommonJS(src_exports);
601
628
  // Annotate the CommonJS export names for ESM import in node:
602
629
  0 && (module.exports = {
603
630
  Configurator,
604
631
  ExplicitFunction,
605
632
  FluentConfigurator,
606
- InferenceError,
607
633
  KeyStorage,
608
634
  Model,
609
635
  MutationIdentity,
@@ -631,7 +657,6 @@ function withValue(td) {
631
657
  isBoolean,
632
658
  isFalse,
633
659
  isFunction,
634
- isInferenceError,
635
660
  isLiteral,
636
661
  isNull,
637
662
  isNumber,
@@ -650,10 +675,13 @@ function withValue(td) {
650
675
  mapValues,
651
676
  nameLiteral,
652
677
  or,
678
+ randomString,
653
679
  ruleSet,
654
680
  strArrayToDict,
655
681
  type,
656
682
  typeApi,
683
+ uuid,
684
+ valueTypes,
657
685
  valuesOfProp,
658
686
  withValue
659
687
  });
package/dist/index.mjs CHANGED
@@ -32,9 +32,34 @@ function MutationIdentity() {
32
32
  };
33
33
  }
34
34
 
35
- // src/errors/InferenceError.ts
36
- import { createError } from "brilliant-errors";
37
- var [InferenceError, isInferenceError] = createError("InferenceError", "inferred-types")()()()();
35
+ // src/shared/randomString.ts
36
+ function randomString() {
37
+ return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
38
+ }
39
+
40
+ // src/shared/uuid.ts
41
+ function uuid() {
42
+ return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
43
+ }
44
+
45
+ // src/shared/valueTypes.ts
46
+ var valueTypes = {
47
+ string: ["", false],
48
+ boolean: [true, false],
49
+ number: [0, false],
50
+ function: [() => "", false],
51
+ object: [{}, false],
52
+ array: (arr = []) => [arr, false],
53
+ null: [null, false],
54
+ symbol: [Symbol("type"), false],
55
+ undefined: [void 0, false],
56
+ true: [true, true],
57
+ false: [false, true],
58
+ literal: (v) => {
59
+ return [v, true];
60
+ },
61
+ literalArray: (arr) => [arr, true]
62
+ };
38
63
 
39
64
  // src/utility/keys.ts
40
65
  function keys(obj, ...without) {
@@ -329,7 +354,7 @@ function runtimeExtendsCheck(val, base, narrow = false) {
329
354
  return true;
330
355
  case "function":
331
356
  if (narrow) {
332
- throw new InferenceError(`Use of narrowlyExtends with a function is not possible!`, "ifTypeOf/not-allowed");
357
+ throw new Error(`Use of narrowlyExtends with a function is not possible!`);
333
358
  }
334
359
  return true;
335
360
  case "object":
@@ -521,7 +546,6 @@ export {
521
546
  Configurator,
522
547
  ExplicitFunction,
523
548
  FluentConfigurator,
524
- InferenceError,
525
549
  KeyStorage,
526
550
  Model,
527
551
  MutationIdentity,
@@ -549,7 +573,6 @@ export {
549
573
  isBoolean,
550
574
  isFalse,
551
575
  isFunction,
552
- isInferenceError,
553
576
  isLiteral,
554
577
  isNull,
555
578
  isNumber,
@@ -568,10 +591,13 @@ export {
568
591
  mapValues,
569
592
  nameLiteral,
570
593
  or,
594
+ randomString,
571
595
  ruleSet,
572
596
  strArrayToDict,
573
597
  type,
574
598
  typeApi,
599
+ uuid,
600
+ valueTypes,
575
601
  valuesOfProp,
576
602
  withValue
577
603
  };
@@ -1,41 +1,35 @@
1
1
  // #autoindex
2
2
 
3
3
  // #region autoindexed files
4
+ // index last changed at: 12th Dec, 2021, 09:28 AM ( GMT-8 )
5
+ // hash-code: 3659802676
4
6
 
5
- // index last changed at: 5th May, 2021, 07:16 AM ( GMT-7 )
6
- // export: named; exclusions: index, private.
7
- // files: Builder, BuilderApi, IdentityToMutationApi, MutationToFluentApi.
8
7
 
9
- // local file exports
10
- export * from "./Builder";
11
- export * from "./BuilderApi";
12
- export * from "./IdentityToMutationApi";
13
- export * from "./MutationToFluentApi";
14
8
 
15
- // Note:
16
- // -----
17
- // This file was created by running: "dd devops autoindex"; it assumes you have
18
- // the 'do-devops' pkg installed as a dev dep.
9
+ // #endregion
10
+
11
+ // This file was created by running: "dd autoindex"; it assumes you have
12
+ // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
19
13
  //
20
14
  // By default it assumes that exports are named exports but this can be changed by
21
15
  // adding a modifier to the '// #autoindex' syntax:
22
16
  //
23
17
  // - autoindex:named same as default, exports "named symbols"
24
- // - autoindex:default assumes each file is exporting a default export
25
- // and converts the default export to the name of the
26
- // file
18
+ // - autoindex:default assumes each file is exporting a default export and
19
+ // converts the default export to the name of the file
27
20
  // - autoindex:offset assumes files export "named symbols" but that each
28
21
  // file's symbols should be offset by the file's name
29
- // (useful for files which might symbols which collide
30
- // or where the namespacing helps consumers)
31
22
  //
32
23
  // You may also exclude certain files or directories by adding it to the
33
24
  // autoindex command. As an example:
34
25
  //
35
26
  // - autoindex:named, exclude: foo,bar,baz
36
27
  //
37
- // Also be aware that all of your content outside the defined region in this file
38
- // will be preserved in situations where you need to do something paricularly awesome.
28
+ // Inversely, if you state a file to be an "orphan" then autoindex files
29
+ // below this file will not reference this autoindex file:
30
+ //
31
+ // - autoindex:named, orphan
32
+ //
33
+ // All content outside the "// #region" section in this file will be
34
+ // preserved in situations where you need to do something paricularly awesome.
39
35
  // Keep on being awesome.
40
-
41
- // #endregion
@@ -1,39 +1,34 @@
1
1
  // #autoindex
2
2
  // #region autoindexed files
3
+ // index last changed at: 12th Dec, 2021, 09:28 AM ( GMT-8 )
4
+ // hash-code: 3659802676
3
5
 
4
- // index last changed at: 8th Aug, 2021, 10:48 AM ( GMT-7 )
5
- // export: named; exclusions: index, private.
6
- // files: object, prop, scalar.
7
6
 
8
- // local file exports
9
- export * from "./object";
10
- export * from "./prop";
11
- export * from "./scalar";
12
7
 
13
- // Note:
14
- // -----
15
- // This file was created by running: "dd devops autoindex"; it assumes you have
16
- // the 'do-devops' pkg installed as a dev dep.
8
+ // #endregion
9
+
10
+ // This file was created by running: "dd autoindex"; it assumes you have
11
+ // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
17
12
  //
18
13
  // By default it assumes that exports are named exports but this can be changed by
19
14
  // adding a modifier to the '// #autoindex' syntax:
20
15
  //
21
16
  // - autoindex:named same as default, exports "named symbols"
22
- // - autoindex:default assumes each file is exporting a default export
23
- // and converts the default export to the name of the
24
- // file
17
+ // - autoindex:default assumes each file is exporting a default export and
18
+ // converts the default export to the name of the file
25
19
  // - autoindex:offset assumes files export "named symbols" but that each
26
20
  // file's symbols should be offset by the file's name
27
- // (useful for files which might symbols which collide
28
- // or where the namespacing helps consumers)
29
21
  //
30
22
  // You may also exclude certain files or directories by adding it to the
31
23
  // autoindex command. As an example:
32
24
  //
33
25
  // - autoindex:named, exclude: foo,bar,baz
34
26
  //
35
- // Also be aware that all of your content outside the defined region in this file
36
- // will be preserved in situations where you need to do something paricularly awesome.
27
+ // Inversely, if you state a file to be an "orphan" then autoindex files
28
+ // below this file will not reference this autoindex file:
29
+ //
30
+ // - autoindex:named, orphan
31
+ //
32
+ // All content outside the "// #region" section in this file will be
33
+ // preserved in situations where you need to do something paricularly awesome.
37
34
  // Keep on being awesome.
38
-
39
- // #endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inferred-types",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "Functions which provide useful type inference on TS projects",
5
5
  "license": "MIT",
6
6
  "author": "Ken Snyder<ken@ken.net>",
@@ -20,7 +20,6 @@
20
20
  "test": "jest"
21
21
  },
22
22
  "devDependencies": {
23
- "@antfu/eslint-config-ts": "^0.11.0",
24
23
  "@type-challenges/utils": "~0.1.1",
25
24
  "@types/jest": "^27.0.3",
26
25
  "@types/node": "^14.18.3",
@@ -28,13 +27,14 @@
28
27
  "@typescript-eslint/parser": "^5.8.0",
29
28
  "common-types": "^1.30.0",
30
29
  "cross-env": "^7.0.3",
31
- "dd": "^0.16.3",
30
+ "dd": "^0.16.7",
32
31
  "dotenv": "^10.0.0",
33
32
  "eslint": "^8.5.0",
34
33
  "eslint-config-prettier": "^8.3.0",
35
34
  "eslint-plugin-import": "^2.25.3",
36
35
  "eslint-plugin-prettier": "^4.0.0",
37
36
  "eslint-plugin-promise": "^6.0.0",
37
+ "eslint-plugin-unicorn": "^39.0.0",
38
38
  "jest": "^27.4.5",
39
39
  "jest-extended": "~1.2.0",
40
40
  "npm-run-all": "~4.1.5",
@@ -46,8 +46,8 @@
46
46
  "typescript": "^4.5.4"
47
47
  },
48
48
  "dependencies": {
49
- "common-types": "^1.31.0",
50
49
  "brilliant-errors": "^0.5.4",
51
- "native-dash": "^1.21.1"
50
+ "common-types": "^1.31.0",
51
+ "native-dash": "^1.21.2"
52
52
  }
53
53
  }