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

util-es

v1.0.4

Published

js工具集

Downloads

1

Readme

util-es

JavaScript常用方法

非常抱歉, 因操作失误导致npm上v0.1.10以前版本全都没了, 之后的版本完全兼容以前的写法, 请放心食用 orz

使用方法

通过npm安装

npm i util-es
import Util from 'util-es'
import { isEmpty, Session } from 'util-es'

const Util = request('util-es')

通过<script>标签引用

util.min.js

此方法是向window对象中注册一个 util 对象

规则

  • 驼峰命名的为方法
  • 首写字母大写为对象

对象

对象名 | 描述 ---|--- Session | 对sessionStorage的封装 Local | 对localStorage的封装 Cookie | 对document.cookie的封装

Session & Local
  • 可以直接存储{}[]
  • 可以设置过期时长

方法 | 描述 ---|--- Session.get(String key) | 获取对应key的session Session.set(String key, * value, Number second) | 设置session, second(非必传 单位: 秒) Session.remove(String key) | 移除对应key的session Session.key(Number key) | 获取对应索引的键名 Session.clear() | 移除所有session

Local的方法与Session一致

:exclamation::exclamation:使用Session & Local存储对象时, 请勿使用$$ExpiryTime作为属性,这是设置过期时间的关键字

Cookie

单纯的对cookie封装, 仅支持存储字符串和设置时间 方法 | header 2 ---|--- get(String key) | 获取对应key的Cookie set(String key, * value, Number second) | 设置Cookie, second(非必传 单位: 秒) remove(String key) | 移除对应key的Cookie

方法

方法 | 描述 ---|--- isEmpty(* param) | 判断传入数据是否为空字符或对象 ( {} [] Map Set), 返回 Boolean isObject(* param) | 判断传入数据是否为对象 ( 不包含nullundefined ), 返回 Boolean uuid(Boolean bar) | 生成并返回一个uuid ( bar:是否带 -,默认false )

其他

有问题欢迎交流, 轻喷 :bow:

欢迎PR或提交issues :smiley:

License

This project is licensed under the MIT License