@architect/parser
Advanced tools
Comparing version 1.1.4 to 1.1.5
module.exports = function getSections(text) { | ||
if (!text.startsWith('@')) { | ||
@@ -31,6 +31,7 @@ throw SyntaxError(`invalid_arc | ||
Invalid value: "${name}" | ||
`) | ||
`) | ||
} | ||
// validates section values | ||
// eslint-disable-next-line | ||
var index = 0 | ||
@@ -59,3 +60,3 @@ var lastToken = false | ||
Invalid value: "${val}" | ||
`) | ||
`) | ||
} | ||
@@ -62,0 +63,0 @@ } |
14
_json.js
@@ -5,3 +5,3 @@ /** | ||
* usage | ||
* | ||
* | ||
* let parse = require('@architect/parser') | ||
@@ -12,3 +12,3 @@ * console.log(parse.json(jsontext)) | ||
let json = JSON.parse(raw) | ||
let json = JSON.parse(raw) | ||
let result = {} | ||
@@ -27,3 +27,3 @@ | ||
result.aws = [ | ||
['region', json[section].region], | ||
['region', json[section].region], | ||
['profile', json[section].profile] | ||
@@ -35,3 +35,3 @@ ] | ||
result.static = [ | ||
['staging', json[section].staging], | ||
['staging', json[section].staging], | ||
['production', json[section].production] | ||
@@ -113,3 +113,3 @@ ] | ||
_json.stringify = function _stringify(json) { | ||
let raw = JSON.parse(json) | ||
let raw = JSON.parse(json) | ||
let result = '' | ||
@@ -201,3 +201,3 @@ result += '@app\n' | ||
let props = Object.keys(table[name]) | ||
result += `${name}\n` | ||
result += `${name}\n` | ||
props.forEach(prop=> { | ||
@@ -214,3 +214,3 @@ result += ` ${prop} ${table[name][prop]}\n` | ||
let props = Object.keys(table[name]) | ||
result += `${name}\n` | ||
result += `${name}\n` | ||
props.forEach(prop=> { | ||
@@ -217,0 +217,0 @@ result += ` ${prop} ${table[name][prop]}\n` |
@@ -11,3 +11,3 @@ module.exports = function visit(section) { | ||
if (s === 'true') return true | ||
if (s === 'false') return false | ||
if (s === 'false') return false | ||
return s | ||
@@ -17,3 +17,3 @@ } | ||
function parseMembers(rtrn) { | ||
var num = s=> isNaN(s)? s : +s | ||
@@ -27,3 +27,3 @@ var name = Object.keys(rtrn)[0] | ||
members.forEach(member=> { | ||
// this line has no spaces | ||
@@ -58,7 +58,7 @@ var isSingle = !/ /g.test(member) | ||
else if (isVector) { | ||
finals.push(member.split(' ').map(num).map(bool)) | ||
finals.push(member.replace(/( ){1,}/g, ' ').split(' ').map(num).map(bool)) | ||
index += 1 | ||
} | ||
else if (isSingle) { | ||
finals.push(isNaN(member)? bool(member) : +member) | ||
finals.push(isNaN(member)? bool(member) : +member) | ||
index += 1 | ||
@@ -65,0 +65,0 @@ } |
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line | ||
var comments = /\#.*/gm | ||
@@ -9,0 +10,0 @@ var emptyLines = /(^[ \t]*\n)/gm |
12
index.js
@@ -5,3 +5,3 @@ let _parse = require('./_parse') | ||
// to remain backwards compat we augment _parse | ||
// to remain backwards compat we augment _parse | ||
// and treat it as a namespace for these extended fns | ||
@@ -13,3 +13,3 @@ // everything is pure here so its cool.. | ||
/** | ||
* parse | ||
* parse | ||
* parse .arc text into a js intermediate obj | ||
@@ -23,3 +23,3 @@ * | ||
* | ||
* parse.json | ||
* parse.json | ||
* parse json text into a js intermediate obj | ||
@@ -39,6 +39,6 @@ * | ||
* parse.yaml(txt) | ||
* | ||
* | ||
* --- | ||
* | ||
* parse.stringify | ||
* parse.stringify | ||
* stringify intermediate obj to .arc format | ||
@@ -49,3 +49,3 @@ * | ||
* parse.stringify({ | ||
* app: ['testapp'], | ||
* app: ['testapp'], | ||
* html:[['get', '/']] | ||
@@ -52,0 +52,0 @@ * }) |
{ | ||
"name": "@architect/parser", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "function that accepts .arc text and returns a plain JavaScript Object", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint . --fix", | ||
"test": "tape test/**/*-test.js | tap-spec", | ||
@@ -13,2 +14,3 @@ "t": "node test/05-arc-json-test.js | tap-spec" | ||
"devDependencies": { | ||
"eslint": "^5.8.0", | ||
"tap-spec": "^4.1.1", | ||
@@ -15,0 +17,0 @@ "tape": "^4.6.3" |
@@ -1,7 +0,6 @@ | ||
# <kbd>:cloud_with_lightning: @architect/parser</kbd> | ||
## [`@architect/parser`](https://www.npmjs.com/package/@architect/parser) | ||
[![Build Status](https://travis-ci.com/arc-repos/arc-parser.svg?branch=master)](https://travis-ci.com/arc-repos/arc-parser) | ||
> `.arc` is a simplistic text format for storing structured data; `@architect/parser` is a function that accepts text and returns a plain JavaScript `Object` | ||
[ ![Codeship Status for arc-repos/arc-parser](https://app.codeship.com/projects/8ac91c80-4f9d-0135-36b3-22bcd0c3040e/status?branch=master)](https://app.codeship.com/projects/234098) | ||
The format: | ||
@@ -8,0 +7,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68595
13
598
3
81