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

sanctuary-descending

v2.1.0

Published

Fantasy Land -compliant Descending type

Downloads

183

Readme

sanctuary-descending

Descending is a simple container type: a value of type Descending a always contains exactly one value, of type a.

Values of type Descending a sort in the reverse order of values of type a.

Descending differs from Identity only in the behaviour of its fantasy-land/lte method.

> S.sort ([5, 1, 2])
[1, 2, 5]

> S.sort ([Descending (5), Descending (1), Descending (2)])
[Descending (5), Descending (2), Descending (1)]

> S.sortBy (Descending) ([5, 1, 2])
[5, 2, 1]

Descending a satisfies the following Fantasy Land specifications:

> const Useless = require ('sanctuary-useless')

> const isTypeClass = x =>
.   type (x) === 'sanctuary-type-classes/TypeClass@1'

> S.map (k => k + ' '.repeat (16 - k.length) +
.             (Z[k].test (Descending (Useless)) ? '\u2705   ' :
.              Z[k].test (Descending (['foo'])) ? '\u2705 * ' :
.              /* otherwise */                    '\u274C   '))
.       (S.keys (S.unchecked.filter (isTypeClass) (Z)))
[ 'Setoid          ✅ * ',  // if ‘a’ satisfies Setoid
. 'Ord             ✅ * ',  // if ‘a’ satisfies Ord
. 'Semigroupoid    ❌   ',
. 'Category        ❌   ',
. 'Semigroup       ✅ * ',  // if ‘a’ satisfies Semigroup
. 'Monoid          ❌   ',
. 'Group           ❌   ',
. 'Filterable      ❌   ',
. 'Functor         ✅   ',
. 'Bifunctor       ❌   ',
. 'Profunctor      ❌   ',
. 'Apply           ✅   ',
. 'Applicative     ✅   ',
. 'Chain           ✅   ',
. 'ChainRec        ✅   ',
. 'Monad           ✅   ',
. 'Alt             ❌   ',
. 'Plus            ❌   ',
. 'Alternative     ❌   ',
. 'Foldable        ✅   ',
. 'Traversable     ✅   ',
. 'Extend          ✅   ',
. 'Comonad         ✅   ',
. 'Contravariant   ❌   ' ]

Descending :: a -⁠> Descending a

Descending's sole data constructor. Additionally, it serves as the Descending type representative.

> Descending (42)
Descending (42)

Descending.fantasy-land/of :: a -⁠> Descending a

of (Descending) (x) is equivalent to Descending (x).

> S.of (Descending) (42)
Descending (42)

Descending.fantasy-land/chainRec :: ((a -⁠> c, b -⁠> c, a) -⁠> Descending c, a) -⁠> Descending b

> Z.chainRec (
.   Descending,
.   (next, done, x) => Descending (x >= 0 ? done (x * x) : next (x + 1)),
.   8
. )
Descending (64)

> Z.chainRec (
.   Descending,
.   (next, done, x) => Descending (x >= 0 ? done (x * x) : next (x + 1)),
.   -8
. )
Descending (0)

Descending#@@show :: Showable a => Descending a ~> () -⁠> String

show (Descending (x)) is equivalent to 'Descending (' + show (x) + ')'.

> show (Descending (['foo', 'bar', 'baz']))
'Descending (["foo", "bar", "baz"])'

Descending#fantasy-land/equals :: Setoid a => Descending a ~> Descending a -⁠> Boolean

Descending (x) is equal to Descending (y) iff x is equal to y according to Z.equals.

> S.equals (Descending ([1, 2, 3])) (Descending ([1, 2, 3]))
true

> S.equals (Descending ([1, 2, 3])) (Descending ([3, 2, 1]))
false

Descending#fantasy-land/lte :: Ord a => Descending a ~> Descending a -⁠> Boolean

Descending (x) is less than or equal to Descending (y) iff y is less than or equal to x according to Z.lte (note the transposition of x and y).

> S.sort ([Descending (5), Descending (1), Descending (2)])
[Descending (5), Descending (2), Descending (1)]

Descending#fantasy-land/concat :: Semigroup a => Descending a ~> Descending a -⁠> Descending a

concat (Descending (x)) (Descending (y)) is equivalent to Descending (concat (x) (y)).

> S.concat (Descending ([1, 2, 3])) (Descending ([4, 5, 6]))
Descending ([1, 2, 3, 4, 5, 6])

Descending#fantasy-land/map :: Descending a ~> (a -⁠> b) -⁠> Descending b

map (f) (Descending (x)) is equivalent to Descending (f (x)).

> S.map (Math.sqrt) (Descending (64))
Descending (8)

Descending#fantasy-land/ap :: Descending a ~> Descending (a -⁠> b) -⁠> Descending b

ap (Descending (f)) (Descending (x)) is equivalent to Descending (f (x)).

> S.ap (Descending (Math.sqrt)) (Descending (64))
Descending (8)

Descending#fantasy-land/chain :: Descending a ~> (a -⁠> Descending b) -⁠> Descending b

chain (f) (Descending (x)) is equivalent to f (x).

> S.chain (n => Descending (n + 1)) (Descending (99))
Descending (100)

Descending#fantasy-land/reduce :: Descending a ~> ((b, a) -⁠> b, b) -⁠> b

reduce (f) (x) (Descending (y)) is equivalent to f (x) (y).

> S.reduce (S.concat) ([1, 2, 3]) (Descending ([4, 5, 6]))
[1, 2, 3, 4, 5, 6]

Descending#fantasy-land/traverse :: Applicative f => Descending a ~> (TypeRep f, a -⁠> f b) -⁠> f (Descending b)

traverse (_) (f) (Descending (x)) is equivalent to map (Descending) (f (x)).

> S.traverse (Array) (x => [x + 1, x + 2, x + 3]) (Descending (100))
[Descending (101), Descending (102), Descending (103)]

Descending#fantasy-land/extend :: Descending a ~> (Descending a -⁠> b) -⁠> Descending b

extend (f) (Descending (x)) is equivalent to Descending (f (Descending (x))).

> S.extend (S.reduce (S.add) (1)) (Descending (99))
Descending (100)

Descending#fantasy-land/extract :: Descending a ~> () -⁠> a

extract (Descending (x)) is equivalent to x.

> S.extract (Descending (42))
42