
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
dot-prop-ts
Advanced tools
Get, set, or delete a property from a nested object using a dot path refactored for typescript
Get, set, or delete a property from a nested object using a dot path
This package is heavily inspired on the dot-prop package developed by Sindre Sorhus and has been refactored to typescript so that it can be installed and used without converting your project to ESM module (see issue).
Using NPM
npm install dot-prop-ts
Using yarn
yarn add dot-prop-ts
import {getProperty} from 'dot-prop-ts';
// Getter
getProperty({foo: {bar: 'unicorn'}}, 'foo.bar');
//=> 'unicorn'
getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep');
//=> null
getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
//=> 'default value'
getProperty({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
//=> 'unicorn'
getProperty({foo: [{bar: 'unicorn'}]}, 'foo.0.bar');
//=> 'unicorn'
import {setProperty} from 'dot-prop-ts';
const object = {foo: {bar: 'a'}};
setProperty(object, 'foo.bar', 'b');
//=> {foo: {bar: 'b'}}
const foo = setProperty({}, 'foo.bar', 'c');
//=> {foo: {bar: 'c'}}
setProperty(object, 'foo.baz', 'x');
//=> {foo: {bar: 'b', baz: 'x'}}
setProperty(object, 'foo.biz[0]', 'a');
//=> {foo: {bar: 'b', baz: 'x', biz: ['a']}}
import {hasProperty} from 'dot-prop-ts';
const object = {foo: {bar: 'a'}};
hasProperty(object, 'foo.bar');
//=> true
hasProperty(object, 'foo.goo');
//=> false
import {deleteProperty} from 'dot-prop-ts';
const object = {foo: {bar: 'a'}};
deleteProperty(object, 'foo.bar');
//=> {foo:{}}
const object = {foo: {bar: 'a'}};
deleteProperty(object, 'foo');
//=> {}
FAQs
Get, set, or delete a property from a nested object using a dot path refactored for typescript
The npm package dot-prop-ts receives a total of 778 weekly downloads. As such, dot-prop-ts popularity was classified as not popular.
We found that dot-prop-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.