ethereumjs / keythereum

Create, import and export Ethereum keys
MIT License
609 stars 163 forks source link

browserifiable version #27

Closed fanatid closed 7 years ago

fanatid commented 7 years ago

https://github.com/ethereumjs/keythereum/blob/0.4.7/index.js#L8-L11

tinybike commented 7 years ago

Read a bit about this today and it seems there is not a consensus on the best way to detect Node.js vs browser environment. Apparently browserify and webpack are the edge cases that create complications. I thought this discussion was good -- conclusion was that the "right" way to do this is:

typeof process !== "undefined" && process.nextTick && !process.browser
fanatid commented 7 years ago

nextTick is defined in process for browser

tinybike commented 7 years ago

Well, process.nextTick is defined if you require('process'), but the browser does not normally have process.nextTick (or process) defined.