@architect/parser
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "@architect/parser", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Architect Parser accepts plaintext, JSON, or YAML .arc manifests and returns a plain JavaScript Object", | ||
@@ -10,4 +10,4 @@ "main": "./src/index.js", | ||
"coverage": "nyc --reporter=lcov --reporter=text-summary npm run test:unit", | ||
"_test": "npm run lint && npm run coverage", | ||
"test": "npm run lint && npm run test:unit", | ||
"test": "npm run lint && npm run coverage", | ||
"t": "npm run lint && npm run test:unit", | ||
"rc": "npm version prerelease --preid RC" | ||
@@ -14,0 +14,0 @@ }, |
@@ -11,3 +11,3 @@ # [`@architect/parser`](https://www.npmjs.com/package/@architect/parser) [![GitHub CI status](https://github.com/architect/parser/workflows/Node%20CI/badge.svg)](https://github.com/architect/parser/actions?query=workflow%3A%22Node+CI%22) | ||
- `arc.json` - [example](/examples/arc.json) - [schema](https://arc.codes/schema.json) | ||
- `arc.yaml` - [example](/examples/arc.yaml) | ||
- `arc.yaml` - [example](/examples/arc.yml) | ||
- `arc.toml` - [example](/examples/arc.toml) | ||
@@ -14,0 +14,0 @@ |
@@ -84,5 +84,5 @@ const notempty = require('./_not-empty') | ||
if (is.map) | ||
return map(lines, index) | ||
return map(lines) | ||
throw new TypeUnknown(tokens[index]) | ||
} |
@@ -13,7 +13,7 @@ const notempty = require('./_not-empty') | ||
*/ | ||
module.exports = function map(lines, index) { | ||
module.exports = function map(lines) { | ||
// extract the `name` and create the `end` index | ||
let copy = lines.slice(0) | ||
let end = index + copy[0].length + 1 | ||
let end = copy[0].length + 1 // length of the current line plus one for the line | ||
let raw = copy.shift().filter(notempty)[0] | ||
@@ -34,22 +34,14 @@ let name = raw.value | ||
while (!done) { | ||
// figure out the indentation of the next line | ||
let line = copy.shift() | ||
let {onespace, twospace, threespace, fourspace, fivespace} = spaces(line) | ||
let onespace = Array.isArray(line) && line.length > 2 && line[0].type == 'space' && line[1].type != 'space' | ||
let twospace = Array.isArray(line) && line.length > 2 && line[0].type == 'space' && line[1].type == 'space' | ||
let threespace = Array.isArray(line) && line.length >= 4 && line[0].type == 'space' && line[1].type == 'space' && line[2].type == 'space' && line[3].type != 'space' | ||
let fourspace = Array.isArray(line) && line.length >= 5 && line[0].type == 'space' && line[1].type == 'space' && line[2].type == 'space' && line[3].type == 'space' | ||
let fivespace = Array.isArray(line) && line.length >= 5 && line[0].type == 'space' && line[1].type == 'space' && line[2].type == 'space' && line[3].type == 'space' && line[4].type == 'space' | ||
if (onespace || threespace || fivespace) | ||
throw new SpaceError(line[0]) //SyntaxError('illegal single space indent line ' + line[0].line) | ||
throw new SpaceError(line[0]) | ||
if (fourspace && done === false) { | ||
// four spaces signals a vector value | ||
if (line.filter(notempty).length > 1) | ||
throw new KeyError(line[0])//SyntaxError('illegal too many values on line ' + line[0].line) | ||
// if (last === false || Array.isArray(value[name][last]) === false) | ||
// throw SyntaxError('illegal vector key must be string value on line ' + line[0].line) | ||
throw new KeyError(line[0]) | ||
end += 1 // one for the line | ||
@@ -61,2 +53,3 @@ end += line.length // for all the tokens in the given line | ||
else if (twospace && done === false) { | ||
// two spaces signals a key/value | ||
@@ -73,2 +66,3 @@ end += 1 // one for the line | ||
else { | ||
// indentation is over: we out | ||
@@ -80,1 +74,13 @@ done = true | ||
} | ||
/** hide this here */ | ||
function spaces(line) { | ||
if (!Array.isArray(line)) | ||
return {onespace: false, twospace: false, threespace: false, fourspace: false, fivespace: false} | ||
let onespace = line.length > 2 && line[0].type == 'space' && line[1].type != 'space' | ||
let twospace = line.length > 2 && line[0].type == 'space' && line[1].type == 'space' | ||
let threespace = line.length >= 4 && line[0].type == 'space' && line[1].type == 'space' && line[2].type == 'space' && line[3].type != 'space' | ||
let fourspace = line.length >= 5 && line[0].type == 'space' && line[1].type == 'space' && line[2].type == 'space' && line[3].type == 'space' | ||
let fivespace = line.length >= 5 && line[0].type == 'space' && line[1].type == 'space' && line[2].type == 'space' && line[3].type == 'space' && line[4].type == 'space' | ||
return {onespace, twospace, threespace, fourspace, fivespace} | ||
} |
@@ -11,6 +11,6 @@ const notempty = require('./_not-empty') | ||
*/ | ||
module.exports = function vector(lines, index) { | ||
module.exports = function vector(lines) { | ||
let copy = lines.slice(0) | ||
let end = index + copy[0].length + 1 | ||
let end = copy[0].length + 1 // len of the tokes in the line plus one for the line itself | ||
let raw = copy.shift().filter(notempty)[0] | ||
@@ -17,0 +17,0 @@ let name = raw.value |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
475124
11701
3