Skip to content

Commit

Permalink
punctualTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Mar 7, 2024
1 parent e0320d5 commit e217a9c
Show file tree
Hide file tree
Showing 10 changed files with 938 additions and 1,079 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change logs

## 2024.03.07 v5.18.0

1. new `punctualTimer` function, see: [punctualTimer](https://github.com/saqqdy/js-cool#punctualtimer)

## 2024.01.21 v5.17.1

1. `safeParse` `safeStringify` supports converting bigint
Expand Down
1 change: 1 addition & 0 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const functionList = {
// 工具类
nextIndex, // 返回下一个zIndex值
nextVersion, // 返回下一个版本号
punctualTimer, // 准时的setInterval
promiseFactory, // 将一个对象转换为promise like api
fixNumber, // 截取小数点后几位,不足的不补0
mapTemplate, // 替换模板字符串的特定数据
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Collection of common JavaScript / TypeScript utilities
- [Utilities](#utilities)
- [nextIndex](#nextindex) - return the next zIndex value
- [nextVersion](#nextversion) - return the next version, **Only version types with no more than 3 digits are supported**. (Follow the npm version rules)
- [punctualTimer](#punctualtimer) - punctual setInterval
- [promiseFactory](#promisefactory) - Convert an object to a promise like api
- [fixNumber](#fixnumber) - truncate a few decimal places, not 0 for shortage
- [mapTemplate](#maptemplate) - Replacing specific data in a template string, support `${xxxx}` `{{xxxx}}` and `{xxxx}`
Expand Down Expand Up @@ -2458,6 +2459,38 @@ declare function nextVersion(
): string
```

#### punctualTimer

punctual setInterval

- Since: `5.18.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ------------ | ---------- | -------- | -------- | ------- |
| callback | call | `function` | - | `true` | - |
| type | version type | `number` | - | `false` | `1000` |

- Returns: `void`

- Example:

```ts
const printDate = () => console.log(new Date())
punctualTimer(printDate, 1000)
```

- Types:

```ts
declare function punctualTimer(
version: string,
type?: 'major' | 'minor' | 'patch' | 'premajor' | 'preminor' | 'prepatch' | 'prerelease',
preid?: string
): string
```

#### promiseFactory

Convert an object to a promise like api
Expand Down
4 changes: 2 additions & 2 deletions build/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const configs: Config[] = IS_WATCH
format: 'cjs',
env: 'development'
}
]
]
: [
{
input: 'src/index.ts',
Expand Down Expand Up @@ -90,7 +90,7 @@ const configs: Config[] = IS_WATCH
format: 'cjs',
env: 'development'
}
]
]

function createEntries() {
return configs.map(createEntry)
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-cool",
"description": "Collection of common JavaScript / TypeScript utilities",
"version": "5.17.1",
"version": "5.18.0",
"packageManager": "pnpm@8.9.2",
"main": "dist/index.cjs.js",
"module": "dist/index.esm-bundler.js",
Expand Down Expand Up @@ -59,12 +59,12 @@
"use-downloads": "^1.5.1"
},
"devDependencies": {
"@babel/core": "^7.23.7",
"@babel/plugin-transform-runtime": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@babel/core": "^7.24.0",
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-typescript": "^7.23.3",
"@eslint-sets/eslint-config-ts": "^5.11.0",
"@microsoft/api-extractor": "^7.39.1",
"@eslint-sets/eslint-config-ts": "^5.12.0",
"@microsoft/api-extractor": "^7.42.3",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
Expand All @@ -75,28 +75,28 @@
"@rollup/plugin-typescript": "^11.1.6",
"@types/activex-excel": "^14.0.10",
"@types/babel__core": "^7.20.5",
"@types/node": "^20.11.5",
"@types/node": "^20.11.25",
"babel-loader": "^9.1.3",
"core-js": "^3.35.1",
"core-js": "^3.36.0",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"fast-glob": "^3.3.2",
"load-yml": "^1.4.0",
"madge": "^6.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"prettier-config-common": "^1.4.0",
"reinstaller": "^3.0.2",
"rm-all": "^1.1.1",
"rollup": "^4.9.6",
"rollup": "^4.12.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"rollup-plugin-visualizer": "^5.12.0",
"tsnd": "^1.1.0",
"typedoc": "^0.25.7",
"typedoc": "^0.25.11",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.3.3",
"typescript": "^5.4.2",
"zx": "^7.2.3"
},
"engines": {
Expand Down
Loading

0 comments on commit e217a9c

Please sign in to comment.