Giter Club home page Giter Club logo

load-ini's Introduction

load-ini

Read and parse a .ini file

NPM version Codacy Badge Test coverage npm download License

Sonar

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:

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[]>

loadIniSync

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[]

parseIni

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[]

stringifyIni

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

Support & Issues

Please open an issue here.

License

MIT

load-ini's People

Contributors

saqqdy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.