├── .eslintrc.cjs ├── .github ├── dependabot.yml └── workflows │ └── push.yml ├── .gitignore ├── .hyperfine.json ├── .kodiak.toml ├── .prettierrc.cjs ├── CHANGELOG.md ├── LICENSE ├── README.md ├── SECURITY.md ├── example ├── array.ts ├── bits.ts └── simple.ts ├── package-lock.json ├── package.json ├── src ├── __benchmark__ │ ├── benchmark.array.ts │ ├── benchmark.int.ts │ └── benchmark.packet.ts ├── __tests__ │ ├── at.test.ts │ ├── buffer.test.ts │ ├── complex.object.test.ts │ ├── data.type.test.ts │ ├── flags.test.ts │ ├── int64.test.ts │ ├── lookup.test.ts │ └── parser.test.ts ├── array.ts ├── at.ts ├── base.ts ├── bits.ts ├── bitstream │ ├── __tests__ │ │ └── bitstream.test.ts │ └── index.ts ├── bytes.ts ├── hex.ts ├── index.ts ├── int.ts ├── lookup.ts ├── object.ts ├── offset.ts ├── skip.ts ├── string.ts └── type.ts └── tsconfig.json /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ...require('@linzjs/style/.eslintrc.cjs'), 3 | }; 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: docker 4 | directory: '/' 5 | schedule: 6 | interval: daily 7 | time: '17:00' 8 | open-pull-requests-limit: 10 9 | - package-ecosystem: npm 10 | directory: '/' 11 | schedule: 12 | interval: daily 13 | time: '17:00' 14 | open-pull-requests-limit: 10 15 | -------------------------------------------------------------------------------- /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | name: Build/Test 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: linz/action-typescript@v3 11 | 12 | - uses: blacha/hyperfine-action@v1 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | tsconfig.tsbuildinfo 4 | dist 5 | .cache 6 | cdk.context.json 7 | test-data -------------------------------------------------------------------------------- /.hyperfine.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"name": "Packet x 100,000", "command": "node build/src/__benchmark__/benchmark.packet.js"}, 3 | {"name": "UInt x 5,000,000", "command": "node build/src/__benchmark__/benchmark.int.js"}, 4 | {"name": "Array x 25,000", "command": "node build/src/__benchmark__/benchmark.array.js"} 5 | 6 | ] -------------------------------------------------------------------------------- /.kodiak.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [approve] 4 | auto_approve_usernames = ["dependabot"] 5 | 6 | [merge] 7 | method = "squash" 8 | automerge_label = "automerge 🚀" 9 | 10 | [merge.message] 11 | title = "pull_request_title" 12 | include_coauthors = true 13 | include_pull_request_url = true -------------------------------------------------------------------------------- /.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ...require('@linzjs/style/.prettierrc.cjs'), 3 | }; 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [2.1.0](https://github.com/blacha/binparse/compare/v2.0.1...v2.1.0) (2022-05-09) 2 | 3 | ### Bug Fixes 4 | 5 | - correctly get the size whe using the `at` type ([ed1d18a](https://github.com/blacha/binparse/commit/ed1d18a2a793c12022cd19a9f50c28c715c57dfd)) 6 | - start at the offset that was passed in not at zero ([5980e64](https://github.com/blacha/binparse/commit/5980e64bcae2061eccc9686a135329eb080069b0)) 7 | 8 | ### Features 9 | 10 | - add explicit reading option to read at locations ([7dfc70a](https://github.com/blacha/binparse/commit/7dfc70a99394b2b26bf7fcabff3baa73ddc8c7bf)) 11 | - force set the size of objects ([cba7c33](https://github.com/blacha/binparse/commit/cba7c330bf952b72749f715eb99118f429161e99)) 12 | 13 | ## [2.0.1](https://github.com/blacha/binparse/compare/v2.0.0...v2.0.1) (2021-10-27) 14 | 15 | ### Bug Fixes 16 | 17 | - make both object implementations the same ([631de17](https://github.com/blacha/binparse/commit/631de17fb905301090b4e8381975080ae6cc7f74)) 18 | - use "use strict"; to prevent function leakage ([152543b](https://github.com/blacha/binparse/commit/152543b6b5b48b7d512bc04f95d3d3ca744b85e0)) 19 | 20 | ### Features 21 | 22 | - make the two object generators more similar ([3a7bfab](https://github.com/blacha/binparse/commit/3a7bfabda814271ba3bae7379477e469468a6245)) 23 | 24 | ### Performance Improvements 25 | 26 | - rename all benchmarks to reset their stats ([7c9e590](https://github.com/blacha/binparse/commit/7c9e590a4246f3b19d9d0c741f20e5008e658993)) 27 | 28 | # [2.0.0](https://github.com/blacha/binparse/compare/v1.3.1...v2.0.0) (2021-10-25) 29 | 30 | ### Features 31 | 32 | - greatly increase the number of points required for the array benchmark ([bfee799](https://github.com/blacha/binparse/commit/bfee799f0f5be51f029fcfdf4923ad68c922abeb)) 33 | - remove variable object type lookups can now be done on the parent object ([4147f41](https://github.com/blacha/binparse/commit/4147f41c8821638383d5de334f5e148ab74d8dc4)) 34 | - support weird key names in object functions eg `"` ([fa695a5](https://github.com/blacha/binparse/commit/fa695a58eeb948df8cb9bbf06ed397abbc87089b)) 35 | 36 | ## [1.3.1](https://github.com/blacha/binparse/compare/v1.3.0...v1.3.1) (2021-10-25) 37 | 38 | ### Features 39 | 40 | - include the field names in the object ([304d933](https://github.com/blacha/binparse/commit/304d93306badac0a38e0bfba19742b6574c4fbc0)) 41 | 42 | # [1.3.0](https://github.com/blacha/binparse/compare/v1.2.1...v1.3.0) (2021-10-25) 43 | 44 | ### Features 45 | 46 | - benchmark on every push to master ([4b40a79](https://github.com/blacha/binparse/commit/4b40a79226e05cdc7eeb7d7ceb8be639037f7e70)) 47 | - generate a function for improved performance ([30d4cd7](https://github.com/blacha/binparse/commit/30d4cd7a5ea184507f3c32b044292a563bd1cb8c)) 48 | - improve continous benchmarks ([f2267c0](https://github.com/blacha/binparse/commit/f2267c0aa8b80d8003e17dd4494abefd85e0a6c1)) 49 | - only add keys to objects if they exist ([60f47ca](https://github.com/blacha/binparse/commit/60f47ca691cfa6cec70cf1256144fbe32a1f50e3)) 50 | - track performance of int ([eafa59c](https://github.com/blacha/binparse/commit/eafa59cb88a9b937be662fd0d97699a0fcaa7180)) 51 | 52 | ### Performance Improvements 53 | 54 | - minor adjustments to how ints and objects are read ([f1dc88e](https://github.com/blacha/binparse/commit/f1dc88ef547f761d229dd29b2f5943b59a7893c5)) 55 | 56 | ## [1.2.1](https://github.com/blacha/binparse/compare/v1.2.0...v1.2.1) (2021-08-29) 57 | 58 | ### Bug Fixes 59 | 60 | - export Object strut type ([4f7c7cf](https://github.com/blacha/binparse/commit/4f7c7cf8005eed8f1c8227651d0a3327cb33e604)) 61 | 62 | # [1.2.0](https://github.com/blacha/binparse/compare/v1.1.0...v1.2.0) (2021-08-28) 63 | 64 | ### Features 65 | 66 | - add .size to calculate the size of a strut ([#171](https://github.com/blacha/binparse/issues/171)) ([a4d1ab8](https://github.com/blacha/binparse/commit/a4d1ab8e50c4c22f63b0b65ada6635324c58692a)) 67 | - add support for a number and BigInt based lu64 ([#172](https://github.com/blacha/binparse/issues/172)) ([e3b9527](https://github.com/blacha/binparse/commit/e3b952752a1d99aab26ea269551fa6cd91a5f1e6)) 68 | 69 | # [1.1.0](https://github.com/blacha/binparse/compare/v1.0.1...v1.1.0) (2021-02-23) 70 | 71 | ### Features 72 | 73 | - adding refine to standard base ([4e234d3](https://github.com/blacha/binparse/commit/4e234d3bc7557178fa213a191a3094ae4d0ea392)) 74 | 75 | ## [1.0.1](https://github.com/blacha/binparse/compare/v1.0.0...v1.0.1) (2020-09-16) 76 | 77 | ### Bug Fixes 78 | 79 | - **uint32:** uint32 is now actually a uint ([de97952](https://github.com/blacha/binparse/commit/de979521a8549b782b604b73aed33998ea98967b)) 80 | 81 | # [1.0.0](https://github.com/blacha/binparse/compare/v0.3.0...v1.0.0) (2020-09-15) 82 | 83 | ### Features 84 | 85 | - reduce interface for input ([003ca23](https://github.com/blacha/binparse/commit/003ca235f60328453dccf0e9d7b744bbb46e5068)) 86 | 87 | ### BREAKING CHANGES 88 | 89 | - no longer use Buffer | number[] as the typeing for it is too broad, use a very minimal type interface 90 | 91 | # [0.3.0](https://github.com/blacha/binparse/compare/v0.2.0...v0.3.0) (2020-09-01) 92 | 93 | ### Features 94 | 95 | - adding .bool() ([e7c904a](https://github.com/blacha/binparse/commit/e7c904a9ace88a5c9596ebdba4a97850b93171df)) 96 | 97 | # [0.2.0](https://github.com/blacha/binparse/compare/v0.1.0...v0.2.0) (2020-08-29) 98 | 99 | ### Features 100 | 101 | - improve typing of bp.lookup and bp.enum ([6a964de](https://github.com/blacha/binparse/commit/6a964de518282933f61de1f24d524c3d27d20f68)) 102 | - **bitstream:** bitstream string reader ([3b6b13f](https://github.com/blacha/binparse/commit/3b6b13f132b751436ef39a37a9deb4cc75347d22)) 103 | 104 | # 0.1.0 (2020-08-29) 105 | 106 | ### Features 107 | 108 | - adding bit flag strut type ([78cfdd5](https://github.com/blacha/binparse/commit/78cfdd57faebec48de4ea1550c322c716c221cdd)) 109 | - initial commit ([275afb4](https://github.com/blacha/binparse/commit/275afb4f2abc34953f3fb768738583e32f0fa1b8)) 110 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Blayne Chard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # binparse 2 | 3 | Typed binary object parser 4 | 5 | ```typescript 6 | import { bp } from 'binparse'; 7 | 8 | const simpleParser = bp.object('SimpleObject', { 9 | id: bp.lu16, 10 | x: bp.u8, 11 | y: bp.u8, 12 | }); 13 | 14 | const { value, offset } = simpleParser.read([0x01, 0x00, 0x01, 0x02]); 15 | 16 | /** byte offset of where the reader finished */ 17 | offset; // 3 18 | 19 | /** Parsed object */ 20 | value.id; // 0x01 21 | value.x; // 0x01; 22 | value.y; // 0x02 23 | 24 | value.unk1; // Typescript error 25 | ``` 26 | 27 | Heavily inspired by [zod](https://github.com/vriad/zod) 28 | 29 | ## Arrays 30 | 31 | Read in a variable length array of points 32 | 33 | Load the length in as a variable which can be referenced by the array parser for the length 34 | 35 | ```typescript 36 | import { bp } from 'binparse'; 37 | 38 | const PointParser = bp.object('Point', { 39 | /** X Offset */ 40 | x: bp.lu16, 41 | /** Y Offset */ 42 | y: bp.lu16, 43 | }); 44 | 45 | const PointsParser = bp.object('SimpleObject', { 46 | // Number of points to read 47 | length: bp.variable('len', bp.u8), 48 | // Array of points with length "len" 49 | points: bp.array('Points', PointParser, 'len'), 50 | }); 51 | 52 | const points = PointsParser.read([0x01, 0x01, 0x00, 0x02, 0x00]); 53 | ``` 54 | 55 | ## BitFlags 56 | 57 | ```typescript 58 | import { bp } from 'binparse'; 59 | 60 | const FlagParser = bp.bits('Flags', { 61 | isRed: 1, 62 | isGreen: 1, 63 | isBlue: 1, 64 | isAlpha: 1, 65 | }); 66 | 67 | const { value } = FlagParser.read([0b0101]); 68 | 69 | value.isRed; // true 70 | value.isGreen; // false 71 | value.isBlue; // true 72 | value.isAlpha; // false 73 | ``` 74 | 75 | ## Explicit offsets 76 | 77 | ```typescript 78 | import { bp } from 'binparse'; 79 | 80 | const sparseParser = bp.object('Sparse', { 81 | first: bp.at(0x30, bp.lu32), // Read a lu32 at 0x30 82 | second: bp.at(0x60, bp.lu32), // Read a lu32 at 0x60 83 | }); 84 | sparseParser.size; // 0x64 85 | ``` 86 | 87 | ## Performance 88 | 89 | Continuos performance monitoring is done using [hyperfine](https://github.com/sharkdp/hyperfine) and [hyperfine-action](https://github.com/blacha/hyperfine-action) 90 | 91 | Results can be found at [benchmarks.html](https://blacha.github.io/binparse/benchmarks.html) 92 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report (suspected) security vulnerabilities to **[security@chard.com](mailto:security@chard.com)**. 6 | You should receive a response from us within 48 hours. 7 | -------------------------------------------------------------------------------- /example/array.ts: -------------------------------------------------------------------------------- 1 | import { bp } from '../src/index.js'; 2 | 3 | const PointParser = bp.object('Point', { 4 | /** X Offset */ 5 | x: bp.lu16, 6 | /** Y Offset */ 7 | y: bp.lu16, 8 | }); 9 | 10 | const PointsParser = bp.object('SimpleObject', { 11 | length: bp.u8, 12 | // Array of points with length "len" 13 | points: bp.array('Points', PointParser, 'length', false), 14 | }); 15 | 16 | const points = PointsParser.read([0x01, 0x01, 0x00, 0x02, 0x00]); 17 | 18 | points.value.length; // 1 19 | points.value.points[0]; // { x: 1, y: 2 } 20 | points.value.points[0]?.x; // 1 21 | points.value.points[0]?.y; // 2 22 | -------------------------------------------------------------------------------- /example/bits.ts: -------------------------------------------------------------------------------- 1 | import { bp } from '../src/index.js'; 2 | 3 | const FlagParser = bp.bits('Flags', { 4 | isRed: 1, 5 | isGreen: 1, 6 | isBlue: 1, 7 | isAlpha: 1, 8 | }); 9 | 10 | const { value } = FlagParser.read([0b0101]); 11 | 12 | value.isRed; // true 13 | value.isGreen; // false 14 | value.isBlue; // true 15 | value.isAlpha; // false 16 | -------------------------------------------------------------------------------- /example/simple.ts: -------------------------------------------------------------------------------- 1 | import { bp } from '../src/index.js'; 2 | 3 | const simpleParser = bp.object('SimpleObject', { 4 | id: bp.lu16, 5 | x: bp.u8, 6 | y: bp.u8, 7 | }); 8 | 9 | const { value, offset } = simpleParser.read([0x01, 0x00, 0x01, 0x02]); 10 | 11 | /** byte offset of where the reader finished */ 12 | offset; // 3 13 | 14 | /** Parsed object */ 15 | value.id; // 0x01 16 | value.x; // 0x01; 17 | value.y; // 0x02 18 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "binparse", 3 | "version": "2.1.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "binparse", 9 | "version": "2.1.0", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "@linzjs/style": "^4.0.0", 13 | "@types/node": "^18.11.9" 14 | }, 15 | "engines": { 16 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 17 | } 18 | }, 19 | "node_modules/@eslint-community/eslint-utils": { 20 | "version": "4.4.0", 21 | "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", 22 | "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", 23 | "dev": true, 24 | "dependencies": { 25 | "eslint-visitor-keys": "^3.3.0" 26 | }, 27 | "engines": { 28 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 29 | }, 30 | "peerDependencies": { 31 | "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" 32 | } 33 | }, 34 | "node_modules/@eslint-community/regexpp": { 35 | "version": "4.5.1", 36 | "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz", 37 | "integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==", 38 | "dev": true, 39 | "engines": { 40 | "node": "^12.0.0 || ^14.0.0 || >=16.0.0" 41 | } 42 | }, 43 | "node_modules/@eslint/eslintrc": { 44 | "version": "2.0.3", 45 | "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", 46 | "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", 47 | "dev": true, 48 | "dependencies": { 49 | "ajv": "^6.12.4", 50 | "debug": "^4.3.2", 51 | "espree": "^9.5.2", 52 | "globals": "^13.19.0", 53 | "ignore": "^5.2.0", 54 | "import-fresh": "^3.2.1", 55 | "js-yaml": "^4.1.0", 56 | "minimatch": "^3.1.2", 57 | "strip-json-comments": "^3.1.1" 58 | }, 59 | "engines": { 60 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 61 | }, 62 | "funding": { 63 | "url": "https://opencollective.com/eslint" 64 | } 65 | }, 66 | "node_modules/@eslint/js": { 67 | "version": "8.41.0", 68 | "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.41.0.tgz", 69 | "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", 70 | "dev": true, 71 | "engines": { 72 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 73 | } 74 | }, 75 | "node_modules/@humanwhocodes/config-array": { 76 | "version": "0.11.8", 77 | "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", 78 | "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", 79 | "dev": true, 80 | "dependencies": { 81 | "@humanwhocodes/object-schema": "^1.2.1", 82 | "debug": "^4.1.1", 83 | "minimatch": "^3.0.5" 84 | }, 85 | "engines": { 86 | "node": ">=10.10.0" 87 | } 88 | }, 89 | "node_modules/@humanwhocodes/module-importer": { 90 | "version": "1.0.1", 91 | "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", 92 | "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", 93 | "dev": true, 94 | "engines": { 95 | "node": ">=12.22" 96 | }, 97 | "funding": { 98 | "type": "github", 99 | "url": "https://github.com/sponsors/nzakas" 100 | } 101 | }, 102 | "node_modules/@humanwhocodes/object-schema": { 103 | "version": "1.2.1", 104 | "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", 105 | "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", 106 | "dev": true 107 | }, 108 | "node_modules/@linzjs/style": { 109 | "version": "4.0.0", 110 | "resolved": "https://registry.npmjs.org/@linzjs/style/-/style-4.0.0.tgz", 111 | "integrity": "sha512-dtiXRbn2rqqwgspEq+oABwrZqT3DAKp/cP29PnFoMH0elHZBg2rR0lClLnh0ioWFheOA8DhdEP+erNXOqSaghA==", 112 | "dev": true, 113 | "dependencies": { 114 | "@typescript-eslint/eslint-plugin": "^5.57.0", 115 | "@typescript-eslint/parser": "^5.57.0", 116 | "eslint": "^8.39.0", 117 | "eslint-config-prettier": "^8.8.0", 118 | "eslint-plugin-prettier": "^4.2.1", 119 | "prettier": "^2.8.7", 120 | "typescript": "^5.0.4" 121 | }, 122 | "bin": { 123 | "linz-style-install": "linz-style-install.mjs" 124 | } 125 | }, 126 | "node_modules/@nodelib/fs.scandir": { 127 | "version": "2.1.5", 128 | "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", 129 | "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", 130 | "dev": true, 131 | "dependencies": { 132 | "@nodelib/fs.stat": "2.0.5", 133 | "run-parallel": "^1.1.9" 134 | }, 135 | "engines": { 136 | "node": ">= 8" 137 | } 138 | }, 139 | "node_modules/@nodelib/fs.stat": { 140 | "version": "2.0.5", 141 | "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", 142 | "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", 143 | "dev": true, 144 | "engines": { 145 | "node": ">= 8" 146 | } 147 | }, 148 | "node_modules/@nodelib/fs.walk": { 149 | "version": "1.2.8", 150 | "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", 151 | "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", 152 | "dev": true, 153 | "dependencies": { 154 | "@nodelib/fs.scandir": "2.1.5", 155 | "fastq": "^1.6.0" 156 | }, 157 | "engines": { 158 | "node": ">= 8" 159 | } 160 | }, 161 | "node_modules/@types/json-schema": { 162 | "version": "7.0.12", 163 | "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", 164 | "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", 165 | "dev": true 166 | }, 167 | "node_modules/@types/node": { 168 | "version": "18.16.16", 169 | "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.16.tgz", 170 | "integrity": "sha512-NpaM49IGQQAUlBhHMF82QH80J08os4ZmyF9MkpCzWAGuOHqE4gTEbhzd7L3l5LmWuZ6E0OiC1FweQ4tsiW35+g==", 171 | "dev": true 172 | }, 173 | "node_modules/@types/semver": { 174 | "version": "7.5.0", 175 | "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", 176 | "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", 177 | "dev": true 178 | }, 179 | "node_modules/@typescript-eslint/eslint-plugin": { 180 | "version": "5.59.8", 181 | "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz", 182 | "integrity": "sha512-JDMOmhXteJ4WVKOiHXGCoB96ADWg9q7efPWHRViT/f09bA8XOMLAVHHju3l0MkZnG1izaWXYmgvQcUjTRcpShQ==", 183 | "dev": true, 184 | "dependencies": { 185 | "@eslint-community/regexpp": "^4.4.0", 186 | "@typescript-eslint/scope-manager": "5.59.8", 187 | "@typescript-eslint/type-utils": "5.59.8", 188 | "@typescript-eslint/utils": "5.59.8", 189 | "debug": "^4.3.4", 190 | "grapheme-splitter": "^1.0.4", 191 | "ignore": "^5.2.0", 192 | "natural-compare-lite": "^1.4.0", 193 | "semver": "^7.3.7", 194 | "tsutils": "^3.21.0" 195 | }, 196 | "engines": { 197 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 198 | }, 199 | "funding": { 200 | "type": "opencollective", 201 | "url": "https://opencollective.com/typescript-eslint" 202 | }, 203 | "peerDependencies": { 204 | "@typescript-eslint/parser": "^5.0.0", 205 | "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" 206 | }, 207 | "peerDependenciesMeta": { 208 | "typescript": { 209 | "optional": true 210 | } 211 | } 212 | }, 213 | "node_modules/@typescript-eslint/parser": { 214 | "version": "5.59.8", 215 | "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.8.tgz", 216 | "integrity": "sha512-AnR19RjJcpjoeGojmwZtCwBX/RidqDZtzcbG3xHrmz0aHHoOcbWnpDllenRDmDvsV0RQ6+tbb09/kyc+UT9Orw==", 217 | "dev": true, 218 | "dependencies": { 219 | "@typescript-eslint/scope-manager": "5.59.8", 220 | "@typescript-eslint/types": "5.59.8", 221 | "@typescript-eslint/typescript-estree": "5.59.8", 222 | "debug": "^4.3.4" 223 | }, 224 | "engines": { 225 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 226 | }, 227 | "funding": { 228 | "type": "opencollective", 229 | "url": "https://opencollective.com/typescript-eslint" 230 | }, 231 | "peerDependencies": { 232 | "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" 233 | }, 234 | "peerDependenciesMeta": { 235 | "typescript": { 236 | "optional": true 237 | } 238 | } 239 | }, 240 | "node_modules/@typescript-eslint/scope-manager": { 241 | "version": "5.59.8", 242 | "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.8.tgz", 243 | "integrity": "sha512-/w08ndCYI8gxGf+9zKf1vtx/16y8MHrZs5/tnjHhMLNSixuNcJavSX4wAiPf4aS5x41Es9YPCn44MIe4cxIlig==", 244 | "dev": true, 245 | "dependencies": { 246 | "@typescript-eslint/types": "5.59.8", 247 | "@typescript-eslint/visitor-keys": "5.59.8" 248 | }, 249 | "engines": { 250 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 251 | }, 252 | "funding": { 253 | "type": "opencollective", 254 | "url": "https://opencollective.com/typescript-eslint" 255 | } 256 | }, 257 | "node_modules/@typescript-eslint/type-utils": { 258 | "version": "5.59.8", 259 | "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.8.tgz", 260 | "integrity": "sha512-+5M518uEIHFBy3FnyqZUF3BMP+AXnYn4oyH8RF012+e7/msMY98FhGL5SrN29NQ9xDgvqCgYnsOiKp1VjZ/fpA==", 261 | "dev": true, 262 | "dependencies": { 263 | "@typescript-eslint/typescript-estree": "5.59.8", 264 | "@typescript-eslint/utils": "5.59.8", 265 | "debug": "^4.3.4", 266 | "tsutils": "^3.21.0" 267 | }, 268 | "engines": { 269 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 270 | }, 271 | "funding": { 272 | "type": "opencollective", 273 | "url": "https://opencollective.com/typescript-eslint" 274 | }, 275 | "peerDependencies": { 276 | "eslint": "*" 277 | }, 278 | "peerDependenciesMeta": { 279 | "typescript": { 280 | "optional": true 281 | } 282 | } 283 | }, 284 | "node_modules/@typescript-eslint/types": { 285 | "version": "5.59.8", 286 | "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.8.tgz", 287 | "integrity": "sha512-+uWuOhBTj/L6awoWIg0BlWy0u9TyFpCHrAuQ5bNfxDaZ1Ppb3mx6tUigc74LHcbHpOHuOTOJrBoAnhdHdaea1w==", 288 | "dev": true, 289 | "engines": { 290 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 291 | }, 292 | "funding": { 293 | "type": "opencollective", 294 | "url": "https://opencollective.com/typescript-eslint" 295 | } 296 | }, 297 | "node_modules/@typescript-eslint/typescript-estree": { 298 | "version": "5.59.8", 299 | "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.8.tgz", 300 | "integrity": "sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==", 301 | "dev": true, 302 | "dependencies": { 303 | "@typescript-eslint/types": "5.59.8", 304 | "@typescript-eslint/visitor-keys": "5.59.8", 305 | "debug": "^4.3.4", 306 | "globby": "^11.1.0", 307 | "is-glob": "^4.0.3", 308 | "semver": "^7.3.7", 309 | "tsutils": "^3.21.0" 310 | }, 311 | "engines": { 312 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 313 | }, 314 | "funding": { 315 | "type": "opencollective", 316 | "url": "https://opencollective.com/typescript-eslint" 317 | }, 318 | "peerDependenciesMeta": { 319 | "typescript": { 320 | "optional": true 321 | } 322 | } 323 | }, 324 | "node_modules/@typescript-eslint/utils": { 325 | "version": "5.59.8", 326 | "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz", 327 | "integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==", 328 | "dev": true, 329 | "dependencies": { 330 | "@eslint-community/eslint-utils": "^4.2.0", 331 | "@types/json-schema": "^7.0.9", 332 | "@types/semver": "^7.3.12", 333 | "@typescript-eslint/scope-manager": "5.59.8", 334 | "@typescript-eslint/types": "5.59.8", 335 | "@typescript-eslint/typescript-estree": "5.59.8", 336 | "eslint-scope": "^5.1.1", 337 | "semver": "^7.3.7" 338 | }, 339 | "engines": { 340 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 341 | }, 342 | "funding": { 343 | "type": "opencollective", 344 | "url": "https://opencollective.com/typescript-eslint" 345 | }, 346 | "peerDependencies": { 347 | "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" 348 | } 349 | }, 350 | "node_modules/@typescript-eslint/visitor-keys": { 351 | "version": "5.59.8", 352 | "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.8.tgz", 353 | "integrity": "sha512-pJhi2ms0x0xgloT7xYabil3SGGlojNNKjK/q6dB3Ey0uJLMjK2UDGJvHieiyJVW/7C3KI+Z4Q3pEHkm4ejA+xQ==", 354 | "dev": true, 355 | "dependencies": { 356 | "@typescript-eslint/types": "5.59.8", 357 | "eslint-visitor-keys": "^3.3.0" 358 | }, 359 | "engines": { 360 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 361 | }, 362 | "funding": { 363 | "type": "opencollective", 364 | "url": "https://opencollective.com/typescript-eslint" 365 | } 366 | }, 367 | "node_modules/acorn": { 368 | "version": "8.8.2", 369 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", 370 | "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", 371 | "dev": true, 372 | "bin": { 373 | "acorn": "bin/acorn" 374 | }, 375 | "engines": { 376 | "node": ">=0.4.0" 377 | } 378 | }, 379 | "node_modules/acorn-jsx": { 380 | "version": "5.3.2", 381 | "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", 382 | "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", 383 | "dev": true, 384 | "peerDependencies": { 385 | "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" 386 | } 387 | }, 388 | "node_modules/ajv": { 389 | "version": "6.12.6", 390 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", 391 | "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", 392 | "dev": true, 393 | "dependencies": { 394 | "fast-deep-equal": "^3.1.1", 395 | "fast-json-stable-stringify": "^2.0.0", 396 | "json-schema-traverse": "^0.4.1", 397 | "uri-js": "^4.2.2" 398 | }, 399 | "funding": { 400 | "type": "github", 401 | "url": "https://github.com/sponsors/epoberezkin" 402 | } 403 | }, 404 | "node_modules/ansi-regex": { 405 | "version": "5.0.1", 406 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", 407 | "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", 408 | "dev": true, 409 | "engines": { 410 | "node": ">=8" 411 | } 412 | }, 413 | "node_modules/ansi-styles": { 414 | "version": "4.3.0", 415 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", 416 | "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", 417 | "dev": true, 418 | "dependencies": { 419 | "color-convert": "^2.0.1" 420 | }, 421 | "engines": { 422 | "node": ">=8" 423 | }, 424 | "funding": { 425 | "url": "https://github.com/chalk/ansi-styles?sponsor=1" 426 | } 427 | }, 428 | "node_modules/argparse": { 429 | "version": "2.0.1", 430 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 431 | "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", 432 | "dev": true 433 | }, 434 | "node_modules/array-union": { 435 | "version": "2.1.0", 436 | "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", 437 | "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", 438 | "dev": true, 439 | "engines": { 440 | "node": ">=8" 441 | } 442 | }, 443 | "node_modules/balanced-match": { 444 | "version": "1.0.2", 445 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 446 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", 447 | "dev": true 448 | }, 449 | "node_modules/brace-expansion": { 450 | "version": "1.1.11", 451 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 452 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 453 | "dev": true, 454 | "dependencies": { 455 | "balanced-match": "^1.0.0", 456 | "concat-map": "0.0.1" 457 | } 458 | }, 459 | "node_modules/braces": { 460 | "version": "3.0.2", 461 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 462 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 463 | "dev": true, 464 | "dependencies": { 465 | "fill-range": "^7.0.1" 466 | }, 467 | "engines": { 468 | "node": ">=8" 469 | } 470 | }, 471 | "node_modules/callsites": { 472 | "version": "3.1.0", 473 | "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", 474 | "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", 475 | "dev": true, 476 | "engines": { 477 | "node": ">=6" 478 | } 479 | }, 480 | "node_modules/chalk": { 481 | "version": "4.1.2", 482 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", 483 | "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", 484 | "dev": true, 485 | "dependencies": { 486 | "ansi-styles": "^4.1.0", 487 | "supports-color": "^7.1.0" 488 | }, 489 | "engines": { 490 | "node": ">=10" 491 | }, 492 | "funding": { 493 | "url": "https://github.com/chalk/chalk?sponsor=1" 494 | } 495 | }, 496 | "node_modules/color-convert": { 497 | "version": "2.0.1", 498 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", 499 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", 500 | "dev": true, 501 | "dependencies": { 502 | "color-name": "~1.1.4" 503 | }, 504 | "engines": { 505 | "node": ">=7.0.0" 506 | } 507 | }, 508 | "node_modules/color-name": { 509 | "version": "1.1.4", 510 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", 511 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", 512 | "dev": true 513 | }, 514 | "node_modules/concat-map": { 515 | "version": "0.0.1", 516 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 517 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", 518 | "dev": true 519 | }, 520 | "node_modules/cross-spawn": { 521 | "version": "7.0.3", 522 | "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", 523 | "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", 524 | "dev": true, 525 | "dependencies": { 526 | "path-key": "^3.1.0", 527 | "shebang-command": "^2.0.0", 528 | "which": "^2.0.1" 529 | }, 530 | "engines": { 531 | "node": ">= 8" 532 | } 533 | }, 534 | "node_modules/debug": { 535 | "version": "4.3.4", 536 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 537 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 538 | "dev": true, 539 | "dependencies": { 540 | "ms": "2.1.2" 541 | }, 542 | "engines": { 543 | "node": ">=6.0" 544 | }, 545 | "peerDependenciesMeta": { 546 | "supports-color": { 547 | "optional": true 548 | } 549 | } 550 | }, 551 | "node_modules/deep-is": { 552 | "version": "0.1.4", 553 | "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", 554 | "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", 555 | "dev": true 556 | }, 557 | "node_modules/dir-glob": { 558 | "version": "3.0.1", 559 | "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", 560 | "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", 561 | "dev": true, 562 | "dependencies": { 563 | "path-type": "^4.0.0" 564 | }, 565 | "engines": { 566 | "node": ">=8" 567 | } 568 | }, 569 | "node_modules/doctrine": { 570 | "version": "3.0.0", 571 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", 572 | "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", 573 | "dev": true, 574 | "dependencies": { 575 | "esutils": "^2.0.2" 576 | }, 577 | "engines": { 578 | "node": ">=6.0.0" 579 | } 580 | }, 581 | "node_modules/escape-string-regexp": { 582 | "version": "4.0.0", 583 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", 584 | "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", 585 | "dev": true, 586 | "engines": { 587 | "node": ">=10" 588 | }, 589 | "funding": { 590 | "url": "https://github.com/sponsors/sindresorhus" 591 | } 592 | }, 593 | "node_modules/eslint": { 594 | "version": "8.41.0", 595 | "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.41.0.tgz", 596 | "integrity": "sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q==", 597 | "dev": true, 598 | "dependencies": { 599 | "@eslint-community/eslint-utils": "^4.2.0", 600 | "@eslint-community/regexpp": "^4.4.0", 601 | "@eslint/eslintrc": "^2.0.3", 602 | "@eslint/js": "8.41.0", 603 | "@humanwhocodes/config-array": "^0.11.8", 604 | "@humanwhocodes/module-importer": "^1.0.1", 605 | "@nodelib/fs.walk": "^1.2.8", 606 | "ajv": "^6.10.0", 607 | "chalk": "^4.0.0", 608 | "cross-spawn": "^7.0.2", 609 | "debug": "^4.3.2", 610 | "doctrine": "^3.0.0", 611 | "escape-string-regexp": "^4.0.0", 612 | "eslint-scope": "^7.2.0", 613 | "eslint-visitor-keys": "^3.4.1", 614 | "espree": "^9.5.2", 615 | "esquery": "^1.4.2", 616 | "esutils": "^2.0.2", 617 | "fast-deep-equal": "^3.1.3", 618 | "file-entry-cache": "^6.0.1", 619 | "find-up": "^5.0.0", 620 | "glob-parent": "^6.0.2", 621 | "globals": "^13.19.0", 622 | "graphemer": "^1.4.0", 623 | "ignore": "^5.2.0", 624 | "import-fresh": "^3.0.0", 625 | "imurmurhash": "^0.1.4", 626 | "is-glob": "^4.0.0", 627 | "is-path-inside": "^3.0.3", 628 | "js-yaml": "^4.1.0", 629 | "json-stable-stringify-without-jsonify": "^1.0.1", 630 | "levn": "^0.4.1", 631 | "lodash.merge": "^4.6.2", 632 | "minimatch": "^3.1.2", 633 | "natural-compare": "^1.4.0", 634 | "optionator": "^0.9.1", 635 | "strip-ansi": "^6.0.1", 636 | "strip-json-comments": "^3.1.0", 637 | "text-table": "^0.2.0" 638 | }, 639 | "bin": { 640 | "eslint": "bin/eslint.js" 641 | }, 642 | "engines": { 643 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 644 | }, 645 | "funding": { 646 | "url": "https://opencollective.com/eslint" 647 | } 648 | }, 649 | "node_modules/eslint-config-prettier": { 650 | "version": "8.8.0", 651 | "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz", 652 | "integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==", 653 | "dev": true, 654 | "bin": { 655 | "eslint-config-prettier": "bin/cli.js" 656 | }, 657 | "peerDependencies": { 658 | "eslint": ">=7.0.0" 659 | } 660 | }, 661 | "node_modules/eslint-plugin-prettier": { 662 | "version": "4.2.1", 663 | "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz", 664 | "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==", 665 | "dev": true, 666 | "dependencies": { 667 | "prettier-linter-helpers": "^1.0.0" 668 | }, 669 | "engines": { 670 | "node": ">=12.0.0" 671 | }, 672 | "peerDependencies": { 673 | "eslint": ">=7.28.0", 674 | "prettier": ">=2.0.0" 675 | }, 676 | "peerDependenciesMeta": { 677 | "eslint-config-prettier": { 678 | "optional": true 679 | } 680 | } 681 | }, 682 | "node_modules/eslint-scope": { 683 | "version": "5.1.1", 684 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", 685 | "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", 686 | "dev": true, 687 | "dependencies": { 688 | "esrecurse": "^4.3.0", 689 | "estraverse": "^4.1.1" 690 | }, 691 | "engines": { 692 | "node": ">=8.0.0" 693 | } 694 | }, 695 | "node_modules/eslint-visitor-keys": { 696 | "version": "3.4.1", 697 | "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", 698 | "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", 699 | "dev": true, 700 | "engines": { 701 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 702 | }, 703 | "funding": { 704 | "url": "https://opencollective.com/eslint" 705 | } 706 | }, 707 | "node_modules/eslint/node_modules/eslint-scope": { 708 | "version": "7.2.0", 709 | "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", 710 | "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", 711 | "dev": true, 712 | "dependencies": { 713 | "esrecurse": "^4.3.0", 714 | "estraverse": "^5.2.0" 715 | }, 716 | "engines": { 717 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 718 | }, 719 | "funding": { 720 | "url": "https://opencollective.com/eslint" 721 | } 722 | }, 723 | "node_modules/eslint/node_modules/estraverse": { 724 | "version": "5.3.0", 725 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", 726 | "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", 727 | "dev": true, 728 | "engines": { 729 | "node": ">=4.0" 730 | } 731 | }, 732 | "node_modules/espree": { 733 | "version": "9.5.2", 734 | "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", 735 | "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", 736 | "dev": true, 737 | "dependencies": { 738 | "acorn": "^8.8.0", 739 | "acorn-jsx": "^5.3.2", 740 | "eslint-visitor-keys": "^3.4.1" 741 | }, 742 | "engines": { 743 | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" 744 | }, 745 | "funding": { 746 | "url": "https://opencollective.com/eslint" 747 | } 748 | }, 749 | "node_modules/esquery": { 750 | "version": "1.5.0", 751 | "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", 752 | "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", 753 | "dev": true, 754 | "dependencies": { 755 | "estraverse": "^5.1.0" 756 | }, 757 | "engines": { 758 | "node": ">=0.10" 759 | } 760 | }, 761 | "node_modules/esquery/node_modules/estraverse": { 762 | "version": "5.3.0", 763 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", 764 | "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", 765 | "dev": true, 766 | "engines": { 767 | "node": ">=4.0" 768 | } 769 | }, 770 | "node_modules/esrecurse": { 771 | "version": "4.3.0", 772 | "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", 773 | "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", 774 | "dev": true, 775 | "dependencies": { 776 | "estraverse": "^5.2.0" 777 | }, 778 | "engines": { 779 | "node": ">=4.0" 780 | } 781 | }, 782 | "node_modules/esrecurse/node_modules/estraverse": { 783 | "version": "5.3.0", 784 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", 785 | "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", 786 | "dev": true, 787 | "engines": { 788 | "node": ">=4.0" 789 | } 790 | }, 791 | "node_modules/estraverse": { 792 | "version": "4.3.0", 793 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", 794 | "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", 795 | "dev": true, 796 | "engines": { 797 | "node": ">=4.0" 798 | } 799 | }, 800 | "node_modules/esutils": { 801 | "version": "2.0.3", 802 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", 803 | "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", 804 | "dev": true, 805 | "engines": { 806 | "node": ">=0.10.0" 807 | } 808 | }, 809 | "node_modules/fast-deep-equal": { 810 | "version": "3.1.3", 811 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", 812 | "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", 813 | "dev": true 814 | }, 815 | "node_modules/fast-diff": { 816 | "version": "1.3.0", 817 | "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", 818 | "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", 819 | "dev": true 820 | }, 821 | "node_modules/fast-glob": { 822 | "version": "3.2.12", 823 | "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", 824 | "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", 825 | "dev": true, 826 | "dependencies": { 827 | "@nodelib/fs.stat": "^2.0.2", 828 | "@nodelib/fs.walk": "^1.2.3", 829 | "glob-parent": "^5.1.2", 830 | "merge2": "^1.3.0", 831 | "micromatch": "^4.0.4" 832 | }, 833 | "engines": { 834 | "node": ">=8.6.0" 835 | } 836 | }, 837 | "node_modules/fast-glob/node_modules/glob-parent": { 838 | "version": "5.1.2", 839 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 840 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 841 | "dev": true, 842 | "dependencies": { 843 | "is-glob": "^4.0.1" 844 | }, 845 | "engines": { 846 | "node": ">= 6" 847 | } 848 | }, 849 | "node_modules/fast-json-stable-stringify": { 850 | "version": "2.1.0", 851 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", 852 | "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", 853 | "dev": true 854 | }, 855 | "node_modules/fast-levenshtein": { 856 | "version": "2.0.6", 857 | "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", 858 | "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", 859 | "dev": true 860 | }, 861 | "node_modules/fastq": { 862 | "version": "1.15.0", 863 | "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", 864 | "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", 865 | "dev": true, 866 | "dependencies": { 867 | "reusify": "^1.0.4" 868 | } 869 | }, 870 | "node_modules/file-entry-cache": { 871 | "version": "6.0.1", 872 | "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", 873 | "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", 874 | "dev": true, 875 | "dependencies": { 876 | "flat-cache": "^3.0.4" 877 | }, 878 | "engines": { 879 | "node": "^10.12.0 || >=12.0.0" 880 | } 881 | }, 882 | "node_modules/fill-range": { 883 | "version": "7.0.1", 884 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 885 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 886 | "dev": true, 887 | "dependencies": { 888 | "to-regex-range": "^5.0.1" 889 | }, 890 | "engines": { 891 | "node": ">=8" 892 | } 893 | }, 894 | "node_modules/find-up": { 895 | "version": "5.0.0", 896 | "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", 897 | "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", 898 | "dev": true, 899 | "dependencies": { 900 | "locate-path": "^6.0.0", 901 | "path-exists": "^4.0.0" 902 | }, 903 | "engines": { 904 | "node": ">=10" 905 | }, 906 | "funding": { 907 | "url": "https://github.com/sponsors/sindresorhus" 908 | } 909 | }, 910 | "node_modules/flat-cache": { 911 | "version": "3.0.4", 912 | "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", 913 | "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", 914 | "dev": true, 915 | "dependencies": { 916 | "flatted": "^3.1.0", 917 | "rimraf": "^3.0.2" 918 | }, 919 | "engines": { 920 | "node": "^10.12.0 || >=12.0.0" 921 | } 922 | }, 923 | "node_modules/flatted": { 924 | "version": "3.2.7", 925 | "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", 926 | "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", 927 | "dev": true 928 | }, 929 | "node_modules/fs.realpath": { 930 | "version": "1.0.0", 931 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 932 | "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", 933 | "dev": true 934 | }, 935 | "node_modules/glob": { 936 | "version": "7.2.3", 937 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", 938 | "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", 939 | "dev": true, 940 | "dependencies": { 941 | "fs.realpath": "^1.0.0", 942 | "inflight": "^1.0.4", 943 | "inherits": "2", 944 | "minimatch": "^3.1.1", 945 | "once": "^1.3.0", 946 | "path-is-absolute": "^1.0.0" 947 | }, 948 | "engines": { 949 | "node": "*" 950 | }, 951 | "funding": { 952 | "url": "https://github.com/sponsors/isaacs" 953 | } 954 | }, 955 | "node_modules/glob-parent": { 956 | "version": "6.0.2", 957 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", 958 | "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", 959 | "dev": true, 960 | "dependencies": { 961 | "is-glob": "^4.0.3" 962 | }, 963 | "engines": { 964 | "node": ">=10.13.0" 965 | } 966 | }, 967 | "node_modules/globals": { 968 | "version": "13.20.0", 969 | "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", 970 | "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", 971 | "dev": true, 972 | "dependencies": { 973 | "type-fest": "^0.20.2" 974 | }, 975 | "engines": { 976 | "node": ">=8" 977 | }, 978 | "funding": { 979 | "url": "https://github.com/sponsors/sindresorhus" 980 | } 981 | }, 982 | "node_modules/globby": { 983 | "version": "11.1.0", 984 | "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", 985 | "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", 986 | "dev": true, 987 | "dependencies": { 988 | "array-union": "^2.1.0", 989 | "dir-glob": "^3.0.1", 990 | "fast-glob": "^3.2.9", 991 | "ignore": "^5.2.0", 992 | "merge2": "^1.4.1", 993 | "slash": "^3.0.0" 994 | }, 995 | "engines": { 996 | "node": ">=10" 997 | }, 998 | "funding": { 999 | "url": "https://github.com/sponsors/sindresorhus" 1000 | } 1001 | }, 1002 | "node_modules/grapheme-splitter": { 1003 | "version": "1.0.4", 1004 | "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", 1005 | "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", 1006 | "dev": true 1007 | }, 1008 | "node_modules/graphemer": { 1009 | "version": "1.4.0", 1010 | "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", 1011 | "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", 1012 | "dev": true 1013 | }, 1014 | "node_modules/has-flag": { 1015 | "version": "4.0.0", 1016 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", 1017 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", 1018 | "dev": true, 1019 | "engines": { 1020 | "node": ">=8" 1021 | } 1022 | }, 1023 | "node_modules/ignore": { 1024 | "version": "5.2.4", 1025 | "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", 1026 | "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", 1027 | "dev": true, 1028 | "engines": { 1029 | "node": ">= 4" 1030 | } 1031 | }, 1032 | "node_modules/import-fresh": { 1033 | "version": "3.3.0", 1034 | "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", 1035 | "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", 1036 | "dev": true, 1037 | "dependencies": { 1038 | "parent-module": "^1.0.0", 1039 | "resolve-from": "^4.0.0" 1040 | }, 1041 | "engines": { 1042 | "node": ">=6" 1043 | }, 1044 | "funding": { 1045 | "url": "https://github.com/sponsors/sindresorhus" 1046 | } 1047 | }, 1048 | "node_modules/imurmurhash": { 1049 | "version": "0.1.4", 1050 | "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", 1051 | "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", 1052 | "dev": true, 1053 | "engines": { 1054 | "node": ">=0.8.19" 1055 | } 1056 | }, 1057 | "node_modules/inflight": { 1058 | "version": "1.0.6", 1059 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 1060 | "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", 1061 | "dev": true, 1062 | "dependencies": { 1063 | "once": "^1.3.0", 1064 | "wrappy": "1" 1065 | } 1066 | }, 1067 | "node_modules/inherits": { 1068 | "version": "2.0.4", 1069 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 1070 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 1071 | "dev": true 1072 | }, 1073 | "node_modules/is-extglob": { 1074 | "version": "2.1.1", 1075 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 1076 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 1077 | "dev": true, 1078 | "engines": { 1079 | "node": ">=0.10.0" 1080 | } 1081 | }, 1082 | "node_modules/is-glob": { 1083 | "version": "4.0.3", 1084 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 1085 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 1086 | "dev": true, 1087 | "dependencies": { 1088 | "is-extglob": "^2.1.1" 1089 | }, 1090 | "engines": { 1091 | "node": ">=0.10.0" 1092 | } 1093 | }, 1094 | "node_modules/is-number": { 1095 | "version": "7.0.0", 1096 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 1097 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 1098 | "dev": true, 1099 | "engines": { 1100 | "node": ">=0.12.0" 1101 | } 1102 | }, 1103 | "node_modules/is-path-inside": { 1104 | "version": "3.0.3", 1105 | "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", 1106 | "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", 1107 | "dev": true, 1108 | "engines": { 1109 | "node": ">=8" 1110 | } 1111 | }, 1112 | "node_modules/isexe": { 1113 | "version": "2.0.0", 1114 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", 1115 | "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", 1116 | "dev": true 1117 | }, 1118 | "node_modules/js-yaml": { 1119 | "version": "4.1.0", 1120 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", 1121 | "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", 1122 | "dev": true, 1123 | "dependencies": { 1124 | "argparse": "^2.0.1" 1125 | }, 1126 | "bin": { 1127 | "js-yaml": "bin/js-yaml.js" 1128 | } 1129 | }, 1130 | "node_modules/json-schema-traverse": { 1131 | "version": "0.4.1", 1132 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", 1133 | "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", 1134 | "dev": true 1135 | }, 1136 | "node_modules/json-stable-stringify-without-jsonify": { 1137 | "version": "1.0.1", 1138 | "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", 1139 | "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", 1140 | "dev": true 1141 | }, 1142 | "node_modules/levn": { 1143 | "version": "0.4.1", 1144 | "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", 1145 | "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", 1146 | "dev": true, 1147 | "dependencies": { 1148 | "prelude-ls": "^1.2.1", 1149 | "type-check": "~0.4.0" 1150 | }, 1151 | "engines": { 1152 | "node": ">= 0.8.0" 1153 | } 1154 | }, 1155 | "node_modules/locate-path": { 1156 | "version": "6.0.0", 1157 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", 1158 | "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", 1159 | "dev": true, 1160 | "dependencies": { 1161 | "p-locate": "^5.0.0" 1162 | }, 1163 | "engines": { 1164 | "node": ">=10" 1165 | }, 1166 | "funding": { 1167 | "url": "https://github.com/sponsors/sindresorhus" 1168 | } 1169 | }, 1170 | "node_modules/lodash.merge": { 1171 | "version": "4.6.2", 1172 | "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", 1173 | "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", 1174 | "dev": true 1175 | }, 1176 | "node_modules/lru-cache": { 1177 | "version": "6.0.0", 1178 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 1179 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 1180 | "dev": true, 1181 | "dependencies": { 1182 | "yallist": "^4.0.0" 1183 | }, 1184 | "engines": { 1185 | "node": ">=10" 1186 | } 1187 | }, 1188 | "node_modules/merge2": { 1189 | "version": "1.4.1", 1190 | "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", 1191 | "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", 1192 | "dev": true, 1193 | "engines": { 1194 | "node": ">= 8" 1195 | } 1196 | }, 1197 | "node_modules/micromatch": { 1198 | "version": "4.0.5", 1199 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", 1200 | "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", 1201 | "dev": true, 1202 | "dependencies": { 1203 | "braces": "^3.0.2", 1204 | "picomatch": "^2.3.1" 1205 | }, 1206 | "engines": { 1207 | "node": ">=8.6" 1208 | } 1209 | }, 1210 | "node_modules/minimatch": { 1211 | "version": "3.1.2", 1212 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 1213 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 1214 | "dev": true, 1215 | "dependencies": { 1216 | "brace-expansion": "^1.1.7" 1217 | }, 1218 | "engines": { 1219 | "node": "*" 1220 | } 1221 | }, 1222 | "node_modules/ms": { 1223 | "version": "2.1.2", 1224 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 1225 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 1226 | "dev": true 1227 | }, 1228 | "node_modules/natural-compare": { 1229 | "version": "1.4.0", 1230 | "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", 1231 | "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", 1232 | "dev": true 1233 | }, 1234 | "node_modules/natural-compare-lite": { 1235 | "version": "1.4.0", 1236 | "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", 1237 | "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", 1238 | "dev": true 1239 | }, 1240 | "node_modules/once": { 1241 | "version": "1.4.0", 1242 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 1243 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 1244 | "dev": true, 1245 | "dependencies": { 1246 | "wrappy": "1" 1247 | } 1248 | }, 1249 | "node_modules/optionator": { 1250 | "version": "0.9.1", 1251 | "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", 1252 | "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", 1253 | "dev": true, 1254 | "dependencies": { 1255 | "deep-is": "^0.1.3", 1256 | "fast-levenshtein": "^2.0.6", 1257 | "levn": "^0.4.1", 1258 | "prelude-ls": "^1.2.1", 1259 | "type-check": "^0.4.0", 1260 | "word-wrap": "^1.2.3" 1261 | }, 1262 | "engines": { 1263 | "node": ">= 0.8.0" 1264 | } 1265 | }, 1266 | "node_modules/p-limit": { 1267 | "version": "3.1.0", 1268 | "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", 1269 | "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", 1270 | "dev": true, 1271 | "dependencies": { 1272 | "yocto-queue": "^0.1.0" 1273 | }, 1274 | "engines": { 1275 | "node": ">=10" 1276 | }, 1277 | "funding": { 1278 | "url": "https://github.com/sponsors/sindresorhus" 1279 | } 1280 | }, 1281 | "node_modules/p-locate": { 1282 | "version": "5.0.0", 1283 | "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", 1284 | "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", 1285 | "dev": true, 1286 | "dependencies": { 1287 | "p-limit": "^3.0.2" 1288 | }, 1289 | "engines": { 1290 | "node": ">=10" 1291 | }, 1292 | "funding": { 1293 | "url": "https://github.com/sponsors/sindresorhus" 1294 | } 1295 | }, 1296 | "node_modules/parent-module": { 1297 | "version": "1.0.1", 1298 | "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", 1299 | "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", 1300 | "dev": true, 1301 | "dependencies": { 1302 | "callsites": "^3.0.0" 1303 | }, 1304 | "engines": { 1305 | "node": ">=6" 1306 | } 1307 | }, 1308 | "node_modules/path-exists": { 1309 | "version": "4.0.0", 1310 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", 1311 | "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", 1312 | "dev": true, 1313 | "engines": { 1314 | "node": ">=8" 1315 | } 1316 | }, 1317 | "node_modules/path-is-absolute": { 1318 | "version": "1.0.1", 1319 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 1320 | "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", 1321 | "dev": true, 1322 | "engines": { 1323 | "node": ">=0.10.0" 1324 | } 1325 | }, 1326 | "node_modules/path-key": { 1327 | "version": "3.1.1", 1328 | "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", 1329 | "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", 1330 | "dev": true, 1331 | "engines": { 1332 | "node": ">=8" 1333 | } 1334 | }, 1335 | "node_modules/path-type": { 1336 | "version": "4.0.0", 1337 | "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", 1338 | "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", 1339 | "dev": true, 1340 | "engines": { 1341 | "node": ">=8" 1342 | } 1343 | }, 1344 | "node_modules/picomatch": { 1345 | "version": "2.3.1", 1346 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 1347 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 1348 | "dev": true, 1349 | "engines": { 1350 | "node": ">=8.6" 1351 | }, 1352 | "funding": { 1353 | "url": "https://github.com/sponsors/jonschlinkert" 1354 | } 1355 | }, 1356 | "node_modules/prelude-ls": { 1357 | "version": "1.2.1", 1358 | "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", 1359 | "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", 1360 | "dev": true, 1361 | "engines": { 1362 | "node": ">= 0.8.0" 1363 | } 1364 | }, 1365 | "node_modules/prettier": { 1366 | "version": "2.8.8", 1367 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", 1368 | "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", 1369 | "dev": true, 1370 | "bin": { 1371 | "prettier": "bin-prettier.js" 1372 | }, 1373 | "engines": { 1374 | "node": ">=10.13.0" 1375 | }, 1376 | "funding": { 1377 | "url": "https://github.com/prettier/prettier?sponsor=1" 1378 | } 1379 | }, 1380 | "node_modules/prettier-linter-helpers": { 1381 | "version": "1.0.0", 1382 | "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", 1383 | "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", 1384 | "dev": true, 1385 | "dependencies": { 1386 | "fast-diff": "^1.1.2" 1387 | }, 1388 | "engines": { 1389 | "node": ">=6.0.0" 1390 | } 1391 | }, 1392 | "node_modules/punycode": { 1393 | "version": "2.3.0", 1394 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", 1395 | "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", 1396 | "dev": true, 1397 | "engines": { 1398 | "node": ">=6" 1399 | } 1400 | }, 1401 | "node_modules/queue-microtask": { 1402 | "version": "1.2.3", 1403 | "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", 1404 | "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", 1405 | "dev": true, 1406 | "funding": [ 1407 | { 1408 | "type": "github", 1409 | "url": "https://github.com/sponsors/feross" 1410 | }, 1411 | { 1412 | "type": "patreon", 1413 | "url": "https://www.patreon.com/feross" 1414 | }, 1415 | { 1416 | "type": "consulting", 1417 | "url": "https://feross.org/support" 1418 | } 1419 | ] 1420 | }, 1421 | "node_modules/resolve-from": { 1422 | "version": "4.0.0", 1423 | "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", 1424 | "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", 1425 | "dev": true, 1426 | "engines": { 1427 | "node": ">=4" 1428 | } 1429 | }, 1430 | "node_modules/reusify": { 1431 | "version": "1.0.4", 1432 | "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", 1433 | "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", 1434 | "dev": true, 1435 | "engines": { 1436 | "iojs": ">=1.0.0", 1437 | "node": ">=0.10.0" 1438 | } 1439 | }, 1440 | "node_modules/rimraf": { 1441 | "version": "3.0.2", 1442 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", 1443 | "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", 1444 | "dev": true, 1445 | "dependencies": { 1446 | "glob": "^7.1.3" 1447 | }, 1448 | "bin": { 1449 | "rimraf": "bin.js" 1450 | }, 1451 | "funding": { 1452 | "url": "https://github.com/sponsors/isaacs" 1453 | } 1454 | }, 1455 | "node_modules/run-parallel": { 1456 | "version": "1.2.0", 1457 | "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", 1458 | "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", 1459 | "dev": true, 1460 | "funding": [ 1461 | { 1462 | "type": "github", 1463 | "url": "https://github.com/sponsors/feross" 1464 | }, 1465 | { 1466 | "type": "patreon", 1467 | "url": "https://www.patreon.com/feross" 1468 | }, 1469 | { 1470 | "type": "consulting", 1471 | "url": "https://feross.org/support" 1472 | } 1473 | ], 1474 | "dependencies": { 1475 | "queue-microtask": "^1.2.2" 1476 | } 1477 | }, 1478 | "node_modules/semver": { 1479 | "version": "7.5.1", 1480 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", 1481 | "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", 1482 | "dev": true, 1483 | "dependencies": { 1484 | "lru-cache": "^6.0.0" 1485 | }, 1486 | "bin": { 1487 | "semver": "bin/semver.js" 1488 | }, 1489 | "engines": { 1490 | "node": ">=10" 1491 | } 1492 | }, 1493 | "node_modules/shebang-command": { 1494 | "version": "2.0.0", 1495 | "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", 1496 | "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", 1497 | "dev": true, 1498 | "dependencies": { 1499 | "shebang-regex": "^3.0.0" 1500 | }, 1501 | "engines": { 1502 | "node": ">=8" 1503 | } 1504 | }, 1505 | "node_modules/shebang-regex": { 1506 | "version": "3.0.0", 1507 | "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", 1508 | "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", 1509 | "dev": true, 1510 | "engines": { 1511 | "node": ">=8" 1512 | } 1513 | }, 1514 | "node_modules/slash": { 1515 | "version": "3.0.0", 1516 | "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", 1517 | "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", 1518 | "dev": true, 1519 | "engines": { 1520 | "node": ">=8" 1521 | } 1522 | }, 1523 | "node_modules/strip-ansi": { 1524 | "version": "6.0.1", 1525 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", 1526 | "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", 1527 | "dev": true, 1528 | "dependencies": { 1529 | "ansi-regex": "^5.0.1" 1530 | }, 1531 | "engines": { 1532 | "node": ">=8" 1533 | } 1534 | }, 1535 | "node_modules/strip-json-comments": { 1536 | "version": "3.1.1", 1537 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", 1538 | "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", 1539 | "dev": true, 1540 | "engines": { 1541 | "node": ">=8" 1542 | }, 1543 | "funding": { 1544 | "url": "https://github.com/sponsors/sindresorhus" 1545 | } 1546 | }, 1547 | "node_modules/supports-color": { 1548 | "version": "7.2.0", 1549 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", 1550 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", 1551 | "dev": true, 1552 | "dependencies": { 1553 | "has-flag": "^4.0.0" 1554 | }, 1555 | "engines": { 1556 | "node": ">=8" 1557 | } 1558 | }, 1559 | "node_modules/text-table": { 1560 | "version": "0.2.0", 1561 | "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", 1562 | "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", 1563 | "dev": true 1564 | }, 1565 | "node_modules/to-regex-range": { 1566 | "version": "5.0.1", 1567 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 1568 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 1569 | "dev": true, 1570 | "dependencies": { 1571 | "is-number": "^7.0.0" 1572 | }, 1573 | "engines": { 1574 | "node": ">=8.0" 1575 | } 1576 | }, 1577 | "node_modules/tslib": { 1578 | "version": "1.14.1", 1579 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", 1580 | "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", 1581 | "dev": true 1582 | }, 1583 | "node_modules/tsutils": { 1584 | "version": "3.21.0", 1585 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", 1586 | "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", 1587 | "dev": true, 1588 | "dependencies": { 1589 | "tslib": "^1.8.1" 1590 | }, 1591 | "engines": { 1592 | "node": ">= 6" 1593 | }, 1594 | "peerDependencies": { 1595 | "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" 1596 | } 1597 | }, 1598 | "node_modules/type-check": { 1599 | "version": "0.4.0", 1600 | "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", 1601 | "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", 1602 | "dev": true, 1603 | "dependencies": { 1604 | "prelude-ls": "^1.2.1" 1605 | }, 1606 | "engines": { 1607 | "node": ">= 0.8.0" 1608 | } 1609 | }, 1610 | "node_modules/type-fest": { 1611 | "version": "0.20.2", 1612 | "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", 1613 | "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", 1614 | "dev": true, 1615 | "engines": { 1616 | "node": ">=10" 1617 | }, 1618 | "funding": { 1619 | "url": "https://github.com/sponsors/sindresorhus" 1620 | } 1621 | }, 1622 | "node_modules/typescript": { 1623 | "version": "5.0.4", 1624 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", 1625 | "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", 1626 | "dev": true, 1627 | "bin": { 1628 | "tsc": "bin/tsc", 1629 | "tsserver": "bin/tsserver" 1630 | }, 1631 | "engines": { 1632 | "node": ">=12.20" 1633 | } 1634 | }, 1635 | "node_modules/uri-js": { 1636 | "version": "4.4.1", 1637 | "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", 1638 | "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", 1639 | "dev": true, 1640 | "dependencies": { 1641 | "punycode": "^2.1.0" 1642 | } 1643 | }, 1644 | "node_modules/which": { 1645 | "version": "2.0.2", 1646 | "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", 1647 | "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", 1648 | "dev": true, 1649 | "dependencies": { 1650 | "isexe": "^2.0.0" 1651 | }, 1652 | "bin": { 1653 | "node-which": "bin/node-which" 1654 | }, 1655 | "engines": { 1656 | "node": ">= 8" 1657 | } 1658 | }, 1659 | "node_modules/word-wrap": { 1660 | "version": "1.2.3", 1661 | "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", 1662 | "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", 1663 | "dev": true, 1664 | "engines": { 1665 | "node": ">=0.10.0" 1666 | } 1667 | }, 1668 | "node_modules/wrappy": { 1669 | "version": "1.0.2", 1670 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 1671 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", 1672 | "dev": true 1673 | }, 1674 | "node_modules/yallist": { 1675 | "version": "4.0.0", 1676 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 1677 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", 1678 | "dev": true 1679 | }, 1680 | "node_modules/yocto-queue": { 1681 | "version": "0.1.0", 1682 | "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", 1683 | "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", 1684 | "dev": true, 1685 | "engines": { 1686 | "node": ">=10" 1687 | }, 1688 | "funding": { 1689 | "url": "https://github.com/sponsors/sindresorhus" 1690 | } 1691 | } 1692 | } 1693 | } 1694 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "binparse", 3 | "version": "2.1.0", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/blacha/binparse.git" 7 | }, 8 | "license": "MIT", 9 | "type": "module", 10 | "main": "./build/src/index.js", 11 | "types": "./build/src/index.d.ts", 12 | "scripts": { 13 | "build": "tsc --pretty", 14 | "build-watch": "tsc --pretty --watch", 15 | "lint": "eslint . --quiet --fix --ignore-path .gitignore", 16 | "format": "npx prettier -w .github/**/*.yml *.md", 17 | "test": "node --test" 18 | }, 19 | "publishConfig": { 20 | "access": "public" 21 | }, 22 | "engines": { 23 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 24 | }, 25 | "files": [ 26 | "build/src" 27 | ], 28 | "devDependencies": { 29 | "@linzjs/style": "^4.0.0", 30 | "@types/node": "^18.11.9" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/__benchmark__/benchmark.array.ts: -------------------------------------------------------------------------------- 1 | import { bp } from '../index.js'; 2 | 3 | const PointParser = bp.object('Point', { 4 | x: bp.lu16, 5 | y: bp.lu32, 6 | }); 7 | 8 | const PointsParser = bp.object('SimpleObject', { 9 | length: bp.lu32, 10 | points: bp.array('Points', PointParser, 'length'), 11 | }); 12 | 13 | const n = 1000; 14 | const buf = Buffer.alloc(4 + n * 6); 15 | 16 | buf.writeUInt32LE(n, 0); 17 | for (let i = 0; i < n; i++) { 18 | buf.writeUInt16LE(123, 4 + i * 4); 19 | buf.writeUInt32LE(456, 4 + i * 4 + 2); 20 | } 21 | 22 | for (let i = 0; i < 25_000; i++) { 23 | PointsParser.raw(buf); 24 | } 25 | -------------------------------------------------------------------------------- /src/__benchmark__/benchmark.int.ts: -------------------------------------------------------------------------------- 1 | import { bp } from '../index.js'; 2 | 3 | const pkt = Buffer.from('6e6973747261746f725d00ff633947532', 'hex'); 4 | 5 | for (let i = 0; i < 5_000_000; i++) { 6 | bp.u8.raw(pkt); 7 | bp.lu16.raw(pkt); 8 | bp.lu32.raw(pkt); 9 | bp.lu64.raw(pkt); 10 | } 11 | -------------------------------------------------------------------------------- /src/__benchmark__/benchmark.packet.ts: -------------------------------------------------------------------------------- 1 | import { bp } from '../index.js'; 2 | 3 | const pkt = Buffer.from( 4 | '260400020000000001005b61646d696e6973747261746f725d00ff6339475323383a205379646e65792c4155532e20737570706f7274656420627920414345204775696c642020ff633400', 5 | 'hex', 6 | ); 7 | 8 | const parser = bp.object('ChatMessage', { 9 | packetId: bp.u8, 10 | chatKind: bp.lu16, 11 | unk1: bp.lu16, 12 | unk2: bp.lu32, 13 | type: bp.u8, 14 | name: bp.string(), 15 | message: bp.string(), 16 | }); 17 | 18 | for (let i = 0; i < 100_000; i++) { 19 | parser.raw(pkt); 20 | } 21 | -------------------------------------------------------------------------------- /src/__tests__/at.test.ts: -------------------------------------------------------------------------------- 1 | import { bp } from '../index.js'; 2 | import { describe, it } from 'node:test'; 3 | import assert from 'node:assert'; 4 | const { at, lu16 } = bp; 5 | 6 | describe('ExplicitLocation', () => { 7 | const buf = Buffer.from([ 8 | 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 9 | 0x00, 0x0a, 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x0e, 0x00, 0x0f, 0x00, 0x10, 0x00, 0x11, 0x00, 10 | ]); 11 | 12 | // const buf = Buffer.alloc(0x24); 13 | it('should parse a complex object from buffer', () => { 14 | const locStrut = bp.object('Location', { 15 | xOffset: at(0x00, lu16), 16 | x: at(0x02, lu16), 17 | yOffset: at(0x04, lu16), 18 | y: at(0x06, lu16), 19 | staticX: at(0x10, lu16), 20 | staticY: at(0x14, lu16), 21 | pRoom: at(0x20, lu16), 22 | }); 23 | const ret = locStrut.read(buf); 24 | assert.deepEqual(ret.value, { xOffset: 0, x: 1, yOffset: 2, y: 3, staticX: 8, staticY: 10, pRoom: 16 }); 25 | assert.equal(ret.offset, 0x22); 26 | }); 27 | 28 | it('should extract from the middle of a buffer', () => { 29 | const jumpingStruct = bp.object('Loc', { 30 | beforeA: lu16, 31 | beforeB: lu16, 32 | jumpA: at(0x00, lu16), // Jump back to 0x00 and read 0x2 bytes 33 | afterJump: lu16, 34 | }); 35 | 36 | const ret = jumpingStruct.read(buf); 37 | 38 | assert.deepEqual(ret.value, { beforeA: 0, beforeB: 1, jumpA: 0, afterJump: 1 }); 39 | assert.equal(ret.offset, 4); 40 | }); 41 | 42 | it('should calculate the size using at', () => { 43 | const jumpingStruct = bp.object('Loc', { 44 | jumpA: at(0x30, lu16), 45 | }); 46 | 47 | assert.equal(jumpingStruct.size, 0x30 + 0x02); 48 | }); 49 | 50 | it('should throw when trying to calculate size', () => { 51 | assert.throws(() => at(0x30, lu16).size, Error); 52 | }); 53 | }); 54 | -------------------------------------------------------------------------------- /src/__tests__/buffer.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { bp } from '../index.js'; 4 | 5 | describe('InputTypes', () => { 6 | it('String:Buffer', () => { 7 | const res = bp.string(4).raw(Buffer.from('defP')); 8 | assert.equal(res, 'defP'); 9 | }); 10 | 11 | it('String:Number', () => { 12 | const res = bp.string(4).raw([100, 101, 102, 80, 83, 0]); 13 | assert.equal(res, 'defP'); 14 | }); 15 | 16 | it('String:UInt8', () => { 17 | const buf = Buffer.from('defP'); 18 | const uint8Array = new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)); 19 | const res = bp.string(4).raw(uint8Array); 20 | assert.equal(res, 'defP'); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /src/__tests__/complex.object.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { bp } from '../index.js'; 4 | 5 | describe('ComplexStruts', () => { 6 | const pkt = Buffer.from( 7 | '260400020000000001005b61646d696e6973747261746f725d00ff6339475323383a205379646e65792c4155532e20737570706f7274656420627920414345204775696c642020ff633400', 8 | 'hex', 9 | ); 10 | it('should parse multiple strings', () => { 11 | const parser = bp.object('ChatMessage', { 12 | packetId: bp.u8, 13 | chatKind: bp.lu16, 14 | unk1: bp.lu16, 15 | unk2: bp.lu32, 16 | type: bp.u8, 17 | name: bp.string(), 18 | message: bp.string(), 19 | }); 20 | 21 | const res = parser.raw(pkt); 22 | 23 | assert.equal(res.packetId, 38); 24 | assert.equal(res['chatKind'], 4); 25 | assert.equal(res.name, '[administrator]'); 26 | }); 27 | 28 | it('should read at exact location', () => { 29 | const parser = bp.object('ChatMessage', { 30 | name: bp.at(10, bp.string()), 31 | message: bp.string(), 32 | }); 33 | 34 | const res = parser.raw(pkt); 35 | assert.equal(res.name, '[administrator]'); 36 | assert.equal(res.message.includes('Sydney'), true); 37 | }); 38 | 39 | it('should support weird item names', () => { 40 | const pkt = Buffer.from('01020304', 'hex'); 41 | const parser = bp.object('Message', { 42 | "'": bp.u8, 43 | 'chat-kind': bp.u8, 44 | '"message"': bp.u8, 45 | '`': bp.u8, 46 | }); 47 | 48 | const res = parser.raw(pkt); 49 | assert.equal(res["'"], 1); 50 | assert.equal(res['chat-kind'], 2); 51 | assert.equal(res['"message"'], 3); 52 | assert.equal(res['`'], 4); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /src/__tests__/data.type.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, beforeEach, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { StrutParserContext } from '../type.js'; 4 | import { bp } from '../index.js'; 5 | import { StrutTypeArrayOffset } from '../array.js'; 6 | 7 | describe('DataType', () => { 8 | let pkt: StrutParserContext; 9 | beforeEach(() => { 10 | pkt = { offset: 0, startOffset: 0 }; 11 | }); 12 | it('String:Fixed', () => { 13 | const res = bp.string(4).parse([100, 101, 102, 80, 83, 0], pkt); 14 | assert.equal(res, 'defP'); 15 | assert.equal(pkt.offset, 4); 16 | }); 17 | it('String:Var', () => { 18 | const res = bp.string().parse([100, 101, 102, 80, 83, 0], pkt); 19 | assert.equal(res, 'defPS'); 20 | assert.equal(pkt.offset, 6); 21 | }); 22 | 23 | it('should parse a object', () => { 24 | const obj = bp.object('Test', { u8: bp.u8, lu16: bp.lu16 }); 25 | const res = obj.parse([255, 1, 0], pkt); 26 | assert.deepEqual(res, { u8: 255, lu16: 1 }); 27 | assert.equal(obj.size, 3); 28 | }); 29 | 30 | it('should parse a array', () => { 31 | const obj = bp.bytes(4); 32 | assert.equal(obj.size, 4); 33 | const res = obj.parse([1, 2, 3, 4], pkt); 34 | assert.deepEqual(res, [1, 2, 3, 4]); 35 | assert.equal(pkt.offset, 4); 36 | }); 37 | 38 | it('should parse a var array with offset', () => { 39 | const obj = bp.object('Obj', { 40 | len: bp.u8, 41 | varArray: new StrutTypeArrayOffset('Test', bp.u8, 'len', true), 42 | }); 43 | assert.deepEqual(obj.parse([3, 2, 3, 4], pkt), { len: 3, varArray: [2, 3] }); 44 | assert.equal(pkt.offset, 3); 45 | assert.throws(() => obj.size, Error); 46 | }); 47 | it('should parse a var array without offset', () => { 48 | const obj = bp.object('Obj', { 49 | len: bp.u8, 50 | varArray: new StrutTypeArrayOffset('Test', bp.u8, 'len', false), 51 | }); 52 | assert.deepEqual(obj.parse([3, 2, 3, 4], pkt), { len: 3, varArray: [2, 3, 4] }); 53 | assert.equal(pkt.offset, 4); 54 | assert.throws(() => obj.size, Error); 55 | }); 56 | 57 | it('uint8', () => { 58 | assert.equal(bp.u8.size, 1); 59 | const bytes = [100, 101, 102, 80, 83, 0]; 60 | assert.equal(bp.u8.parse(bytes, pkt), 100); 61 | assert.equal(pkt.offset, 1); 62 | assert.equal(bp.u8.parse(bytes, pkt), 101); 63 | assert.equal(pkt.offset, 2); 64 | assert.equal(bp.u8.parse(bytes, pkt), 102); 65 | assert.equal(pkt.offset, 3); 66 | assert.equal(bp.u8.parse(bytes, pkt), 80); 67 | assert.equal(pkt.offset, 4); 68 | assert.equal(bp.u8.parse(bytes, pkt), 83); 69 | assert.equal(pkt.offset, 5); 70 | }); 71 | 72 | it('uint16', () => { 73 | assert.equal(bp.lu16.size, 2); 74 | const bytes = [36, 0, 102, 80, 83, 0]; 75 | assert.equal(bp.lu16.parse(bytes, pkt), 36); 76 | assert.equal(pkt.offset, 2); 77 | assert.equal(bp.lu16.parse(bytes, pkt), 20582); 78 | assert.equal(pkt.offset, 4); 79 | }); 80 | 81 | it('uint32', () => { 82 | assert.equal(bp.lu32.size, 4); 83 | 84 | const bytes = [36, 0, 0, 0, 0, 0, 0, 1]; 85 | assert.equal(bp.lu32.parse(bytes, pkt), 36); 86 | assert.equal(pkt.offset, 4); 87 | assert.equal(bp.lu32.parse(bytes, pkt), 16777216); 88 | assert.equal(pkt.offset, 8); 89 | 90 | assert.equal(bp.lu32.parse([1, 0, 0, 0], { offset: 0, startOffset: 0 }), 1); 91 | assert.equal(bp.lu32.parse([0, 1, 0, 0], { offset: 0, startOffset: 0 }), 256); 92 | assert.equal(bp.lu32.parse([0, 0, 1, 0], { offset: 0, startOffset: 0 }), 65536); 93 | assert.equal(bp.lu32.parse([0, 0, 0, 1], { offset: 0, startOffset: 0 }), 16777216); 94 | assert.equal(bp.lu32.parse([255, 255, 255, 1], { offset: 0, startOffset: 0 }), 33554431); 95 | }); 96 | 97 | it('unit32 from buffer', () => { 98 | const bytes = Buffer.from([0xdd, 0x7e, 0xf4, 0xaa, 0x7f, 0xf7, 0x8c, 0xa6]); 99 | const uintA = bp.lu32.parse(bytes, { offset: 0, startOffset: 4 }); 100 | const uintB = bp.lu32.parse(bytes, { offset: 4, startOffset: 4 }); 101 | 102 | assert.equal(uintA, bytes.readUInt32LE(0)); 103 | assert.equal(uintB, bytes.readUInt32LE(4)); 104 | 105 | const outputBuffer = Buffer.alloc(bytes.length); 106 | outputBuffer.writeUInt32LE(uintA, 0); 107 | outputBuffer.writeUInt32LE(uintB, 4); 108 | 109 | assert.equal(outputBuffer.toString('hex'), bytes.toString('hex')); 110 | }); 111 | }); 112 | -------------------------------------------------------------------------------- /src/__tests__/flags.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { bp } from '../index.js'; 4 | 5 | describe('StrutTypeFlags', () => { 6 | it('should parse flags', () => { 7 | const flags = bp.flags('RGB', bp.u8, { r: 0x01, g: 0x02, b: 0x04 }); 8 | const output = flags.raw([0b101]); 9 | assert.deepEqual(output, { r: true, b: true }); 10 | }); 11 | 12 | it('should calculate size', () => { 13 | assert.equal(bp.flags('RGB', bp.u8, { r: 0x01 }).size, 1); 14 | assert.equal(bp.flags('RGB', bp.lu16, { r: 0x01 }).size, 2); 15 | assert.equal(bp.flags('RGB', bp.lu32, { r: 0x01 }).size, 4); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /src/__tests__/int64.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { blu64, lu64 } from '../int.js'; 4 | 5 | describe('Uint64', () => { 6 | it('should parse a uint 64', () => { 7 | const buf = Buffer.from([0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); 8 | assert.equal(blu64.raw(buf), buf.readBigUInt64LE(0)); 9 | assert.equal(lu64.raw(buf), 1); 10 | }); 11 | 12 | it('should loose precision', () => { 13 | const buf = Buffer.alloc(8); 14 | const tooBig = BigInt(Number.MAX_SAFE_INTEGER) + BigInt(2); 15 | buf.writeBigInt64LE(tooBig, 0); 16 | 17 | assert.equal(blu64.raw(buf), tooBig); 18 | // TODO should this throw if number is too large 19 | assert.notEqual(String(lu64.raw(buf)), String(tooBig)); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /src/__tests__/lookup.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { bp } from '../index.js'; 4 | 5 | enum Foo { 6 | bar = 1, 7 | baz = 2, 8 | } 9 | 10 | describe('StrutLookup', () => { 11 | it('should lookup from enum', () => { 12 | const lookup = bp.lookup('Foo', bp.u8, (id) => { 13 | switch (id) { 14 | case 1: 15 | return 'bar'; 16 | case 2: 17 | return 'baz'; 18 | } 19 | return undefined; 20 | }); 21 | assert.equal(lookup.size, 1); 22 | assert.equal(lookup.raw([0x01]).name, 'bar'); 23 | assert.equal(lookup.raw([0x01]).id, 1); 24 | 25 | assert.equal(lookup.raw([0x02]).name, 'baz'); 26 | assert.equal(lookup.raw([0x02]).id, 2); 27 | }); 28 | 29 | it('should be typesafe in lookups', () => { 30 | const lookup = bp.enum('Foo', bp.u8, Foo); 31 | assert.equal(lookup.size, 1); 32 | assert.equal(lookup.raw([0x01]).name, 'bar'); 33 | assert.equal(lookup.raw([0x01]).id, 1); 34 | 35 | assert.equal(lookup.raw([0x02]).name, 'baz'); 36 | assert.equal(lookup.raw([0x02]).id, 2); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /src/__tests__/parser.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { bp } from '../index.js'; 4 | 5 | describe('Object', () => { 6 | it('should parse a object', () => { 7 | const simpleParser = bp.object('SimpleObject', { 8 | x: bp.lu16, 9 | y: bp.lu16, 10 | }); 11 | 12 | const { value, offset } = simpleParser.read([0x00, 0x01, 0x01, 0x00]); 13 | assert.equal(offset, 4); 14 | assert.deepEqual(value, { x: 256, y: 1 }); 15 | }); 16 | }); 17 | 18 | describe('Bits', () => { 19 | it('should parse bitflags', () => { 20 | const PointParser = bp.object('Flags', { 21 | flags: bp.bits('Flags', { 22 | isRed: 1, 23 | isGreen: 1, 24 | isBlue: 1, 25 | isAlpha: 1, 26 | }), 27 | }); 28 | 29 | const { value } = PointParser.read([0b0101]); 30 | assert.deepEqual(value.flags, { isRed: 1, isGreen: 0, isBlue: 1, isAlpha: 0 }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/array.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { StrutParserContext, StrutParserInput, StrutType } from './type.js'; 3 | 4 | export class StrutTypeArray extends StrutBase { 5 | count: number; 6 | type: StrutType; 7 | 8 | constructor(name: string, type: StrutType, count: number) { 9 | super(`Array:${name}:${type.name}x${count}`); 10 | this.count = count; 11 | this.type = type; 12 | } 13 | 14 | get size(): number { 15 | return this.count * this.type.size; 16 | } 17 | 18 | parse(bytes: StrutParserInput, ctx: StrutParserContext): T[] { 19 | const value: T[] = []; 20 | for (let i = 0; i < this.count; i++) value.push(this.type.parse(bytes, ctx)); 21 | return value; 22 | } 23 | } 24 | 25 | export class StrutTypeArrayOffset extends StrutBase { 26 | type: StrutType; 27 | isMaxLength: boolean; 28 | /** Name of the variable to use as the length */ 29 | lengthName: string; 30 | 31 | /** Since we reference the current object we need to make sure currentObject is passed through */ 32 | isLookupRequired = true; 33 | 34 | constructor(name: string, type: StrutType, lengthVar: string, isMaxLength: boolean) { 35 | super('Array:Offset:' + name); 36 | this.isMaxLength = isMaxLength; 37 | this.lengthName = lengthVar; 38 | this.type = type; 39 | } 40 | 41 | /** Size cannot be calculated as it is variable */ 42 | get size(): number { 43 | throw new Error('Unable to calculate size of dynamic object: ' + this.name); 44 | } 45 | 46 | parse(bytes: StrutParserInput, ctx: StrutParserContext, currentObject: Record): T[] { 47 | const value: T[] = []; 48 | let packetLength = currentObject?.[this.lengthName]; 49 | if (packetLength == null || typeof packetLength !== 'number') { 50 | throw new Error(`${this.name}: Missing variable a "${this.lengthName}"`); 51 | } 52 | if (this.isMaxLength) packetLength -= ctx.offset - ctx.startOffset; 53 | for (let i = 0; i < packetLength; i++) value.push(this.type.parse(bytes, ctx)); 54 | return value; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/at.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { toHex } from './hex.js'; 3 | import { StrutParserContext, StrutParserInput, StrutType } from './type.js'; 4 | 5 | /** 6 | * Read a object at a specific offset 7 | */ 8 | export class StrutTypeAt extends StrutBase { 9 | type: StrutType; 10 | offset: number; 11 | constructor(offset: number, type: StrutType) { 12 | super('At:' + toHex(offset) + ':' + type.name); 13 | this.type = type; 14 | this.offset = offset; 15 | } 16 | 17 | get size(): number { 18 | throw new Error('Cannot calculate size with: ' + this.name); 19 | } 20 | 21 | parse(bytes: StrutParserInput, ctx: StrutParserContext): T { 22 | const readAt = ctx.startOffset + this.offset; 23 | if (readAt > bytes.length || readAt < 0) { 24 | throw new Error(`[${this.name}]: BufferOverflow attempted read at ${toHex(readAt)}`); 25 | } 26 | 27 | const readAmount = { offset: readAt, startOffset: ctx.startOffset }; 28 | const ret = this.type.parse(bytes, readAmount); 29 | ctx.offset = readAmount.offset; 30 | return ret; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/base.ts: -------------------------------------------------------------------------------- 1 | import { RefineCallBack, StrutParserContext, StrutParserInput, StrutType } from './type.js'; 2 | 3 | export abstract class StrutBase implements StrutType { 4 | /** Human friendly name of the parser */ 5 | name: string; 6 | 7 | /** number of bytes needed to read this object */ 8 | abstract size: number; 9 | 10 | constructor(name: string) { 11 | this.name = name; 12 | } 13 | 14 | abstract parse(bytes: StrutParserInput, pkt: StrutParserContext, currentObject?: Record): T; 15 | 16 | /** Read in raw instance of this object */ 17 | raw(bytes: StrutParserInput, offset = 0): T { 18 | return this.parse(bytes, { offset, startOffset: offset }); 19 | } 20 | 21 | /** Read in a new instance of this object */ 22 | read(bytes: StrutParserInput, offset = 0): { value: T; offset: number } { 23 | const ctx = { offset, startOffset: offset }; 24 | const value = this.parse(bytes, ctx); 25 | return { value, offset: ctx.offset }; 26 | } 27 | 28 | refine(cb: RefineCallBack): StrutType { 29 | return new StrutRefine(this, cb); 30 | } 31 | } 32 | 33 | export class StrutRefine extends StrutBase { 34 | cb: RefineCallBack; 35 | input: StrutBase; 36 | 37 | constructor(input: StrutBase, cb: RefineCallBack) { 38 | super('Function:' + input.name); 39 | this.input = input; 40 | this.cb = cb; 41 | } 42 | 43 | get size(): number { 44 | return this.input.size; 45 | } 46 | 47 | parse(bytes: StrutParserInput, ctx: StrutParserContext): TOut { 48 | const value = this.input.parse(bytes, ctx); 49 | return this.cb(value, bytes, ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/bits.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { BitStream } from './bitstream/index.js'; 3 | import { StrutParserInput, StrutParserContext, StrutType } from './type.js'; 4 | 5 | export class StrutTypeBits> extends StrutBase { 6 | fields: { key: string; bits: number }[]; 7 | size: number; 8 | 9 | constructor(name: string, obj: T) { 10 | super('Bits:' + name); 11 | let totalBits = 0; 12 | this.fields = Object.keys(obj).map((key) => { 13 | const bits = obj[key]; 14 | totalBits += bits ?? 0; 15 | return { key, bits }; 16 | }) as { key: string; bits: number }[]; 17 | this.size = Math.ceil(totalBits / 8); 18 | } 19 | 20 | parse(bytes: StrutParserInput, pkt: StrutParserContext): T { 21 | const offset = pkt.offset; 22 | 23 | const output = {} as any; 24 | const bs = new BitStream(bytes, offset, offset + this.size); 25 | for (const { key, bits } of this.fields) { 26 | output[key] = bs.bits(bits); 27 | } 28 | pkt.offset += this.size; 29 | return output; 30 | } 31 | } 32 | 33 | export class StrutTypeFlags> extends StrutBase>> { 34 | type: StrutType; 35 | fields: [string, number][]; 36 | constructor(name: string, type: StrutType, obj: T) { 37 | super('BitsFlags:' + name); 38 | this.type = type; 39 | this.fields = Object.entries(obj); 40 | } 41 | 42 | get size(): number { 43 | return this.type.size; 44 | } 45 | 46 | parse(bytes: StrutParserInput, pkt: StrutParserContext): Record { 47 | const raw = this.type.parse(bytes, pkt); 48 | const output = {} as any; 49 | for (const [key, value] of this.fields) { 50 | const flagValue = (raw & value) === value; 51 | if (flagValue) output[key] = flagValue; 52 | } 53 | return output; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/bitstream/__tests__/bitstream.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'node:test'; 2 | import assert from 'node:assert'; 3 | import { BitStream } from '../index.js'; 4 | 5 | describe('BitStream', () => { 6 | function toNullString(str: string): Buffer { 7 | const buf = []; 8 | for (let i = 0; i < str.length; i++) buf.push(str.charCodeAt(i)); 9 | return Buffer.from(buf); 10 | } 11 | it('should read bits from a stream', () => { 12 | const reader = new BitStream([0b1]); 13 | assert.equal(reader.bit(), 1); 14 | assert.equal(reader.offset, 1); 15 | assert.equal(reader.maxOffset, 8); 16 | assert.equal(reader.bit(), 0); 17 | }); 18 | 19 | it('should read little endian', () => { 20 | assert.equal(new BitStream([0xff]).bits(8), 255); 21 | assert.equal(new BitStream([0xff, 0xff]).bits(16), 256 * 256 - 1); 22 | assert.equal(new BitStream([0xff, 0xff, 0xff, 0xff]).bits(32), 256 ** 4 - 1); 23 | }); 24 | 25 | it('should read a boolean', () => { 26 | const br = new BitStream([0b10]); 27 | assert.equal(br.bool(), false); 28 | assert.equal(br.bool(), true); 29 | }); 30 | 31 | it('should read a string', () => { 32 | // o(new BitStream(toNullString('Hello')).string()).equals('Hello'); 33 | // o(new BitStream(toNullString('Hello World')).string(2)).equals('He'); 34 | 35 | const reader = new BitStream(toNullString('Hello\x00World')); 36 | assert.equal(reader.string(), 'Hello'); 37 | assert.equal(reader.string(), 'World'); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /src/bitstream/index.ts: -------------------------------------------------------------------------------- 1 | import { StrutParserInput } from '../type.js'; 2 | 3 | /** 4 | * Powers of two for 0-63 5 | * `2 ** offset` 6 | */ 7 | const Power2: number[] = []; 8 | for (let i = 0; i < 64; i++) Power2[i] = Math.pow(2, i); 9 | 10 | /** Very basic bit reader */ 11 | export class BitStream { 12 | /** Number of bits through the stream */ 13 | offset: number; 14 | /** Raw buffer */ 15 | buffer: StrutParserInput; 16 | /** Max bits that can be read */ 17 | maxOffset: number; 18 | /** How to read multiple bits at a time */ 19 | isLittleEndian: boolean; 20 | 21 | constructor(buffer: StrutParserInput, offset = 0, maxOffset: number = buffer.length, isLittleEndian = true) { 22 | this.buffer = buffer; 23 | this.offset = offset * 8; 24 | this.maxOffset = maxOffset * 8; 25 | this.isLittleEndian = isLittleEndian; 26 | if (!this.isLittleEndian) throw new Error('BigEndian is not supported'); 27 | } 28 | 29 | /** Number of bits left in this stream */ 30 | get remainingBits(): number { 31 | return this.maxOffset - this.offset; 32 | } 33 | 34 | getBitValue(byte: number, offset: number, length: number): number { 35 | return (byte & (((1 << (offset + length)) - 1) & ~((1 << offset) - 1))) >> offset; 36 | } 37 | 38 | /** 39 | * Skip number of bits 40 | * @param bits number of bits to skip 41 | */ 42 | skip(bits: number): void { 43 | this.offset += bits; 44 | } 45 | 46 | /** Read a single bit */ 47 | bit(): number { 48 | if (this.remainingBits < 0) throw new Error('BitStream: Overflow ' + this.remainingBits); 49 | 50 | const bytePos = Math.floor(this.offset / 8); 51 | const bitPos = this.offset % 8; 52 | const byte = this.buffer[bytePos]; 53 | this.offset++; 54 | if (byte == null) throw new Error('BitStream: Overflow: ' + this.remainingBits); 55 | return this.getBitValue(byte, bitPos, 1); 56 | } 57 | 58 | /** Read a boolean from a bit */ 59 | bool(): boolean { 60 | return this.bit() === 1; 61 | } 62 | 63 | /** Read bits */ 64 | bits(length: number): number { 65 | const initialLen = length; 66 | let bits = 0; 67 | while (length > 0) { 68 | const bit = this.bit(); 69 | if (bit === 1) bits += Power2[initialLen - length]!; 70 | length--; 71 | } 72 | return bits; 73 | } 74 | 75 | /** 76 | * Read a string up to length 77 | * 78 | * Will break early if a null character is found 79 | * 80 | * @param length max length to read, defaults to entire buffer 81 | */ 82 | string(length?: number): string { 83 | const buf = []; 84 | if (length == null) length = Math.floor(this.remainingBits / 8); 85 | for (let i = 0; i < length; i++) { 86 | const chr = this.bits(8); 87 | if (chr === 0x00) break; 88 | buf.push(String.fromCharCode(chr)); 89 | } 90 | return buf.join(''); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/bytes.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { StrutParserInput, StrutParserContext } from './type.js'; 3 | 4 | export class StrutTypeBytes extends StrutBase { 5 | size: number; 6 | 7 | constructor(count: number) { 8 | super('Bytes:' + count); 9 | this.size = count; 10 | } 11 | 12 | parse(bytes: StrutParserInput, ctx: StrutParserContext): StrutParserInput { 13 | const value = bytes.slice(ctx.offset, ctx.offset + this.size); 14 | ctx.offset += this.size; 15 | return value; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/hex.ts: -------------------------------------------------------------------------------- 1 | export function toHex(num: number, padding = 2): string { 2 | return '0x' + num.toString(16).padStart(padding, '0'); 3 | } 4 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { StrutTypeArray, StrutTypeArrayOffset } from './array.js'; 2 | import { StrutTypeAt } from './at.js'; 3 | import { StrutBase } from './base.js'; 4 | import { StrutTypeBits, StrutTypeFlags } from './bits.js'; 5 | import { StrutTypeBytes } from './bytes.js'; 6 | import { blu64, lu16, lu32, lu64, u8 } from './int.js'; 7 | import { StrutTypeEnum, StrutTypeLookup } from './lookup.js'; 8 | import { StrutTypeObject, StrutTypeObjectGenerated } from './object.js'; 9 | import { StrutTypeOffset } from './offset.js'; 10 | import { StrutTypeSkip } from './skip.js'; 11 | import { StrutTypeStringFixed, StrutTypeStringNull } from './string.js'; 12 | import { StrutAny, StrutType } from './type.js'; 13 | 14 | /** 15 | * Read an fixed number of objects 16 | * @param name Name of the parser 17 | * @param type Type to read in 18 | * @param count number of objects to read in 19 | */ 20 | function array(name: string, type: StrutType, count: number): StrutTypeArray; 21 | /** 22 | * Read an array of objects, using a previously read in `offset` as the length for the array 23 | * @param name Name of the parser 24 | * @param varName Variable name to lookup length from 25 | * @param type Type to read in 26 | * @param isMaxLength Is the offset length the end of the packet 27 | */ 28 | function array(name: string, type: StrutType, varName: string, isMaxLength?: boolean): StrutTypeArrayOffset; 29 | function array(name: string, type: StrutType, count: string | number, isMaxLength?: boolean): StrutType { 30 | if (typeof count === 'number') return new StrutTypeArray(name, type, count); 31 | return new StrutTypeArrayOffset(name, type, count, isMaxLength ?? false); 32 | } 33 | 34 | export const bp = { 35 | /** Unsigned int 8 (1 byte) */ 36 | u8, 37 | /** Unsigned LE int 16 (2 bytes) */ 38 | lu16, 39 | /** Unsigned LE int 32 (4 bytes) */ 40 | lu32, 41 | 42 | /** 43 | * Unsigned LE int 64 (8 bytes) 44 | * 45 | * **Warning** this can and will loose precision if the number is > `Number.MAX_SAFE_INTEGER` 46 | * 47 | * When using 64 bit for offsets all memory offsets can fit into a float without loosing precision, 48 | * as `Number.MAX_SAFE_INTEGER` is approx 9000TB in bytes 49 | * 50 | * @see bp.blu64 for BigInt variant 51 | */ 52 | lu64, 53 | /** BigInt Unsigned LE 64 (8 bytes) */ 54 | blu64, 55 | /** Empty object with nothing to parse (0 Bytes) */ 56 | empty: new StrutTypeObject('Empty', {}), 57 | 58 | /** Read a value from a offset */ 59 | offset(offset: StrutType, type: StrutType): StrutTypeOffset { 60 | return new StrutTypeOffset(offset, type); 61 | }, 62 | 63 | /** 64 | * Read at a specific offset since the start of the object 65 | * 66 | * @example 67 | * ```typescript 68 | * bp.object({ 69 | * id: bp.lu32, 70 | * // skip 0x04 -> 0x100 71 | * message: bp.at(0x100, bp.string()) 72 | * }) 73 | * ``` 74 | */ 75 | at(offset: number, type: StrutType): StrutTypeAt { 76 | return new StrutTypeAt(offset, type); 77 | }, 78 | 79 | /** 80 | * Read a string 81 | * @param length max number of bytes to read if defined, otherwise read util finding a null or end of buffer 82 | */ 83 | string(length?: number): StrutBase { 84 | if (length == null) return new StrutTypeStringNull(); 85 | return new StrutTypeStringFixed(length); 86 | }, 87 | /** User a bit parser to extract raw bits from the buffer */ 88 | bits>(name: string, obj: T): StrutTypeBits { 89 | return new StrutTypeBits(name, obj); 90 | }, 91 | flags>(name: string, type: StrutType, flags: T): StrutTypeFlags { 92 | return new StrutTypeFlags(name, type, flags); 93 | }, 94 | /** 95 | * Generates a parser for a object type 96 | * If issues occur see @see bp.static for a non code generated object 97 | */ 98 | object>(name: string, obj: T): StrutTypeObjectGenerated { 99 | return new StrutTypeObjectGenerated(name, obj); 100 | }, 101 | static>(name: string, obj: T): StrutTypeObject { 102 | return new StrutTypeObject(name, obj); 103 | }, 104 | /** Convert a number lookup into a human friendly output */ 105 | lookup(name: string, type: StrutType, lookup: (id: number) => keyof T | undefined): StrutTypeLookup { 106 | return new StrutTypeLookup(name, type, lookup); 107 | }, 108 | 109 | /** Reverse lookup from a enumeration */ 110 | enum>(name: string, type: StrutType, e: T): StrutTypeEnum { 111 | return new StrutTypeEnum(name, type, e); 112 | }, 113 | /** 114 | * Read a byte array 115 | * 116 | * @param count number of bytes to read 117 | */ 118 | bytes(count: number): StrutTypeBytes { 119 | return new StrutTypeBytes(count); 120 | }, 121 | /** Skip count number of bytes */ 122 | skip(count: number): StrutType { 123 | return new StrutTypeSkip(count); 124 | }, 125 | array, 126 | }; 127 | 128 | export { StrutBase } from './base.js'; 129 | export { BitStream } from './bitstream/index.js'; 130 | export { toHex } from './hex.js'; 131 | export { StrutAny, StrutEval, StrutInfer, StrutParserContext, StrutType, StrutParserInput } from './type.js'; 132 | export { StrutTypeObject } from './object.js'; 133 | -------------------------------------------------------------------------------- /src/int.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { StrutParserContext, StrutParserInput } from './type.js'; 3 | 4 | export class UInt8 extends StrutBase { 5 | size = 1; 6 | parse(bytes: StrutParserInput, pkt: StrutParserContext): number { 7 | const offset = pkt.offset; 8 | pkt.offset += this.size; 9 | return bytes[offset]; 10 | } 11 | } 12 | 13 | export class LUInt16 extends StrutBase { 14 | size = 2; 15 | parse(bytes: StrutParserInput, pkt: StrutParserContext): number { 16 | let offset = pkt.offset; 17 | const byteA = bytes[offset++]; 18 | const byteB = bytes[offset++] << 8; 19 | pkt.offset += 2; 20 | return byteA | byteB; 21 | } 22 | } 23 | 24 | export class LUInt32 extends StrutBase { 25 | size = 4; 26 | parse(bytes: StrutParserInput, pkt: StrutParserContext): number { 27 | let offset = pkt.offset; 28 | const byteA = bytes[offset++]; 29 | const byteB = bytes[offset++] << 8; 30 | const byteC = bytes[offset++] << 16; 31 | const byteD = bytes[offset++] * 0x1000000; 32 | pkt.offset = offset; 33 | return (byteA | byteB | byteC) + byteD; 34 | } 35 | } 36 | 37 | const Pow32 = 2 ** 32; 38 | /** 39 | * Read a int from 64bits of number 40 | * **Warning** this can and will loose precision if the number is > Number.MAX_SAFE_INTEGER 41 | * 42 | * When using 64 bit for offsets all memory offsets can fit into a float without loosing precision, 43 | * as Number.MAX_SAFE_INTEGER is approx 9000TB in bytes 44 | */ 45 | export class LUInt64 extends StrutBase { 46 | size = 8; 47 | parse(bytes: StrutParserInput, pkt: StrutParserContext): number { 48 | const intA = lu32.parse(bytes, pkt); 49 | const intB = lu32.parse(bytes, pkt); 50 | return intA + intB * Pow32; // Shifting by 32 doesn't work in javascript 51 | } 52 | } 53 | 54 | export class BigLUInt64 extends StrutBase { 55 | size = 8; 56 | parse(bytes: StrutParserInput, pkt: StrutParserContext): bigint { 57 | const intA = BigInt(lu32.parse(bytes, pkt)); 58 | const intB = BigInt(lu32.parse(bytes, pkt)); 59 | return intA + (intB << BigInt(32)); 60 | } 61 | } 62 | 63 | export const u8 = new UInt8('UInt8'); 64 | export const lu16 = new LUInt16('LUInt16'); 65 | export const lu32 = new LUInt32('LUInt32'); 66 | export const lu64 = new LUInt64('LUInt64'); 67 | export const blu64 = new BigLUInt64('BigLUInt64'); 68 | -------------------------------------------------------------------------------- /src/lookup.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { StrutParserContext, StrutParserInput, StrutType } from './type.js'; 3 | 4 | type ValueOf = T[keyof T]; 5 | 6 | export class StrutTypeLookup extends StrutBase<{ id: ValueOf; name: keyof T }> { 7 | type: StrutType; 8 | lookup: (id: number) => keyof T | undefined; 9 | 10 | constructor(name: string, type: StrutType, lookup: (id: number) => keyof T | undefined) { 11 | super('Lookup:' + name); 12 | this.lookup = lookup; 13 | this.type = type; 14 | } 15 | 16 | get size(): number { 17 | return this.type.size; 18 | } 19 | 20 | parse(bytes: StrutParserInput, ctx: StrutParserContext): { id: ValueOf; name: keyof T } { 21 | const id = this.type.parse(bytes, ctx) as any; 22 | const name = this.lookup(id); 23 | if (name == null) throw new Error(`${this.name}: Failed to lookup ${id}`); 24 | return { id, name } as any; 25 | } 26 | } 27 | 28 | export class StrutTypeEnum> extends StrutBase<{ 29 | id: ValueOf; 30 | name: keyof T; 31 | }> { 32 | enumeration: T; 33 | type: StrutType; 34 | constructor(name: string, type: StrutType, enumeration: T) { 35 | super('Enum:' + name); 36 | this.enumeration = enumeration; 37 | this.type = type; 38 | } 39 | 40 | get size(): number { 41 | return this.type.size; 42 | } 43 | 44 | parse(bytes: StrutParserInput, ctx: StrutParserContext): { id: ValueOf; name: keyof T } { 45 | const id = this.type.parse(bytes, ctx) as any; 46 | const name = this.enumeration[id] as keyof T; 47 | if (name == null) throw new Error(`${this.name}: Failed to lookup ${id}`); 48 | return { id, name }; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/object.ts: -------------------------------------------------------------------------------- 1 | import { StrutTypeAt } from './at.js'; 2 | import { StrutBase } from './base.js'; 3 | import { StrutAny, StrutInfer, StrutParserContext, StrutParserInput } from './type.js'; 4 | 5 | export type StrutReturnType = { [K in keyof T]: StrutInfer }; 6 | 7 | export class StrutTypeObject> extends StrutBase> { 8 | fields: { key: string; parser: StrutAny }[]; 9 | 10 | constructor(name: string, obj: T) { 11 | super(name); 12 | this.fields = []; 13 | for (const [key, parser] of Object.entries(obj)) { 14 | this.fields.push({ key, parser }); 15 | } 16 | } 17 | 18 | private _size = -1; 19 | get size(): number { 20 | if (this._size > -1) return this._size; 21 | let size = 0; 22 | for (const ctx of this.fields) { 23 | if (ctx.parser instanceof StrutTypeAt) { 24 | size = ctx.parser.offset + ctx.parser.type.size; 25 | } else { 26 | size += ctx.parser.size; 27 | } 28 | } 29 | this._size = size; 30 | return this._size; 31 | } 32 | 33 | parse(bytes: StrutParserInput, ctx: StrutParserContext): StrutReturnType { 34 | const value = {} as Record; 35 | for (const kv of this.fields) { 36 | value[kv.key] = kv.parser.parse(bytes, ctx, value); 37 | } 38 | return value as StrutReturnType; 39 | } 40 | } 41 | 42 | /** 43 | * Generate a object parser this is significantly faster than `StrutTypeObject` 44 | * initial benchmarks put it at almost 10x faster 45 | */ 46 | export class StrutTypeObjectGenerated> extends StrutBase> { 47 | fields: { key: string; parser: StrutAny }[] = []; 48 | 49 | constructor(name: string, obj: T) { 50 | super(name); 51 | 52 | const entries = Object.entries(obj); 53 | let isLookupRequired = false; 54 | for (const [key, parser] of entries) { 55 | /** 56 | * Determine if any sub objects need a reference to the current object during parsing as it is slightly slower 57 | * try and avoid it if possible 58 | */ 59 | if (parser.isLookupRequired) isLookupRequired = true; 60 | this.fields.push({ key, parser }); 61 | } 62 | 63 | // No point generating a function for no entries 64 | if (entries.length === 0) return; 65 | 66 | if (isLookupRequired) this.generateObjectAssign(); 67 | else this.generateSingleObject(); 68 | } 69 | /** 70 | * This method is slightly faster than `generateObjectAssign` but generates single line return 71 | * 72 | * Basic testing shows it to be roughly 20% faster than the other method 73 | * 74 | * @see StrutTypeObjectGenerated.generateObjectAssign 75 | */ 76 | generateSingleObject(): void { 77 | const parsers: StrutAny[] = []; 78 | 79 | let body = '"use strict"; return {'; 80 | for (let i = 0; i < this.fields.length; i++) { 81 | parsers.push(this.fields[i].parser); 82 | body += ` ${JSON.stringify(this.fields[i].key)}: _bp[${i}].parse(buf, ctx),`; 83 | } 84 | body += ' };'; 85 | const func = new Function('_bp', 'buf', 'ctx', body); 86 | this.parse = func.bind(null, parsers); 87 | } 88 | 89 | /** 90 | * This method is slightly slower object creation than `generateSingleObject` 91 | * It is needed when sub objects want to reference the object being parsed 92 | * 93 | * @see StrutTypeObjectGenerated.generateSingleObject 94 | */ 95 | generateObjectAssign(): void { 96 | const parsers: StrutAny[] = []; 97 | 98 | let body = '"use strict"; const ret = {};\n'; 99 | for (let i = 0; i < this.fields.length; i++) { 100 | parsers.push(this.fields[i].parser); 101 | body += `ret[${JSON.stringify(this.fields[i].key)}] = _bp[${i}].parse(buf, ctx, ret)\n`; 102 | } 103 | body += `return ret`; 104 | const func = new Function('_bp', 'buf', 'ctx', body); 105 | this.parse = func.bind(null, parsers); 106 | } 107 | 108 | private _size = -1; 109 | get size(): number { 110 | if (this._size > -1) return this._size; 111 | let size = 0; 112 | for (const ctx of this.fields) { 113 | if (ctx.parser instanceof StrutTypeAt) { 114 | size = ctx.parser.offset + ctx.parser.type.size; 115 | } else { 116 | size += ctx.parser.size; 117 | } 118 | } 119 | this._size = size; 120 | return this._size; 121 | } 122 | 123 | /** Force the size of this object */ 124 | setSize(size: number): void { 125 | this._size = size; 126 | } 127 | 128 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 129 | parse(_bytes: StrutParserInput, _ctx: StrutParserContext): StrutReturnType { 130 | return {} as StrutReturnType; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/offset.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { toHex } from './hex.js'; 3 | import { StrutParserContext, StrutParserInput, StrutType } from './type.js'; 4 | 5 | /** 6 | * Variable length string that is null terminated. 7 | */ 8 | export class StrutTypeOffset extends StrutBase { 9 | type: StrutType; 10 | offset: StrutType; 11 | constructor(offset: StrutType, type: StrutType) { 12 | super('Offset:' + offset.name + ':' + type.name); 13 | this.type = type; 14 | this.offset = offset; 15 | } 16 | 17 | get size(): number { 18 | return this.type.size; 19 | } 20 | 21 | parse(bytes: StrutParserInput, ctx: StrutParserContext): T { 22 | const readAt = this.offset.parse(bytes, ctx); 23 | if (readAt > bytes.length || readAt < 0) { 24 | throw new Error(`[${this.name}]: BufferOverflow attempted read at ${toHex(readAt)}`); 25 | } 26 | return this.type.parse(bytes, { offset: readAt, startOffset: readAt }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/skip.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { StrutParserContext, StrutParserInput } from './type.js'; 3 | 4 | /** Skip count amount of bytes from the buffer */ 5 | export class StrutTypeSkip extends StrutBase { 6 | size: number; 7 | 8 | constructor(count: number) { 9 | super('Skip:' + count); 10 | this.size = count; 11 | } 12 | 13 | parse(_bytes: StrutParserInput, ctx: StrutParserContext): undefined { 14 | ctx.offset += this.size; 15 | return undefined; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/string.ts: -------------------------------------------------------------------------------- 1 | import { StrutBase } from './base.js'; 2 | import { toHex } from './hex.js'; 3 | import { StrutParserContext, StrutParserInput } from './type.js'; 4 | 5 | /** 6 | * Variable length string that is null terminated. 7 | */ 8 | export class StrutTypeStringNull extends StrutBase { 9 | constructor() { 10 | super('String'); 11 | } 12 | 13 | get size(): number { 14 | throw new Error('Unable to calculate size from dynamic object'); 15 | } 16 | 17 | parse(bytes: StrutParserInput, ctx: StrutParserContext): string { 18 | const offset = ctx.offset; 19 | 20 | const value: string[] = []; 21 | let size = 0; 22 | while (size + offset < bytes.length) { 23 | const res = bytes[offset + size]; 24 | if (res === 0x00 || res == null) break; 25 | value.push(String.fromCharCode(res)); 26 | size++; 27 | } 28 | ctx.offset += size + 1; 29 | 30 | return value.join(''); 31 | } 32 | } 33 | 34 | /** 35 | * Fixed length string 36 | * 37 | * will stop parsing when first `0x00` is read in or 38 | * max length which ever is first 39 | */ 40 | export class StrutTypeStringFixed extends StrutBase { 41 | size: number; 42 | constructor(maxLength: number) { 43 | super('String:' + maxLength); 44 | this.size = maxLength; 45 | } 46 | 47 | parse(bytes: StrutParserInput, ctx: StrutParserContext): string { 48 | const offset = ctx.offset; 49 | if (this.size + offset > bytes.length) { 50 | throw new Error(`BufferOverflow: ${this.name} offset: ${toHex(ctx.offset)}`); 51 | } 52 | const value: string[] = []; 53 | let size = 0; 54 | while (size < this.size) { 55 | const res = bytes[offset + size]; 56 | if (res === 0x00 || res == null) break; 57 | value.push(String.fromCharCode(res)); 58 | size++; 59 | } 60 | ctx.offset += this.size; 61 | 62 | return value.join(''); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/type.ts: -------------------------------------------------------------------------------- 1 | /** Minimal interface that should allow for `UInt8Array` `Buffer` and `number[]` to be passed into our functions */ 2 | export interface StrutParserInput { 3 | readonly [n: number]: number; 4 | length: number; 5 | slice(start: number, end: number): StrutParserInput; 6 | } 7 | 8 | /** Parser context that is passed around during the parsing process */ 9 | export interface StrutParserContext { 10 | /** Current offset */ 11 | offset: number; 12 | /** Offset the current strut parser started at */ 13 | startOffset: number; 14 | /** Values to be used in other strut parsers */ 15 | vars?: Record; 16 | } 17 | 18 | export interface StrutType { 19 | /** Number of bytes needed */ 20 | size: number; 21 | /** Name of the parser */ 22 | name: string; 23 | /** Parse some bytes with the provided context */ 24 | parse(bytes: StrutParserInput, pkt: StrutParserContext, currentObject?: Record): T; 25 | 26 | /** Read in the data throwing away any parser information */ 27 | raw(bytes: StrutParserInput, offset?: number): T; 28 | 29 | /** Refine the type using a custom function */ 30 | refine(cb: RefineCallBack): StrutType; 31 | 32 | /** Are variables required by this object */ 33 | isLookupRequired?: boolean; 34 | } 35 | 36 | export type RefineCallBack = (value: TIn, bytes?: StrutParserInput, pkt?: StrutParserContext) => TOut; 37 | 38 | export type StrutAny = StrutType; 39 | export type StrutEval = T extends any[] | Date ? T : { [Key in keyof T]: T[Key] }; 40 | export type StrutInfer = T extends StrutType ? StrutEval : never; 41 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@linzjs/style/tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "build", 5 | "noUncheckedIndexedAccess": false 6 | } 7 | } 8 | --------------------------------------------------------------------------------