New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

config.ini

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

config.ini

your .ini files parser with some extras

latest
Source
npmnpm
Version
0.0.60
Version published
Maintainers
1
Created
Source

config.ini

your .ini files parser with some extras

MIT License Build Status npm version Build

Version

VersionPublishedByURL
0.0.602019-08-11codeblokenpm

How to use it

Installation

npm install --save config.ini

In your code...

var configIni = require('config.ini');

Examples

Example format

For all examples below we are assuming following .ini file structure


# A comment
; This is a comment too

[SectionOne]

key = "value"
integer = 1234
real = 3.14
string1 = "Case 1"
string2 = 'Case 2'
multivalue[] = "first"   # in-line comments
multivalue[] = 'second'  # are supported as well

; Section: SectionTwo
[SectionTwo]

key = new value
integer = 1234
real = 3.14
string1 = Case 1
string2 = Case 2
string3 = Case 3
multivalue[] = first
multivalue[] = second
multivalue[] = third

« back to list

Reading from a string

Reading config from an .ini string with sections (For section-less feature see: #2)

var string = '',
    conf   = configIni.parse(string);

    /// (...)
    console.log(conf.SectionOne.integer);
    // 1234
    console.log(typeof conf.SectionOne.integer);
    // 'number'
    console.log(typeof conf.SectionTwo);
    // 'object'
    console.log(conf.SectionTwo.real);
    // 3.14
    /// (...)

« back to list

Reading from a file

Reading config from a file.ini

var conf = configIni.load('/yourFull/path/to/file.ini');

    /// (...)
    console.log(conf.SectionOne.integer);
    // 1234
    console.log(typeof conf.SectionOne.integer);
    // 'number'
    console.log(typeof conf.SectionTwo);
    // 'object'
    console.log(conf.SectionTwo.real);
    // 3.14
    /// (...)

« back to list

Output to an .ini string


    var objToIniString = {
        mysection: {
            key: "string",
            integer: 1234,
            real: 3.14
        }
    };

    console.log(configIni.stringify(objToIniString));
'
; Section: mysection
[mysection]

key = string
integer = 1234
real = 3.14
'

« back to list

I8N Support

For the .ini file as follows:

[Japan]
miyamoto_musashi = "宮本武蔵"

[Germany]
gebhard_von_bluecher = "Gebhard-Leberecht von Blücher Fürst von Wahlstatt"

[ME]
salah_ad_din = "صلاحالدينيوسفبنأيوب"

we are getting back following object:

console.log(
    {
        Japan: {
            miyamoto_musashi: '宮本武蔵'
        },
        Germany: {
            gebhard_von_bluecher: 'Gebhard-Leberecht von Blücher Fürst von Wahlstatt'
        },
        ME: {
            salah_ad_din: 'صلاحالدينيوسفبنأيوب'
        }
    }
);

« back to list

Keywords

ini

FAQs

Package last updated on 12 Aug 2019

Did you know?

Socket

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.

Install

Related posts