@oscarpalmer/jhunal 0.14.0 → 0.16.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/package.json CHANGED
@@ -1,49 +1,54 @@
1
1
  {
2
- "author": {
3
- "name": "Oscar Palmér",
4
- "url": "https://oscarpalmer.se"
5
- },
6
- "dependencies": {
7
- "@oscarpalmer/atoms": "^0.141.2"
8
- },
9
- "description": "Flies free beneath the glistening moons…",
10
- "devDependencies": {
11
- "@types/node": "^25.3",
12
- "@vitest/coverage-istanbul": "^4",
13
- "jsdom": "^28.1",
14
- "oxfmt": "^0.35",
15
- "oxlint": "^1.50",
16
- "rolldown": "1.0.0-rc.5",
17
- "tslib": "^2.8",
18
- "typescript": "^5.9",
19
- "vite": "8.0.0-beta.15",
20
- "vitest": "^4"
21
- },
22
- "exports": {
23
- "./package.json": "./package.json",
24
- ".": {
25
- "types": "./types/index.d.ts",
26
- "default": "./dist/index.js"
27
- }
28
- },
29
- "files": ["dist", "src", "types"],
30
- "keywords": ["schema", "validation"],
31
- "license": "MIT",
32
- "module": "./dist/index.js",
33
- "name": "@oscarpalmer/jhunal",
34
- "repository": {
35
- "type": "git",
36
- "url": "git+https://github.com/oscarpalmer/jhunal.git"
37
- },
38
- "scripts": {
39
- "build": "npm run clean && npx vite build && npm run rolldown:build && npx tsc",
40
- "clean": "rm -rf ./dist && rm -rf ./types && rm -f ./tsconfig.tsbuildinfo",
41
- "rolldown:build": "npx rolldown -c",
42
- "rolldown:watch": "npx rolldown -c ./rolldown.config.js --watch",
43
- "test": "npx vitest --coverage",
44
- "watch": "npx vite build --watch"
45
- },
46
- "type": "module",
47
- "types": "./types/index.d.ts",
48
- "version": "0.14.0"
49
- }
2
+ "name": "@oscarpalmer/jhunal",
3
+ "version": "0.16.0",
4
+ "description": "Flies free beneath the glistening moons…",
5
+ "keywords": [
6
+ "schema",
7
+ "validation"
8
+ ],
9
+ "license": "MIT",
10
+ "author": {
11
+ "name": "Oscar Palmér",
12
+ "url": "https://oscarpalmer.se"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/oscarpalmer/jhunal.git"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "src"
21
+ ],
22
+ "type": "module",
23
+ "module": "./dist/index.mjs",
24
+ "types": "./dist/index.d.mts",
25
+ "exports": {
26
+ "./package.json": "./package.json",
27
+ ".": {
28
+ "types": "./dist/index.d.mts",
29
+ "default": "./dist/index.mjs"
30
+ }
31
+ },
32
+ "scripts": {
33
+ "build": "npx vp pack && npm run tsdown:build",
34
+ "tsdown:build": "npx tsdown -c ./tsdown.config.ts",
35
+ "tsdown:watch": "npx tsdown -c ./tsdown.config.ts --watch",
36
+ "test": "npx vp test run --coverage",
37
+ "test:leak": "npx vp test run --detect-async-leaks --coverage",
38
+ "watch": "npx vite build --watch"
39
+ },
40
+ "dependencies": {
41
+ "@oscarpalmer/atoms": "^0.166"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^25.5",
45
+ "@vitest/coverage-istanbul": "^4.1",
46
+ "jsdom": "^29.0",
47
+ "tsdown": "^0.21",
48
+ "typescript": "^5.9",
49
+ "vite": "npm:@voidzero-dev/vite-plus-core@latest",
50
+ "vite-plus": "latest",
51
+ "vitest": "npm:@voidzero-dev/vite-plus-test@latest"
52
+ },
53
+ "packageManager": "npm@11.11.1"
54
+ }
package/src/constants.ts CHANGED
@@ -11,8 +11,7 @@ export const MESSAGE_SCHEMA_INVALID_EMPTY = 'Schema must have at least one prope
11
11
  export const MESSAGE_SCHEMA_INVALID_PROPERTY_DISALLOWED =
12
12
  "'<key>.<property>' property is not allowed for schemas in $type";
13
13
 
14
- export const MESSAGE_SCHEMA_INVALID_PROPERTY_REQUIRED =
15
- "'<>.$required' property must be a boolean";
14
+ export const MESSAGE_SCHEMA_INVALID_PROPERTY_REQUIRED = "'<>.$required' property must be a boolean";
16
15
 
17
16
  export const MESSAGE_SCHEMA_INVALID_PROPERTY_TYPE = "'<>' property must be of a valid type";
18
17
 
package/src/helpers.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import {isConstructor} from '@oscarpalmer/atoms/is';
2
+ import type {Constructor} from '@oscarpalmer/atoms/models';
2
3
  import {MESSAGE_CONSTRUCTOR, SCHEMATIC_NAME} from './constants';
3
- import type {Constructor} from './models';
4
4
  import type {Schematic} from './schematic';
5
5
 
6
+ /**
7
+ * Creates a validator function for a given constructor
8
+ * @param constructor - Constructor to check against
9
+ * @throws Will throw a `TypeError` if the provided argument is not a valid constructor
10
+ * @returns Validator function that checks if a value is an instance of the constructor
11
+ */
6
12
  export function instanceOf<Instance>(
7
13
  constructor: Constructor<Instance>,
8
14
  ): (value: unknown) => value is Instance {
@@ -15,6 +21,11 @@ export function instanceOf<Instance>(
15
21
  };
16
22
  }
17
23
 
24
+ /**
25
+ * Is the value a schematic?
26
+ * @param value Value to check
27
+ * @returns `true` if the value is a schematic, `false` otherwise
28
+ */
18
29
  export function isSchematic(value: unknown): value is Schematic<never> {
19
30
  return (
20
31
  typeof value === 'object' &&
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export {instanceOf} from './helpers';
1
+ export {instanceOf, isSchematic} from './helpers';
2
2
  export {SchematicError, type Schema, type TypedSchema} from './models';
3
3
  export {schematic, type Schematic} from './schematic';