0.0.1 • Published 5 years ago

@sullux/fp-light-always v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

home

fp-light-always

npm i @sullux/fp-light-always source test

The always utility wraps a static value in a function. While simple as far as utilities go, it can add readability to functional code.

always

always<T>(value: T): T

The following example uses always to return a pre-determined value from a thennable.

const { curry } = require('@sullux/fp-light-curry')
const AWS = require('aws-sdk')

const s3 = new AWS.s3()

const saveObject = curry((key, object) =>
  s3.putObject({
    Body: JSON.stringify(object),
    Bucket: process.env.BUCKET,
    Key: key,
  }).promise().then(always(object)))