Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

afile

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

afile - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

32

index.js

@@ -5,2 +5,10 @@ 'use strict';

function arrify(a) {
if (!Array.isArray(a)) {
a = [a];
}
return a.slice(0);
}
function findone(targets, cb) {

@@ -13,4 +21,4 @@ if (targets.length === 0) {

var target = targets.shift();
fs.stat(target, function (err) {
if (err) {
fs.stat(target, function (err, stat) {
if (err || !stat.isFile()) {
findone(targets, cb);

@@ -24,8 +32,20 @@ } else {

function findoneSync(targets) {
for (var i = 0; i < targets.length; ++i) {
try {
if (fs.statSync(targets[i]).isFile()) {
return targets[i];
}
} catch (e) {}
}
return null;
}
function afile(targets, cb) {
if (!Array.isArray(targets)) {
targets = [targets];
if (cb) {
return findone(arrify(targets), cb);
}
findone(targets.slice(0), cb);
return findoneSync(arrify(targets));
}

@@ -45,2 +65,2 @@

module.exports.cb = afile;
module.exports.cb = module.exports.sync = afile;

2

package.json
{
"name": "afile",
"version": "0.3.1",
"version": "0.3.2",
"description": "Find a file on the list",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -34,6 +34,11 @@ # afile [![Build Status](https://travis-ci.org/ragingwind/afile.svg?branch=master)](https://travis-ci.org/ragingwind/afile)

// callback style
afile(targets, f => {
afile.cb(targets, f => {
console.log(f);
//=> /home/yours/.bowerrc
});
// sync style
afile.sync(targets);
//=> /home/yours/.bowerrc
});
```

@@ -50,6 +55,10 @@

callback style, will pass with target file or not.
callback style, will pass with target file path or not.
### afile.sync(targets)
return target file path or null.
## License
MIT © [Jimmy Moon](http://ragingwind.me)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc