Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 3, 2024 via pnpm

es-module-lexer 0.9.3

Lexes ES modules returning their import/export metadata
Package summary
Share
0
issues
1
license
1
MIT
Package created
8 Aug 2019
Version published
7 Oct 2021
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
es-module-lexer@0.9.3
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of es-module-lexer 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does es-module-lexer do?

The es-module-lexer is a JavaScript library that focuses on lexing ES modules and returning their import/export metadata. It is primarily used in es-module-shims, and has been designed to be compact and rapid. The package uses an inlined Web Assembly for a very rapid analysis of ECMAScript module syntax. A useful comparison of its efficiency is that Angular 1 (720KiB) is completely parsed just in a fraction of time (5ms) as compared to over 100ms taken by Acorn, which is considered to be one of the fastest JavaScript parsers.

How do you use es-module-lexer?

To use this library, you first need to install it via the npm package manager using npm install es-module-lexer. The usage varies depending on whether you're working with CommonJS or an ES module.

For CommonJS, the code looks like:

const { init, parse } = require('es-module-lexer');

(async () => {
  await init;

  const source = 'export var p = 5';
  const [imports, exports] = parse(source);
  
  // Returns "p"
  source.slice(exports[0].s, exports[0].e);
  // Returns "p"
  source.slice(exports[0].ls, exports[0].le);
})();

For an ES module version, the sample usage code can be like the following:

import { init, parse } from 'es-module-lexer';

(async () => {
  await init;

  const source = `...`; // put your source here

  const [imports, exports] = parse(source, 'optional-sourcename');

  // Here, you can manipulate the parsed imports and exports
})();

Where are the es-module-lexer docs?

The documentation for the es-module-lexer can be found in the README file of its GitHub repository. As the repository is hosted at https://github.com/guybedford/es-module-lexer, you can find the README at the root of this project. The README provides a comprehensive insight into the usage, environment support, grammar support, and other details related to the es-module-lexer package. This README serves as the primary source of documentation for the package.