Skip to content

Commit

Permalink
feat(utils): add count methods
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Feb 19, 2024
1 parent 247c2aa commit 31523dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions common/utils/src/counter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let globalCount = 0

export function getGlobalCount() {
return globalCount++
}

export function setGlobalCount(count: number) {
globalCount = Math.round(count)
}

export function createCounter(count = 0) {
return {
getCount: () => count++,
setCount: (newCount: number) => {
count = newCount
}
}
}
1 change: 1 addition & 0 deletions common/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './clipboard'
export * from './color'
export * from './common'
export * from './counter'
export * from './data'
export * from './date'
export * from './deep-clone'
Expand Down

0 comments on commit 31523dc

Please sign in to comment.