New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aleclarson/deep

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aleclarson/deep

Deep get/set/delete

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

deep

npm Build status codecov Bundle size Install size Code style: Prettier Donate

Woah. That's deep.

import deep from '@aleclarson/deep'
// or
import { get, set, unset } from '@aleclarson/deep'

let val
val = deep.get(obj, 'a.b.c') // dot-notation
val = deep.get(obj, ['a', 'b', 'c']) // key path
val = deep.get(obj, 'a', 0) // default value
val = deep.set(obj, 'a', 1) // type-safe shallow keys
val = deep.unset(obj, 'a') // delete an optional property
val = deep.delete(obj, 'a') // "delete" is an alias for "unset"
val = deep.delete(obj, 'a', 0) // default value

The get function returns either the default value or undefined when a property cannot be resolved.

The set function returns the new value. When a parent is nullish, an object is created on-the-fly. When a parent is a non-nullish non-object, an error is thrown.

The unset function returns the old value. When a property cannot be resolved, this function is a no-op.

 

Inspiration

 

License

MIT

FAQs

Package last updated on 08 Dec 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc