common-screw v1.3.1
English | 简体中文
Front-end business code tool library
Provide the commonly used tool functions in the project, such as timestamp
, conversion of format
, data type judgment
, throttling function
, etc. Like the name screw, be a screw in the project development process.
Purpose: complete front-end business code efficiently
To avoid the trouble of copying and pasting many times for different projects, the common functions in the business development process are encapsulated here and released to npm to improve development efficiency.
Install
npm i common-screw
yarn add common-screw
Demand Loading
Default support for ES Modules-based Tree Shaking
import { randomBoolean, isArray, addDaysToDate } from "common-screw"
randomBoolean() // false
isArray(3) // false
isArray([1, 2]) // true
addDaysToDate("2020-10-15", -10) // 2020-10-05
Module loading
import {
CSBrowser,
CSDate,
CSDown,
CSFormat,
CSFunction,
CSLang,
CSRandom,
CSRegexp
} from "common-screw"
CSDate.addDaysToDate("2021-10-15", -10) // 2021-10-05
CSRandom.randomBoolean() // false
:package: API Documentation
CSBrowser (Browser Class Methods)
copyToClipboard Copy to clipboard
getUrlParam Get the parameters of the URL
isBrowser Check is browser environment
toUrlEncode Object to URL parameter
url Operation URL
CSDate (Date Class Methods)
addDaysToDate Date plus days before and after
addMinutesToDate Minutes before and after addition
dateToTimestamp Date to Timestamp
diffTime Date interval
formatDate Format date
getNow Get current date
timestampToDate Timestamp to Date
timestampToDateNoTime Timestamp to Date And noTime
CSDevice (Device Class Methods)
getOS Operating system type
isMobile Is mobile
isSupportCamera Whether to support the camera
isWeiXin Is WeChat
CSDown (Down Class Methods)
downToCsv Download csv
downToXlsx Download xlsx
downUrl Download file from URL
CSFormat (Format Class Methods)
addUnit Add unit after the number
getObjKey Get object properties
toEnum Array => Object
toEnumArray Objects => Array
toFixed Retain decimal points (not rounded)
toString String conversion
CSFunction (Function Class Methods)
debounce Debounce
deepClone DeepClone
throttle Throttle
CSLang (Lang Class Methods)
common Common format judgments
isNil Determine the type - is empty
CSProject (Project Class Methods)
toMenuData Format the menu data
CSRandom (Random Class Methods)
randomBoolean Random Generation Boolean
randomNum Generate a random number in the specified range min, max.
CSRegexp (Regexp Class Methods)
regList Common format rules
toRule Determines if the format is specified
CSStorage (Storage Class Methods)
storage Modify localStorage,set expiration time
CSString (String Class Methods)
getEscapeString Escape of strings
getUnEscapeString Unescape of strings
10 months ago
10 months ago
6 months ago
10 months ago
10 months ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago