npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

common-screw

v1.3.1

Published

提供项目中常用的工具函数,比如时间戳、格式的转换、数据类型判断等。如名字screw一样,做一个项目开发过程中的螺丝钉。

Downloads

58

Readme

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