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

@jsier/deep-value

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

@jsier/deep-value

Safely resolves deep value of an object or array by providing path to the targeted property.

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@jsier/deep-value

A simple, efficient and lightweight package without external dependencies intended for safely resolving deep value of an object or array by providing path to the targeted property. deepValue is built with TypeScript (preserves full compatibility with pure JavaScript) and is easy to use.

Getting Started

$ npm install @jsier/deep-value --save

Usage

deepValue as first argument expects object or array as a source. Second argument should be string representing the path to the targeted property. Non-existing properties or invalid paths provided will return undefined as the result.

import { deepValue } from '@jsier/deep-value';

const employee = {
  name: 'Gia',
  age: 44,
  gender: null,
  skills: [['ts', 'js'], ['en', 'fr']],
  children: [{name: 'Mia'}]
};

deepValue(employee, 'name'); // -> 'Gia'
deepValue(employee, 'gender'); // -> null
deepValue(employee, 'skill[0]'); // -> ['ts', 'js']
deepValue(employee, 'skill[0][1]'); // -> 'js'
deepValue(employee, 'children[0].name'); // -> 'Mia'
deepValue(employee.children, '[0].name'); // -> 'Mia'
deepValue(employee.children, '[0].gender'); // -> undefined

Support

All suggestions and improvements are welcomed and appreciated.

License

The MIT License.

Keywords

FAQs

Package last updated on 23 Feb 2020

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