Comparing version 0.2.0 to 0.3.0
18
index.js
@@ -22,3 +22,3 @@ 'use strict'; | ||
module.exports = function (targets, cb) { | ||
function afile(targets, cb) { | ||
if (!Array.isArray(targets)) { | ||
@@ -28,3 +28,17 @@ targets = [targets]; | ||
findone(targets, cb); | ||
findone(targets.slice(0), cb); | ||
} | ||
module.exports = function (targets) { | ||
return new Promise(function (resolve, reject) { | ||
afile(targets, function (f) { | ||
if (f) { | ||
resolve(f); | ||
} else { | ||
reject(new Error('Not found a file')); | ||
} | ||
}); | ||
}); | ||
}; | ||
module.exports.cb = afile; |
{ | ||
"name": "afile", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Find a file on the list", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && ava" | ||
"test": "xo && ava --verbose" | ||
}, | ||
@@ -19,0 +19,0 @@ "files": [ |
# afile [![Build Status](https://travis-ci.org/ragingwind/afile.svg?branch=master)](https://travis-ci.org/ragingwind/afile) | ||
> Find a file on the list | ||
> Find a file in the list | ||
@@ -25,12 +25,30 @@ | ||
afile(targets, afilepath => { | ||
// promise supports | ||
afile(targets).then(function (f) { | ||
console.log(f); | ||
//=> /home/yours/.bowerrc | ||
}, function () { | ||
// not in the list | ||
}); | ||
// callback style | ||
afile(targets, f => { | ||
console.log(f); | ||
//=> /home/yours/.bowerrc | ||
}); | ||
``` | ||
## API | ||
### afile(tagets, cb); | ||
### afile(tagets) | ||
return promise, will resolve if target file is exist. | ||
### afile.cb(tagets, cb) | ||
callback style, will pass with target file or not. | ||
## License | ||
MIT © [Jimmy Moon](http://ragingwind.me) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3139
35
54