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

es.shim

v2.2.2

Published

实现部分新API, 以及一些常用的扩展方法

Downloads

706

Readme

downloads version

es.shim

es.shim 提供了部分新API, 以及一些常用的扩展方法。具体如下:

├── Obejct
│   └── .empty(any)    // 判断对象是否为空对象
│   └── .groupBy(arr, fn)    // 数组分组, 返回分组后的对象
│   └── .hasOwn(any, key)    // 安全版的 Object.prototype.hasOwnProperty()
├── Obejct.prototype
│   └── .toParams()    // 把对象转为 key1=value1&key2=value2 格式
│
├── Map
│   └── .groupBy(any)    // 数组分组, 返回分组后的对象
│
├── Array.prototype
│   ├── .flat(depth)    // 数组降维
│   ├── .flatMap(fn)    // 等价于 map(fn) -> flat(1)
│   ├── .at(index)    // 读取指定位置的元素, 负值则从后往前读
│   ├── .findLast(fn)    // 查找匹配的最后一项
│   ├── .findLastIndex(fn)    // 查找匹配的最后一项的索引值
│   ├── .toSorted(fn)    // 数组排序, 返回一个副本(不改变原数组)
│   ├── .toReversed(fn)    // 反转数组, 同样返回一个副本
│   ├── .toSpliced(fn)    // 数组截取, 同样返回副本
│   ├── .with(index, newValue)    // 创建一个副本,再修改副本中的元素, 返回副本 
│   ├── .group(fn)    // 数组分组
│   └── .groupToMap(fn)    // 数组分组, 返回Map对象
│
├── Date
│   └── .isDate(any)    // 判断对象是否为 日期对象
├── Date.prototype
│   ├── .getWeek()    // 获取当前是本月第几周
│   ├── .getFullWeek()    // 获取当前是本年度第几周
│   └── .format(formatStr)    // 把日期按指定格式转换
│
├── String.prototype
│   ├── .splice(index, len, pad)    // 类似数组的splice方法
│   ├── .htmlspecialchars()    // 字符串HTML安全转义
│   ├── .tohtml()    // htmlspecialchars的还原
│   ├── .xss()    // 字符串安全转义
│   ├── .escape()    // js特殊字符的转义
│   ├── .at(index)    // 读取指定位置的字符, 负值则从后往前读
│   ├── .toJson()    // 将url参数转为对象
│   ├── .lt(version)    // 判断是否小于目标版本号
│   ├── .lte(version)    // 判断是否小于或等于目标版本号
│   ├── .gt(version)    // 判断是否大于目标版本号
│   ├── .gte(version)    // 判断是否大于或等于目标版本号
│   └── .eq(version)    // 判断是否等于目标版本号, 1.0和1.0.0这里会返回true, 而用 == 或 ===, 无法得到正确的结果
│
├── Number
│   ├── .parse(str)    // 将安全范围内的数字字符串转为数字类型
│   └── .fromString(str)    // 将字符串转为数字类型
│
└── Promise
    └── .defer()    // 创建一个延迟的Promise对象