This project follows semantic versioning.
The ES6 version of mimic is hosted on NPM as 'mimic-it'.
There is no ES5 version at the moment - please just use babel or similar in your toolchain, with regenerator, if you need to run this on an older environment.
npm i -S mimic-it
or
yarn add mimic-it
// create a replayable iterator
const it = mimic(gen)
// you can specifying first steps
const it = mimic(gen, {
prevCalls: [{ cmd: 'next', args: [2, 42] }, { cmd: 'throw', args: [new Error('oops')] }]
})
// ...and / or specify initial args passed to the generator
const it = mimic(gen, {
initArgs: [42, 'secondArg']
})
// do stuff...
it.next()
// ... etc ...
// get a replayed iterator
const it2 = it.mimic()
// get a replayed iterator, specifying how many steps to replay
const it3 = it.mimic({ steps: 2 })