Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@architect/parser

Package Overview
Dependencies
Maintainers
7
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/parser

Architect Parser accepts plaintext, JSON, or YAML .arc manifests and returns a plain JavaScript Object

  • 1.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.9K
increased by118.05%
Maintainers
7
Weekly downloads
 
Created
Source

@architect/parser

Build Status

.arc is a simplistic text format for storing structured data; @architect/parser is a function that accepts text and returns a plain JavaScript Object

The format:

  • Starts with a @section
  • Sections start with @
  • Sections contain either scalar values, Vector or Map
  • Scalar values are either String, Number or Boolean
  • Vector values are space seperated scalar values on a single line
  • A Map is defined by a scalar value followed by Vectors indented two spaces
  • Comments follow # symbols

Install

npm i arc-parser

Example Usage

var parser = require('arc-parser')
var fs = require('fs')
var text = fs.readFileSync('./some-arc-file.txt').toString()
var result = parse(text)

Example

Input

# this is a comment
@section-one
simple-string-value # String
another-value 
4.2 # Number
true # Boolean

@another-section-of-vectors
vector of values 
vector tuple

@this-section-has-a-map
hello-world
  name some-value

Output

{
  "section-one": [
    "simple-string-value",
    "another-value",
    4.2,
    true
  ],
  "another-section-of-vectors": [
    ["vector", "of", "values"],
    ["vector", "tuple"]
  ],
  "this-section-has-a-map": [{
    "hello-world": {
      "name": "some-value"
    }
  }]
}

Experimental Support

To facilitate interop the main module exported here has the additional methods that are specific to the Architect .arc format:

  • parse.json(jsonText) returns .arc compatible Object
  • parse.yaml(yamlText) returns .arc compatible Object
  • parse.json.stringify returns .arc compatible String
  • parse.yaml.stringify returns .arc compatible String

It is worth noting that parse is a generic .arc format parser in a similar vien to yaml and json. the impl above parse.json and parse.yaml are Architect grammer specific dialects of json and yaml.

FAQs

Package last updated on 17 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc