range-create

0.0.12 • Public • Published

Ranger

lightweight library for creating arrays of numbers

Installation:

npm install range-create --save

Use in browser

<script src="https://unpkg.com/range-create@0.0.1/dist/browser/ranger.js" ></script>

Live example on code pen

https://codepen.io/anon/pen/MRPJmO

Methods:

  • init

create array with simple string

Examples:

const  R  =  require('range-create').default.init
  
// without step (default is 1)
let  arr  =  R("10:20")
console.log(arr)
// [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
  
// with step
arr  =  R("0:20:5")
console.log(arr)
// [ 0, 5, 10, 15, 20 ]
  
// count down
arr  =  R("48:36")
console.log(arr)
// [ 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36 ]
  
// count down with step
arr  =  R("10:-10:5")
console.log(arr)
// [ 10, 5, 0, -5, -10 ]
  
// float numbers
arr  =  R("0:5:0.75")
console.log(arr)
// [ 0, 0.75, 1.5, 2.25, 3, 3.75, 4.5 ]

any question ? Ask It :)

made with ❤️ for you

/range-create/

    Package Sidebar

    Install

    npm i range-create

    Weekly Downloads

    1

    Version

    0.0.12

    License

    ISC

    Unpacked Size

    10.1 kB

    Total Files

    13

    Last publish

    Collaborators

    • mrfarhad.ir