Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@datorama/ts-safe-access

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datorama/ts-safe-access

🍭 It's Like Lodash get with the 💪 of Typescript

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
131
-9.66%
Maintainers
1
Weekly downloads
 
Created
Source

🍭 It's Like Lodash get with the 💪 of Typescript

Build Status License Stars

Installation

npm install @datorama/ts-safe-access --save

Usage

  • get(object, getFn[, defaultValue, excludeNull = false]) - Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.

Options

OptionDescriptionDefault Value
defaultValueIf the resolved value is undefined, the defaultValue is returned in its place.undefined
excludeNullif the resolved value is null, the defaultValue is returned in its place.false
const data = {its: {really: {really: {really: {nested : undefined}}}}, nested: {value: null}};
const result = get(data, data => data.its.really.really.really.nested, 'defaultValue');
  • has(object, getFn) - Checks if path is a direct property of object.
const data = {its: {really: {really: {}}, b: {}};
const result = has(data, data => data.its.really.really.really.nested);

expect(result).toEqual(false);

Keywords

safe access

FAQs

Package last updated on 01 Apr 2019

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