{"id":13547251,"url":"https://github.com/yuanqing/malarkey","last_synced_at":"2025-04-06T02:08:07.175Z","repository":{"id":20031536,"uuid":"23299602","full_name":"yuanqing/malarkey","owner":"yuanqing","description":":keyboard: Simulate a typewriter effect in vanilla JavaScript.","archived":false,"fork":false,"pushed_at":"2021-01-30T07:40:51.000Z","size":203,"stargazers_count":239,"open_issues_count":3,"forks_count":17,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-29T11:55:36.653Z","etag":null,"topics":["javascript","typewriter"],"latest_commit_sha":null,"homepage":"https://codepen.io/lyuanqing/pen/oqgOMK","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuanqing.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-25T02:42:47.000Z","updated_at":"2024-07-07T14:24:17.000Z","dependencies_parsed_at":"2022-08-27T03:16:38.908Z","dependency_job_id":null,"html_url":"https://github.com/yuanqing/malarkey","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fmalarkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fmalarkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fmalarkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fmalarkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuanqing","download_url":"https://codeload.github.com/yuanqing/malarkey/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423514,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","typewriter"],"created_at":"2024-08-01T12:00:53.039Z","updated_at":"2025-04-06T02:08:07.156Z","avatar_url":"https://github.com/yuanqing.png","language":"JavaScript","funding_links":[],"categories":["🚀 A series of exquisite and compact web page cool effects","Text"],"sub_categories":["Input Effect"],"readme":"# malarkey [![npm Version](http://img.shields.io/npm/v/malarkey.svg?style=flat)](https://www.npmjs.org/package/malarkey) [![Build Status](https://img.shields.io/travis/yuanqing/malarkey.svg?branch=master\u0026style=flat)](https://travis-ci.org/yuanqing/malarkey) [![Coverage Status](https://img.shields.io/coveralls/yuanqing/malarkey.svg?style=flat)](https://coveralls.io/r/yuanqing/malarkey)\n\n\u003e Simulate a typewriter effect in vanilla JavaScript.\n\n- Flexible API allowing granular control\n- Option to repeat the sequence indefinitely\n- Allows stopping and resuming the sequence on-the-fly\n- 524 bytes gzipped\n\n## Usage\n\n\u003e [**Editable demo (CodePen)**](https://codepen.io/lyuanqing/pen/oqgOMK)\n\n```html\n\u003cdiv class=\"typewriter\"\u003e\u003c/div\u003e\n```\n\n```js\nconst malarkey = require('malarkey')\n\nconst element = document.querySelector('.typewriter')\nfunction callback (text) {\n  element.textContent = text\n}\nconst options = {\n  typeSpeed: 50,\n  deleteSpeed: 50,\n  pauseDuration: 2000,\n  repeat: true\n}\nmalarkey(callback, options)\n  .type('Say hello')\n  .pause()\n  .delete()\n  .type('Wave goodbye')\n  .pause()\n  .delete()\n```\n\n## API\n\n```js\nconst malarkey = require('malarkey')\n```\n\n### const m = malarkey(callback [, options])\n\nInitialise the typewriter effect with the given optional `options` settings.\n\n- `callback` is a function that is invoked for every `type` and `delete` event in the sequence. The function signature is `(text)`, where `text` is the string of characters that have been typed so far.\n\n- `options` is an object literal:\n\n    Key | Description | Default\n    :--|:--|:--\n    `typeSpeed` | Duration in milliseconds to `type` a single character | `50`\n    `deleteSpeed` | Duration in milliseconds to `delete` a single character | `50`\n    `pauseDuration` | Duration in milliseconds to `pause` | `2000`\n    `repeat` | Whether to repeat the entire sequence indefinitely | `false`\n\n### m.type(string [, options])\n\nType the given `string`, one character at a time.\n\n- Set `options.speed` to override the default `typeSpeed`.\n\n### m.delete([characterCount, options])\n\nDelete the specified number of characters, one character at a time.\n\n- `characterCount` is a positive integer. If not specified, all characters previously typed will be deleted, one character at a time.\n- Set `options.speed` to override the default `deleteSpeed`.\n\n### m.pause([options])\n\nDo nothing for some duration.\n\n- Set `options.duration` to override the default `pauseDuration`.\n\n### m.clear()\n\nImmediately clear all characters that were typed.\n\n### m.call(fn)\n\nCall the given `fn` function.\n\n- The function signature of `fn` is `(callback, text)`. Invoke `callback` to signal that `fn` has finished execution and that we can move on to the next event in the sequence.\n\n### m.triggerStop([fn])\n\nStops the sequence. Calls the given `fn` function when the sequence has been stopped.\n\n- The function signature of `fn` is `(text)`.\n\n### m.triggerResume()\n\nResume the sequence. Has no effect if the sequence is already running.\n\n### m.isStopped()\n\nReturns `true` if the sequence is currently stopped, else returns `false`.\n\n## Installation\n\nInstall via [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add malarkey\n```\n\nOr [npm](https://npmjs.com):\n\n```sh\n$ npm install --save malarkey\n```\n\n## License\n\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanqing%2Fmalarkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuanqing%2Fmalarkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanqing%2Fmalarkey/lists"}