A business-oriented JavaScript/TypeScript utility library.
import { md5 } from 'vtils'
console.log(md5('龙'))
// => 682570a229cbd3d67e76ad99b3152060
🙅♀️Rejection of repetition : Based on community high-quality libraries ( Lodash , date-fns , react-use , type-fest , ts-essentials , yup, etc.), supplement common business codes.
🌸Sophisticated and elegant : comments and tests are added for each tool, and can be used directly without looking at the documentation.
🌈Facing the future : written in TypeScript , supports Tree Shaking , ECMAScript Modules , and can also be used in Taro 3 and Deno .
## npm
above sea level and vtils
## yarn
yarn add vtils
## pnpm
pnpm add vtils
If you are in China, it is recommended to install tbify and use Taobao mirror acceleration:
## npm
tnpm i vtils
## yarn
tyn add vtils
## pnpm tpm
add vtils
// master tool library
Import { the wait , isNumber , EventBus , Base64Encode } from 'vtils'
Date Time tool magazine //
Import { formatRelative , subDays , zhCN } from 'vtils / DATE'
// React 工具库
import { useClassName, useToggle, useScrollLoadMore } from 'vtils/react'
Verification tool magazine //
Import { Yup } from 'vtils / Validator'
Type tool magazine //
Import { OmitStrict , LiteralUnion , PartialDeep } from 'vtils / types'
Toolkit applet //
Import { getTopBarInfo , navigatePageTo , redirectPageTo } from 'vtils / MP'
See the document for detailed usage: https://fjc0k.github.io/vtils/v3/ .
In Taro 3 need to modify the configuration Webpack before use, in config/index.js
the mini
settings field:
mini: {
webpackChain ( config ) {
// This plugin will affect the performance of resolve.extensions, delete
config . resolve . plugins . delete ( 'MultiPlatformPlugin' )
// support .taro.js suffix
config . resolve . extensions . prepend ( '.taro.js' )
} ,
}
Then, you can use it happily:
// React tool magazine
Import { useSearchParam } from 'vtils / REACT'
// Taro 3 tools Hyogo
import { UseTopBarInfo } from 'Vtils / taro'
export default function ( ) {
const id = + useSearchParam ( 'id' ) !
const topBarInfo = useTopBarInfo , ( ),
// ...
},
Only basic tool library and type tool library are currently supported under Deno .
// master tool library
Import {
the wait ,
isNumber ,
EventBus ,
Base64Encode ,
} from 'https://cdn.skypack.dev/vtils@3.44.1'
Type tool magazine //
Import {
OmitStrict ,
LiteralUnion ,
PartialDeep ,
} from 'https://cdn.skypack.dev/vtils@3.44.1/types'
Author: fjc0k
Demo: https://fjc0k.github.io/vtils/v3/
Source Code: https://github.com/fjc0k/vtils
#deno #nodejs #node #javascript