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

f2e-tools

v0.0.10-1

Published

javascript tools RegExp number math type scroll copy

Downloads

25

Readme

f2e-tools

Common front-end tools

Install

npm install f2e-tools --save

Use

const tool = require('f2e-tools').default
// OR
import tool from 'f2e-tools'

tool.*

点击查看详细文档

Math

.add(...number)                    // add               :: (...number) -> number
.addition(num1, num2)              // addition          :: (number, number) -> number
.subtract(...number)               // subtract          :: (...number) -> number
.subtraction(num1, num2)           // subtraction       :: (number, number) -> number
.multiply(...number)               // multiply          :: (...number) -> number
.multiplication(num1, num2)        // multiplication    :: (number, number) -> number
.divide(...number)                 // divide            :: (...number) -> number
.division(num1, num2)              // division          :: (number, number) -> number
.round(num, ?round = 2)            // round             :: (number, number = 2) -> number

Amount

// number2Amount :: (number, string = '0,0', string = 'M/A') -> string
.number2Amount(num, ?temp = '0,0', ?nullFormat = 'N/A', ?zeroFormat = 'N/A')
.amount2Number(amount)                    // amount2Number            :: string -> number
.number2Percentage(num)                   // number2Percentage        :: number -> string
.percentage2Number(percentage)            // percentage2Number        :: string -> number
.amount2Chinese(amount)                   // amount2Chinese           :: number -> string
.number2Chinese(num)                      // number2Chinese           :: number -> string
.number2ChineseWithOption(opts, ?number) // number2ChineseWithOption :: (object, ?number) -> function | string

Page

.scroll2Top(?DOM = window)                   // scroll2Top         :: (document = window) -> undefined
.scroll2Bottom(?DOM = window)                // scroll2Bottom      :: (document = window) -> undefined
.isScrollTop(?DOM = window)                  // isScrollTop        :: (document = window) -> boolean
.isScrollBottom(?DOM = window, ?limit = 0.1) // isScrollBottom     :: (document = window, number = 0.1) -> boolean
.scrollTopByStep(step, ?DOM = window)        // scrollTopByStep    :: (number, document = window) -> number
.scrollBottomByStep(step, ?DOM = window)     // scrollBottomByStep :: (number, document = window) -> number
.toFullScreen()                              // toFullScreen       :: any -> boolean
.exitFullScreen()                            // exitFullScreen     :: any -> boolean
.print(?opts)                                // print              :: object -> undefined
.createElement(str)                          // createElement      :: string -> element
.copyToClipboard(str)                        // copyToClipboard    :: string -> promise
.preventScroll()                             // preventScroll      :: any -> undefined | number
.recoverScroll()                             // recoverScroll      :: any -> undefined | number
.disableSelect(?DOM = document)              // disableSelect      :: ?document -> undefined
.disableContextMenu(?DOM = document)         // disableContextMenu :: ?document -> undefined
.disableCopy(?DOM = document)                // disableCopy        :: ?document -> undefined
.getSelectText()                             // getSelectText      :: any -> string

RegExp

