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

@quantabit/coupon-sdk

v1.0.1

Published

QuantaBit 优惠券 SDK - 提供优惠券发放、领取、核销功能

Readme

@quantabit/coupon-sdk

QuantaBit 优惠券 SDK - 提供优惠券发放、领取、核销功能

📦 安装

npm install @quantabit/coupon-sdk
# 或
yarn add @quantabit/coupon-sdk

🚀 快速开始

1. 引入 Provider

import { CouponProvider } from "@quantabit/coupon-sdk";
import "@quantabit/coupon-sdk/styles.css";

function App() {
  return (
    <CouponProvider
      apiUrl="https://api.example.com/v1"
      token="your-auth-token"
      language="zh"
      onClaim={(coupon) => console.log("领取成功:", coupon)}
    >
      <YourComponent />
    </CouponProvider>
  );
}

2. 使用组件

import { CouponCard, CouponList } from '@quantabit/coupon-sdk';

// 优惠券卡片
<CouponCard
  coupon={couponData}
  onClaim={(coupon) => handleClaim(coupon)}
/>

// 我的优惠券列表
<CouponList
  type="my"
  showFilter
  onUse={(coupon) => handleUse(coupon)}
/>

// 可领取优惠券列表
<CouponList
  type="available"
  onClaim={(coupon) => handleClaim(coupon)}
/>

// 选择优惠券(结算页面)
<CouponList
  type="my"
  selectable
  selectedId={selectedCouponId}
  onSelect={(coupon) => setSelectedCoupon(coupon)}
/>

3. 使用 Hooks

import { useCoupon } from "@quantabit/coupon-sdk";

function MyComponent() {
  const {
    availableCoupons, // 可领取优惠券
    myCoupons, // 我的优惠券
    stats, // 统计(可用/已用/过期数量)
    loading,
    claimCoupon, // 领取优惠券
    getUsableCoupons, // 获取订单可用优惠券
  } = useCoupon();

  return <div>...</div>;
}

📚 组件列表

| 组件 | 描述 | | ------------ | ------------------------------------- | | CouponCard | 优惠券卡片(价值展示、领取/使用按钮) | | CouponList | 优惠券列表,支持筛选和选择模式 |

📖 类型定义

import { CouponType, CouponStatus } from "@quantabit/coupon-sdk";

// 优惠券类型
CouponType.DISCOUNT; // 折扣券
CouponType.AMOUNT; // 满减券
CouponType.CASH; // 现金券
CouponType.GIFT; // 礼品券
CouponType.FREESHIP; // 包邮券

// 优惠券状态
CouponStatus.AVAILABLE; // 可使用
CouponStatus.USED; // 已使用
CouponStatus.EXPIRED; // 已过期
CouponStatus.LOCKED; // 已锁定

🧮 优惠计算

import { calculateDiscount, isCouponUsable } from "@quantabit/coupon-sdk";

// 检查优惠券是否可用
const usable = isCouponUsable(userCoupon, orderAmount);

// 计算优惠金额
const discount = calculateDiscount(coupon, orderAmount);

📄 许可证

MIT License