Skip to content

Commit c96bb7c

Browse files
authored
feat(dt-utils): refactor the dt-utils (#105)
* chore: upgrade package & replace packaging tools * refactor: remove old functions * refactor: rename browserCheck to checkBrowserSupport * refactor: improve copy * refactor: rename downLoadData to downloadFile * refactor: rename convertBytes to formatBytes * refactor: rename dateTime to formatDateTime * feat: add formatSecond * feat: add formatBase64 * refactor: rename generateFullUrlPath to generateUrlWithQuery * refactor: merge generateAKey and getRandomStr into getKey * refactor: improve getQueryParameters * feat: add getTypeOfValue * refactor: improve isMacOS * refactor: improve isMobile * refactor: improve isWindows * refactor: localDB.set support batch set, localDB.clear support except parameter * refactor: improve LocalIndexedDB * feat: add sessionDB * feat: add shouldRender * refactor: merge getBase64 and base64Encode into toBase64 * refactor: rename percent to toPercent * refactor: rename exchangeOrder to toSortOrder * refactor: rename getThousandth to toThousand * feat: add unit testing * chore: add entry file * chore: remove docs * refactor: build site with VitePress and generate documentation using TypeDoc * chore: add docs:deploy script * chore: replace yarn with pnpm * refactor: rename LocalIndexedDB to IndexedDB * refactor: improve code * chore: translate English comments to Chinese * chore: update project configuration and set TypeScript package version * chore: update docs * chore: replace yarn with pnpm * refactor: rename getKey to generateUniqueId * feat: support HH[h]mm[m]ss[s] time format * fix: replace Chinese dash with ASCII hyphen * chore: update comments * fix: correct isMacOS functionality * chore: remove comment * docs: build docs * feat: support custom time units * feat: add IndexedDB unit test * docs: correct @see syntax issue * docs: convert indexedDB, localDB, and sessionDB method docs into table format * feat: localDB.remove supports batch deletion * test: add remove multiple keys unit tests * fix: set default size for generateUniqueId * refactor: improve trim * chore: remove changelog generation from prepublishOnly script
1 parent cdac32a commit c96bb7c

File tree

124 files changed

+15671
-13649
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+15671
-13649
lines changed

.editorconfig

Lines changed: 0 additions & 13 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
module.exports = {
22
extends: [require.resolve('ko-lint-config/.eslintrc')],
3-
rules: {
4-
'no-console': 0,
5-
'no-param-reassign': 0, // 函数的入参再次赋值
6-
},
73
};

.github/workflows/CI.yml

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,134 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Triggers the workflow on push or pull request events but only for the master branch
63
on:
74
push:
85
branches: [master]
96
pull_request:
107
branches: [master]
118

12-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
139
jobs:
1410
setup:
1511
runs-on: ubuntu-latest
1612
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
13+
- uses: actions/checkout@v4
1914

20-
- name: Cache yarn.lock
21-
uses: actions/cache@v4
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
2217
with:
23-
path: package-temp-dir
24-
key: lock-${{ github.sha }}
18+
node-version: 16.x
2519

26-
- name: Create yarn.lock
27-
run: yarn generate-lock-entry
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@v2
22+
with:
23+
version: 6.32.12
24+
run_install: false
2825

29-
- name: Hack for single file
26+
- name: Get pnpm store directory
27+
id: pnpm-cache
28+
shell: bash
3029
run: |
31-
if [ ! -d "package-temp-dir" ]; then
32-
mkdir package-temp-dir
33-
fi
34-
cp yarn.lock package-temp-dir
35-
- name: Cache node_modules
36-
id: node_modules_cache_id
30+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
31+
32+
- name: Cache pnpm store
3733
uses: actions/cache@v4
3834
with:
39-
path: node_modules
40-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
35+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
4139
4240
- name: Install dependencies
43-
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
44-
run: yarn
41+
shell: bash
42+
run: pnpm install
4543

4644
prettier:
47-
needs: [setup]
45+
needs: setup
4846
runs-on: ubuntu-latest
4947
steps:
50-
- uses: actions/checkout@v2
48+
- uses: actions/checkout@v4
5149

52-
- name: Restore cache from yarn.lock
53-
uses: actions/cache@v4
50+
- name: Set up Node.js
51+
uses: actions/setup-node@v4
5452
with:
55-
path: package-temp-dir
56-
key: lock-${{ github.sha }}
53+
node-version: 16.x
5754

58-
- name: Restore cache from node_modules
59-
uses: actions/cache@v4
55+
- name: Install pnpm
56+
uses: pnpm/action-setup@v2
6057
with:
61-
path: node_modules
62-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
58+
version: 6.32.12
59+
run_install: false
60+
61+
- run: pnpm install
6362

64-
- name: Prettier check
65-
run: yarn prettier
63+
- name: Run Prettier
64+
run: pnpm prettier
6665

6766
eslint:
68-
needs: [setup]
67+
needs: setup
6968
runs-on: ubuntu-latest
7069
steps:
71-
- uses: actions/checkout@v2
70+
- uses: actions/checkout@v4
7271

73-
- name: Restore cache from yarn.lock
74-
uses: actions/cache@v4
72+
- name: Set up Node.js
73+
uses: actions/setup-node@v4
7574
with:
76-
path: package-temp-dir
77-
key: lock-${{ github.sha }}
75+
node-version: 16.x
7876

79-
- name: Restore cache from node_modules
80-
uses: actions/cache@v4
77+
- name: Install pnpm
78+
uses: pnpm/action-setup@v2
8179
with:
82-
path: node_modules
83-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
80+
version: 6.32.12
81+
run_install: false
8482

85-
- name: Eslint check
86-
run: yarn eslint
83+
- run: pnpm install
84+
85+
- name: Run ESLint
86+
run: pnpm eslint
8787

8888
test:
89-
needs: [setup]
89+
needs: setup
9090
runs-on: ubuntu-latest
9191
steps:
92-
- uses: actions/checkout@v2
92+
- uses: actions/checkout@v4
9393

94-
- name: Restore cache from yarn.lock
95-
uses: actions/cache@v4
94+
- name: Set up Node.js
95+
uses: actions/setup-node@v4
9696
with:
97-
path: package-temp-dir
98-
key: lock-${{ github.sha }}
97+
node-version: 16.x
9998

100-
- name: Restore cache from node_modules
101-
uses: actions/cache@v4
99+
- name: Install pnpm
100+
uses: pnpm/action-setup@v2
102101
with:
103-
path: node_modules
104-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
102+
version: 6.32.12
103+
run_install: false
104+
- run: pnpm install
105105

106-
- name: Setup timezone
106+
- name: Set up timezone
107107
uses: zcong1993/setup-timezone@master
108108
with:
109-
timezone: Asia/Shanghai
109+
timezone: Asia/Shanghai
110110

111-
- name: Unit Test
112-
run: yarn test
111+
- name: Run Tests
112+
run: pnpm test
113113

114114
build:
115-
runs-on: ubuntu-latest
116115
needs: [setup, prettier, eslint, test]
116+
runs-on: ubuntu-latest
117117
steps:
118-
- uses: actions/checkout@v2
118+
- uses: actions/checkout@v4
119119

120-
- name: Restore cache from yarn.lock
121-
uses: actions/cache@v4
120+
- name: Set up Node.js
121+
uses: actions/setup-node@v4
122122
with:
123-
path: package-temp-dir
124-
key: lock-${{ github.sha }}
123+
node-version: 16.x
125124

126-
- name: Restore cache from node_modules
127-
uses: actions/cache@v4
125+
- name: Install pnpm
126+
uses: pnpm/action-setup@v2
128127
with:
129-
path: node_modules
130-
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}
128+
version: 6.32.12
129+
run_install: false
130+
131+
- run: pnpm install
131132

