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 🙏

© 2026 – Pkg Stats / Ryan Hefner

js-screw

v1.0.13

Published

js tools function

Readme

js-screw


  • 定位 提供项目中常用的工具函数,比如时间戳多种格式的转换,对于缓存的存取,数据类型判断等等;如名字screw一样,做一个项目开发过程中的小螺丝钉。

  • use

1、安装(insatll)

  npm i -S js-screw

2、入口文件引入(entry)

  // main.js
  const $tool = require('js-screw');
  
  // For example, VUE project
  Vue.prototype.$tool = $tool;

3、组件中使用(template use)

  • convertTime 时间戳转化为常用的时间格式
  ...

  // For example, VUE TEMPLAte project 
  computed: {
    // 转换时间 使用converTime方法
    return this.$tool.convertTime(1610068902452, 'ymdhm');
    /*
      * 默认 'y-m-d' -> 2021-10-20
      * 'y-m-d-h-m' -> 2021-10-20 10:28
      * 'm-d' -> 10-20
      * 'ymdhm' -> 2021年10月20日 10:28
      * 'md' -> 10月20日
    */
    // results(最终结果就是) -> 2021年01月08日 09:21
  }

  ...
  • convertEmpty 数据为空(null, undefined)的时候自动转化为 '--'
  {{this.$tool.convertEmpty(data.name)}}
  • convertString 校验字符串(格式是否符合ip,服务器地址,是否为电话,邮箱等)
 // 举个例子,校验是否为ip地址
 if (this.$tool.checkString(str).isIp) {
   // if true, some code here
 } else {

 }
  • getSession 本地缓存操作(对应还有localstorage的存取)
 let user = this.$tool.getSession('user');
  • showDataType 获取数据类型
 // 判断是否为对象
 if (this.$tool.showDataType(data) == 'Object') {

 }
  • convertSize 转换文件大小(b -> kb,mb,gb)
 this.$tool.convertSize(1024); // -> 1kb
  • Github 目前暂时提供了时间转换,缓存存取,字符校验等方法,后续会不断更新,具体方法和使用可直接查看源码。

github地址:https://github.com/wangshuo1991/js-screw

I hope that it is helpful for front end developer! Enjoy !