@gram-data/gram-builder
Advanced tools
Comparing version 0.2.9 to 0.2.10
@@ -46,4 +46,3 @@ 'use strict'; | ||
/** | ||
* Build a path sequence that represents a graph | ||
* accumulating structure over time. | ||
* Build a path sequence that represents a graph. | ||
* | ||
@@ -70,5 +69,5 @@ * @param paths sequence of paths through history | ||
/** | ||
* Reduce a list of paths into a single path composed using the given relation. | ||
* Reduce a list of paths into a single path composed using the given kind. | ||
* | ||
* @param relation the relation to apply to all sub-paths | ||
* @param kind the kind to apply to all sub-paths | ||
* @param pathlist sub-paths to be paired | ||
@@ -78,17 +77,13 @@ * @param baseID the baseID from which path expressions will derive new IDs | ||
var reduce = function reduce(relation, pathlist, baseID) { | ||
if (relation === void 0) { | ||
relation = 'pair'; | ||
var listToPath = function listToPath(kind, pathlist) { | ||
if (kind === void 0) { | ||
kind = 'pair'; | ||
} | ||
var subID = 0; | ||
if (pathlist.length > 1) { | ||
return pathlist.reduceRight(function (acc, curr) { | ||
var childID = baseID ? "" + baseID + subID : undefined; | ||
return pathlist.slice(0, pathlist.length - 1).reduceRight(function (acc, curr) { | ||
return cons([curr, acc], { | ||
relation: relation, | ||
id: childID | ||
kind: kind | ||
}); | ||
}, EMPTY_PATH); | ||
}, pathlist[pathlist.length - 1]); | ||
} else { | ||
@@ -146,8 +141,8 @@ return pathlist[0]; | ||
} else if (members.length === 2) { | ||
if (attributes.relation && attributes.relation !== 'pair' && gramAst.isGramNode(members[0]) && gramAst.isGramNode(members[1])) { | ||
element.relation = attributes.relation; | ||
if (attributes.kind && attributes.kind !== 'pair' && gramAst.isGramNode(members[0]) && gramAst.isGramNode(members[1])) { | ||
element.kind = attributes.kind; | ||
element.children = [members[0], members[1]]; | ||
return element; | ||
} else if (gramAst.isGramEmptyPath(members[0]) && gramAst.isGramEmptyPath(members[1])) { | ||
element.relation = attributes.relation; | ||
element.kind = attributes.kind; | ||
element.children = []; | ||
@@ -160,3 +155,3 @@ return element; | ||
element.relation = attributes.relation || 'pair'; | ||
element.kind = attributes.kind || 'pair'; | ||
return element; | ||
@@ -173,3 +168,3 @@ }; | ||
record: undefined, | ||
children: undefined | ||
children: [] | ||
}; | ||
@@ -209,3 +204,3 @@ /** | ||
* @param children | ||
* @param relation | ||
* @param kind | ||
* @param id | ||
@@ -216,3 +211,3 @@ * @param labels | ||
var edge = function edge(children, relation, id, labels, record) { | ||
var edge = function edge(children, kind, id, labels, record) { | ||
return _extends({ | ||
@@ -226,3 +221,3 @@ type: 'path', | ||
}, { | ||
relation: relation, | ||
kind: kind, | ||
children: children | ||
@@ -239,6 +234,28 @@ }); | ||
*/ | ||
// export const path = ( | ||
// members: [GramPath] | [GramPath, GramPath], | ||
// id?: string, | ||
// labels?: string[], | ||
// record?: GramRecord | ||
// ): GramPath => ({ | ||
// type: 'path', | ||
// id, | ||
// ...(labels && { labels }), | ||
// ...(record && { record }), | ||
// children: members, | ||
// }); | ||
var path = function path(members, id, labels, record) { | ||
/** | ||
* Build a pair | ||
* | ||
* @param children | ||
* @param id | ||
* @param labels | ||
* @param record | ||
*/ | ||
var pair = function pair(members, id, labels, record) { | ||
return _extends({ | ||
type: 'path', | ||
kind: 'pair', | ||
id: id | ||
@@ -371,3 +388,4 @@ }, labels && { | ||
cons: cons, | ||
path: path, | ||
pair: pair, | ||
listToPath: listToPath, | ||
node: node, | ||
@@ -395,9 +413,8 @@ edge: edge, | ||
seq: seq, | ||
reduce: reduce, | ||
listToPath: listToPath, | ||
cons: cons, | ||
EMPTY_PATH: EMPTY_PATH, | ||
empty: empty, | ||
node: node, | ||
edge: edge, | ||
path: path, | ||
pair: pair, | ||
recordToMap: recordToMap, | ||
@@ -424,3 +441,2 @@ mapToRecord: mapToRecord, | ||
exports.EMPTY_PATH = EMPTY_PATH; | ||
exports.boolean = _boolean; | ||
@@ -438,2 +454,3 @@ exports.builder = gramBuilder$1; | ||
exports.integer = integer; | ||
exports.listToPath = listToPath; | ||
exports.mapToRecord = mapToRecord; | ||
@@ -443,7 +460,6 @@ exports.measurement = measurement; | ||
exports.octal = octal; | ||
exports.path = path; | ||
exports.pair = pair; | ||
exports.pluck = pluck; | ||
exports.property = property; | ||
exports.recordToMap = recordToMap; | ||
exports.reduce = reduce; | ||
exports.seq = seq; | ||
@@ -450,0 +466,0 @@ exports.string = string; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-ast");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function r(e){return Array.isArray(e)?e:e instanceof Function?r(e()):void 0===e?[]:[e]}var n=function(e,n,o,i){return t({type:"seq",id:n},o&&{labels:o},i&&{record:i},{children:r(e)})},o=function(e,t,r){return void 0===e&&(e="pair"),t.length>1?t.reduceRight((function(t,n){return i([n,t],{relation:e,id:r?""+r+0:void 0})}),a):t[0]},i=function(r,n){void 0===n&&(n={});var o=t({type:"path"},n.id&&{id:n.id},n.labels&&{labels:n.labels},n.record&&{record:n.record});if(void 0===r)return o.id&&o.id!==e.EMPTY_PATH_ID?(o.children=[],o):(o.children=void 0,a);if(0===r.length)return o.id===e.EMPTY_PATH_ID?a:(o.children=[],o);if(1===r.length){var i=r[0];return e.isGramEmptyPath(i)?(o.children=[],o):(o.children=[i],o)}if(2===r.length){if(n.relation&&"pair"!==n.relation&&e.isGramNode(r[0])&&e.isGramNode(r[1]))return o.relation=n.relation,o.children=[r[0],r[1]],o;if(e.isGramEmptyPath(r[0])&&e.isGramEmptyPath(r[1]))return o.relation=n.relation,o.children=[],o;o.children=[r[0],r[1]]}return o.relation=n.relation||"pair",o},a={type:"path",id:e.EMPTY_PATH_ID,labels:void 0,record:void 0,children:void 0},u=function(){return a},c=function(e,r,n){return t({type:"path"},e&&{id:e},r&&{labels:r},n&&{record:n},{children:[]})},l=function(e,r,n,o,i){return t({type:"path",id:n},o&&{labels:o},i&&{record:i},{relation:r,children:e})},d=function(e,r,n,o){return t({type:"path",id:r},n&&{labels:n},o&&{record:o},{children:e})},p=function(e){return e.reduce((function(e,t){return e[t.name]=t.value,e}),{})},s=function(e){return Object.entries(e).reduce((function(e,t){return e.push(g(t[0],t[1])),e}),[])},f=function(e,t){return e.reduce((function(e,r){return r.name===t?r:e}))},g=function(e,t){return{type:"property",name:e,value:t}},m=function(e){return{type:"boolean",value:e?"true":"false"}},h=function(e){return{type:"string",value:e}},y=function(e,t){return{type:"tagged",value:t,tag:e}},x=function(e){return{type:"integer",value:String(e)}},v=function(e){return{type:"decimal",value:String(e)}},T=function(e){return{type:"hexadecimal",value:"number"==typeof e?e.toString(16):e}},b=function(e){return{type:"octal",value:"number"==typeof e?e.toString(8):e}},M=function(e,t){return{type:"measurement",value:String(t),unit:e}},P=function(e){return y("date",e instanceof Date?e.getFullYear().toString():e)},_=function(e){return y("date",e instanceof Date?e.toISOString().slice(0,10):e)},S=function(e){return y("date",e instanceof Date?"--"+e.toISOString().slice(5,10):e)},D=function(e){return y("time",e instanceof Date?e.toTimeString():e)},O=function(e){return y("duration",e instanceof Date?"P"+(e.getUTCFullYear()-1970)+"Y"+e.getUTCMonth()+"M"+e.getUTCDate()+"DT"+e.getUTCHours()+"H"+e.getUTCMinutes()+"M"+e.getUTCMilliseconds()/1e3+"S":e)},E=function(e,t){return void 0===t&&(t=1),e.flat(t).filter((function(e){return null!==e}))},Y={__proto__:null,seq:n,reduce:o,cons:i,EMPTY_PATH:a,empty:u,node:c,edge:l,path:d,recordToMap:p,mapToRecord:s,pluck:f,property:g,boolean:m,string:h,tagged:y,integer:x,decimal:v,hexadecimal:T,octal:b,measurement:M,year:P,date:_,dayOfMonth:S,time:D,duration:O,flatten:E,default:{seq:n,empty:u,cons:i,path:d,node:c,edge:l,property:g,boolean:m,string:h,tagged:y,integer:x,decimal:v,hexadecimal:T,octal:b,measurement:M,date:_,time:D,duration:O,flatten:E,recordToMap:p,mapToRecord:s}};exports.EMPTY_PATH=a,exports.boolean=m,exports.builder=Y,exports.cons=i,exports.date=_,exports.dayOfMonth=S,exports.decimal=v,exports.duration=O,exports.edge=l,exports.empty=u,exports.flatten=E,exports.hexadecimal=T,exports.integer=x,exports.mapToRecord=s,exports.measurement=M,exports.node=c,exports.octal=b,exports.path=d,exports.pluck=f,exports.property=g,exports.recordToMap=p,exports.reduce=o,exports.seq=n,exports.string=h,exports.tagged=y,exports.time=D,exports.year=P; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gram-data/gram-ast");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function r(e){return Array.isArray(e)?e:e instanceof Function?r(e()):void 0===e?[]:[e]}var n=function(e,n,i,o){return t({type:"seq",id:n},i&&{labels:i},o&&{record:o},{children:r(e)})},i=function(e,t){return void 0===e&&(e="pair"),t.length>1?t.slice(0,t.length-1).reduceRight((function(t,r){return o([r,t],{kind:e})}),t[t.length-1]):t[0]},o=function(r,n){void 0===n&&(n={});var i=t({type:"path"},n.id&&{id:n.id},n.labels&&{labels:n.labels},n.record&&{record:n.record});if(void 0===r)return i.id&&i.id!==e.EMPTY_PATH_ID?(i.children=[],i):(i.children=void 0,a);if(0===r.length)return i.id===e.EMPTY_PATH_ID?a:(i.children=[],i);if(1===r.length){var o=r[0];return e.isGramEmptyPath(o)?(i.children=[],i):(i.children=[o],i)}if(2===r.length){if(n.kind&&"pair"!==n.kind&&e.isGramNode(r[0])&&e.isGramNode(r[1]))return i.kind=n.kind,i.children=[r[0],r[1]],i;if(e.isGramEmptyPath(r[0])&&e.isGramEmptyPath(r[1]))return i.kind=n.kind,i.children=[],i;i.children=[r[0],r[1]]}return i.kind=n.kind||"pair",i},a={type:"path",id:e.EMPTY_PATH_ID,labels:void 0,record:void 0,children:[]},u=function(){return a},d=function(e,r,n){return t({type:"path"},e&&{id:e},r&&{labels:r},n&&{record:n},{children:[]})},c=function(e,r,n,i,o){return t({type:"path",id:n},i&&{labels:i},o&&{record:o},{kind:r,children:e})},l=function(e,r,n,i){return t({type:"path",kind:"pair",id:r},n&&{labels:n},i&&{record:i},{children:e})},p=function(e){return e.reduce((function(e,t){return e[t.name]=t.value,e}),{})},s=function(e){return Object.entries(e).reduce((function(e,t){return e.push(g(t[0],t[1])),e}),[])},f=function(e,t){return e.reduce((function(e,r){return r.name===t?r:e}))},g=function(e,t){return{type:"property",name:e,value:t}},h=function(e){return{type:"boolean",value:e?"true":"false"}},m=function(e){return{type:"string",value:e}},y=function(e,t){return{type:"tagged",value:t,tag:e}},x=function(e){return{type:"integer",value:String(e)}},v=function(e){return{type:"decimal",value:String(e)}},T=function(e){return{type:"hexadecimal",value:"number"==typeof e?e.toString(16):e}},b=function(e){return{type:"octal",value:"number"==typeof e?e.toString(8):e}},P=function(e,t){return{type:"measurement",value:String(t),unit:e}},M=function(e){return y("date",e instanceof Date?e.getFullYear().toString():e)},k=function(e){return y("date",e instanceof Date?e.toISOString().slice(0,10):e)},S=function(e){return y("date",e instanceof Date?"--"+e.toISOString().slice(5,10):e)},_=function(e){return y("time",e instanceof Date?e.toTimeString():e)},D=function(e){return y("duration",e instanceof Date?"P"+(e.getUTCFullYear()-1970)+"Y"+e.getUTCMonth()+"M"+e.getUTCDate()+"DT"+e.getUTCHours()+"H"+e.getUTCMinutes()+"M"+e.getUTCMilliseconds()/1e3+"S":e)},O=function(e,t){return void 0===t&&(t=1),e.flat(t).filter((function(e){return null!==e}))},C={__proto__:null,seq:n,listToPath:i,cons:o,empty:u,node:d,edge:c,pair:l,recordToMap:p,mapToRecord:s,pluck:f,property:g,boolean:h,string:m,tagged:y,integer:x,decimal:v,hexadecimal:T,octal:b,measurement:P,year:M,date:k,dayOfMonth:S,time:_,duration:D,flatten:O,default:{seq:n,empty:u,cons:o,pair:l,listToPath:i,node:d,edge:c,property:g,boolean:h,string:m,tagged:y,integer:x,decimal:v,hexadecimal:T,octal:b,measurement:P,date:k,time:_,duration:D,flatten:O,recordToMap:p,mapToRecord:s}};exports.boolean=h,exports.builder=C,exports.cons=o,exports.date=k,exports.dayOfMonth=S,exports.decimal=v,exports.duration=D,exports.edge=c,exports.empty=u,exports.flatten=O,exports.hexadecimal=T,exports.integer=x,exports.listToPath=i,exports.mapToRecord=s,exports.measurement=P,exports.node=d,exports.octal=b,exports.pair=l,exports.pluck=f,exports.property=g,exports.recordToMap=p,exports.seq=n,exports.string=m,exports.tagged=y,exports.time=_,exports.year=M; | ||
//# sourceMappingURL=gram-builder.cjs.production.min.js.map |
@@ -6,7 +6,6 @@ /** | ||
*/ | ||
import { GramPathSeq, GramPath, GramNode, GramEdge, GramProperty, GramRecordValue, Relation, Navigation, BooleanLiteral, StringLiteral, TaggedLiteral, IntegerLiteral, DecimalLiteral, HexadecimalLiteral, OctalLiteral, MeasurementLiteral, GramRecord, GramPathlike, GramEmptyPath, GramPropertyMap, DateLiteral, TimeLiteral, DurationLiteral } from '@gram-data/gram-ast'; | ||
import { GramSeq, GramPath, GramNode, GramEdge, GramProperty, GramRecordValue, BooleanLiteral, StringLiteral, TaggedLiteral, IntegerLiteral, DecimalLiteral, HexadecimalLiteral, OctalLiteral, MeasurementLiteral, GramRecord, GramEmptyPath, GramPropertyMap, DateLiteral, TimeLiteral, DurationLiteral, RelationshipKind, OrientedKind } from '@gram-data/gram-ast'; | ||
export declare type Children<T> = T | T[] | (() => T | T[]); | ||
/** | ||
* Build a path sequence that represents a graph | ||
* accumulating structure over time. | ||
* Build a path sequence that represents a graph. | ||
* | ||
@@ -18,3 +17,3 @@ * @param paths sequence of paths through history | ||
*/ | ||
export declare const seq: (paths: Children<GramPath>, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramPathSeq; | ||
export declare const seq: (paths: Children<GramPath>, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramSeq; | ||
export interface PathAttributes { | ||
@@ -24,12 +23,12 @@ id?: string; | ||
record?: GramRecord; | ||
relation?: Relation; | ||
kind?: RelationshipKind; | ||
} | ||
/** | ||
* Reduce a list of paths into a single path composed using the given relation. | ||
* Reduce a list of paths into a single path composed using the given kind. | ||
* | ||
* @param relation the relation to apply to all sub-paths | ||
* @param kind the kind to apply to all sub-paths | ||
* @param pathlist sub-paths to be paired | ||
* @param baseID the baseID from which path expressions will derive new IDs | ||
*/ | ||
export declare const reduce: (relation: "left" | "right" | "either" | "pair" | undefined, pathlist: GramPath[], baseID?: string | undefined) => GramPathlike; | ||
export declare const listToPath: (kind: "left" | "right" | "either" | "pair" | undefined, pathlist: GramPath[]) => GramPath; | ||
/** | ||
@@ -41,8 +40,4 @@ * Build a path. | ||
*/ | ||
export declare const cons: (members?: [] | [GramPathlike] | [GramPathlike, GramPathlike] | undefined, attributes?: PathAttributes) => GramPathlike; | ||
export declare const cons: (members?: [] | [GramPath] | [GramPath, GramPath] | undefined, attributes?: PathAttributes) => GramPath; | ||
/** | ||
* Singleton instance of GramEmptyPath | ||
*/ | ||
export declare const EMPTY_PATH: GramEmptyPath; | ||
/** | ||
* Convenience function for retrieving the singleton GramEmptyPath. | ||
@@ -64,3 +59,3 @@ */ | ||
* @param children | ||
* @param relation | ||
* @param kind | ||
* @param id | ||
@@ -70,3 +65,3 @@ * @param labels | ||
*/ | ||
export declare const edge: (children: [GramNode, GramNode], relation: Navigation, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramEdge; | ||
export declare const edge: (children: [GramNode, GramNode], kind: OrientedKind, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramEdge; | ||
/** | ||
@@ -80,4 +75,12 @@ * Build a path | ||
*/ | ||
export declare const path: (members: [GramPath] | [GramPath, GramPath], id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramPath; | ||
/** | ||
* Build a pair | ||
* | ||
* @param children | ||
* @param id | ||
* @param labels | ||
* @param record | ||
*/ | ||
export declare const pair: (members: [GramPath, GramPath], id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramPath; | ||
/** | ||
* Reduces an array of GramProperties into a map. | ||
@@ -111,8 +114,9 @@ * | ||
declare const _default: { | ||
seq: (paths: Children<GramPath>, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramPathSeq; | ||
seq: (paths: Children<GramPath>, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramSeq; | ||
empty: () => GramEmptyPath; | ||
cons: (members?: [] | [GramPathlike] | [GramPathlike, GramPathlike] | undefined, attributes?: PathAttributes) => GramPathlike; | ||
path: (members: [GramPath] | [GramPath, GramPath], id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramPath; | ||
cons: (members?: [] | [GramPath] | [GramPath, GramPath] | undefined, attributes?: PathAttributes) => GramPath; | ||
pair: (members: [GramPath, GramPath], id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramPath; | ||
listToPath: (kind: "left" | "right" | "either" | "pair" | undefined, pathlist: GramPath[]) => GramPath; | ||
node: (id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramNode; | ||
edge: (children: [GramNode, GramNode], relation: Navigation, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramEdge; | ||
edge: (children: [GramNode, GramNode], kind: OrientedKind, id?: string | undefined, labels?: string[] | undefined, record?: GramRecord | undefined) => GramEdge; | ||
property: (name: string, value: GramRecordValue) => GramProperty; | ||
@@ -119,0 +123,0 @@ boolean: (value: boolean) => BooleanLiteral; |
@@ -42,4 +42,3 @@ import { EMPTY_PATH_ID, isGramEmptyPath, isGramNode } from '@gram-data/gram-ast'; | ||
/** | ||
* Build a path sequence that represents a graph | ||
* accumulating structure over time. | ||
* Build a path sequence that represents a graph. | ||
* | ||
@@ -66,5 +65,5 @@ * @param paths sequence of paths through history | ||
/** | ||
* Reduce a list of paths into a single path composed using the given relation. | ||
* Reduce a list of paths into a single path composed using the given kind. | ||
* | ||
* @param relation the relation to apply to all sub-paths | ||
* @param kind the kind to apply to all sub-paths | ||
* @param pathlist sub-paths to be paired | ||
@@ -74,17 +73,13 @@ * @param baseID the baseID from which path expressions will derive new IDs | ||
var reduce = function reduce(relation, pathlist, baseID) { | ||
if (relation === void 0) { | ||
relation = 'pair'; | ||
var listToPath = function listToPath(kind, pathlist) { | ||
if (kind === void 0) { | ||
kind = 'pair'; | ||
} | ||
var subID = 0; | ||
if (pathlist.length > 1) { | ||
return pathlist.reduceRight(function (acc, curr) { | ||
var childID = baseID ? "" + baseID + subID : undefined; | ||
return pathlist.slice(0, pathlist.length - 1).reduceRight(function (acc, curr) { | ||
return cons([curr, acc], { | ||
relation: relation, | ||
id: childID | ||
kind: kind | ||
}); | ||
}, EMPTY_PATH); | ||
}, pathlist[pathlist.length - 1]); | ||
} else { | ||
@@ -142,8 +137,8 @@ return pathlist[0]; | ||
} else if (members.length === 2) { | ||
if (attributes.relation && attributes.relation !== 'pair' && isGramNode(members[0]) && isGramNode(members[1])) { | ||
element.relation = attributes.relation; | ||
if (attributes.kind && attributes.kind !== 'pair' && isGramNode(members[0]) && isGramNode(members[1])) { | ||
element.kind = attributes.kind; | ||
element.children = [members[0], members[1]]; | ||
return element; | ||
} else if (isGramEmptyPath(members[0]) && isGramEmptyPath(members[1])) { | ||
element.relation = attributes.relation; | ||
element.kind = attributes.kind; | ||
element.children = []; | ||
@@ -156,3 +151,3 @@ return element; | ||
element.relation = attributes.relation || 'pair'; | ||
element.kind = attributes.kind || 'pair'; | ||
return element; | ||
@@ -169,3 +164,3 @@ }; | ||
record: undefined, | ||
children: undefined | ||
children: [] | ||
}; | ||
@@ -205,3 +200,3 @@ /** | ||
* @param children | ||
* @param relation | ||
* @param kind | ||
* @param id | ||
@@ -212,3 +207,3 @@ * @param labels | ||
var edge = function edge(children, relation, id, labels, record) { | ||
var edge = function edge(children, kind, id, labels, record) { | ||
return _extends({ | ||
@@ -222,3 +217,3 @@ type: 'path', | ||
}, { | ||
relation: relation, | ||
kind: kind, | ||
children: children | ||
@@ -235,6 +230,28 @@ }); | ||
*/ | ||
// export const path = ( | ||
// members: [GramPath] | [GramPath, GramPath], | ||
// id?: string, | ||
// labels?: string[], | ||
// record?: GramRecord | ||
// ): GramPath => ({ | ||
// type: 'path', | ||
// id, | ||
// ...(labels && { labels }), | ||
// ...(record && { record }), | ||
// children: members, | ||
// }); | ||
var path = function path(members, id, labels, record) { | ||
/** | ||
* Build a pair | ||
* | ||
* @param children | ||
* @param id | ||
* @param labels | ||
* @param record | ||
*/ | ||
var pair = function pair(members, id, labels, record) { | ||
return _extends({ | ||
type: 'path', | ||
kind: 'pair', | ||
id: id | ||
@@ -367,3 +384,4 @@ }, labels && { | ||
cons: cons, | ||
path: path, | ||
pair: pair, | ||
listToPath: listToPath, | ||
node: node, | ||
@@ -391,9 +409,8 @@ edge: edge, | ||
seq: seq, | ||
reduce: reduce, | ||
listToPath: listToPath, | ||
cons: cons, | ||
EMPTY_PATH: EMPTY_PATH, | ||
empty: empty, | ||
node: node, | ||
edge: edge, | ||
path: path, | ||
pair: pair, | ||
recordToMap: recordToMap, | ||
@@ -420,3 +437,3 @@ mapToRecord: mapToRecord, | ||
export { EMPTY_PATH, _boolean as boolean, gramBuilder$1 as builder, cons, date, dayOfMonth, decimal, duration, edge, empty, flatten, hexadecimal, integer, mapToRecord, measurement, node, octal, path, pluck, property, recordToMap, reduce, seq, string, tagged, time, year }; | ||
export { _boolean as boolean, gramBuilder$1 as builder, cons, date, dayOfMonth, decimal, duration, edge, empty, flatten, hexadecimal, integer, listToPath, mapToRecord, measurement, node, octal, pair, pluck, property, recordToMap, seq, string, tagged, time, year }; | ||
//# sourceMappingURL=gram-builder.esm.js.map |
@@ -26,14 +26,2 @@ (function (global, factory) { | ||
/** | ||
* # Gram AST Types | ||
* | ||
* These AST elements | ||
* | ||
* References: | ||
* | ||
* - [unist](https://github.com/syntax-tree/unist) - Universal Synax Tree | ||
* - [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) | ||
* @packageDocumentation | ||
*/ | ||
/** | ||
* Type guard for a Path. | ||
@@ -44,2 +32,3 @@ * | ||
var isGramPath = function isGramPath(o) { | ||
@@ -63,3 +52,3 @@ return !!o.type && o.type === 'path'; | ||
var isGramEmptyPath = function isGramEmptyPath(o) { | ||
return isGramPath(o) && o.children === undefined && o.id === EMPTY_PATH_ID; | ||
return isGramPath(o) && o.id === EMPTY_PATH_ID; | ||
}; | ||
@@ -104,4 +93,3 @@ /** | ||
/** | ||
* Build a path sequence that represents a graph | ||
* accumulating structure over time. | ||
* Build a path sequence that represents a graph. | ||
* | ||
@@ -128,5 +116,5 @@ * @param paths sequence of paths through history | ||
/** | ||
* Reduce a list of paths into a single path composed using the given relation. | ||
* Reduce a list of paths into a single path composed using the given kind. | ||
* | ||
* @param relation the relation to apply to all sub-paths | ||
* @param kind the kind to apply to all sub-paths | ||
* @param pathlist sub-paths to be paired | ||
@@ -136,17 +124,13 @@ * @param baseID the baseID from which path expressions will derive new IDs | ||
var reduce = function reduce(relation, pathlist, baseID) { | ||
if (relation === void 0) { | ||
relation = 'pair'; | ||
var listToPath = function listToPath(kind, pathlist) { | ||
if (kind === void 0) { | ||
kind = 'pair'; | ||
} | ||
var subID = 0; | ||
if (pathlist.length > 1) { | ||
return pathlist.reduceRight(function (acc, curr) { | ||
var childID = baseID ? "" + baseID + subID : undefined; | ||
return pathlist.slice(0, pathlist.length - 1).reduceRight(function (acc, curr) { | ||
return cons([curr, acc], { | ||
relation: relation, | ||
id: childID | ||
kind: kind | ||
}); | ||
}, EMPTY_PATH); | ||
}, pathlist[pathlist.length - 1]); | ||
} else { | ||
@@ -204,8 +188,8 @@ return pathlist[0]; | ||
} else if (members.length === 2) { | ||
if (attributes.relation && attributes.relation !== 'pair' && isGramNode(members[0]) && isGramNode(members[1])) { | ||
element.relation = attributes.relation; | ||
if (attributes.kind && attributes.kind !== 'pair' && isGramNode(members[0]) && isGramNode(members[1])) { | ||
element.kind = attributes.kind; | ||
element.children = [members[0], members[1]]; | ||
return element; | ||
} else if (isGramEmptyPath(members[0]) && isGramEmptyPath(members[1])) { | ||
element.relation = attributes.relation; | ||
element.kind = attributes.kind; | ||
element.children = []; | ||
@@ -218,3 +202,3 @@ return element; | ||
element.relation = attributes.relation || 'pair'; | ||
element.kind = attributes.kind || 'pair'; | ||
return element; | ||
@@ -231,3 +215,3 @@ }; | ||
record: undefined, | ||
children: undefined | ||
children: [] | ||
}; | ||
@@ -267,3 +251,3 @@ /** | ||
* @param children | ||
* @param relation | ||
* @param kind | ||
* @param id | ||
@@ -274,3 +258,3 @@ * @param labels | ||
var edge = function edge(children, relation, id, labels, record) { | ||
var edge = function edge(children, kind, id, labels, record) { | ||
return _extends({ | ||
@@ -284,3 +268,3 @@ type: 'path', | ||
}, { | ||
relation: relation, | ||
kind: kind, | ||
children: children | ||
@@ -297,6 +281,28 @@ }); | ||
*/ | ||
// export const path = ( | ||
// members: [GramPath] | [GramPath, GramPath], | ||
// id?: string, | ||
// labels?: string[], | ||
// record?: GramRecord | ||
// ): GramPath => ({ | ||
// type: 'path', | ||
// id, | ||
// ...(labels && { labels }), | ||
// ...(record && { record }), | ||
// children: members, | ||
// }); | ||
var path = function path(members, id, labels, record) { | ||
/** | ||
* Build a pair | ||
* | ||
* @param children | ||
* @param id | ||
* @param labels | ||
* @param record | ||
*/ | ||
var pair = function pair(members, id, labels, record) { | ||
return _extends({ | ||
type: 'path', | ||
kind: 'pair', | ||
id: id | ||
@@ -429,3 +435,4 @@ }, labels && { | ||
cons: cons, | ||
path: path, | ||
pair: pair, | ||
listToPath: listToPath, | ||
node: node, | ||
@@ -453,9 +460,8 @@ edge: edge, | ||
seq: seq, | ||
reduce: reduce, | ||
listToPath: listToPath, | ||
cons: cons, | ||
EMPTY_PATH: EMPTY_PATH, | ||
empty: empty, | ||
node: node, | ||
edge: edge, | ||
path: path, | ||
pair: pair, | ||
recordToMap: recordToMap, | ||
@@ -482,3 +488,2 @@ mapToRecord: mapToRecord, | ||
exports.EMPTY_PATH = EMPTY_PATH; | ||
exports.boolean = _boolean; | ||
@@ -496,2 +501,3 @@ exports.builder = gramBuilder$1; | ||
exports.integer = integer; | ||
exports.listToPath = listToPath; | ||
exports.mapToRecord = mapToRecord; | ||
@@ -501,7 +507,6 @@ exports.measurement = measurement; | ||
exports.octal = octal; | ||
exports.path = path; | ||
exports.pair = pair; | ||
exports.pluck = pluck; | ||
exports.property = property; | ||
exports.recordToMap = recordToMap; | ||
exports.reduce = reduce; | ||
exports.seq = seq; | ||
@@ -508,0 +513,0 @@ exports.string = string; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e=e||self).gram=e.gram||{},e.gram.builder={}))}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(e){return!!e.type&&"path"===e.type},r=function(e){return n(e)&&void 0===e.children&&"ø"===e.id},i=function(e){return n(e)&&e.children&&0===e.children.length&&"ø"!==e.id};function o(e){return Array.isArray(e)?e:e instanceof Function?o(e()):void 0===e?[]:[e]}var a=function(e,n,r,i){return t({type:"seq",id:n},r&&{labels:r},i&&{record:i},{children:o(e)})},u=function(e,t,n){return void 0===e&&(e="pair"),t.length>1?t.reduceRight((function(t,r){return c([r,t],{relation:e,id:n?""+n+0:void 0})}),d):t[0]},c=function(e,n){void 0===n&&(n={});var o=t({type:"path"},n.id&&{id:n.id},n.labels&&{labels:n.labels},n.record&&{record:n.record});if(void 0===e)return o.id&&"ø"!==o.id?(o.children=[],o):(o.children=void 0,d);if(0===e.length)return"ø"===o.id?d:(o.children=[],o);if(1===e.length){var a=e[0];return r(a)?(o.children=[],o):(o.children=[a],o)}if(2===e.length){if(n.relation&&"pair"!==n.relation&&i(e[0])&&i(e[1]))return o.relation=n.relation,o.children=[e[0],e[1]],o;if(r(e[0])&&r(e[1]))return o.relation=n.relation,o.children=[],o;o.children=[e[0],e[1]]}return o.relation=n.relation||"pair",o},d={type:"path",id:"ø",labels:void 0,record:void 0,children:void 0},l=function(){return d},f=function(e,n,r){return t({type:"path"},e&&{id:e},n&&{labels:n},r&&{record:r},{children:[]})},p=function(e,n,r,i,o){return t({type:"path",id:r},i&&{labels:i},o&&{record:o},{relation:n,children:e})},s=function(e,n,r,i){return t({type:"path",id:n},r&&{labels:r},i&&{record:i},{children:e})},g=function(e){return e.reduce((function(e,t){return e[t.name]=t.value,e}),{})},h=function(e){return Object.entries(e).reduce((function(e,t){return e.push(m(t[0],t[1])),e}),[])},y=function(e,t){return e.reduce((function(e,n){return n.name===t?n:e}))},m=function(e,t){return{type:"property",name:e,value:t}},v=function(e){return{type:"boolean",value:e?"true":"false"}},b=function(e){return{type:"string",value:e}},T=function(e,t){return{type:"tagged",value:t,tag:e}},M=function(e){return{type:"integer",value:String(e)}},S=function(e){return{type:"decimal",value:String(e)}},O=function(e){return{type:"hexadecimal",value:"number"==typeof e?e.toString(16):e}},_=function(e){return{type:"octal",value:"number"==typeof e?e.toString(8):e}},x=function(e,t){return{type:"measurement",value:String(t),unit:e}},D=function(e){return T("date",e instanceof Date?e.getFullYear().toString():e)},P=function(e){return T("date",e instanceof Date?e.toISOString().slice(0,10):e)},C=function(e){return T("date",e instanceof Date?"--"+e.toISOString().slice(5,10):e)},U=function(e){return T("time",e instanceof Date?e.toTimeString():e)},j=function(e){return T("duration",e instanceof Date?"P"+(e.getUTCFullYear()-1970)+"Y"+e.getUTCMonth()+"M"+e.getUTCDate()+"DT"+e.getUTCHours()+"H"+e.getUTCMinutes()+"M"+e.getUTCMilliseconds()/1e3+"S":e)},Y=function(e,t){return void 0===t&&(t=1),e.flat(t).filter((function(e){return null!==e}))},q={__proto__:null,seq:a,reduce:u,cons:c,EMPTY_PATH:d,empty:l,node:f,edge:p,path:s,recordToMap:g,mapToRecord:h,pluck:y,property:m,boolean:v,string:b,tagged:T,integer:M,decimal:S,hexadecimal:O,octal:_,measurement:x,year:D,date:P,dayOfMonth:C,time:U,duration:j,flatten:Y,default:{seq:a,empty:l,cons:c,path:s,node:f,edge:p,property:m,boolean:v,string:b,tagged:T,integer:M,decimal:S,hexadecimal:O,octal:_,measurement:x,date:P,time:U,duration:j,flatten:Y,recordToMap:g,mapToRecord:h}};e.EMPTY_PATH=d,e.boolean=v,e.builder=q,e.cons=c,e.date=P,e.dayOfMonth=C,e.decimal=S,e.duration=j,e.edge=p,e.empty=l,e.flatten=Y,e.hexadecimal=O,e.integer=M,e.mapToRecord=h,e.measurement=x,e.node=f,e.octal=_,e.path=s,e.pluck=y,e.property=m,e.recordToMap=g,e.reduce=u,e.seq=a,e.string=b,e.tagged=T,e.time=U,e.year=D,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=e.gram||{},e.gram.builder={}))}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(e){return!!e.type&&"path"===e.type},r=function(e){return n(e)&&"ø"===e.id},i=function(e){return n(e)&&e.children&&0===e.children.length&&"ø"!==e.id};function o(e){return Array.isArray(e)?e:e instanceof Function?o(e()):void 0===e?[]:[e]}var a=function(e,n,r,i){return t({type:"seq",id:n},r&&{labels:r},i&&{record:i},{children:o(e)})},u=function(e,t){return void 0===e&&(e="pair"),t.length>1?t.slice(0,t.length-1).reduceRight((function(t,n){return d([n,t],{kind:e})}),t[t.length-1]):t[0]},d=function(e,n){void 0===n&&(n={});var o=t({type:"path"},n.id&&{id:n.id},n.labels&&{labels:n.labels},n.record&&{record:n.record});if(void 0===e)return o.id&&"ø"!==o.id?(o.children=[],o):(o.children=void 0,c);if(0===e.length)return"ø"===o.id?c:(o.children=[],o);if(1===e.length){var a=e[0];return r(a)?(o.children=[],o):(o.children=[a],o)}if(2===e.length){if(n.kind&&"pair"!==n.kind&&i(e[0])&&i(e[1]))return o.kind=n.kind,o.children=[e[0],e[1]],o;if(r(e[0])&&r(e[1]))return o.kind=n.kind,o.children=[],o;o.children=[e[0],e[1]]}return o.kind=n.kind||"pair",o},c={type:"path",id:"ø",labels:void 0,record:void 0,children:[]},l=function(){return c},f=function(e,n,r){return t({type:"path"},e&&{id:e},n&&{labels:n},r&&{record:r},{children:[]})},p=function(e,n,r,i,o){return t({type:"path",id:r},i&&{labels:i},o&&{record:o},{kind:n,children:e})},s=function(e,n,r,i){return t({type:"path",kind:"pair",id:n},r&&{labels:r},i&&{record:i},{children:e})},g=function(e){return e.reduce((function(e,t){return e[t.name]=t.value,e}),{})},h=function(e){return Object.entries(e).reduce((function(e,t){return e.push(m(t[0],t[1])),e}),[])},y=function(e,t){return e.reduce((function(e,n){return n.name===t?n:e}))},m=function(e,t){return{type:"property",name:e,value:t}},v=function(e){return{type:"boolean",value:e?"true":"false"}},b=function(e){return{type:"string",value:e}},T=function(e,t){return{type:"tagged",value:t,tag:e}},k=function(e){return{type:"integer",value:String(e)}},S=function(e){return{type:"decimal",value:String(e)}},M=function(e){return{type:"hexadecimal",value:"number"==typeof e?e.toString(16):e}},O=function(e){return{type:"octal",value:"number"==typeof e?e.toString(8):e}},x=function(e,t){return{type:"measurement",value:String(t),unit:e}},D=function(e){return T("date",e instanceof Date?e.getFullYear().toString():e)},C=function(e){return T("date",e instanceof Date?e.toISOString().slice(0,10):e)},P=function(e){return T("date",e instanceof Date?"--"+e.toISOString().slice(5,10):e)},U=function(e){return T("time",e instanceof Date?e.toTimeString():e)},_=function(e){return T("duration",e instanceof Date?"P"+(e.getUTCFullYear()-1970)+"Y"+e.getUTCMonth()+"M"+e.getUTCDate()+"DT"+e.getUTCHours()+"H"+e.getUTCMinutes()+"M"+e.getUTCMilliseconds()/1e3+"S":e)},j=function(e,t){return void 0===t&&(t=1),e.flat(t).filter((function(e){return null!==e}))},q={__proto__:null,seq:a,listToPath:u,cons:d,empty:l,node:f,edge:p,pair:s,recordToMap:g,mapToRecord:h,pluck:y,property:m,boolean:v,string:b,tagged:T,integer:k,decimal:S,hexadecimal:M,octal:O,measurement:x,year:D,date:C,dayOfMonth:P,time:U,duration:_,flatten:j,default:{seq:a,empty:l,cons:d,pair:s,listToPath:u,node:f,edge:p,property:m,boolean:v,string:b,tagged:T,integer:k,decimal:S,hexadecimal:M,octal:O,measurement:x,date:C,time:U,duration:_,flatten:j,recordToMap:g,mapToRecord:h}};e.boolean=v,e.builder=q,e.cons=d,e.date=C,e.dayOfMonth=P,e.decimal=S,e.duration=_,e.edge=p,e.empty=l,e.flatten=j,e.hexadecimal=M,e.integer=k,e.listToPath=u,e.mapToRecord=h,e.measurement=x,e.node=f,e.octal=O,e.pair=s,e.pluck=y,e.property=m,e.recordToMap=g,e.seq=a,e.string=b,e.tagged=T,e.time=U,e.year=D,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=gram-builder.umd.production.min.js.map |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"license": "MIT", | ||
@@ -52,5 +52,7 @@ "repository": { | ||
"devDependencies": { | ||
"@types/chalk": "^2.2.0", | ||
"@types/jest": "^26.0.15", | ||
"@types/unist": "^2.0.3", | ||
"@typescript-eslint/parser": "^4.8.1", | ||
"chalk": "^4.1.0", | ||
"husky": "^4.3.0", | ||
@@ -69,5 +71,5 @@ "npm-check-updates": "^10.2.1", | ||
"dependencies": { | ||
"@gram-data/gram-ast": "^0.2.9" | ||
"@gram-data/gram-ast": "^0.2.10" | ||
}, | ||
"gitHead": "1ff6bdb1c799a29a95540314bdb5b2a881971774", | ||
"gitHead": "5ab0f6f900db922abaf69906f62d6cf23e12215e", | ||
"publishConfig": { | ||
@@ -74,0 +76,0 @@ "access": "public" |
@@ -9,3 +9,3 @@ /** | ||
import { | ||
GramPathSeq, | ||
GramSeq, | ||
GramPath, | ||
@@ -16,4 +16,2 @@ GramNode, | ||
GramRecordValue, | ||
Relation, | ||
Navigation, | ||
BooleanLiteral, | ||
@@ -28,3 +26,2 @@ StringLiteral, | ||
GramRecord, | ||
GramPathlike, | ||
GramEmptyPath, | ||
@@ -38,2 +35,4 @@ isGramNode, | ||
DurationLiteral, | ||
RelationshipKind, | ||
OrientedKind, | ||
} from '@gram-data/gram-ast'; | ||
@@ -61,4 +60,3 @@ | ||
/** | ||
* Build a path sequence that represents a graph | ||
* accumulating structure over time. | ||
* Build a path sequence that represents a graph. | ||
* | ||
@@ -75,3 +73,3 @@ * @param paths sequence of paths through history | ||
record?: GramRecord | ||
): GramPathSeq => ({ | ||
): GramSeq => ({ | ||
type: 'seq', | ||
@@ -88,23 +86,22 @@ id, | ||
record?: GramRecord; | ||
relation?: Relation; | ||
kind?: RelationshipKind; | ||
} | ||
/** | ||
* Reduce a list of paths into a single path composed using the given relation. | ||
* Reduce a list of paths into a single path composed using the given kind. | ||
* | ||
* @param relation the relation to apply to all sub-paths | ||
* @param kind the kind to apply to all sub-paths | ||
* @param pathlist sub-paths to be paired | ||
* @param baseID the baseID from which path expressions will derive new IDs | ||
*/ | ||
export const reduce = ( | ||
relation: Relation = 'pair', | ||
pathlist: GramPath[], | ||
baseID?: string | ||
): GramPathlike => { | ||
let subID = 0; | ||
export const listToPath = ( | ||
kind: RelationshipKind = 'pair', | ||
pathlist: GramPath[] | ||
): GramPath => { | ||
if (pathlist.length > 1) { | ||
return pathlist.reduceRight((acc: GramPathlike, curr) => { | ||
const childID = baseID ? `${baseID}${subID}` : undefined; | ||
return cons([curr, acc], { relation, id: childID }); | ||
}, EMPTY_PATH); | ||
return pathlist | ||
.slice(0, pathlist.length - 1) | ||
.reduceRight((acc: GramPath, curr) => { | ||
return cons([curr, acc], { kind }); | ||
}, pathlist[pathlist.length - 1]); | ||
} else { | ||
@@ -122,5 +119,5 @@ return pathlist[0]; | ||
export const cons = ( | ||
members?: [] | [GramPathlike] | [GramPathlike, GramPathlike], | ||
members?: [] | [GramPath] | [GramPath, GramPath], | ||
attributes: PathAttributes = {} | ||
): GramPathlike => { | ||
): GramPath => { | ||
const element: any = { | ||
@@ -158,12 +155,12 @@ type: 'path', | ||
if ( | ||
attributes.relation && | ||
attributes.relation !== 'pair' && | ||
attributes.kind && | ||
attributes.kind !== 'pair' && | ||
isGramNode(members[0]) && | ||
isGramNode(members[1]) | ||
) { | ||
element.relation = attributes.relation; | ||
element.kind = attributes.kind; | ||
element.children = [members[0], members[1]]; | ||
return element as GramEdge; | ||
} else if (isGramEmptyPath(members[0]) && isGramEmptyPath(members[1])) { | ||
element.relation = attributes.relation; | ||
element.kind = attributes.kind; | ||
element.children = []; | ||
@@ -174,3 +171,3 @@ return element as GramNode; | ||
} | ||
element.relation = attributes.relation || 'pair'; | ||
element.kind = attributes.kind || 'pair'; | ||
return element as GramPath; | ||
@@ -182,3 +179,3 @@ }; | ||
*/ | ||
export const EMPTY_PATH: GramEmptyPath = { | ||
const EMPTY_PATH: GramEmptyPath = { | ||
type: 'path', | ||
@@ -188,3 +185,3 @@ id: EMPTY_PATH_ID, | ||
record: undefined, | ||
children: undefined, | ||
children: [], | ||
}; | ||
@@ -221,3 +218,3 @@ | ||
* @param children | ||
* @param relation | ||
* @param kind | ||
* @param id | ||
@@ -229,3 +226,3 @@ * @param labels | ||
children: [GramNode, GramNode], | ||
relation: Navigation, | ||
kind: OrientedKind, | ||
id?: string, | ||
@@ -239,3 +236,3 @@ labels?: string[], | ||
...(record && { record }), | ||
relation, | ||
kind, | ||
children, | ||
@@ -252,4 +249,25 @@ }); | ||
*/ | ||
export const path = ( | ||
members: [GramPath] | [GramPath, GramPath], | ||
// export const path = ( | ||
// members: [GramPath] | [GramPath, GramPath], | ||
// id?: string, | ||
// labels?: string[], | ||
// record?: GramRecord | ||
// ): GramPath => ({ | ||
// type: 'path', | ||
// id, | ||
// ...(labels && { labels }), | ||
// ...(record && { record }), | ||
// children: members, | ||
// }); | ||
/** | ||
* Build a pair | ||
* | ||
* @param children | ||
* @param id | ||
* @param labels | ||
* @param record | ||
*/ | ||
export const pair = ( | ||
members: [GramPath, GramPath], | ||
id?: string, | ||
@@ -260,2 +278,3 @@ labels?: string[], | ||
type: 'path', | ||
kind: 'pair', | ||
id, | ||
@@ -291,7 +310,7 @@ ...(labels && { labels }), | ||
export const pluck = (properties: GramRecord, path:string) => { | ||
return properties.reduce( (acc, prop) => { | ||
return prop.name === path ? prop : acc | ||
}) | ||
} | ||
export const pluck = (properties: GramRecord, path: string) => { | ||
return properties.reduce((acc, prop) => { | ||
return prop.name === path ? prop : acc; | ||
}); | ||
}; | ||
@@ -396,3 +415,4 @@ export const property = ( | ||
cons, | ||
path, | ||
pair, | ||
listToPath, | ||
node, | ||
@@ -399,0 +419,0 @@ edge, |
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
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
144835
1838
16
Updated@gram-data/gram-ast@^0.2.10