@cnrs/hel 0.5.0 → 0.5.1

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.1",
32
32
  "keywords": [
33
33
  "hera",
34
34
  "hecate",
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
@@ -129,6 +129,7 @@ class StringToFunctionVisitor extends CstVisitor {
129
129
  const visitor = new StringToFunctionVisitor(); // this is stateless, so Singleton
130
130
 
131
131
  export function toFunction(input) {
132
+ if (!input) return (item) => true; // accepts ""
132
133
  const result = tokenize(input);
133
134
  parser.input = result.tokens; // resets the parser's internal state
134
135
  const cst = parser.statement(); // semantics actions are now defined