increment-map

1.0.0 • Public • Published

increment-map

Build Status NPM

Create a map with incrementing values

Motivation

What is the point of 'overcomplicating' a for loop?

In some scenarios (e.g. React Components), it's not that straight forward to loop from a to b. This methods implements a simple for-loop in a more functional way.

Usage

Vanilla JS

const incrementMap = require('increment-map');

incrementMap(0, 5, function (index) {
  console.log(index);
})

// Will output 0 1 2 3 4 5

React Example

function List() {
  return (
    <ul>
      {incrementMap(1, 3, index => <li>{`Item ${index}`}</li>)}
    </ul>
  );
}

Properties

  • From (including): From which number do you want to count?
  • To (including): To which number do you want to count?
  • mapFunction

Readme

Keywords

none

Package Sidebar

Install

npm i increment-map

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

2.48 kB

Total Files

5

Last publish

Collaborators

  • dejakob