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

klaw-sync

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

klaw-sync - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

7

CHANGELOG.md

@@ -0,1 +1,7 @@

6.0.0 / 2018-09-22
------------------
### Added
- `traverseAll` option. It would allow to traverse all subdirectories regardless of filter option. [#13] (Thanks to [@jskrzypek](https://github.com/jskrzypek))
5.0.0 / 2018-09-05

@@ -67,1 +73,2 @@ ------------------

[#12]: https://github.com/manidlou/node-klaw-sync/pull/12 "Fixing logic issues"
[#13]: https://github.com/manidlou/node-klaw-sync/pull/13 "Traverse all option"

13

klaw-sync.js

@@ -19,9 +19,8 @@ 'use strict'

const isUnderDepthLimit = (!opts.rootDepth || pi.split(path.sep).length - opts.rootDepth < opts.depthLimit)
if (st.isDirectory()) {
if (!opts.nodir) { if ((opts.filter && opts.filter(item)) || !opts.filter) ls.push(item) }
if (isUnderDepthLimit && ((opts.filter && opts.filter(item)) || !opts.filter)) ls = klawSync(pi, opts, ls)
} else if (!st.isDirectory()) {
if (!opts.nofile) { if ((opts.filter && opts.filter(item)) || !opts.filter) ls.push(item) }
}
const filterResult = opts.filter ? opts.filter(item) : true
const isDir = st.isDirectory()
const shouldAdd = filterResult && (isDir ? !opts.nodir : !opts.nofile)
const shouldTraverse = isDir && isUnderDepthLimit && (opts.traverseAll || filterResult)
if (shouldAdd) ls.push(item)
if (shouldTraverse) ls = klawSync(pi, opts, ls)
}

@@ -28,0 +27,0 @@ return ls

{
"name": "klaw-sync",
"version": "5.0.0",
"version": "6.0.0",
"description": "Recursive, synchronous, and fast file system walker",

@@ -5,0 +5,0 @@ "main": "klaw-sync.js",

@@ -7,5 +7,6 @@ node-klaw-sync

[![windows Build status](https://ci.appveyor.com/api/projects/status/braios34k6qw4h5p/branch/master?svg=true)](https://ci.appveyor.com/project/manidlou/node-klaw-sync/branch/master)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
[![Known Vulnerabilities](https://snyk.io/test/npm/klaw-sync/badge.svg?style=flat-square)](https://snyk.io/test/npm/klaw-sync)
`klaw-sync` is a Node.js recursive file system walker, which is the synchronous counterpart of [klaw](https://github.com/jprichardson/node-klaw). It lists all files and directories inside a directory recursively and returns an array of objects that each object has two properties: `path` and `stats`. `path` is the full path of the file or directory and `stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).
`klaw-sync` is a Node.js recursive and fast file system walker, which is the synchronous counterpart of [klaw](https://github.com/jprichardson/node-klaw). It lists all files and directories inside a directory recursively and returns an array of objects that each object has two properties: `path` and `stats`. `path` is the full path of the file or directory and `stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).

@@ -34,3 +35,4 @@ Install

- function that gets one argument `fn({path: '', stats: {}})` and returns true to include or false to exclude the item.
- `traverseAll` `<Boolean>`
- traverse all subdirectories, regardless of `filter` option. (When set to `true`, `traverseAll` produces similar behavior to the default behavior prior to v4.0.0. The current default of `traverseAll: false` is equivalent to the old `noRecurseOnFailedFilter: true`).
- **Return:** `<Array<Object>>` `[{path: '', stats: {}}]`

@@ -97,3 +99,3 @@

Again here `noRecurseOnFailedFilter` option is not required since we still want to read all directories even though they don't pass the `filter` function, to see if their contents pass the `filter` function.
Here `traverseAll` option is required since we still want to read all directories even if they don't pass the `filter` function, to see if their contents do pass the `filter` function.

@@ -100,0 +102,0 @@ ```js

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