UNPKG

ts-prims

Version:
43 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Big4K = exports.Big512 = exports.Big256 = exports.Big192 = exports.Big160 = exports.Big128 = exports.Big96 = exports.Big64 = exports.Big = void 0; const width_js_1 = require("./width.js"); const prim_js_1 = require("./prim.js"); const varint_js_1 = require("./varint.js"); /** * Returns a constructor for `big` integer numbers with the given Width `W`. * * `big` numbers are always backed by `bigint` values, which is less performant * than `number`, so for small `W`, prefer `int` instead. If you need a type * that uses either `number` or `bigint` depending on the width, use `varint`. * * @template W The `Width`, inferred from parameter `w`. * * @param w The width of this type * @returns The constructor for `big<W>` * * @see {@link big} For the prim type * @see {@link Width} The widths of the big int types * @see {@link isInteger} constraint that values must be integer * @see {@link widthConstraint} constraint that values must be within width `W` * @see {@link varint} for the low-level type that accepts all widths */ const Big = (w) => (0, prim_js_1.Prim)(`big<${w}>`, BigInt, [varint_js_1.isInteger, (0, width_js_1.widthConstraint)(w)]); exports.Big = Big; /** Constructor for {@link big64} */ exports.Big64 = (0, exports.Big)(8); /** Constructor for {@link big96} */ exports.Big96 = (0, exports.Big)(9); /** Constructor for {@link big128} */ exports.Big128 = (0, exports.Big)(10); /** Constructor for {@link big160} */ exports.Big160 = (0, exports.Big)(11); /** Constructor for {@link big192} */ exports.Big192 = (0, exports.Big)(12); /** Constructor for {@link big256} */ exports.Big256 = (0, exports.Big)(13); /** Constructor for {@link big512} */ exports.Big512 = (0, exports.Big)(14); /** Constructor for {@link big4K} */ exports.Big4K = (0, exports.Big)(15); //# sourceMappingURL=big.js.map