MCPcopy
hub / github.com/di-sukharev/opencommit / "node_modules/webidl-conversions/lib/index.js"

Function "node_modules/webidl-conversions/lib/index.js"

out/cli.cjs:2353–2694  ·  view source on GitHub ↗
(exports2)

Source from the content-addressed store, hash-verified

2351// node_modules/webidl-conversions/lib/index.js
2352var require_lib = __commonJS({
2353 "node_modules/webidl-conversions/lib/index.js"(exports2) {
2354 "use strict";
2355 function makeException(ErrorType, message, options) {
2356 if (options.globals) {
2357 ErrorType = options.globals[ErrorType.name];
2358 }
2359 return new ErrorType(`${options.context ? options.context : "Value"} ${message}.`);
2360 }
2361 function toNumber(value, options) {
2362 if (typeof value === "bigint") {
2363 throw makeException(TypeError, "is a BigInt which cannot be converted to a number", options);
2364 }
2365 if (!options.globals) {
2366 return Number(value);
2367 }
2368 return options.globals.Number(value);
2369 }
2370 function evenRound(x5) {
2371 if (x5 > 0 && x5 % 1 === 0.5 && (x5 & 1) === 0 || x5 < 0 && x5 % 1 === -0.5 && (x5 & 1) === 1) {
2372 return censorNegativeZero(Math.floor(x5));
2373 }
2374 return censorNegativeZero(Math.round(x5));
2375 }
2376 function integerPart(n2) {
2377 return censorNegativeZero(Math.trunc(n2));
2378 }
2379 function sign(x5) {
2380 return x5 < 0 ? -1 : 1;
2381 }
2382 function modulo(x5, y6) {
2383 const signMightNotMatch = x5 % y6;
2384 if (sign(y6) !== sign(signMightNotMatch)) {
2385 return signMightNotMatch + y6;
2386 }
2387 return signMightNotMatch;
2388 }
2389 function censorNegativeZero(x5) {
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);

Callers

nothing calls this directly

Calls 11

createIntegerConversionFunction · 0.85
createLongLongConversionFunction · 0.85
toNumberFunction · 0.85
makeExceptionFunction · 0.85
isNonSharedArrayBufferFunction · 0.85
isSharedArrayBufferFunction · 0.85
isArrayBufferDetachedFunction · 0.85
isFiniteMethod · 0.80
testMethod · 0.80
pushMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…