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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rubix-code/ini

v0.0.4

Published

An ini-file parser which supports multi line, multiple levels and arrays to get a maximum of compatibility with Zend config files.

Downloads

65

Readme

@rubix-code/ini

This project is a fork of evangelion1204/multi-ini

An ini-file parser which supports multi line, multiple levels and arrays to get a maximum of compatibility with Zend config files.

Please note that this is a work in progress and may be ditched, all contributions are welcome!

Install

npm install @rubix-code/ini

Usage

ini = require('@rubix-code/ini');
content = ini.read(file);
content.section.key = value;
ini.write(file, content);

Options

Following options are available:

  • encoding ['utf8'] - directly passed to readFileSync
  • keep_quotes [false] - does not strip quotes around values
  • filters - predefined lowercase, uppercase, trim, constants, boolean

Examples

encoding

ini = require('@rubix-code/ini');
content = ini.read(file, {encoding: 'utf8'});
content.section.key = value;
ini.write(file, content, {encoding: 'utf8'});

keep_quotes

This option is by default off to be backward compatible, if you ever need the value containing the quotes then use this.

key="value"

Enabling this option will result in "value" instead of value.

ini = require('@rubix-code/ini');
content = ini.read(file, {keep_quotes: true});

This will also affect the Serializer and serialized values. Using it will not quote anything automatically.

{
    production: {
        quoted: '"quoted"',
        not_quoted: 'not_quoted'
    }
}

Will result in a ini like

[production]
quoted="quoted"
not_quotes=not_quoted

filters

Ini = require('@rubix-code/ini');
ini = new Ini.Class({
    filters: [Ini.filters.lowercase]
});
content = ini.read(file);

Replacing constants

Ini = require('@rubix-code/ini');
ini = new Ini.Class({
  constants: {'CONSTANT': 'replacement'},
  filters: [Ini.filters.constants]
});
content = ini.read(file);

Define a custom filter

Ini = require('@rubix-code/ini');
ini = new Ini.Class({
    filters: [
        function (value) {
            return "Prepend " + value;
        }
    ]
});
content = ini.read(file);

line_breaks

Either unix or windows for line breaks.

ini = require('@rubix-code/ini');
content = ini.read(file, {line_breaks: 'windows'});
content.section.key = value;

Parser

It's also possible to parse a ini file from an array of strings.

ini = require('@rubix-code/ini');
parser = new ini.Parser();
content = parser.parse(lines);

Serializer

Like parsing it's also possible to serialize an ini object to a string.

ini = require('@rubix-code/ini');
serializer = new ini.Serializer();
content = serializer.serialize({
    production: {
        base_url: 'https://google.com'
    }
});

Changelog

0.0.2

  • Rewritten in Typescript