Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goto-bus-stop/estree-is-require
check if an AST node is a call to require()
https://github.com/goto-bus-stop/estree-is-require
Last synced: 27 days ago
JSON representation
check if an AST node is a call to require()
- Host: GitHub
- URL: https://github.com/goto-bus-stop/estree-is-require
- Owner: goto-bus-stop
- License: other
- Created: 2018-01-11T16:09:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-17T16:23:16.000Z (over 4 years ago)
- Last Synced: 2024-10-14T03:30:16.244Z (about 1 month ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# estree-is-require
check if an AST node is a valid `require()` call
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url][npm-image]: https://img.shields.io/npm/v/estree-is-require.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/estree-is-require
[travis-image]: https://img.shields.io/travis/goto-bus-stop/estree-is-require.svg?style=flat-square
[travis-url]: https://travis-ci.org/goto-bus-stop/estree-is-require
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard## Install
```
npm install estree-is-require
```## Usage
```js
var isRequire = require('estree-is-require')var node = parse('function a () {}')
isRequire(node) // false
var node = parse('require("abc")')
isRequire(node) // true
isRequire(node, 'abc') // true
isRequire(node, 'xyz') // false
var node = parse('require(10)')
isRequire(node, 10) // true
```Also see the [tests](./test.js) for more examples.
## API
### `isRequire(node, source)`
Check if `node` is a call to `require`.
If `source` is given, also check if the first argument to `require` matches it.## License
[Apache-2.0](LICENSE.md)