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

shmaml

v0.0.3

Published

Parse `.ini` files into JSON objects. Support lists.

Downloads

5

Readme

License: MIT Build Status

SHMAML

Parse .ini files into JSON objects. Support lists.

Install

$ npm install shmaml

Use

const parse = require('shmaml');

const resultPromise = parse('../path/to/config.ini');
// or:
const result = parse.sync('../path/to/config.ini');

 

Example config.ini + list:

username = me
pasword = 1234

[SectionA]
  key=value

[SectionB]
  key=value
  list=[
      item1,
      item2,
      item3
  ]

Becomes:

result = {
  username: 'me',
  pasword: 1234,
  SectionA: {
    key: 'value',
  },
  SectionB: {
    key: 'value',
    list: ['item1', 'item2', 'item3']
  },
}

Convention

  • key-value pairs are noted with an equal sign.

    key="value"
  • Quoting values is optional. Strings are used as default.

    ; These are all the same:
    key=value
    key='value'
    key="value"
  • Unquoted numbers are parsed as numbers. Use single/double quotes to make number values parsed as strings.

    number = 55
    string = '55'
    string = "55"
  • Unquoted booleans are parsed as booleans. Use single/double quotes to make boolean values parsed as strings. CaSe InSeNsITiVe.

    bool = TRUE
    bool = false
    string = 'true'
    string = "false"
  • Sections are noted with wrapping square brackets.

    [categoryA]
        key="value"
    [categoryB]
        key="value"
  • Lists are also noted with wrapping square brackets when come after a key=.

    [categoryA]
        key="value"
        list=[item1, item2, item3]
  • Multiline lists are also supported.

    [categoryA]
        multilineList=[
            item1,
            item2,
            item3
        ]
        key="value"

NOTE: Nested lists are NOT supported.
list=[A, [B, [C, D]], E]

  • Comments are ignored, obviously. Use quotes to work with semicolons:

    ; line comment
    [category]
        key1=value1 ; inline comment
        key2='quoted ; semicolon'
        key3="double quoted ; semicolon"
  • Whitespace (including tabs) is trimmed:

    ;Same
    [sectionA]
    [ sectionA ]
    ;Same
    key= value
    key =value
    key  =  value
    [sectionA]
    key=value
      
    ;Same as
      
    [sectionA]
        key=value   
  • Preserve whitespace using quotes:

    [' section   ']
    key="  value "
    {
        " section   ": {
            key: "  value "
        }
    }
  • Duplicates.
    Duplicated section names are merged to the same object.

    [sectionA]
        key1=value1
    [sectionA]
        key2=value2
    result = {
        SectionA: {
            key1: 'value1',
            key2: 'value2',
        },
    }

    Duplicated key names in the same section: the later overwrites the former.

    sameKey=value1
    sameKey=value2
    sameKey=value3
    result = {
        sameKey: 'value3'
    }