Description
Is your feature request related to a problem? Please describe.
Right now js-id only works in node due to 2 imports:
import crypto from 'crypto';
import { performance } from 'perf_hooks';
Both of these are part of ES standards:
- https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API
- https://developer.mozilla.org/en-US/docs/Web/API/Performance
Therefore it should be possible to use the JS APIs without importing node specific libraries.
Describe the solution you'd like
Attempt to use top-level await to create modules that work in nodejs and general JS platforms.
This was attempted already in:
- ID standardisation for all projects and domains #1 (comment)
- ID standardisation for all projects and domains #1 (comment)
This will require updating the ecosystem dependencies. It's quite experimental features.
Describe alternatives you've considered
One can also bundle a browser version of the script. However I've come to dislike this method because it introduces lots of dependencies and makes it more difficult to bundle at the end. IMO bundling should only occur at the application point, not at the library. The library itself should be made generic. This reduces maintenance overhead.
Additional context
See #1 for the development of this library.