Giter VIP home page Giter VIP logo

left-phalange-api's Introduction

left-phalange-api

CommonJS, ESModule, INI, JSON, JSON5, TOML, YAML data loader, parser and stringifier

Install

yarn add left-phalange-api

Usage

import {parse, load, stringify} from 'left-phalange-api'

load(file[, options])

  • file
    • Data file path to load
  • options
    • Optional
    • Type Object | String
    • Default {}
  • options(String)
    • options.type
  • options.type
    • Data type of file
    • Should be one of cjs, esm, ini, js, json, json5, toml, yaml

examples:

load('path/to/data.json')

load('path/to/data', 'yaml')

load('path/to/data', {type: 'toml'})

parse(string[, options])

  • string
    • type: String
    • string to parse
  • options
    • Optional
    • Type Object | String
    • Default {}
  • options(String)
    • options.type
  • options.type
    • Data type of string
    • Default yaml
    • Should be one of ini, json, json5, toml, yaml
  • options.filename
    • Filename displayed in the error message.

examples:

parse('{"left": "phalange"}')

parse('{"left": "phalange"}', 'json')

parse('left = "phalange"', {type: 'toml'})

parse('left = phalange', {filename: 'path/to/data.yml'})

stringify(data[, options])

  • data
    • Data to stringify
  • options
    • Optional
    • Type Object | String | Boolean
    • Default {}
  • options(String)
    • options.type
  • options(Boolean)
    • options.pretty
  • options.type
    • Data type of string
    • Default json
    • Should be one of cjs, esm, ini, json, json5
  • options.pretty
    • Pretty output
    • Default false

examples:

stringify({left: 'phalange'})
// {"left": "phalange"}

stringify({left: 'phalange'}, 'toml')
// left = "phalange"

stringify({left: 'phalange'}, true)
// {
//   "left": "phalange"
// }

stringify({left: 'phalange'}, {type: 'json5', pretty: true})
// {
//   left: 'phalange',
// }

Related

License

MIT © fisker Cheung

left-phalange-api's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar fisker avatar renovate-bot avatar renovate[bot] 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.