Skip to content

gouegd/mimic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm

Versioning

This project follows semantic versioning.

Install

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

Usage

// 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 })

About

Clone and replay an ES6 iterator

Resources

License

Stars

Watchers

Forks

Packages

No packages published