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

ibox-mock

v1.0.4

Published

utools ibox script mock

Readme

ibox-mock

一个用于模拟 ibox 功能的 npm 包。

安装

npm install ibox-mock

使用方法

import IBox from "ibox-mock";

// 创建实例
const ibox = IBox();

// 使用 toast 显示消息
ibox.toast.info("这是一条通知消息"); // 输出: [INFO] 这是一条通知消息
ibox.toast.success("操作成功"); // 输出: [SUCCESS] 操作成功
ibox.toast.error("发生错误"); // 输出: [ERROR] 发生错误

// 加载页面并获取 cheerio 实例
const $ = await ibox.loadPage("https://example.com");
console.log($("title").text());

// 使用内置的 ky 实例发起 HTTP 请求
const response = await ibox.ky.get("https://api.example.com/data");

// 使用 cheerio 解析 HTML
const html = await response.text();
const $doc = ibox.cheerio.load(html);

// 使用 licia 工具函数
const randomStr = ibox.licia.random();

// 使用默认的 push 实现
ibox.push(
  { url: "https://example.com/item1", title: "示例1" },
  { url: "https://example.com/item2", title: "示例2" }
);
// 输出:
// [IBOX:PUSH] [
//   { "url": "https://example.com/item1", "title": "示例1" },
//   { "url": "https://example.com/item2", "title": "示例2" }
// ]

// 使用自定义的 push 实现
const customIBox = IBox({
  push: (...items) => {
    // 自定义处理逻辑
    items.forEach((item) => {
      console.log(`处理项目:${item.url}`);
    });
  },
});

customIBox.push(
  { url: "https://example.com/item1", title: "示例1" },
  { url: "https://example.com/item2", title: "示例2" }
);
// 输出:
// 处理项目:https://example.com/item1
// 处理项目:https://example.com/item2

API

IBox(options?: IBoxOptions)

创建一个新的 IBox 实例。

  • options.push: 可选的自定义 push 处理函数,接收任意数量的数据项作为参数

ibox.push(...items: Array<{ url: string, [key: string]: any }>)

推送数据项到处理队列。

  • items: 包含数据项的列表,每个数据项必须包含 url 属性,可以包含其他任意属性
  • 如果在创建实例时提供了自定义的 push 函数,将使用该函数处理数据项
  • 否则,将以 JSON 格式输出数据项到控制台

示例:

// 使用默认实现
ibox.push(
  { url: "https://example.com/item1", title: "示例1" },
  { url: "https://example.com/item2", title: "示例2" }
);

// 使用自定义实现
const customIBox = IBox({
  push: (...items) => {
    items.forEach((item) => {
      // 自定义处理逻辑
      console.log(`处理项目:${item.url}`);
    });
  },
});

customIBox.push(
  { url: "https://example.com/item1", title: "示例1" },
  { url: "https://example.com/item2", title: "示例2" }
);

ibox.toast

提供消息提示功能的对象,包含以下方法:

  • ibox.toast.info(message: string): 显示信息提示
  • ibox.toast.success(message: string): 显示成功提示
  • ibox.toast.error(message: string): 显示错误提示

示例:

ibox.toast.info("这是一条通知消息"); // 输出: [INFO] 这是一条通知消息
ibox.toast.success("操作成功"); // 输出: [SUCCESS] 操作成功
ibox.toast.error("发生错误"); // 输出: [ERROR] 发生错误

ibox.loadPage(url: string, options?: object)

加载指定 URL 的页面,并返回一个 cheerio 实例。

  • url: 要加载的页面 URL
  • options: 可选的 HTTP 请求选项,与 ky 的选项相同
  • 返回: Promise<cheerio.CheerioAPI>

示例:

const $ = await ibox.loadPage("https://example.com");
console.log($("title").text());

ibox.ky

访问内置的 ky HTTP 客户端实例。你可以使用它来发起 HTTP 请求,例如:

  • ibox.ky.get(url)
  • ibox.ky.post(url, options)
  • ibox.ky.put(url, options)
  • 更多用法请参考 ky 文档

ibox.cheerio

访问内置的 cheerio 实例,用于解析和操作 HTML。使用方法类似于 jQuery:

  • ibox.cheerio.load(html) - 加载 HTML 字符串
  • 更多用法请参考 cheerio 文档

ibox.licia

访问内置的 licia 工具库,提供了大量实用的 JavaScript 工具函数:

  • 字符串处理
  • 数组操作
  • 日期处理
  • 更多用法请参考 licia 文档

License

ISC