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

@justinc/sequence

v1.0.2

Published

Similar to Ramda's sequence (as a micro lib)

Downloads

2

Readme

sequence Build status NPM version Js Standard Style

This package exports a function similar to Ramda's sequence function.

Note that it is strictly curried (see demo usage below).

Known issue

For this package to work, the Applicative (see below) ADT value you use must have the following sematics for the .ap method: fnApplicative.ap(valueApplicative). This is Fantasy Land pre-v1.0.0 semantics.

Folktale 2's Applicative ADTs have this behaviour for their .ap method (and support v1.0.0+ semantics of .ap via valueApplicative['fantasy-land/ap'](fnApplicative)).

sequence uses the .ap method. This means sequence will work with Folktale 2 ADTs (as well as Folktale 1 mico-libs like data.maybe etc…).

In the future, it is likely that a major version update of this package will take a config Object as the first curried function which can configure which sematics of .ap to use. Apart from this, it will be possible to add to this config enabling/disabling of "basic type checking" to make sure we have the required methods that make up an "Applicative". This "basic type checking" is on by force in version ^1.0.0 - which could get expensive for large iterables.

Install

npm i @justinc/sequence

Demo

(See tests for more example usage). Also, there's a REPL file you can run with node repl.js.

const Maybe = require('folktale/data/maybe')
const sequence = require('@justinc/sequence')

const { Just, Nothing } = Maybe

// "strictly curried" means you cannot use short-hands like `sequence(Maybe.of, [Just(1), Just(2), Just(3)])`.
// That's extra functionality provided by Ramda (not provided here).
sequence(Maybe.of)([Just(1), Just(2), Just(3)]) // ==> Just([1, 2, 3])

Functions

Typedefs

sequence([applicativeReturningFn], [iterable]) ⇒ Applicative.<Array.<T>>

This function is curried.

The applicativeReturningFn is expected to return a value of type Applicative. Also, it is expected that the Applicative returned by applicativeReturningFn is of the same kind as the Applicatives in the given iterable (2nd curried param). e.g. if applicativeReturningFn returns a Maybe, iterable is expected to have Maybe values.

Just like the Ramda function with the same name, this function:

"Transforms a Traversable of Applicative into an Applicative of Traversable."

e.g. if applicativeReturningFn returns a Maybe, and iterable is made up of Maybe T values, then this function returns a Maybe<Array<T>> where T is a type like String etc…

Kind: global function
See: Applicative

| Param | Type | Description | | --- | --- | --- | | [applicativeReturningFn] | function | A function that returns an Applicative | | [iterable] | Iterable.<Applicative> | An iterable of Applicatives |

Applicative : Object

This is a value as specified in the Fantasy Land spec for Applicative. This means that a value of this type needs to have of, ap and map methods with the properties specified in the Fantasy Land spec.

Kind: global typedef