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

js-knife

v1.1.10

Published

knife

Downloads

17

Readme

js-knife

  • 尽管作为高级编程语言的 javascript 提供了如此多好用的函数,但是我觉得还是不够的,比如 Date 对象转字符串、忽略大小写的子字符串匹配、提前结束的 forEach 等。这是发起此项目的原因一。
  • 好用、功能全面的工具库很多,但是,他们提供了太多的功能,很多功能几乎不会用到。我不想因为想用某一个函数而引用一个库,这是不想用常见工具库的原因之一。
  • 这些功能全面的库,往往采用“函数式编程”的思路而设计。也许看到这里很多人都已经开始认为我“不喜欢”函数式编程,当然不是,作为一种编程思路,无论是面向过程、面向对象还是函数式编程,都有其适用的场景。函数式编程一个突出的优点是安全,但是安全是有代价的,安全的代价是保守。当衡量安全带来的好处和保守带来的烦恼,我发现,日常的 web 开发也许不需要那么保守,甚至,我想更激进一些。这是不想用常见工具库的原因之二。正像此项目的名字,此项目用起来是有危险的,用不好可能会割到自己的手指。
  • 不想用常见工具库是发起此项目的原因之二。

设计理念

  • 实用
  • 易读
  • 易写
  • 拆掉辅助轮

关于易写和易读。有的功能比如检测一个值或对象,是否是一个数组中的某一个元素,仅用原生的 js 功能就可以实现(且代码不长)比如['car', 'shop', 'person'].indexOf('shop') > -1。但是这个方法的缺点是:不够直观,尽管 “是否是数组中的某一项” 和 “这个元素在数组中的位置大于-1” 是全等的,但是其实现和所需效果的原始目的并不是一致的,也就是写个功能的时候需要“稍微想一下”,读的时候,也是需要想一下的,而'shop'.isOneOf(['car', 'shop', 'person'])则一眼就能看懂,写的时候也无需思考。

使用时需注意

  • 此项目在 String、Date、Array 等原生 js 对象的 prototype 上了添加很多不安全的函数(可能会与其他项目冲突)
  • 此项目不会在操作前进行安全检验
  • 此项目的源码不会特别大,使用前,最好读一遍

使用

安装
npm install js-knife
源码

传送门

感谢贡献

  • 欢迎在 issue 里表达您的观点、不满,如果发现 bug 并提出批评,码者会更加感激
  • 如果你有自己想用而本项目没有的工具函数,欢迎在 issue 里提出
  • 如果你有自己常用的工具函数库,欢迎合并