@gram-data/gram-d3
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -5,101 +5,7 @@ 'use strict'; | ||
var gramFormat = require('@gram-data/gram-format'); | ||
var ast = require('@gram-data/gram-ast'); | ||
// export * from './gram-parse'; | ||
// export { recordToValue } from './record-to-object'; | ||
var status = "TBD"; | ||
var literalToValue = function literalToValue(literal) { | ||
if (ast.isTaggedLiteral(literal)) { | ||
switch (literal.tag) { | ||
case 'date': | ||
return new Date(literal.value); | ||
default: | ||
return literal.value; | ||
} | ||
} else { | ||
switch (literal.type) { | ||
case 'boolean': | ||
return JSON.parse(literal.value); | ||
case 'integer': | ||
return Number.parseInt(literal.value); | ||
case 'decimal': | ||
return Number.parseFloat(literal.value); | ||
default: | ||
return literal.value; | ||
} | ||
} | ||
}; | ||
var recordToValue = function recordToValue(recordValue) { | ||
if (Array.isArray(recordValue)) { | ||
return recordValue.map(function (v) { | ||
return recordToValue(v); | ||
}); | ||
} else if (ast.isLiteral(recordValue)) { | ||
return literalToValue(recordValue); | ||
} else { | ||
return Object.entries(recordValue).reduce(function (acc, _ref) { | ||
var k = _ref[0], | ||
v = _ref[1]; | ||
acc[k] = recordToValue(v); | ||
return acc; | ||
}, {}); | ||
} | ||
}; | ||
var MISSING_ID = '_missing_id'; | ||
var gramNodeDatum = function gramNodeDatum(id, labels, record) { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {} | ||
}; | ||
}; | ||
var isGramNodeDatum = function isGramNodeDatum(o) { | ||
return o.id !== undefined; | ||
}; | ||
var gramLinkDatum = function gramLinkDatum(source, target, id, labels, record) { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {}, | ||
source: source, | ||
target: target | ||
}; | ||
}; | ||
var nodeToD3 = function nodeToD3(node) { | ||
return gramNodeDatum(node.id, node.labels, node.record); | ||
}; | ||
var source = function source(edge) { | ||
if (edge.direction === 'left') return edge.children[1].id || MISSING_ID; | ||
return edge.children[0].id || MISSING_ID; | ||
}; | ||
var target = function target(edge) { | ||
if (edge.direction === 'left') return edge.children[0].id || MISSING_ID; | ||
return edge.children[1].id || MISSING_ID; | ||
}; | ||
var edgeToD3 = function edgeToD3(edge) { | ||
return gramLinkDatum(source(edge), target(edge), edge.id, edge.labels, edge.record); | ||
}; | ||
var gramParse = function gramParse(src) { | ||
var parsed = gramFormat.parse(src); | ||
var d3Gram = { | ||
nodes: gramFormat.transform.mergeNodes(parsed).map(nodeToD3), | ||
links: gramFormat.transform.mergeEdges(parsed).map(edgeToD3), | ||
paths: [] | ||
}; | ||
return d3Gram; | ||
}; | ||
exports.edgeToD3 = edgeToD3; | ||
exports.gramLinkDatum = gramLinkDatum; | ||
exports.gramNodeDatum = gramNodeDatum; | ||
exports.gramParse = gramParse; | ||
exports.isGramNodeDatum = isGramNodeDatum; | ||
exports.nodeToD3 = nodeToD3; | ||
exports.recordToValue = recordToValue; | ||
exports.status = status; | ||
//# sourceMappingURL=gram-d3.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-format"),r=require("@gram-data/gram-ast"),t=function e(t){return Array.isArray(t)?t.map((function(r){return e(r)})):r.isLiteral(t)?function(e){if(r.isTaggedLiteral(e))switch(e.tag){case"date":return new Date(e.value);default:return e.value}else switch(e.type){case"boolean":return JSON.parse(e.value);case"integer":return Number.parseInt(e.value);case"decimal":return Number.parseFloat(e.value);default:return e.value}}(t):Object.entries(t).reduce((function(r,t){return r[t[0]]=e(t[1]),r}),{})},i=function(e,r,i){return{id:e||"_missing_id",labels:r||[],record:i?t(i):{}}},n=function(e,r,i,n,a){return{id:i||"_missing_id",labels:n||[],record:a?t(a):{},source:e,target:r}},a=function(e){return i(e.id,e.labels,e.record)},s=function(e){return n(function(e){return"left"===e.direction?e.children[1].id||"_missing_id":e.children[0].id||"_missing_id"}(e),function(e){return"left"===e.direction?e.children[0].id||"_missing_id":e.children[1].id||"_missing_id"}(e),e.id,e.labels,e.record)};exports.edgeToD3=s,exports.gramLinkDatum=n,exports.gramNodeDatum=i,exports.gramParse=function(r){var t=e.parse(r);return{nodes:e.transform.mergeNodes(t).map(a),links:e.transform.mergeEdges(t).map(s),paths:[]}},exports.isGramNodeDatum=function(e){return void 0!==e.id},exports.nodeToD3=a,exports.recordToValue=t; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.status="TBD"; | ||
//# sourceMappingURL=gram-d3.cjs.production.min.js.map |
@@ -1,94 +0,6 @@ | ||
import { parse, transform } from '@gram-data/gram-format'; | ||
import { isLiteral, isTaggedLiteral } from '@gram-data/gram-ast'; | ||
// export * from './gram-parse'; | ||
// export { recordToValue } from './record-to-object'; | ||
var status = "TBD"; | ||
var literalToValue = function literalToValue(literal) { | ||
if (isTaggedLiteral(literal)) { | ||
switch (literal.tag) { | ||
case 'date': | ||
return new Date(literal.value); | ||
default: | ||
return literal.value; | ||
} | ||
} else { | ||
switch (literal.type) { | ||
case 'boolean': | ||
return JSON.parse(literal.value); | ||
case 'integer': | ||
return Number.parseInt(literal.value); | ||
case 'decimal': | ||
return Number.parseFloat(literal.value); | ||
default: | ||
return literal.value; | ||
} | ||
} | ||
}; | ||
var recordToValue = function recordToValue(recordValue) { | ||
if (Array.isArray(recordValue)) { | ||
return recordValue.map(function (v) { | ||
return recordToValue(v); | ||
}); | ||
} else if (isLiteral(recordValue)) { | ||
return literalToValue(recordValue); | ||
} else { | ||
return Object.entries(recordValue).reduce(function (acc, _ref) { | ||
var k = _ref[0], | ||
v = _ref[1]; | ||
acc[k] = recordToValue(v); | ||
return acc; | ||
}, {}); | ||
} | ||
}; | ||
var MISSING_ID = '_missing_id'; | ||
var gramNodeDatum = function gramNodeDatum(id, labels, record) { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {} | ||
}; | ||
}; | ||
var isGramNodeDatum = function isGramNodeDatum(o) { | ||
return o.id !== undefined; | ||
}; | ||
var gramLinkDatum = function gramLinkDatum(source, target, id, labels, record) { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {}, | ||
source: source, | ||
target: target | ||
}; | ||
}; | ||
var nodeToD3 = function nodeToD3(node) { | ||
return gramNodeDatum(node.id, node.labels, node.record); | ||
}; | ||
var source = function source(edge) { | ||
if (edge.direction === 'left') return edge.children[1].id || MISSING_ID; | ||
return edge.children[0].id || MISSING_ID; | ||
}; | ||
var target = function target(edge) { | ||
if (edge.direction === 'left') return edge.children[0].id || MISSING_ID; | ||
return edge.children[1].id || MISSING_ID; | ||
}; | ||
var edgeToD3 = function edgeToD3(edge) { | ||
return gramLinkDatum(source(edge), target(edge), edge.id, edge.labels, edge.record); | ||
}; | ||
var gramParse = function gramParse(src) { | ||
var parsed = parse(src); | ||
var d3Gram = { | ||
nodes: transform.mergeNodes(parsed).map(nodeToD3), | ||
links: transform.mergeEdges(parsed).map(edgeToD3), | ||
paths: [] | ||
}; | ||
return d3Gram; | ||
}; | ||
export { edgeToD3, gramLinkDatum, gramNodeDatum, gramParse, isGramNodeDatum, nodeToD3, recordToValue }; | ||
export { status }; | ||
//# sourceMappingURL=gram-d3.esm.js.map |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@gram-data/gram-format'), require('@gram-data/gram-ast')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@gram-data/gram-format', '@gram-data/gram-ast'], factory) : | ||
(global = global || self, factory(global['@gram-data/gram-d3'] = {}, global.gramFormat, global.ast)); | ||
}(this, (function (exports, gramFormat, ast) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global['@gram-data/gram-d3'] = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
var literalToValue = function literalToValue(literal) { | ||
if (ast.isTaggedLiteral(literal)) { | ||
switch (literal.tag) { | ||
case 'date': | ||
return new Date(literal.value); | ||
// export * from './gram-parse'; | ||
// export { recordToValue } from './record-to-object'; | ||
var status = "TBD"; | ||
default: | ||
return literal.value; | ||
} | ||
} else { | ||
switch (literal.type) { | ||
case 'boolean': | ||
return JSON.parse(literal.value); | ||
exports.status = status; | ||
case 'integer': | ||
return Number.parseInt(literal.value); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
case 'decimal': | ||
return Number.parseFloat(literal.value); | ||
default: | ||
return literal.value; | ||
} | ||
} | ||
}; | ||
var recordToValue = function recordToValue(recordValue) { | ||
if (Array.isArray(recordValue)) { | ||
return recordValue.map(function (v) { | ||
return recordToValue(v); | ||
}); | ||
} else if (ast.isLiteral(recordValue)) { | ||
return literalToValue(recordValue); | ||
} else { | ||
return Object.entries(recordValue).reduce(function (acc, _ref) { | ||
var k = _ref[0], | ||
v = _ref[1]; | ||
acc[k] = recordToValue(v); | ||
return acc; | ||
}, {}); | ||
} | ||
}; | ||
var MISSING_ID = '_missing_id'; | ||
var gramNodeDatum = function gramNodeDatum(id, labels, record) { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {} | ||
}; | ||
}; | ||
var isGramNodeDatum = function isGramNodeDatum(o) { | ||
return o.id !== undefined; | ||
}; | ||
var gramLinkDatum = function gramLinkDatum(source, target, id, labels, record) { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {}, | ||
source: source, | ||
target: target | ||
}; | ||
}; | ||
var nodeToD3 = function nodeToD3(node) { | ||
return gramNodeDatum(node.id, node.labels, node.record); | ||
}; | ||
var source = function source(edge) { | ||
if (edge.direction === 'left') return edge.children[1].id || MISSING_ID; | ||
return edge.children[0].id || MISSING_ID; | ||
}; | ||
var target = function target(edge) { | ||
if (edge.direction === 'left') return edge.children[0].id || MISSING_ID; | ||
return edge.children[1].id || MISSING_ID; | ||
}; | ||
var edgeToD3 = function edgeToD3(edge) { | ||
return gramLinkDatum(source(edge), target(edge), edge.id, edge.labels, edge.record); | ||
}; | ||
var gramParse = function gramParse(src) { | ||
var parsed = gramFormat.parse(src); | ||
var d3Gram = { | ||
nodes: gramFormat.transform.mergeNodes(parsed).map(nodeToD3), | ||
links: gramFormat.transform.mergeEdges(parsed).map(edgeToD3), | ||
paths: [] | ||
}; | ||
return d3Gram; | ||
}; | ||
exports.edgeToD3 = edgeToD3; | ||
exports.gramLinkDatum = gramLinkDatum; | ||
exports.gramNodeDatum = gramNodeDatum; | ||
exports.gramParse = gramParse; | ||
exports.isGramNodeDatum = isGramNodeDatum; | ||
exports.nodeToD3 = nodeToD3; | ||
exports.recordToValue = recordToValue; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=gram-d3.umd.development.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@gram-data/gram-format"),require("@gram-data/gram-ast")):"function"==typeof define&&define.amd?define(["exports","@gram-data/gram-format","@gram-data/gram-ast"],r):r((e=e||self)["@gram-data/gram-d3"]={},e.gramFormat,e.ast)}(this,(function(e,r,t){"use strict";var a=function e(r){return Array.isArray(r)?r.map((function(r){return e(r)})):t.isLiteral(r)?function(e){if(t.isTaggedLiteral(e))switch(e.tag){case"date":return new Date(e.value);default:return e.value}else switch(e.type){case"boolean":return JSON.parse(e.value);case"integer":return Number.parseInt(e.value);case"decimal":return Number.parseFloat(e.value);default:return e.value}}(r):Object.entries(r).reduce((function(r,t){return r[t[0]]=e(t[1]),r}),{})},n=function(e,r,t){return{id:e||"_missing_id",labels:r||[],record:t?a(t):{}}},i=function(e,r,t,n,i){return{id:t||"_missing_id",labels:n||[],record:i?a(i):{},source:e,target:r}},d=function(e){return n(e.id,e.labels,e.record)},u=function(e){return i(function(e){return"left"===e.direction?e.children[1].id||"_missing_id":e.children[0].id||"_missing_id"}(e),function(e){return"left"===e.direction?e.children[0].id||"_missing_id":e.children[1].id||"_missing_id"}(e),e.id,e.labels,e.record)};e.edgeToD3=u,e.gramLinkDatum=i,e.gramNodeDatum=n,e.gramParse=function(e){var t=r.parse(e);return{nodes:r.transform.mergeNodes(t).map(d),links:r.transform.mergeEdges(t).map(u),paths:[]}},e.isGramNodeDatum=function(e){return void 0!==e.id},e.nodeToD3=d,e.recordToValue=a,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["@gram-data/gram-d3"]={})}(this,(function(e){"use strict";e.status="TBD",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=gram-d3.umd.production.min.js.map |
@@ -1,2 +0,1 @@ | ||
export * from './gram-parse'; | ||
export { recordToValue } from './record-to-object'; | ||
export declare const status = "TBD"; |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"author": "Andreas Kollegger", | ||
@@ -58,2 +58,4 @@ "license": "MIT", | ||
"npm-run-all": "^4.1.5", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"serve": "^11.3.2", | ||
"shx": "^0.3.2", | ||
@@ -65,7 +67,7 @@ "tsdx": "^0.13.2", | ||
"dependencies": { | ||
"@gram-data/gram-ast": "^0.1.8", | ||
"@gram-data/gram-parse": "^0.1.8", | ||
"@gram-data/gram-ast": "^0.1.9", | ||
"@gram-data/gram-parse": "^0.1.9", | ||
"d3": "^5.16.0" | ||
}, | ||
"gitHead": "767922021318156135c4fc0e755bdaa888f7a057" | ||
"gitHead": "43a096296038b010d268f648eb456207f8b1640b" | ||
} |
@@ -1,87 +0,87 @@ | ||
import * as ast from '@gram-data/gram-ast'; | ||
import { parse, transform } from '@gram-data/gram-format'; | ||
import { SimulationNodeDatum, SimulationLinkDatum } from 'd3-force'; | ||
import { recordToValue } from './record-to-object'; | ||
// import * as ast from '@gram-data/gram-ast'; | ||
// // import { parse, transform } from '@gram-data/gram-format'; | ||
// import { SimulationNodeDatum, SimulationLinkDatum } from 'd3-force'; | ||
// import { recordToValue } from './record-to-object'; | ||
const MISSING_ID = '_missing_id'; | ||
// const MISSING_ID = '_missing_id'; | ||
export interface GramNodeDatum extends SimulationNodeDatum { | ||
id: string; | ||
labels: string[]; | ||
record: { [key: string]: any }; | ||
} | ||
// export interface GramNodeDatum extends SimulationNodeDatum { | ||
// id: string; | ||
// labels: string[]; | ||
// record: { [key: string]: any }; | ||
// } | ||
export const gramNodeDatum = ( | ||
id?: string, | ||
labels?: string[], | ||
record?: { [key: string]: any } | ||
) => { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {}, | ||
}; | ||
}; | ||
export const isGramNodeDatum = (o: any): o is GramNodeDatum => { | ||
return (o as GramNodeDatum).id !== undefined; | ||
}; | ||
// export const gramNodeDatum = ( | ||
// id?: string, | ||
// labels?: string[], | ||
// record?: { [key: string]: any } | ||
// ) => { | ||
// return { | ||
// id: id || MISSING_ID, | ||
// labels: labels || [], | ||
// record: record ? recordToValue(record) : {}, | ||
// }; | ||
// }; | ||
// export const isGramNodeDatum = (o: any): o is GramNodeDatum => { | ||
// return (o as GramNodeDatum).id !== undefined; | ||
// }; | ||
export const gramLinkDatum = ( | ||
source: string, | ||
target: string, | ||
id?: string, | ||
labels?: string[], | ||
record?: { [key: string]: any } | ||
) => { | ||
return { | ||
id: id || MISSING_ID, | ||
labels: labels || [], | ||
record: record ? recordToValue(record) : {}, | ||
source, | ||
target | ||
}; | ||
} | ||
// export const gramLinkDatum = ( | ||
// source: string, | ||
// target: string, | ||
// id?: string, | ||
// labels?: string[], | ||
// record?: { [key: string]: any } | ||
// ) => { | ||
// return { | ||
// id: id || MISSING_ID, | ||
// labels: labels || [], | ||
// record: record ? recordToValue(record) : {}, | ||
// source, | ||
// target | ||
// }; | ||
// } | ||
export interface GramLinkDatum extends SimulationLinkDatum<GramNodeDatum> { | ||
id: string; | ||
record: { [key: string]: any }; | ||
} | ||
// export interface GramLinkDatum extends SimulationLinkDatum<GramNodeDatum> { | ||
// id: string; | ||
// record: { [key: string]: any }; | ||
// } | ||
export interface GramPathDatum { | ||
links: GramLinkDatum[]; | ||
} | ||
// export interface GramPathDatum { | ||
// links: GramLinkDatum[]; | ||
// } | ||
export interface D3Gram { | ||
nodes: GramNodeDatum[]; | ||
links: GramLinkDatum[]; | ||
paths: GramPathDatum[]; | ||
} | ||
// export interface D3Gram { | ||
// nodes: GramNodeDatum[]; | ||
// links: GramLinkDatum[]; | ||
// paths: GramPathDatum[]; | ||
// } | ||
export const nodeToD3 = (node: ast.GramNode): GramNodeDatum => { | ||
return gramNodeDatum(node.id, node.labels, node.record); | ||
}; | ||
// export const nodeToD3 = (node: ast.GramNode): GramNodeDatum => { | ||
// return gramNodeDatum(node.id, node.labels, node.record); | ||
// }; | ||
const source = (edge: ast.GramEdge): string => { | ||
if (edge.direction === 'left') return edge.children[1].id || MISSING_ID; | ||
return edge.children[0].id || MISSING_ID; | ||
}; | ||
// const source = (edge: ast.GramEdge): string => { | ||
// if (edge.direction === 'left') return edge.children[1].id || MISSING_ID; | ||
// return edge.children[0].id || MISSING_ID; | ||
// }; | ||
const target = (edge: ast.GramEdge): string => { | ||
if (edge.direction === 'left') return edge.children[0].id || MISSING_ID; | ||
return edge.children[1].id || MISSING_ID; | ||
}; | ||
// const target = (edge: ast.GramEdge): string => { | ||
// if (edge.direction === 'left') return edge.children[0].id || MISSING_ID; | ||
// return edge.children[1].id || MISSING_ID; | ||
// }; | ||
export const edgeToD3 = (edge: ast.GramEdge): GramLinkDatum => { | ||
return gramLinkDatum(source(edge), target(edge), edge.id,edge.labels, edge.record) | ||
}; | ||
// export const edgeToD3 = (edge: ast.GramEdge): GramLinkDatum => { | ||
// return gramLinkDatum(source(edge), target(edge), edge.id,edge.labels, edge.record) | ||
// }; | ||
export const gramParse = (src: string): D3Gram => { | ||
const parsed = parse(src); | ||
const d3Gram = { | ||
nodes: transform.mergeNodes(parsed).map(nodeToD3), | ||
links: transform.mergeEdges(parsed).map(edgeToD3), | ||
paths: [], | ||
}; | ||
// export const gramParse = (src: string): D3Gram => { | ||
// const parsed = parse(src); | ||
// const d3Gram = { | ||
// nodes: transform.mergeNodes(parsed).map(nodeToD3), | ||
// links: transform.mergeEdges(parsed).map(edgeToD3), | ||
// paths: [], | ||
// }; | ||
return d3Gram; | ||
}; | ||
// return d3Gram; | ||
// }; |
@@ -1,2 +0,4 @@ | ||
export * from './gram-parse'; | ||
export { recordToValue } from './record-to-object'; | ||
// export * from './gram-parse'; | ||
// export { recordToValue } from './record-to-object'; | ||
export const status = "TBD" |
@@ -1,40 +0,40 @@ | ||
import * as ast from '@gram-data/gram-ast'; | ||
// import * as ast from '@gram-data/gram-ast'; | ||
export const literalToDate = (literal: ast.DateLiteral) => { | ||
return new Date(literal.value); | ||
}; | ||
// export const literalToDate = (literal: ast.DateLiteral) => { | ||
// return new Date(literal.value); | ||
// }; | ||
export const literalToValue = (literal: ast.GramLiteral) => { | ||
if (ast.isTaggedLiteral(literal)) { | ||
switch (literal.tag) { | ||
case 'date': | ||
return new Date(literal.value); | ||
default: | ||
return literal.value; | ||
} | ||
} else { | ||
switch (literal.type) { | ||
case 'boolean': | ||
return JSON.parse(literal.value); | ||
case 'integer': | ||
return Number.parseInt(literal.value); | ||
case 'decimal': | ||
return Number.parseFloat(literal.value); | ||
default: | ||
return literal.value; | ||
} | ||
} | ||
}; | ||
// export const literalToValue = (literal: ast.GramLiteral) => { | ||
// if (ast.isTaggedLiteral(literal)) { | ||
// switch (literal.tag) { | ||
// case 'date': | ||
// return new Date(literal.value); | ||
// default: | ||
// return literal.value; | ||
// } | ||
// } else { | ||
// switch (literal.type) { | ||
// case 'boolean': | ||
// return JSON.parse(literal.value); | ||
// case 'integer': | ||
// return Number.parseInt(literal.value); | ||
// case 'decimal': | ||
// return Number.parseFloat(literal.value); | ||
// default: | ||
// return literal.value; | ||
// } | ||
// } | ||
// }; | ||
export const recordToValue = (recordValue: ast.GramRecordValue): any => { | ||
if (Array.isArray(recordValue)) { | ||
return recordValue.map(v => recordToValue(v)); | ||
} else if (ast.isLiteral(recordValue)) { | ||
return literalToValue(recordValue); | ||
} else { | ||
return Object.entries(recordValue).reduce((acc, [k, v]) => { | ||
acc[k] = recordToValue(v); | ||
return acc; | ||
}, {} as { [key: string]: any }); | ||
} | ||
}; | ||
// export const recordToValue = (recordValue: ast.GramRecordValue): any => { | ||
// if (Array.isArray(recordValue)) { | ||
// return recordValue.map(v => recordToValue(v)); | ||
// } else if (ast.isLiteral(recordValue)) { | ||
// return literalToValue(recordValue); | ||
// } else { | ||
// return Object.entries(recordValue).reduce((acc, [k, v]) => { | ||
// acc[k] = recordToValue(v); | ||
// return acc; | ||
// }, {} as { [key: string]: any }); | ||
// } | ||
// }; |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
10719
14
149
1
Updated@gram-data/gram-ast@^0.1.9
Updated@gram-data/gram-parse@^0.1.9