JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 28604
  • Score
    100M100P100Q136025F
  • License MIT

Check if a string of code requires a specified module by id

Package Exports

  • has-require

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (has-require) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

has-require Build Status

Check if a string of code requires a specified module by id.

Installing

$ npm install has-require

API

hasRequire(code, id) -> Boolean

Checks a string of code for a require(id), where id is an valid require input such as a package name or path.

hasRequire('require(\'foo\'', 'foo'); // => true

Checker

new hasRequire.Checker(code) -> checker

Constructs a new checker instance for a string of code, allowing you to performantly check many module ids without closures.

checker.has(id) -> Boolean

Checks whether the code passed to Checker requires the specified module id.