summaryrefslogtreecommitdiff
path: root/node_modules/thenify-all
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/thenify-all')
-rw-r--r--node_modules/thenify-all/History.md11
-rw-r--r--node_modules/thenify-all/LICENSE22
-rw-r--r--node_modules/thenify-all/README.md66
-rw-r--r--node_modules/thenify-all/index.js73
-rw-r--r--node_modules/thenify-all/package.json34
5 files changed, 206 insertions, 0 deletions
diff --git a/node_modules/thenify-all/History.md b/node_modules/thenify-all/History.md
new file mode 100644
index 0000000..16e378c
--- /dev/null
+++ b/node_modules/thenify-all/History.md
@@ -0,0 +1,11 @@
+
+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
diff --git a/node_modules/thenify-all/LICENSE b/node_modules/thenify-all/LICENSE
new file mode 100644
index 0000000..a7ae8ee
--- /dev/null
+++ b/node_modules/thenify-all/LICENSE
@@ -0,0 +1,22 @@
+
+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.
diff --git a/node_modules/thenify-all/README.md b/node_modules/thenify-all/README.md
new file mode 100644
index 0000000..8e7829e
--- /dev/null
+++ b/node_modules/thenify-all/README.md
@@ -0,0 +1,66 @@
+
+# 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/
diff --git a/node_modules/thenify-all/index.js b/node_modules/thenify-all/index.js
new file mode 100644
index 0000000..e0cc69c
--- /dev/null
+++ b/node_modules/thenify-all/index.js
@@ -0,0 +1,73 @@
+
+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
+}
diff --git a/node_modules/thenify-all/package.json b/node_modules/thenify-all/package.json
new file mode 100644
index 0000000..768800f
--- /dev/null
+++ b/node_modules/thenify-all/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "thenify-all",
+ "description": "Promisifies all the selected functions in an object",
+ "version": "1.6.0",
+ "author": "Jonathan Ong <me@jongleberry.com> (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"
+ }
+}