<commit_before># typish

Yet another typewriter simulator. This one supports `span`s though for syntax highlighting.<br>
**[Demo →](http://ricostacruz.com/typish)**

![](https://github.com/rstacruz/typish/blob/gh-pages/screencast.gif)

```js
var typish = require('typish');

function repeat() {
  typish('#container')
    .type('hello stranger')
    .del(8)
    .type('you. ')
    .type('continue', '<a href="next.html">')
    .wait(50)
    .then(repeat)
}

repeat();
```

[![Status](http://img.shields.io/travis/rstacruz/typish/master.svg)](https://travis-ci.org/rstacruz/typish "See test builds")
[![npm version](http://img.shields.io/npm/v/typish.svg)](https://npmjs.org/package/typish "View this project on npm")

## API cheatsheet

```js
typish(element)
  .speed(50)         // sets base speed in milliseconds
  .type("hi")        // types something letter by letter
  .type("hi", "red") // types, with classname set to 'red'
  .type("hi", "<b>") // types, uses a custom tag
  .type("hi", 0)     // types immediately
  .del()             // delete 1 character
  .del(4)            // delete 4 characters
  .wait()            // pauses for a while
  .wait(10)          // pauses (10x longer)
  .clear()           // clears everything
  .clear(0)          // clears everything immediately (speed is 0)
  .then(function)    // executes something asynchronously
```

<!-- include: index.js -->

## typish()
> `typish(element)`

Starts typish. `element` may be a DOM element, selector, or a jQuery
object. This returns a `typish` object that you can run methods on.

```js
typish('#container')
typish(el)
```

### type()
> `type(text, [element, speed])`

Types some text. If `element` is given, it'll start a new span.
You can also give a different `speed` to make it faster or slower.

```js
typish(el)
  .type('hello')
  .type('hello', 'keyword')
  .type('hello', 10)
  .type('hello', 'keyword', 10)
```

When a name is passed to the `element` parameter, it'll be used
as a class name for a `<span>`.

```js
typish(el)
  .type('Jack', 'name')

<div id='box'><span class='name'>Jack</span></div>
```

Each `.type()` call creates a new span element.

```js
typish(el)
  .type('Jack ', 'name')
  .type('Sparrow', 'last')

<div id='box'>
  <span class='name'>Jack </span>
  <span class='last'>Sparrow</span>
</div>
```

The parameter `element` can also be an HTML tag.

```js
typish('#box')
  .type('download me', '<a href="download.html">')

<div id='box'>
  <a href="download.html">download me</a>
</div>
```

### del()
> `del([count, speed])`

Deletes characters. if `count` is given, it'll delete that many
characters.  If `speed` is given, that's the speed it'll run on.

```js
typish('.box')
  .type('hello John')
  .del(4)
  .type('Sherlock')
```

### wait()
> `wait([speed])`

Waits a while. You may give an optional `speed` argument.

```js
typish(el)
  .type('hello')
  .wait()
  .type('there')
```

### clear()
> `clear([speed])`

Clears the entire thing one letter at a time. To clear everything
instantly, use `.clear(0)`.

```js
typish('.box')
  .type('hello.')
  .clear()
```

### then()
> `then(function)`

Executes a `function` asynchronously.

```js
typish('#box')
  .type('hello')
  .then(popupSomething)
  .wait()
  .type('there')
  .then(popupSomethingAgain)
```

### speed()
> `speed(ms)`

Sets the base speed. All `speed` arguments will be multiplied by this
number.

```js
typish(el)
  .speed(50)
  .type('hello')
```

### queue()
> `queue(fn(next))`

Queues a command for execution. The function `fn` will be invoked, where
the `next` parameter should be ran to move onto the next thing on queue.

```js
typish(el)
  queue(function (next) {
    this.typeSync('hi');
    setTimeout(next, 100);
  })
```

### defer()
> `defer(next, [speed])`

Waits then runs `next`. Useful inside queue().

```js
typish(el)
  .queue(function (next) {
    //dosomething
    this.defer(next);
  })
```<commit_msg>dot missing<commit_after># typish

Yet another typewriter simulator. This one supports `span`s though for syntax highlighting.<br>
**[Demo →](http://ricostacruz.com/typish)**

![](https://github.com/rstacruz/typish/blob/gh-pages/screencast.gif)

```js
var typish = require('typish');

function repeat() {
  typish('#container')
    .type('hello stranger')
    .del(8)
    .type('you. ')
    .type('continue', '<a href="next.html">')
    .wait(50)
    .then(repeat)
}

repeat();
```

[![Status](http://img.shields.io/travis/rstacruz/typish/master.svg)](https://travis-ci.org/rstacruz/typish "See test builds")
[![npm version](http://img.shields.io/npm/v/typish.svg)](https://npmjs.org/package/typish "View this project on npm")

## API cheatsheet

```js
typish(element)
  .speed(50)         // sets base speed in milliseconds
  .type("hi")        // types something letter by letter
  .type("hi", "red") // types, with classname set to 'red'
  .type("hi", "<b>") // types, uses a custom tag
  .type("hi", 0)     // types immediately
  .del()             // delete 1 character
  .del(4)            // delete 4 characters
  .wait()            // pauses for a while
  .wait(10)          // pauses (10x longer)
  .clear()           // clears everything
  .clear(0)          // clears everything immediately (speed is 0)
  .then(function)    // executes something asynchronously
```

<!-- include: index.js -->

## typish()
> `typish(element)`

Starts typish. `element` may be a DOM element, selector, or a jQuery
object. This returns a `typish` object that you can run methods on.

```js
typish('#container')
typish(el)
```

### type()
> `type(text, [element, speed])`

Types some text. If `element` is given, it'll start a new span.
You can also give a different `speed` to make it faster or slower.

```js
typish(el)
  .type('hello')
  .type('hello', 'keyword')
  .type('hello', 10)
  .type('hello', 'keyword', 10)
```

When a name is passed to the `element` parameter, it'll be used
as a class name for a `<span>`.

```js
typish(el)
  .type('Jack', 'name')

<div id='box'><span class='name'>Jack</span></div>
```

Each `.type()` call creates a new span element.

```js
typish(el)
  .type('Jack ', 'name')
  .type('Sparrow', 'last')

<div id='box'>
  <span class='name'>Jack </span>
  <span class='last'>Sparrow</span>
</div>
```

The parameter `element` can also be an HTML tag.

```js
typish('#box')
  .type('download me', '<a href="download.html">')

<div id='box'>
  <a href="download.html">download me</a>
</div>
```

### del()
> `del([count, speed])`

Deletes characters. if `count` is given, it'll delete that many
characters.  If `speed` is given, that's the speed it'll run on.

```js
typish('.box')
  .type('hello John')
  .del(4)
  .type('Sherlock')
```

### wait()
> `wait([speed])`

Waits a while. You may give an optional `speed` argument.

```js
typish(el)
  .type('hello')
  .wait()
  .type('there')
```

### clear()
> `clear([speed])`

Clears the entire thing one letter at a time. To clear everything
instantly, use `.clear(0)`.

```js
typish('.box')
  .type('hello.')
  .clear()
```

### then()
> `then(function)`

Executes a `function` asynchronously.

```js
typish('#box')
  .type('hello')
  .then(popupSomething)
  .wait()
  .type('there')
  .then(popupSomethingAgain)
```

### speed()
> `speed(ms)`

Sets the base speed. All `speed` arguments will be multiplied by this
number.

```js
typish(el)
  .speed(50)
  .type('hello')
```

### queue()
> `queue(fn(next))`

Queues a command for execution. The function `fn` will be invoked, where
the `next` parameter should be ran to move onto the next thing on queue.

```js
typish(el)
  .queue(function (next) {
    this.typeSync('hi');
    setTimeout(next, 100);
  })
```

### defer()
> `defer(next, [speed])`

Waits then runs `next`. Useful inside queue().

```js
typish(el)
  .queue(function (next) {
    //dosomething
    this.defer(next);
  })
```
{'fraction_non_alphanumeric': 0.1962712297280041, 'fraction_numerical': 0.006640275826842038, 'mean_word_length': 3.493402180149168, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 61, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3326981', 'n_tokens_mistral': 2909, 'n_tokens_neox': 2746, 'n_words': 803}