{"id":18623951,"url":"https://github.com/lloydzhou/action-stack-manager","last_synced_at":"2025-11-03T18:30:33.623Z","repository":{"id":65668630,"uuid":"596946285","full_name":"lloydzhou/action-stack-manager","owner":"lloydzhou","description":"action stack manager","archived":false,"fork":false,"pushed_at":"2023-02-03T10:27:02.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T14:09:05.981Z","etag":null,"topics":["history","manager","redo","stack","undo"],"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/lloydzhou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-02-03T09:27:52.000Z","updated_at":"2023-02-03T09:29:48.000Z","dependencies_parsed_at":"2023-02-18T06:00:40.871Z","dependency_job_id":null,"html_url":"https://github.com/lloydzhou/action-stack-manager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Faction-stack-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Faction-stack-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Faction-stack-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lloydzhou%2Faction-stack-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lloydzhou","download_url":"https://codeload.github.com/lloydzhou/action-stack-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239418576,"owners_count":19635208,"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":["history","manager","redo","stack","undo"],"created_at":"2024-11-07T04:26:48.970Z","updated_at":"2025-11-03T18:30:33.565Z","avatar_url":"https://github.com/lloydzhou.png","language":"TypeScript","readme":"# action-stack-manager\n\nmanage redo/undo stack\n\n管理撤销重做调用栈\n\n1. always push (commit and rollback)\n2. redo() ==\u003e call commit\n2. undo() ==\u003e call rollback\n\n\n## demo \n\n```\n  const h = new HistoryManager()\n\n  let inc = 0\n  // 0 --\u003e 2\n  await h.push(() =\u003e inc = 2, () =\u003e inc = 0)\n  // 2 --\u003e 3\n  await h.push(() =\u003e inc += 1, () =\u003e inc -= 1)\n\n  console.log('HistoryManager', h, inc)\n  console.log(this)\n  // 3 --\u003e 2\n  await h.undo()\n  console.log('undo', h.redoSize, h.undoSize, inc, 'inc = 2')\n  // 2 --\u003e 0\n  await h.undo()\n  console.log('undo', h.redoSize, h.undoSize, inc, 'inc = 0')\n  // 0 --\u003e 2\n  await h.redo()\n  console.log('redo', h.redoSize, h.undoSize, inc, 'inc = 2')\n  // 2 --\u003e 3\n  await h.redo()\n  console.log('redo', h.redoSize, h.undoSize, inc, 'inc = 3')\n  // 报错\n  await h.redo().catch(console.log)\n  console.log('redo', h.redoSize, h.undoSize, inc, 'inc = 3')\n  // 3 --\u003e 2\n  await h.undo()\n  console.log('undo', h.redoSize, h.undoSize, inc, 'inc = 2')\n  // 2 --\u003e 4\n  await h.push(() =\u003e inc += 2, () =\u003e inc -= 2)\n  console.log('push', h.redoSize, h.undoSize, inc, 'inc = 4', h)\n  // 4 --\u003e 2\n  await h.undo()\n  console.log('undo', h.redoSize, h.undoSize, inc, 'inc = 2')\n  // 2 --\u003e 0\n  await h.undo()\n  console.log('undo', h.redoSize, h.undoSize, inc, 'inc = 0')\n  // 0 --\u003e 4\n  await h.push(() =\u003e inc += 4, () =\u003e inc -= 4)\n  console.log('push', h.redoSize, h.undoSize, inc, 'inc = 4', h)\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flloydzhou%2Faction-stack-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flloydzhou%2Faction-stack-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flloydzhou%2Faction-stack-manager/lists"}