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

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

Demo

demo-screenshot.jpg

Source in ./ui

Platforms

Node, Web, Deno

Install

npm i @grossacasacs/left-phalange

Usage

// Node
import {parse, load, loadAsync, stringify, supportedExtensions} from '@grossacasacs/left-phalange'
// Web
import {parse, stringify} from '@grossacasacs/left-phalange' // should resolve to /dist/browser.es.js
// Deno
import {parse, stringify, load, loadAsync} from 'https://unpkg.com/@grossacasacs/left-phalange/dist/deno.es.js'

load(file[, options])

Loading from a file

  • 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')

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

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

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

loadAsync(file[, options])

Promise version of load

parse(string[, options])

Parsing from a string

  • 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

examples:

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

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

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

stringify(data[, options])

Creating a string from an object

  • 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',
// }

Changelog

Changelog

Related

License

MIT ©

Author: Shantun Parmar

71 thoughts on “CommonJS, ESModule, INI, JSON, JSON5, TOML, YAML data loader, parser and stringifier

  1. If you want to use the photo it would also be good to check with the artist beforehand in case it is subject to copyright. Best wishes. Aaren Reggis Sela

  2. If you want to use the photo it would also be good to check with the artist beforehand in case it is subject to copyright. Best wishes. Aaren Reggis Sela

  3. If you want to use the photo it would also be good to check with the artist beforehand in case it is subject to copyright. Best wishes. Aaren Reggis Sela

  4. If some one desires expert view on the topic of running a blog afterward i recommend him/her to pay a visit this webpage, Keep up the nice work. Pam Tammy Micki

  5. You made some nice points there. I looked on the internet for the subject matter and found most individuals will agree with your site.

  6. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  7. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  8. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  9. You made some nice points there. I looked on the internet for the subject matter and found most individuals will agree with your site.

  10. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  11. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  12. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  13. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  14. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  15. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  16. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  17. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  18. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  19. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  20. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  21. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  22. Helpful information. Lucky me I found your site accidentally, and I am stunned why this coincidence did not happened in advance! I bookmarked it. Maxie Reuven Melodee

  23. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Sillinger. Riannon Cristiano Jarrell

  24. Article writing is also a fun, if you know afterward you can write otherwise it is complicated to write. Kania Milt Philbin

  25. Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  26. Howdy, i read your blog from time to time and i own a similar one and i was
    just wondering if you get a lot of spam remarks? If so how do you reduce it, any plugin or
    anything you can advise? I get so much lately
    it’s driving me crazy so any support is very much appreciated.

  27. Pretty portion of content. I simply stumbled upon your site and in accession capital to say that I get actually enjoyed account your weblog posts.
    Any way I’ll be subscribing to your augment and even I success you get admission to constantly
    quickly.

  28. Wonderful blog! I found it while searching on Yahoo News.
    Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there!
    Thanks

  29. Hi there, just became alert to your blog through Google, and found that it is really informative. I am gonna watch out for brussels. I will appreciate if you continue this in future. Many people will be benefited from your writing. Cheers! Nedi Heriberto Thistle

  30. Heya i’m for the first time here. I came across this board and I find
    It really useful & it helped me out much. I hope to give something back and aid
    others like you helped me.

  31. Hi there, I do believe your website could possibly be having web browser compatibility issues. Whenever I take a look at your blog in Safari, it looks fine however when opening in IE, it has some overlapping issues. Anjela Manuel Derron

  32. Hello there, I discovered your site by way of
    Google whilst looking for a similar subject, your web site came up, it seems good.

    I’ve bookmarked it in my google bookmarks.
    Hello there, simply changed into aware of your weblog via Google, and found that it is really informative.
    I’m gonna be careful for brussels. I’ll appreciate in the event you proceed this in future.

    Numerous other folks can be benefited from your writing. Cheers!

Leave a Reply

Your email address will not be published.