# ini-parser-encoder

> A helper to parse,encode ini file for nodejs

Latest version **0.0.4** (published 2017-10-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ini-parser-encoder
pnpm add ini-parser-encoder
yarn add ini-parser-encoder
bun add ini-parser-encoder
```

## 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.4 |
| Published | 2017-10-30 |
| First published | 2017-09-23 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | levi.lu |
| Maintainers | lscgzwd |
| Keywords | ini, nodejs, npm, parser |

## Links

- npm: https://www.npmjs.com/package/ini-parser-encoder
- Repository: https://github.com/lscgzwd/node-ini-parser
- Homepage: https://github.com/lscgzwd/node-ini-parser#readme
- Issues: https://github.com/lscgzwd/node-ini-parser/issues
- npm.io page: https://npm.io/package/ini-parser-encoder

## 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.4 (latest) — 2017-10-30
- 0.0.3 — 2017-10-10
- 0.0.2 — 2017-09-23
- 0.0.1 — 2017-09-23

## README

# ini-parser-encoder
A helper to parse ini file for nodejs

# USAGE


```
npm install ini-parser-encoder
```
## parse
```
var parser = require('ini-parser-encoder');
// sync
var config = parser.parseFileSync(INI_FILE, sub_separator, process_section, file_encoding, return_number_as_string);
// async
var parser.parseFile(INI_FILE, function(err, data) {
    if (err) {
        //
    } else {
        //
    }
}, sub_separator, process_section, file_encoding, return_number_as_string)
```
### subSeparator
`a.b.c = val` will be parse as {a:{b:{c: val}}}, the default sub separator is `.` , you can change it by pass param subSeparator
### processSection
By default, will process section `[section]` as object property, you can pass `false` to disable it.  
## note
if set returnNumberAsString to false,  will return Number(value) if a line only contain number and point

## encode

```
var obj = {
    hello: 'world',
    arr: ['a', 'b', 'c'],
    sectionA: {
        itema: 'stringa',
        itemb: true
    }
}
var strIni = parser.encode(obj);
// save to file
```

# Example for ini file
```
hello = world ; inline comment
booltest = true
numbertest = 1
floattest = 2.22
floattesta = 0.333
notfloattest = .4444
; this is comment
[sectionA]
# # comment not recommend
itemarray[] = a
itemarray[] = b
itemarray[] = c
[sectionB]
# sub seperator test
itemobject.subobj.a = 1
itemobject.subobj.b.d = 2
itemobject.subobj.b.e = 2
[mysql]
database="mis"
username="rd"
password="ABCDD=="
host=100.0.0.2
port="3306"
charset= "utf8"
```

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