1.0.2 • Published 7 years ago

alternate v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
7 years ago

alternate Build Status

Install

npm install --save alternate

Usage

Example 1

const alternate = require('alternate');
const a = new alternate(true, false);

// .next()
a.next() // returns true
a.next() // returns false
a.next() // returns true
a.next() // returns false

// .peek()
a.peek() // returns true
a.peek() // returns true

a.next() // returns true

a.peek() // returns false
a.peek() // returns false

Example 2

const alternate = require('alternate');
const a = new alternate('one', 'two', 3, 4);

a.next() // returns 'one'
a.next() // returns 'two'
a.next() // returns 3
a.next() // returns 4
a.next() // returns 'one'

Usage with React

import React from 'react';
import Alternate from 'alternate';

const rows = ['row1', 'row2', 'row3', 'row4'];

const Table = () => {
  const alternateRowColor = new Alternate('red', 'yellow');

  return (
    <div>
      {rows.map(row => (
        <div style={{ backgroundColor: alternateRowColor.next() }}>
          {row}
        </div>
      ))}
    </div>
  );
};

export default Table;
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago