Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ideyuta/ghost-writer

:ghost: Ghost Writer outputs the sentence like typewriter
https://github.com/ideyuta/ghost-writer

Last synced: 8 days ago
JSON representation

:ghost: Ghost Writer outputs the sentence like typewriter

Awesome Lists containing this project

README

        



Ghost Writer


Ghost Writer outputs the sentence like typewriter.





|
Installation |
Usage |
Advanced Use |
Types |
License |
Demo → |





## Installation

```
npm install ghost-writer
```

## Usage

#### Japanese Typewriting

![Demo - Ghostruct](./demo-ghostruct.gif)

```js
import ghostWriter from 'ghost-writer';

const struct = [{
i: 'anoiーhatoーvono',
o: 'あのイーハトーヴォの'
}, {
i: 'sukitoottakaze',
o: 'すきとおった風、'
}, {
i: 'natsudemo',
o: '夏でも'
}, {
i: 'sokoni',
o: '底に'
}, {
i: 'tsumetasawomotsu',
o: '冷たさをもつ'
}, {
i: 'aoisora',
o: '青いそら'
}];
const writer = ghostWriter(struct);

let text = '';
writer(t => text = t);
```

#### Simple Typewriting

![Demo - Simple Text](./demo-simple-text.gif)

```js
import ghostWriter from 'ghost-writer';

const writer = ghostWriter('あのイーハトーヴォのすきとおった風');

let text = '';
writer(t => text = t);
```

![Demo - English](./demo-en.gif)

```js
import ghostWriter from 'ghost-writer';

const struct = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
const writer = ghostWriter(struct);

let text = '';
writer(t => text = t, 50);
```

## Advanced Use

```js
import {ghost} from 'ghost-writer';

ghost([{i: 'anoiーhatoーvono', o: 'あのイーハトーヴォの'}]);

/* return
[
'あ',
'あn',
'あの',
'あのい',
'あのいー',
'あのいーh',
'あのいーは',
'あのいーはt',
'あのいーはと',
'あのいーはとー',
'あのいーはとーv',
'あのいーはとーゔぉ',
'あのいーはとーゔぉn',
'あのいーはとーゔぉの',
'あのイーハトーヴォの'
]
*/
```

## Types

```js
ghostWriter: (struct: RawGhostruct|string) => writer
```

```js
writer: (
callbackFunction: (string) => void,
msec: number
) => string
```

```js
ghost: (struct: RawGhostruct|string) => string[]
```

```js
RawGhostruct: [{
i: RawGhostruct | string,
o: string
}]
```

## License

[MIT](https://github.com/ideyuta/ghost-writer/blob/master/LICENSE)