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

globs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

globs - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

102

index.js

@@ -8,49 +8,85 @@ 'use strict';

*
* @example
* ## Examples:
*
* ```
* expand('../*.js', function (err, jsfiles) {
* globs('../*.js', function (err, jsfiles) {
* console.log(jsfiles);
* })
* ```
* @example
* ```
* expand(['*.js', '../*.js'], function (err, jsfiles) {
*
* globs(['*.js', '../*.js'], function (err, jsfiles) {
* console.log(jsfiles)
* })
*
* globs(['*.js', '../*.js'], { cwd: '/foo' }, function (err, jsfiles) {
* console.log(jsfiles)
* })
* ```
*
* @param {String|Array} patterns One or more patterns to match
* @param {Object} [options] Options
* @param {Function} callback Function which accepts two parameters: err, files
*/
function expand(patterns, callback) {
var pending,
groups = [];
var globs = module.exports = function (patterns, options, callback) {
var pending
, groups = [];
// not an Array? make it so!
if (!Array.isArray(patterns)) {
patterns = [ patterns ];
}
// not an Array? make it so!
if (!Array.isArray(patterns)) {
patterns = [ patterns ];
}
pending = patterns.length;
pending = patterns.length;
// walk the patterns
patterns.forEach(function (pattern) {
// grab the files
glob(pattern, function (err, files) {
if (err) {
return callback(err);
}
// parameter shifting is really horrible, but i'm
// mimicing glob's api...
if (typeof options === 'function') {
callback = options;
options = {};
}
// add the files to the group
groups = groups.concat(files);
// walk the patterns
patterns.forEach(function (pattern) {
// grab the files
glob(pattern, options, function (err, files) {
if (err) {
return callback(err);
}
pending -= 1;
// last pattern?
if (!pending) {
// done
return callback(null, groups);
}
});
});
}
// add the files to the group
groups = groups.concat(files);
module.exports = expand;
pending -= 1;
// last pattern?
if (!pending) {
// done
return callback(null, groups);
}
});
});
};
/**
* Synchronously Expand one or more patterns to an Array of files
*
* @api public
* @param {String|Array} patterns
* @param {Object} [options]
* @return {Array}
*/
globs.sync = function (patterns, options) {
options = options || {};
var groups = []
, index
, length;
if (!Array.isArray(patterns)) {
patterns = [ patterns ];
}
for (index = 0, length = patterns.length; index < length; index++) {
groups = groups.concat(glob.sync(patterns[index], options));
}
return groups;
};
{
"name": "globs",
"version": "0.0.1",
"version": "0.1.0",
"author": {

@@ -5,0 +5,0 @@ "name": "Stephen Mathieson",

@@ -28,4 +28,18 @@ # globs

// sync
var files = globs.sync([ '**/*.js', '/foo/bar/*.coffee' ], { option: 'stuff' });
```
## Revision History
### 0.1.0
- Added sync support (`globs.sync(patterns)`)
### 0.0.1
- Initial release
- Supports `globs(patterns/pattern)`
[glob]: https://github.com/isaacs/node-glob
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