Skip to content

Commit

Permalink
feat(scripting/hooks): create useDelay() hook
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Sep 21, 2023
1 parent a32c362 commit 2d04c75
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"default": "./dist/src/scripting/commands/index.js",
"types": "./dist/src/scripting/commands/index.d.ts"
},
"./scripting/hooks": {
"default": "./dist/src/scripting/hooks/index.js",
"types": "./dist/src/scripting/hooks/index.d.ts"
},
"./scripting/interfaces": {
"default": "./dist/src/scripting/interfaces/index.js",
"types": "./dist/src/scripting/interfaces/index.d.ts"
Expand Down
1 change: 1 addition & 0 deletions src/scripting/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useDelay } from '@scripting/hooks/useDelay.js'
11 changes: 11 additions & 0 deletions src/scripting/hooks/useDelay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let delayIdx = 0

export const useDelay = () => {
let delayOffset = 0

return (delayInMs: number = 0) => {
delayOffset += Math.floor(delayInMs)

return `TIMERdelay${++delayIdx} -m 1 ${delayOffset}`
}
}

0 comments on commit 2d04c75

Please sign in to comment.