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

fileseg

v0.1.0

Published

Manage config file segments with ease

Readme

fileseg

File segment fetching and replacing for configuration files

Build Status

Installation

Simply install by running npm install fileseg --save.

Usage

fileseg allows for configuration block management within files. For instance you may want to control a custom block of ignored paths in a .gitignore file:

node_modules
*.log
.vscode

# __fileseg__ BEGIN:customConfig
some-application-path
another/path
# __fileseg__ END:customConfig

Reading and editing this configuration section is easy with fileseg:

const createAdapter = require("fileseg");

const adapter = createAdapter(".gitignore");
adapter
    .read("customConfig")
    .then(function(config) {
        const newConfig = [
            ...config.split("\n"),
            "somefile.exe"
        ];
        return adapter.write("customConfig", newConfig.join("\n"));
    });

The result within .gitignore would be:

node_modules
*.log
.vscode

# __fileseg__ BEGIN:customConfig
some-application-path
another/path
somefile.exe
# __fileseg__ END:customConfig

A file can have any number of blocks managed by fileseg. A file is created automatically when writing to a path that doesn't exist. Reading a block from a non-existent file will return null by default (this can be overidden in the options).

Configuring

fileseg can be configured by passing in a configuration object when creating the adapter:

const createAdapter = require("fileseg");

const adapter = createAdapter(".gitignore", {
    commentPrefix: "#",
    blockPrefix: " __fileseg__ ",
    beginText: "BEGIN:",
    endText: "END:",
    newLine: "\n",
    noSegment: null
});

You can override the default behaviour:

  • commentPrefix is the string used to prefix block delimiters. The default # character is quite common in configuration files, but it can be changed to other comment characters for other markups and languages.
  • blockPrefix is a library-specific identifier to increase the uniqueness of the block.
  • beginText and endText configure the values to delimit the start and end of a block. These must never be the same and should usually not be changed.
  • newLine controls the new line characters (both recognised and replaced). This could be set, for example, to "\r\n" in a pure Windows project.
  • noSegment is the default return value for when a segment is not found (includes non-existent files).