@oscarpalmer/jhunal 0.7.0 → 0.8.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.
package/dist/constants.js CHANGED
@@ -1,3 +1,6 @@
1
+ const EXPRESSION_HAS_NUMBER = /\d+/;
2
+ const EXPRESSION_INDEX = /\.\d+$/;
3
+ const EXPRESSION_PROPERTY = /\.\$(required|type)(\.|$)/;
1
4
  const PROPERTY_REQUIRED = "$required";
2
5
  const PROPERTY_TYPE = "$type";
3
6
  const SCHEMATIC_NAME = "$schematic";
@@ -8,14 +11,12 @@ const TYPE_ALL = new Set([
8
11
  "bigint",
9
12
  "boolean",
10
13
  "date",
11
- "date-like",
12
14
  "function",
13
15
  "null",
14
16
  "number",
15
- "numerical",
16
17
  "string",
17
18
  "symbol",
18
19
  TYPE_OBJECT,
19
20
  TYPE_UNDEFINED
20
21
  ]);
21
- export { PROPERTY_REQUIRED, PROPERTY_TYPE, SCHEMATIC_NAME, TYPE_ALL, TYPE_OBJECT, TYPE_UNDEFINED };
22
+ export { EXPRESSION_HAS_NUMBER, EXPRESSION_INDEX, EXPRESSION_PROPERTY, PROPERTY_REQUIRED, PROPERTY_TYPE, SCHEMATIC_NAME, TYPE_ALL, TYPE_OBJECT, TYPE_UNDEFINED };
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ import { isInstance } from "./is.js";
1
2
  import { schematic } from "./schematic.js";
2
- export { schematic };
3
+ export { isInstance, schematic };
package/dist/is.js CHANGED
@@ -1,10 +1,14 @@
1
- import { SCHEMATIC_NAME } from "./constants.js";
2
- function isDateLike(value) {
3
- if (value instanceof Date) return true;
4
- if (typeof value === "number") return value >= -864e13 && value <= 864e13;
5
- return typeof value === "string" && !Number.isNaN(Date.parse(value));
1
+ import "./constants.js";
2
+ function isConstructor(value) {
3
+ return typeof value === "function" && value.prototype !== void 0;
4
+ }
5
+ function isInstance(constructor) {
6
+ if (!isConstructor(constructor)) throw new TypeError("Expected a constructor function");
7
+ return (value) => {
8
+ return value instanceof constructor;
9
+ };
6
10
  }
7
11
  function isSchematic(value) {
8
12
  return typeof value === "object" && value !== null && "$schematic" in value && value["$schematic"] === true;
9
13
  }
10
- export { isDateLike, isSchematic };
14
+ export { isConstructor, isInstance, isSchematic };