Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rangegen

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rangegen

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

  • 0.2.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

Keywords

FAQs

Package last updated on 29 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc