Giter VIP home page Giter VIP logo

gura-js-parser's Introduction

Gura Javascript/Typescript parser

CI

This repository contains the implementation of a Gura (compliant with version 1.0.0) format parser for Javascript written in pure Typescript.

Installation

# NPM
npm install gura --save

# Yarn
yarn add gura

# Bower
bower install gura --save

Usage

import { parse, dump } from 'gura'

const guraString = `
# This is a Gura document.
title: "Gura Example"

an_object:
    username: "Stephen"
    pass: "Hawking"

# Line breaks are OK when inside arrays
hosts: [
    "alpha",
    "omega"
]`

// Parse: transforms a Gura string into a dictionary
const parsedGura = parse(guraString)
console.log(parsedGura) // {title: 'Gura Example', an_object: {'username': 'Stephen', 'pass': 'Hawking'}, hosts: ['alpha', 'omega']}

// Access a specific field
console.log(`Title -> ${parsedGura['title']}`)

// Iterate over structure
for (const host of parsedGura['hosts']) {
    console.log(`Host -> ${host}`)
}

// Dump: transforms a dictionary into a Gura string
console.log(dump(parsedGura))

Troubleshoot

Module not found: Error: Can't resolve 'fs' (or 'path')

If you are using this library for the browser, there are some components like path or fs that are not available as you can not access the filesystem. If your code is not transpiling, you can try adding this block to your Webpack configuration:

module.export = {
    // ...
    resolve: {
        // ...
        fallback: {
            fs: false,
            path: false
        }
    }
}

Contributing

All kind of contribution is welcome! If you want to contribute just:

  1. Fork this repository.
  2. Create a new branch and introduce there your new changes.
  3. Run yarn check-all (or npm run check-all with NPM). This command runs tests and linter to check that new changes are correct!
  4. Make a Pull Request!

Or you can join to our community in Discord!

Tests

To run all the tests: yarn test or npm run test

License

This repository is distributed under the terms of the MIT license.

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.