Installing
$ pnpm install load-ini
$ npm install load-ini --save
Usage
1. Nodejs require
const { loadIni, loadIniSync } = require('load-ini')
loadIni('/path/of/ini_file').then(data => {})
loadIniSync('/path/of/ini_file')
2. ES6 module
import { loadIni, loadIniSync } from 'load-ini'
API Reference
loadIni
Read and parse a .ini file
Parameters | Description | Type | Optional | Required | Default |
---|
path | path of ini file | string | - | true | - |
-
Returns: object | array
-
Example:
loadIni('/path/of/ini_file').then(data => {
console.log(data)
})
declare function loadIni(path: string): Promise<Record<string, unknown> | unknown[]>
loadIniSync
Read and parse a .ini file sync mode
Parameters | Description | Type | Optional | Required | Default |
---|
path | path of ini file | string | - | true | - |
-
Returns: object | array
-
Example:
loadIniSync('/path/of/ini_file')
declare function loadIniSync(path: string): Record<string, unknown> | unknown[]
parseIni
Parse ini string into object
Parameters | Description | Type | Optional | Required | Default |
---|
data | ini string | string | - | true | - |
-
Returns: object | array
-
Example:
parseIni(`
[user]
name = saqqdy
age = 18
`)
declare function parseIni(data: string): Record<string, unknown> | unknown[]
stringifyIni
Convert objects to ini strings
Parameters | Description | Type | Optional | Required | Default |
---|
data | object data | object array | - | true | - |
stringifyIni({ name: 'saqqdy', age: 18 })
declare function stringifyIni<T>(data: T, options?: EncodeOptions): string
Support & Issues
Please open an issue here.
License
MIT