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

uke-base

v1.0.21

Published

uke base.js

Downloads

12

Readme

#uke-base 基础核心库

##基本API

###amountHelper @description 数量除以100 @param {number} amount 数量 @param {number} decimals 小数位数 @returns {string} @example AmountHelper.centiAmount(100) 返回值 1.00


###encryption charCodeAt 简单加密 非md5

    字符串解密
deEncryption(String) 

    字符串加密
encryption(String) 

###numberFormat 数字处理 格式化手机号码: xxx-xxxx-xxxx formatMobilePhone(number)

    格式化显示IMEI号码 xxxx-xxxx-xxxx-xxx
    formatIMEI(number)

    分隔字符串
        @param {string|number} str 字符串
        @param {number} separateLength 分隔长度
        @param {string} separator 分隔符
        @returns {string}
separateString(str, separateLength, separator)

###store localStorage和sessionStorage简单封装 存储对象 localSave(key, value)

    获取对象
localGet(key)  

    获取本地存储的长度
localSize()  

    根据键删除本地存储
localDelete(key)  

    清空本地存储
localClear()  

    存储session对象
sessionSave(key, value)  

    获取session对象
sessionGet(key)  

    获取session存储的长度
sessionSize()  

    根据键删除session存储
sessionDelete(key)  

    清空session存储
sessionClear()  

    设置cookie值
    @param name 名称
    @param value 名称对应值
    @param Hours 过期时间
setCookie(name, value, Hours)

    获取cookie值
    @param name cookie名
    @returns {*}
getCookie(name)

    删除cookie
    @param name cookie name
delCookie(name)

###timeFormat

    获取当前浏览器的时区
getBrowserGMT()  

    获取当前浏览器时区的修正
getDateZoneOffset()


    转换时间long格式到yyyy-mm-dd hh-MM-ss
    d long格式数据
    ks 时区
getFormatTime(d, ks)

      转换时间yyyy-mm-dd hh-MM-ss格式到long
formatTimeTolong(datetime, ks)

     今天的时间戳
getToday()

     今天的时间格式 yyyy-mm-dd hh-MM-ss
getTodayFormat()

     今天的时间格式 yyyy-mm-dd
getTodayFormatShort()

     今天加减n天的时间戳
getDayNearToday(day)

     今天加减n天的时间格式 yyyy-mm-dd hh-MM-ss
getDayNearTodayFormat(day)

     今天加减n天的时间格式 yyyy-mm-dd
getDayNearTodayFormatShort(day)

    转化日期字符串为时间戳
parseDateStr(dtStr)

    转换时间到其他时区的时间
    convertDatetime(1495238400000, 8, 'yyyy-MM-dd HH:mm:ss', true) 返回值 "2017-05-20 08:00:00 GMT+0800"
    withGMT 返回值是否带时区标识 默认为false, 时区标识 Chrome/Edge 支持, Firefox不支持 
    new Date("017-05-20 08:00:00 GMT+0800")
    convertDatetime(dt, targetTimezone = 0, format = 'yyyy-MM-dd HH:mm:ss', withGMT = false) 

    浏览器时间和UTC时间的偏移量(毫秒数)
getTimezoneOffset()


    @description 通用格式化时间方法
    @param {string} format 'yyyy-MM-dd HH:mm:ss.uuu' 时间格式
        yyyy年 MM月 dd日 HH时 mm分 ss秒 uuu毫秒
    @param {number|Date|undefined|string|mixed} dt dateTime 
    可以为 时间戳|Date对象|undefined|表示日期时间的字符串
    @returns {string}
    @throws {string}
    @example
        timeFormat.formatDateTime('yyyy-MM-dd', '2017-05-20 00:00:00') 
        返回值 "2017-05-20"
        timeFormat.formatDateTime('yyyy-MM-dd HH:mm:ss.uuu', 1495209600000) 
        返回值 "2017-05-20 00:00:00.000"
        timeFormat.formatDateTime('yyyyMMdd', 'Sat May 20 2017') 
        返回值 "20170520"

formatDateTime(format, dt)

###util

    数组根据其中某个值进行冒泡排序
    @param {object} dataList 数组
    @param {object} k 排序基准值
    @param {object} desc 升序还是降序排序
    @return {undefined || array} 数组的值或者为空
 
arraySortByTag(dataList, k, desc)     


    根据值移除数组中的某个元素(仅仅真的非复杂对象的数组)
    @param {array} dataList 数组
    @param {string} value 值
    @return {array} 数组的值

arrRemoveByValue(dataList, value)

    异步等待功能,主要解决一下数据同步的问题,后续有可能的话可能需要对此方法进行改进
    @param {function} fn 需要重置的对象
    @return {Promise} Promise 对象

wait(fn)

    判断是否是数字
IsNumeric(txt)  

    数组去重
    @param thisArr 需要去重的数组
    @retrun {array}去重后的新数组
unique(thisArr)    

    通过key获取url中的参数值
    @param key
    @returns {string}

getQueryString(key)

    判断非空
    @param obj
    @returns {boolean}
isEmpty(obj)

    区间随机数
    @param low 开始
    @param high 结束
    @return {number} 随机数
randInt(low, high)

    判断变量的数据类型
    @param obj 变量
    @return{string}
    map = {
        '[object Boolean]': 'boolean',
        '[object Number]': 'number',
        '[object String]': 'string',
        '[object Function]': 'function',
        '[object Array]': 'array',
        '[object Date]': 'date',
        '[object RegExp]': 'regExp',
        '[object Undefined]': 'undefined',
        '[object Null]': 'null',
        '[object Object]': 'object'
    };

typeOf(obj) 

    深度克隆
    @param obj  需要克隆的对象
    @retrun _obj 克隆后对象
deepCopy(obj)

    判断对象是否为空
    @param obj
    @return {boolean}
isEmptyObject(obj)

    页面跳转工具,加当前时间戳参数
    使用方式 url(‘url地址’,{ 参数1:参数值1,参数2:参数值2 })
    会直接跳转
RedirectUrl(url,{key:111,key1:222})