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

coonlink-random-duck

v26.1.2

Published

Random PSD layer / image loader with Node.js core, static server and React hook

Readme

coonlink-random-duck

Load PSD layers (or plain PNG sources), serve a random one over HTTP, and use it in React. Pure-JS PNG encoder (zlib), no native dependencies.

Install

npm i coonlink-random-duck

For .psd support install the optional parser too:

npm i @webtoon/psd

Usage

Node.js

const { loadPsdLayers, createServer, randomLayer } = require('coonlink-random-duck');

// 1. From a PSD file (needs @webtoon/psd)
const layers = await loadPsdLayers('./duck.psd');

// or from plain PNG sources — no PSD parser needed:
// const layers = [pngBuffer1, pngBuffer2, 'https://.../duck.png'];

// 2. Serve them
const { server, base } = await createServer(layers, { port: 3000, open: true });
// → http://127.0.0.1:3000/        (click = next layer)
// → http://127.0.0.1:3000/random  (raw random PNG)

// 3. Or just take a random one
const layer = randomLayer(layers); // Buffer (or the URL string, if any)

Options for createServer:

await createServer(layers, {
  host: '0.0.0.0',
  port: 3000,
  open: true   // open the page in the default browser (best-effort)
});

React

Works with any sources (URLs / Blobs / Uint8Array / Buffer / ArrayBuffer) — the PSD parser is only needed in Node.

import { RandomLayer, useRandomLayer } from 'coonlink-random-duck/react';

// Ready-made component (click = next layer)
<RandomLayer layers={pngBuffersOrUrls} />

// Or the hook
function Duck() {
  const { url, index, total, next } = useRandomLayer(sources);
  return url ? <img src={url} onClick={next} alt={`layer ${index}`} /> : null;
}

Options:

useRandomLayer(sources, {
  start: 0,            // initial index
  random: false,       // start on a random layer instead
  shuffleOnNext: true // next() picks a random layer (preserve order if false)
});

RandomLayer accepts the same options plus any <img> props (style, className, alt, ...) and onClick, which is called before advancing.

Notes

  • loadPsdLayers is Node-only and uses @webtoon/psd (optional dependency). If the parser can't be installed or the layer API differs, just pass ready PNG buffers / URLs / Blobs instead.
  • createServer accepts the same sources: PNG Buffers / Blobs / Uint8Array in Node, plus URL strings (fetched on demand per request).
  • The PNG encoder in the core is pure JS (zlib) — no native dependencies.