# use pnpm
$ pnpm install load-ini
# use npm
$ npm install load-ini --save
const { loadIni, loadIniSync } = require('load-ini')
loadIni('/path/of/ini_file').then(data => {})
loadIniSync('/path/of/ini_file')
import { loadIni, loadIniSync } from 'load-ini'
Read and parse a .ini file
-
Since:
1.0.0
-
Arguments:
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)
// { "name": "saqqdy" }
})
- Types:
declare function loadIni(path: string): Promise<Record<string, unknown> | unknown[]>
Read and parse a .ini file sync mode
-
Since:
1.0.0
-
Arguments:
Parameters | Description | Type | Optional | Required | Default |
---|---|---|---|---|---|
path | path of ini file | string |
- | true | - |
-
Returns:
object | array
-
Example:
loadIniSync('/path/of/ini_file')
// { "name": "saqqdy" }
- Types:
declare function loadIniSync(path: string): Record<string, unknown> | unknown[]
Parse ini string into object
-
Since:
1.0.0
-
Arguments:
Parameters | Description | Type | Optional | Required | Default |
---|---|---|---|---|---|
data | ini string | string |
- | true | - |
-
Returns:
object | array
-
Example:
parseIni(`
[user]
name = saqqdy
age = 18
`)
// { "name": "saqqdy", age: 18 }
- Types:
declare function parseIni(data: string): Record<string, unknown> | unknown[]
Convert objects to ini strings
-
Since:
1.0.0
-
Arguments:
Parameters | Description | Type | Optional | Required | Default |
---|---|---|---|---|---|
data | object data | object array |
- | true | - |
-
Returns:
string
-
Example:
stringifyIni({ name: 'saqqdy', age: 18 })
// [user]
// name = saqqdy
// age = 18
- Types:
declare function stringifyIni<T>(data: T, options?: EncodeOptions): string
Please open an issue here.