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

super-number

v1.0.2

Published

extra Integers and Numbers methods

Downloads

52

Readme

super-number

NPM version Build Status

This is a tool that provides extra Integer or Number methods. It allows to perform some actions more easily with Intseger or only Number types which makes it simpler, more flexible, more practical and less effort.

Installation

# Using npm
npm install --save super-number

Usage

const Ints = require('super-number');

// Syntax : Ints(array_of_integers).findNearestInteger(integer)
Ints([-5, -2, 0, 1, 5]).findNearestInteger(0); // expected output: 1
Ints([-5, -2, 0, 1, 5]).findNearestInteger(1); // expected output: 0
Ints([-5, -2, 0, 1, 5]).findNearestInteger(5); // expected output: 1
Ints([0, 1, 2, 5, 6]).findNearestInteger(5); // expected output: 6
Ints([-1, 0, 1]).findNearestInteger(0); // expected output: 1
Ints([-5, -2, 0, 1, 5]).findNearestInteger(-2); // expected output: 0
Ints([-5, -2, 0, 1, 5]).findNearestInteger(-5); // expected output: -2
Ints([-5, -4, -2, 0]).findNearestInteger(-2); // expected output: 0

// Even numbers
Ints(10).getLessEvenNumbers(); // expected output: [2, 4, 6, 8]
Ints(10).getLessOrEqualEvenNumbers(); // expected output: [2, 4, 6, 8, 10]
Ints([1, -2, 3, 4, -6, 7, 11]).getEvenNumbers(); // expected output: [-2, 4, -6]
Ints([0, 3, -4, 7, 9, 10, 13, 20]).getEvenNumbersLessThan(20); // expected output: [0, -4, 10]
Ints([0, 3, -4, 7, 9, -10, 13, 20]).getEvenNumbersLessThan(-4); // expected output: [-10]
Ints([0, 3, 4, 7, 9, -10, 13, 20]).getEvenNumbersLessOrEqualThan(20); // expected output: [0, 4, -10, 20]
Ints([0, -3, 4, -7, 9, -10, 13, -20]).getEvenNumbersLessOrEqualThan(-7); // expected output: [-10, -20]
Ints([0, -2, -4, 7, 9, 10, 13, 20]).getEvenNumbersGreaterThan(4); // expected output: [10, 20]
Ints([0, -2, -4, 7, 9, 10, 13, 20]).getEvenNumbersGreaterThan(-4); // expected output: [0, -2, 10, 20]
Ints([0, -2, -4, 4, 7, 9, 10, 13, 20]).getEvenNumbersGreaterOrEqualThan(4); // expected output: [4, 10, 20]
Ints([0, -2, -4, 7, 9, 10, 13, 20]).getEvenNumbersGreaterOrEqualThan(-4); // expected output: [0, -2, -4, 10, 20]
Ints(2).isEvenNumber(); // expected output: true
Ints(3).isEvenNumber(); // expected output: false
Ints(-2).isEvenNumber(); // expected output: true
Ints(-3).isEvenNumber(); // expected output: false

// Odd numbers
Ints(11).getLessOddNumbers(); // expected output: [1, 3, 5, 7, 9]
Ints(11).getLessOrEqualOddNumbers(); // expected output: [1, 3, 5, 7, 9, 11]
Ints([0, 1, 2, -3, 4, 6, 7, 11]).getOddNumbers(); // expected output: [1, -3, 7, 11]
Ints([0, 1, 2, -3, 4, 6, 7, 11]).getOddNumbersLessThan(11); // expected output: [1, -3, 7]
Ints([0, 1, -2, -3, -5, 6, 7, 11]).getOddNumbersLessThan(-3); // expected output: [-5]
Ints([0, 1, 2, -3, 4, 6, 7, 11]).getOddNumbersLessOrEqualThan(11); // expected output: [1, -3, 7, 11]
Ints([0, 1, -2, -3, -5, 6, 7, 11]).getOddNumbersLessOrEqualThan(-3); // expected output: [-3, -5]
Ints([0, 1, 2, -3, 4, 6, 7, 11]).getOddNumbersGreaterThan(3); // expected output: [7, 11]
Ints([0, 1, -2, -3, 4, 6, 7, 11]).getOddNumbersGreaterThan(-3); // expected output: [1, 7, 11]
Ints([0, 1, -2, 3, 4, 6, 7, 11]).getOddNumbersGreaterOrEqualThan(3); // expected output: [3, 7, 11]
Ints([0, 1, -2, -3, -5, 6, 7, 11]).getOddNumbersGreaterOrEqualThan(-3); // expected output: [1, -3, 7, 11]
Ints(3).isOddNumber(); // expected output: true
Ints(2).isOddNumber(); // expected output: false
Ints(-3).isOddNumber(); // expected output: true
Ints(-2).isOddNumber(); // expected output: false

// Some others useful operations
Ints([-5, -2, 0, 1, 5]).getPositivesNumbers(); // expected output: [1, 5]
Ints([-5, -2, 0, 1, 5]).getNegativesNumbers(); // expected output: [-5, -2]
Ints([3, -2, 4, 5, 10, 7, 8, 9, 12, 20]).getDivisiblesOf(10); // expected output: [-2, 5, 10]
Ints([3, 2, 4, 5, -10, 7, 8, 9, 12, 20]).getMultiplesOf(10); // expected output: [-10, 20]
Ints([3, 2, 4, 5, 10, 7, 8, 9, 12, -20]).getGreatersThan(10); // expected output: [12]
Ints([3, 2, 4, 5, 10, 7, 8, 9, 12, -20]).getGreatersThan(-10); // expected output: [3, 2, 4, 5, 10, 7, 8, 9, 12]
Ints([3, 2, 4, 5, 10, 7, 8, 9, 12, -20]).getLessersThan(10); // expected output: [3, 2, 4, 5, 7, 8, 9, -20]
Ints([3, 2, 4, 5, 10, 7, 8, 9, 12, -20]).getLessersThan(-10); // expected output: [-20]

// Prime numbers
Ints(11).getLessPrimeNumbers(); // expected output: [2, 3, 5, 7]
Ints(11).getLessOrEqualPrimeNumbers(); // expected output: [2, 3, 5, 7, 11]
Ints([2, 1, 3, 7, 10, 4, 20, 6, 11, 8, 23]).getPrimeNumbers(); // expected output: [2, 3, 7, 11, 23]
Ints([2, 1, 3, 7, 10, 4, 20, 6, 11, 8, 23]).getPrimeNumbersLessThan(23); // expected output: [2, 3, 7, 11]
Ints([2, 1, 3, 7, 10, 4, 20, 6, 11, 8, 23]).getPrimeNumbersLessOrEqualThan(23); // expected output: [2, 3, 7, 11, 23]
Ints([2, 1, 3, 7, 10, 4, 20, 6, 11, 8, 23]).getPrimeNumbersGreaterThan(7); // expected output: [11, 23]
Ints([2, 1, 3, 7, 10, 4, 20, 6, 11, 8, 23]).getPrimeNumbersGreaterOrEqualThan(7); // expected output: [7, 11, 23]
Ints(2).isPrimeNumber(); // expected output: true
Ints(4).isPrimeNumber(); // expected output: false