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

@micl/helper

v0.1.4

Published

micl helper

Readme

@micl/helper

npm version npm downloads license

Micl 项目的辅助工具模块,通过原型扩展提供常用工具函数。

✨ 特性

  1. 原型扩展方式,无需导入单独函数即可使用
  2. 字节编解码功能
  3. 元数据管理
  4. 对象操作工具
  5. 数组工具
  6. Promise 延迟执行工具

📦 安装

npm install @micl/helper
# or
pnpm add @micl/helper
# or
yarn add @micl/helper

📚 模块导出

只需 import '@micl/helper' 即可自动扩展原生对象原型。

| 扩展对象 | 方法 | 描述 | |----------|------|------| | Buffer | encode() | 编码数据为 Buffer | | Buffer | decode() | 从 Buffer 解码数据 | | Object | omit(keys) | 移除对象指定属性 | | Object | defineMetadata(key, value) | 定义元数据 | | Object | getMetadata(key) | 获取元数据 | | Array | findMaxObj(filter, key) | 查找指定键的最大值对象 | | Promise | sleep(ms) | 延迟执行 |

🎯 使用示例

字节编解码

import '@micl/helper';

// 编码字符串
const str = 'hello world';
const encoded = (str as any).encode();
console.log(encoded); // <Buffer 01 00 00 00 0b 68 65 6c 6c 6f 20 77 6f 72 6c 64>

// 解码字符串
const decoded = encoded.decode();
console.log(decoded); // 'hello world'

// 编码数字
const num = 3.1415926;
const numEncoded = (num as any).encode();
const numDecoded = numEncoded.decode();
console.log(numDecoded); // 3.1415926

// 编码对象
const obj = { name: 'test', value: 123 };
const objEncoded = (obj as any).encode();
const objDecoded = objEncoded.decode();
console.log(objDecoded); // { name: 'test', value: 123 }

对象操作

import '@micl/helper';

// omit - 移除属性
const original = { a: 1, b: 2, c: 3 };
const result = original.omit(['a', 'c']);
console.log(result); // { b: 2 }

// 元数据管理
const obj = {};
obj.defineMetadata('key', 'value');
const metadata = obj.getMetadata('key');
console.log(metadata); // 'value'

数组操作

import '@micl/helper';

// 查找最大值对象
const arr = [
  { id: 1, score: 85 },
  { id: 2, score: 95 },
  { id: 3, score: 78 },
];
const maxItem = arr.findMaxObj(item => item.id > 0, 'score');
console.log(maxItem); // { id: 2, score: 95 }

Promise 延迟

import '@micl/helper';

// 延迟执行
console.log('开始');
await Promise.sleep(1000);
console.log('1秒后');

� API 参考

Buffer.encode()

编码数据为 Buffer 格式。

返回: Buffer - 编码后的字节数据

Buffer.decode()

从 Buffer 解码数据。

返回: 解码后的原始数据(string | number | object)

Object.omit(keys)

移除对象指定属性,返回新对象。

参数:

  • keys - 要移除的属性名数组

返回: 新对象

Object.defineMetadata(key, value)

在对象上定义元数据。

参数:

  • key - 元数据键名
  • value - 元数据值

Object.getMetadata(key)

获取对象的元数据。

参数:

  • key - 元数据键名

返回: 元数据值

Array.findMaxObj(filter, key)

在数组中查找满足过滤条件且指定键值最大的对象。

参数:

  • filter - 过滤函数
  • key - 比较最大值的键名

返回: 找到的对象

Promise.sleep(ms)

延迟指定时间后 resolve。

参数:

  • ms - 延迟毫秒数

返回: Promise

🛠 开发

构建

cd helper
pnpm build

🤝 贡献

欢迎提交 Issue 和 Pull Request 来完善这个模块。

📄 许可证

本项目采用 ISC 许可证 - 查看 LICENSE 文件了解详情。

Copyright (c) alexgogoing [email protected]

📞 支持

如有问题或建议,请提交 Issue 或联系维护者。


@micl/helper - 简洁高效的原型扩展工具集 🚀