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

blue-utils

v1.2.11

Published

blue-utils

Downloads

8

Readme

blue-utils

blue-utils

const utils = require('blue-utils');
utils.isStr('string');

Methods

//是否为空对象:Boolean
utils.isEmptyPlainObject({});

//是否为string
utils.isStr('string');

//是否为obj对象
utils.isPlainObject({});

//是否为数组
utils.isArray([]);

//是否为对象Object
utils.isObject({}||[]);

//是否有值
utils.isDef('123');

//是否为undefine 或者 null
utils.isUndef(undefined );

//字符串是否为空
utils.isBlankSpace('   string   ');

//是否为true
utils.isTrue(true);

//是否为false
utils.isFalse(false);

//是否为function
utils.isFunction(() => {});

//是否为error
utils.isError(new Error('123'));

//是否为布尔值
utils.isBoolean(true || false);

//执行function
utils.hook(window,(arg1,arg2)=>{
  console.log(this,arg1,arg2);
},['123','456']);

//遍历
utils.each(object || array , (value, index || [key,index]) => {});

//深拷贝
utils.deepCopy(object);

//多个的obj的扩展,最后的一个参数为深拷贝
utils.extend(obj,...objn, isDeep = true);

//处理RegExp
utils.getRegExp(`\s+\d{1,8}`);

//获取obj的长度
utils.getObjLen(object);

//获取obj的keys
utils.getObjKeys(object);

//获取连接中的query string
var paramsString = utils.getLinkParams(`https://github.com/azhanging/blue-utils?params=1&params=2`);

//query string 转化为 object
var params = utils.parseParams(paramsString);

//query 转化为 string
utils.stringifyParams(params);

//实例化promise
utils.promise((resolve,reject)=>{
  if(true){
    resolve();  
  } else {
    reject();
  }
});

//防抖@return function(ctx,args);
const debounceFn = utils.debounce((data)=>{
  console.log(data);
},200);
debounceFn(utils,[`data`]);

//节流
const throttleFn = utils.throttle((data)=>{
  console.log(data);
},200);
throttleFn(window,[`data`]);


debounce(hook: Function, delay?: number): Function;
throttle(hook: Function, delay?: number): Function;
formatDate(date: TDateArg, format: string): string;
getDate(date: TDateArg): TResultDate;
getYear(time: TDateArg): number;
getMonth(time: TDateArg): number;
getDay(time: TDateArg): number;
getHours(time: TDateArg): number;
getMinutes(time: TDateArg): number;
getSeconds(time: TDateArg): number;
getTime(time: TDateArg): number;


//倒计时
const countDown = new utils.CountDown({
  hooks: {
    tick(){
      tick(){},
      start(){},
      end(){}
    }
  }
});

//ms时间差
countDown.start(diffTime);
countDown.stop();
countDown.reset();

//生成显示数据 {day,hours,minutes,second}
countDown.genViewDate();