Skip to content

ideyuta/ghost-writer

Repository files navigation


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

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

import ghostWriter from 'ghost-writer';

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

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

Demo - English

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

import {ghost} from 'ghost-writer';

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

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

Types

ghostWriter: (struct: RawGhostruct|string) => writer
writer: (
  callbackFunction: (string) => void,
  msec: number
) => string
ghost: (struct: RawGhostruct|string) => string[]
RawGhostruct: [{
  i: RawGhostruct | string,
  o: string
}]

License

MIT

About

👻 Ghost Writer outputs the sentence like typewriter

Resources

License

Stars

Watchers

Forks

Packages

No packages published