# module-interop

> ES6 module interop

Latest version **1.2.0** (published 2018-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install module-interop
pnpm add module-interop
yarn add module-interop
bun add module-interop
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2018-04-18 |
| First published | 2018-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lee Benson |
| Maintainers | leebenson |
| Keywords | es6, module, interop |

## Links

- npm: https://www.npmjs.com/package/module-interop
- Repository: https://github.com/leebenson/module-interop
- Homepage: https://github.com/leebenson/module-interop#readme
- Issues: https://github.com/leebenson/module-interop/issues
- npm.io page: https://npm.io/package/module-interop

## Recent versions

- 1.2.0 (latest) — 2018-04-18
- 1.1.0 — 2018-04-18
- 1.0.0 — 2018-04-18

## README

# Get underlying CommonJS/ES6 module with `require()`

Simple function to determine whether a `require()`'d object is an ES6 module, and return its `.default` implementation if so.

Written in Typescript.

## How to use

Simply wrap any call to `require` to get the underlying module:

**meaningOfLife.ts**
```ts
const meaningOfLife = 42;

export default meaningOfLife;
```

```ts
import moduleInterop from "module-interop";

// Doesn't matter if `require` uses `module.exports` or ES6 exports
const meaningOfLife = moduleInterop(require("./meaningOfLife.ts")); // 42
```

## License

MIT

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