{"id":41055059,"url":"https://github.com/typescript-package/history","last_synced_at":"2026-01-22T11:35:48.367Z","repository":{"id":283532652,"uuid":"951493670","full_name":"typescript-package/history","owner":"typescript-package","description":"A lightweight TypeScript package for tracking the history of values.","archived":false,"fork":false,"pushed_at":"2025-05-07T16:36:21.000Z","size":127,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-20T03:43:16.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/typescript-package.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["angular-package"],"patreon":"angularpackage","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29","https://donate.stripe.com/dR614hfDZcJE3wAcMM"]}},"created_at":"2025-03-19T19:08:31.000Z","updated_at":"2025-05-07T16:36:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a7cb383-b9d6-431c-98a7-210f2e382937","html_url":"https://github.com/typescript-package/history","commit_stats":null,"previous_names":["typescript-package/history"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/typescript-package/history","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fhistory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fhistory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fhistory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fhistory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typescript-package","download_url":"https://codeload.github.com/typescript-package/history/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typescript-package%2Fhistory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28662166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-01-22T11:35:47.747Z","updated_at":"2026-01-22T11:35:48.357Z","avatar_url":"https://github.com/typescript-package.png","language":"TypeScript","funding_links":["https://github.com/sponsors/angular-package","https://patreon.com/angularpackage","https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29","https://donate.stripe.com/dR614hfDZcJE3wAcMM"],"categories":[],"sub_categories":[],"readme":"\u003cimg\n    src=\"https://avatars.githubusercontent.com/u/189666396?s=150\u0026u=9d55b1eb4ce258974ead76bf07ccf49ef0eb0ea7\u0026v=4\"\n    title=\"The typescript package enhances the development of typescript-based applications by providing well-structured, reusable, easy-to-use packages.\"\n  /\u003e\n\u003c/a\u003e\n\n## typescript-package/history\n\n\u003c!-- npm badge --\u003e\n[![npm version][typescript-package-npm-badge-svg]][typescript-package-npm-badge]\n[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues]\n[![GitHub license][typescript-package-badge-license]][typescript-package-license]\n\nA **lightweight TypeScript** package for tracking history of values.\n\n## Table of contents\n\n- [Installation](#installation)\n- [Api](#api)\n  - [`History`](#history)\n  - Base\n    - [`CurrentHistory`](#currenthistory)\n    - [`HistoryBase`](#historybase)\n    - [`RedoHistory`](#redohistory)\n    - [`UndoHistory`](#undohistory)\n  - Core\n    - [`HistoryAppend`](#historyappend)\n    - [`HistoryCore`](#historycore)\n    - [`HistoryCurrent`](#historycurrent)\n    - [`HistoryPrepend`](#historyprepend)\n    - [`HistoryStorage`](#historystorage)\n  - Type\n    - [`HistoryCoreConstructor`](#historycoreconstructor)\n    - [`HistoryCurrentConstructor`](#historycurrentconstructor)\n- [Contributing](#contributing)\n- [Support](#support)\n- [Code of Conduct](#code-of-conduct)\n- [Git](#git)\n  - [Commit](#commit)\n  - [Versioning](#versioning)\n- [License](#license)\n\n## Installation\n\n### 1. Install peer dependencies\n\n```bash\nnpm install @typescript-package/data --save-peer\n```\n\n### 2. Install package\n\n```bash\nnpm install @typescript-package/history --save-peer\n```\n\n## Api\n\n```typescript\nimport {\n  History,\n  // Base.\n  HistoryBase,\n  // Core (Abstract).\n  HistoryAppend,\n  HistoryCore,\n  HistoryCurrent,\n  HistoryPrepend,\n  HistoryStorage,\n  // Type.\n  HistoryCoreConstructor,\n  HistoryCurrentConstructor,\n} from '@typescript-package/history';\n```\n\n### `History`\n\nThe class to manage the value changes.\n\n```typescript\nimport { History } from '@typescript-package/history';\n\n// Initialize.\nexport const history = new History({value: 5, size: 5});\n\nconsole.group(`History README.md`);\n\nconsole.log(`set 10 - 35`);\nhistory.set(10).set(15).set(20).set(25).set(30).set(35);\n\n// [10, 15, 20, 25, 30], 35, []\nconsole.log(history.undoHistory.get(), history.current, history.redoHistory.get());\n\n// undo 35\nconsole.log(`undo`, 35);\nhistory.undo();\n\n// [10, 15, 20, 25], 30, [35]\nconsole.log(history.undoHistory.get(), history.current, history.redoHistory.get()); \n\n// undo 30\nconsole.log(`undo`, 30);\nhistory.undo();\n\n// [10, 15, 20], 25, [30, 35]\nconsole.log(history.undoHistory.get(), history.current, history.redoHistory.get()); \n\n// undo 25\nconsole.log(`undo`, 25);\nhistory.undo();\n\n// [10, 15], 20, [25, 30, 35]\nconsole.log(history.undoHistory.get(), history.current, history.redoHistory.get());\n\n// undo 20\nconsole.log(`undo`, 20);\nhistory.undo();\n\n// [10], 15, [20, 25, 30, 35]\nconsole.log(history.undoHistory.get(), history.current, history.redoHistory.get());\n\n// redo 20\nconsole.log(`redo`, 20);\nhistory.redo();\n\n// [10, 15], 20, [25, 30, 35]\nconsole.log(history.undoHistory.get(), history.current, history.redoHistory.get());\n\nconsole.groupEnd();\n```\n\nAn example of usage data type.\n\n```typescript\nimport { History as BaseHistory } from '@typescript-package/history';\nimport { WeakData } from '@typescript-package/data';\n\n// Initialize.\nexport const history = new class History\u003cType, Size extends number = number\u003e\n  extends BaseHistory\u003cType, Size, WeakData\u003creadonly Type[]\u003e\u003e{}({value: 5, size: 5}, WeakData);\n\n// Add to the history.\nhistory.set(10).set(15).set(20);\n\n// Check whether it is stored under the `WeakData`.\nconsole.log(`history.undoHistory.data`, WeakData.get(history.undoHistory.data)); // Output: [5, 10, 15]\n\n```\n\n### Base\n\n### `CurrentHistory`\n\n```typescript\nimport { CurrentHistory } from '@typescript-package/history';\n```\n\n### `HistoryBase`\n\nThe base `abstract` class to manage history.\n\n```typescript\nimport { HistoryBase } from '@typescript-package/history';\n```\n\n### `RedoHistory`\n\n```typescript\nimport { RedoHistory } from '@typescript-package/history';\n```\n\n### `UndoHistory`\n\n```typescript\nimport { UndoHistory } from '@typescript-package/history';\n```\n\n### Core\n\n### `HistoryAppend`\n\n```typescript\nimport { HistoryAppend as AbstractHistoryAppend } from '@typescript-package/history';\n\n// Initialize.\nexport const historyAppend = new class HistoryAppend\u003cType = number, Size extends number = number\u003e\n  extends AbstractHistoryAppend\u003cType, Size\u003e{}();\n\n// Add to the history.\nconsole.log(`add`, 127, 227);\nhistoryAppend.add(127).add(227);\nconsole.log(historyAppend.get()); // [127, 227]\n\n// Peek.\nconsole.log(`last()`, historyAppend.last()); // Outputs: 127\nconsole.log(`next()`, historyAppend.next()); // Outputs: 227\n\n// Take from the history.\nconsole.log(historyAppend.take()); // Outputs: 227\nconsole.log(historyAppend.get()); // Outputs: [127]\n```\n\n### `HistoryCore`\n\nThe core class for history append and prepend.\n\n### `HistoryCurrent`\n\nThe class represents the current value of the history.\n\n```typescript\nimport { HistoryCurrent as AbstractHistoryCurrent } from '@typescript-package/history';\n\nexport class HistoryCurrent\u003c\n  Value,\n  DataType extends DataCore\u003creadonly Value[]\u003e = Data\u003creadonly Value[]\u003e\n\u003e extends AbstractHistoryCurrent\u003cValue, DataType\u003e {\n  public override get value() {\n    return super.data.value[0]\n  }\n  public has() {\n    return super.data.value.length \u003e 0;\n  }\n  public override set(value: readonly Value[]) {\n    super.set(value);\n    return this;\n  }\n  public update(value: Value) {\n    super.set([value]);\n    return this;\n  }\n}\n\nconst historyCurrent = new HistoryCurrent({value: 'a'});\nconsole.log(`get()`, historyCurrent.get()); // ['a']\nconsole.log(`length`, historyCurrent.length); // 1\nconsole.log(`isEmpty()`, historyCurrent.isEmpty()); // false\nconsole.log(`data.value`, historyCurrent.data.value); // ['a']\nhistoryCurrent.set(['b']);\nconsole.log(`get()`, historyCurrent.get()); // ['b']\nconsole.log(`length`, historyCurrent.length); // 1\nconsole.log(`isEmpty()`, historyCurrent.isEmpty()); // false\nhistoryCurrent.set(['b', 'c', 'd']);\nconsole.log(`get()`, historyCurrent.get()); // ['b', 'c', 'd']\nconsole.log(`length`, historyCurrent.length); // 3\nconsole.log(`isEmpty()`, historyCurrent.isEmpty()); // false\nhistoryCurrent.update('e');\nconsole.log(`get()`, historyCurrent.get()); // ['e']\nconsole.log(`length`, historyCurrent.length); // 1\nconsole.log(`isEmpty()`, historyCurrent.isEmpty()); // false\nhistoryCurrent.destroy();\n\n```\n\n### `HistoryPrepend`\n\n```typescript\nimport { HistoryPrepend as AbstractHistoryPrepend } from '@typescript-package/history';\n\n// Initialize.\nexport const historyPrepend = new class HistoryPrepend\u003cType = number, Size extends number = number\u003e\n  extends AbstractHistoryPrepend\u003cType, Size\u003e{}();\n\n// Add to the history.\nconsole.log(`add`, 127, 327, 227);\nhistoryPrepend.add(127).add(327).add(227);\nconsole.log(historyPrepend.get()); // [227, 327, 127]\n\n// Peek.\nconsole.log(`last()`, historyPrepend.last()); // Outputs: 127\nconsole.log(`next()`, historyPrepend.next()); // Outputs: 227\n\n// Take from the history.\nconsole.log(historyPrepend.take()); // 227\nconsole.log(historyPrepend.get()); // [327, 127]\n```\n\n### `HistoryStorage`\n\nThe history storage of specified data.\n\n```typescript\nimport { HistoryStorage as AbstractHistoryStorage } from '@typescript-package/history';\n\nexport class HistoryStorage\u003c\n  Value,\n  DataType extends DataCore\u003creadonly Value[]\u003e = Data\u003creadonly Value[]\u003e\n\u003e extends AbstractHistoryStorage\u003cValue, DataType\u003e {\n  public override set(value: readonly Value[]) {\n    super.set(value);\n    return this;\n  }\n}\n\nconst historyStorage = new HistoryStorage(['a']);\nconsole.log(historyStorage.get()); // ['a']\nconsole.log(historyStorage.length); // 1\nconsole.log(historyStorage.isEmpty()); // false\nconsole.log(historyStorage.data.value); // ['a']\nhistoryStorage.set(['b']);\nconsole.log(historyStorage.get()); // ['b']\nhistoryStorage.set(['b', 'c', 'd']);\nconsole.log(historyStorage.get()); // ['b', 'c', 'd']\nconsole.log(historyStorage.length); // 3\nhistoryStorage.destroy();\nconsole.log(Object.hasOwn(historyStorage.data, 'value')); // false\n\n```\n\n### Type\n\n### `HistoryCoreConstructor`\n\n```typescript\nimport { HistoryCoreConstructor } from '@typescript-package/history';\n```\n\n### `HistoryCurrentConstructor`\n\n```typescript\nimport { HistoryCurrentConstructor } from '@typescript-package/history';\n```\n\n## Contributing\n\nYour contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.\n\n## Support\n\nIf you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.\n\nSupport via:\n\n- [Stripe](https://donate.stripe.com/dR614hfDZcJE3wAcMM)\n- [Revolut](https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29)\n\nThanks for your support!\n\n## Code of Conduct\n\nBy participating in this project, you agree to follow **[Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/)**.\n\n## GIT\n\n### Commit\n\n- [AngularJS Git Commit Message Conventions][git-commit-angular]\n- [Karma Git Commit Msg][git-commit-karma]\n- [Conventional Commits][git-commit-conventional]\n\n### Versioning\n\n[Semantic Versioning 2.0.0][git-semver]\n\n**Given a version number MAJOR.MINOR.PATCH, increment the:**\n\n- MAJOR version when you make incompatible API changes,\n- MINOR version when you add functionality in a backwards-compatible manner, and\n- PATCH version when you make backwards-compatible bug fixes.\n\nAdditional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.\n\n**FAQ**\nHow should I deal with revisions in the 0.y.z initial development phase?\n\n\u003e The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.\n\nHow do I know when to release 1.0.0?\n\n\u003e If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.\n\n## License\n\nMIT © typescript-package ([license][typescript-package-license])\n\n## Packages\n\n- **[@typescript-package/affix](https://github.com/typescript-package/affix)**: A **lightweight TypeScript** library for the affix - prefix and suffix.\n- **[@typescript-package/are](https://github.com/typescript-package/are)**: Type-safe `are` checkers for validating value types in TypeScript.\n- **[@typescript-package/data](https://github.com/typescript-package/data)**: A **lightweight TypeScript** library for basic data management.\n- **[@typescript-package/descriptor](https://github.com/typescript-package/descriptor)**: A **lightweight TypeScript** library for property descriptor.\n- **[@typescript-package/guard](https://github.com/typescript-package/guard)**: Type-safe guards for guarding the value types in TypeScript.c\n- **[@typescript-package/history](https://github.com/typescript-package/history)**: A **TypeScript** package for tracking history of values.\n- **[@typescript-package/is](https://github.com/typescript-package/is)**: Type-safe is checkers for validating value types in TypeScript.\n- **[@typescript-package/name](https://github.com/typescript-package/name)**: A **lightweight TypeScript** library for the name with prefix and suffix.\n- **[@typescript-package/property](https://github.com/typescript-package/property)**: A **lightweight TypeScript** package with features to handle object properties.\n- **[@typescript-package/queue](https://github.com/typescript-package/queue)**: A **lightweight TypeScript** library for managing various queue and stack structures.\n- **[@typescript-package/range](https://github.com/typescript-package/range)**: A **lightweight TypeScript** library for managing various types of ranges.\n- **[@typescript-package/regexp](https://github.com/typescript-package/regexp)**: A **lightweight TypeScript** library for **RegExp**.\n- **[@typescript-package/state](https://github.com/typescript-package/state)**: Simple state management for different types in **TypeScript**.\n- **[@typescript-package/type](https://github.com/typescript-package/type)**: Utility types to enhance and simplify **TypeScript** development.\n- **[@typescript-package/wrapper](https://github.com/typescript-package/wrapper)**: A **lightweight TypeScript** library to wrap the text with the opening and closing chars.\n\n\u003c!-- This package: typescript-package  --\u003e\n  \u003c!-- GitHub: badges --\u003e\n  [typescript-package-badge-issues]: https://img.shields.io/github/issues/typescript-package/history\n  [isscript-package-badge-forks]: https://img.shields.io/github/forks/typescript-package/history\n  [typescript-package-badge-stars]: https://img.shields.io/github/stars/typescript-package/history\n  [typescript-package-badge-license]: https://img.shields.io/github/license/typescript-package/history\n  \u003c!-- GitHub: badges links --\u003e\n  [typescript-package-issues]: https://github.com/typescript-package/history/issues\n  [typescript-package-forks]: https://github.com/typescript-package/history/network\n  [typescript-package-license]: https://github.com/typescript-package/history/blob/master/LICENSE\n  [typescript-package-stars]: https://github.com/typescript-package/history/stargazers\n\u003c!-- This package --\u003e\n\n\u003c!-- Package: typescript-package --\u003e\n  \u003c!-- npm --\u003e\n  [typescript-package-npm-badge-svg]: https://badge.fury.io/js/@typescript-package%2Fhistory.svg\n  [typescript-package-npm-badge]: https://badge.fury.io/js/@typescript-package%2Fhistory\n\n\u003c!-- GIT --\u003e\n[git-semver]: http://semver.org/\n\n\u003c!-- GIT: commit --\u003e\n[git-commit-angular]: https://gist.github.com/stephenparish/9941e89d80e2bc58a153\n[git-commit-karma]: http://karma-runner.github.io/0.10/dev/git-commit-msg.html\n[git-commit-conventional]: https://www.conventionalcommits.org/en/v1.0.0/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypescript-package%2Fhistory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypescript-package%2Fhistory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypescript-package%2Fhistory/lists"}