Giter Club home page Giter Club logo

javascript-utils's Introduction

JavaScript Utils Node.js CI

常用工具函数

安装

$ yarn add @xuanmo/javascript-utils

使用

import { debounce } from '@xuanmo/javascript-utils'

// 全量引用
// import * as utils from '@xuanmo/javascript-utils'

已有方法

工具名 描述 Nodejs 可用
realType 获取数据真实类型
isObject 是否为对象
isRegexp 是否为正则表达式
isFunction 是否为函数
isImageUrl 判断 url 是否为图片路径
isNumber 是否为纯数字
isEmpty 是否为空
toBoolean 转换 string 布尔值
toLowerCamelCase 下划线转小驼峰
toUnderline 小驼峰转下划线分割
formatThousandth 数字千分位
countDown 倒计时
debounce 防抖
deepCopy 深拷贝
searchParams 获取 URL 单个查询参数
formatQueryParams 获取 URL 全部查询参数
createRandomID 生成随机 ID
objectKeyToCamelCase Object key 转换为小驼峰
ua navigator.userAgent 进行解析
dCookie cookie 操作
generateTree 一维数组转树形数据

ua 示例

import { ua } from '@xuanmo/javascript-utils'
console.log(ua())
// console.log(ua('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36'))
// {
//   "browser": "Chrome",
//   "browserZH": "Chrome",
//   "browserVersion": "96.0.4664.93",
//   "os": "Macintosh",
//   "osVersion": "10.15.7",
//   "device": "PC",
//   "engine": "WebKit"
// }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.