fake-history-fns

fake-history functions.

Usage no npm install needed!

<script type="module">
  import fakeHistoryFns from 'https://cdn.skypack.dev/fake-history-fns';
</script>

README

fake-history-fns

fake-history functions.

Installation

$ npm install fake-history-fns

Usage

import assert from 'assert';
import {
  back,
  create,
  current,
  currentState,
  length,
  next,
  nextState,
  previous,
  previousState,
  pushState,
  state
} from 'fake-history-fns';

const p0 = create();
const p1 = pushState(p0, 1, '1', '/1');
const p2 = pushState(p1, 2, '2', '/2');
const p3 = pushState(p2, 3, '3', '/3');
const b1 = back(p0);

assert(length(b1) === 3);
assert(state(b1) === 2);

assert(current(b1) === '/2');
assert(currentState(b1) === 2);
assert(next(b1) === '/3');
assert(nextState(b1) === 3);
assert(previous(b1) === '/1');
assert(previousState(b1) === 1);

Related Project

Development

$ yarn
$ npm run watch

Badges

Travis CI

License

MIT

Author

bouzuya <m@bouzuya.net> (http://bouzuya.net)