diff --git a/README.md b/README.md index f542f6c..a7990b3 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,20 @@ await copy({ }) ``` +### `INI` +Provides [INI API](https://github.com/npm/ini#readme). +```js +import {INI} from 'zx-extra' + +const ini = `[database] +user = dbuser +password = dbpassword +` + const parsed = INI.parse(ini) + parsed.database.user // 'dbuser' + INI.stringify(parsed, {whitespace: true}) // ini +``` + ### `SSRI` Exposes [SSRI API](https://github.com/npm/ssri#readme) ```js diff --git a/src/main/js/goods.mjs b/src/main/js/goods.mjs index a30b887..4f85500 100644 --- a/src/main/js/goods.mjs +++ b/src/main/js/goods.mjs @@ -1,5 +1,5 @@ export * as tempy from 'tempy' export { default as ip } from 'ip' -export { semver, SSRI } from './reexport.mjs' +export { semver, SSRI, INI } from './reexport.mjs' export { default as tcping } from 'is-reachable' export { copy } from 'globby-cp' diff --git a/src/main/js/reexport.mjs b/src/main/js/reexport.mjs index ee720c9..120f6c4 100644 --- a/src/main/js/reexport.mjs +++ b/src/main/js/reexport.mjs @@ -11,3 +11,4 @@ const reexport = (name) => require(join( export const semver = reexport('semver') export const SSRI = reexport('ssri') +export const INI = reexport('ini') diff --git a/src/test/js/test.mjs b/src/test/js/test.mjs index e2dd67a..1807259 100644 --- a/src/test/js/test.mjs +++ b/src/test/js/test.mjs @@ -1,5 +1,5 @@ import {strict as assert} from 'node:assert' -import {$, semver, createHook, ip, tempy, tcping, ctx, copy, fs, path, SSRI} from '../../main/js/index.mjs' +import {$, semver, createHook, ip, tempy, tcping, ctx, copy, fs, path, SSRI, INI} from '../../main/js/index.mjs' // $.verbose { @@ -44,6 +44,17 @@ import {$, semver, createHook, ip, tempy, tcping, ctx, copy, fs, path, SSRI} fro assert.equal(parsed.toString(), integrity) } +// INI +{ + const ini = `[database] +user = dbuser +password = dbpassword +` + const parsed = INI.parse(ini) + assert.equal(parsed.database.user, 'dbuser') + assert.equal(INI.stringify(parsed, {whitespace: true}), ini) +} + // opt { const nothrow = $.opt({nothrow: true})