# async-require

> async module loader

Latest version **1.2.2** (published 2015-11-20) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2015-11-20 |
| First published | 2015-06-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | https://github.com/Jhorlin |
| Maintainers | jhorlin |
| Keywords | require, async, module |

## Links

- npm: https://www.npmjs.com/package/async-require
- Repository: https://github.com/Jhorlin/async-require
- Homepage: https://github.com/Jhorlin/async-require#readme
- Issues: https://github.com/Jhorlin/async-require/issues
- npm.io page: https://npm.io/package/async-require

## Dependencies (2)

- [bluebird](https://npm.io/package/bluebird.md) ^3.0.5
- [callsite](https://npm.io/package/callsite.md) ^1.0.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2015-11-20
- 1.2.1 — 2015-07-24
- 1.1.1 — 2015-07-20
- 1.1.0 — 2015-06-26
- 1.0.0 — 2015-06-25

## README

# async-require
[![Build Status](https://travis-ci.org/Jhorlin/async-require.svg?branch=master)](https://travis-ci.org/Jhorlin/async-require)
[![Coverage Status](https://coveralls.io/repos/Jhorlin/async-require/badge.svg)](https://coveralls.io/r/Jhorlin/async-require)
[![Dependency Status](https://david-dm.org/jhorlin/async-require.svg)](https://david-dm.org/jhorlin/async-require)
[![devDependency Status](https://david-dm.org/jhorlin/async-require/dev-status.svg)](https://david-dm.org/jhorlin/async-require#info=devDependencies)
    <a name="module_async-require"></a>
## async-require
asyncronous module loader

**Example**  
```js//ironically loading async-require using syncronaous require.var asyncRequire = require('async-require');```

* [async-require](#module_async-require)
  * [requireAsync(module)](#exp_module_async-require--requireAsync) ⇒ <code>Promise.&lt;(module\|Error)&gt;</code> ⏏
    * [~load - A promisified function that accepts a moduleId as an argument and returns a promise resolving in an object with a toString method such as a Buffer or a String.()](#module_async-require--requireAsync..load - A promisified function that accepts a moduleId as an argument and returns a promise resolving in an object with a toString method such as a Buffer or a String.)

<a name="exp_module_async-require--requireAsync"></a>
### requireAsync(module) ⇒ <code>Promise.&lt;(module\|Error)&gt;</code> ⏏
**Kind**: Exported function  

| Param | Type | Description |
| --- | --- | --- |
| module | <code>string</code> | the path to the module without a .js extension |

**Example**  
```js//load script myModule.jsasyncRequire('myModule').then(function(module){  //module has been exported});```
<a name="module_async-require--requireAsync..load - A promisified function that accepts a moduleId as an argument and returns a promise resolving in an object with a toString method such as a Buffer or a String."></a>
#### requireAsync~load - A promisified function that accepts a moduleId as an argument and returns a promise resolving in an object with a toString method such as a Buffer or a String.()
load is used by async-require to load the script. By default it load a file relative to the calling modulesimilar to how require works when loading module not installed through npm. Since this function is public you canset a new load method.

**Kind**: inner method of <code>[requireAsync](#exp_module_async-require--requireAsync)</code>  
**Access:** public  
**Example**  
load a script with request```jsvar asyncRequire = require('async-require'),    request = require('request'),    Promise = require('promise'),    //load must return a promise    get = Promise.promisify(request.get);    //overwrite the default load    asyncRequire.load = function(url){         //get the script         return get(url).spread(function(res, body){             //returrn only the body of the script             return body;         })    }```

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