1.3.0 • Published 9 months ago

@new10com/attempt v1.3.0

Weekly downloads
577
License
-
Repository
-
Last release
9 months ago

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)
1.3.0

9 months ago

1.3.0-alpha.0

9 months ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago