Server IP : 162.213.251.212 / Your IP : 3.136.160.250 [ Web Server : LiteSpeed System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : allssztx ( 535) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/home/allssztx/needapair.com/node_modules/bson/src/utils/ |
Upload File : |
/** * @internal * Removes leading zeros and explicit plus from textual representation of a number. */ export function removeLeadingZerosAndExplicitPlus(str: string): string { if (str === '') { return str; } let startIndex = 0; const isNegative = str[startIndex] === '-'; const isExplicitlyPositive = str[startIndex] === '+'; if (isExplicitlyPositive || isNegative) { startIndex += 1; } let foundInsignificantZero = false; for (; startIndex < str.length && str[startIndex] === '0'; ++startIndex) { foundInsignificantZero = true; } if (!foundInsignificantZero) { return isExplicitlyPositive ? str.slice(1) : str; } return `${isNegative ? '-' : ''}${str.length === startIndex ? '0' : str.slice(startIndex)}`; } /** * @internal * Returns false for an string that contains invalid characters for its radix, else returns the original string. * @param str - The textual representation of the Long * @param radix - The radix in which the text is written (2-36), defaults to 10 */ export function validateStringCharacters(str: string, radix?: number): false | string { radix = radix ?? 10; const validCharacters = '0123456789abcdefghijklmnopqrstuvwxyz'.slice(0, radix); // regex is case insensitive and checks that each character within the string is one of the validCharacters const regex = new RegExp(`[^-+${validCharacters}]`, 'i'); return regex.test(str) ? false : str; }