Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wishtack/get

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wishtack/get

A safe navigation `get` function.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
2
Weekly downloads
 
Created
Source

@wishtack/get

@wishtack/get is a TypeScript typed functional alternative to Optional Chaining Operator (a.k.a. Safe Navigation Operator).

  • Cf. https://github.com/Microsoft/TypeScript/issues/16
  • Cf. https://github.com/tc39/proposal-optional-chaining

Installation

yarn add @wishtack/get

or

npm install --save @wishtack/get

Usage

import { get } from '@wishtack/get';

interface User {
    name: string;
    address?: {
        postalCode: string;
        street: string;
    };
}

const user: User = {
    name: 'Foo BAR'
};

get(user, 'address', 'postalCode'); // -> undefined

get(user, 'address', 'code'); // -> Compile time error

// playground.ts: - error TS2345: Argument of type '"code"' is not assignable to parameter of type '"postalCode" | "street"'.
//
// console.log(get(user, 'address', 'code'));
//                                 ~~~~~~~~

Enjoy type inference and get auto-completion for free

@wishtack/get auto completion

Keywords

FAQs

Package last updated on 12 Feb 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

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