
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
flavored-wc
Advanced tools
Node.js project
Version: 0.0.2
The Unix wc command counts the number of bytes, characters, words and lines in a file but it lacks some useful features like walking a directory recursively and ignore paths. Also it has some issues with utf8 encoded files.
npm install flavored-wc
npm install flavored-wc-native
A native version is also available. I made it just for fun but, if you can, install it. The speed improvement depends on some factors: file size, number of files, file content and the information to retrieve. I've tested both implementations with a 10MB file and the native is twice as fast. The directory of this repository has been also tested with the following code and the native is four times faster.
//wc.js
var wc = require ("flavored-wc-native");
wc (".", function (){});
$ time node wc.js
wc(path[, options], callback) : undefined
The path can be an String or an Array of Strings. These Strings can contain a valid path or text data.
The callback gets two parameters, an error and the counters object.
If the options object is not provided all the information (bytes, chars, words and lines) will be counted.
Options:
bytes - Boolean
Set to true to count the number of bytes. Default is false.
chars - Boolean
Set to true to count the number of characters. Default is false. UTF8 multibyte characters are also allowed.
words - Boolean
Set to true to count the number of words. Default is false. A word is any consecutive sequence of characters separated by \r, \n, \v, \f, \t or space.
lines - Boolean
Set to true to count the number of lines. The maximum line length will be also calculated and will be returned with the maxLineLine property. Default is false.
data - Boolean
If path contains text data, set this option to true. Default is false.
ignore - String | Array | Function
Paths to ignore. It can be also a function. The function is executed for each file and directory. It receives the absolute path, the directory name, the name of the entry and a callback. The callback expects two parameters, a possible error and a boolean. If the boolean is true the path will be read, otherwise it will be ignored. The function acts like a filter, if you return false the path won't pass the filter.
var wc = require ("flavored-wc");
var options = {
ignore: function (p, dirname, basename, cb){
cb (null, basename !== "ignored_path");
},
bytes: ...,
...
};
wc (".", options, function (error, counters){
...
});
FAQs
wc command ported to Node.js with additional features
The npm package flavored-wc receives a total of 5 weekly downloads. As such, flavored-wc popularity was classified as not popular.
We found that flavored-wc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.