# is-require

> Tests whether an JavaScript AST node is likely to be a valid `require` call.

Latest version **0.0.1** (published 2014-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-require
pnpm add is-require
yarn add is-require
bun add is-require
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2014-06-27 |
| First published | 2014-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | require, ast, static, analysis, helper, call, function |

## Links

- npm: https://www.npmjs.com/package/is-require
- Repository: https://github.com/hughsk/is-require
- Issues: https://github.com/hughsk/is-require/issues
- npm.io page: https://npm.io/package/is-require

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2014-06-27
- 0.0.0 — 2014-02-06

## README

# is-require [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/is-require&title=is-require&description=hughsk/is-require%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #

Tests whether an JavaScript AST node is likely to be a valid `require` call.
Mostly for convenience, seeing as I've had to copy/paste it a few times now.

## Usage ##

[![is-require](https://nodei.co/npm/is-require.png?mini=true)](https://nodei.co/npm/is-require)

### `isRequire = require('is-require')([name])` ###

Returns a function which tests AST nodes for `require` calls. You can supply
your own function name to `name` to use something other than require.

### `isRequire(node)` ###

Tests an AST node to see if it is a `require` call.

``` javascript
var isImports = require('is-require')('imports')
var isRequire = require('is-require')()
var esprima = require('esprima')
var astw = require('astw')
var fs = require('fs')

var src = fs.readFileSync('some-file.js', 'utf8')
var ast = esprima.parse(src)
var walk = astw(ast)

walk(function(node) {
  if (!isRequire(node)) return
  // do things...
})

walk(function(node) {
  if (!isImports(node)) return
  // do things...
})
```

## License ##

MIT. See [LICENSE.md](http://github.com/hughsk/is-require/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/is-require · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
