@marianmeres/topo-merge
v1.1.2
Published
[](https://jsr.io/@marianmeres/topo-merge) [](https://www.npmjs.com/package/@marianmeres/topo-merge) [;
// Result:
// a: { foo: "bar" }
// b: { foo: "bar", baz: "bat" }
// c: { foo: "bar", baz: "bat", hey: "ho" }
// d: { foo: "foo", baz: "bat", hey: "ho", lets: "go" }
// e: { foo: "bar", baz: "bat", hey: "ho" }API
topoMerge(schema, mergeOptions?, mergeOmitIdProp?)
Main function that resolves inheritance and merges objects.
function topoMerge(
schema: Record<string, WithExtends> | [string, WithExtends][],
mergeOptions?: DeepMergeOptions,
mergeOmitIdProp?: boolean // default: true
): Record<string, Record<string, any>>schema- Object or entries array where keys become node IDsmergeOptions- Options fordeepMerge. Default:{ arrays: "replace" }mergeOmitIdProp- Whether to exclude theidproperty from results. Default:true
topoSort(nodes)
Lower-level utility for topological sorting. Most users should use topoMerge instead.
Merge Behavior
- Child overrides parent - Properties defined on a node override inherited ones
- Arrays are replaced - By default, arrays replace rather than concatenate (configurable via
mergeOptions.arrays) - Deep merge - Nested objects are recursively merged
- Explicit
undefined- Set a property toundefinedto remove an inherited value
Full API Documentation
See API.md for complete API reference including all interfaces, error handling, and detailed examples.
