pax_global_header00006660000000000000000000000064124542576500014524gustar00rootroot0000000000000052 comment=f436113d8076adb9138c222a61689acdef6f6bd9 thenify-all-1.6.0/000077500000000000000000000000001245425765000137445ustar00rootroot00000000000000thenify-all-1.6.0/.gitignore000066400000000000000000000000561245425765000157350ustar00rootroot00000000000000 .DS_Store* *.log *.gz node_modules coverage thenify-all-1.6.0/.travis.yml000066400000000000000000000002521245425765000160540ustar00rootroot00000000000000node_js: - "0.8" - "0.10" - "0.11" language: node_js script: "npm run-script test-travis" after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" thenify-all-1.6.0/History.md000066400000000000000000000002641245425765000157310ustar00rootroot00000000000000 1.6.0 / 2015-01-11 ================== * feat: exports thenify * support node 0.8+ 1.5.0 / 2015-01-09 ================== * feat: support backward compatible with callback thenify-all-1.6.0/LICENSE000066400000000000000000000021131245425765000147460ustar00rootroot00000000000000 The MIT License (MIT) Copyright (c) 2014 Jonathan Ong me@jongleberry.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. thenify-all-1.6.0/README.md000066400000000000000000000047211245425765000152270ustar00rootroot00000000000000 # thenify-all [![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] [![Gittip][gittip-image]][gittip-url] Promisifies all the selected functions in an object. ```js var thenifyAll = require('thenify-all'); var fs = thenifyAll(require('fs'), {}, [ 'readFile', 'writeFile', ]); fs.readFile(__filename).then(function (buffer) { console.log(buffer.toString()); }); ``` ## API ### var obj = thenifyAll(source, [obj], [methods]) Promisifies all the selected functions in an object. - `source` - the source object for the async functions - `obj` - the destination to set all the promisified methods - `methods` - an array of method names of `source` ### var obj = thenifyAll.withCallback(source, [obj], [methods]) Promisifies all the selected functions in an object and backward compatible with callback. - `source` - the source object for the async functions - `obj` - the destination to set all the promisified methods - `methods` - an array of method names of `source` ### thenifyAll.thenify Exports [thenify](https://github.com/thenables/thenify) this package uses. [gitter-image]: https://badges.gitter.im/thenables/thenify-all.png [gitter-url]: https://gitter.im/thenables/thenify-all [npm-image]: https://img.shields.io/npm/v/thenify-all.svg?style=flat-square [npm-url]: https://npmjs.org/package/thenify-all [github-tag]: http://img.shields.io/github/tag/thenables/thenify-all.svg?style=flat-square [github-url]: https://github.com/thenables/thenify-all/tags [travis-image]: https://img.shields.io/travis/thenables/thenify-all.svg?style=flat-square [travis-url]: https://travis-ci.org/thenables/thenify-all [coveralls-image]: https://img.shields.io/coveralls/thenables/thenify-all.svg?style=flat-square [coveralls-url]: https://coveralls.io/r/thenables/thenify-all [david-image]: http://img.shields.io/david/thenables/thenify-all.svg?style=flat-square [david-url]: https://david-dm.org/thenables/thenify-all [license-image]: http://img.shields.io/npm/l/thenify-all.svg?style=flat-square [license-url]: LICENSE [downloads-image]: http://img.shields.io/npm/dm/thenify-all.svg?style=flat-square [downloads-url]: https://npmjs.org/package/thenify-all [gittip-image]: https://img.shields.io/gratipay/jonathanong.svg?style=flat-square [gittip-url]: https://gratipay.com/jonathanong/ thenify-all-1.6.0/index.js000066400000000000000000000037211245425765000154140ustar00rootroot00000000000000 var thenify = require('thenify') module.exports = thenifyAll thenifyAll.withCallback = withCallback thenifyAll.thenify = thenify /** * Promisifies all the selected functions in an object. * * @param {Object} source the source object for the async functions * @param {Object} [destination] the destination to set all the promisified methods * @param {Array} [methods] an array of method names of `source` * @return {Object} * @api public */ function thenifyAll(source, destination, methods) { return promisifyAll(source, destination, methods, thenify) } /** * Promisifies all the selected functions in an object and backward compatible with callback. * * @param {Object} source the source object for the async functions * @param {Object} [destination] the destination to set all the promisified methods * @param {Array} [methods] an array of method names of `source` * @return {Object} * @api public */ function withCallback(source, destination, methods) { return promisifyAll(source, destination, methods, thenify.withCallback) } function promisifyAll(source, destination, methods, promisify) { if (!destination) { destination = {}; methods = Object.keys(source) } if (Array.isArray(destination)) { methods = destination destination = {} } if (!methods) { methods = Object.keys(source) } if (typeof source === 'function') destination = promisify(source) methods.forEach(function (name) { // promisify only if it's a function if (typeof source[name] === 'function') destination[name] = promisify(source[name]) }) // proxy the rest Object.keys(source).forEach(function (name) { if (deprecated(source, name)) return if (destination[name]) return destination[name] = source[name] }) return destination } function deprecated(source, name) { var desc = Object.getOwnPropertyDescriptor(source, name) if (!desc || !desc.get) return false if (desc.get.name === 'deprecated') return true return false } thenify-all-1.6.0/package.json000066400000000000000000000014311245425765000162310ustar00rootroot00000000000000{ "name": "thenify-all", "description": "Promisifies all the selected functions in an object", "version": "1.6.0", "author": "Jonathan Ong (http://jongleberry.com)", "license": "MIT", "repository": "thenables/thenify-all", "dependencies": { "thenify": ">= 3.1.0 < 4" }, "devDependencies": { "bluebird": "2", "istanbul": "0", "mocha": "2" }, "scripts": { "test": "mocha --reporter spec", "test-cov": "istanbul cover node_modules/.bin/_mocha -- --reporter dot", "test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter dot" }, "keywords": [ "promisify", "promise", "thenify", "then", "es6" ], "files": [ "index.js" ], "engines": { "node": ">=0.8" } } thenify-all-1.6.0/test/000077500000000000000000000000001245425765000147235ustar00rootroot00000000000000thenify-all-1.6.0/test/test.js000066400000000000000000000040051245425765000162370ustar00rootroot00000000000000 var assert = require('assert') var thenify = require('..') it('thenifyAll(fs, {}, ["readFile"])', function () { var fs = thenify(require('fs'), {}, [ 'readFile', ]) return fs.readFile(__filename, 'utf8').then(function (string) { assert(~string.indexOf('kasjdflasjkdflajsdfklajs dajsdfakls;dfjal;ksdfj akls;dfj als;kdfj asdf')) }) }) it('thenifyAll(fs, ["readFile"])', function () { var fs = thenify(require('fs'), [ 'readFile', ]) return fs.readFile(__filename, 'utf8').then(function (string) { assert(~string.indexOf('kasjdflasjkdflajsdfklajs dajsdfakls;dfjal;ksdfj akls;dfj als;kdfj asdf')) }) }) it('thenifyAll(fs)', function () { var fs = thenify(require('fs')) return fs.readFile(__filename, 'utf8').then(function (string) { assert(~string.indexOf('kasjdflasjkdflajsdfklajs dajsdfakls;dfjal;ksdfj akls;dfj als;kdfj asdf')) return fs.stat(__filename) }).then(function (stat) { assert(stat.size, fs.statSync(__filename).size) }) }) it('thenifyAll(fs, destination)', function () { var fs = {}; thenify(require('fs'), fs) return fs.readFile(__filename, 'utf8').then(function (string) { assert(~string.indexOf('kasjdflasjkdflajsdfklajs dajsdfakls;dfjal;ksdfj akls;dfj als;kdfj asdf')) return fs.stat(__filename) }).then(function (stat) { assert(stat.size, fs.statSync(__filename).size) }) }) it('thenifyAll.withCallback(fs, {}, ["readFile"]) as promise', function () { var fs = thenify.withCallback(require('fs'), {}, [ 'readFile', ]) return fs.readFile(__filename, 'utf8').then(function (string) { assert(~string.indexOf('kasjdflasjkdflajsdfklajs dajsdfakls;dfjal;ksdfj akls;dfj als;kdfj asdf')) }) }) it('thenifyAll.withCallback(fs, {}, ["readFile"]) as callback', function (done) { var fs = thenify.withCallback(require('fs'), {}, [ 'readFile', ]) return fs.readFile(__filename, 'utf8', function (err, string) { assert(~string.indexOf('kasjdflasjkdflajsdfklajs dajsdfakls;dfjal;ksdfj akls;dfj als;kdfj asdf')) done(err) }) })