.REGEXP_PHONE               // 手机号
.REGEXP_EMAIL               // 电子邮箱
.REGEXP_CN_CHARACTERS       // 中文字符
.REGEXP_EN_CHARACTERS       // 英文字符
.REGEXP_UPPER_EN_CHARACTERS // 大写英文字符
.REGEXP_DBCS                // 双字节字符
.REGEXP_POSITIVE_INT        // 正整数
.REGEXP_NEGATIVE_INT        // 负整数
.REGEXP_NON_NEGATIVE_INT    // 非负整数
.REGEXP_NON_POSITIVE_INT    // 非正整数
.REGEXP_POSITIVE_NUMBER     // 正数
.REGEXP_NUMBER              // 实数
.REGEXP_NON_NEGATIVE_FLOAT  // 非负浮点数
.REGEXP_NON_POSITIVE_FLOAT  // 非正浮点数
.REGEXP_POSITIVE_FLOAT      // 正浮点数
.REGEXP_NEGATIVE_FLOAT      // 负浮点数
.REGEXP_FLOAT               // 浮点数
.REGEXP_EN_NUM              // 英文 + 数字
.REGEXP_PASS_COMPLEX[4][9]  // 复杂密码(包含大小写字母,数字,特殊字符)特殊调用方式,见详细文档
.REGEXP_PASS_MODERATE[3][8] // 中等密码(包含大小写字母,数字)特殊调用方式,见详细文档
.REGEXP_URL                 // URL 地址
.REGEXP_IPV4                // IPv4 地址
.REGEXP_IPV6                // IPv6 地址
.REGEXP_IP                  // IPv4 或 IPv6 地址
.REGEXP_DATE                // 日期 YYYY-MM-dd 或 YYYY/MM/dd
.REGEXP_TIME_12             // HH:mm 12小时制
.REGEXP_TIME_24             // HH:mm 24小时制
.REGEXP_AMOUNT_OF_MONEY     // 匹配金额(包含千分符)
.REGEXP_HTML_TAG            // 匹配 HTML 标签
.REGEXP_REPEAT_STR            // 匹配重复字符串
.REGEXP_LNG_LAT             // 经纬度
.REGEXP_ID_CARD             // 身份证
.REGEXP_POSTCODE            // 邮编
.REGEXP_FILE_PATH           // 带有后缀名的文件路径
.REGEXP_HEX                 // 匹配 HEX 颜色值
.REGEXP_SLUG                // 匹配 slug 字符串
.REGEXP_PLATES              // 车牌号
.REGEXP_IS_IE               // 从 UA 判断是否为 IE 浏览器
.REGEXP_IS_WEBKIT           // 从 UA 判断是否为 webkit 内核
.REGEXP_IS_CHROME           // 从 UA 判断是否为 chrome 浏览器
.REGEXP_IS_FIREFOX          // 从 UA 判断是否为 firefox 浏览器
.REGEXP_IS_OPERA            // 从 UA 判断是否为 opera 浏览器
.REGEXP_IS_SAFARI           // 从 UA 判断是否为 safari 浏览器
.REGEXP_IS_ANDROID          // 从 UA 判断是否为 Android 系统
.REGEXP_IS_IPAD             // 从 UA 判断是否为 iPad
.REGEXP_IS_IPHONE           // 从 UA 判断是否为 iPhone
.REGEXP_IS_MAC              // 从 UA 判断是否为 Mac OS 平台
.REGEXP_IS_WINDOWS          // 从 UA 判断是否为 Windows 平台
.REGEXP_IS_WX               // 从 UA 判断是否为微信浏览器
.REGEXP_IS_MOBILE           // 从 UA 判断是否为移动终端

Type


.isString    // isString    :: any -> boolean
.isNumber    // isNumber    :: any -> boolean
.isNaN       // isNaN       :: any -> boolean
.isFinite    // isFinite    :: any -> boolean
.isInteger   // isInteger   :: any -> boolean
.isBigInt    // isBigInt    :: any -> boolean
.isFloat     // isFloat     :: any -> boolean
.isBoolean   // isBoolean   :: any -> boolean
.isUndefined // isUndefined :: any -> boolean
.isSymbol    // isSymbol    :: any -> boolean
.isFunction  // isFunction  :: any -> boolean
.isObject    // isObject    :: any -> boolean
.isArray     // isArray     :: any -> boolean
.isNull      // isNull      :: any -> boolean
.isHTML      // isHTML      :: any -> boolean
.isMap       // isMap       :: any -> boolean
.isSet       // isSet       :: any -> boolean
.isEmpty     // isEmpty     :: any -> boolean

Other


.hideMiddlePhoneNumber(phoneNumber, ?replaceStr = '*') // hideMiddlePhoneNumber :: (number | string, string = '*') -> string
.hideFrontNumber(phoneNumber, ?replaceStr = '')        // hideFrontNumber       :: (number | string, string = '') -> string
.outOfNumber(number, max = 99)                         // outOfNumber           :: (number, number) -> string | number
.hideLastName(name, replaceStr = '*')                  // hideLastName          :: (string, string = '*') -> string
.hideFirstName(name, gender)                           // hideFirstName          :: (string, number) -> string