Skip to content

Commit

Permalink
problem: text-encode and sha3 are required when using
Browse files Browse the repository at this point in the history
  • Loading branch information
splix committed Jul 27, 2020
1 parent 8d6ea4d commit e386fb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/hashicon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@
"node": ">=8"
},
"dependencies": {
"@stablelib/blake2s": "^1.0.0"
"@stablelib/blake2s": "^1.0.0",
"js-sha3": "^0.8.0",
"text-encoding": "^0.7.0"
},
"devDependencies": {
"js-sha3": "^0.8.0",
"typescript": "^3.9.6",
"rimraf": "^2.6.3",
"jest": "24.8.0",
"@types/jest": "24.0.13",
"@types/text-encoding": "0.0.35",
"ts-jest": "24.0.2",
"jest-serial-runner": "1.1.0",
"@storybook/html": "^5.3.19",
Expand Down
5 changes: 3 additions & 2 deletions packages/hashicon/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Params, DefaultParams} from './params';
import {deepMerge} from './utils';
import {keccak256} from 'js-sha3';
import {BLAKE2s} from '@stablelib/blake2s';
import {TextEncoder} from 'text-encoding';

export {Params, HasherType} from './params';

Expand Down Expand Up @@ -32,9 +33,9 @@ export function hashicon(hash: string, options: number | Partial<Params> = {}):
const params: Params = deepMerge(DefaultParams, extraParams);
let result;

if (params.hasher == "blake2") {
if (params.hasher === "blake2") {
result = new Uint16Array(hashBlake2(hash));
} else if (params.hasher == "legacy" || params.hasher == "keccak") {
} else if (params.hasher === "legacy" || params.hasher === "keccak") {
result = new Uint16Array(hashKeccak(hash));
} else {
throw Error("Unsupported hasher: " + params.hasher)
Expand Down

0 comments on commit e386fb3

Please sign in to comment.