Registry / storage / treem
library1.1.1jsnpmunverified

A high performance library for converting flat data (e.g., SQL query result rows) into nested object trees. Version 1.1.1. The tree structure is defined by column naming conventions: separator, collection, and key symbols. It supports multicolumn primary keys, pruning, custom model injection, aliasing, and pluralization detection. Key differentiator: minimal configuration for complex nesting, with sub-millisecond performance for thousands of rows.

npm install treem
INSTALL
IMPORT
SIG · TREEM
T
treem
storagejavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Treem
import Treem from 'treem'
import { Treem } from 'treem'
Default import. CommonJS users must call require('treem').default.

Convert flat movie data with actor arrays into nested object tree using treem.

import Treem from 'treem'; const movies = [ { name: 'Rogue one', '+actors.firstName': 'Felicity', '+actors.lastName': 'Jones' }, { name: 'Rogue one', '+actors.firstName': 'Diego', '+actors.lastName': 'Luna' }, { name: 'Star Wars: The Force Awakens', '+actors.firstName': 'Harrison', '+actors.lastName': 'Ford' }, { name: 'Star Wars: The Force Awakens', '+actors.firstName': 'Daisy', '+actors.lastName': 'Ridley' } ]; const treem = new Treem(); treem.fill(movies); const result = treem.data; console.log(JSON.stringify(result, null, 2)); /* Output: [ { "name": "Rogue one", "actors": [ { "firstName": "Felicity", "lastName": "Jones" }, { "firstName": "Diego", "lastName": "Luna" } ] }, { "name": "Star Wars: The Force Awakens", "actors": [ { "firstName": "Harrison", "lastName": "Ford" }, { "firstName": "Daisy", "lastName": "Ridley" } ] } ] */
Debug
Known issues
gotchaWhen using CommonJS require, you must access .default: const Treem = require('treem').default
fix
Use const Treem = require('treem').default; or switch to ESM.
affects: >=1.0
gotchaNested collection detection relies on '+' symbol by default; ensure no collision with column names containing '+'. You can customize the symbol via options.
fix
Pass custom symbols: new Treem({ symbols: { collection: '~' } })
affects: >=1.0
gotchaEmpty rows after pruning may result in missing nodes; understand prune behavior for null/undefined values.
fix
Set prune: false or customize prune function.
affects: >=1.0
Errors
Common errors & fixes
TypeError: treem.fill is not a function
Incorrect import: using named import instead of default import.
fix
Use import Treem from 'treem' (default import).
Cannot find module 'treem'
treem is not installed or typo in package name.
fix
Run npm install treem and verify package.json.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
18
Amazon
1
Resources
packagetreem
treem — npm install treem · libregistry