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 🙏

© 2025 – Pkg Stats / Ryan Hefner

udi-package

v1.0.31

Published

UDI package for utils purposes

Readme

UDI Package

一個UDI內部使用的套件。

安裝

npm install udi-package

使用方法

ES6 模組匯入

import UdiPackage from 'udi-package';


// 使用輔助功能
const isObj = UdiPackage.isObject({}); // true
await UdiPackage.sleep(1000); // 延遲 1 秒

// 使用 Token 功能
const token = UdiPackage.getToken();
const plainToken = UdiPackage.getPlainToken();

// 使用通知功能
UdiPackage.notify('這是一則通知', 'success');

具名匯入

import { isObject, sleep, getToken, notify } from 'udi-package';


const isObj = isObject({});
const token = getToken();
notify('通知訊息', 'info');

Webpack 打包

本專案已配置 webpack 打包功能,可以生成適用於瀏覽器的 UMD 模組。

打包指令

# 生產環境打包
npm run build

# 開發環境打包
npm run build:dev

# 啟動開發伺服器
npm run dev

打包輸出

打包後的檔案位於 dist/ 目錄:

  • udi-package.js - 生產環境版本(已壓縮)
  • udi-package.dev.js - 開發環境版本(包含 source map)

瀏覽器使用

<!DOCTYPE html>
<html>
<head>
    <title>UDI Package 測試</title>
</head>
<body>
    <script src="dist/udi-package.js"></script>
    <script>
        // 全域變數 UdiPackage 可用
        console.log(UdiPackage.add(5, 3));
        UdiPackage.notify('測試通知', 'success');
    </script>
</body>
</html>

功能說明

數學功能

  • add(a, b) - 加法運算
  • subtract(a, b) - 減法運算

輔助功能

  • isObject(value) - 檢查是否為物件
  • sleep(ms) - 延遲執行

Token 功能

  • getToken() - 取得儲存的 token
  • getPlainToken() - 取得解碼後的 token

通知功能

  • notify(message, type, options) - 顯示通知

開發

安裝依賴

npm install

執行測試

npm test

打包測試

# 打包
npm run build

# 在瀏覽器中開啟 dist/index.html 進行測試

授權

MIT