Skip to content

Commit

Permalink
complexity reported by @codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Jan 15, 2016
1 parent 5ff9570 commit 658142a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 67 deletions.
48 changes: 0 additions & 48 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,54 +32,6 @@
+ or custom passed promise module constructor
+ or Bluebird constructor

**example**

```js
'use strict'

var fs = require('fs')
var redolent = require('redolent')
var readFile = redolent(fs.readFileSync, require('q'))
var promise = readFile('package.json', 'utf8')

console.log(promise.Prome)
//=> `q` constructor (if native promise not available)
// or native promise constructor
console.log(promise.Prome.___customPromise) //=> true
console.log(promise.___customPromise) //=> true
```

- allow passing custom promise module through static properties
+ till now it was able to do this only if you pass promise module as second argument

**example**

```js
'use strict'

var fs = require('fs')
var redolent = require('redolent')

// `pinkie` is promise module
// will use `pinkie` if not native promise is available
redolent.promise = require('pinkie')

var readFile = redolent(fs.readFileSync)

// will use `q` promise if native not available
// readFile.promise = require('q')

var promise = readFile('package.json')
promise.then(function (res) {
console.log(res) //=> Buffer
console.log(promise.Prome)
//=> `pinkie` constructor (if native promise not available)
// or native promise constructor
console.log(promise.Prome.___customPromise) //=> true
console.log(promise.___customPromise) //=> true
})
```

## 1.0.0 - 2015-09-28
- Release v1.0.0 / npm@v1.0.0
- implement :cat2:
Expand Down
22 changes: 3 additions & 19 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ function multipleArgs (one, two, three, cb) {
test('should not throw TypeError if falsey value given', function (done) {
redolent(false)().then(function (bool) {
test.strictEqual(bool, false)
return redolent(null)().then(function (empty) {
test.strictEqual(empty, null)
done()
})
done()
}, done)
})

Expand Down Expand Up @@ -139,7 +136,7 @@ test('should not skip last argument and work core api (fs.readFileSync)', functi
})

test('should not skip if pass callback fn, e.g. fn(err, res) as last argument', function (done) {
function foo (_err, res) {}
function foo (_err, res) { return [_err, res] }
redolent(function (one, fn, cb) {
cb(null, one, fn)
})(123, foo).then(function (res) {
Expand All @@ -149,17 +146,6 @@ test('should not skip if pass callback fn, e.g. fn(err, res) as last argument',
})
})

test('should promisify sync function `fs.readFileSync` and handle utf8 result', function (done) {
var promise = redolent(fs.readFileSync)('package.json', 'utf8')

promise
.then(JSON.parse)
.then(function (res) {
test.strictEqual(res.name, 'redolent')
done()
}, done)
})

test('should promisify `fs.readFileSync` and handle buffer result', function (done) {
var readFile = redolent(fs.readFileSync)
readFile('package.json').then(function (buf) {
Expand All @@ -169,9 +155,7 @@ test('should promisify `fs.readFileSync` and handle buffer result', function (do
})

test('should catch errors from failing sync function', function (done) {
var promise = redolent(fs.readFileSync)('foobar.json', 'utf8')

promise
redolent(fs.readFileSync)('foobar.json', 'utf8')
.catch(function (err) {
test.strictEqual(err.code, 'ENOENT')
test.strictEqual(/no such file or directory/.test(err.message), true)
Expand Down

0 comments on commit 658142a

Please sign in to comment.