Gathering detailed insights and metrics for @cseitz/watchpack
Gathering detailed insights and metrics for @cseitz/watchpack
npm install @cseitz/watchpack
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
136
Last Day
1
Last Week
2
Last Month
4
Last Year
136
380 Stars
398 Commits
107 Forks
15 Watching
5 Branches
95 Contributors
Minified
Minified + Gzipped
Latest Version
2.4.0
Package Id
@cseitz/watchpack@2.4.0
Unpacked Size
55.61 kB
Size
13.87 kB
File Count
9
NPM Version
9.6.7
Node Version
18.17.1
Publised On
10 Feb 2024
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
100%
2
Compared to previous week
Last month
100%
4
Compared to previous month
Last year
0%
136
Compared to previous year
Wrapper library for directory and file watching.
watchpack high level API doesn't map directly to watchers. Instead a three level architecture ensures that for each directory only a single watcher exists.
DirectoryWatchers
from a WatcherManager
, which ensures that only a single DirectoryWatcher
per directory is created.Watcher
can be obtained from a DirectoryWatcher
and provides a filtered view on the DirectoryWatcher
.DirectoryWatcher
and Watcher
to decide when to close them.DirectoryWatcher
.1var Watchpack = require("watchpack"); 2 3var wp = new Watchpack({ 4 // options: 5 aggregateTimeout: 1000, 6 // fire "aggregated" event when after a change for 1000ms no additional change occurred 7 // aggregated defaults to undefined, which doesn't fire an "aggregated" event 8 9 poll: true, 10 // poll: true - use polling with the default interval 11 // poll: 10000 - use polling with an interval of 10s 12 // poll defaults to undefined, which prefer native watching methods 13 // Note: enable polling when watching on a network path 14 // When WATCHPACK_POLLING environment variable is set it will override this option 15 16 followSymlinks: true, 17 // true: follows symlinks and watches symlinks and real files 18 // (This makes sense when symlinks has not been resolved yet, comes with a performance hit) 19 // false (default): watches only specified item they may be real files or symlinks 20 // (This makes sense when symlinks has already been resolved) 21 22 ignored: "**/.git" 23 // ignored: "string" - a glob pattern for files or folders that should not be watched 24 // ignored: ["string", "string"] - multiple glob patterns that should be ignored 25 // ignored: /regexp/ - a regular expression for files or folders that should not be watched 26 // ignored: (entry) => boolean - an arbitrary function which must return truthy to ignore an entry 27 // For all cases expect the arbitrary function the path will have path separator normalized to '/'. 28 // All subdirectories are ignored too 29}); 30 31// Watchpack.prototype.watch({ 32// files: Iterable<string>, 33// directories: Iterable<string>, 34// missing: Iterable<string>, 35// startTime?: number 36// }) 37wp.watch({ 38 files: listOfFiles, 39 directories: listOfDirectories, 40 missing: listOfNotExistingItems, 41 startTime: Date.now() - 10000 42}); 43// starts watching these files and directories 44// calling this again will override the files and directories 45// files: can be files or directories, for files: content and existence changes are tracked 46// for directories: only existence and timestamp changes are tracked 47// directories: only directories, directory content (and content of children, ...) and 48// existence changes are tracked. 49// assumed to exist, when directory is not found without further information a remove event is emitted 50// missing: can be files or directorees, 51// only existence changes are tracked 52// expected to not exist, no remove event is emitted when not found initially 53// files and directories are assumed to exist, when they are not found without further information a remove event is emitted 54// missing is assumed to not exist and no remove event is emitted 55 56wp.on("change", function(filePath, mtime, explanation) { 57 // filePath: the changed file 58 // mtime: last modified time for the changed file 59 // explanation: textual information how this change was detected 60}); 61 62wp.on("remove", function(filePath, explanation) { 63 // filePath: the removed file or directory 64 // explanation: textual information how this change was detected 65}); 66 67wp.on("aggregated", function(changes, removals) { 68 // changes: a Set of all changed files 69 // removals: a Set of all removed files 70 // watchpack gives up ownership on these Sets. 71}); 72 73// Watchpack.prototype.pause() 74wp.pause(); 75// stops emitting events, but keeps watchers open 76// next "watch" call can reuse the watchers 77// The watcher will keep aggregating events 78// which can be received with getAggregated() 79 80// Watchpack.prototype.close() 81wp.close(); 82// stops emitting events and closes all watchers 83 84// Watchpack.prototype.getAggregated(): { changes: Set<string>, removals: Set<string> } 85const { changes, removals } = wp.getAggregated(); 86// returns the current aggregated info and removes that from the watcher 87// The next aggregated event won't include that info and will only emitted 88// when futher changes happen 89// Can also be used when paused. 90 91// Watchpack.prototype.collectTimeInfoEntries(fileInfoEntries: Map<string, Entry>, directoryInfoEntries: Map<string, Entry>) 92wp.collectTimeInfoEntries(fileInfoEntries, directoryInfoEntries); 93// collects time info objects for all known files and directories 94// this include info from files not directly watched 95// key: absolute path, value: object with { safeTime, timestamp } 96// safeTime: a point in time at which it is safe to say all changes happened before that 97// timestamp: only for files, the mtime timestamp of the file 98 99// Watchpack.prototype.getTimeInfoEntries() 100var fileTimes = wp.getTimeInfoEntries(); 101// returns a Map with all known time info objects for files and directories 102// similar to collectTimeInfoEntries but returns a single map with all entries 103 104// (deprecated) 105// Watchpack.prototype.getTimes() 106var fileTimes = wp.getTimes(); 107// returns an object with all known change times for files 108// this include timestamps from files not directly watched 109// key: absolute path, value: timestamp as number
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 1/11 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
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