Download node_modules/fast-check/lib/esm/arbitrary/integer.js from Really-amin/Datasourceforcryptocurrency: direct link, hf CLI and curl.
- Browser
- Download file 976 Bytes
-
https://huggingface.co/spaces/Really-amin/Datasourceforcryptocurrency/resolve/250b128700538234afd94de5d02f4e054f24823e/node_modules/fast-check/lib/esm/arbitrary/integer.js
- Command line
-
hf download hf://spaces/Really-amin/Datasourceforcryptocurrency@250b128700538234afd94de5d02f4e054f24823e/node_modules/fast-check/lib/esm/arbitrary/integer.js
-
curl -L -o integer.js https://huggingface.co/spaces/Really-amin/Datasourceforcryptocurrency/resolve/250b128700538234afd94de5d02f4e054f24823e/node_modules/fast-check/lib/esm/arbitrary/integer.js
976 Bytes
| import { IntegerArbitrary } from './_internals/IntegerArbitrary.js'; | |
| const safeNumberIsInteger = Number.isInteger; | |
| function buildCompleteIntegerConstraints(constraints) { | |
| const min = constraints.min !== undefined ? constraints.min : -0x80000000; | |
| const max = constraints.max !== undefined ? constraints.max : 0x7fffffff; | |
| return { min, max }; | |
| } | |
| export function integer(constraints = {}) { | |
| const fullConstraints = buildCompleteIntegerConstraints(constraints); | |
| if (fullConstraints.min > fullConstraints.max) { | |
| throw new Error('fc.integer maximum value should be equal or greater than the minimum one'); | |
| } | |
| if (!safeNumberIsInteger(fullConstraints.min)) { | |
| throw new Error('fc.integer minimum value should be an integer'); | |
| } | |
| if (!safeNumberIsInteger(fullConstraints.max)) { | |
| throw new Error('fc.integer maximum value should be an integer'); | |
| } | |
| return new IntegerArbitrary(fullConstraints.min, fullConstraints.max); | |
| } | |