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

power-range

v1.2.0

Published

🏋🏻 A small and powerful library for creating ranges of almost anything: numbers, letters, dates and even strings! Yay!

Downloads

12

Readme

power-range Build status

🏋🏻 A small and powerful library for creating ranges of almost anything: numbers, letters, dates and even strings! Yay!

It's morphing time!

Install

$ npm install power-range

Usage

create(from, to[, options])

Creates an array with the range between two values.

const pr = require('power-range');

// Number ranges
pr.create(0, 5);
//=> [0, 1, 2, 3, 4 ,5]

pr.create(-2, 5);
//=> [-2, -1, 0, 1 , 2, 3, 4, 5]

pr.create(100, 100);
//=> [100]

// Options
/**
 * increment: The interval between the range values
 */
pr.create(2, 10, { increment: 2 });
//=> [2, 4, 6, 8, 10]

pr.create(-2, 13, { increment: 3 });
//=> [-2, 1, 4, 7, 13]


// Date ranges
pr.create(new Date(2001, 2, 30, 4, 5, 6), new Date(2001, 3, 2, 6, 7, 8));
/**
 * => [ Fri Mar 30 2001 04:05:06 GMT-0300 (BRT),
 *      Sat Mar 31 2001 04:05:06 GMT-0300 (BRT),
 *      Sun Apr 01 2001 04:05:06 GMT-0300 (BRT),
 *      Mon Apr 02 2001 04:05:06 GMT-0300 (BRT) ]
 */

// Options
/**
 * increment: The interval between the range values
 */
pr.create(new Date(2001, 2, 30, 4, 5, 6), new Date(2001, 3, 2, 6, 7, 8), { increment: 2 });
/**
 * => [ Fri Mar 30 2001 04:05:06 GMT-0300 (BRT),
 *      Sun Apr 01 2001 04:05:06 GMT-0300 (BRT) ]
 */

/**
 * unit: The unit of time used to build the range (second, minute, hour, day, week, month)
 */
pr.create(new Date(2001, 2, 30, 4, 5, 6), new Date(2001, 6, 30, 4, 5, 6), { unit: 'month' });
/**
 * => [ Fri Mar 30 2001 04:05:06 GMT-0300 (BRT),
 *      Mon Apr 30 2001 04:05:06 GMT-0300 (BRT),
 *      Wed May 30 2001 04:05:06 GMT-0300 (BRT),
 *      Sat Jun 30 2001 04:05:06 GMT-0300 (BRT),
 *      Mon Jul 30 2001 04:05:06 GMT-0300 (BRT) ]
 */

// String ranges
pr.create('A', 'G');
//=> ['A', 'B', 'C', 'D', 'E', 'F', 'G']

pr.create('X', 'd');
//=> ['X', 'Y', 'Z', 'a', 'b', 'c', 'd']

pr.create('DA', 'DD');
//=> ['DA', 'DB', 'DC', 'DD']

pr.create('AZ', 'BA');
//=> ['AZ', 'BA']

pr.create('6', 'B');
//=> ['6', '7', '8', '9', 'A', 'B']

pr.create('6', 'b');
//=> ['6', '7', '8', '9', 'a', 'b']

pr.create('z', 'ab');
//=> ['z', 'aa', 'ab']

pr.create('ZY', 'AAB');
//=> ['ZY', 'ZZ', 'AAA', 'AAB']

pr.create('98', '002');
//=> ['98', '99', '000', '001', '002']


// Options
/**
 * numbers: Enables numbers (if one of the limit values has a number,
 *          this option is enabled automatically)
 */
pr.create('AZ', 'BA', { numbers: true });
//=> ['AZ', 'B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'BA']

/**
 * upperCaseLetters: Enables uppercase letters (if one of the limit values
 *                   has an uppercase letter, this option is enabled automatically)
 */
pr.create('6', 'b', { upperCaseLetters: true });
//=> ['6', '7', '8', '9', 'A', 'B', ..., 'X', 'Y', 'Z', 'a', 'b'])

/**
 * lowerCaseLetters: Enables lowercase letters (if one of the limit values
 *                   has a lowercase letter, this option is enabled automatically)
 */
pr.create('Z', 'AB', { lowerCaseLetters: true });
//=> ['Z', 'a', 'b', 'c', 'd', 'e', ..., 'x', 'y', 'z', 'AA', 'AB'])

/**
 * chars: Customizes the characters used to build the string range
 */
pr.create('$', '%#', { chars: '$%#' });
//=> ['$', '%', '#', '$$', '$%', '$#', '%$', '%%', '%#']

Author

Alcides Queiroz Aguiar

License

This code is free to use under the terms of the MIT License.