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-int

v3.0.0

Published

A collection of functions which operate on 32-bit signed integers

Downloads

13

Readme

sanctuary-int

A collection of functions which operate on 32-bit signed integers.

API

Int :: Type

The Int type represents integers in the range [-2^31 .. 2^31).

NonZeroInt :: Type

The NonZeroInt type represents non-zero integers in the range [-2^31 .. 2^31).

add :: Int -⁠> Int -⁠> Int

Returns the sum of its two arguments.

> add (1) (2)
3

sub :: Int -⁠> Int -⁠> Int

Returns the result of subtracting its first argument from its second argument.

> sub (1) (100)
99

mul :: Int -⁠> Int -⁠> Int

Returns the product of its two arguments.

> mul (6) (7)
42

quot :: NonZeroInt -⁠> Int -⁠> Int

Returns the result of dividing its second argument by its first argument, truncating towards zero.

Throws if the divisor is zero.

See also div.

> quot (5) (42)
8

> quot (-5) (42)
-8

> quot (5) (-42)
-8

> quot (-5) (-42)
8

rem :: NonZeroInt -⁠> Int -⁠> Int

Integer remainder, satisfying:

quot (y) (x) * y + rem (y) (x) === x

Throws if the divisor is zero.

See also mod.

> rem (5) (42)
2

> rem (-5) (42)
2

> rem (5) (-42)
-2

> rem (-5) (-42)
-2

div :: NonZeroInt -⁠> Int -⁠> Int

Returns the result of dividing its second argument by its first argument, truncating towards negative infinity.

Throws if the divisor is zero.

See also quot.

> div (5) (42)
8

> div (-5) (42)
-9

> div (5) (-42)
-9

> div (-5) (-42)
8

mod :: NonZeroInt -⁠> Int -⁠> Int

Integer modulus, satisfying:

div (y) (x) * y + mod (y) (x) === x

Throws if the divisor is zero.

See also rem.

> mod (5) (42)
2

> mod (-5) (42)
-3

> mod (5) (-42)
3

> mod (-5) (-42)
-2

and :: Int -⁠> Int -⁠> Int

Bitwise AND. Returns an Int with a one at each bit position at which both arguments have a one.

> and (0b1100) (0b1010)
0b1000

or :: Int -⁠> Int -⁠> Int

Bitwise OR. Returns an Int with a one at each bit position at which at least one argument has a one.

> or (0b1100) (0b1010)
0b1110

xor :: Int -⁠> Int -⁠> Int

Bitwise XOR. Returns an Int with a one at each bit position at which exactly one argument has a one.

> xor (0b1100) (0b1010)
0b0110

not :: Int -⁠> Int

Bitwise NOT, satisfying:

not (x) === -(x + 1)
> not (42)
-43

even :: Int -⁠> Boolean

Returns true if its argument is even; false if it is odd.

> even (42)
true

odd :: Int -⁠> Boolean

Returns true if its argument is odd; false if it is even.

> odd (42)
false