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

@utilx/semantic

v0.0.6

Published

## Millis

Downloads

2

Readme

semantic

Result

Error

我们需要改变使用throw [string]的习惯,抛出字符串,会失去stacks,对后面的debug非常不友好。 我们应该:

  1. 原生的Error有哪些,尽量在这些Error上进行扩展
  2. 能够设计一种方法,能够快速创建error的特殊类

原生Error

  1. RangeError: 例如,端口号问题,require('net').connect(-1);
  2. ReferenceError: 尝试引用不应该的Error,这个不是我们能用的,是内部触发
  3. SyntaxError: 这个我只能理解为语法层次上的问题
  4. TypeError: 类型不符合预期

TimeStamp:语义化的时间戳

采用数字时间戳(1970以来的毫秒数)可读性很差 采用ISO标准的可读性不错,但里面的 :-. 一定程度对文件系统(扩展名判别),URL带来额外的负担。

因此,我们统一把这些分隔的标点符号变成_,并提供相应的stringify和parse函数。 我们还提供了一种在末尾加入了周六日的简写,在不少场合,这种额外的信息有助于信息回溯,对运维工作有一定的帮助。 这个简写是固定两位,从周日到周六分别是:S0 M1 T2 W3 T4 F5 S6

UTC标准时间:timestamp.utc()

new Date().toISOString():
2019-04-13T04:58:18.809Z

timestamp.utc():
2019_04_13T04_58_18_809Z

timestamp.locale_weekday():
2019_04_13T12_58_18_809Z_S6

带时区偏移(笔者所在东八区)的:timestamp.locale()

new Date().toISOString() + 偏移 :
2019-04-13T04:58:18.809Z-480

timestamp.locale():
2019_04_13T12_58_18_809Z_480

// 加入周六日信息
timestamp.locale_weekday():
2019_04_13T12_58_18_809Z_480_S6

Millis

millis({ year: 3, day: 3 }) => Class Millis(number)

meter

centimeter

Latitude Longtitude