@gram-data/gram-stringify
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -60,4 +60,4 @@ 'use strict'; | ||
var edgeToString = function edgeToString(ast) { | ||
var left = ast.direction === 'left' ? '<-' : '-'; | ||
var right = ast.direction === 'right' ? '->' : '-'; | ||
var left = ast.relation === 'left' ? '<-' : '-'; | ||
var right = ast.relation === 'right' ? '->' : '-'; | ||
var leftNode = gramAst.isGramNode(ast.children[0]) ? nodeToString(ast.children[0]) : edgeToString(ast.children[0]); | ||
@@ -122,4 +122,4 @@ var rightNode = gramAst.isGramNode(ast.children[1]) ? nodeToString(ast.children[1]) : edgeToString(ast.children[1]); | ||
exports.default = gramStringifyPlugin; | ||
exports.stringify = stringify; | ||
exports.gramStringifyPlugin = gramStringifyPlugin; | ||
exports.toString = stringify; | ||
//# sourceMappingURL=gram-stringify.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-ast"),r=function(e){switch(e.type){case"integer":return e.value;case"string":return"`"+e.value+"`";case"tagged":return e.tag+"`"+e.value+"`";default:return"<ERROR, can't stringify literals of type "+e.type+">"}},t=function(n){return"{"+Object.entries(n).map((function(n,i){return(i>0?",":"")+n[0]+":"+(a=n[1],Array.isArray(a)?"["+a.map((function(e){return r(e)})).join(",")+"]":e.isLiteral(a)?r(a):t(a));var a})).join("")+"}"},n=function(e){var r=e.id||"",n=e.labels&&e.labels.length>0?":"+e.labels.join(":"):"",i=e.record&&0!==Object.keys(e.record).length?t(e.record):"";return""+r+n+(i.length>0?" ":"")+i},i=function(e){return"("+n(e)+")"},a=function r(t){var a="left"===t.direction?"<-":"-",o="right"===t.direction?"->":"-",c=e.isGramNode(t.children[0])?i(t.children[0]):r(t.children[0]),s=e.isGramNode(t.children[1])?i(t.children[1]):r(t.children[1]),u=n(t);return""+c+a+(u.length>0?"["+u+"]":"")+o+s},o=function r(t){switch(t.type){case"seq":return t.children.map((function(e){return r(e)})).join("\n");case"path":return function r(t){var o=n(t),c=t.children[0],s=c?""+(e.isGramNode(c)?i(c):e.isGramEdge(c)?a(c):e.isGramUnit(c)?"":r(c)):"";return o.length>0?"["+o+" "+s+"]":s}(t);case"node":return i(t);case"edge":return a(t);default:console.error("Impossible:",typeof t)}return[].join("")},c=function(r){return e.isGramPathlike(r)?o(r):"Don't know how to stringify \""+r.type+'" nodes'};exports.default=function(){this.Compiler=c},exports.stringify=o; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-ast"),r=function(e){switch(e.type){case"integer":return e.value;case"string":return"`"+e.value+"`";case"tagged":return e.tag+"`"+e.value+"`";default:return"<ERROR, can't stringify literals of type "+e.type+">"}},n=function(t){return"{"+Object.entries(t).map((function(t,i){return(i>0?",":"")+t[0]+":"+(a=t[1],Array.isArray(a)?"["+a.map((function(e){return r(e)})).join(",")+"]":e.isLiteral(a)?r(a):n(a));var a})).join("")+"}"},t=function(e){var r=e.id||"",t=e.labels&&e.labels.length>0?":"+e.labels.join(":"):"",i=e.record&&0!==Object.keys(e.record).length?n(e.record):"";return""+r+t+(i.length>0?" ":"")+i},i=function(e){return"("+t(e)+")"},a=function r(n){var a="left"===n.relation?"<-":"-",o="right"===n.relation?"->":"-",u=e.isGramNode(n.children[0])?i(n.children[0]):r(n.children[0]),s=e.isGramNode(n.children[1])?i(n.children[1]):r(n.children[1]),c=t(n);return""+u+a+(c.length>0?"["+c+"]":"")+o+s},o=function r(n){switch(n.type){case"seq":return n.children.map((function(e){return r(e)})).join("\n");case"path":return function r(n){var o=t(n),u=n.children[0],s=u?""+(e.isGramNode(u)?i(u):e.isGramEdge(u)?a(u):e.isGramUnit(u)?"":r(u)):"";return o.length>0?"["+o+" "+s+"]":s}(n);case"node":return i(n);case"edge":return a(n);default:console.error("Impossible:",typeof n)}return[].join("")},u=function(r){return e.isGramPathlike(r)?o(r):"Don't know how to stringify \""+r.type+'" nodes'};exports.gramStringifyPlugin=function(){this.Compiler=u},exports.toString=o; | ||
//# sourceMappingURL=gram-stringify.cjs.production.min.js.map |
@@ -56,4 +56,4 @@ import { isGramNode, isGramEdge, isGramUnit, isLiteral, isGramPathlike } from '@gram-data/gram-ast'; | ||
var edgeToString = function edgeToString(ast) { | ||
var left = ast.direction === 'left' ? '<-' : '-'; | ||
var right = ast.direction === 'right' ? '->' : '-'; | ||
var left = ast.relation === 'left' ? '<-' : '-'; | ||
var right = ast.relation === 'right' ? '->' : '-'; | ||
var leftNode = isGramNode(ast.children[0]) ? nodeToString(ast.children[0]) : edgeToString(ast.children[0]); | ||
@@ -118,4 +118,3 @@ var rightNode = isGramNode(ast.children[1]) ? nodeToString(ast.children[1]) : edgeToString(ast.children[1]); | ||
export default gramStringifyPlugin; | ||
export { stringify }; | ||
export { gramStringifyPlugin, stringify as toString }; | ||
//# sourceMappingURL=gram-stringify.esm.js.map |
import gramStringifyPlugin from './gram-stringify-plugin'; | ||
import stringify from './gram-stringify'; | ||
export { stringify }; | ||
export default gramStringifyPlugin; | ||
import toString from './gram-stringify'; | ||
export { toString, gramStringifyPlugin }; |
{ | ||
"name": "@gram-data/gram-stringify", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"license": "MIT", | ||
@@ -16,3 +16,3 @@ "main": "dist/index.js", | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"build": "tsdx build --format cjs,esm,umd", | ||
"test": "tsdx test", | ||
@@ -22,3 +22,5 @@ "test:watch": "tsdx test --watch", | ||
"lint:fix": "tsdx lint --fix", | ||
"prepare": "tsdx build" | ||
"prepare": "tsdx build", | ||
"build:demo": "shx cp dist/gram-stringify.umd.development.* ./public", | ||
"demo": "serve ./public/" | ||
}, | ||
@@ -39,3 +41,3 @@ "husky": { | ||
"devDependencies": { | ||
"@gram-data/gram-builder": "^0.1.8", | ||
"@gram-data/gram-builder": "^0.1.9", | ||
"@types/unist": "^2.0.3", | ||
@@ -45,2 +47,4 @@ "@typescript-eslint/parser": "^3.5.0", | ||
"npm-run-all": "^4.1.5", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"serve": "^11.3.2", | ||
"shx": "^0.3.2", | ||
@@ -52,6 +56,6 @@ "tsdx": "^0.13.2", | ||
"dependencies": { | ||
"@gram-data/gram-ast": "^0.1.8", | ||
"@gram-data/gram-ast": "^0.1.9", | ||
"unified": "^9.0.0" | ||
}, | ||
"gitHead": "767922021318156135c4fc0e755bdaa888f7a057", | ||
"gitHead": "43a096296038b010d268f648eb456207f8b1640b", | ||
"publishConfig": { | ||
@@ -58,0 +62,0 @@ "access": "public" |
@@ -0,1 +1,6 @@ | ||
# Gram Stringify | ||
--- | ||
# TSDX Bootstrap | ||
@@ -2,0 +7,0 @@ |
@@ -63,4 +63,4 @@ import { | ||
const edgeToString = (ast: GramEdge): string => { | ||
const left = ast.direction === 'left' ? '<-' : '-'; | ||
const right = ast.direction === 'right' ? '->' : '-'; | ||
const left = ast.relation === 'left' ? '<-' : '-'; | ||
const right = ast.relation === 'right' ? '->' : '-'; | ||
@@ -67,0 +67,0 @@ const leftNode = isGramNode(ast.children[0]) |
import gramStringifyPlugin from './gram-stringify-plugin'; | ||
import stringify from './gram-stringify'; | ||
import toString from './gram-stringify'; | ||
export { stringify }; | ||
export default gramStringifyPlugin; | ||
export { toString, gramStringifyPlugin }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
39895
33
11
339
Updated@gram-data/gram-ast@^0.1.9