npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chelf

v0.1.0

Published

CHeck Encoding and Line Feeds

Readme

Chelf

"Chelf" (pronounced shelf ) stands for CHeck Encodings and Line Feeds.

This utility is used to scan text files for certain conditions, and make corrections where possible. Currently it supports verifying the files are either ASCII, UTF8, or UTF16 (big endian or little endian) - with or without a byte-order mark, or Windows CodePage 1252.

The utility can update line endings to be CRLF (\r\n), CR, or LF, and can also remove extra BOM marks from files (which can occur if files are concatenated). It can also convert between encodings that it understands.

Usage

    chelf [-dir=<path>] [-recurse[=true|false]] [-lineendings=crlf|cr|lf] -encodings=<ascii|utf8|utf8bom|utf16lebom|utf16bebom|utf16le|utf16be|cp1252>[,..] [-allowExtraBoms[=true|false]] [-includeFiles=<regex>] [-excludeFiles=<regex>]  [-fixup[=true|false]] [-fixedSuffix=<suffix>] [-v]
  • dir indicates the directory to scan (default is current directory)
  • recurse indicates whether to recurse through subdirectories (default is true)
  • linendings indicates the type of line-endings to allow (default is 'crlf')
  • encodings is the comma separated list of encodings to support. If not specified, default is "utf8". When fixup is specified, any encoding conversion needed uses the first encoding listed.
  • allowExtraBoms will ignore additional byte order marks in files (common if files are concatenated) if set to true (default is false)
  • includeFiles contains a regular expression to identify files to include. If not specified, the default is \.txt$|\.js$|\.css$|\.html$|\.ts$|jakefile$|\.json$|\.cmd$|\.bat$|\.map$.
  • excludeFiles contains a regular expression to exclude files. If not specified, the default is (.*\/)(\..*)\/ (i.e. any folder begining with a ".", such as ".git"). Note paths should use forward slashes as separators
  • fixup indicates whether to automatically fix the line-endings, encoding, and BOMs in files (default is false)
  • fixedSuffix indicates to write the fixed file as a new file with a suffix on the original filename, rather than overwriting the original file
  • v indicates to log verbose information to the console during execution

Examples

Note: Below assumes the 'chelf' command-line has been registered (via 'npm install' or 'npm link'), else run 'node ./bin/cli.js <args>' from the Chelf directory.

  • Scan the current directory and all subdirectories to check for only CRLF endings, encodings of UTF-8 with no BOM, and no midfile BOM marks.

     chelf
  • Scan the C:\Temp folder only, and for only .js files, change all line-endings to CRLF, remove any extra BOM marks, and ensure all files are UTF8 with no BOM

     chelf -dir=C:\Temp -recurse=false -fixup=true "-includeFiles=\.js$"

Building

To compile the utility, the 'jake' build system must be installed ("npm install -g jake").
Then, with the TypeScript compiler (tsc) in your path, and from the root folder of the source run:

    jake

To execute the tests run

    jake test

Structure

All source code is written in TypeScript and stored in subdirectories under the ./src directory. The compiler places the compiled versions of these subdirectories (lib & test) at the top level for execution.

The cli.js file is the exception. This is the command-line wrapper, and requires the she-bang ("#!") on the first line for NPM to run correctly, which TypeScript doesn't recognize. Thus this simple wrapper is written directly in JavaScript in the ./bin directory.

  • bin/cli.js Thin NPM wrapper when invoked via the command-line. Runs the main module
  • src/lib
    • main.ts Main module to be loaded for require('chelf')
    • encoding.ts Module to encode/decode various file encodings
    • filemanager.ts Module to crawl directories and read/write files
  • src/ref
    • types.d.ts Declarations for the types used across the utility
    • node.d.ts Declarations for the Node API surface area
  • src/test
    • encodingTests.ts Tests for file encoding/decoding
    • fileTests.ts Tests for the directory and file operations
    • mainTests.ts Tests for the overall utility