JavaScript generic ASN.1 parser (mirror)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve ESM usage examples.

+19 -2
+19 -2
README.md
··· 26 26 A submodule of this package can also be imported: 27 27 28 28 ```js 29 - import { Hex } from '@lapo/asn1js/hex'; 29 + import { Hex } from '@lapo/asn1js/hex.js'; 30 + ``` 31 + 32 + Once [`require(esm)` gets released](https://joyeecheung.github.io/blog/2024/03/18/require-esm-in-node-js/) (probably in Node 22) it will be possible to `require` it normally: 33 + 34 + ```js 35 + const ASN1 = require('@lapo/asn1js'); 36 + const Hex = require('@lapo/asn1js/hex.js'); 37 + console.log(ASN1.decode(Hex.decode('06032B6570')).content()); 30 38 ``` 31 39 32 - Unfortunately until [`require(esm)` gets released](https://joyeecheung.github.io/blog/2024/03/18/require-esm-in-node-js/) it is necessary to use async `import()` when used from CommonJS (legacy NodeJS) code. 40 + Until then, it is necessary to use async `import()` when used from CommonJS (legacy NodeJS) code: 41 + 42 + ```js 43 + async function main() { 44 + const { ASN1 } = await import('@lapo/asn1js'); 45 + const { Hex } = await import('@lapo/asn1js/hex.js'); 46 + console.log(ASN1.decode(Hex.decode('06032B6570')).content()); 47 + } 48 + main(); 49 + ``` 33 50 34 51 Usage on the web 35 52 --------------------