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

@new10com/attempt

Package Overview
Dependencies
Maintainers
31
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@new10com/attempt

Replaces `lodash.get` with a similar API while also providing additional features.

  • 1.3.0
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Maintainers
31
Created
Source

Attempt

Replaces lodash.get with a similar API while also providing additional features.

Why?

Lodash is an amazing utility however it's quite bloated, even its modularized version.

This module has around 0.2kb while lodash.get has 27kb.

Remember that size is really important in our serverless world :rocket:

API

attempt(getter, fallback)

  • getter: A function which returns the value we want or executes another function
  • fallback: Fallback value in case getter throws or returns undefined. If typeof fallback === 'function' then it will execute it.

Usage

Retrieving data based on a given path:

const data = attempt(() => response.items[2].payload)
const dataWithFallback = attempt(() => response.items[2].payload, null)

FAQs

Package last updated on 21 Aug 2023

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