Skip to content

Commit

Permalink
chore: add path option to initialize node
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhirn committed Sep 23, 2024
1 parent 96e993d commit eecb3ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test:dev": "vitest",
"format": "prettier --write \"**/*.{js,ts,tsx,json,css,yml,yaml}\"",
"format:check": "prettier --check \"**/*.{js,ts,tsx,json,css,yml,yaml}\"",
"check": "pnpm format:check && pnpm lint && pnpm typecheck"
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test"
},
"devDependencies": {
"@eslint/js": "9.11.0",
Expand Down
4 changes: 1 addition & 3 deletions src/argon2.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export default Argon2ModuleFactory;

declare function Argon2ModuleFactory(
overrides?: unknown
): Promise<Argon2Module>;
declare function Argon2ModuleFactory(overrides?: unknown): Promise<Argon2Module>;
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,12 @@ class Argon2 {
static initialize = async (overrides?: Partial<Argon2Module>): Promise<Argon2> =>
new Argon2(await init(overrides));

static initializeNode = async (overrides?: Partial<Argon2Module>): Promise<Argon2> => {
const path = resolve(import.meta.dirname, "./argon2.wasm");
const wasm = await readFile(path);
static initializeNode = async (
path?: string,
overrides?: Partial<Argon2Module>
): Promise<Argon2> => {
const wasmPath = path ?? resolve(import.meta.dirname, "./argon2.wasm");
const wasm = await readFile(wasmPath);

return this.initialize({
instantiateWasm: (imports, cb) => {
Expand Down

0 comments on commit eecb3ca

Please sign in to comment.