@metamask-previews/utils 11.12.1-preview-c44fd50 → 11.12.1-preview-2caaa71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/{assert.d.mts → assert.d.ts} +2 -2
- package/dist/assert.d.ts.map +1 -0
- package/dist/{assert.mjs → assert.js} +4 -4
- package/dist/assert.js.map +1 -0
- package/dist/{base64.d.cts → base64.d.ts} +2 -2
- package/dist/base64.d.ts.map +1 -0
- package/dist/{base64.mjs → base64.js} +3 -3
- package/dist/base64.js.map +1 -0
- package/dist/{bytes.d.cts → bytes.d.ts} +2 -2
- package/dist/bytes.d.ts.map +1 -0
- package/dist/{bytes.mjs → bytes.js} +4 -4
- package/dist/bytes.js.map +1 -0
- package/dist/{caip-types.d.cts → caip-types.d.ts} +2 -2
- package/dist/caip-types.d.ts.map +1 -0
- package/dist/{caip-types.mjs → caip-types.js} +2 -2
- package/dist/caip-types.js.map +1 -0
- package/dist/{checksum.d.cts → checksum.d.ts} +1 -1
- package/dist/checksum.d.ts.map +1 -0
- package/dist/checksum.js +4 -0
- package/dist/checksum.js.map +1 -0
- package/dist/{coercers.d.cts → coercers.d.ts} +4 -4
- package/dist/coercers.d.ts.map +1 -0
- package/dist/{coercers.mjs → coercers.js} +5 -5
- package/dist/coercers.js.map +1 -0
- package/dist/{collections.d.cts → collections.d.ts} +9 -9
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +93 -0
- package/dist/collections.js.map +1 -0
- package/dist/{encryption-types.d.cts → encryption-types.d.ts} +1 -1
- package/dist/encryption-types.d.ts.map +1 -0
- package/dist/encryption-types.js +2 -0
- package/dist/encryption-types.js.map +1 -0
- package/dist/{errors.d.mts → errors.d.ts} +1 -1
- package/dist/errors.d.ts.map +1 -0
- package/dist/{errors.mjs → errors.js} +4 -10
- package/dist/errors.js.map +1 -0
- package/dist/{fs.d.cts → fs.d.ts} +2 -2
- package/dist/fs.d.ts.map +1 -0
- package/dist/{fs.mjs → fs.js} +7 -7
- package/dist/fs.js.map +1 -0
- package/dist/{hashing.d.cts → hashing.d.ts} +1 -1
- package/dist/hashing.d.ts.map +1 -0
- package/dist/{hashing.mjs → hashing.js} +8 -3
- package/dist/hashing.js.map +1 -0
- package/dist/{hex.d.cts → hex.d.ts} +5 -6
- package/dist/hex.d.ts.map +1 -0
- package/dist/{hex.mjs → hex.js} +5 -6
- package/dist/hex.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/{json.d.cts → json.d.ts} +19 -29
- package/dist/json.d.ts.map +1 -0
- package/dist/{json.mjs → json.js} +5 -4
- package/dist/json.js.map +1 -0
- package/dist/{keyring.d.mts → keyring.d.ts} +5 -5
- package/dist/keyring.d.ts.map +1 -0
- package/dist/keyring.js +2 -0
- package/dist/keyring.js.map +1 -0
- package/dist/{logging.d.cts → logging.d.ts} +2 -2
- package/dist/logging.d.ts.map +1 -0
- package/dist/{logging.mjs → logging.js} +2 -9
- package/dist/logging.js.map +1 -0
- package/dist/{misc.d.mts → misc.d.ts} +1 -1
- package/dist/misc.d.ts.map +1 -0
- package/dist/{misc.mjs → misc.js} +1 -1
- package/dist/misc.js.map +1 -0
- package/dist/{mnemonic.d.cts → mnemonic.d.ts} +1 -1
- package/dist/mnemonic.d.ts.map +1 -0
- package/dist/{mnemonic.mjs → mnemonic.js} +2 -2
- package/dist/mnemonic.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/{number.d.mts → number.d.ts} +2 -2
- package/dist/number.d.ts.map +1 -0
- package/dist/{number.mjs → number.js} +3 -3
- package/dist/number.js.map +1 -0
- package/dist/{opaque.d.cts → opaque.d.ts} +1 -1
- package/dist/opaque.d.ts.map +1 -0
- package/dist/opaque.js +2 -0
- package/dist/opaque.js.map +1 -0
- package/dist/{promise.d.cts → promise.d.ts} +1 -1
- package/dist/promise.d.ts.map +1 -0
- package/dist/{promise.mjs → promise.js} +1 -1
- package/dist/promise.js.map +1 -0
- package/dist/{superstruct.d.mts → superstruct.d.ts} +2 -2
- package/dist/superstruct.d.ts.map +1 -0
- package/dist/{superstruct.mjs → superstruct.js} +2 -2
- package/dist/superstruct.js.map +1 -0
- package/dist/{time.d.mts → time.d.ts} +1 -1
- package/dist/time.d.ts.map +1 -0
- package/dist/{time.mjs → time.js} +1 -1
- package/dist/time.js.map +1 -0
- package/dist/{transaction-types.d.cts → transaction-types.d.ts} +3 -3
- package/dist/transaction-types.d.ts.map +1 -0
- package/dist/transaction-types.js +2 -0
- package/dist/transaction-types.js.map +1 -0
- package/dist/{unitsConversion.d.cts → unitsConversion.d.ts} +28 -28
- package/dist/unitsConversion.d.ts.map +1 -0
- package/dist/{unitsConversion.mjs → unitsConversion.js} +1 -1
- package/dist/unitsConversion.js.map +1 -0
- package/dist/{versions.d.mts → versions.d.ts} +3 -3
- package/dist/versions.d.ts.map +1 -0
- package/dist/{versions.mjs → versions.js} +4 -4
- package/dist/versions.js.map +1 -0
- package/package.json +21 -30
- package/dist/assert.cjs +0 -122
- package/dist/assert.cjs.map +0 -1
- package/dist/assert.d.cts +0 -61
- package/dist/assert.d.cts.map +0 -1
- package/dist/assert.d.mts.map +0 -1
- package/dist/assert.mjs.map +0 -1
- package/dist/base64.cjs +0 -34
- package/dist/base64.cjs.map +0 -1
- package/dist/base64.d.cts.map +0 -1
- package/dist/base64.d.mts +0 -25
- package/dist/base64.d.mts.map +0 -1
- package/dist/base64.mjs.map +0 -1
- package/dist/bytes.cjs +0 -427
- package/dist/bytes.cjs.map +0 -1
- package/dist/bytes.d.cts.map +0 -1
- package/dist/bytes.d.mts +0 -198
- package/dist/bytes.d.mts.map +0 -1
- package/dist/bytes.mjs.map +0 -1
- package/dist/caip-types.cjs +0 -390
- package/dist/caip-types.cjs.map +0 -1
- package/dist/caip-types.d.cts.map +0 -1
- package/dist/caip-types.d.mts +0 -294
- package/dist/caip-types.d.mts.map +0 -1
- package/dist/caip-types.mjs.map +0 -1
- package/dist/checksum.cjs +0 -7
- package/dist/checksum.cjs.map +0 -1
- package/dist/checksum.d.cts.map +0 -1
- package/dist/checksum.d.mts +0 -2
- package/dist/checksum.d.mts.map +0 -1
- package/dist/checksum.mjs +0 -4
- package/dist/checksum.mjs.map +0 -1
- package/dist/coercers.cjs +0 -166
- package/dist/coercers.cjs.map +0 -1
- package/dist/coercers.d.cts.map +0 -1
- package/dist/coercers.d.mts +0 -97
- package/dist/coercers.d.mts.map +0 -1
- package/dist/coercers.mjs.map +0 -1
- package/dist/collections.cjs +0 -109
- package/dist/collections.cjs.map +0 -1
- package/dist/collections.d.cts.map +0 -1
- package/dist/collections.d.mts +0 -39
- package/dist/collections.d.mts.map +0 -1
- package/dist/collections.mjs +0 -105
- package/dist/collections.mjs.map +0 -1
- package/dist/encryption-types.cjs +0 -3
- package/dist/encryption-types.cjs.map +0 -1
- package/dist/encryption-types.d.cts.map +0 -1
- package/dist/encryption-types.d.mts +0 -7
- package/dist/encryption-types.d.mts.map +0 -1
- package/dist/encryption-types.mjs +0 -2
- package/dist/encryption-types.mjs.map +0 -1
- package/dist/errors.cjs +0 -129
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.d.cts +0 -68
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.mts.map +0 -1
- package/dist/errors.mjs.map +0 -1
- package/dist/fs.cjs +0 -248
- package/dist/fs.cjs.map +0 -1
- package/dist/fs.d.cts.map +0 -1
- package/dist/fs.d.mts +0 -133
- package/dist/fs.d.mts.map +0 -1
- package/dist/fs.mjs.map +0 -1
- package/dist/hashing.cjs +0 -60
- package/dist/hashing.cjs.map +0 -1
- package/dist/hashing.d.cts.map +0 -1
- package/dist/hashing.d.mts +0 -28
- package/dist/hashing.d.mts.map +0 -1
- package/dist/hashing.mjs.map +0 -1
- package/dist/hex.cjs +0 -188
- package/dist/hex.cjs.map +0 -1
- package/dist/hex.d.cts.map +0 -1
- package/dist/hex.d.mts +0 -118
- package/dist/hex.d.mts.map +0 -1
- package/dist/hex.mjs.map +0 -1
- package/dist/index.cjs +0 -58
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -26
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -26
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -21
- package/dist/index.mjs.map +0 -1
- package/dist/json.cjs +0 -425
- package/dist/json.cjs.map +0 -1
- package/dist/json.d.cts.map +0 -1
- package/dist/json.d.mts +0 -398
- package/dist/json.d.mts.map +0 -1
- package/dist/json.mjs.map +0 -1
- package/dist/keyring.cjs +0 -3
- package/dist/keyring.cjs.map +0 -1
- package/dist/keyring.d.cts +0 -243
- package/dist/keyring.d.cts.map +0 -1
- package/dist/keyring.d.mts.map +0 -1
- package/dist/keyring.mjs +0 -2
- package/dist/keyring.mjs.map +0 -1
- package/dist/logging.cjs +0 -43
- package/dist/logging.cjs.map +0 -1
- package/dist/logging.d.cts.map +0 -1
- package/dist/logging.d.mts +0 -30
- package/dist/logging.d.mts.map +0 -1
- package/dist/logging.mjs.map +0 -1
- package/dist/misc.cjs +0 -154
- package/dist/misc.cjs.map +0 -1
- package/dist/misc.d.cts +0 -127
- package/dist/misc.d.cts.map +0 -1
- package/dist/misc.d.mts.map +0 -1
- package/dist/misc.mjs.map +0 -1
- package/dist/mnemonic.cjs +0 -53
- package/dist/mnemonic.cjs.map +0 -1
- package/dist/mnemonic.d.cts.map +0 -1
- package/dist/mnemonic.d.mts +0 -14
- package/dist/mnemonic.d.mts.map +0 -1
- package/dist/mnemonic.mjs.map +0 -1
- package/dist/node.cjs +0 -19
- package/dist/node.cjs.map +0 -1
- package/dist/node.d.cts +0 -3
- package/dist/node.d.cts.map +0 -1
- package/dist/node.d.mts +0 -3
- package/dist/node.d.mts.map +0 -1
- package/dist/node.mjs +0 -3
- package/dist/node.mjs.map +0 -1
- package/dist/number.cjs +0 -102
- package/dist/number.cjs.map +0 -1
- package/dist/number.d.cts +0 -74
- package/dist/number.d.cts.map +0 -1
- package/dist/number.d.mts.map +0 -1
- package/dist/number.mjs.map +0 -1
- package/dist/opaque.cjs +0 -3
- package/dist/opaque.cjs.map +0 -1
- package/dist/opaque.d.cts.map +0 -1
- package/dist/opaque.d.mts +0 -6
- package/dist/opaque.d.mts.map +0 -1
- package/dist/opaque.mjs +0 -2
- package/dist/opaque.mjs.map +0 -1
- package/dist/promise.cjs +0 -44
- package/dist/promise.cjs.map +0 -1
- package/dist/promise.d.cts.map +0 -1
- package/dist/promise.d.mts +0 -45
- package/dist/promise.d.mts.map +0 -1
- package/dist/promise.mjs.map +0 -1
- package/dist/superstruct.cjs +0 -28
- package/dist/superstruct.cjs.map +0 -1
- package/dist/superstruct.d.cts +0 -20
- package/dist/superstruct.d.cts.map +0 -1
- package/dist/superstruct.d.mts.map +0 -1
- package/dist/superstruct.mjs.map +0 -1
- package/dist/time.cjs +0 -67
- package/dist/time.cjs.map +0 -1
- package/dist/time.d.cts +0 -49
- package/dist/time.d.cts.map +0 -1
- package/dist/time.d.mts.map +0 -1
- package/dist/time.mjs.map +0 -1
- package/dist/transaction-types.cjs +0 -3
- package/dist/transaction-types.cjs.map +0 -1
- package/dist/transaction-types.d.cts.map +0 -1
- package/dist/transaction-types.d.mts +0 -117
- package/dist/transaction-types.d.mts.map +0 -1
- package/dist/transaction-types.mjs +0 -2
- package/dist/transaction-types.mjs.map +0 -1
- package/dist/unitsConversion.cjs +0 -217
- package/dist/unitsConversion.cjs.map +0 -1
- package/dist/unitsConversion.d.cts.map +0 -1
- package/dist/unitsConversion.d.mts +0 -80
- package/dist/unitsConversion.d.mts.map +0 -1
- package/dist/unitsConversion.mjs.map +0 -1
- package/dist/versions.cjs +0 -95
- package/dist/versions.cjs.map +0 -1
- package/dist/versions.d.cts +0 -101
- package/dist/versions.d.cts.map +0 -1
- package/dist/versions.d.mts.map +0 -1
- package/dist/versions.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unitsConversion.cjs","sourceRoot":"","sources":["../src/unitsConversion.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC;;;;;;EAME;;;AAEF,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7B;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,GAA6B;IAC3D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,kBAAkB,OAAO,GAAG,YAAY,CAAC,CAAC;AAC5D,CAAC;AAZD,0CAYC;AAED,6BAA6B;AAChB,QAAA,OAAO,GAAG;IACrB,OAAO,EAAE,GAAG;IACZ,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,YAAY;IACrB,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,eAAe;IACtB,UAAU,EAAE,eAAe;IAC3B,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,kBAAkB;IAC1B,UAAU,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,GAAG,GAAG,CAAC;IACd,CAAC;IACD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,GAAG,CAAC;IACjB,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,2BAA2B,UAAU,kCAAkC,CACxE,CAAC;IACJ,CAAC;IAED,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,GAAG,GAAG,WAAW,GAAG,IAAI,GAAG,cAAc,CAAC;IAE9C,IAAI,QAAQ,EAAE,CAAC;QACb,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IACxB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAjFD,sBAiFC","sourcesContent":["/* eslint-disable operator-assignment */\n/*\nPrimary Attribution\nRichard Moore <ricmoo@me.com>\nhttps://github.com/ethers-io\n\nNote, Richard is a god of ether gods. Follow and respect him, and use Ethers.io!\n*/\n\nconst zero = BigInt(0);\nconst negative1 = BigInt(-1);\n\n/**\n * Converts a string, number, or bigint to a bigint.\n *\n * @param arg - The value to convert to bigint.\n * @returns The bigint representation of the input.\n * @throws Error if the input type cannot be converted to bigint.\n */\nexport function numericToBigInt(arg: string | number | bigint): bigint {\n if (typeof arg === 'string') {\n return BigInt(arg);\n }\n if (typeof arg === 'number') {\n return BigInt(arg);\n }\n if (typeof arg === 'bigint') {\n return arg;\n }\n\n throw new Error(`Cannot convert ${typeof arg} to BigInt`);\n}\n\n// complete ethereum unit map\nexport const unitMap = {\n noether: '0',\n wei: '1',\n kwei: '1000',\n Kwei: '1000',\n babbage: '1000',\n femtoether: '1000',\n mwei: '1000000',\n Mwei: '1000000',\n lovelace: '1000000',\n picoether: '1000000',\n gwei: '1000000000',\n Gwei: '1000000000',\n shannon: '1000000000',\n nanoether: '1000000000',\n nano: '1000000000',\n szabo: '1000000000000',\n microether: '1000000000000',\n micro: '1000000000000',\n finney: '1000000000000000',\n milliether: '1000000000000000',\n milli: '1000000000000000',\n ether: '1000000000000000000',\n kether: '1000000000000000000000',\n grand: '1000000000000000000000',\n mether: '1000000000000000000000000',\n gether: '1000000000000000000000000000',\n tether: '1000000000000000000000000000000',\n} as const;\n\n// Pre-computed unit values as BigInt for performance\nconst unitMapBigInt = Object.fromEntries(\n Object.entries(unitMap).map(([key, value]) => [key, BigInt(value)]),\n) as Record<EthereumUnit, bigint>;\n\nconst unitLengths = Object.fromEntries(\n Object.entries(unitMap).map(([key, value]) => [key, value.length - 1 || 1]),\n) as Record<EthereumUnit, number>;\n\nconst NUMBER_REGEX = /^-?[0-9.]+$/u;\nconst FRACTION_REGEX = /^([0-9]*[1-9]|0)(0*)/u;\nconst COMMIFY_REGEX = /\\B(?=(\\d{3})+(?!\\d))/gu;\n\ntype EthereumUnit = keyof typeof unitMap;\n\n/**\n * Returns value of unit in Wei.\n *\n * @param unitInput - The unit to convert to, default ether.\n * @returns Value of the unit (in Wei).\n * @throws Error if the unit is not correct.\n */\nexport function getValueOfUnit(unitInput: EthereumUnit = 'ether'): bigint {\n const unit = unitInput.toLowerCase() as EthereumUnit;\n const unitValue = unitMapBigInt[unit];\n\n if (unitValue === undefined) {\n throw new Error(\n `The unit provided ${unitInput} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n return unitValue;\n}\n\n/**\n * Converts a number to a string.\n *\n * @param arg - The number to convert to a string.\n * @returns The string representation of the number.\n * @throws Error if the number is invalid.\n */\nexport function numberToString(arg: string | number | bigint) {\n if (typeof arg === 'string') {\n if (!NUMBER_REGEX.test(arg)) {\n throw new Error(\n `while converting number to string, invalid number value '${arg}', should be a number matching (^-?[0-9.]+).`,\n );\n }\n return arg;\n }\n if (typeof arg === 'number') {\n return String(arg);\n }\n if (typeof arg === 'bigint') {\n return arg.toString();\n }\n throw new Error(\n `while converting number to string, invalid number value '${String(\n arg,\n )}' type ${typeof arg}.`,\n );\n}\n\n/**\n * Converts a number from Wei to a string.\n *\n * @param weiInput - The number to convert from Wei.\n * @param unit - The unit to convert to, default ether.\n * @param optionsInput - The options to use for the conversion.\n * @param optionsInput.pad - Whether to pad the fractional part with zeros.\n * @param optionsInput.commify - Whether to add commas to separate thousands.\n * @returns The string representation of the number.\n * @throws Error if the number is invalid.\n */\nexport function fromWei(\n weiInput: string | number | bigint,\n unit: EthereumUnit,\n optionsInput?: { pad?: boolean; commify?: boolean },\n) {\n let wei = numericToBigInt(weiInput);\n const negative = wei < zero;\n const unitLower = unit.toLowerCase() as EthereumUnit;\n const base = unitMapBigInt[unitLower];\n const baseLength = unitLengths[unitLower];\n const options = optionsInput ?? {};\n\n if (base === undefined) {\n throw new Error(\n `The unit provided ${unit} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n // Handle special case of noether (base = 0)\n if (base === zero) {\n return negative ? '-0' : '0';\n }\n\n if (negative) {\n wei = wei * negative1;\n }\n\n let fraction = (wei % base).toString();\n\n fraction = fraction.padStart(baseLength, '0');\n\n if (!options.pad) {\n const fractionMatch = fraction.match(FRACTION_REGEX);\n // istanbul ignore next: defensive fallback that's never reachable but necessary to satisfy TS\n fraction = fractionMatch?.[1] ?? '0';\n }\n\n let whole = (wei / base).toString();\n\n if (options.commify) {\n whole = whole.replace(COMMIFY_REGEX, ',');\n }\n\n let value = `${whole}${fraction === '0' ? '' : `.${fraction}`}`;\n\n if (negative) {\n value = `-${value}`;\n }\n\n return value;\n}\n\n/**\n * Converts a number to Wei.\n *\n * @param etherInput - The number to convert to Wei.\n * @param unit - The unit to convert to, default ether.\n * @returns The number in Wei.\n * @throws Error if the number is invalid.\n */\nexport function toWei(\n etherInput: string | number | bigint,\n unit: EthereumUnit,\n): bigint {\n const unitLower = unit.toLowerCase() as EthereumUnit;\n const base = unitMapBigInt[unitLower];\n const baseLength = unitLengths[unitLower];\n\n if (base === undefined) {\n throw new Error(\n `The unit provided ${unit} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n // Handle special case of noether (base = 0)\n if (base === zero) {\n return zero;\n }\n\n // Fast path for bigint inputs when unit is wei (no conversion needed)\n if (typeof etherInput === 'bigint' && unitLower === 'wei') {\n return etherInput;\n }\n\n // Fast path for bigint inputs with whole units (no fractional part)\n if (typeof etherInput === 'bigint') {\n return etherInput * base;\n }\n\n let ether = numberToString(etherInput);\n\n // Is it negative?\n const negative = ether.startsWith('-');\n if (negative) {\n ether = ether.substring(1);\n }\n\n if (ether === '.') {\n throw new Error(\n `While converting number ${etherInput} to wei, invalid value`,\n );\n }\n\n // Split it into a whole and fractional part\n const comps = ether.split('.');\n if (comps.length > 2) {\n throw new Error(\n `While converting number ${etherInput} to wei, too many decimal points`,\n );\n }\n\n let whole = comps[0];\n let fraction = comps[1];\n\n if (!whole) {\n whole = '0';\n }\n if (!fraction) {\n fraction = '0';\n }\n if (fraction.length > baseLength) {\n throw new Error(\n `While converting number ${etherInput} to wei, too many decimal places`,\n );\n }\n\n fraction = fraction.padEnd(baseLength, '0');\n\n const wholeBigInt = BigInt(whole);\n const fractionBigInt = BigInt(fraction);\n let wei = wholeBigInt * base + fractionBigInt;\n\n if (negative) {\n wei = wei * negative1;\n }\n\n return wei;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unitsConversion.d.cts","sourceRoot":"","sources":["../src/unitsConversion.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAYrE;AAGD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BV,CAAC;AAeX,KAAK,YAAY,GAAG,MAAM,OAAO,OAAO,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,GAAE,YAAsB,GAAG,MAAM,CAexE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,UAoB3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,IAAI,EAAE,YAAY,EAClB,YAAY,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,UAmDpD;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CACnB,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EACpC,IAAI,EAAE,YAAY,GACjB,MAAM,CA8ER"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a string, number, or bigint to a bigint.
|
|
3
|
-
*
|
|
4
|
-
* @param arg - The value to convert to bigint.
|
|
5
|
-
* @returns The bigint representation of the input.
|
|
6
|
-
* @throws Error if the input type cannot be converted to bigint.
|
|
7
|
-
*/
|
|
8
|
-
export declare function numericToBigInt(arg: string | number | bigint): bigint;
|
|
9
|
-
export declare const unitMap: {
|
|
10
|
-
readonly noether: "0";
|
|
11
|
-
readonly wei: "1";
|
|
12
|
-
readonly kwei: "1000";
|
|
13
|
-
readonly Kwei: "1000";
|
|
14
|
-
readonly babbage: "1000";
|
|
15
|
-
readonly femtoether: "1000";
|
|
16
|
-
readonly mwei: "1000000";
|
|
17
|
-
readonly Mwei: "1000000";
|
|
18
|
-
readonly lovelace: "1000000";
|
|
19
|
-
readonly picoether: "1000000";
|
|
20
|
-
readonly gwei: "1000000000";
|
|
21
|
-
readonly Gwei: "1000000000";
|
|
22
|
-
readonly shannon: "1000000000";
|
|
23
|
-
readonly nanoether: "1000000000";
|
|
24
|
-
readonly nano: "1000000000";
|
|
25
|
-
readonly szabo: "1000000000000";
|
|
26
|
-
readonly microether: "1000000000000";
|
|
27
|
-
readonly micro: "1000000000000";
|
|
28
|
-
readonly finney: "1000000000000000";
|
|
29
|
-
readonly milliether: "1000000000000000";
|
|
30
|
-
readonly milli: "1000000000000000";
|
|
31
|
-
readonly ether: "1000000000000000000";
|
|
32
|
-
readonly kether: "1000000000000000000000";
|
|
33
|
-
readonly grand: "1000000000000000000000";
|
|
34
|
-
readonly mether: "1000000000000000000000000";
|
|
35
|
-
readonly gether: "1000000000000000000000000000";
|
|
36
|
-
readonly tether: "1000000000000000000000000000000";
|
|
37
|
-
};
|
|
38
|
-
type EthereumUnit = keyof typeof unitMap;
|
|
39
|
-
/**
|
|
40
|
-
* Returns value of unit in Wei.
|
|
41
|
-
*
|
|
42
|
-
* @param unitInput - The unit to convert to, default ether.
|
|
43
|
-
* @returns Value of the unit (in Wei).
|
|
44
|
-
* @throws Error if the unit is not correct.
|
|
45
|
-
*/
|
|
46
|
-
export declare function getValueOfUnit(unitInput?: EthereumUnit): bigint;
|
|
47
|
-
/**
|
|
48
|
-
* Converts a number to a string.
|
|
49
|
-
*
|
|
50
|
-
* @param arg - The number to convert to a string.
|
|
51
|
-
* @returns The string representation of the number.
|
|
52
|
-
* @throws Error if the number is invalid.
|
|
53
|
-
*/
|
|
54
|
-
export declare function numberToString(arg: string | number | bigint): string;
|
|
55
|
-
/**
|
|
56
|
-
* Converts a number from Wei to a string.
|
|
57
|
-
*
|
|
58
|
-
* @param weiInput - The number to convert from Wei.
|
|
59
|
-
* @param unit - The unit to convert to, default ether.
|
|
60
|
-
* @param optionsInput - The options to use for the conversion.
|
|
61
|
-
* @param optionsInput.pad - Whether to pad the fractional part with zeros.
|
|
62
|
-
* @param optionsInput.commify - Whether to add commas to separate thousands.
|
|
63
|
-
* @returns The string representation of the number.
|
|
64
|
-
* @throws Error if the number is invalid.
|
|
65
|
-
*/
|
|
66
|
-
export declare function fromWei(weiInput: string | number | bigint, unit: EthereumUnit, optionsInput?: {
|
|
67
|
-
pad?: boolean;
|
|
68
|
-
commify?: boolean;
|
|
69
|
-
}): string;
|
|
70
|
-
/**
|
|
71
|
-
* Converts a number to Wei.
|
|
72
|
-
*
|
|
73
|
-
* @param etherInput - The number to convert to Wei.
|
|
74
|
-
* @param unit - The unit to convert to, default ether.
|
|
75
|
-
* @returns The number in Wei.
|
|
76
|
-
* @throws Error if the number is invalid.
|
|
77
|
-
*/
|
|
78
|
-
export declare function toWei(etherInput: string | number | bigint, unit: EthereumUnit): bigint;
|
|
79
|
-
export {};
|
|
80
|
-
//# sourceMappingURL=unitsConversion.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unitsConversion.d.mts","sourceRoot":"","sources":["../src/unitsConversion.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAYrE;AAGD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BV,CAAC;AAeX,KAAK,YAAY,GAAG,MAAM,OAAO,OAAO,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,GAAE,YAAsB,GAAG,MAAM,CAexE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,UAoB3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,IAAI,EAAE,YAAY,EAClB,YAAY,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,UAmDpD;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CACnB,UAAU,EAAE,MAAM,GAAG,MA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ACX,KAAK,GAAG,GAAG,CAAC;IACd,CAAC;IACD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,GAAG,CAAC;IACjB,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,2BAA2B,UAAU,kCAAkC,CACxE,CAAC;IACJ,CAAC;IAED,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,GAAG,GAAG,WAAW,GAAG,IAAI,GAAG,cAAc,CAAC;IAE9C,IAAI,QAAQ,EAAE,CAAC;QACb,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IACxB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/* eslint-disable operator-assignment */\n/*\nPrimary Attribution\nRichard Moore <ricmoo@me.com>\nhttps://github.com/ethers-io\n\nNote, Richard is a god of ether gods. Follow and respect him, and use Ethers.io!\n*/\n\nconst zero = BigInt(0);\nconst negative1 = BigInt(-1);\n\n/**\n * Converts a string, number, or bigint to a bigint.\n *\n * @param arg - The value to convert to bigint.\n * @returns The bigint representation of the input.\n * @throws Error if the input type cannot be converted to bigint.\n */\nexport function numericToBigInt(arg: string | number | bigint): bigint {\n if (typeof arg === 'string') {\n return BigInt(arg);\n }\n if (typeof arg === 'number') {\n return BigInt(arg);\n }\n if (typeof arg === 'bigint') {\n return arg;\n }\n\n throw new Error(`Cannot convert ${typeof arg} to BigInt`);\n}\n\n// complete ethereum unit map\nexport const unitMap = {\n noether: '0',\n wei: '1',\n kwei: '1000',\n Kwei: '1000',\n babbage: '1000',\n femtoether: '1000',\n mwei: '1000000',\n Mwei: '1000000',\n lovelace: '1000000',\n picoether: '1000000',\n gwei: '1000000000',\n Gwei: '1000000000',\n shannon: '1000000000',\n nanoether: '1000000000',\n nano: '1000000000',\n szabo: '1000000000000',\n microether: '1000000000000',\n micro: '1000000000000',\n finney: '1000000000000000',\n milliether: '1000000000000000',\n milli: '1000000000000000',\n ether: '1000000000000000000',\n kether: '1000000000000000000000',\n grand: '1000000000000000000000',\n mether: '1000000000000000000000000',\n gether: '1000000000000000000000000000',\n tether: '1000000000000000000000000000000',\n} as const;\n\n// Pre-computed unit values as BigInt for performance\nconst unitMapBigInt = Object.fromEntries(\n Object.entries(unitMap).map(([key, value]) => [key, BigInt(value)]),\n) as Record<EthereumUnit, bigint>;\n\nconst unitLengths = Object.fromEntries(\n Object.entries(unitMap).map(([key, value]) => [key, value.length - 1 || 1]),\n) as Record<EthereumUnit, number>;\n\nconst NUMBER_REGEX = /^-?[0-9.]+$/u;\nconst FRACTION_REGEX = /^([0-9]*[1-9]|0)(0*)/u;\nconst COMMIFY_REGEX = /\\B(?=(\\d{3})+(?!\\d))/gu;\n\ntype EthereumUnit = keyof typeof unitMap;\n\n/**\n * Returns value of unit in Wei.\n *\n * @param unitInput - The unit to convert to, default ether.\n * @returns Value of the unit (in Wei).\n * @throws Error if the unit is not correct.\n */\nexport function getValueOfUnit(unitInput: EthereumUnit = 'ether'): bigint {\n const unit = unitInput.toLowerCase() as EthereumUnit;\n const unitValue = unitMapBigInt[unit];\n\n if (unitValue === undefined) {\n throw new Error(\n `The unit provided ${unitInput} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n return unitValue;\n}\n\n/**\n * Converts a number to a string.\n *\n * @param arg - The number to convert to a string.\n * @returns The string representation of the number.\n * @throws Error if the number is invalid.\n */\nexport function numberToString(arg: string | number | bigint) {\n if (typeof arg === 'string') {\n if (!NUMBER_REGEX.test(arg)) {\n throw new Error(\n `while converting number to string, invalid number value '${arg}', should be a number matching (^-?[0-9.]+).`,\n );\n }\n return arg;\n }\n if (typeof arg === 'number') {\n return String(arg);\n }\n if (typeof arg === 'bigint') {\n return arg.toString();\n }\n throw new Error(\n `while converting number to string, invalid number value '${String(\n arg,\n )}' type ${typeof arg}.`,\n );\n}\n\n/**\n * Converts a number from Wei to a string.\n *\n * @param weiInput - The number to convert from Wei.\n * @param unit - The unit to convert to, default ether.\n * @param optionsInput - The options to use for the conversion.\n * @param optionsInput.pad - Whether to pad the fractional part with zeros.\n * @param optionsInput.commify - Whether to add commas to separate thousands.\n * @returns The string representation of the number.\n * @throws Error if the number is invalid.\n */\nexport function fromWei(\n weiInput: string | number | bigint,\n unit: EthereumUnit,\n optionsInput?: { pad?: boolean; commify?: boolean },\n) {\n let wei = numericToBigInt(weiInput);\n const negative = wei < zero;\n const unitLower = unit.toLowerCase() as EthereumUnit;\n const base = unitMapBigInt[unitLower];\n const baseLength = unitLengths[unitLower];\n const options = optionsInput ?? {};\n\n if (base === undefined) {\n throw new Error(\n `The unit provided ${unit} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n // Handle special case of noether (base = 0)\n if (base === zero) {\n return negative ? '-0' : '0';\n }\n\n if (negative) {\n wei = wei * negative1;\n }\n\n let fraction = (wei % base).toString();\n\n fraction = fraction.padStart(baseLength, '0');\n\n if (!options.pad) {\n const fractionMatch = fraction.match(FRACTION_REGEX);\n // istanbul ignore next: defensive fallback that's never reachable but necessary to satisfy TS\n fraction = fractionMatch?.[1] ?? '0';\n }\n\n let whole = (wei / base).toString();\n\n if (options.commify) {\n whole = whole.replace(COMMIFY_REGEX, ',');\n }\n\n let value = `${whole}${fraction === '0' ? '' : `.${fraction}`}`;\n\n if (negative) {\n value = `-${value}`;\n }\n\n return value;\n}\n\n/**\n * Converts a number to Wei.\n *\n * @param etherInput - The number to convert to Wei.\n * @param unit - The unit to convert to, default ether.\n * @returns The number in Wei.\n * @throws Error if the number is invalid.\n */\nexport function toWei(\n etherInput: string | number | bigint,\n unit: EthereumUnit,\n): bigint {\n const unitLower = unit.toLowerCase() as EthereumUnit;\n const base = unitMapBigInt[unitLower];\n const baseLength = unitLengths[unitLower];\n\n if (base === undefined) {\n throw new Error(\n `The unit provided ${unit} doesn't exist, please use the one of the following units ${JSON.stringify(\n unitMap,\n null,\n 2,\n )}`,\n );\n }\n\n // Handle special case of noether (base = 0)\n if (base === zero) {\n return zero;\n }\n\n // Fast path for bigint inputs when unit is wei (no conversion needed)\n if (typeof etherInput === 'bigint' && unitLower === 'wei') {\n return etherInput;\n }\n\n // Fast path for bigint inputs with whole units (no fractional part)\n if (typeof etherInput === 'bigint') {\n return etherInput * base;\n }\n\n let ether = numberToString(etherInput);\n\n // Is it negative?\n const negative = ether.startsWith('-');\n if (negative) {\n ether = ether.substring(1);\n }\n\n if (ether === '.') {\n throw new Error(\n `While converting number ${etherInput} to wei, invalid value`,\n );\n }\n\n // Split it into a whole and fractional part\n const comps = ether.split('.');\n if (comps.length > 2) {\n throw new Error(\n `While converting number ${etherInput} to wei, too many decimal points`,\n );\n }\n\n let whole = comps[0];\n let fraction = comps[1];\n\n if (!whole) {\n whole = '0';\n }\n if (!fraction) {\n fraction = '0';\n }\n if (fraction.length > baseLength) {\n throw new Error(\n `While converting number ${etherInput} to wei, too many decimal places`,\n );\n }\n\n fraction = fraction.padEnd(baseLength, '0');\n\n const wholeBigInt = BigInt(whole);\n const fractionBigInt = BigInt(fraction);\n let wei = wholeBigInt * base + fractionBigInt;\n\n if (negative) {\n wei = wei * negative1;\n }\n\n return wei;\n}\n"]}
|
package/dist/versions.cjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.satisfiesVersionRange = exports.gtRange = exports.gtVersion = exports.assertIsSemVerRange = exports.assertIsSemVerVersion = exports.isValidSemVerRange = exports.isValidSemVerVersion = exports.VersionRangeStruct = exports.VersionStruct = void 0;
|
|
4
|
-
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
-
const semver_1 = require("semver");
|
|
6
|
-
const assert_1 = require("./assert.cjs");
|
|
7
|
-
/**
|
|
8
|
-
* A struct for validating a version string.
|
|
9
|
-
*/
|
|
10
|
-
exports.VersionStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'Version', (value) => {
|
|
11
|
-
if ((0, semver_1.valid)(value) === null) {
|
|
12
|
-
return `Expected SemVer version, got "${value}"`;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
});
|
|
16
|
-
exports.VersionRangeStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'Version range', (value) => {
|
|
17
|
-
if ((0, semver_1.validRange)(value) === null) {
|
|
18
|
-
return `Expected SemVer range, got "${value}"`;
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
});
|
|
22
|
-
/**
|
|
23
|
-
* Checks whether a SemVer version is valid.
|
|
24
|
-
*
|
|
25
|
-
* @param version - A potential version.
|
|
26
|
-
* @returns `true` if the version is valid, and `false` otherwise.
|
|
27
|
-
*/
|
|
28
|
-
function isValidSemVerVersion(version) {
|
|
29
|
-
return (0, superstruct_1.is)(version, exports.VersionStruct);
|
|
30
|
-
}
|
|
31
|
-
exports.isValidSemVerVersion = isValidSemVerVersion;
|
|
32
|
-
/**
|
|
33
|
-
* Checks whether a SemVer version range is valid.
|
|
34
|
-
*
|
|
35
|
-
* @param versionRange - A potential version range.
|
|
36
|
-
* @returns `true` if the version range is valid, and `false` otherwise.
|
|
37
|
-
*/
|
|
38
|
-
function isValidSemVerRange(versionRange) {
|
|
39
|
-
return (0, superstruct_1.is)(versionRange, exports.VersionRangeStruct);
|
|
40
|
-
}
|
|
41
|
-
exports.isValidSemVerRange = isValidSemVerRange;
|
|
42
|
-
/**
|
|
43
|
-
* Asserts that a value is a valid concrete SemVer version.
|
|
44
|
-
*
|
|
45
|
-
* @param version - A potential SemVer concrete version.
|
|
46
|
-
*/
|
|
47
|
-
function assertIsSemVerVersion(version) {
|
|
48
|
-
(0, assert_1.assertStruct)(version, exports.VersionStruct);
|
|
49
|
-
}
|
|
50
|
-
exports.assertIsSemVerVersion = assertIsSemVerVersion;
|
|
51
|
-
/**
|
|
52
|
-
* Asserts that a value is a valid SemVer range.
|
|
53
|
-
*
|
|
54
|
-
* @param range - A potential SemVer range.
|
|
55
|
-
*/
|
|
56
|
-
function assertIsSemVerRange(range) {
|
|
57
|
-
(0, assert_1.assertStruct)(range, exports.VersionRangeStruct);
|
|
58
|
-
}
|
|
59
|
-
exports.assertIsSemVerRange = assertIsSemVerRange;
|
|
60
|
-
/**
|
|
61
|
-
* Checks whether a SemVer version is greater than another.
|
|
62
|
-
*
|
|
63
|
-
* @param version1 - The left-hand version.
|
|
64
|
-
* @param version2 - The right-hand version.
|
|
65
|
-
* @returns `version1 > version2`.
|
|
66
|
-
*/
|
|
67
|
-
function gtVersion(version1, version2) {
|
|
68
|
-
return (0, semver_1.gt)(version1, version2);
|
|
69
|
-
}
|
|
70
|
-
exports.gtVersion = gtVersion;
|
|
71
|
-
/**
|
|
72
|
-
* Checks whether a SemVer version is greater than all possibilities in a range.
|
|
73
|
-
*
|
|
74
|
-
* @param version - A SemvVer version.
|
|
75
|
-
* @param range - The range to check against.
|
|
76
|
-
* @returns `version > range`.
|
|
77
|
-
*/
|
|
78
|
-
function gtRange(version, range) {
|
|
79
|
-
return (0, semver_1.gtr)(version, range);
|
|
80
|
-
}
|
|
81
|
-
exports.gtRange = gtRange;
|
|
82
|
-
/**
|
|
83
|
-
* Returns whether a SemVer version satisfies a SemVer range.
|
|
84
|
-
*
|
|
85
|
-
* @param version - The SemVer version to check.
|
|
86
|
-
* @param versionRange - The SemVer version range to check against.
|
|
87
|
-
* @returns Whether the version satisfied the version range.
|
|
88
|
-
*/
|
|
89
|
-
function satisfiesVersionRange(version, versionRange) {
|
|
90
|
-
return (0, semver_1.satisfies)(version, versionRange, {
|
|
91
|
-
includePrerelease: true,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
exports.satisfiesVersionRange = satisfiesVersionRange;
|
|
95
|
-
//# sourceMappingURL=versions.cjs.map
|
package/dist/versions.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versions.cjs","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":";;;AACA,uDAA2D;AAC3D,mCAMgB;AAEhB,yCAAwC;AAiDxC;;GAEG;AACU,QAAA,aAAa,GAAG,IAAA,oBAAM,EACjC,IAAA,oBAAM,GAA4C,EAClD,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,IAAA,cAAkB,EAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACvC,OAAO,iCAAiC,KAAK,GAAG,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAA,oBAAM,EACtC,IAAA,oBAAM,GAA0C,EAChD,eAAe,EACf,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,IAAA,mBAAgB,EAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACrC,OAAO,+BAA+B,KAAK,GAAG,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,oBAAoB,CAClC,OAAgB;IAEhB,OAAO,IAAA,gBAAE,EAAC,OAAO,EAAE,qBAAa,CAAC,CAAC;AACpC,CAAC;AAJD,oDAIC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,YAAqB;IAErB,OAAO,IAAA,gBAAE,EAAC,YAAY,EAAE,0BAAkB,CAAC,CAAC;AAC9C,CAAC;AAJD,gDAIC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CACnC,OAAgB;IAEhB,IAAA,qBAAY,EAAC,OAAO,EAAE,qBAAa,CAAC,CAAC;AACvC,CAAC;AAJD,sDAIC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CACjC,KAAc;IAEd,IAAA,qBAAY,EAAC,KAAK,EAAE,0BAAkB,CAAC,CAAC;AAC1C,CAAC;AAJD,kDAIC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CACvB,QAAuB,EACvB,QAAuB;IAEvB,OAAO,IAAA,WAAQ,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AALD,8BAKC;AAED;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,OAAsB,EAAE,KAAkB;IAChE,OAAO,IAAA,YAAS,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAFD,0BAEC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,OAAsB,EACtB,YAAyB;IAEzB,OAAO,IAAA,kBAAe,EAAC,OAAO,EAAE,YAAY,EAAE;QAC5C,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC;AAPD,sDAOC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport { is, refine, string } from '@metamask/superstruct';\nimport {\n gt as gtSemver,\n gtr as gtrSemver,\n satisfies as satisfiesSemver,\n valid as validSemVerVersion,\n validRange as validSemVerRange,\n} from 'semver';\n\nimport { assertStruct } from './assert';\nimport type { Opaque } from './opaque';\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.\n *\n * @example Use {@link assertIsSemVerRange} and {@link isValidSemVerRange} to cast to proper type.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * assertIsSemVerRange(unsafeRange);\n * unsafeRange\n * // ^? SemVerRange\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * unsafeRange as SemVerRange;\n * // ^? SemVerRange\n * ```\n * @see {@link assertIsSemVerRange}\n * @see {@link isValidSemVerRange}\n */\nexport type SemVerRange = Opaque<string, typeof semVerRange>;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Branding symbol for the opaque type; used only via `typeof`.\ndeclare const semVerRange: unique symbol;\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.\n *\n * @example Use {@link assertIsSemVerVersion} and {@link isValidSemVerVersion} to cast to proper type.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * assertIsSemVerVersion(unsafeRange);\n * unsafeVersion\n * // ^? SemVerVersion\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * unsafeRange as SemVerVersion;\n * // ^? SemVerVersion\n * ```\n * @see {@link assertIsSemVerVersion}\n * @see {@link isValidSemVerVersion}\n */\nexport type SemVerVersion = Opaque<string, typeof semVerVersion>;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Branding symbol for the opaque type; used only via `typeof`.\ndeclare const semVerVersion: unique symbol;\n\n/**\n * A struct for validating a version string.\n */\nexport const VersionStruct = refine<SemVerVersion, null>(\n string() as unknown as Struct<SemVerVersion, null>,\n 'Version',\n (value) => {\n if (validSemVerVersion(value) === null) {\n return `Expected SemVer version, got \"${value}\"`;\n }\n return true;\n },\n);\n\nexport const VersionRangeStruct = refine<SemVerRange, null>(\n string() as unknown as Struct<SemVerRange, null>,\n 'Version range',\n (value) => {\n if (validSemVerRange(value) === null) {\n return `Expected SemVer range, got \"${value}\"`;\n }\n return true;\n },\n);\n\n/**\n * Checks whether a SemVer version is valid.\n *\n * @param version - A potential version.\n * @returns `true` if the version is valid, and `false` otherwise.\n */\nexport function isValidSemVerVersion(\n version: unknown,\n): version is SemVerVersion {\n return is(version, VersionStruct);\n}\n\n/**\n * Checks whether a SemVer version range is valid.\n *\n * @param versionRange - A potential version range.\n * @returns `true` if the version range is valid, and `false` otherwise.\n */\nexport function isValidSemVerRange(\n versionRange: unknown,\n): versionRange is SemVerRange {\n return is(versionRange, VersionRangeStruct);\n}\n\n/**\n * Asserts that a value is a valid concrete SemVer version.\n *\n * @param version - A potential SemVer concrete version.\n */\nexport function assertIsSemVerVersion(\n version: unknown,\n): asserts version is SemVerVersion {\n assertStruct(version, VersionStruct);\n}\n\n/**\n * Asserts that a value is a valid SemVer range.\n *\n * @param range - A potential SemVer range.\n */\nexport function assertIsSemVerRange(\n range: unknown,\n): asserts range is SemVerRange {\n assertStruct(range, VersionRangeStruct);\n}\n\n/**\n * Checks whether a SemVer version is greater than another.\n *\n * @param version1 - The left-hand version.\n * @param version2 - The right-hand version.\n * @returns `version1 > version2`.\n */\nexport function gtVersion(\n version1: SemVerVersion,\n version2: SemVerVersion,\n): boolean {\n return gtSemver(version1, version2);\n}\n\n/**\n * Checks whether a SemVer version is greater than all possibilities in a range.\n *\n * @param version - A SemvVer version.\n * @param range - The range to check against.\n * @returns `version > range`.\n */\nexport function gtRange(version: SemVerVersion, range: SemVerRange): boolean {\n return gtrSemver(version, range);\n}\n\n/**\n * Returns whether a SemVer version satisfies a SemVer range.\n *\n * @param version - The SemVer version to check.\n * @param versionRange - The SemVer version range to check against.\n * @returns Whether the version satisfied the version range.\n */\nexport function satisfiesVersionRange(\n version: SemVerVersion,\n versionRange: SemVerRange,\n): boolean {\n return satisfiesSemver(version, versionRange, {\n includePrerelease: true,\n });\n}\n"]}
|
package/dist/versions.d.cts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { Struct } from "@metamask/superstruct";
|
|
2
|
-
import type { Opaque } from "./opaque.cjs";
|
|
3
|
-
/**
|
|
4
|
-
* {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.
|
|
5
|
-
*
|
|
6
|
-
* @example Use {@link assertIsSemVerRange} and {@link isValidSemVerRange} to cast to proper type.
|
|
7
|
-
* ```typescript
|
|
8
|
-
* const unsafeRange: string = dataFromUser();
|
|
9
|
-
* assertIsSemVerRange(unsafeRange);
|
|
10
|
-
* unsafeRange
|
|
11
|
-
* // ^? SemVerRange
|
|
12
|
-
* ```
|
|
13
|
-
* @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const unsafeRange: string = dataFromUser();
|
|
16
|
-
* unsafeRange as SemVerRange;
|
|
17
|
-
* // ^? SemVerRange
|
|
18
|
-
* ```
|
|
19
|
-
* @see {@link assertIsSemVerRange}
|
|
20
|
-
* @see {@link isValidSemVerRange}
|
|
21
|
-
*/
|
|
22
|
-
export type SemVerRange = Opaque<string, typeof semVerRange>;
|
|
23
|
-
declare const semVerRange: unique symbol;
|
|
24
|
-
/**
|
|
25
|
-
* {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.
|
|
26
|
-
*
|
|
27
|
-
* @example Use {@link assertIsSemVerVersion} and {@link isValidSemVerVersion} to cast to proper type.
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const unsafeVersion: string = dataFromUser();
|
|
30
|
-
* assertIsSemVerVersion(unsafeRange);
|
|
31
|
-
* unsafeVersion
|
|
32
|
-
* // ^? SemVerVersion
|
|
33
|
-
* ```
|
|
34
|
-
* @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.
|
|
35
|
-
* ```typescript
|
|
36
|
-
* const unsafeVersion: string = dataFromUser();
|
|
37
|
-
* unsafeRange as SemVerVersion;
|
|
38
|
-
* // ^? SemVerVersion
|
|
39
|
-
* ```
|
|
40
|
-
* @see {@link assertIsSemVerVersion}
|
|
41
|
-
* @see {@link isValidSemVerVersion}
|
|
42
|
-
*/
|
|
43
|
-
export type SemVerVersion = Opaque<string, typeof semVerVersion>;
|
|
44
|
-
declare const semVerVersion: unique symbol;
|
|
45
|
-
/**
|
|
46
|
-
* A struct for validating a version string.
|
|
47
|
-
*/
|
|
48
|
-
export declare const VersionStruct: Struct<SemVerVersion, null>;
|
|
49
|
-
export declare const VersionRangeStruct: Struct<SemVerRange, null>;
|
|
50
|
-
/**
|
|
51
|
-
* Checks whether a SemVer version is valid.
|
|
52
|
-
*
|
|
53
|
-
* @param version - A potential version.
|
|
54
|
-
* @returns `true` if the version is valid, and `false` otherwise.
|
|
55
|
-
*/
|
|
56
|
-
export declare function isValidSemVerVersion(version: unknown): version is SemVerVersion;
|
|
57
|
-
/**
|
|
58
|
-
* Checks whether a SemVer version range is valid.
|
|
59
|
-
*
|
|
60
|
-
* @param versionRange - A potential version range.
|
|
61
|
-
* @returns `true` if the version range is valid, and `false` otherwise.
|
|
62
|
-
*/
|
|
63
|
-
export declare function isValidSemVerRange(versionRange: unknown): versionRange is SemVerRange;
|
|
64
|
-
/**
|
|
65
|
-
* Asserts that a value is a valid concrete SemVer version.
|
|
66
|
-
*
|
|
67
|
-
* @param version - A potential SemVer concrete version.
|
|
68
|
-
*/
|
|
69
|
-
export declare function assertIsSemVerVersion(version: unknown): asserts version is SemVerVersion;
|
|
70
|
-
/**
|
|
71
|
-
* Asserts that a value is a valid SemVer range.
|
|
72
|
-
*
|
|
73
|
-
* @param range - A potential SemVer range.
|
|
74
|
-
*/
|
|
75
|
-
export declare function assertIsSemVerRange(range: unknown): asserts range is SemVerRange;
|
|
76
|
-
/**
|
|
77
|
-
* Checks whether a SemVer version is greater than another.
|
|
78
|
-
*
|
|
79
|
-
* @param version1 - The left-hand version.
|
|
80
|
-
* @param version2 - The right-hand version.
|
|
81
|
-
* @returns `version1 > version2`.
|
|
82
|
-
*/
|
|
83
|
-
export declare function gtVersion(version1: SemVerVersion, version2: SemVerVersion): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Checks whether a SemVer version is greater than all possibilities in a range.
|
|
86
|
-
*
|
|
87
|
-
* @param version - A SemvVer version.
|
|
88
|
-
* @param range - The range to check against.
|
|
89
|
-
* @returns `version > range`.
|
|
90
|
-
*/
|
|
91
|
-
export declare function gtRange(version: SemVerVersion, range: SemVerRange): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Returns whether a SemVer version satisfies a SemVer range.
|
|
94
|
-
*
|
|
95
|
-
* @param version - The SemVer version to check.
|
|
96
|
-
* @param versionRange - The SemVer version range to check against.
|
|
97
|
-
* @returns Whether the version satisfied the version range.
|
|
98
|
-
*/
|
|
99
|
-
export declare function satisfiesVersionRange(version: SemVerVersion, versionRange: SemVerRange): boolean;
|
|
100
|
-
export {};
|
|
101
|
-
//# sourceMappingURL=versions.d.cts.map
|
package/dist/versions.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.cts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAWpD,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAiB;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,WAAW,CAAC,CAAC;AAE7D,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,aAAa,CAAC,CAAC;AAEjE,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,aAAa,6BASzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,2BAS9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,aAAa,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,WAAW,CAE7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,aAAa,CAElC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,WAAW,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,WAAW,GACxB,OAAO,CAIT"}
|
package/dist/versions.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.mts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAWpD,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAiB;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,WAAW,CAAC,CAAC;AAE7D,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,aAAa,CAAC,CAAC;AAEjE,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,aAAa,6BASzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,2BAS9B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,IAAI,aAAa,CAE1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,WAAW,CAE7B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,IAAI,aAAa,CAElC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,WAAW,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,WAAW,GACxB,OAAO,CAIT"}
|
package/dist/versions.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versions.mjs","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAC3D,OAAO,EACL,EAAE,IAAI,QAAQ,EACd,GAAG,IAAI,SAAS,EAChB,SAAS,IAAI,eAAe,EAC5B,KAAK,IAAI,kBAAkB,EAC3B,UAAU,IAAI,gBAAgB,EAC/B,eAAe;AAEhB,OAAO,EAAE,YAAY,EAAE,qBAAiB;AAiDxC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CACjC,MAAM,EAA4C,EAClD,SAAS,EACT,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,kBAAkB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACvC,OAAO,iCAAiC,KAAK,GAAG,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CACtC,MAAM,EAA0C,EAChD,eAAe,EACf,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,gBAAgB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACrC,OAAO,+BAA+B,KAAK,GAAG,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAgB;IAEhB,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,YAAqB;IAErB,OAAO,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAgB;IAEhB,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAc;IAEd,YAAY,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,QAAuB,EACvB,QAAuB;IAEvB,OAAO,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,OAAsB,EAAE,KAAkB;IAChE,OAAO,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAsB,EACtB,YAAyB;IAEzB,OAAO,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE;QAC5C,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Struct } from '@metamask/superstruct';\nimport { is, refine, string } from '@metamask/superstruct';\nimport {\n gt as gtSemver,\n gtr as gtrSemver,\n satisfies as satisfiesSemver,\n valid as validSemVerVersion,\n validRange as validSemVerRange,\n} from 'semver';\n\nimport { assertStruct } from './assert';\nimport type { Opaque } from './opaque';\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.\n *\n * @example Use {@link assertIsSemVerRange} and {@link isValidSemVerRange} to cast to proper type.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * assertIsSemVerRange(unsafeRange);\n * unsafeRange\n * // ^? SemVerRange\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * unsafeRange as SemVerRange;\n * // ^? SemVerRange\n * ```\n * @see {@link assertIsSemVerRange}\n * @see {@link isValidSemVerRange}\n */\nexport type SemVerRange = Opaque<string, typeof semVerRange>;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Branding symbol for the opaque type; used only via `typeof`.\ndeclare const semVerRange: unique symbol;\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.\n *\n * @example Use {@link assertIsSemVerVersion} and {@link isValidSemVerVersion} to cast to proper type.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * assertIsSemVerVersion(unsafeRange);\n * unsafeVersion\n * // ^? SemVerVersion\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * unsafeRange as SemVerVersion;\n * // ^? SemVerVersion\n * ```\n * @see {@link assertIsSemVerVersion}\n * @see {@link isValidSemVerVersion}\n */\nexport type SemVerVersion = Opaque<string, typeof semVerVersion>;\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Branding symbol for the opaque type; used only via `typeof`.\ndeclare const semVerVersion: unique symbol;\n\n/**\n * A struct for validating a version string.\n */\nexport const VersionStruct = refine<SemVerVersion, null>(\n string() as unknown as Struct<SemVerVersion, null>,\n 'Version',\n (value) => {\n if (validSemVerVersion(value) === null) {\n return `Expected SemVer version, got \"${value}\"`;\n }\n return true;\n },\n);\n\nexport const VersionRangeStruct = refine<SemVerRange, null>(\n string() as unknown as Struct<SemVerRange, null>,\n 'Version range',\n (value) => {\n if (validSemVerRange(value) === null) {\n return `Expected SemVer range, got \"${value}\"`;\n }\n return true;\n },\n);\n\n/**\n * Checks whether a SemVer version is valid.\n *\n * @param version - A potential version.\n * @returns `true` if the version is valid, and `false` otherwise.\n */\nexport function isValidSemVerVersion(\n version: unknown,\n): version is SemVerVersion {\n return is(version, VersionStruct);\n}\n\n/**\n * Checks whether a SemVer version range is valid.\n *\n * @param versionRange - A potential version range.\n * @returns `true` if the version range is valid, and `false` otherwise.\n */\nexport function isValidSemVerRange(\n versionRange: unknown,\n): versionRange is SemVerRange {\n return is(versionRange, VersionRangeStruct);\n}\n\n/**\n * Asserts that a value is a valid concrete SemVer version.\n *\n * @param version - A potential SemVer concrete version.\n */\nexport function assertIsSemVerVersion(\n version: unknown,\n): asserts version is SemVerVersion {\n assertStruct(version, VersionStruct);\n}\n\n/**\n * Asserts that a value is a valid SemVer range.\n *\n * @param range - A potential SemVer range.\n */\nexport function assertIsSemVerRange(\n range: unknown,\n): asserts range is SemVerRange {\n assertStruct(range, VersionRangeStruct);\n}\n\n/**\n * Checks whether a SemVer version is greater than another.\n *\n * @param version1 - The left-hand version.\n * @param version2 - The right-hand version.\n * @returns `version1 > version2`.\n */\nexport function gtVersion(\n version1: SemVerVersion,\n version2: SemVerVersion,\n): boolean {\n return gtSemver(version1, version2);\n}\n\n/**\n * Checks whether a SemVer version is greater than all possibilities in a range.\n *\n * @param version - A SemvVer version.\n * @param range - The range to check against.\n * @returns `version > range`.\n */\nexport function gtRange(version: SemVerVersion, range: SemVerRange): boolean {\n return gtrSemver(version, range);\n}\n\n/**\n * Returns whether a SemVer version satisfies a SemVer range.\n *\n * @param version - The SemVer version to check.\n * @param versionRange - The SemVer version range to check against.\n * @returns Whether the version satisfied the version range.\n */\nexport function satisfiesVersionRange(\n version: SemVerVersion,\n versionRange: SemVerRange,\n): boolean {\n return satisfiesSemver(version, versionRange, {\n includePrerelease: true,\n });\n}\n"]}
|