# config.ini

> your .ini files parser with some extras

Latest version **0.0.60** (published 2019-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install config.ini
pnpm add config.ini
yarn add config.ini
bun add config.ini
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.60 |
| Published | 2019-08-12 |
| First published | 2017-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 158.6 KB |
| Known vulnerabilities | 0 (+5 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Martin Swiderski |
| Maintainers | codebloke |
| Keywords | ini, config, ini, file, ini, parser, configuration, linux, application, config |

## Links

- npm: https://www.npmjs.com/package/config.ini
- Repository: https://github.com/martinswiderski/config.ini
- Homepage: https://github.com/martinswiderski/config.ini#readme
- Issues: https://github.com/martinswiderski/config.ini/issues
- npm.io page: https://npm.io/package/config.ini

## Dependencies (6)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [npm](https://npm.io/package/npm.md) ^6.10.3
- [growl](https://npm.io/package/growl.md) ^1.10.5
- [jsesc](https://npm.io/package/jsesc.md) ^2.5.2
- [md5-file](https://npm.io/package/md5-file.md) ^4.0.0
- [validator](https://npm.io/package/validator.md) ^11.1.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.0.60 (latest) — 2019-08-12
- 0.0.55 — 2019-01-17
- 0.0.52 — 2018-02-15
- 0.0.51 — 2017-04-15
- 0.0.5 — 2017-04-15
- 0.0.4 — 2017-04-09
- 0.0.3 — 2017-04-09
- 0.0.2 — 2017-04-09
- 0.0.1 — 2017-04-08

## README

config.ini
---

**your `.ini` files parser with some extras**


[![MIT License](https://raw.githubusercontent.com/martinswiderski/config.ini/master/mit-license.png)](LICENSE) [![Build Status](https://travis-ci.org/martinswiderski/config.ini.svg?branch=master)](https://travis-ci.org/martinswiderski/config.ini) [![npm version](https://badge.fury.io/js/config.ini.svg)](https://www.npmjs.com/package/config.ini) [![Build](https://ci.appveyor.com/api/projects/status/github/martinswiderski/config.ini?branch=master&svg=true&pendingText=Windows%20...&failingText=Windows%20failed&passingText=Windows%20OK)](https://ci.appveyor.com/project/martinswiderski/config-ini)


### Version

Version|Published|By|URL
--- | --- | --- | ---
**0.0.60** | **2019-08-11** | `codebloke` | [npm](https://www.npmjs.com/package/config.ini)

### How to use it

#### Installation

```bash
npm install --save config.ini
```
#### In your code...

```javascript 1.8
var configIni = require('config.ini');
```

#### <a name="examples"></a>Examples

 * [Example .ini file format](#ini)
 * [Reading string](#string)
 * [Reading from a file](#file)
 * [Output to .ini string (you can save it into a file)](#output)
 * [I8N Support](#i8n)


#### <a name="ini"></a>Example format

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

```bash

# 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

```
[&laquo; back to list](#examples)


#### <a name="string"></a>Reading from a string

Reading config from an .ini `string` **with sections** <sub>(For section-less feature see: [#2](https://github.com/martinswiderski/config.ini/issues/2))</sub>

```javascript 1.8
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
    /// (...)
```
[&laquo; back to list](#examples)

#### <a name="file"></a>Reading from a file

Reading config from a `file.ini`

```javascript 1.8
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
    /// (...)
```

[&laquo; back to list](#examples)

#### <a name="output"></a>Output to an .ini string

```javascript 1.8

    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
'

```

[&laquo; back to list](#examples)

#### <a name="i8n"></a>I8N Support

For the `.ini` file as follows:

```bash
[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:

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

[&laquo; back to list](#examples)

---
_Source: https://npm.io/package/config.ini · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
