Skip to content

Commit

Permalink
perf: remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-jerry committed Dec 5, 2023
1 parent 809bbaa commit 1810cfb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
],
"devDependencies": {
"@0x-jerry/x-release": "^0.4.0",
"@types/lodash-es": "^4.17.9",
"@types/minimist": "^1.2.2",
"@types/node": "^20.6.2",
"@vitest/coverage-v8": "^1.0.0",
Expand All @@ -37,7 +36,6 @@
},
"dependencies": {
"@0x-jerry/utils": "^2.0.0",
"lodash-es": "^4.17.21",
"minimist": "^1.2.8"
}
}
20 changes: 0 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ TODO

- [vitest](https://vitest.dev/)
- [minimist](https://github.com/minimistjs/minimist)
- [lodash](https://lodash.com)
- [tsup](https://tsup.egoist.dev)
5 changes: 2 additions & 3 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import {
type CmdAction,
ProgramFlag,
} from './types'
import { builtinType, isType, splitFirst } from './utils'
import { uniqueId } from 'lodash-es'
import { autoIncrement, builtinType, isType, splitFirst } from './utils'

const TOKEN_ID_PREFIX = '__token_id__'
const nextId = () => uniqueId(TOKEN_ID_PREFIX)
const nextId = autoIncrement(TOKEN_ID_PREFIX)

const tokenIdReg = new RegExp(`${TOKEN_ID_PREFIX}\\d+`, 'g')

Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ export function isType(targetType: string | undefined, type: string | string[])
export function isBuiltinType(type?: string) {
return Object.values(builtinType).flat().includes(type!)
}

export function autoIncrement(prefix = 'i') {
let i = 1;
return () => `${prefix}${i++}`
}

0 comments on commit 1810cfb

Please sign in to comment.