# ini-parser-plus

> INI configuration file parser with .local file support.

Latest version **1.0.1** (published 2018-06-15) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-06-15 |
| First published | 2018-06-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sebastian Babb |
| Maintainers | sbabb |
| Keywords | ini, config, configuration, parser |

## Links

- npm: https://www.npmjs.com/package/ini-parser-plus
- npm.io page: https://npm.io/package/ini-parser-plus

## Dependencies (1)

- [path](https://npm.io/package/path.md) ^0.12.7

## 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

- 1.0.1 (latest) — 2018-06-15
- 1.0.0 — 2018-06-15

## README

# ini-parser-plus

A simple INI configuration file parser with support for .local files.

## Installation

Using npm:
```shell
$ npm i --save ini-parser-plus
```

## Usage

In myConfig.ini:
```ini
; general settings
[general]
force-ssl-port=443
timezone="US/Pacific"
country-timezones="US"
lang="en"

; settings for ajax/javascript
[ajax]
server-timeout=25000 
upload-timeout=2700000
ajax-refresh=5000
ajax-refresh-on-request-status=1000
log=no
autocomplete-search-delay=2000
```

In myConfig.ini.local:<br />
_Any new sections will be added to the config object and any redeclared section properties will override those set in myConfig.ini._
```ini
; general settings
[general]
timezone="US/Mountain"  ; Overrides existing timezone property.
locale="eu_US"			; Adds locale property.

; Adds an entirely new section.
[debug]
level=0 
```

In Node.js:
```js
// Load the parser.
var config_parser = require('ini-parser-plus')();

// Set the config path.
config_parser.setPath('./myConfig.ini');

// Get all sections.
var sections = config_parser.getSection();

console.log(sections);

[ 'general', 'ajax', 'debug' ]

// Get a specific section's properties.
var properties = config_parser.getSectionProperties("general");                                                                                                                                                                                                             

console.log(properties);

[ 'force-ssl-port',
  'timezone',
  'country-timezones',
  'lang',
  'locale' ]

// Load the config file into an object.
var config = config_parser.getConfig();

console.log(config);

{ general: 
   { 'force-ssl-port': '443',
     timezone: 'US/Mountain',
     'country-timezones': 'US',
     lang: 'en',
     locale: 'en_US' },
  ajax: 
   { 'server-timeout': '25000',
     'upload-timeout': '2700000',
     'ajax-refresh': '5000',
     'ajax-refresh-on-request-status': '1000',
     log: 'no',
     'autocomplete-search-delay': '2000' },
  debug: { 
  	level: '0' 
    }
}

// Access the sections and their properties using Dot notation.
console.log(config.general.timezone);
US/Mountain

// Access the sections and their properties using Bracket notation.
console.log(config.ajax['server-timeout']);
25000

```

Exception Handling:
```exc
let config_parser = require('config-parser')();                                                                                                                                                                                                                             

try {                                                                                                                                                                                                                                                                           
    config_parser.setConfigPath('./no/such/path/myConfig.ini');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
} catch(e) {
	console.log(e.code +"::"+ e.message); 
}

2::No config file(s) found

```

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