Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,6 @@ | ||
1.3.0 / 2016-06-09 | ||
------------------ | ||
### Added | ||
- `filter` option to pre-filter and not walk directories. | ||
1.2.0 / 2016-04-16 | ||
@@ -2,0 +7,0 @@ ------------------ |
{ | ||
"name": "klaw", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "File system walker with Readable stream interface.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -10,3 +10,4 @@ Node.js - klaw | ||
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) | ||
<!-- [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) --> | ||
<a href="http://standardjs.com"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard" width="100"></a> | ||
@@ -41,2 +42,3 @@ Install | ||
- `fs` (`object`, default: `require('fs')`): Use this to hook into the `fs` methods or to use [`mock-fs`](https://github.com/tschaub/mock-fs) | ||
- `filter` (`function`, default: `undefined`): Filtering [function for Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) | ||
@@ -142,4 +144,19 @@ **Streams 1 (push) example:** | ||
``` | ||
**Example (ignore hidden directories):** | ||
```js | ||
var klaw = require('klaw') | ||
var path = require('path') | ||
var filterFunc = function(item){ | ||
var basename = path.basename(item) | ||
return basename === '.' || basename[0] !== '.' | ||
} | ||
klaw('/some/dir', { filter : filterFunc }) | ||
.on('data', function(item){ | ||
// only items of none hidden folders will reach here | ||
}) | ||
``` | ||
**Example (totaling size of PNG files):** | ||
@@ -146,0 +163,0 @@ |
@@ -11,3 +11,3 @@ var assert = require('assert') | ||
var defaultStreamOptions = { objectMode: true } | ||
var defaultOpts = { queueMethod: 'shift', pathSorter: undefined } | ||
var defaultOpts = { queueMethod: 'shift', pathSorter: undefined, filter: undefined } | ||
options = assign(defaultOpts, options, defaultStreamOptions) | ||
@@ -40,2 +40,3 @@ | ||
pathItems = pathItems.map(function (part) { return path.join(pathItem, part) }) | ||
if (self.options.filter) pathItems = pathItems.filter(self.options.filter) | ||
if (self.options.pathSorter) pathItems.sort(self.options.pathSorter) | ||
@@ -42,0 +43,0 @@ pathItems.forEach(function (pi) { self.paths.push(pi) }) |
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
12318
57
271