Skip to content

Commit

Permalink
chore: rm index2
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Oct 30, 2024
1 parent cad46a3 commit fdf97c9
Show file tree
Hide file tree
Showing 9 changed files with 3,140 additions and 3,148 deletions.
4 changes: 2 additions & 2 deletions src/Hex.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ test('asserts', () => {
{
const hex = '0x0123456789abcdefABCDEF' as const
Hex.assert(hex)
expectTypeOf(hex).toMatchTypeOf<Hex>()
expectTypeOf(hex).toMatchTypeOf<Hex.Hex>()
}

{
const hex = Bytes.fromHex('0x0123456789abcdefABCDEF')
Hex.assert(hex)
// expectTypeOf(hex).toMatchTypeOf<Hex>()
expectTypeOf(hex).toMatchTypeOf<Hex.Hex>()
}
})
5 changes: 4 additions & 1 deletion src/Hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export type Hex = `0x${string}`
* @param value - The value to assert.
* @param options - Options.
*/
export function assert(value: unknown, options: assert.Options = {}) {
export function assert(
value: unknown,
options: assert.Options = {},
): asserts value is Hex {
const { strict = true } = options
if (!value) throw new InvalidHexTypeError(value)
if (typeof value !== 'string') throw new InvalidHexTypeError(value)
Expand Down
Loading

0 comments on commit fdf97c9

Please sign in to comment.