Skip to content

Commit 3e8e9fd

Browse files
pdehaanphated
authored andcommitted
Build: Add eslint and jscs presets & update code
1 parent e1d3945 commit 3e8e9fd

File tree

14 files changed

+98
-119
lines changed

14 files changed

+98
-119
lines changed

.eslintrc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
11
{
2-
"rules": {
3-
"semi": [2, "always"],
4-
"quotes": [2, "single"],
5-
"strict": [2, "global"],
6-
"no-underscore-dangle": 0,
7-
"no-use-before-define": 0
8-
},
9-
"env": {
10-
"es6": true,
11-
"browser": true,
12-
"node": true
13-
}
2+
"extends": "gulp"
143
}

.jscsrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"preset": "gulp"
3+
}

.jshintrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
sudo: false
2+
23
language: node_js
4+
35
node_js:
46
- '0.10'
57
- '0.12'
6-
- 'iojs'
8+
- 'stable'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
async-done
22
==========
33

4-
[![build status](https://secure.travis-ci.org/phated/async-done.png)](http://travis-ci.org/phated/async-done)
4+
[![build status](https://secure.travis-ci.org/gulpjs/async-done.png)](http://travis-ci.org/gulpjs/async-done)
55

66
Handles completion and errors for callbacks, promises, observables, child processes and streams.
77

index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ var once = require('once');
88
var exhaust = require('stream-exhaust');
99

1010
var eosConfig = {
11-
error: false
11+
error: false,
1212
};
1313

14-
function asyncDone(fn, cb){
14+
function asyncDone(fn, cb) {
1515
cb = once(cb);
1616

1717
var d = domain.create();
1818
d.once('error', onError);
1919
var domainBoundFn = d.bind(fn);
2020

21-
function done(){
21+
function done() {
2222
d.removeListener('error', onError);
2323
d.exit();
2424
return cb.apply(null, arguments);
2525
}
2626

27-
function onSuccess(result){
27+
function onSuccess(result) {
2828
return done(null, result);
2929
}
3030

31-
function onError(error){
31+
function onError(error) {
3232
return done(error);
3333
}
3434

35-
function asyncRunner(){
35+
function asyncRunner() {
3636
var result = domainBoundFn(done);
3737

3838
function onNext(state) {
@@ -43,21 +43,21 @@ function asyncDone(fn, cb){
4343
return onSuccess(onNext.state);
4444
}
4545

46-
if(result && typeof result.on === 'function'){
47-
// assume node stream
46+
if (result && typeof result.on === 'function') {
47+
// Assume node stream
4848
d.add(result);
4949
eos(exhaust(result), eosConfig, done);
5050
return;
5151
}
5252

53-
if(result && typeof result.subscribe === 'function'){
54-
// assume RxJS observable
53+
if (result && typeof result.subscribe === 'function') {
54+
// Assume RxJS observable
5555
result.subscribe(onNext, onError, onCompleted);
5656
return;
5757
}
5858

59-
if(result && typeof result.then === 'function'){
60-
// assume promise
59+
if (result && typeof result.then === 'function') {
60+
// Assume promise
6161
result.then(onSuccess, onError);
6262
return;
6363
}

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"Pawel Kozlowski <pkozlowski.opensource@gmail.com>",
99
"Matthew Podwysocki <matthew.podwysocki@gmail.com>"
1010
],
11-
"repository": "phated/async-done",
11+
"repository": "gulpjs/async-done",
1212
"license": "MIT",
1313
"engines": {
1414
"node": ">= 0.10"
@@ -19,7 +19,8 @@
1919
"LICENSE"
2020
],
2121
"scripts": {
22-
"test": "lab -cvL"
22+
"lint": "eslint . && jscs *.js test/",
23+
"test": "lab -cv"
2324
},
2425
"dependencies": {
2526
"end-of-stream": "^1.1.0",
@@ -29,6 +30,10 @@
2930
},
3031
"devDependencies": {
3132
"code": "^1.4.1",
33+
"eslint": "^1.7.3",
34+
"eslint-config-gulp": "^2.0.0",
35+
"jscs": "^2.3.5",
36+
"jscs-preset-gulp": "^1.0.0",
3237
"lab": "^6.2.0",
3338
"rx": "^4.0.6",
3439
"through2": "^2.0.0",

test/.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "gulp/test"
3+
}

test/arguments.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ var expect = require('code').expect;
77

88
var asyncDone = require('../');
99

10-
function twoArg(cb){
10+
function twoArg(cb) {
1111
cb(null, 1, 2);
1212
}
1313

14-
describe('arguments', function(){
14+
describe('arguments', function() {
1515

16-
it('passes all arguments to the completion callback', function(done){
17-
asyncDone(twoArg, function(err, arg1, arg2){
16+
it('passes all arguments to the completion callback', function(done) {
17+
asyncDone(twoArg, function(err, arg1, arg2) {
1818
expect(arg1).to.equal(1);
1919
expect(arg2).to.equal(2);
2020
done(err);

test/callbacks.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,53 @@ var expect = require('code').expect;
77

88
var asyncDone = require('../');
99

10-
function success(cb){
10+
function success(cb) {
1111
cb(null, 2);
1212
}
1313

14-
function failure(cb){
14+
function failure(cb) {
1515
cb(new Error('Callback Error'));
1616
}
1717

18-
function neverDone(){
18+
function neverDone() {
1919
return 2;
2020
}
2121

22-
describe('callbacks', function(){
22+
describe('callbacks', function() {
2323

24-
it('should handle a successful callback', function(done){
25-
asyncDone(success, function(err, result){
24+
it('should handle a successful callback', function(done) {
25+
asyncDone(success, function(err, result) {
2626
expect(result).to.equal(2);
2727
done(err);
2828
});
2929
});
3030

31-
it('should handle an errored callback', function(done){
32-
asyncDone(failure, function(err){
31+
it('should handle an errored callback', function(done) {
32+
asyncDone(failure, function(err) {
3333
expect(err).to.be.instanceof(Error);
3434
done();
3535
});
3636
});
3737

38-
it('a function that takes an argument but never calls callback', function(done){
39-
asyncDone(neverDone, function(){
38+
it('a function that takes an argument but never calls callback', function(done) {
39+
asyncDone(neverDone, function() {
4040
done(new Error('Callback called'));
4141
});
4242

43-
setTimeout(function(){
43+
setTimeout(function() {
4444
done();
4545
}, 1000);
4646
});
4747

48-
it('should not handle error if something throws inside the callback', function(done){
48+
it('should not handle error if something throws inside the callback', function(done) {
4949
var d = require('domain').create();
50-
d.on('error', function(err){
50+
d.on('error', function(err) {
5151
expect(err).to.be.instanceof(Error);
5252
done();
5353
});
5454

55-
d.run(function(){
56-
asyncDone(success, function(){
55+
d.run(function() {
56+
asyncDone(success, function() {
5757
throw new Error('Thrown Error');
5858
});
5959
});

0 commit comments

Comments
 (0)