handle-tool
v1.0.0
Published
A collection of commonly used tool functions
Downloads
4
Maintainers
Readme
A collection of commonly used tool functions, including:
- Verify data type
- Anti shake
- Throttling
- Phone number desensitization
- Enable full screen
- Turn off full screen
- Case conversion
Install it
pnpm install handle-tool
Specific usage:
- Verify data type
import { typeOf } from 'handle-tool';
typeOf([]); // array
typeOf(new Date()); // date
typeOf(null); // null
typeOf(true); // boolean
typeOf(() => {}); // function
//[{id: 1, name: 'noah', age: 18]
- Anti shake
import { debounce } from 'handle-tool';
const loadList = () => {
debounce(() => {
console.log('Loading Data');
}, 500);
};
loadList();
//[{id: 1, a: 123, b: 1234, boo: true},{id: 2, a: 123, b: 1234, boo: false}]
- Throttling
import { throttle } from 'handle-tool';
- Phone number desensitization
import { hideMobile } from 'handle-tool';
hideMobile('13788895634');
// 137****5634
- Enable full screen
import { launchFullscreen } from 'handle-tool';
- Turn off full screen
import { exitFullscreen } from 'handle-tool';
- Case conversion
import { turnCase } from 'handle-tool';
// Str string to be converted
// Type 1- All uppercase 2- All lowercase 3- First letter uppercase
turnCase('react', 1); // REACT