132-
- name: Build test
133-
run: yarn build
133+
- name: Run Build
134+
run: pnpm build

.gitignore

Lines changed: 4 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,15 @@
1-
# Logs
21
logs
32
*.log
43
npm-debug.log*
54
yarn-debug.log*
65
yarn-error.log*
76
lerna-debug.log*
8-
9-
# Diagnostic reports (https://nodejs.org/api/report.html)
10-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11-
12-
# Runtime data
13-
pids
14-
*.pid
15-
*.seed
16-
*.pid.lock
17-
18-
# Directory for instrumented libs generated by jscoverage/JSCover
19-
lib-cov
20-
21-
# Coverage directory used by tools like istanbul
22-
coverage
23-
*.lcov
24-
25-
# nyc test coverage
26-
.nyc_output
27-
28-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29-
.grunt
30-
31-
# Bower dependency directory (https://bower.io/)
32-
bower_components
33-
34-
# node-waf configuration
35-
.lock-wscript
36-
37-
# Compiled binary addons (https://nodejs.org/api/addons.html)
38-
build/Release
39-
40-
# Dependency directories
417
node_modules/
42-
jspm_packages/
43-
44-
# TypeScript v1 declaration files
45-
typings/
46-
47-
# TypeScript cache
48-
*.tsbuildinfo
49-
50-
# Optional npm cache directory
51-
.npm
52-
53-
# Optional eslint cache
54-
.eslintcache
55-
56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
61-
62-
# Optional REPL history
63-
.node_repl_history
64-
65-
# Output of 'npm pack'
66-
*.tgz
67-
68-
# Yarn Integrity file
69-
.yarn-integrity
70-
71-
# dotenv environment variables file
72-
.env
73-
.env.test
74-
75-
# parcel-bundler cache (https://parceljs.org/)
76-
.cache
77-
78-
# Next.js build output
79-
.next
80-
81-
# Nuxt.js build / generate output
82-
.nuxt
83-
dist
84-
85-
# Gatsby files
868
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
90-
91-
# vuepress build output
92-
.vuepress/dist
93-
94-
# Serverless directories
95-
.serverless/
96-
97-
# FuseBox cache
98-
.fusebox/
99-
100-
# DynamoDB Local files
101-
.dynamodb/
102-
103-
# TernJS port file
104-
.tern-port
105-
9+
docs/.vitepress/cache/
10+
dist
10611
lib
10712
temp
108-
109-
# ide
110-
# .vscode
11113
.idea
14+
.vscode
15+
.DS_Store

.vscode/extensions.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)