@saunos/utils
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

Utils

Functional utility library - modern, simple, typed, powerful

bundle size npm downloads npm version MIT license

Docs

Can be found here

Install

npm install @saunos/utils

Usage

A very brief kitchen sink.

import * as _ from 'radash'

const gods = [{
  name: 'Ra',
  power: 'sun',
  rank: 100,
  culture: 'egypt'
}, {
  name: 'Loki',
  power: 'tricks',
  rank: 72,
  culture: 'norse'
}, {
  name: 'Zeus',
  power: 'lightning',
  rank: 96,
  culture: 'greek'
}]

_.max(gods, g => g.rank) // => ra
_.sum(gods, g => g.rank) // => 268
_.fork(gods, g => g.culture === 'norse') // => [[loki], [ra, zeus]]
_.sort(gods, g => g.rank) // => [ra, zeus, loki]
_.boil(gods, (a, b) => a.rank > b.rank ? a : b) // => ra

_.objectify(
  gods, 
  g => g.name.toLowerCase(), 
  g => _.pick(g, ['power', 'rank', 'culture'])
) // => { ra, zeus, loki }

const godName = _.get(gods, g => g[0].name)

const [err, god] = await _.try(api.gods.findByName)(godName)

const allGods = await _.map(gods, async ({ name }) => {
  return api.gods.findByName(name)
})

Readme

Keywords

none

Package Sidebar

Install

npm i @saunos/utils

Weekly Downloads

62

Version

0.6.0

License

MIT

Unpacked Size

324 kB

Total Files

44

Last publish

Collaborators

  • mkatrenik