Skip to content

Commit

Permalink
feat(death): add using syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Sep 2, 2023
1 parent 31e3c64 commit 9ee40fb
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 42 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"devDependencies": {
"@size-limit/preset-small-lib": "^8.2.6",
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"bumpp": "latest",
"size-limit": "^8.2.6",
"turbo": "^1.10.13",
Expand Down
4 changes: 2 additions & 2 deletions packages/breadc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@breadc/color": "workspace:*"
},
"devDependencies": {
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"@vitest/coverage-v8": "^0.34.3",
"cac": "^6.7.14",
"vitest": "0.34.3"
Expand All @@ -63,4 +63,4 @@
"path": "./dist/index.cjs"
}
]
}
}
4 changes: 2 additions & 2 deletions packages/color/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"vitest": "^0.34.3"
}
}
}
4 changes: 2 additions & 2 deletions packages/complete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"devDependencies": {
"@breadc/color": "workspace:*",
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"breadc": "workspace:*",
"typescript": "^5.2.2",
"vitest": "0.34.3"
Expand All @@ -56,4 +56,4 @@
"@breadc/color": "workspace:*",
"breadc": "workspace:*"
}
}
}
2 changes: 1 addition & 1 deletion packages/death/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"vitest": "^0.34.3"
}
}
13 changes: 13 additions & 0 deletions packages/death/src/death.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ export function onDeath(
};
}

export function useDeath(
callback: OnDeathCallback,
options: OnDeathOptions = {}
) {
const cancel = onDeath(callback, options);

return {
[Symbol.dispose]: () => {
cancel();
}
};
}

function registerCallback(signal: DeathSignals, handler: Handler) {
if (handler.count === 0) {
handler.count += 1;
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"std-env": "^3.4.3"
},
"devDependencies": {
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"vitest": "0.34.3"
}
}
4 changes: 2 additions & 2 deletions packages/progress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"string-width": "^6.1.0"
},
"devDependencies": {
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"vitest": "0.34.3"
}
}
}
4 changes: 2 additions & 2 deletions packages/spinner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"string-width": "^6.1.0"
},
"devDependencies": {
"@types/node": "^18.17.13",
"@types/node": "^20.5.8",
"vitest": "0.34.3"
}
}
}
58 changes: 29 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9ee40fb

Please sign in to comment.