@cnrs/hel 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -28,7 +28,7 @@
28
28
  "https://medium.com/sapioit/why-having-3-numbers-in-the-version-name-is-bad-92fc1f6bc73c",
29
29
  "https://gist.github.com/jashkenas/cbd2b088e20279ae2c8e"
30
30
  ],
31
- "version": "0.5.0",
31
+ "version": "0.5.2",
32
32
  "keywords": [
33
33
  "hera",
34
34
  "hecate",
@@ -144,4 +144,4 @@
144
144
  "lint": "exec eslint \"src/**/*.js\"",
145
145
  "doc:html": "./node_modules/jsdoc/jsdoc.js -c .jsdoc.conf.json"
146
146
  }
147
- }
147
+ }
package/src/ast2str.js CHANGED
@@ -104,5 +104,6 @@ function validate(ast, keys) {
104
104
 
105
105
 
106
106
  export function toString(ast) {
107
+ if (Object.keys(ast).length < 1) return ""; // accepts {}
107
108
  return visit(ast);
108
109
  }
package/src/str2ast.js CHANGED
@@ -102,6 +102,7 @@ class StringToAstVisitor extends CstVisitor {
102
102
  const visitor = new StringToAstVisitor(); // this is stateless, so Singleton
103
103
 
104
104
  export function toAst(input) {
105
+ if (!input) return {}; // accepts ""
105
106
  const result = tokenize(input);
106
107
  parser.input = result.tokens; // resets the parser's internal state
107
108
  const cst = parser.statement(); // semantics actions are now defined
package/src/str2fun.js CHANGED
@@ -96,7 +96,8 @@ class StringToFunctionVisitor extends CstVisitor {
96
96
  if (context.attribute) return this.visit(context.attribute);
97
97
  if (context.property) return this.visit(context.property);
98
98
  if (context.Integer) return parseInt(context.Integer[0].image);
99
- return context.String[0].image;
99
+ const value = context.String[0].image;
100
+ return value.substring(1, value.length-1); // remove surrounding quotes
100
101
  }
101
102
 
102
103
  relationalOperator(context) {
@@ -129,6 +130,7 @@ class StringToFunctionVisitor extends CstVisitor {
129
130
  const visitor = new StringToFunctionVisitor(); // this is stateless, so Singleton
130
131
 
131
132
  export function toFunction(input) {
133
+ if (!input) return () => true; // accepts ""
132
134
  const result = tokenize(input);
133
135
  parser.input = result.tokens; // resets the parser's internal state
134
136
  const cst = parser.statement(); // semantics actions are now defined