Giter VIP home page Giter VIP logo

parserblade's Introduction

parserblade

CI

A all-in-one parser for Javascript, heavily inspired by: https://github.com/nathanmac/Parser. It allows you to work with JSON, XML, CSV and YAML more without worrying about which module install. It's designed to work just as JSON.parse and JSON.stringify does, with some improvements.

See docs for more info and examples.

Installation

$ npm install --save parserblade

Usage

Every filetype has two main methods: stringify() and parse(), both receives two arguments, data containing any type of data and an options object.

CSV

const { csv } = require('parserblade')

// Parsing
const input = 'title,platform\nStardew Valley,Steam'
const result = csv.parse(input)
console.log(result) // [ { title: 'Stardew Valley', platform: 'Steam' } ]

// Stringifying
console.log(
  csv.stringify(result)
) // 'title,platform\nStardew Valley,Steam'

YAML

const { yaml } = require('parserblade')

// Parsing
const input = 'title: Stardew Valley\nplatform: Steam'
const result = yaml.parse(input)
console.log(result) // { title: 'Stardew Valley', platform: 'Steam' }

// Stringifying
console.log(
  yaml.stringify(result)
) // 'title: Stardew Valley\nplatform: Steam'

XML

const { xml } = require('parserblade')

// Parsing
const input = '<?xml version="1.0" encoding="utf-8"?><package>lodash</package>'
const result = xml.parse(input)
console.log(result) // { package: 'lodash' }

// Stringifying
console.log(
  xml.stringify(result)
) // '<?xml version="1.0" encoding="utf-8"?><package>lodash</package>'

License

MIT ©

parserblade's People

Contributors

onhernandes 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.