@systemfsoftware/hex-schema 1.3.0 → 1.5.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.
@@ -9,7 +9,7 @@ export declare type ColonHex = Schema.Schema.Type<typeof ColonHex>;
9
9
  * this to produce a `Uint8Array` from that format:
10
10
  *
11
11
  * ```ts
12
- * S.compose(PrefixedHex, HexBytes) // Schema<Uint8Array, string>
12
+ * S.compose(PrefixedHex, HexBytes) // Schema<Uint8Array, `0x${string}`>
13
13
  * S.compose(ColonHex, HexBytes) // Schema<Uint8Array, string>
14
14
  * ```
15
15
  */
@@ -19,13 +19,13 @@ export declare const HexString: Schema.brand<Schema.transform<Schema.refine<stri
19
19
 
20
20
  export declare type HexString = Schema.Schema.Type<typeof HexString>;
21
21
 
22
- export declare const PrefixedHex: Schema.brand<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
22
+ export declare const PrefixedHex: Schema.brand<Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
23
23
 
24
24
  export declare type PrefixedHex = Schema.Schema.Type<typeof PrefixedHex>;
25
25
 
26
26
  export declare const StrictHex: Schema.refine<string, typeof Schema.String>;
27
27
 
28
- export declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
28
+ export declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
29
29
 
30
30
  export declare type Uint8ArrayFromPrefixedHex = Schema.Schema.Type<typeof Uint8ArrayFromPrefixedHex>;
31
31
 
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ type ColonHex = Schema.Schema.Type<typeof ColonHex>;
9
9
  * this to produce a `Uint8Array` from that format:
10
10
  *
11
11
  * ```ts
12
- * S.compose(PrefixedHex, HexBytes) // Schema<Uint8Array, string>
12
+ * S.compose(PrefixedHex, HexBytes) // Schema<Uint8Array, `0x${string}`>
13
13
  * S.compose(ColonHex, HexBytes) // Schema<Uint8Array, string>
14
14
  * ```
15
15
  */
@@ -20,14 +20,14 @@ declare const HexString: Schema.brand<Schema.transform<Schema.refine<string, typ
20
20
  type HexString = Schema.Schema.Type<typeof HexString>;
21
21
  //#endregion
22
22
  //#region src/prefixed-hex.schema.d.ts
23
- declare const PrefixedHex: Schema.brand<Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
23
+ declare const PrefixedHex: Schema.brand<Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.refine<string, typeof Schema.String>>, "PrefixedHex">;
24
24
  type PrefixedHex = Schema.Schema.Type<typeof PrefixedHex>;
25
25
  //#endregion
26
26
  //#region src/strict-hex.schema.d.ts
27
27
  declare const StrictHex: Schema.refine<string, typeof Schema.String>;
28
28
  //#endregion
29
29
  //#region src/uint8array-from-prefixed-hex.schema.d.ts
30
- declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.refine<string, typeof Schema.String>, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
30
+ declare const Uint8ArrayFromPrefixedHex: Schema.transform<Schema.refine<`0x${string}`, Schema.TemplateLiteral<`0x${string}`>>, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>>;
31
31
  type Uint8ArrayFromPrefixedHex = Schema.Schema.Type<typeof Uint8ArrayFromPrefixedHex>;
32
32
  //#endregion
33
33
  export { ColonHex, HexBytes, HexString, PrefixedHex, StrictHex, Uint8ArrayFromPrefixedHex };
package/dist/index.mjs CHANGED
@@ -8,12 +8,13 @@ const StrictHex = Schema.String.pipe(Schema.pattern(/^[0-9a-f]*$/), Schema.annot
8
8
  }));
9
9
  //#endregion
10
10
  //#region src/hex-string.schema.ts
