# mz

> modernize node.js to current ECMAScript standards

Latest version **2.7.0** (published 2017-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install mz
pnpm add mz
yarn add mz
bun add mz
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.7.0 |
| Published | 2017-09-13 |
| First published | 2014-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/mz) |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1369 |
| Author | Jonathan Ong |
| Maintainers | evancarroll, coderhaoxin, rstacruz, linusu, dead_horse, dead-horse, jongleberry, swatinem |
| Keywords | promisify, promise, thenify, then, es6 |

## Links

- npm: https://www.npmjs.com/package/mz
- Repository: https://github.com/normalize/mz
- Homepage: https://github.com/normalize/mz#readme
- Issues: https://github.com/normalize/mz/issues
- npm.io page: https://npm.io/package/mz

## Dependencies (3)

- [any-promise](https://npm.io/package/any-promise.md) ^1.0.0
- [thenify-all](https://npm.io/package/thenify-all.md) ^1.0.0
- [object-assign](https://npm.io/package/object-assign.md) ^4.0.1

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 2.7.0 (latest) — 2017-09-13
- 2.6.0 — 2016-11-22
- 2.5.0 — 2016-11-04
- 2.4.0 — 2016-03-24
- 2.3.1 — 2016-02-01
- 2.3.0 — 2016-01-30
- 2.2.0 — 2016-01-24
- 2.1.0 — 2015-10-15
- 2.0.0 — 2015-05-25
- 1.3.0 — 2015-02-11
- 1.2.1 — 2014-12-27
- 1.2.0 — 2014-12-17
- 1.1.0 — 2014-11-14
- 1.0.2 — 2014-10-16
- 1.0.1 — 2014-08-18
- … 7 more at https://npm.io/package/mz/versions

## README

# MZ - Modernize node.js

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

Modernize node.js to current ECMAScript specifications!
node.js will not update their API to ES6+ [for a while](https://github.com/joyent/node/issues/7549).
This library is a wrapper for various aspects of node.js' API.

## Installation and Usage

Set `mz` as a dependency and install it.

```bash
npm i mz
```

Then prefix the relevant `require()`s with `mz/`:

```js
var fs = require('mz/fs')

fs.exists(__filename).then(function (exists) {
  if (exists) // do something
})
```

With ES2017, this will allow you to use async functions cleanly with node's core API:

```js
const fs = require('mz/fs')


async function doSomething () {
  if (await fs.exists(__filename)) // do something
}
```

## Promisification

Many node methods are converted into promises.
Any properties that are deprecated or aren't asynchronous will simply be proxied.
The modules wrapped are:

- `child_process`
- `crypto`
- `dns`
- `fs` (uses `graceful-fs` if available)
- `readline`
- `zlib`

```js
var exec = require('mz/child_process').exec

exec('node --version').then(function (stdout) {
  console.log(stdout)
})
```

## Promise Engine

`mz` uses [`any-promise`](https://github.com/kevinbeaty/any-promise).

## FAQ

### Can I use this in production?

Yes, Node 4.x ships with stable promises support. For older engines,
you should probably install your own promise implementation and register it with
`require('any-promise/register')('bluebird')`.

### Will this make my app faster?

Nope, probably slower actually.

### Can I add more features?

Sure.
Open an issue.

Currently, the plans are to eventually support:

- New APIs in node.js that are not available in older versions of node
- ECMAScript7 Streams

[bluebird]: https://github.com/petkaantonov/bluebird

[npm-image]: https://img.shields.io/npm/v/mz.svg?style=flat-square
[npm-url]: https://npmjs.org/package/mz
[github-tag]: http://img.shields.io/github/tag/normalize/mz.svg?style=flat-square
[github-url]: https://github.com/normalize/mz/tags
[travis-image]: https://img.shields.io/travis/normalize/mz.svg?style=flat-square
[travis-url]: https://travis-ci.org/normalize/mz
[coveralls-image]: https://img.shields.io/coveralls/normalize/mz.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/normalize/mz?branch=master
[david-image]: http://img.shields.io/david/normalize/mz.svg?style=flat-square
[david-url]: https://david-dm.org/normalize/mz
[license-image]: http://img.shields.io/npm/l/mz.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/mz.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/mz

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