{"_id":"@digitaldefiance/reed-solomon-erasure.wasm","_rev":"3-1b13496b1e1aae86676be8ef878400c8","name":"@digitaldefiance/reed-solomon-erasure.wasm","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@digitaldefiance/reed-solomon-erasure.wasm","version":"1.0.0","keywords":["reed-solomon","erasure-coding","parity","shard","error-correction","ecc","wasm","webassembly","browser","nodejs"],"author":{"name":"Digital Defiance"},"license":"MIT","_id":"@digitaldefiance/reed-solomon-erasure.wasm@1.0.0","maintainers":[{"name":"jessica-mulein","email":"jessica@mulein.com"}],"homepage":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm#readme","bugs":{"url":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm/issues"},"dist":{"shasum":"de34d0fb34654f41c7f417c1ec1ec251e9e81325","tarball":"https://registry.npmjs.org/@digitaldefiance/reed-solomon-erasure.wasm/-/reed-solomon-erasure.wasm-1.0.0.tgz","fileCount":16,"integrity":"sha512-ZWY+fRqYPAyXEIje0Hbphvt18vTtZzR+ZQ1gGyLxzdLtj6mb5tmgVVCQBU/kWIjRrAL8RPDRX2CdUD1YUQhRfQ==","signatures":[{"sig":"MEYCIQCT+h4BzbH6zut9b6hqdz8qj+R02UsFXd1CSQ9fViuKnQIhAMn5uP2j/962OAXz0WtjfcWmjbK8jliV0gNUWUYiWKea","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":307023},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","browser":"browser/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","browser":"./browser/index.js","require":"./dist/index.js"},"./wasm":"./dist/reed_solomon_erasure_bg.wasm","./browser":{"types":"./dist/index.d.ts","import":"./browser/index.mjs","require":"./browser/index.js"}},"scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"yarn clean && yarn compile && yarn copy-wasm","clean":"rm -rf dist browser","compile":"yarn compile:cjs && yarn compile:esm && yarn compile:browser","lint:fix":"eslint src --ext .ts --fix","copy-wasm":"cp src/*.wasm dist/ && cp src/*.wasm browser/","typecheck":"tsc --noEmit","build:full":"yarn clean && yarn compile-wasm && yarn compile && yarn copy-wasm","test:watch":"vitest","compile:cjs":"tsc -p tsconfig.json","compile:esm":"tsc -p tsconfig.esm.json","compile-wasm":"wasm-pack build --release --out-dir wasm-build && cp wasm-build/reed_solomon_erasure_bg.wasm src/ && rm -rf wasm-build","test:browser":"vitest --environment jsdom","prepublishOnly":"yarn build","publish:public":"npm publish --access public","compile:browser":"tsc -p tsconfig.browser.json"},"_npmUser":{"name":"jessica-mulein","email":"jessica@mulein.com"},"repository":{"url":"git+https://github.com/Digital-Defiance/reed-solomon-erasure.wasm.git","type":"git"},"_npmVersion":"10.9.4","description":"Reed-Solomon erasure coding compiled to WebAssembly - browser and Node.js compatible","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"packageManager":"yarn@4.11.0","devDependencies":{"jsdom":"^24.0.0","eslint":"^8.57.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^7.0.0","@typescript-eslint/eslint-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/reed-solomon-erasure.wasm_1.0.0_1770313195640_0.2512413447831734","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@digitaldefiance/reed-solomon-erasure.wasm","version":"1.0.1","keywords":["reed-solomon","erasure-coding","parity","shard","error-correction","ecc","wasm","webassembly","browser","nodejs"],"author":{"name":"Digital Defiance"},"license":"MIT","_id":"@digitaldefiance/reed-solomon-erasure.wasm@1.0.1","maintainers":[{"name":"jessica-mulein","email":"jessica@mulein.com"}],"homepage":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm#readme","bugs":{"url":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm/issues"},"dist":{"shasum":"131775241350ca2d2e9a03dbc6b767d2a3dbcaae","tarball":"https://registry.npmjs.org/@digitaldefiance/reed-solomon-erasure.wasm/-/reed-solomon-erasure.wasm-1.0.1.tgz","fileCount":13,"integrity":"sha512-OLCTA/MuikA/7EGknJrj3iEopjWKzefwEqSvMXVwG0c8dkFLpFEA6TxprE4svgFQQssA5OZ9JGO104iYhXa8qw==","signatures":[{"sig":"MEQCIGZnQxNZpJl11es9Iwp09YvHs6evdVFFP4PYJOI866icAiAHMXQkGNpVV/MThJFhYMP3enDuP8/QmHQ1taUEFMcKdw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":177473},"main":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./wasm":"./dist/reed_solomon_erasure_bg.wasm","./browser":{"types":"./dist/browser.d.ts","default":"./dist/browser.js"}},"scripts":{"lint":"eslint src --ext .ts","test":"vitest run","build":"yarn clean && yarn compile && yarn copy-wasm","clean":"rm -rf dist","compile":"tsc -p tsconfig.json","lint:fix":"eslint src --ext .ts --fix","copy-wasm":"cp src/*.wasm dist/","typecheck":"tsc --noEmit","build:full":"yarn clean && yarn compile-wasm && yarn compile && yarn copy-wasm","test:watch":"vitest","compile-wasm":"wasm-pack build --release --out-dir wasm-build && cp wasm-build/reed_solomon_erasure_bg.wasm src/ && rm -rf wasm-build","test:browser":"vitest --environment jsdom","prepublishOnly":"yarn build","publish:public":"npm publish --access public"},"_npmUser":{"name":"jessica-mulein","email":"jessica@mulein.com"},"repository":{"url":"git+https://github.com/Digital-Defiance/reed-solomon-erasure.wasm.git","type":"git"},"_npmVersion":"10.9.4","description":"Reed-Solomon erasure coding compiled to WebAssembly - browser and Node.js compatible","directories":{},"sideEffects":false,"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"packageManager":"yarn@4.11.0","devDependencies":{"jsdom":"^24.0.0","eslint":"^8.57.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.0.0","@typescript-eslint/parser":"^7.0.0","@typescript-eslint/eslint-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/reed-solomon-erasure.wasm_1.0.1_1770313587865_0.9103347927341294","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@digitaldefiance/reed-solomon-erasure.wasm","version":"1.0.2","description":"Reed-Solomon erasure coding compiled to WebAssembly - browser and Node.js compatible","author":{"name":"Digital Defiance"},"license":"MIT","keywords":["reed-solomon","erasure-coding","parity","shard","error-correction","ecc","wasm","webassembly","browser","nodejs"],"repository":{"type":"git","url":"git+https://github.com/Digital-Defiance/reed-solomon-erasure.wasm.git"},"homepage":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm#readme","bugs":{"url":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm/issues"},"packageManager":"yarn@4.11.0","main":"./dist/index.js","module":"./dist/index.mjs","browser":"./dist/browser.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","browser":{"import":"./dist/browser.mjs","require":"./dist/browser.js","default":"./dist/browser.mjs"},"import":"./dist/index.mjs","require":"./dist/index.js","default":"./dist/index.js"},"./browser":{"types":"./dist/browser.d.ts","import":{"default":"./dist/browser.mjs"},"require":{"default":"./dist/browser.js"},"default":"./dist/browser.js"},"./wasm":"./dist/reed_solomon_erasure_bg.wasm"},"sideEffects":false,"scripts":{"clean":"rm -rf dist browser","compile-wasm":"wasm-pack build --release --out-dir wasm-build && cp wasm-build/reed_solomon_erasure_bg.wasm src/ && rm -rf wasm-build","compile:cjs":"tsc -p tsconfig.json","compile:esm":"tsc -p tsconfig.esm.json && mv dist/index.js dist/index.mjs && mv dist/index.js.map dist/index.mjs.map && mv dist/browser.js dist/browser.mjs && mv dist/browser.js.map dist/browser.mjs.map","compile:browser":"tsc -p tsconfig.browser.json","compile":"yarn compile:esm && yarn compile:cjs && yarn compile:browser","copy-wasm":"cp src/*.wasm dist/ && cp src/*.wasm browser/","build":"yarn clean && yarn compile && yarn copy-wasm","build:full":"yarn clean && yarn compile-wasm && yarn compile && yarn copy-wasm","test":"vitest run","test:watch":"vitest","test:browser":"vitest --environment jsdom","lint":"eslint src --ext .ts","lint:fix":"eslint src --ext .ts --fix","typecheck":"tsc --noEmit","prepublishOnly":"yarn build","publish:public":"npm publish --access public"},"devDependencies":{"@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^7.0.0","@typescript-eslint/parser":"^7.0.0","eslint":"^8.57.0","jsdom":"^24.0.0","typescript":"^5.4.0","vitest":"^1.6.0"},"engines":{"node":">=18.0.0"},"_id":"@digitaldefiance/reed-solomon-erasure.wasm@1.0.2","gitHead":"e0e09736933912b6df820b3cbbc02f5e17a88c0c","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-Qltu+Vzj/x07rryH8wQo+5uMTtIxFEYi88phWgX+V5qVHdTcjMSSHXr6Ay24dPvsc6Q7NsdYnr28vQNkspxkfA==","shasum":"49e25c532291929f77e75b0eca1658694542174f","tarball":"https://registry.npmjs.org/@digitaldefiance/reed-solomon-erasure.wasm/-/reed-solomon-erasure.wasm-1.0.2.tgz","fileCount":20,"unpackedSize":341457,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDSrpUz03p5t0i2QUdbiK+k3cqS6mrsUw4f5iO7FhNxhQIgHyq1EHpYbd3Y9jbu35ck9+aCpeZoVIaLw1lKuhcKUGg="}]},"_npmUser":{"name":"jessica-mulein","email":"jessica@mulein.com"},"directories":{},"maintainers":[{"name":"jessica-mulein","email":"jessica@mulein.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/reed-solomon-erasure.wasm_1.0.2_1770575707455_0.4154264416192439"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-05T17:39:55.581Z","modified":"2026-02-08T18:35:07.756Z","1.0.0":"2026-02-05T17:39:55.851Z","1.0.1":"2026-02-05T17:46:28.101Z","1.0.2":"2026-02-08T18:35:07.616Z"},"bugs":{"url":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm/issues"},"author":{"name":"Digital Defiance"},"license":"MIT","homepage":"https://github.com/Digital-Defiance/reed-solomon-erasure.wasm#readme","keywords":["reed-solomon","erasure-coding","parity","shard","error-correction","ecc","wasm","webassembly","browser","nodejs"],"repository":{"type":"git","url":"git+https://github.com/Digital-Defiance/reed-solomon-erasure.wasm.git"},"description":"Reed-Solomon erasure coding compiled to WebAssembly - browser and Node.js compatible","maintainers":[{"name":"jessica-mulein","email":"jessica@mulein.com"}],"readme":"# reed-solomon-erasure.wasm\n[reed-solomon-erasure](https://github.com/darrenldl/reed-solomon-erasure) Rust library compiled to WebAssembly and optimized for small size.\n\nThis library aims to provide relatively low-level, yet simple to use API to Reed-Solomon erasure coding.\nLibrary works both in modern browsers and Node.js environment with TypeScript support.\n\n### How to install\n```bash\nnpm install @subspace/reed-solomon-erasure.wasm\n```\n\n### How to use\n```typescript\nimport {ReedSolomonErasure} from \"@subspace/reed-solomon-erasure.wasm\";\n\nconst reedSolomonErasure = await ReedSolomonErasure.fromCurrentDirectory();\nconst SHARD_SIZE = 4;\nconst DATA_SHARDS = 4;\nconst PARITY_SHARDS = 2;\n\nconst input = Uint8Array.of(\n    1, 2, 3, 4,\n    1, 2, 3, 4,\n    1, 2, 3, 4,\n    1, 2, 3, 4,\n);\n\nconst shards = new Uint8Array(SHARD_SIZE * (DATA_SHARDS + PARITY_SHARDS));\nshards.set(input.slice());\n\nconsole.log(\n    'Encoding success: expect 0, result',\n    reedSolomonErasure.encode(shards, DATA_SHARDS, PARITY_SHARDS),\n);\n\nconst corruptedShards = shards.slice();\ncorruptedShards.set([0, 0, 0, 0], 0);\ncorruptedShards.set([0, 0, 0, 0], SHARD_SIZE);\n\nconsole.log('Corrupted shards 0 and 1');\n\nconst result = reedSolomonErasure.reconstruct(\n    corruptedShards,\n    DATA_SHARDS,\n    PARITY_SHARDS,\n    [false, false, true, true, true, true],\n);\n\nconsole.log(\n    'Reconstructing corrupted data shards: expect 0, result',\n    result,\n);\nconsole.log(\n    'Original data shards:     ',\n    input.join(', '),\n);\nconsole.log(\n    'Reconstructed data shards:',\n    corruptedShards.slice(0, SHARD_SIZE * DATA_SHARDS).join(', '),\n);\n```\n\n### API\n\n#### ReedSolomonErasure.fromCurrentDirectory(): Promise<ReedSolomonErasure>\nStatic automagical method that will try to detect environment (Node.js or browser) and load *.wasm file from current directory\n\n#### ReedSolomonErasure.fromCurrentDirectory(source: Response): Promise<ReedSolomonErasure>\nStatic method for asynchronous instantiation, primarily in Browser environment, expects you to load WASM file with `fetch()`, usage example:\n```javascript\nfetch('https://domain.tld/path/to/reed_solomon_erasure_bg.wasm')\n    .then(ReedSolomonErasure.fromResponse)\n    .then((reedSolomonErasure) => {\n        // Use library here\n    })\n```\n\n#### ReedSolomonErasure.fromBytes(bytes: BufferSource): ReedSolomonErasure\nStatic method for synchronous instantiation, primarily in Node.js environment, usage example:\n```javascript\nconst reedSolomonErasure = ReedSolomonErasure.fromBytes(\n    require('fs').readFileSync(`/path/to/reed_solomon_erasure_bg.wasm`)\n);\n// Use library here\n```\n\n#### ReedSolomonErasure.encode(shards: Uint8Array, dataShards: number, parityShards: number): number\nTakes a contiguous array of bytes that contain space for `data_shards + parity_shards` shards with `data_shards` shards containing data and fills additional `parity_shards` with parity information that can be later used to reconstruct data in case of corruption.\n\nReturns one of `ReedSolomonErasure.RESULT_*` constants; if `ReedSolomonErasure.RESULT_OK` then parity shards were updated in `shards` in-place.\n\n#### ReedSolomonErasure.reconstruct(shards: Uint8Array, dataShards: number, parityShards: number, shardsAvailable: boolean[]): number\nTakes a contiguous array of bytes that contain `data_shards + parity_shards` shards and tries to reconstruct data shards if they are broken and whenever possible using information from `shards_available` (contains `data_shards + parity_shards` boolean values, each of which is either `true` if shard is not corrupted or `false` if it is).\n\nReturns one of `ReedSolomonErasure.RESULT_*` constants; if `ReedSolomonErasure.RESULT_OK` then data shards were reconstructed in `shards` in-place.\n\n#### Constants\nBelow constants are used to check the result of encoding/reconstruction:\n* `ReedSolomonErasure.RESULT_OK`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_FEW_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_MANY_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_FEW_DATA_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_MANY_DATA_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_FEW_PARITY_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_MANY_PARITY_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_FEW_BUFFER_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_MANY_BUFFER_SHARDS`\n* `ReedSolomonErasure.RESULT_ERROR_INCORRECT_SHARD_SIZE`\n* `ReedSolomonErasure.RESULT_ERROR_TOO_FEW_SHARDS_PRESENT`\n* `ReedSolomonErasure.RESULT_ERROR_EMPTY_SHARD`\n* `ReedSolomonErasure.RESULT_ERROR_INVALID_SHARD_FLAGS`\n* `ReedSolomonErasure.RESULT_ERROR_INVALID_INDEX`\n\n### Tests\nProject is covered with tests that ensure things work as expected and do not regress, run them with usual `npm test`.\n\n### License\nMIT, see license.txt\n","readmeFilename":"readme.md"}