11
+ const toStrictHex = (hex) => (hex.startsWith("0x") ? hex.slice(2) : hex).toLowerCase();
11
12
  const HexString = pipe(Schema.transform(Schema.String.pipe(Schema.pattern(/^(0x)?[0-9a-fA-F]*$/), Schema.annotations({
12
13
  arbitrary: () => (fc) => fc.stringMatching(/^(0x)?[0-9a-fA-F]*$/),
13
14
  identifier: "HexStringInput",
14
15
  description: "A hex string, optionally prefixed with 0x (empty string allowed)"
15
16
  })), StrictHex, {
16
- decode: (hex) => (hex.startsWith("0x") ? hex.slice(2) : hex).toLowerCase(),
17
+ decode: toStrictHex,
17
18
  encode: (s) => s
18
19
  }), Schema.annotations({
19
20
  identifier: "HexString",
@@ -39,7 +40,7 @@ const ColonHex = pipe(Schema.compose(Schema.transform(Schema.String.pipe(Schema.
39
40
  * this to produce a `Uint8Array` from that format:
40
41
  *
41
42
  * ```ts
42
- * S.compose(PrefixedHex, HexBytes) // Schema<Uint8Array, string>
43
+ * S.compose(PrefixedHex, HexBytes) // Schema<Uint8Array, `0x${string}`>
43
44
  * S.compose(ColonHex, HexBytes) // Schema<Uint8Array, string>
44
45
  * ```
45
46
  */
@@ -50,7 +51,7 @@ const HexBytes = Schema.Uint8ArrayFromHex.pipe(Schema.annotations({
50
51
  }));
51
52
  //#endregion
52
53
  //#region src/prefixed-hex.schema.ts
53
- const PrefixedHex = pipe(Schema.transform(Schema.String.pipe(Schema.pattern(/^0x[0-9a-f]*$/), Schema.annotations({ arbitrary: () => (fc) => fc.hexaString().map((hex) => `0x${hex}`) })), StrictHex, {
54
+ const PrefixedHex = pipe(Schema.transform(Schema.TemplateLiteral("0x", Schema.String).pipe(Schema.pattern(/^0x[0-9a-f]*$/), Schema.annotations({ arbitrary: () => (fc) => fc.hexaString().map((hex) => `0x${hex}`) })), StrictHex, {
54
55
  strict: true,
55
56
  decode: (fromA) => fromA.slice(2),
56
57
  encode: (toI) => `0x${toI}`
@@ -61,7 +62,7 @@ const PrefixedHex = pipe(Schema.transform(Schema.String.pipe(Schema.pattern(/^0x
61
62
  }), Schema.brand("PrefixedHex"));
62
63
  //#endregion
63
64
  //#region src/uint8array-from-prefixed-hex.schema.ts
64
- const Uint8ArrayFromPrefixedHex = pipe(Schema.transform(Schema.String.pipe(Schema.pattern(/^0x(?:[0-9a-f]{2})*$/), Schema.annotations({ arbitrary: () => (fc) => fc.uint8Array().map((bytes) => `0x${Encoding.encodeHex(bytes)}`) })), HexBytes, {
65
+ const Uint8ArrayFromPrefixedHex = pipe(Schema.transform(Schema.TemplateLiteral("0x", Schema.String).pipe(Schema.pattern(/^0x(?:[0-9a-f]{2})*$/), Schema.annotations({ arbitrary: () => (fc) => fc.uint8Array().map((bytes) => `0x${Encoding.encodeHex(bytes)}`) })), HexBytes, {
65
66
  strict: true,
66
67
  decode: (prefixed) => prefixed.slice(2),
67
68
  encode: (hex) => `0x${hex}`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/hex-schema",
3
3
  "license": "MIT",
4
- "version": "1.3.0",
4
+ "version": "1.5.0",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -36,6 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@effect/vitest": "0.30.0",
38
38
  "@microsoft/api-extractor": "^7.58.7",
39
+ "@stryker-mutator/vitest-runner": "^9.6.1",
39
40
  "@types/node": "^24",
40
41
  "effect": "^3.22.0",
41
42
  "fast-check": "^3",
@@ -43,10 +44,13 @@
43
44
  "tsdown": "^0.22.9",
44
45
  "vitest": "^4",
45
46
  "@systemfsoftware/arethetypeswrong-cli": "^1.0.7",
46
- "@systemfsoftware/effect-schema-law": "^0.5.0",
47
- "@systemfsoftware/effect-schema-vite": "^1.3.0",
47
+ "@systemfsoftware/effect-schema-vite": "^1.4.0",
48
48
  "@systemfsoftware/oxlint-config": "^0.1.0",
49
+ "@systemfsoftware/stryker-js-core": "^1.1.6",
50
+ "@systemfsoftware/effect-schema-law": "^0.5.0",
49
51
  "@systemfsoftware/tsconfig": "^1.2.6",
52
+ "@systemfsoftware/stryker-js-typescript-checker": "^1.1.6",
53
+ "@systemfsoftware/stryker-plugins": "^0.7.0",
50
54
  "@systemfsoftware/vitest-config": "^0.1.0"
51
55
  },
52
56
  "peerDependencies": {
@@ -63,6 +67,8 @@
63
67
  "api:check": "api-extractor run",
64
68
  "api:update": "api-extractor run --local",
65
69
  "lint": "oxlint . ${AGENT:+--format=unix --quiet}",
66
- "attw": "attw --pack ."
70
+ "attw": "attw --pack .",
71
+ "mutation": "stryker run --incremental",
72
+ "mutation:full": "stryker run"
67
73
  }
68
74
  }