112 lines
6.6 KiB
JSON
112 lines
6.6 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "thenify@>= 3.1.0 < 4",
|
|
"scope": null,
|
|
"escapedName": "thenify",
|
|
"name": "thenify",
|
|
"rawSpec": ">= 3.1.0 < 4",
|
|
"spec": ">=3.1.0 <4.0.0",
|
|
"type": "range"
|
|
},
|
|
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/thenify-all"
|
|
]
|
|
],
|
|
"_from": "thenify@>=3.1.0 <4.0.0",
|
|
"_id": "thenify@3.3.0",
|
|
"_inCache": true,
|
|
"_location": "/thenify",
|
|
"_nodeVersion": "6.10.2",
|
|
"_npmOperationalInternal": {
|
|
"host": "packages-18-east.internal.npmjs.com",
|
|
"tmp": "tmp/thenify-3.3.0.tgz_1495187910351_0.656304276548326"
|
|
},
|
|
"_npmUser": {
|
|
"name": "dead_horse",
|
|
"email": "dead_horse@qq.com"
|
|
},
|
|
"_npmVersion": "3.10.3",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "thenify@>= 3.1.0 < 4",
|
|
"scope": null,
|
|
"escapedName": "thenify",
|
|
"name": "thenify",
|
|
"rawSpec": ">= 3.1.0 < 4",
|
|
"spec": ">=3.1.0 <4.0.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/thenify-all"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz",
|
|
"_shasum": "e69e38a1babe969b0108207978b9f62b88604839",
|
|
"_shrinkwrap": null,
|
|
"_spec": "thenify@>= 3.1.0 < 4",
|
|
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/thenify-all",
|
|
"author": {
|
|
"name": "Jonathan Ong",
|
|
"email": "me@jongleberry.com",
|
|
"url": "http://jongleberry.com"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/thenables/thenify/issues"
|
|
},
|
|
"dependencies": {
|
|
"any-promise": "^1.0.0"
|
|
},
|
|
"description": "Promisify a callback-based function",
|
|
"devDependencies": {
|
|
"bluebird": "^3.1.1",
|
|
"istanbul": "^0.4.0",
|
|
"mocha": "^3.0.2"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "e69e38a1babe969b0108207978b9f62b88604839",
|
|
"tarball": "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz"
|
|
},
|
|
"files": [
|
|
"index.js"
|
|
],
|
|
"gitHead": "aa21cfb64f47238c764d258d0faf7366a8487e36",
|
|
"homepage": "https://github.com/thenables/thenify#readme",
|
|
"keywords": [
|
|
"promisify",
|
|
"promise",
|
|
"thenify",
|
|
"then",
|
|
"es6"
|
|
],
|
|
"license": "MIT",
|
|
"maintainers": [
|
|
{
|
|
"name": "jongleberry",
|
|
"email": "jonathanrichardong@gmail.com"
|
|
},
|
|
{
|
|
"name": "dead-horse",
|
|
"email": "dead_horse@qq.com"
|
|
},
|
|
{
|
|
"name": "dead_horse",
|
|
"email": "dead_horse@qq.com"
|
|
}
|
|
],
|
|
"name": "thenify",
|
|
"optionalDependencies": {},
|
|
"readme": "\n# thenify\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Dependency Status][david-image]][david-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\nPromisify a callback-based function using [`any-promise`](https://github.com/kevinbeaty/any-promise).\n\n- Preserves function names\n- Uses a native promise implementation if available and tries to fall back to a promise implementation such as `bluebird`\n- Converts multiple arguments from the callback into an `Array`, also support change the behavior by `options.multiArgs`\n- Resulting function never deoptimizes\n- Supports both callback and promise style\n\nAn added benefit is that `throw`n errors in that async function will be caught by the promise!\n\n## API\n\n### fn = thenify(fn, options)\n\nPromisifies a function.\n\n### Options\n\n`options` are optional.\n\n- `options.withCallback` - support both callback and promise style, default to `false`.\n- `options.multiArgs` - change the behavior when callback have multiple arguments. default to `true`.\n - `true` - converts multiple arguments to an array\n - `false`- always use the first argument\n - `Array` - converts multiple arguments to an object with keys provided in `options.multiArgs`\n\n- Turn async functions into promises\n\n```js\nvar thenify = require('thenify');\n\nvar somethingAsync = thenify(function somethingAsync(a, b, c, callback) {\n callback(null, a, b, c);\n});\n```\n\n- Backward compatible with callback\n\n```js\nvar thenify = require('thenify');\n\nvar somethingAsync = thenify(function somethingAsync(a, b, c, callback) {\n callback(null, a, b, c);\n}, { withCallback: true });\n\n// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);\n// somethingAsync(a, b, c, function () {});\n```\n\nor use `thenify.withCallback()`\n\n```js\nvar thenify = require('thenify').withCallback;\n\nvar somethingAsync = thenify(function somethingAsync(a, b, c, callback) {\n callback(null, a, b, c);\n});\n\n// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);\n// somethingAsync(a, b, c, function () {});\n```\n\n- Always return the first argument in callback\n\n```js\nvar thenify = require('thenify');\n\nvar promise = thenify(function (callback) {\n callback(null, 1, 2, 3);\n}, { multiArgs: false });\n\n// promise().then(function onFulfilled(value) {\n// assert.equal(value, 1);\n// });\n```\n\n- Converts callback arguments to an object\n\n```js\nvar thenify = require('thenify');\n\nvar promise = thenify(function (callback) {\n callback(null, 1, 2, 3);\n}, { multiArgs: [ 'one', 'tow', 'three' ] });\n\n// promise().then(function onFulfilled(value) {\n// assert.deepEqual(value, {\n// one: 1,\n// tow: 2,\n// three: 3\n// });\n// });\n```\n\n[gitter-image]: https://badges.gitter.im/thenables/thenify.png\n[gitter-url]: https://gitter.im/thenables/thenify\n[npm-image]: https://img.shields.io/npm/v/thenify.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/thenify\n[github-tag]: http://img.shields.io/github/tag/thenables/thenify.svg?style=flat-square\n[github-url]: https://github.com/thenables/thenify/tags\n[travis-image]: https://img.shields.io/travis/thenables/thenify.svg?style=flat-square\n[travis-url]: https://travis-ci.org/thenables/thenify\n[coveralls-image]: https://img.shields.io/coveralls/thenables/thenify.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/thenables/thenify\n[david-image]: http://img.shields.io/david/thenables/thenify.svg?style=flat-square\n[david-url]: https://david-dm.org/thenables/thenify\n[license-image]: http://img.shields.io/npm/l/thenify.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: http://img.shields.io/npm/dm/thenify.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/thenify\n",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/thenables/thenify.git"
|
|
},
|
|
"scripts": {
|
|
"test": "mocha --reporter spec",
|
|
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
|
|
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
|
|
},
|
|
"version": "3.3.0"
|
|
}
|