├── .npmrc ├── .gitattributes ├── .travis.yml ├── test ├── mocha.opts └── index.js ├── .npmignore ├── dist └── index.html ├── CHANGELOG.md ├── .editorconfig ├── example.js ├── .gitignore ├── bower.json ├── .bumpedrc ├── index.js ├── LICENSE.md ├── package.json ├── gulpfile.coffee └── README.md /.npmrc: -------------------------------------------------------------------------------- 1 | unsafe-perm=true 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "stable" 4 | - "5" 5 | - "4" 6 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --require should 2 | --reporter spec 3 | --timeout 120000 4 | --slow 300 5 | --bail 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .project 3 | *.sublime-* 4 | .DS_Store 5 | *.seed 6 | *.log 7 | *.csv 8 | *.dat 9 | *.out 10 | *.pid 11 | *.swp 12 | *.swo 13 | node_modules 14 | coverage 15 | *.tgz 16 | *.xml 17 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | promise-async 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 0.1.0 (2016-01-18) 3 | 4 | 5 | * first commit ([9b5d686](https://github.com/kikobeats/promise-async/commit/9b5d686)) 6 | * Update ([ef3c9fe](https://github.com/kikobeats/promise-async/commit/ef3c9fe)) 7 | * Update build scripts ([4dbe80a](https://github.com/kikobeats/promise-async/commit/4dbe80a)) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | max_line_length = 80 13 | indent_brace_style = 1TBS 14 | spaces_around_operators = true 15 | quote_type = auto 16 | 17 | [package.json] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [*.md] 22 | trim_trailing_whitespace = false 23 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const async = require('.') 4 | 5 | async.waterfall([ 6 | function (callback) { 7 | callback(null, 'one', 'two') 8 | }, 9 | function (arg1, arg2, callback) { 10 | // arg1 now equals 'one' and arg2 now equals 'two' 11 | callback(null, 'three') 12 | }, 13 | function (arg1, callback) { 14 | // arg1 now equals 'three' 15 | callback(null, 'done') 16 | } 17 | ]).then(function (value) { 18 | console.log(value === 'done') 19 | }) 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ############################ 2 | # npm 3 | ############################ 4 | node_modules 5 | npm-debug.log 6 | 7 | 8 | ############################ 9 | # tmp, editor & OS files 10 | ############################ 11 | .tmp 12 | *.swo 13 | *.swp 14 | *.swn 15 | *.swm 16 | .DS_STORE 17 | *# 18 | *~ 19 | .idea 20 | nbproject 21 | 22 | 23 | ############################ 24 | # Tests 25 | ############################ 26 | testApp 27 | coverage 28 | 29 | 30 | ############################ 31 | # Other 32 | ############################ 33 | .node_history 34 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "promise-async", 3 | "description": "Promise bindings for async lib.", 4 | "homepage": "https://github.com/Kikobeats/promise-async", 5 | "version": "0.1.0", 6 | "main": "./dist/promise-async.js", 7 | "authors": [ 8 | { 9 | "email": "josefrancisco.verdu@gmail.com", 10 | "name": "Kiko Beats", 11 | "url": "https://github.com/Kikobeats" 12 | } 13 | ], 14 | "repository": "Kikobeats/promise-async", 15 | "bugs": { 16 | "url": "https://github.com/Kikobeats/promise-async/issues" 17 | }, 18 | "keywords": [ 19 | "async", 20 | "promise" 21 | ], 22 | "ignore": [ 23 | "**/.*", 24 | "bower_components", 25 | "node_modules", 26 | "test", 27 | "tests" 28 | ], 29 | "license": "MIT" 30 | } 31 | -------------------------------------------------------------------------------- /.bumpedrc: -------------------------------------------------------------------------------- 1 | files: [ 2 | 'package.json' 3 | 'bower.json' 4 | ] 5 | 6 | plugins: 7 | 8 | prerelease: 9 | 10 | 'Linting config files': 11 | plugin: 'bumped-finepack' 12 | 13 | postrelease: 14 | 15 | 'Generating CHANGELOG file': 16 | plugin: 'bumped-changelog' 17 | 18 | 'Commiting new version': 19 | plugin: 'bumped-terminal' 20 | command: 'git add CHANGELOG.md bower.json package.json dist && git commit -m "$newVersion releases"' 21 | 22 | 'Detecting problems before publish': 23 | plugin: 'bumped-terminal' 24 | command: 'git-dirty && npm run clean && npm test' 25 | 26 | 'Publishing tag at Github': 27 | plugin: 'bumped-terminal' 28 | command: 'git tag $newVersion && git push origin $newVersion --follow-tags' 29 | 30 | 'Publishing at NPM': 31 | plugin: 'bumped-terminal' 32 | command: 'npm publish' 33 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const pify = require('pify') 4 | const util = require('util') 5 | const async = require('async') 6 | 7 | const EXCLUDE_METHODS = [ 'apply', 'memoize', 'log', 'dir', 'noConflict' ] 8 | 9 | function remove (arr, element) { 10 | const index = arr.indexOf(element) 11 | index !== -1 && arr.splice(index, 1) 12 | } 13 | 14 | const methods = Object.keys(async) 15 | 16 | EXCLUDE_METHODS.forEach(function (exclude) { 17 | remove(methods, exclude) 18 | }) 19 | 20 | const asyncPromise = methods.reduce(function (accumulator, method) { 21 | accumulator[method] = pify(async[method]) 22 | return accumulator 23 | }, {}) 24 | 25 | module.exports = methods.reduce(function (accumulator, method) { 26 | accumulator[method] = (function () { 27 | const cb = arguments[arguments.length - 1] 28 | const proxy = util.isFunction(cb) ? async : asyncPromise 29 | return proxy[method] 30 | })() 31 | return accumulator 32 | }, {}) 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2016 Kiko Beats 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | /* global describe, it */ 2 | 3 | 'use strict' 4 | 5 | require('should') 6 | const async = require('..') 7 | 8 | describe('promise-async ::', function () { 9 | it('promise', function () { 10 | async.waterfall([ 11 | function (callback) { 12 | callback(null, 'one', 'two') 13 | }, 14 | function (arg1, arg2, callback) { 15 | // arg1 now equals 'one' and arg2 now equals 'two' 16 | callback(null, 'three') 17 | }, 18 | function (arg1, callback) { 19 | // arg1 now equals 'three' 20 | callback(null, 'done') 21 | } 22 | ]).should.be.finally.equal('done') 23 | }) 24 | 25 | it('callback', function (done) { 26 | async.waterfall([ 27 | function (callback) { 28 | callback(null, 'one', 'two') 29 | }, 30 | function (arg1, arg2, callback) { 31 | // arg1 now equals 'one' and arg2 now equals 'two' 32 | callback(null, 'three') 33 | }, 34 | function (arg1, callback) { 35 | // arg1 now equals 'three' 36 | callback(null, 'done') 37 | } 38 | ], function (err, value) { 39 | value.should.be.equal('done') 40 | done(err) 41 | }) 42 | }) 43 | }) 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "promise-async", 3 | "description": "Promise bindings for async lib.", 4 | "homepage": "https://github.com/Kikobeats/promise-async", 5 | "version": "0.1.0", 6 | "main": "./index.js", 7 | "author": { 8 | "email": "josefrancisco.verdu@gmail.com", 9 | "name": "Kiko Beats", 10 | "url": "https://github.com/Kikobeats" 11 | }, 12 | "repository": "Kikobeats/promise-async", 13 | "bugs": { 14 | "url": "https://github.com/Kikobeats/promise-async/issues" 15 | }, 16 | "keywords": [ 17 | "async", 18 | "promise" 19 | ], 20 | "dependencies": { 21 | "async": "~1.5.2", 22 | "pify": "~2.3.0" 23 | }, 24 | "devDependencies": { 25 | "browserify": "~13.0.0", 26 | "coffee-script": "~1.10.0", 27 | "coffeeify": "~2.0.1", 28 | "git-dirty": "~1.0.0", 29 | "gulp": "~3.9.0", 30 | "gulp-header": "~1.7.1", 31 | "gulp-uglify": "~1.5.1", 32 | "gulp-util": "~3.0.7", 33 | "mocha": "~2.3.4", 34 | "should": "~8.1.1", 35 | "standard": "~5.4.1", 36 | "vinyl-buffer": "~1.0.0", 37 | "vinyl-source-stream": "~1.1.0" 38 | }, 39 | "engines": { 40 | "node": ">= 4" 41 | }, 42 | "scripts": { 43 | "clean": "rm -rf node_modules", 44 | "lint": "standard lib", 45 | "pretest": "npm run lint", 46 | "test": "mocha" 47 | }, 48 | "license": "MIT" 49 | } 50 | -------------------------------------------------------------------------------- /gulpfile.coffee: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | # -- Dependencies -------------------------------------------------------------- 4 | 5 | gulp = require 'gulp' 6 | coffeeify = require 'coffeeify' 7 | gutil = require 'gulp-util' 8 | browserify = require 'browserify' 9 | header = require 'gulp-header' 10 | uglify = require 'gulp-uglify' 11 | buffer = require 'vinyl-buffer' 12 | pkg = require './package.json' 13 | source = require 'vinyl-source-stream' 14 | 15 | # -- Files --------------------------------------------------------------------- 16 | 17 | src = 18 | main: './index.js' 19 | 20 | module = 21 | filename : "#{pkg.name}.js" 22 | shortcut : "#{pkg.name}" 23 | dist : 'dist' 24 | 25 | banner = [ 26 | "/**" 27 | " * <%= pkg.name %> - <%= pkg.description %>" 28 | " * @version v<%= pkg.version %>" 29 | " * @link <%= pkg.homepage %>" 30 | " * @license <%= pkg.license %>" 31 | " */"].join("\n") 32 | 33 | # -- Tasks --------------------------------------------------------------------- 34 | 35 | gulp.task 'browserify', -> 36 | browserify extensions: ['.coffee', '.js'] 37 | .transform coffeeify, global: true 38 | .require(src.main, { expose: module.shortcut}) 39 | .ignore('coffee-script') 40 | .bundle().on('error', gutil.log) 41 | .pipe source module.filename 42 | .pipe buffer() 43 | .pipe uglify() 44 | .pipe header banner, pkg: pkg 45 | .pipe gulp.dest module.dist 46 | 47 | gulp.task 'default', -> 48 | gulp.start 'browserify' 49 | return 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # promise-async 2 | 3 | ![Last version](https://img.shields.io/github/tag/Kikobeats/promise-async.svg?style=flat-square) 4 | [![Build Status](http://img.shields.io/travis/Kikobeats/promise-async/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/promise-async) 5 | [![Dependency status](http://img.shields.io/david/Kikobeats/promise-async.svg?style=flat-square)](https://david-dm.org/Kikobeats/promise-async) 6 | [![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/promise-async.svg?style=flat-square)](https://david-dm.org/Kikobeats/promise-async#info=devDependencies) 7 | [![NPM Status](http://img.shields.io/npm/dm/promise-async.svg?style=flat-square)](https://www.npmjs.org/package/promise-async) 8 | [![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/Kikobeats) 9 | 10 | > Adds Promises bindings for async library. Works with callbacks as well. 11 | 12 | ## Install 13 | 14 | ```bash 15 | npm install promise-async --save 16 | ``` 17 | 18 | If you want to use in the browser (powered by [Browserify](http://browserify.org/)): 19 | 20 | ```bash 21 | bower install promise-async --save 22 | ``` 23 | 24 | and later link in your HTML: 25 | 26 | ```html 27 | 28 | ``` 29 | 30 | ## Usage 31 | 32 | ```js 33 | const async = require('promise-async') 34 | 35 | async.waterfall([ 36 | function (callback) { 37 | callback(null, 'one', 'two') 38 | }, 39 | function (arg1, arg2, callback) { 40 | // arg1 now equals 'one' and arg2 now equals 'two' 41 | callback(null, 'three') 42 | }, 43 | function (arg1, callback) { 44 | // arg1 now equals 'three' 45 | callback(null, 'done') 46 | } 47 | ]).then(function (value) { 48 | console.log(value === 'done') // => true 49 | }) 50 | ``` 51 | 52 | ## License 53 | 54 | MIT © [Kiko Beats](http://kikobeats.com) 55 | --------------------------------------------------------------------------------