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

m-jslib

v1.0.16

Published

- ### 通用

Readme

M项目 javascript 公共库

  • 通用

    • isType
      /**
       * 判断变量类型
       * @method isType
       * @param {Any} obj 需要判断的变量
       * @param {String} type 判断的类型
       * @return {Boolean} 返回值说明
       */
      isType("s", "String"); //true
      isType([], "Object");  //false;
      isType([], "Array");   //true
  • 字符串

    • trim
      /**
       * 删除字符串两侧所有的空格
       * @method trim
       * @param {String} str 需要删除空格的字符串
       * @return {String} 删除空格后的字符串
       */
      trim("     s       ");   //"s"
      trim("  s    s       "); //"s    s"
    • trimAll
      /**
       * 删除字符串所有的空格
       * @method trimAll
       * @param {String} str 需要删除空格的字符串
       * @return {String} 删除空格后的字符串
       */
      trimAll("     s       ");   //"s"
      trimAll("  s    s       "); //"ss"
    • delSquareBrackets
      /**
       * 删除字符串中<>以及<>里面所包含的值
       * @method delSquareBrackets
       * @param {String} str  待处理的字符串
       * @param {Array} ignoreFilterTagName 不删除的tag
       * @return {String} 删除后的字符串
       */
      delSquareBrackets('123<div>45</div><div>67<div>89</div></div>10<b>1112</b>');   //"123456789101112"
      delSquareBrackets('123<div>45</div><div>67<div><span>89</span></div></div>10<b>1112</b>', ['span']); //"1234567<span>89</span>101112"
    • regExpPattern
     //常用正则对象
      regExpPattern.isEmail(str)  //是否是邮箱
      regExpPattern.isPhone(str)  //是否是电话号码
      regExpPattern.isQq(str)     //是否是qq
      regExpPattern.isDomain(str) //是否是域名
      regExpPattern.isIp(str)     //是否是ip
      regExpPattern.haveChineseChar(str)  //是否包含中文字符
      regExpPattern.isFloat(str)          //是否是浮点数
  • cookie处理

    • removeCookie
      /**
       * 删除cookie
       * @method removeCookie
       * @param {String} key 需要删除Cookie的key
       * @return {Boolean} 是否删除成功
       */
      removeCookie('test');   //true
    • addCookie
      /**
       * 添加cookie
       * @method addCookie
       * @param {String} key
       * @param {String} value
       * @param {String} expireMilliseconds 有效时间
       * @return {String} 添加后的cookie格式
       */
      addCookie("test", "test", 360000);   //"test=test;Domain=lanhuapp.com;expires=Thu, 07 May 2020 07:05:23 GMT;Path=/"
    • getCookie
      /**
       * 获取cookie
       * @method getCookie
       * @param {String} key
       * @return {String} key所对应的value
       */
      getCookie("test");   //"test"
  • 验签

    • sign
      /**
       * 验签 
       * @method sign
       * @param {Object} settings 传递的给后台的参数对象,参数放在data里面
       * @param {String} salt  salt
       * @return {Object}
       */
      sign({
        data: {
          start: 123,
          len: 10
        }
      }, "12345678910"); //{ data:{ start: 123,len: 10,_: 1588837513227,sign: 'a3fda79d49257effe7faa7a4cb606938' } }
  • url

    • parseUrl
      /**
       * 解析url的query
       * @method parseUrl
       * @param {String} key 需要取得的query的键
       * @return {String} key所对应的value
       */
      parseUrl('ie');   //"utf-8"
  • 图片

    • preloadImgs
      /**
       * 预加载图片
       * @method preloadImgs
       * @param {Array} imgs 需要加载的img的src
       * @return {void}
       */
      preloadImgs(['https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1970585368,2576171845&fm=15&gp=0.jpg', 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1588846464456&di=8591a4e2c9955474c8ccc14a0c8965cd&imgtype=0&src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farchive%2F309b84f2e09bd9f87df9b14efbcf21131a5bfcbd.jpg']);
  • 文件

    • isDirExsit

    • getDirectory

    • createDir

    • copyFile

    • createFile

    • readFile

  • vue Component

    • ActionBar
      @Input() title:string
      @Output() back: EventEmitter<null>
    
      //import ActionBar from "m-jslib/vueComponent/ActionBar.vue";
    
      //components: {
      //  appActionBar: ActionBar,
      //}
    
      //<app-action-bar title="这是标题" @back="close"></app-action-bar>
    • Model
      //import Model from "m-jslib/vueComponent/Model.vue";
    
      //components: {
      //  appModel: Model
      //}
    
      /*
          <app-model ref="confirm">
            自定义内容slot
          </app-model>
      */
    • Dialog
      //import Dialog from "m-jslib/vueComponent/Dialog.vue";
      //components: {
      //  appDialog: Dialog
      //}
    
      /*
        <app-dialog width="2.95rem" height="1.59rem">
          自定义内容slot
        </app-dialog>
      */