Skip to content

Commit c576427

Browse files
mixedCasegcanti
authored andcommitted
Add codec for bigint primitive
1 parent 3ac954a commit c576427

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,31 @@ export interface NumberC extends NumberType {}
363363
*/
364364
export const number: NumberC = new NumberType()
365365

366+
/**
367+
* @since 2.0.7
368+
*/
369+
export class BigIntType extends Type<bigint> {
370+
readonly _tag: 'BigIntType' = 'BigIntType'
371+
constructor() {
372+
super(
373+
'bigint',
374+
(u): u is bigint => typeof u === 'bigint',
375+
(u, c) => (this.is(u) ? success(u) : failure(u, c)),
376+
identity
377+
)
378+
}
379+
}
380+
381+
/**
382+
* @since 2.0.7
383+
*/
384+
export interface BigIntC extends BigIntType {}
385+
386+
/**
387+
* @since 2.0.7
388+
*/
389+
export const bigint: BigIntC = new BigIntType()
390+
366391
/**
367392
* @since 1.0.0
368393
*/

0 commit comments

Comments
 (0)