Socket
Socket
Sign inDemoInstall

mz

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mz - npm Package Compare versions

Comparing version 0.1.6 to 1.0.0

HISTORY.md

69

_promisify.js
var falsey = {
0: true,
false: true,
no: true,
nope: true
}
var promisify
try {
promisify = require('bluebird').promisify
} catch (_) {}
var bloob = process.env.MZ_BLUEBIRD
if (typeof Promise === 'undefined' || (bloob && !falsey[bloob])) {
// use bluebird
var promisify
try {
promisify = require('bluebird').promisify
} catch (err) {
throw new Error('please install bluebird!')
}
if (promisify) {
module.exports = function mz_promisify(name, fn) {
return promisify(fn)
}
module.exports.bluebird = true
} else if (typeof Promise === 'function') {
var makeCallback = function(resolve, reject) {
return function(err, value) {
if (err) {
reject(err)
} else {
var len = arguments.length
if (len > 2) {
var values = new Array(len - 1)
for (var i = 1; i < len; ++i) {
values[i - 1] = arguments[i]
}
resolve(values)
} else {
resolve(value)
}
}
}
} else {
if (typeof Promise !== 'function') {
console.error()
console.error('mz: a `Promise` implementation could not be found.')
console.error('mz: please use a version of node that has native Promises')
console.error('mz: or `npm i bluebird`')
console.error()
process.exit(1)
}

@@ -54,3 +33,23 @@

}
module.exports.bluebird = false
}
module.exports.bluebird = !!promisify
function makeCallback(resolve, reject) {
return function(err, value) {
if (err) {
reject(err)
} else {
var len = arguments.length
if (len > 2) {
var values = new Array(len - 1)
for (var i = 1; i < len; ++i) {
values[i - 1] = arguments[i]
}
resolve(values)
} else {
resolve(value)
}
}
}
}
{
"name": "mz",
"description": "modernize node.js to current ECMAScript standards",
"version": "0.1.6",
"version": "1.0.0",
"author": {

@@ -14,11 +14,8 @@ "name": "Jonathan Ong",

"devDependencies": {
"bluebird": "1",
"bluebird": "2",
"mocha": "1"
},
"scripts": {
"test": "mocha --harmony --reporter spec --bail; MZ_BLUEBIRD=1 mocha --reporter spec --bail"
},
"engines": {
"node": ">= 0.10"
"test": "mocha --reporter spec --bail"
}
}

@@ -57,11 +57,14 @@

If you're using node v0.11.13+,
the native v8 `Promise` is used.
Otherwise, __you must install [bluebird][bluebird] yourself__.
If you want to force this library to use [bluebird][bluebird], set the `MZ_BLUEBIRD` environmental variable:
## Promise Engine
```bash
export MZ_BLUEBIRD=1
```
If you've installed [bluebird][bluebird],
[bluebird][bluebird] will be used.
`mz` does not install [bluebird][bluebird] for you.
Otherwise, if you're using a node that has native v8 Promises (v0.11.13+),
then that will be used.
Otherwise, this library will crash the process and exit,
so you might as well install [bluebird][bluebird] as a dependency!
## FAQ

@@ -71,7 +74,8 @@

You may want to always use bluebird in production until v8 fixes and optimizes its `Promise` implementation.
If you do, you should probably install [bluebird][bluebird] as
native v8 promises are still pretty raw.
### Will this make my app faster?
Nope
Nope, probably slower actually.

@@ -78,0 +82,0 @@ ### Can I add more features?

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc