Skip to content

[TODO] Improve the "repeat" method #35

@qodesmith

Description

@qodesmith

Look at the custom function I suggested in order to get Typer to repeat typing words from an array. While the .forEach portion seems fine, having to first call .line and then .continue seemed a bit verbose. What if we wanted to repeat certain portions of Typer, then repeat others?

In order to simplify things and have a more intuitive API I'm thinking about introducing a repeatStart method that would be used something like this:

typer('.some-class')
  .cursor({block: true})
  .line()

  // Portion 1 to repeat 3 times
  .repeatStart()
  .continue('Hip-Hop')
  .pause(2000)
  .back('all')
  .continue('Truth')
  .pause(2000)
  .back('all')
  .continue('Free Speech')
  .pause(2000)
  .back('all')
  .repeat(3)

  .line()
  // Portion 2 to repeat 3 times...
  .repeatStart()
  /* ...methods here... */
  .repeat(3)

I'm pretty sure that currently it's possible to use repeat in place of repeatStart in the example above and it would work. But that's confusing. Even if repeatStart was a wrapper around repeat, that would improve the API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions