From 7f8d8e7e01cd3ab938cced89a997547fb7d47f58 Mon Sep 17 00:00:00 2001 From: Justin Pridgen Date: Sun, 23 Apr 2023 12:02:09 -0400 Subject: [PATCH] 1.0.3 --- .mocharc.json | 5 +- .prettierrc.yaml | 2 +- bin/decodeme.js | 74 ++++++++- bin/encodeme.js | 74 ++++++++- package.json | 17 +- pnpm-lock.yaml | 366 +++++++++++++++++------------------------ src/base.ts | 6 +- src/base32.ts | 14 +- src/base64.ts | 14 +- src/cli.ts | 82 --------- test/dencodeme.test.ts | 2 +- tsconfig.json | 10 +- tsup.config.json | 8 +- 13 files changed, 334 insertions(+), 340 deletions(-) delete mode 100644 src/cli.ts diff --git a/.mocharc.json b/.mocharc.json index 5898553..7378809 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,4 +1,5 @@ { - "extension": ["ts"], - "node-option": ["experimental-loader=ts-node/esm"] + "$schema": "https://json.schemastore.org/mocharc", + "spec": ["test/**/*.test.ts"], + "require": ["ts-node/register"] } diff --git a/.prettierrc.yaml b/.prettierrc.yaml index 9aa4bfc..8a1f6ce 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -5,5 +5,5 @@ quoteProps: consistent trailingComma: none bracketSpacing: true arrowParens: avoid -parser: require("@typescript-eslint/typescript-estree") +parser: typescript endOfLine: lf diff --git a/bin/decodeme.js b/bin/decodeme.js index dda5fa2..9d55599 100644 --- a/bin/decodeme.js +++ b/bin/decodeme.js @@ -1,2 +1,74 @@ #!/usr/bin/env node -require("../dist/cli")(process.argv.slice(2), "decode"); +"use strict"; +const fs = require("fs"); +const path = require("path"); +const { program } = require("commander"); +const dencodeme = require("../dist"); + +const encodingOption = program + .createOption("-e, --encoding ", "The encoding to write the output data in") + .default("utf8") + .choices(["ascii", "binary", "latin1", "ucs2", "utf8", "utf16le"]); +const fileFlag = program + .createOption("-f, --file", "Interprets the input as a file path and decodes the file at the path"); +const inputArgument = program + .createArgument("", "The input data to decode"); +const outOption = program + .createOption("-o, --out ", "The file path to write the output data to"); + +program.name("decodeme") + .usage("[command] [options]") + .description("Decode data using various encoding schemes.") + .version(require("../package.json").version, "-v, --version", "Outputs the current version") + .helpOption("-h, --help", "Outputs this help menu") + .addHelpCommand("help [command]", "Outputs help for command"); + +program.command("base") + .description("Decodes the specified input data from the specified base/radix") + .usage(" [options] ") + .argument("", "The base/radix to decode from, clamped to range 2-36", x => { + const parsed = parseInt(x, 10); + return Number.isNaN(parsed) ? program.error("Base/Radix is not a valid base 10 number") : parsed; + }) + .addArgument(inputArgument) + .addOption(encodingOption) + .addOption(fileFlag) + .addOption(outOption) + .alias("radix") + .action((radix, input, options) => { + try { + const output = dencodeme.base(radix).decode(options.file ? + fs.readFileSync(path.resolve(process.cwd(), input), "utf8") : input); + options.out ? fs.writeFileSync(path.resolve(process.cwd(), options.out), output, options.encoding) : + process.stdout.write(output.toString(options.encoding)); + } catch (err) { + program.error(String(err)); + } + }); + +// Create a command for each base/radix in the dencodeme object +for (const [command, base] of Object.entries(dencodeme).map(x => [x[0], typeof x[1] == "function" ? NaN : x[1].radix]) + .filter(x => !Number.isNaN(x[1]))) { + program.command(command) + .summary(`Decodes the specified input data from base ${base}`) + .description(`Decodes the specified input data from a base/radix of ${base}`) + .usage("[options] ") + .addArgument(inputArgument) + .addOption(encodingOption) + .addOption(fileFlag) + .addOption(outOption) + .aliases(command.startsWith("base") ? [`b${command.slice(4)}`] : [command.slice(0, 3), `base${base}`, `b${base}`]) + .action((input, options) => { + try { + const output = dencodeme[command].decode(options.file ? + fs.readFileSync(path.resolve(process.cwd(), input), "utf8") : input); + options.out ? fs.writeFileSync(path.resolve(process.cwd(), options.out), output, options.encoding) : + process.stdout.write(output.toString(options.encoding)); + } catch (err) { + program.error(String(err)); + } + }); +} + +// Parse the given arguments and run the program +program.parse(process.argv.slice(2), { from: "user" }); diff --git a/bin/encodeme.js b/bin/encodeme.js index 1ac70fc..27e793f 100644 --- a/bin/encodeme.js +++ b/bin/encodeme.js @@ -1,2 +1,74 @@ #!/usr/bin/env node -require("../dist/cli")(process.argv.slice(2), "encode"); +"use strict"; +const fs = require("fs"); +const path = require("path"); +const { program } = require("commander"); +const dencodeme = require("../dist"); + +const encodingOption = program + .createOption("-e, --encoding ", "The encoding to read the input data in") + .default("utf8") + .choices(["ascii", "binary", "latin1", "ucs2", "utf8", "utf16le"]); +const fileFlag = program + .createOption("-f, --file", "Interprets the input as a file path and encodes the file at the path"); +const inputArgument = program + .createArgument("", "The input data to encode"); +const outOption = program + .createOption("-o, --out ", "The file path to write the output data to"); + +program.name("encodeme") + .usage("[command] [options]") + .description("Encode data using various encoding schemes.") + .version(require("../package.json").version, "-v, --version", "Outputs the current version") + .helpOption("-h, --help", "Outputs this help menu") + .addHelpCommand("help [command]", "Outputs help for command"); + +program.command("base") + .description("Encodes the specified input data with the specified base/radix") + .usage(" [options] ") + .argument("", "The base/radix to encode with, clamped to range 2-36", x => { + const parsed = parseInt(x, 10); + return Number.isNaN(parsed) ? program.error("Base/Radix is not a valid base 10 number") : parsed; + }) + .addArgument(inputArgument) + .addOption(encodingOption) + .addOption(fileFlag) + .addOption(outOption) + .alias("radix") + .action((radix, input, options) => { + try { + const output = dencodeme.base(radix).encode(options.file ? + fs.readFileSync(path.resolve(process.cwd(), input), options.encoding) : input); + options.out ? fs.writeFileSync(path.resolve(process.cwd(), options.out), output, options.encoding) : + process.stdout.write(output.toString(options.encoding)); + } catch (err) { + program.error(String(err)); + } + }); + +// Create a command for each base/radix in the dencodeme object +for (const [command, base] of Object.entries(dencodeme).map(x => [x[0], typeof x[1] == "function" ? NaN : x[1].radix]) + .filter(x => !Number.isNaN(x[1]))) { + program.command(command) + .summary(`Encodes the specified input data with base ${base}`) + .description(`Encodes the specified input data with a base/radix of ${base}`) + .usage("[options] ") + .addArgument(inputArgument) + .addOption(encodingOption) + .addOption(fileFlag) + .addOption(outOption) + .aliases(command.startsWith("base") ? [`b${command.slice(4)}`] : [command.slice(0, 3), `base${base}`, `b${base}`]) + .action((input, options) => { + try { + const output = dencodeme[command].encode(options.file ? + fs.readFileSync(path.resolve(process.cwd(), input), options.encoding) : input); + options.out ? fs.writeFileSync(path.resolve(process.cwd(), options.out), output, options.encoding) : + process.stdout.write(output.toString(options.encoding)); + } catch (err) { + program.error(String(err)); + } + }); +} + +// Parse the given arguments and run the program +program.parse(process.argv.slice(2), { from: "user" }); diff --git a/package.json b/package.json index 4cd8749..5bef898 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dencodeme", - "version": "1.0.2", + "version": "1.0.3", "description": "Encode/Decode data using various encoding schemes.", "main": "dist/index.js", "module": "dist/index.mjs", @@ -27,8 +27,8 @@ "homepage": "https://crackabottle.js.org/dencodeme", "scripts": { "build": "tsup", - "docs": "typedoc src --exclude src/cli.ts --includeVersion", - "test": "ts-mocha test", + "docs": "typedoc src/index.ts --includeVersion", + "test": "mocha", "lint": "prettier . -w", "prepare": "pnpm build" }, @@ -36,17 +36,16 @@ "node": ">=16.0.0" }, "dependencies": { - "commander": "^10.0.0" + "commander": "^10.0.1" }, "devDependencies": { "@types/mocha": "^10.0.1", - "@types/node": "^18.15.3", + "@types/node": "^18.15.13", "mocha": "^10.2.0", - "prettier": "^2.8.4", - "ts-mocha": "^10.0.0", + "prettier": "^2.8.7", "ts-node": "^10.9.1", "tsup": "^6.7.0", - "typedoc": "^0.24.1", - "typescript": "^5.0.2" + "typedoc": "^0.24.4", + "typescript": "^5.0.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a36661e..68164bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,37 +2,34 @@ lockfileVersion: '6.0' dependencies: commander: - specifier: ^10.0.0 - version: 10.0.0 + specifier: ^10.0.1 + version: 10.0.1 devDependencies: '@types/mocha': specifier: ^10.0.1 version: 10.0.1 '@types/node': - specifier: ^18.15.3 - version: 18.15.3 + specifier: ^18.15.13 + version: 18.15.13 mocha: specifier: ^10.2.0 version: 10.2.0 prettier: - specifier: ^2.8.4 - version: 2.8.4 - ts-mocha: - specifier: ^10.0.0 - version: 10.0.0(mocha@10.2.0) + specifier: ^2.8.7 + version: 2.8.7 ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@18.15.3)(typescript@5.0.2) + version: 10.9.1(@types/node@18.15.13)(typescript@5.0.4) tsup: specifier: ^6.7.0 - version: 6.7.0(ts-node@10.9.1)(typescript@5.0.2) + version: 6.7.0(ts-node@10.9.1)(typescript@5.0.4) typedoc: - specifier: ^0.24.1 - version: 0.24.1(typescript@5.0.2) + specifier: ^0.24.4 + version: 0.24.4(typescript@5.0.4) typescript: - specifier: ^5.0.2 - version: 5.0.2 + specifier: ^5.0.4 + version: 5.0.4 packages: @@ -43,8 +40,8 @@ packages: '@jridgewell/trace-mapping': 0.3.9 dev: true - /@esbuild/android-arm64@0.17.11: - resolution: {integrity: sha512-QnK4d/zhVTuV4/pRM4HUjcsbl43POALU2zvBynmrrqZt9LPcLA3x1fTZPBg2RRguBQnJcnU059yKr+bydkntjg==} + /@esbuild/android-arm64@0.17.17: + resolution: {integrity: sha512-jaJ5IlmaDLFPNttv0ofcwy/cfeY4bh/n705Tgh+eLObbGtQBK3EPAu+CzL95JVE4nFAliyrnEu0d32Q5foavqg==} engines: {node: '>=12'} cpu: [arm64] os: [android] @@ -52,8 +49,8 @@ packages: dev: true optional: true - /@esbuild/android-arm@0.17.11: - resolution: {integrity: sha512-CdyX6sRVh1NzFCsf5vw3kULwlAhfy9wVt8SZlrhQ7eL2qBjGbFhRBWkkAzuZm9IIEOCKJw4DXA6R85g+qc8RDw==} + /@esbuild/android-arm@0.17.17: + resolution: {integrity: sha512-E6VAZwN7diCa3labs0GYvhEPL2M94WLF8A+czO8hfjREXxba8Ng7nM5VxV+9ihNXIY1iQO1XxUU4P7hbqbICxg==} engines: {node: '>=12'} cpu: [arm] os: [android] @@ -61,8 +58,8 @@ packages: dev: true optional: true - /@esbuild/android-x64@0.17.11: - resolution: {integrity: sha512-3PL3HKtsDIXGQcSCKtWD/dy+mgc4p2Tvo2qKgKHj9Yf+eniwFnuoQ0OUhlSfAEpKAFzF9N21Nwgnap6zy3L3MQ==} + /@esbuild/android-x64@0.17.17: + resolution: {integrity: sha512-446zpfJ3nioMC7ASvJB1pszHVskkw4u/9Eu8s5yvvsSDTzYh4p4ZIRj0DznSl3FBF0Z/mZfrKXTtt0QCoFmoHA==} engines: {node: '>=12'} cpu: [x64] os: [android] @@ -70,8 +67,8 @@ packages: dev: true optional: true - /@esbuild/darwin-arm64@0.17.11: - resolution: {integrity: sha512-pJ950bNKgzhkGNO3Z9TeHzIFtEyC2GDQL3wxkMApDEghYx5Qers84UTNc1bAxWbRkuJOgmOha5V0WUeh8G+YGw==} + /@esbuild/darwin-arm64@0.17.17: + resolution: {integrity: sha512-m/gwyiBwH3jqfUabtq3GH31otL/0sE0l34XKpSIqR7NjQ/XHQ3lpmQHLHbG8AHTGCw8Ao059GvV08MS0bhFIJQ==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] @@ -79,8 +76,8 @@ packages: dev: true optional: true - /@esbuild/darwin-x64@0.17.11: - resolution: {integrity: sha512-iB0dQkIHXyczK3BZtzw1tqegf0F0Ab5texX2TvMQjiJIWXAfM4FQl7D909YfXWnB92OQz4ivBYQ2RlxBJrMJOw==} + /@esbuild/darwin-x64@0.17.17: + resolution: {integrity: sha512-4utIrsX9IykrqYaXR8ob9Ha2hAY2qLc6ohJ8c0CN1DR8yWeMrTgYFjgdeQ9LIoTOfLetXjuCu5TRPHT9yKYJVg==} engines: {node: '>=12'} cpu: [x64] os: [darwin] @@ -88,8 +85,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-arm64@0.17.11: - resolution: {integrity: sha512-7EFzUADmI1jCHeDRGKgbnF5sDIceZsQGapoO6dmw7r/ZBEKX7CCDnIz8m9yEclzr7mFsd+DyasHzpjfJnmBB1Q==} + /@esbuild/freebsd-arm64@0.17.17: + resolution: {integrity: sha512-4PxjQII/9ppOrpEwzQ1b0pXCsFLqy77i0GaHodrmzH9zq2/NEhHMAMJkJ635Ns4fyJPFOlHMz4AsklIyRqFZWA==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] @@ -97,8 +94,8 @@ packages: dev: true optional: true - /@esbuild/freebsd-x64@0.17.11: - resolution: {integrity: sha512-iPgenptC8i8pdvkHQvXJFzc1eVMR7W2lBPrTE6GbhR54sLcF42mk3zBOjKPOodezzuAz/KSu8CPyFSjcBMkE9g==} + /@esbuild/freebsd-x64@0.17.17: + resolution: {integrity: sha512-lQRS+4sW5S3P1sv0z2Ym807qMDfkmdhUYX30GRBURtLTrJOPDpoU0kI6pVz1hz3U0+YQ0tXGS9YWveQjUewAJw==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] @@ -106,8 +103,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm64@0.17.11: - resolution: {integrity: sha512-Qxth3gsWWGKz2/qG2d5DsW/57SeA2AmpSMhdg9TSB5Svn2KDob3qxfQSkdnWjSd42kqoxIPy3EJFs+6w1+6Qjg==} + /@esbuild/linux-arm64@0.17.17: + resolution: {integrity: sha512-2+pwLx0whKY1/Vqt8lyzStyda1v0qjJ5INWIe+d8+1onqQxHLLi3yr5bAa4gvbzhZqBztifYEu8hh1La5+7sUw==} engines: {node: '>=12'} cpu: [arm64] os: [linux] @@ -115,8 +112,8 @@ packages: dev: true optional: true - /@esbuild/linux-arm@0.17.11: - resolution: {integrity: sha512-M9iK/d4lgZH0U5M1R2p2gqhPV/7JPJcRz+8O8GBKVgqndTzydQ7B2XGDbxtbvFkvIs53uXTobOhv+RyaqhUiMg==} + /@esbuild/linux-arm@0.17.17: + resolution: {integrity: sha512-biDs7bjGdOdcmIk6xU426VgdRUpGg39Yz6sT9Xp23aq+IEHDb/u5cbmu/pAANpDB4rZpY/2USPhCA+w9t3roQg==} engines: {node: '>=12'} cpu: [arm] os: [linux] @@ -124,8 +121,8 @@ packages: dev: true optional: true - /@esbuild/linux-ia32@0.17.11: - resolution: {integrity: sha512-dB1nGaVWtUlb/rRDHmuDQhfqazWE0LMro/AIbT2lWM3CDMHJNpLckH+gCddQyhhcLac2OYw69ikUMO34JLt3wA==} + /@esbuild/linux-ia32@0.17.17: + resolution: {integrity: sha512-IBTTv8X60dYo6P2t23sSUYym8fGfMAiuv7PzJ+0LcdAndZRzvke+wTVxJeCq4WgjppkOpndL04gMZIFvwoU34Q==} engines: {node: '>=12'} cpu: [ia32] os: [linux] @@ -133,8 +130,8 @@ packages: dev: true optional: true - /@esbuild/linux-loong64@0.17.11: - resolution: {integrity: sha512-aCWlq70Q7Nc9WDnormntGS1ar6ZFvUpqr8gXtO+HRejRYPweAFQN615PcgaSJkZjhHp61+MNLhzyVALSF2/Q0g==} + /@esbuild/linux-loong64@0.17.17: + resolution: {integrity: sha512-WVMBtcDpATjaGfWfp6u9dANIqmU9r37SY8wgAivuKmgKHE+bWSuv0qXEFt/p3qXQYxJIGXQQv6hHcm7iWhWjiw==} engines: {node: '>=12'} cpu: [loong64] os: [linux] @@ -142,8 +139,8 @@ packages: dev: true optional: true - /@esbuild/linux-mips64el@0.17.11: - resolution: {integrity: sha512-cGeGNdQxqY8qJwlYH1BP6rjIIiEcrM05H7k3tR7WxOLmD1ZxRMd6/QIOWMb8mD2s2YJFNRuNQ+wjMhgEL2oCEw==} + /@esbuild/linux-mips64el@0.17.17: + resolution: {integrity: sha512-2kYCGh8589ZYnY031FgMLy0kmE4VoGdvfJkxLdxP4HJvWNXpyLhjOvxVsYjYZ6awqY4bgLR9tpdYyStgZZhi2A==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] @@ -151,8 +148,8 @@ packages: dev: true optional: true - /@esbuild/linux-ppc64@0.17.11: - resolution: {integrity: sha512-BdlziJQPW/bNe0E8eYsHB40mYOluS+jULPCjlWiHzDgr+ZBRXPtgMV1nkLEGdpjrwgmtkZHEGEPaKdS/8faLDA==} + /@esbuild/linux-ppc64@0.17.17: + resolution: {integrity: sha512-KIdG5jdAEeAKogfyMTcszRxy3OPbZhq0PPsW4iKKcdlbk3YE4miKznxV2YOSmiK/hfOZ+lqHri3v8eecT2ATwQ==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] @@ -160,8 +157,8 @@ packages: dev: true optional: true - /@esbuild/linux-riscv64@0.17.11: - resolution: {integrity: sha512-MDLwQbtF+83oJCI1Cixn68Et/ME6gelmhssPebC40RdJaect+IM+l7o/CuG0ZlDs6tZTEIoxUe53H3GmMn8oMA==} + /@esbuild/linux-riscv64@0.17.17: + resolution: {integrity: sha512-Cj6uWLBR5LWhcD/2Lkfg2NrkVsNb2sFM5aVEfumKB2vYetkA/9Uyc1jVoxLZ0a38sUhFk4JOVKH0aVdPbjZQeA==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] @@ -169,8 +166,8 @@ packages: dev: true optional: true - /@esbuild/linux-s390x@0.17.11: - resolution: {integrity: sha512-4N5EMESvws0Ozr2J94VoUD8HIRi7X0uvUv4c0wpTHZyZY9qpaaN7THjosdiW56irQ4qnJ6Lsc+i+5zGWnyqWqQ==} + /@esbuild/linux-s390x@0.17.17: + resolution: {integrity: sha512-lK+SffWIr0XsFf7E0srBjhpkdFVJf3HEgXCwzkm69kNbRar8MhezFpkIwpk0qo2IOQL4JE4mJPJI8AbRPLbuOQ==} engines: {node: '>=12'} cpu: [s390x] os: [linux] @@ -178,8 +175,8 @@ packages: dev: true optional: true - /@esbuild/linux-x64@0.17.11: - resolution: {integrity: sha512-rM/v8UlluxpytFSmVdbCe1yyKQd/e+FmIJE2oPJvbBo+D0XVWi1y/NQ4iTNx+436WmDHQBjVLrbnAQLQ6U7wlw==} + /@esbuild/linux-x64@0.17.17: + resolution: {integrity: sha512-XcSGTQcWFQS2jx3lZtQi7cQmDYLrpLRyz1Ns1DzZCtn898cWfm5Icx/DEWNcTU+T+tyPV89RQtDnI7qL2PObPg==} engines: {node: '>=12'} cpu: [x64] os: [linux] @@ -187,8 +184,8 @@ packages: dev: true optional: true - /@esbuild/netbsd-x64@0.17.11: - resolution: {integrity: sha512-4WaAhuz5f91h3/g43VBGdto1Q+X7VEZfpcWGtOFXnggEuLvjV+cP6DyLRU15IjiU9fKLLk41OoJfBFN5DhPvag==} + /@esbuild/netbsd-x64@0.17.17: + resolution: {integrity: sha512-RNLCDmLP5kCWAJR+ItLM3cHxzXRTe4N00TQyQiimq+lyqVqZWGPAvcyfUBM0isE79eEZhIuGN09rAz8EL5KdLA==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] @@ -196,8 +193,8 @@ packages: dev: true optional: true - /@esbuild/openbsd-x64@0.17.11: - resolution: {integrity: sha512-UBj135Nx4FpnvtE+C8TWGp98oUgBcmNmdYgl5ToKc0mBHxVVqVE7FUS5/ELMImOp205qDAittL6Ezhasc2Ev/w==} + /@esbuild/openbsd-x64@0.17.17: + resolution: {integrity: sha512-PAXswI5+cQq3Pann7FNdcpSUrhrql3wKjj3gVkmuz6OHhqqYxKvi6GgRBoaHjaG22HV/ZZEgF9TlS+9ftHVigA==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] @@ -205,8 +202,8 @@ packages: dev: true optional: true - /@esbuild/sunos-x64@0.17.11: - resolution: {integrity: sha512-1/gxTifDC9aXbV2xOfCbOceh5AlIidUrPsMpivgzo8P8zUtczlq1ncFpeN1ZyQJ9lVs2hILy1PG5KPp+w8QPPg==} + /@esbuild/sunos-x64@0.17.17: + resolution: {integrity: sha512-V63egsWKnx/4V0FMYkr9NXWrKTB5qFftKGKuZKFIrAkO/7EWLFnbBZNM1CvJ6Sis+XBdPws2YQSHF1Gqf1oj/Q==} engines: {node: '>=12'} cpu: [x64] os: [sunos] @@ -214,8 +211,8 @@ packages: dev: true optional: true - /@esbuild/win32-arm64@0.17.11: - resolution: {integrity: sha512-vtSfyx5yRdpiOW9yp6Ax0zyNOv9HjOAw8WaZg3dF5djEHKKm3UnoohftVvIJtRh0Ec7Hso0RIdTqZvPXJ7FdvQ==} + /@esbuild/win32-arm64@0.17.17: + resolution: {integrity: sha512-YtUXLdVnd6YBSYlZODjWzH+KzbaubV0YVd6UxSfoFfa5PtNJNaW+1i+Hcmjpg2nEe0YXUCNF5bkKy1NnBv1y7Q==} engines: {node: '>=12'} cpu: [arm64] os: [win32] @@ -223,8 +220,8 @@ packages: dev: true optional: true - /@esbuild/win32-ia32@0.17.11: - resolution: {integrity: sha512-GFPSLEGQr4wHFTiIUJQrnJKZhZjjq4Sphf+mM76nQR6WkQn73vm7IsacmBRPkALfpOCHsopSvLgqdd4iUW2mYw==} + /@esbuild/win32-ia32@0.17.17: + resolution: {integrity: sha512-yczSLRbDdReCO74Yfc5tKG0izzm+lPMYyO1fFTcn0QNwnKmc3K+HdxZWLGKg4pZVte7XVgcFku7TIZNbWEJdeQ==} engines: {node: '>=12'} cpu: [ia32] os: [win32] @@ -232,8 +229,8 @@ packages: dev: true optional: true - /@esbuild/win32-x64@0.17.11: - resolution: {integrity: sha512-N9vXqLP3eRL8BqSy8yn4Y98cZI2pZ8fyuHx6lKjiG2WABpT2l01TXdzq5Ma2ZUBzfB7tx5dXVhge8X9u0S70ZQ==} + /@esbuild/win32-x64@0.17.17: + resolution: {integrity: sha512-FNZw7H3aqhF9OyRQbDDnzUApDXfC1N6fgBhkqEO2jvYCJ+DxMTfZVqg3AX0R1khg1wHTBRD5SdcibSJ+XF6bFg==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -241,22 +238,52 @@ packages: dev: true optional: true + /@jridgewell/gen-mapping@0.3.3: + resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/set-array': 1.1.2 + '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/trace-mapping': 0.3.18 + dev: true + /@jridgewell/resolve-uri@3.1.0: resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} engines: {node: '>=6.0.0'} dev: true + /@jridgewell/resolve-uri@3.1.1: + resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==} + engines: {node: '>=6.0.0'} + dev: true + + /@jridgewell/set-array@1.1.2: + resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} + engines: {node: '>=6.0.0'} + dev: true + /@jridgewell/sourcemap-codec@1.4.14: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} dev: true - /@jridgewell/trace-mapping@0.3.9: - resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: true + + /@jridgewell/trace-mapping@0.3.18: + resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==} dependencies: '@jridgewell/resolve-uri': 3.1.0 '@jridgewell/sourcemap-codec': 1.4.14 dev: true + /@jridgewell/trace-mapping@0.3.9: + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + dependencies: + '@jridgewell/resolve-uri': 3.1.1 + '@jridgewell/sourcemap-codec': 1.4.15 + dev: true + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -294,17 +321,12 @@ packages: resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} dev: true - /@types/json5@0.0.29: - resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} - dev: true - optional: true - /@types/mocha@10.0.1: resolution: {integrity: sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==} dev: true - /@types/node@18.15.3: - resolution: {integrity: sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==} + /@types/node@18.15.13: + resolution: {integrity: sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==} dev: true /acorn-walk@8.2.0: @@ -364,11 +386,6 @@ packages: engines: {node: '>=8'} dev: true - /arrify@1.0.1: - resolution: {integrity: sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==} - engines: {node: '>=0.10.0'} - dev: true - /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true @@ -402,18 +419,14 @@ packages: resolution: {integrity: sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==} dev: true - /buffer-from@1.1.2: - resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - dev: true - - /bundle-require@4.0.1(esbuild@0.17.11): + /bundle-require@4.0.1(esbuild@0.17.17): resolution: {integrity: sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} peerDependencies: esbuild: '>=0.17' dependencies: - esbuild: 0.17.11 - load-tsconfig: 0.2.3 + esbuild: 0.17.17 + load-tsconfig: 0.2.5 dev: true /cac@6.7.14: @@ -468,8 +481,8 @@ packages: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} dev: true - /commander@10.0.0: - resolution: {integrity: sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==} + /commander@10.0.1: + resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} dev: false @@ -513,11 +526,6 @@ packages: engines: {node: '>=10'} dev: true - /diff@3.5.0: - resolution: {integrity: sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==} - engines: {node: '>=0.3.1'} - dev: true - /diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} @@ -539,34 +547,34 @@ packages: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true - /esbuild@0.17.11: - resolution: {integrity: sha512-pAMImyokbWDtnA/ufPxjQg0fYo2DDuzAlqwnDvbXqHLphe+m80eF++perYKVm8LeTuj2zUuFXC+xgSVxyoHUdg==} + /esbuild@0.17.17: + resolution: {integrity: sha512-/jUywtAymR8jR4qsa2RujlAF7Krpt5VWi72Q2yuLD4e/hvtNcFQ0I1j8m/bxq238pf3/0KO5yuXNpuLx8BE1KA==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.17.11 - '@esbuild/android-arm64': 0.17.11 - '@esbuild/android-x64': 0.17.11 - '@esbuild/darwin-arm64': 0.17.11 - '@esbuild/darwin-x64': 0.17.11 - '@esbuild/freebsd-arm64': 0.17.11 - '@esbuild/freebsd-x64': 0.17.11 - '@esbuild/linux-arm': 0.17.11 - '@esbuild/linux-arm64': 0.17.11 - '@esbuild/linux-ia32': 0.17.11 - '@esbuild/linux-loong64': 0.17.11 - '@esbuild/linux-mips64el': 0.17.11 - '@esbuild/linux-ppc64': 0.17.11 - '@esbuild/linux-riscv64': 0.17.11 - '@esbuild/linux-s390x': 0.17.11 - '@esbuild/linux-x64': 0.17.11 - '@esbuild/netbsd-x64': 0.17.11 - '@esbuild/openbsd-x64': 0.17.11 - '@esbuild/sunos-x64': 0.17.11 - '@esbuild/win32-arm64': 0.17.11 - '@esbuild/win32-ia32': 0.17.11 - '@esbuild/win32-x64': 0.17.11 + '@esbuild/android-arm': 0.17.17 + '@esbuild/android-arm64': 0.17.17 + '@esbuild/android-x64': 0.17.17 + '@esbuild/darwin-arm64': 0.17.17 + '@esbuild/darwin-x64': 0.17.17 + '@esbuild/freebsd-arm64': 0.17.17 + '@esbuild/freebsd-x64': 0.17.17 + '@esbuild/linux-arm': 0.17.17 + '@esbuild/linux-arm64': 0.17.17 + '@esbuild/linux-ia32': 0.17.17 + '@esbuild/linux-loong64': 0.17.17 + '@esbuild/linux-mips64el': 0.17.17 + '@esbuild/linux-ppc64': 0.17.17 + '@esbuild/linux-riscv64': 0.17.17 + '@esbuild/linux-s390x': 0.17.17 + '@esbuild/linux-x64': 0.17.17 + '@esbuild/netbsd-x64': 0.17.17 + '@esbuild/openbsd-x64': 0.17.17 + '@esbuild/sunos-x64': 0.17.17 + '@esbuild/win32-arm64': 0.17.17 + '@esbuild/win32-ia32': 0.17.17 + '@esbuild/win32-x64': 0.17.17 dev: true /escalade@3.1.1: @@ -785,14 +793,6 @@ packages: argparse: 2.0.1 dev: true - /json5@1.0.2: - resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} - hasBin: true - dependencies: - minimist: 1.2.8 - dev: true - optional: true - /jsonc-parser@3.2.0: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} dev: true @@ -806,8 +806,8 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true - /load-tsconfig@0.2.3: - resolution: {integrity: sha512-iyT2MXws+dc2Wi6o3grCFtGXpeMvHmJqS27sMPGtV2eUu4PeFnG+33I8BlFK1t1NWMjOpcx9bridn5yxLDX2gQ==} + /load-tsconfig@0.2.5: + resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: true @@ -879,24 +879,13 @@ packages: brace-expansion: 2.0.1 dev: true - /minimatch@7.4.6: - resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} - engines: {node: '>=10'} + /minimatch@9.0.0: + resolution: {integrity: sha512-0jJj8AvgKqWN05mrwuqi8QYKx1WmYSUoKSxu5Qhs9prezTz10sxAHGNZe9J9cqIJzta8DWsleh2KaVaLl6Ru2w==} + engines: {node: '>=16 || 14 >=14.17'} dependencies: brace-expansion: 2.0.1 dev: true - /minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - dev: true - - /mkdirp@0.5.6: - resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} - hasBin: true - dependencies: - minimist: 1.2.8 - dev: true - /mocha@10.2.0: resolution: {integrity: sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==} engines: {node: '>= 14.0.0'} @@ -1034,12 +1023,12 @@ packages: optional: true dependencies: lilconfig: 2.1.0 - ts-node: 10.9.1(@types/node@18.15.3)(typescript@5.0.2) + ts-node: 10.9.1(@types/node@18.15.13)(typescript@5.0.4) yaml: 1.10.2 dev: true - /prettier@2.8.4: - resolution: {integrity: sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==} + /prettier@2.8.7: + resolution: {integrity: sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==} engines: {node: '>=10.13.0'} hasBin: true dev: true @@ -1081,8 +1070,8 @@ packages: engines: {iojs: '>=1.0.0', node: '>=0.10.0'} dev: true - /rollup@3.18.0: - resolution: {integrity: sha512-J8C6VfEBjkvYPESMQYxKHxNOh4A5a3FlP+0BETGo34HEcE4eTlgCrO2+eWzlu2a/sHs2QUkZco+wscH7jhhgWg==} + /rollup@3.20.7: + resolution: {integrity: sha512-P7E2zezKSLhWnTz46XxjSmInrbOCiul1yf+kJccMxT56vxjHwCbDfoLbiqFgu+WQoo9ij2PkraYaBstgB2prBA==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: @@ -1135,18 +1124,6 @@ packages: engines: {node: '>=8'} dev: true - /source-map-support@0.5.21: - resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - dev: true - - /source-map@0.6.1: - resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} - engines: {node: '>=0.10.0'} - dev: true - /source-map@0.8.0-beta.0: resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} engines: {node: '>= 8'} @@ -1170,12 +1147,6 @@ packages: ansi-regex: 5.0.1 dev: true - /strip-bom@3.0.0: - resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} - engines: {node: '>=4'} - dev: true - optional: true - /strip-final-newline@2.0.0: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} @@ -1186,11 +1157,12 @@ packages: engines: {node: '>=8'} dev: true - /sucrase@3.29.0: - resolution: {integrity: sha512-bZPAuGA5SdFHuzqIhTAqt9fvNEo9rESqXIG3oiKdF8K4UmkQxC4KlNL3lVyAErXp+mPvUqZ5l13qx6TrDIGf3A==} + /sucrase@3.32.0: + resolution: {integrity: sha512-ydQOU34rpSyj2TGyz4D2p8rbktIOZ8QY9s+DGLvFU1i5pWJE8vkpruCjGCMHsdXwnD7JDcS+noSwM/a7zyNFDQ==} engines: {node: '>=8'} hasBin: true dependencies: + '@jridgewell/gen-mapping': 0.3.3 commander: 4.1.1 glob: 7.1.6 lines-and-columns: 1.2.4 @@ -1248,20 +1220,7 @@ packages: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} dev: true - /ts-mocha@10.0.0(mocha@10.2.0): - resolution: {integrity: sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw==} - engines: {node: '>= 6.X.X'} - hasBin: true - peerDependencies: - mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X - dependencies: - mocha: 10.2.0 - ts-node: 7.0.1 - optionalDependencies: - tsconfig-paths: 3.14.2 - dev: true - - /ts-node@10.9.1(@types/node@18.15.3)(typescript@5.0.2): + /ts-node@10.9.1(@types/node@18.15.13)(typescript@5.0.4): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -1280,45 +1239,19 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.3 - '@types/node': 18.15.3 + '@types/node': 18.15.13 acorn: 8.8.2 acorn-walk: 8.2.0 arg: 4.1.3 create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.0.2 + typescript: 5.0.4 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true - /ts-node@7.0.1: - resolution: {integrity: sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==} - engines: {node: '>=4.2.0'} - hasBin: true - dependencies: - arrify: 1.0.1 - buffer-from: 1.1.2 - diff: 3.5.0 - make-error: 1.3.6 - minimist: 1.2.8 - mkdirp: 0.5.6 - source-map-support: 0.5.21 - yn: 2.0.0 - dev: true - - /tsconfig-paths@3.14.2: - resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} - requiresBuild: true - dependencies: - '@types/json5': 0.0.29 - json5: 1.0.2 - minimist: 1.2.8 - strip-bom: 3.0.0 - dev: true - optional: true - - /tsup@6.7.0(ts-node@10.9.1)(typescript@5.0.2): + /tsup@6.7.0(ts-node@10.9.1)(typescript@5.0.4): resolution: {integrity: sha512-L3o8hGkaHnu5TdJns+mCqFsDBo83bJ44rlK7e6VdanIvpea4ArPcU3swWGsLVbXak1PqQx/V+SSmFPujBK+zEQ==} engines: {node: '>=14.18'} hasBin: true @@ -1334,28 +1267,28 @@ packages: typescript: optional: true dependencies: - bundle-require: 4.0.1(esbuild@0.17.11) + bundle-require: 4.0.1(esbuild@0.17.17) cac: 6.7.14 chokidar: 3.5.3 debug: 4.3.4(supports-color@8.1.1) - esbuild: 0.17.11 + esbuild: 0.17.17 execa: 5.1.1 globby: 11.1.0 joycon: 3.1.1 postcss-load-config: 3.1.4(ts-node@10.9.1) resolve-from: 5.0.0 - rollup: 3.18.0 + rollup: 3.20.7 source-map: 0.8.0-beta.0 - sucrase: 3.29.0 + sucrase: 3.32.0 tree-kill: 1.2.2 - typescript: 5.0.2 + typescript: 5.0.4 transitivePeerDependencies: - supports-color - ts-node dev: true - /typedoc@0.24.1(typescript@5.0.2): - resolution: {integrity: sha512-u4HwjZcSQhQSkkhLjgcs0ooAf6HrFVLDHHrwU2xZW8WxH0KnGZlNkaWxiOcK5Gagj7mxJSgwWx0dv8ACDAOXAQ==} + /typedoc@0.24.4(typescript@5.0.4): + resolution: {integrity: sha512-vQuliyGhJEGeKzzCFHbkS3m0gHoIL6cfr0fHf6eX658iGELtq2J9mWe0b+X5McEYgFoMuHFt5Py3Zug6Sxjn/Q==} engines: {node: '>= 14.14'} hasBin: true peerDependencies: @@ -1363,13 +1296,13 @@ packages: dependencies: lunr: 2.3.9 marked: 4.3.0 - minimatch: 7.4.6 + minimatch: 9.0.0 shiki: 0.14.1 - typescript: 5.0.2 + typescript: 5.0.4 dev: true - /typescript@5.0.2: - resolution: {integrity: sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==} + /typescript@5.0.4: + resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} engines: {node: '>=12.20'} hasBin: true dev: true @@ -1461,11 +1394,6 @@ packages: yargs-parser: 20.2.4 dev: true - /yn@2.0.0: - resolution: {integrity: sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==} - engines: {node: '>=4'} - dev: true - /yn@3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} engines: {node: '>=6'} diff --git a/src/base.ts b/src/base.ts index 1c4d3b7..c69594b 100644 --- a/src/base.ts +++ b/src/base.ts @@ -12,13 +12,13 @@ export function base(radix: number): NumberSystem { radix: rdx, regex: new RegExp(`[${charset}]`, "gi"), encode(data, encoding = "utf8") { + // For each byte of data, encode it into a character. return Buffer.from(data.toString(encoding), encoding).toJSON().data.map(x => x.toString(rdx).padStart(max, "0")).join(""); }, decode(data, encoding) { - const charMatch = data.toString().toLowerCase().match(this.regex); - if (charMatch == null) return ""; - + // For each character of data, decode it into a byte. const decoded = Buffer.from(util.padStart((data.toString().toLowerCase().match(this.regex) ?? []).join(""), max).map(x => parseInt(x, rdx))); + // Return the decoded buffer, or a string if a character encoding is provided. return encoding ? decoded.toString(encoding) : decoded; } } diff --git a/src/base32.ts b/src/base32.ts index 1154287..6c8be65 100644 --- a/src/base32.ts +++ b/src/base32.ts @@ -1,8 +1,8 @@ import * as util from "./util"; -export const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; -export const radix = 32; -export const regex = /[A-Z2-7]/gi; +export const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; // The base 32 character set. +export const radix = 32; // The base 32 radix. +export const regex = /[A-Z2-7]/gi; // The base 32 regex. const bits = util.quickMap(5, x => 2 ** (x * 8), true); // 4294967296, 16777216, 65536, 256, 1 const chars = util.quickMap(8, x => 2 ** (x * 5), true); // 34359738368, 1073741824, 33554432, 1048576, 32768, 1024, 32, 1 @@ -10,7 +10,9 @@ const pads = util.quickMap(5, x => (8 - Math.ceil(x * 8 / 5)) % 8, false); // 0, // Encodes the given data into a Base 32 encoded string. export function encode(data: string | Buffer, encoding: BufferEncoding = "utf8") { + // The number of padding characters to add to the end of the encoded string. let padding = 0; + // For each 5 bytes of data, encode them into 8 characters. (With padding if necessary.) return Buffer.from(data.toString(encoding), encoding).reduce((a, x, i, r) => { if (i % 5 == 0) a.push(0); a[a.length - 1] += x * bits[i % 5]; @@ -18,17 +20,19 @@ export function encode(data: string | Buffer, encoding: BufferEncoding = "utf8") if ((i + 1) >= r.length) padding = pads[r.length % 5]; return a; }, [] as number[]).map((x, i, r) => - chars.slice(0, 8 - ((i + 1) >= r.length ? padding : 0)).map(y => + chars.slice(0, 8 - Number((i + 1) >= r.length) * padding).map(y => charset[Math.floor(x / y) % 32]).join("")).join("") + "=".repeat(padding); } // Decodes the given Base 32 encoded string into a buffer, or a string if a character encoding is provided. export function decode(data: string, encoding?: BufferEncoding) { + // For each 8 characters of data, decode them into 5 bytes. const decoded = Buffer.from(util.padEnd((data.toString().toUpperCase().match(regex) ?? []).join(""), 8) .flatMap(x => { const value = util.stringToNumber(x, charset); - return bits.slice(0, pads.findIndex(y => y == (x.match(/=/g) ?? []).length) || 5) + return bits.slice(0, pads.indexOf((x.match(/=/g) ?? []).length) || 5) .map(y => Math.floor(value / y) % 256); })); + // Return the decoded buffer, or a string if a character encoding is provided. return encoding ? decoded.toString(encoding) : decoded; } diff --git a/src/base64.ts b/src/base64.ts index 9c616a5..40d7fbe 100644 --- a/src/base64.ts +++ b/src/base64.ts @@ -1,8 +1,8 @@ import * as util from "./util"; -export const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -export const radix = 64; -export const regex = /[A-Za-z0-9+/]/gi; +export const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; // The base 64 character set. +export const radix = 64; // The base 64 radix. +export const regex = /[A-Za-z0-9+/]/gi; // The base 64 regex. const bits = util.quickMap(3, x => 2 ** (x * 8), true); // 65536, 256, 1 const chars = util.quickMap(4, x => 2 ** (x * 6), true); // 262144, 4096, 64, 1 @@ -10,7 +10,9 @@ const pads = util.quickMap(3, x => (4 - Math.ceil(x * 4 / 3)) % 4, false); // 0, // Encodes the given data into a Base 64 encoded string. export function encode(data: string | Buffer, encoding: BufferEncoding = "utf8") { + // The number of padding characters to add to the end of the encoded string. let padding = 0; + // For each 3 bytes of data, encode them into 4 characters. (With padding if necessary.) return Buffer.from(data.toString(encoding), encoding).reduce((a, x, i, r) => { if (i % 3 == 0) a.push(0); a[a.length - 1] += x * bits[i % 3]; @@ -18,17 +20,19 @@ export function encode(data: string | Buffer, encoding: BufferEncoding = "utf8") if ((i + 1) >= r.length) padding = pads[r.length % 3]; return a; }, [] as number[]).map((x, i, r) => - chars.slice(0, 4 - ((i + 1) >= r.length ? padding : 0)).map(y => + chars.slice(0, 4 - Number((i + 1) >= r.length) * padding).map(y => charset[Math.floor(x / y) % 64]).join("")).join("") + "=".repeat(padding); } // Decodes the given Base 64 encoded string into a buffer, or a string if a character encoding is provided. export function decode(data: string, encoding?: BufferEncoding) { + // For each 4 characters of data, decode them into 3 bytes. const decoded = Buffer.from(util.padEnd((data.toString().replaceAll("-", "+").replaceAll("_", "/").match(regex) ?? []).join(""), 4) .flatMap(x => { const value = util.stringToNumber(x, charset); - return bits.slice(0, pads.findIndex(y => y == (x.match(/=/g) ?? []).length) || 3) + return bits.slice(0, pads.indexOf((x.match(/=/g) ?? []).length) || 3) .map(y => Math.floor(value / y) % 256); })); + // Return the decoded buffer, or a string if a character encoding is provided. return encoding ? decoded.toString(encoding) : decoded; } diff --git a/src/cli.ts b/src/cli.ts deleted file mode 100644 index e46f1c5..0000000 --- a/src/cli.ts +++ /dev/null @@ -1,82 +0,0 @@ -import * as fs from "fs"; -import * as path from "path"; -import { program } from "commander"; -import * as dencodeme from "."; -import type { NumberSystem } from "."; - -type Options = { - encoding: BufferEncoding; - file: boolean; - out: string; -} - -// Get the version from the package.json file -const { version } = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8")); -// The main CLI function -export = function (argv: string[], mode: "encode" | "decode") { - const isEncode = mode.startsWith("e"); - - const descStart = `${mode[0].toUpperCase() + mode.slice(1)}s the specified input data ${isEncode ? "with" : "from"}`; - const encodingOption = program - .createOption("-e, --encoding ", `The encoding to ${isEncode ? "read" : "write"} the input data in`) - .default("utf8") - .choices(["ascii", "binary", "latin1", "ucs2", "utf8", "utf16le"]); - const fileFlag = program - .createOption("-f, --file", `Interprets the input as a file path and ${mode} the file at the path`); - const inputArgument = program - .createArgument("", `The input data to ${mode}`); - const outOption = program - .createOption("-o, --out ", `The file path to write the output data to.`); - - function actionHandler(radix: number | Exclude, input: string, options: Options) { - try { - const output = (typeof radix == "number" ? dencodeme.base(radix) : dencodeme[radix])[mode](options.file ? - fs.readFileSync(path.resolve(process.cwd(), input), isEncode ? options.encoding : "utf8") : input); - options.out ? fs.writeFileSync(path.resolve(process.cwd(), options.out), output, options.encoding) : - process.stdout.write(output.toString(options.encoding)); - } catch (err) { - program.error(String(err)); - } - } - - program.name(`${mode}me`) - .usage(`[command] [options]`) - .description(`${mode[0].toUpperCase() + mode.slice(1)} data using various encoding schemes.`) - .version(version, "-v, --version", "Outputs the current version") - .helpOption("-h, --help", "Outputs this help menu") - .addHelpCommand("help [command]", "Outputs help for command"); - - program.command("base") - .description(`${descStart} the specified base/radix`) - .usage(" [options] ") - .argument("", `The base/radix to ${mode} ${isEncode ? "with" : "from"}, clamped to range 2-36`, x => { - const parsed = parseInt(x, 10); - if (Number.isNaN(parsed)) return program.error("Base/Radix is not a valid base 10 number"); - else return parsed; - }) - .addArgument(inputArgument) - .addOption(encodingOption) - .addOption(fileFlag) - .addOption(outOption) - .alias("radix") - .action(actionHandler); - - // Create a command for each base/radix in the dencodeme object - for (const [command, base] of Object.entries(dencodeme) - .filter((x): x is [string, NumberSystem] => typeof x[1] !== "function") - .map((x): [string, number] => [x[0], x[1].radix])) { - program.command(command) - .summary(`${descStart} base ${base}`) - .description(`${descStart} a base/radix of ${base}`) - .usage("[options] ") - .addArgument(inputArgument) - .addOption(encodingOption) - .addOption(fileFlag) - .addOption(outOption) - .aliases(command.startsWith("base") ? [`b${command.slice(4)}`] : [command.slice(0, 3), `base${base}`, `b${base}`]) - .action(actionHandler.bind(null, command as Exclude)); - } - - // Parse the given arguments and run the program - program.parse(argv, { from: "user" }); -} diff --git a/test/dencodeme.test.ts b/test/dencodeme.test.ts index a6e19df..5a34497 100644 --- a/test/dencodeme.test.ts +++ b/test/dencodeme.test.ts @@ -1,4 +1,4 @@ -import assert from "assert"; +import * as assert from "assert"; import * as dencodeme from "../src"; describe("dencodeme", () => { diff --git a/tsconfig.json b/tsconfig.json index c980a16..5d9e752 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,7 +27,7 @@ /* Modules */ "module": "commonjs", /* Specify what module code is generated. */ - "rootDir": "./src", /* Specify the root folder within your source files. */ + "rootDir": "src", /* Specify the root folder within your source files. */ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ @@ -48,9 +48,9 @@ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./dist", /* Specify an output folder for all emitted files. */ + "outDir": "dist", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ @@ -61,7 +61,7 @@ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ + "newLine": "lf", /* Set the newline character for emitting files. */ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ @@ -72,7 +72,7 @@ /* Interop Constraints */ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ diff --git a/tsup.config.json b/tsup.config.json index 930cd6c..34d025d 100644 --- a/tsup.config.json +++ b/tsup.config.json @@ -1,8 +1,6 @@ { "$schema": "https://cdn.jsdelivr.net/npm/tsup/schema.json", - "entry": ["src/index.ts", "src/cli.ts"], - "external": [], - "noExternal": [], + "entry": ["src/index.ts"], "platform": "node", "format": ["esm", "cjs"], "target": "es2021", @@ -11,7 +9,5 @@ "minify": false, "splitting": false, "keepNames": true, - "dts": true, - "sourcemap": true, - "esbuildPlugins": [] + "dts": true }