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

pure-funs

v0.1.6

Published

an useful pure function library

Downloads

13

Readme

pure-funs

一个纯函数库

API

曲线 (curve)

linear   linear(percent)
获取线性直线的百分比值,percent代表线性上的百分比;

linear(0.5);  //0.5

easeout   easeout(percent)
得出缓出曲线百分比的值, percent代表点在线性上百分比

easeout(0.5) //0.75

easein easein(percent)
得出缓入曲线百分比的值, percent代表点在线性上百分比

easeout(0.5) //0.75

easeinout easeinout(percent)
得出缓入缓出百分比的值,percent代表点在线性上百分比

easeinout(0.5) //0.75

数组 (array)

asc asc(arr) 数组升序

asc([0, 3, 1])  //[0, 1, 3];

desc desc(arr) 数组降序

asc([3, 1, 0])  //[0, 1, 3];

distance distance(arr) 数组去重

distance([0, 0, 1, 1, 2, 3]) //[0, 1, 2]

集合(collections)

sort   sort(collections, key, asc|desc) 按照某个key进行排序

var objArr = [{index: 1}, {index: 3}, {index: 2}, {index: 0}];
sort(objArr, "index", "asc"); //[{index: 0}, {index: 1}, {index: 2}, {index: 3}]

deepSearch   deepSearch(collections, key, value) 根据keyvalue进行查找

var objArr = [{index: 1}, {index: 3}, {index: 2}, {index: 0}];
sort(objArr, "index", "asc"); //[{index: 0}, {index: 1}, {index: 2}, {index: 3}]

cookie

getCookie   getCookie(key) 获得key的值

//document.cookie = "name=123&index=1";
getCookie("name") //123

setCookie   setCookie(key, val) 给key设置值

//document.cookie = "name=123&index=1";
setCookie("name", 1234) ////document.cookie = "name=1234&index=1";

delCookie   delCookie(key) 删除key的值

//document.cookie = "name=123&index=1";
delCookie("name") ////document.cookie = "index=1";

日期时间(date)

getDateTime   getDateTime(dateFormate, millisecond) 根据特定的时间格式获取时间。dateFormat是时间格式:

  • Y: 四位年份,如2019;
  • y: 两位年份, 如19;
  • M: 两位月份, 如01;
  • m: 一位月份,如1;
  • D: 两位日期, 如01;
  • d: 一位日期,如1;
  • H: 两位小时, 如01;
  • h: 一位小时,如1;
  • I: 两位分钟, 如01;
  • i: 一位分钟,如1;
  • S: 两位秒数, 如01;
  • s: 一位秒数,如1;
  • N: 两位毫秒数, 如10;
  • n: 一位毫秒数, 如1
getDateTime("Y-M-D H:I:S", new Date().getTime()) // 2019-04-29 14:31:41
getDateTime("y/m/d h:i:s", new Date().getTime()) // 19/4/29 14:31:4

getDateTime("y/m/d h:i:s:n", new Date().getTime()) // 19/4/29 14:31:4:9

getTime   getTime(dateFormate) 根据时间字符串获取秒数

getTime("2019-04-29 14:31:41") //1556519501227

countdown   countdown(dateFormate, millisecond) 显示特定时间格式的倒计时

countdown("H:I:S", 20000); //00:00:20
countdown("H:I:S:N", 999985); //00:16:39:98
countdown("H:I:S:n", 999985); //00:16:39:9

节点(dom)

$   $(selector) 模仿jquery选择器

$("p");

getElementByClass   getElementByClass(classname) 获取类名

getElementByClass(".list") 

duration

获取持续的时间

var time = duration();  //获取当前时间
time() //返回持续的秒数;

createTimer createTimer(seconds) 可暂定的计时器, 如果seconds有值则是倒计时

const timer = createTimer(15); //倒计时15秒
timer.stop();
timer.seconds(); //显示秒数

数字(number)

isInt   isInt(num) 是否是整数

isFloat   isFloat(num) 是否是浮点数

toDecimal   isDecimal(float, digit) 给数设置特定位数的小数,返回值number

isDecimal(12.333, 2)    // 12.22

toFixed   toFixed() 给数设置特定位数的小数,返回值String;

toFixed(8, 2); //“8.00”

object

安全(safe)

__filterXss __   filterXss(str) 将字符串的<>分别转义成&lt&gt;

filterXss("<script>alert(123)</script>") //&lt;script&gt;alert(123)&lt;/script&gt;

屏幕(screen)

getPos   getPos() 返回鼠标在页面上的坐标

getHeight   getHeight() 得到页面的高度

getWidth   getWidth() 得到页面的宽度

字符串(string)

trim   trim(str) 去掉字符串开头和结束的空格字符串

copyStr   copyStr(str) 拷贝字符串

单位(unit)

toKm toKm(number) 转化成公里数

超链接(url)

get   get(key) 获取超链接上的值;