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

bahuang_utils

v1.0.3

Published

个人在项目中常用的一些方法,在此做一个分享 ### cookie相关 ``` /** 依赖于 js-cookie 方法: */ // 获取 cookie getCookie(name) // 设置 cookie setCookie(name, value) // 删除 cookie removeCookie(name) ```

Downloads

6

Readme

个人在项目中常用的一些方法,在此做一个分享

cookie相关

    /**
    依赖于 js-cookie
    方法:
    */
    // 获取 cookie
    getCookie(name)
    // 设置 cookie
    setCookie(name, value)
    // 删除 cookie
    removeCookie(name)

日期操作相关

    /*
    *日期转字符串
    * now 为时间
    * flag 为格式
    *   1: YYYY-MM-DD
    *   2: HH:mm
    *   3: YYYY-MM-DD HH:mm
    *   4: YYYY-MM-DD HH:mm:ss
    **/
    dateToStr(now, flag)
    
    // 获取当前时间 时分秒
    getCurTime()
    
    // 获取当前日期 年月
    getCurDate()
    
    // 获取当前周 周几
    getCurWeek()
    
    // 获取当前时间 年月日 时分秒 周几
    getCurDateTimeWeek()
    
    // 用选中的时间获取周一和周日的函数(含时分秒)=>返回一个包含起止时间的数组
    getWeekList(val)
    
    // 用选中的时间获取月初和月末的函数(含时分秒)=>返回一个包含起止时间的数组
    getMonthList(val)
    
    // 用选中的时间获取季度第一天和季度最后一天的函数(含时分秒)=>返回一个包含起止时间的数组
    getSeasonList(val)
    
    // 用选中的时间,来求的是这一年的第几周
    getWeekNum(val)

存储相关

    // 本地缓存存储
    localStorageSet(name, obj)
    
    // 本地缓存获取
    localStorageGet(name)
    
    // 本地缓存删除
    localStorageRemove(name)
    
    // 会话缓存 存储
    sessionStorageSet(name, obj)
    
    // 会话缓存 获取
    sessionStorageGet(name)

安全回显

    // 依赖于 xss
    getSafeText(input)

类型判断

    // string, number, symbol, boolean 判断是否是 primitive 基本数据类型
    isPrimitive(value)
    
    // undefined and null
    isUndef(v)
    
    // not undefined not null
    isDef(v)

    // true
    isTrue(v)
    
    // false
    isFalse(v)
    
    // 是否是对象类型 包含数组
    isObject(obj)
    
    hasOwn(obj, key)
    
    // 是否是 明确的javascript 对象
    isPlainObject(obj)
    
    // 是否是 正则
    isRegExp(v)

类型转换

    // 转化为数组
    toArray(list, start)
    
    // 对象的扩展
    extend(to, _from)
    
    // 转换为 对象
    toObject(arr)
    
    // 转化为数字
    toNumber(val)
    
    // 转化微字符串
    toString(val)

模块整合

    // obj 参数是 通过 import 的模块对象 import * as obj from 'target/module'
    mergeModule(obj)