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

@minswap/internal-sdk

v0.1.2

Published

```ts export function encodeCostModels(costModels: Record<string, number>): Bytes { const sortedCostModelValues: number[] & { encodeCBOR?: any } = Object.entries(costModels) .sort(([key1], [key2]) => { if (key1 < key2) { return -1;

Downloads

129

Readme

How to encode cost models

export function encodeCostModels(costModels: Record<string, number>): Bytes {
  const sortedCostModelValues: number[] & { encodeCBOR?: any } = Object.entries(costModels)
    .sort(([key1], [key2]) => {
      if (key1 < key2) {
        return -1;
      } else if (key1 > key2) {
        return 1;
      } else {
        return 0;
      }
    })
    .map(([_, val]) => val);
  sortedCostModelValues.encodeCBOR = cbor.Encoder.encodeIndefinite;
  return Bytes.fromHex(cbor.encode(sortedCostModelValues).toString("hex"));
}

How to fix circular import

  • Thanks to https://github.com/acrazing/dpdm - A robust static dependency analyzer for your JavaScript and TypeScript projects.

  • Example:

    • I have tree like:
    ➜  ido git:(tony/ido-2.2) ✗ tree -L 1
    .
    ├── build-tx.ts
    ├── ido-v1.ts
    ├── ido.ts
    ├── index.ts
    ├── scripts
    ├── utils.ts
    ├── warehouse-v1.ts
    └── warehouse.ts
    • I try to run and got error:
    check_coin➜  monorepo git:(tony/ido-2.2) ✗ ./packages/backend/scripts/setup-ido.sh mainnet
    rebuild the script
    /Users/dzung/minswap/monorepo/packages/sdk/src/ido/ido-v1.ts:9
    export class IdoV1Event extends IdoEvent {
                                    ^
    
    TypeError: Class extends value undefined is not a constructor or null
        at invariant (/Users/dzung/minswap/monorepo/packages/sdk/src/ido/ido-v1.ts:9:33)
        at Object.<anonymous> (/Users/dzung/minswap/monorepo/packages/sdk/src/ido/ido-v1.ts:79:1)
        at Module._compile (node:internal/modules/cjs/loader:1562:14)
        at Object.transformer (/Users/dzung/minswap/monorepo/node_modules/.pnpm/[email protected]/node_modules/tsx/dist/register-DpmFHar1.cjs:2:1186)
        at Module.load (node:internal/modules/cjs/loader:1313:32)
        at Function._load (node:internal/modules/cjs/loader:1123:12)
        at TracingChannel.traceSync (node:diagnostics_channel:322:14)
        at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
        at Module.require (node:internal/modules/cjs/loader:1335:12)
        at require (node:internal/modules/helpers:136:16)
    
    Node.js v22.13.0
    • Code:
      # ./src/ido/ido-v1.ts
      import invariant from "@minswap/tiny-invariant";
      import { IdoEvent, IdoOrder, Maybe, type NetworkEnvironment, Result, type Utxo } from "..";
      import { IdoWarehouseV1 } from "./warehouse-v1";
    
      export class IdoV1Event extends IdoEvent {
      }
    • Use dpdm to detect circular import:
    ➜  sdk git:(tony/ido-2.2) ✗ npx dpdm --no-warning --no-tree ./src/ido/ido-v1.ts | grep ido
    ✔ [130/130] Analyze done!
      58) src/index.ts -> src/ido/index.ts -> src/ido/build-tx.ts
      59) src/index.ts -> src/ido/index.ts -> src/ido/build-tx.ts -> src/ido/ido.ts
      60) src/index.ts -> src/ido/index.ts -> src/ido/build-tx.ts -> src/ido/ido.ts -> src/ido/warehouse.ts
      61) src/ido/ido-v1.ts -> src/index.ts -> src/ido/index.ts
      62) src/index.ts -> src/ido/index.ts -> src/ido/utils.ts
      63) src/index.ts -> src/ido/index.ts -> src/ido/warehouse-v1.ts
    • Observe: at 61): src/ido/ido-v1.ts -> src/index.ts -> src/ido/index.ts means: src/ido/ido-v1.ts -> src/index.ts -> src/ido/index.ts -> src/index.ts -> src/ido/ido-v1.ts
    • Solution: We need to update direct imports from src/ido/ido-v1.ts to src/ido/ido.ts
    • Updated code:
    import invariant from "@minswap/tiny-invariant";
    import { Maybe, type NetworkEnvironment, Result, type Utxo } from "..";
    import { IdoEvent, IdoOrder } from "./ido";
    import { IdoWarehouseV1 } from "./warehouse-v1";
    
    export class IdoV1Event extends IdoEvent {
    }
    • Re-run:
    ➜  monorepo git:(tony/ido-2.2) ✗ ./packages/backend/scripts/setup-ido.sh mainnet
    rebuild the script
    setup done