Socket
Socket
Sign inDemoInstall

@fallen_leaves/fe-utils

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @fallen_leaves/fe-utils

前端工具函数库


Version published
Maintainers
1
Install size
136 kB
Created

Readme

Source

@fallen_leaves/fe-utils

前端通用工具库

优点:提高前端业务代码开发效率,增强代码复用性

前端开发过程中,会经常用到判断浏览器类型格式化各种日期获取url参数queryString转对象防抖函数节流函数等常用函数,为避免不同项目多次复制粘贴的麻烦,这里统一封装,并发布到npm,以提高开发效率。

安装

  npm install --save @fallen_leaves/fe-utils
  # or
  yarn add @fallen_leaves/fe-utils

使用

  # 完整导入
  import FeUtils from '@fallen_leaves/fe-utils'

  FeUtils.getCookie('user_id')
  # or

  # 模块导入
  import { getCookie } from '@fallen_leaves/fe-utils'

  getCookie('user_id')

API文档

Color

  • hexToRGB  16进制颜色值转rgb格式
  • RGBToHex  16进制颜色值转rgb格式

Device

Dom

Function

Number

Object

Regexp

  • RegCollections  常用正则判断函数
    • .isUrl(url)  判段目标字符串是否为url
    • .isPhoneNumber(phoneNumber)  判段目标字符串是否为手机号
    • .isEmail(email)  判段目标字符串是否为邮箱
    • .isIDCard(IDCard)  判段目标字符串是否为身份证号码
    • .isZipCode(zipCode)  判段目标字符串是否为邮政编码
    • .isIE()  判段是否为IE
    • .isChrome()  判段是否为Chrome
    • .isFirefox()  判段是否为Firefox
    • .isOpera()  判段是否为Opera
    • .isSafari()  判段是否为Safari
    • .isEdge()  判段是否为Edge
    • .isAndroid()  判段是否为Android
    • .isIPhone() 判段是否为iPhone
    • .isIPad()  判段是否为iPad
    • .isMacOS()  判段是否为MacOS
    • .isWindows()  判段是否为Windows
    • .isLinux()  判段是否为Linux
    • .isWeChat()  判段是否为微信环境

Time

Url

String

  • urlToLink  目标字符串中的url串转换为<a>标签

Keywords

FAQs

Last updated on 11 Jan 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc