Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

load-ini

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

load-ini

Read and parse a .ini file

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

load-ini

Read and parse a .ini file

NPM version Codacy Badge Test coverage npm download License

Sonar

DocumentationChange Log

Installing

# use pnpm
$ pnpm install load-ini

# use npm
$ 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

  • Since: 1.0.0

  • Arguments:

ParametersDescriptionTypeOptionalRequiredDefault
pathpath of ini filestring-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[]>

loadIniSync

Read and parse a .ini file sync mode

  • Since: 1.0.0

  • Arguments:

ParametersDescriptionTypeOptionalRequiredDefault
pathpath of ini filestring-true-
  • Returns: object | array

  • Example:

loadIniSync('/path/of/ini_file')
// { "name": "saqqdy" }
  • Types:
declare function loadIniSync(path: string): Record<string, unknown> | unknown[]

parseIni

Parse ini string into object

  • Since: 1.0.0

  • Arguments:

ParametersDescriptionTypeOptionalRequiredDefault
dataini stringstring-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[]

stringifyIni

Convert objects to ini strings

  • Since: 1.0.0

  • Arguments:

ParametersDescriptionTypeOptionalRequiredDefault
dataobject dataobject 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

Support & Issues

Please open an issue here.

License

MIT

Keywords

FAQs

Package last updated on 16 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc