Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use it in NodeJS? #9

Open
croensch opened this issue Feb 23, 2019 · 0 comments
Open

How to use it in NodeJS? #9

croensch opened this issue Feb 23, 2019 · 0 comments

Comments

@croensch
Copy link

croensch commented Feb 23, 2019

Hi, i'm not understanding why i can't use it in NodeJS (an express app). The module gets exported as a promise? VSCode lets me jump to the .d.ts file...

// UnhandledPromiseRejectionWarning: Error: Not supported
var BLAKE2s = import('blake2s-js');

var gen = {
    hash: function(msg, key) {
        var hash;
        // TypeError: BLAKE2s is not a constructor
        hash = new BLAKE2s(32, key);
        hash.update(msg);
        return hash.digest();
    }
};

module.exports = gen;

Solution: use require() not import().
Leaving open because i still need to do some with TextEncoder/TextDecoder and/or Uint8Array...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant