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

rangegen

v0.2.8

Published

Generate a range between two numbers or letters. Examples: 1-100, a-z, A-Z, a-zz or even A-ZZZZZ.

Downloads

15

Readme

RangeGen

Install: npm install rangegen

Information:

Generate a range between two numbers or letters. Examples: 1-100, a-z, A-Z, a-zz or even A-ZZZZZ.

Online example: http://louist.github.io/RangeGen/example.html

View more examples on GitHub.

Usage:

*WARNING* Running range on a big letter gap causes MANY loops!
          For instance, a-zzzzz creates an array with 12,356,630
          indexes and does 73,645,526 while and for loops!

-- Array generator (See "examples.js" for usage) --
var array = RangeGen(<from>,<to>,[<step>[,<exceptions>[,<CB/filter>]]]);

    From         - The letter or number to start the range at. (Number, Float, Letters)
    To           - The letter or number to end on/near. (Number, Float, Letters)
    Step*        - The amount to increment or decrement by. Default, 1. (Boolean, Number, Float)
    Exceptions*  - Throw error messages. Default, return an empty array. (Boolean)
    CB/filter*   - Use a callback or filter results. (see example4.js)
                 * Optional.

-- Check to see if a number or letter is in a range. (Case sensitive, "AB" is not in "a..az". See "examples4.js" for usage) --
RangeGen.inRange(<str>,<from>,<to>[,<step>[,<exceptions>[,<callback>]]]);

    Str          - The number(s) or letter(s) to validate. (Number, Float, Letters)
    From         - The letter or number to start the range at. (Number, Float, Letters)
    To           - The letter or number to end on/near. (Number, Float, Letters)
    Step*        - The amount to increment or decrement by. Default, 1. (Boolean, Number, Float)
    Exceptions*  - Throw error messages. Default, return false. (Boolean)
    Callback*    - Use a callback instead of return.
                 * Optional.

-- Get the Nth value in a given range. (See "examples4.js" for usage) --
RangeGen.byIndex(<num>,<from>,<to>,[<step>[,<exceptions>[,<callback>]]]);

    Num          - The index number within the range. (Number)
    From         - The letter or number to start the range at. (Number, Float, Letters)
    To           - The letter or number to end on/near. (Number, Float, Letters)
    Step*        - The amount to increment or decrement by. Default, 1. (Boolean, Number, Float)
    Exceptions*  - Throw error messages. Default, return false. (Boolean)
    Callback*    - Use a callback instead of return.
                 * Optional.

-- Get the index by value in a given range. (See "examples4.js" for usage) --
RangeGen.byValue(<str>,<from>,<to>,[<step>[,<exceptions>[,<callback>]]]);

    Str          - The value within the range. (Number, Float, Letters)
    From         - The letter or number to start the range at. (Number, Float, Letters)
    To           - The letter or number to end on/near. (Number, Float, Letters)
    Step*        - The amount to increment or decrement by. Default, 1. (Boolean, Number, Float)
    Exceptions*  - Throw error messages. Default, return false. (Boolean)
    Callback*    - Use a callback instead of return.
                 * Optional.

-- Inject "range()" into the String prototype. (See "examples4.js" for usage) --
RangeGen.addPrototype();
RangeGen.addPro();

    Usage: "FROM..TO".range([<step>[,<exceptions>[,<callback>]]]);

    From         - The letter or number to start the range at. (Number, Float, Letters)
    To           - The letter or number to end on/near. (Number, Float, Letters)
    Step*        - The amount to increment or decrement by. Default, 1. (Boolean, Number, Float)
    Exceptions*  - Throw error messages. Default, return false. (Boolean)
    Callback*    - Use a callback instead of return.
                 * Optional.

-- Readable stream. (Node.js ONLY, See examples5.js for usage) --
var stream = RangeGen.createReadStream(<from>,<to>[,<step>]);
             RangeGen.CRS(<from>,<to>[,<step>]);

    From         - The letter or number to start the range at. (Number, Float, Letters)
    To           - The letter or number to end on/near. (Number, Float, Letters)
    Step*        - The amount to increment or decrement by. Default, 1. (Boolean, Number, Float)

    NOTE: If you use this outside of Node.js it will throw a "NodeOnly" error!
          Stream API: http://nodejs.org/api/stream.html#stream_class_stream_readable

-- Iterators. (See "examples2.js" for usage) --
var iterator = RangeGen.iterator(<from>,<to>[,<step>[,<exceptions>]]);
               RangeGen.iter(<from>,<to>[,<step>[,<exceptions>]]);

    hasNext()    - Returns true if the iteration has more elements.
    next()       - Returns the next element in the iteration, or false if `exceptions` is not set.
                   Otherwise throws a `NoSuchElement` exception.
    length       - The total number of iterations.
    left         - The number of iterations left.