MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / createIntegerConversion

Function createIntegerConversion

out/cli.cjs:2392–2438  ·  view source on GitHub ↗
(bitLength, { unsigned })

Source from the content-addressed store, hash-verified

2390 return x5 === 0 ? 0 : x5;
2391 }
2392 function createIntegerConversion(bitLength, { unsigned }) {
2393 let lowerBound, upperBound;
2394 if (unsigned) {
2395 lowerBound = 0;
2396 upperBound = 2 ** bitLength - 1;
2397 } else {
2398 lowerBound = -(2 ** (bitLength - 1));
2399 upperBound = 2 ** (bitLength - 1) - 1;
2400 }
2401 const twoToTheBitLength = 2 ** bitLength;
2402 const twoToOneLessThanTheBitLength = 2 ** (bitLength - 1);
2403 return (value, options = {}) => {
2404 let x5 = toNumber(value, options);
2405 x5 = censorNegativeZero(x5);
2406 if (options.enforceRange) {
2407 if (!Number.isFinite(x5)) {
2408 throw makeException(TypeError, "is not a finite number", options);
2409 }
2410 x5 = integerPart(x5);
2411 if (x5 < lowerBound || x5 > upperBound) {
2412 throw makeException(
2413 TypeError,
2414 `is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`,
2415 options
2416 );
2417 }
2418 return x5;
2419 }
2420 if (!Number.isNaN(x5) && options.clamp) {
2421 x5 = Math.min(Math.max(x5, lowerBound), upperBound);
2422 x5 = evenRound(x5);
2423 return x5;
2424 }
2425 if (!Number.isFinite(x5) || x5 === 0) {
2426 return 0;
2427 }
2428 x5 = integerPart(x5);
2429 if (x5 >= lowerBound && x5 <= upperBound) {
2430 return x5;
2431 }
2432 x5 = modulo(x5, twoToTheBitLength);
2433 if (!unsigned && x5 >= twoToOneLessThanTheBitLength) {
2434 return x5 - twoToTheBitLength;
2435 }
2436 return x5;
2437 };
2438 }
2439 function createLongLongConversion(bitLength, { unsigned }) {
2440 const upperBound = Number.MAX_SAFE_INTEGER;
2441 const lowerBound = unsigned ? 0 : Number.MIN_SAFE_INTEGER;

Calls 9

toNumberFunction · 0.85
censorNegativeZeroFunction · 0.85
makeExceptionFunction · 0.85
integerPartFunction · 0.85
evenRoundFunction · 0.85
moduloFunction · 0.85
isFiniteMethod · 0.80
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…