1.4.4 • Published 2 years ago

gura v1.4.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago