Skip to content

Commit

Permalink
Prefer primitive bigint type over BigInt object type
Browse files Browse the repository at this point in the history
  • Loading branch information
ryota-ka committed Mar 23, 2023
1 parent f22e325 commit 4d4e76b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/VariableDecoder/bigInt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ type Options = {
/**
* Maximum value that will be accepted (inclusive)
*/
max?: BigInt | undefined;
max?: bigint | undefined;
/**
* Minimum value that will be accepted (inclusive)
*/
min?: BigInt | undefined;
min?: bigint | undefined;
};

/**
* Decodes a BigInt.
* Decodes a bigint.
*/
const bigInt = (options: Options = {}): VariableDecoder<BigInt> =>
const bigInt = (options: Options = {}): VariableDecoder<bigint> =>
pipe(
asks((x) => O.tryCatch(() => BigInt(x))),
RE.chain(unwrap('must be a valid BigInt')),
RE.chain(unwrap('must be a valid bigint')),
withOpt(options.max)((max) =>
RE.chain(validate((n) => n <= max, `must be smaller than or equal to ${String(max)}`)),
),
Expand Down

0 comments on commit 4d4e76b

Please sign in to comment.