1.3.1 • Published 6 months ago

common-screw v1.3.1

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

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

1.2.8

10 months ago

1.2.7

10 months ago

1.3.1

6 months ago

1.3.0

10 months ago

1.2.9

10 months ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.2.4

2 years ago

1.1.5

2 years ago

1.2.3

2 years ago

1.1.4

2 years ago

1.2.2

2 years ago

1.1.3

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago