npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

early-cheepers

v1.0.0

Published

type checking combinator birds

Downloads

8

Readme

early-cheepers

early-cheepers uses sanctuary-def to provide early-birds combinators with optional type checking.

By default, type checking is done under the condition process.env.NODE_ENV !== 'production'. If this is not desirable, the condition can be changed using the cheepers function with a configuration object as follows:

const aviary = cheepers ({
  checkTypes: process.env.NODE_ENV !== 'production'`, // change the predicate here
})
// now all available combinators are members of aviary, e.g. aviary.bluebird

If only a subset of the combinators is required, another option key, names, may be set to an array of the desired combinators' names, e.g.

const aviary = cheepers ({
   checkTypes: process.env.NODE_ENV === 'development'`,
   names: [ bluebird, psi, ],
})
// now aviary.bluebird and aviary.psi are available with the changed predicate

Eager evaluation

Intermediate results for early-cheepers combinators, like those of early-birds, are eagerly evaluated, see early-birds for more information regarding the eager evaluation. In short, if the use case relies on side-effects, careful consideration should be given on how the impure functions are being used with the combinators. If eager evaluation is not desired, then fantasy-birds may fit the use case. The cheepers function can be used with fantasy-birds (v0.1.0) using a third option key, implementations, as follows:

const F = require ('fantasy-birds') // NOTE: not included as a dependency, must be installed seperately
import { cheepers } from 'early-cheepers'

const aviary = cheepers({
  implementations: F
})
// now type checking fantasy-birds combinators are available, e.g. aviary.bluebird

Install

npm i early-cheepers

Integrating with Sanctuary

No special action is required for integration with Sanctuary. Simply import the desired combinators from early-cheapers, e.g. import { bluebird } from 'early-cheepers'.

Comparison between early-cheepers combinators and sanctuary combinators

The early-cheepers combinators are specialized on functions whereas the sanctuary combinators are more general. For example, sanctuary's compose can be used to compose Pair types (or any other Semigroupoid) as well as functions; however, early-cheaper's bluebird (compose) combinator only composes functions.

Consideration of type checking functions as parameters

Currently (for sanctuary-def v0.22.0), when functions are passed as parameters, the passed function's type is not checked (in general, this would require knowledge which is simply not available at the time of the call), but rather it seems that sanctuary-def checks that the parameter is a function type. In short, this means that type errors, when thrown, will likely identify the error for an invalid parameter to the passed function rather than the passed function as an invalid parameter for the combinator. For example, warbler (idstar) will not throw an error (and shouldn't); however, warbler (idstar) (3) will throw an error that identifies 3 :: Number as an invalid first parameter for idstar. Also, warbler (3) will throw an error since 3 :: Number is not a valid first parameter for wabler itself.

This behavior also holds for functions of concrete types. For example, let concatNumber :: Number -> String -> String, then warbler (concatNumber) will not throw an error (although the type information is actionable for a throw); however warbler (concatNumber) (3) will throw an error identifying 3 :: Number as an invalid second parameter for concatNumber.

The Aviary

See the early-birds aviary.