Registry / developer-tools / dot-component

dot-component

JSON →
library0.1.1jsnpmunverified

MongoDB-style dot notation querying for JavaScript objects. It provides get, set, and parent traversal functions for nested object paths. This package is stable but very old (v0.1.1, last updated ~2013). It was designed for the now-defunct component(1) package manager and has no recent updates. Minimal and dependency-free, but lacks modern features like array index handling with brackets. Not actively maintained and best replaced by libraries like lodash._get or object-path.

npm install dot-component
INSTALL
IMPORT
SIG · DOT-COMPONENT
D
dot-component
developer-toolsjavascriptv0.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.

dot
const dot = require('dot')
import dot from 'dot'
This package uses CommonJS and does not support ESM imports. The module exports a single object with get, set, parent methods.
get
dot.get(obj, path)
get(obj, path)
get is not exported as a standalone function; it's a method on the default export.
set
dot.set(obj, path, value)
dot.set(obj, path, value, [init])
The fourth parameter init is optional; omitting it defaults to initializing missing paths.

Demonstrates basic usage of dot.get, dot.set, and dot.parent with nested objects and arrays.

const dot = require('dot') const obj = { name: { first: 'tobi' }, pets: [ { id: 1, name: 'loki' }, { id: 2, name: 'jane' } ] } console.log(dot.get(obj, 'name.first')) console.log(dot.get(obj, 'pets.0.name')) console.log(dot.parent(obj, 'name.first')) console.log(dot.set(obj, 'pets.1.name', 'Jane')) console.log(obj.pets[1].name)
Debug
Known issues
deprecatedPackage is no longer actively maintained and uses the deprecated component(1) package manager.
fix
Migrate to maintained alternatives like lodash.get or object-path.
affects: <=0.1.1
gotchaDoes not support bracket notation for array indices (e.g., 'pets[0].name') — only dot notation (e.g., 'pets.0.name').
fix
Use dot-only paths with numeric indices separated by dots.
affects: >=0.0.0
gotchaThe set function will create intermediate objects/arrays by default unless you pass false for the init parameter.
fix
Pass false as the fourth argument to disable path initialization.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'dot'
Not installed via npm; the package is not published on npm (only via component).
fix
Install via npm: npm install dot-component (the npm package name, not 'dot'). Or install the original from GitHub: npm install component/dot.
TypeError: dot.get is not a function
Incorrect import on ESM or bundlers expecting a default export.
fix
Use require('dot') instead of import.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
42 hits · last 30 days
node
38
Resources
dot-component — npm install dot-component · libregistry