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

klaw

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

klaw - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

5

CHANGELOG.md

@@ -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 @@ ------------------

2

package.json
{
"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) })

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