UNPKG

motion

Version:

motion - moving development forward

89 lines (88 loc) 4.78 kB
{ "_args": [ [ "pify@https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "pify@>=2.0.0 <3.0.0", "_id": "pify@2.3.0", "_inCache": true, "_location": "/pify", "_phantomChildren": {}, "_requested": { "name": "pify", "raw": "pify@https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "rawSpec": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "scope": null, "spec": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "type": "remote" }, "_requiredBy": [ "/globby", "/load-json-file", "/path-type" ], "_resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "_shasum": "ed141a6ac043a849ea588498e7dca8b15330e90c", "_shrinkwrap": null, "_spec": "pify@https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "email": "sindresorhus@gmail.com", "name": "Sindre Sorhus", "url": "sindresorhus.com" }, "bugs": { "url": "https://github.com/sindresorhus/pify/issues" }, "dependencies": {}, "description": "Promisify a callback-style function", "devDependencies": { "ava": "*", "pinkie-promise": "^1.0.0", "v8-natives": "0.0.2", "xo": "*" }, "engines": { "node": ">=0.10.0" }, "files": [ "index.js" ], "homepage": "https://github.com/sindresorhus/pify#readme", "keywords": [ "async", "bind", "callback", "cb", "convert", "denodeify", "denodify", "es2015", "node", "promise", "promises", "promisify", "then", "thenify", "to", "transform", "wrap", "wrapper" ], "license": "MIT", "name": "pify", "optionalDependencies": {}, "readme": "# pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify)\n\n> Promisify a callback-style function\n\n\n## Install\n\n```\n$ npm install --save pify\n```\n\n\n## Usage\n\n```js\nconst fs = require('fs');\nconst pify = require('pify');\n\n// promisify a single function\n\npify(fs.readFile)('package.json', 'utf8').then(data => {\n\tconsole.log(JSON.parse(data).name);\n\t//=> 'pify'\n});\n\n// or promisify all methods in a module\n\npify(fs).readFile('package.json', 'utf8').then(data => {\n\tconsole.log(JSON.parse(data).name);\n\t//=> 'pify'\n});\n```\n\n\n## API\n\n### pify(input, [promiseModule], [options])\n\nReturns a promise wrapped version of the supplied function or module.\n\n#### input\n\nType: `function`, `object`\n\nCallback-style function or module whose methods you want to promisify.\n\n#### promiseModule\n\nType: `function`\n\nCustom promise module to use instead of the native one.\n\nCheck out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.\n\n#### options\n\n##### multiArgs\n\nType: `boolean` \nDefault: `false`\n\nBy default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument.\n\n```js\nconst request = require('request');\nconst pify = require('pify');\n\npify(request, {multiArgs: true})('https://sindresorhus.com').then(result => {\n\tconst [httpResponse, body] = result;\n});\n```\n\n##### include\n\nType: `array` of (`string`|`regex`)\n\nMethods in a module to promisify. Remaining methods will be left untouched.\n\n##### exclude\n\nType: `array` of (`string`|`regex`) \nDefault: `[/.+Sync$/]`\n\nMethods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default.\n\n##### excludeMain\n\nType: `boolean` \nDefault: `false`\n\nBy default, if given module is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module.\n\n```js\nconst pify = require('pify');\n\nfunction fn() {\n\treturn true;\n}\n\nfn.method = (data, callback) => {\n\tsetImmediate(() => {\n\t\tcallback(data, null);\n\t});\n};\n\n// promisify methods but not fn()\nconst promiseFn = pify(fn, {excludeMain: true});\n\nif (promiseFn()) {\n\tpromiseFn.method('hi').then(data => {\n\t\tconsole.log(data);\n\t});\n}\n```\n\n\n## License\n\nMIT © [Sindre Sorhus](http://sindresorhus.com)\n", "readmeFilename": "readme.md", "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/pify.git" }, "scripts": { "optimization-test": "node --allow-natives-syntax optimization-test.js", "test": "xo && ava && npm run optimization-test" }, "version": "2.3.0" }