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

@kyol/usejs

v0.1.16

Published

- description

Readme

@kyol/usejs<常用函数库>

  • description

    主要解决常用函数和性能函数的使用

    文档持续更新中

函数描述

| 函数名 | 参数 | 返回 | description | | ------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | compose | compose(func1,func2) : Array[functionList] 函数列队 | Function | 组合函数 | | composeSync | compose(asyncFunc1,asyncFunc2) : Array[functionList] 异步函数列队函数列队 | Function | 组合函数 | | currayFactory | currayFactory(a,b,c) Array 属性列队 c 可以是对象 | Function 返回一个函数,函数入参为映射索引的值,超出索引外的第一个如果是对象,则为扩展对象 | 抽象工厂 | | usePipe | usePipe(a:function,isPromiseReturn :boolean) b 为真则是然会 promise | 返回一个函数 Function:() => {} | 复用代码片段 | | useRef | useRef('keyName',any, reset?) reset 作为强制重置变量值 | 返回一个 ObserveData 对象 里面有一个属性为 value 唯一 key,所有相同 key 的值变化的时候自动,自动更新,并且 | const test = useRef('a', 80);在模板语法中可以直接使用 test 代替 test.value(如 vue2,vue3); const test2 = useRef('a', 100) 这个时候因为是存在 a 这个变量的所以 test2,value 为 80 而不是 100, | | useLocal | useLoacl('key',any) | 返回一个 ObserverData 对象,并绑定原始值在 localStorage 对象上 | const test = useLoacl('test-1',() => 100) 那么 window.localStorage['test-1'] = 100 , 在 JS 中使用 test.value = 200 则 window.localStorage['test-1'] 也变成 200 | | useSession | useSession(('key',any)) | 返回一个 ObserverData 并绑定原始值在 sessionStorage 对象上 | const test = useSession('keyName', 100 or () => ({测试})) 他存储的不是 ObserveData 对象,而是简单的 数据值 | | isRef | isRef(ObserverData) | 返回 boolean | 是不是 ObserberData 类型 |

| dele

test 常用函数演示

useRef: 的映射使用,可以实现跨组件 跨路由。不支持刷新

uselocal 的映射使用,可以实现跨组件 跨路由。支持刷新, 不支持浏览器 同 sessionStorage

useSession 的映射使用,可以实现跨组件 跨路由。支持刷新,支持关闭浏览器同 localStorage

以上三个函数的用法一致

const myOne = useRef('key-one', () => '我是第一个值');

const myTwo = useRef('key-one', () => '我是第二个值');

console.log(myOne); // 返回 {value:我是第一个值}
console.log(myTwo); // 返回 {value:我是第一个值}

// 一改则改
myTwo.value = '改变一次值';

console.log(myOne); // 返回 {value:改变一次值}
console.log(myTwo); // 返回 {value:改变一次值}

// 强制覆盖
const mywtree = useRef('key-one', () => '我是第三个值', true);
console.log(myOne); // 返回 {value:我是第三个值}
console.log(myTwo); // 返回 {value:我是第三个值}
console.log(mywtree); // 返回 {value:改变一次值}

const myOne = uselocal('key-one', () => '我是第一个值');

Object 的函数扩展

useObject 对象上扩展一下方式,也可以使用 useFastExtend() 函数调用,直接扩展到 Object 原型上

  • forEach
  • map
  • filter
  • some
  • every
import { useFastExtend } from '@kyol/usejs';
// 快速绑定 Object 与 Function 的静态方法
useFastExtend();
const myObj = { a: 1, b: 20 };

Object.forEach(myObj, (value, key, origin) => {
    console.log('value:', value, 'key:', key, origin); // 打印出 value: 1, key: a
});

const myArray = Object.map(myObj, (value, key, origin) => {
    return { key: value, name: key };
});
// myArray  = [{a:1,name:'a'},{b:20,name:'b'}]

const findObject = Object.find(myObj, (value, key) => key === 'a');
// findObject = {key:a,value:1} || undefined

const filterObject = Object.find(myObj, (value, key) => key === 'a');
// filterObject = {a:1}
filterObject.keys(); // ['a']
filterObject.values(); // [1]
filterObject.size; //  1  返回查找的个数

version 0.1.3

  • 新增 getRandomString, getOnlyUid 函数获取随机值

  • 修复 useCacheHooks 底层函数对浏览器缓存的实时更新