A tiny (195B to 224B) utility to recursively list all (total) files in a directory
Installations
npm install totalist
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Min. Node Version
>=6
Node Version
18.12.1
NPM Version
8.19.2
Score
99.3
Supply Chain
99.4
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
lukeed
Download Statistics
Total Downloads
870,653,423
Last Day
562,642
Last Week
3,443,763
Last Month
29,012,729
Last Year
352,246,846
GitHub Statistics
153 Stars
42 Commits
5 Forks
6 Watching
1 Branches
3 Contributors
Bundle Size
642.00 B
Minified
349.00 B
Minified + Gzipped
Package Meta Information
Latest Version
3.0.1
Package Id
totalist@3.0.1
Unpacked Size
7.28 kB
Size
3.01 kB
File Count
9
NPM Version
8.19.2
Node Version
18.12.1
Publised On
03 Apr 2023
Total Downloads
Cumulative downloads
Total Downloads
870,653,423
Last day
-16%
562,642
Compared to previous day
Last week
-45.6%
3,443,763
Compared to previous week
Last month
-8%
29,012,729
Compared to previous month
Last year
35.4%
352,246,846
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
totalist
A tiny (195B to 224B) utility to recursively list all (total) files in a directory
Traverse a directory recursively, running a function for every file found.
With this module, you easily apply custom logic to decide which file(s) to process without worrying about accidentally accessing a directory or making repeat fs.Stats
requests.
Install
$ npm install --save totalist
Modes
There are two "versions" of totalist
available:
"async"
Node.js: >= 8.x
Size (gzip): 220 bytes
Availability: CommonJS, ES Module
This is the primary/default mode. It makes use of async
/await
and util.promisify
.
"sync"
Node.js: >= 6.x
Size (gzip): 195 bytes
Availability: CommonJS, ES Module
This is the opt-in mode, ideal for scenarios where async
usage cannot be supported.
Usage
Selecting a Mode
1// import via npm module 2import { totalist } from 'totalist'; 3import { totalist } from 'totalist/sync';
Example Usage
1import { totalist } from 'totalist/sync'; 2 3const styles = new Set(); 4const scripts = new Set(); 5 6totalist('src', (name, abs, stats) => { 7 if (/\.js$/.test(name)) { 8 scripts.add(abs); 9 if (stats.size >= 100e3) { 10 console.warn(`[WARN] "${name}" might cause performance issues (${stats.size})`); 11 } 12 } else if (/\.css$/.test(name)) { 13 styles.add(abs); 14 } 15}); 16 17console.log([...scripts]); 18//=> [..., '/Users/lukeed/.../src/path/to/example.css', ...]
API
totalist(dir, callback)
Returns: void
Important: The "async" usage must be
await
ed or included within a Promise chain.
dir
Type: string
Required: true
The directory to traverse.
This may be a relative or an absolute path.
Note: Node.js will assume a relative path is meant to be resolved from the current location (
process.cwd()
).
callback
Type: Function
Required: true
The callback function to run for every file.
The function receives three parameters:
relPath
Type: String
The path relative to the initial dir
value you provided.
absPath
Type: String
The absolute path of the file.
stats
Type: fs.Stats
The fs.Stats
object for the file.
License
MIT © Luke Edwards
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/lukeed/totalist/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/lukeed/totalist/ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:24
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:25
- Warn: downloadThenRun not pinned by hash: .github/workflows/ci.yml:34
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 npmCommand dependencies pinned
- Info: 0 out of 1 downloadThenRun dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Score
3.4
/10
Last Scanned on 2025-01-06
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More