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

trendkit

v0.1.1

Published

Drawing tools and indicators for TradingView's Lightweight Charts — trendlines, rays, Fibonacci, zones and a measure tool, built on the v5 plugin API.

Readme

trendkit

Drawing tools for Lightweight Charts — trendlines, rays, Fibonacci retracements, zones and a measure tool, built on the v5 plugin API.

Status: pre-release. Five drawing tools and three indicators work and are verified in a browser. Not yet published to npm — the React entry point and the documentation pass are still to come.

Why

Lightweight Charts is excellent and free, but it draws data — not the things a discretionary trader puts on the data. Since v5 it exposes a plugin API (attachPrimitive, hitTest, two-way coordinate conversion) that makes the missing layer buildable. trendkit is that layer.

Install

npm install trendkit lightweight-charts

lightweight-charts is a peer dependency — trendkit never bundles its own copy, because two chart runtimes in one page means two sets of instanceof checks that disagree.

Use

import { createChart, CandlestickSeries } from "lightweight-charts";
import { createTrendkit, Trendline } from "trendkit";

const chart = createChart(container);
const series = chart.addSeries(CandlestickSeries);
series.setData(candles);

const kit = createTrendkit({ chart, series, tools: [Trendline] });

kit.store.add({
  id: crypto.randomUUID(),
  tool: "trendline",
  points: [
    { time: candles[20].time, logical: 20, price: 102.65 },
    { time: candles[120].time, logical: 120, price: 112.80 },
  ],
});

Only the tools you pass are bundled — the package is sideEffects: false, so anything you leave out is tree-shaken away.

Indicators

Independent of the drawing tools — use either alone.

import { addIndicator } from "trendkit";

const rsi = addIndicator(chart, { type: "rsi", period: 14 }, candles);
addIndicator(chart, { type: "macd" }, candles);            // 12/26/9
addIndicator(chart, { type: "bollinger" }, candles);       // 20, 2σ

rsi.setData(moreCandles);   // recompute
rsi.remove();               // takes its pane with it

RSI and MACD get their own panes; Bollinger overlays the price pane, because it is the only one of the three measured in price units.

The maths follows the conventions the rest of the industry uses, which is mostly a matter of getting three things right: RSI uses Wilder's smoothing (k = 1/n), not an EMA; MACD's EMAs are seeded with an SMA, and its signal line skips the leading nulls rather than treating them as zeros; Bollinger uses population standard deviation, not sample. Each of those is a way to produce numbers that look plausible and disagree with every other platform.

The raw functions are exported too, if you only want the numbers:

import { rsi, macd, bollinger, ema, sma, wilder, stdev } from "trendkit";

Persistence

toJSON() and fromJSON() are the whole story. Where the result is stored is your decision, not the library's:

kit.store.subscribe(() => localStorage.setItem("drawings", JSON.stringify(kit.toJSON())));

Two things it gets right

Drawings are anchored in (time, price), never pixels. A trendline through two candles stays through those candles when you pan, zoom or resize. Points dragged past the last bar — where there is no Time to convert — fall back to the logical bar index, so projections into empty space keep working.

Rendering happens in bitmap space, not CSS pixels. On a Retina screen a 1px line drawn in CSS pixels lands across two device pixels and renders as a grey smear. trendkit snaps to the device grid: measured on a DPR 2 display, a 2px line is 4 fully opaque device rows with 2 antialiased edges.

Development

npm install
npm run dev        # the example at localhost:5174
npm test
npm run verify     # typecheck + lint + test + build

vitest is pinned to v3. npm 10.9.2 crashes with Cannot read properties of null (reading 'edgesOut') while resolving vitest 4's peer graph — an npm bug, not a vitest one. Revisit when npm 11 is common.

Licence

MIT