Skip to content

Commit 58ee77a

Browse files
committed
chore: initial
0 parents  commit 58ee77a

File tree

380 files changed

+19586
-0
lines changed

Some content is hidden

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

380 files changed

+19586
-0
lines changed

.github/cache/action.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Setup PNPM cache
2+
3+
description: Cache Dependencies
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Checkout Repo
8+
uses: actions/checkout@v4
9+
with:
10+
fetch-depth: 0
11+
12+
- name: Install Node.js
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
cache: pnpm
17+
18+
- uses: pnpm/action-setup@v4
19+
20+
- name: Get pnpm store directory
21+
shell: bash
22+
run: |
23+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
24+
25+
- uses: actions/cache@v4
26+
name: Setup pnpm cache
27+
with:
28+
path: ${{ env.STORE_PATH }}
29+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
30+
restore-keys: |
31+
${{ runner.os }}-pnpm-store-
32+
33+
# - name: Enable corepack
34+
# run: corepack enable
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
shell: bash

.github/commit-convention.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## Git Commit Message Convention
2+
3+
> This is adapted from [Commit convention](https://www.conventionalcommits.org/en/v1.0.0/).
4+
5+
#### TL;DR:
6+
7+
Messages must be matched by the following regex:
8+
9+
``` js
10+
/^((feat|fix|docs|style|core|i18n|a11y|report|misc|cli|audits|improve|security|deprecated|refactor|perf|test|workflow|build|ci|chore|types|wip|release|deps?|merge|examples?|revert)(\(.+\))?(:|!:)|(Merge|Revert|Version)) .{1,50}$/
11+
```
12+
13+
#### Examples
14+
15+
Appears under "Features" header, `compiler` subheader:
16+
17+
```
18+
feat(compiler): add 'comments' option
19+
```
20+
21+
Appears under "Bug Fixes" header, `v-model` subheader, with a link to issue #28:
22+
23+
```
24+
fix(v-model): handle events on blur
25+
26+
close #28
27+
```
28+
29+
Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:
30+
31+
```
32+
perf(core): improve vdom diffing by removing 'foo' option
33+
34+
BREAKING CHANGE: The 'foo' option has been removed.
35+
```
36+
37+
The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.
38+
39+
```
40+
revert: feat(compiler): add 'comments' option
41+
42+
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
43+
```
44+
45+
### Full Message Format
46+
47+
A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:
48+
49+
```
50+
<type>(<scope>): <subject>
51+
<BLANK LINE>
52+
<body>
53+
<BLANK LINE>
54+
<footer>
55+
```
56+
57+
The **header** is mandatory and the **scope** of the header is optional.
58+
59+
### Revert
60+
61+
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body, it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
62+
63+
### Type
64+
65+
If the prefix is `feat`, `fix` or `perf`, it will appear in the changelog. However, if there is any [BREAKING CHANGE](#footer), the commit will always appear in the changelog.
66+
67+
Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks.
68+
69+
### Scope
70+
71+
The scope could be anything specifying the place of the commit change. For example `core`, `compiler`, `ssr`, `v-model`, `transition` etc...
72+
73+
### Subject
74+
75+
The subject contains a succinct description of the change:
76+
77+
* use the imperative, present tense: "change" not "changed" nor "changes"
78+
* don't capitalize the first letter
79+
* no dot (.) at the end
80+
81+
### Body
82+
83+
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
84+
The body should include the motivation for the change and contrast this with previous behavior.
85+
86+
### Footer
87+
88+
The footer should contain any information about **Breaking Changes** and is also the place to
89+
reference GitHub issues that this commit **Closes**.
90+
91+
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
92+
93+
```
94+
feat!: breaking change / feat(scope)!: rework API
95+
```

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CI
2+
3+
on: [pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Setup Continuous integration
14+
uses: ./.github/cache
15+
16+
- run: pnpm run lint && pnpm run build

.github/workflows/prepublish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish Any Commit
2+
3+
on: [pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
pr-release:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Setup Continuous integration
15+
uses: ./.github/cache
16+
17+
- name: Enable corepack
18+
run: corepack enable
19+
20+
- name: Build
21+
run: pnpm run build
22+
23+
- name: Release for Pull request
24+
run: pnpx pkg-pr-new publish

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Setup Continuous integration
20+
uses: ./.github/cache
21+
22+
- run: pnpm run publish
23+
env:
24+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
25+
26+
- run: pnpm dlx changeloggithub@latest
27+
env:
28+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.DS_Store
2+
3+
.idea/
4+
5+
.pnp.cjs
6+
.pnp.loader.mjs
7+
8+
node_modules
9+
coverage
10+
dist
11+
.junit
12+
out
13+
*.d.ts
14+
*.tgz
15+
16+
node_modules
17+
dist
18+
coverage
19+
.idea
20+
dev-dist
21+
docs/.vitepress/cache
22+
.vercel
23+
.vite-inspect
24+
25+
.DS_Store
26+
.pnpm-debug.log*
27+
.eslintcache

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.nvmrc

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

.vscode/settings.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"editor.tabSize": 2,
3+
"editor.rulers": [100],
4+
5+
"git.ignoreLimitWarning": true,
6+
"editor.quickSuggestions": {
7+
"strings": true
8+
},
9+
10+
"workbench.tree.indent": 14,
11+
"workbench.tree.renderIndentGuides": "always",
12+
"workbench.colorCustomizations": {
13+
"tree.indentGuidesStroke": "#b7b7b7"
14+
},
15+
16+
// Disable the default formatter, use eslint instead
17+
"prettier.enable": false,
18+
"editor.formatOnSave": true,
19+
20+
// Auto fix
21+
"editor.codeActionsOnSave": {
22+
"source.fixAll.eslint": "explicit",
23+
"source.organizeImports": "never"
24+
},
25+
26+
// Silent the stylistic rules in you IDE, but still auto fix them
27+
"eslint.rules.customizations": [
28+
{ "rule": "style/*", "severity": "off" },
29+
{ "rule": "*-indent", "severity": "off" },
30+
{ "rule": "*-spacing", "severity": "off" },
31+
{ "rule": "*-spaces", "severity": "off" },
32+
{ "rule": "*-order", "severity": "off" },
33+
{ "rule": "*-dangle", "severity": "off" },
34+
{ "rule": "*-newline", "severity": "off" },
35+
{ "rule": "*quotes", "severity": "off" },
36+
{ "rule": "*semi", "severity": "off" }
37+
],
38+
39+
// Enable eslint for all supported languages
40+
"eslint.validate": [
41+
"javascript",
42+
"javascriptreact",
43+
"typescript",
44+
"typescriptreact",
45+
"vue",
46+
"html",
47+
"markdown",
48+
"json",
49+
"jsonc",
50+
"yaml"
51+
]
52+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 opensource
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# js-utils-es
2+
3+
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
4+
5+
Documentation is available at [https://js-utils-es.vercel.app](https://js-utils-es.vercel.app).
6+
7+
## Installation
8+
9+
```sh
10+
npm install js-utils-es
11+
```
12+
13+
## Development
14+
15+
- Clone this repository
16+
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
17+
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
18+
- Install dependencies using `pnpm install`
19+
- Run interactive tests using `pnpm dev`

benchmarks/camelCase.bench.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { bench, describe } from 'vitest';
2+
import { camelCase as camelCaseToolkit } from 'js-utils-es';
3+
import { camelCase as camelCaseLodash } from 'lodash';
4+
5+
describe('camelCase', () => {
6+
bench('js-utils-es/camelCase', () => {
7+
const str = 'kebab-case';
8+
camelCaseToolkit(str);
9+
});
10+
11+
bench('lodash/camelCase', () => {
12+
const str = 'kebab-case';
13+
camelCaseLodash(str);
14+
});
15+
});

benchmarks/capitalize.bench.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { bench, describe } from 'vitest';
2+
import { capitalize as capitalizeToolkit } from 'js-utils-es';
3+
import { capitalize as capitalizeLodash } from 'lodash';
4+
5+
describe('capitalize', () => {
6+
bench('js-utils-es/capitalize', () => {
7+
const str = 'camelCase';
8+
capitalizeToolkit(str);
9+
});
10+
11+
bench('lodash/capitalize', () => {
12+
const str = 'camelCase';
13+
capitalizeLodash(str);
14+
});
15+
});

benchmarks/chunk.bench.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { bench, describe } from 'vitest';
2+
import { chunk as chunkToolkit } from 'js-utils-es';
3+
import { chunk as chunkLodash } from 'lodash';
4+
5+
describe('chunk', () => {
6+
bench('js-utils-es/chunk', () => {
7+
chunkToolkit([1, 2, 3, 4, 5, 6], 3);
8+
});
9+
10+
bench('lodash/chunk', () => {
11+
chunkLodash([1, 2, 3, 4, 5, 6], 3);
12+
});
13+
});

benchmarks/clamp.bench.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { bench, describe } from 'vitest';
2+
import { clamp as clampToolkit } from 'js-utils-es';
3+
import { clamp as clampLodash } from 'lodash';
4+
5+
describe('clamp', () => {
6+
bench('js-utils-es/clamp', () => {
7+
clampToolkit(10, 5, 15);
8+
clampToolkit(10, 5);
9+
});
10+
11+
bench('lodash/clamp', () => {
12+
clampLodash(10, 5, 15);
13+
clampLodash(10, 5);
14+
});
15+
});

0 commit comments

Comments
 (0)