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

@wings-j/chart-data-preprocess

v0.4.0

Published

Tools for preprocessing data before generating charts.

Downloads

90

Readme

chart-data-preprocess is a lightweight TypeScript library for preparing numeric data before generating charts. It provides utility functions for parsing values, formatting numbers, and transforming data arrays to support common chart preprocessing tasks.

Installation

npm install @wings-j/chart-data-preprocess

API

Types

Math

Utility

Methods

combine

compress

split

transform

Document

Vector1

interface Vector1 {
  x: number;
}

Vector2

interface Vector2 {
  x: number;
  y: number;
}

min

/**
 * Min
 * @description Find the minimum value in an array.
 * @param [array] Array
 * @return Value
 */
function min(array: number[]): number;

max

/**
 * Max
 * @description Find the maximum value in an array.
 * @param [array] Array
 * @return Value
 */
function max(array: number[]): number;

minMax

/**
 * Min Max
 * @description Find both the minimum and maximum values in an array.
 * @param [array] Array
 * @return Min Value and Max Value
 */
function minMax(array: number[]): [number, number];

sum

/**
 * Sum
 * @description Calculate the sum of all values in an array.
 * @param [array] Array
 * @return Value
 */
function sum(array: number[]): number;

mean

/**
 * Mean
 * @description Calculate the average (mean) of all values in an array.
 * @param [array] Array
 * @return Value
 */
function mean(array: number[]): number;

median

/**
 * Median
 * @description Calculate the median of an array of numbers.
 * @param [array] Array of numbers
 * @return Median value
 */
function median(array: number[]): number;

parse

/**
 * Parse
 * @param [value] Value
 * @return Number
 */
function parse(value: any): number;

format

/**
 * Format
 * @param [value] Value
 * @param [fraction] Fraction
 * @param [trim] Trim
 * @return String
 */
function format(value: number, fraction: number, trim?: boolean): string;

successionCombine

/**
 * Succession Combine
 * @description Merge multiple arrays into one by identifier, removing duplicates while preserving the succession order.
 * @type [T] Data Type
 * @param [array] Array
 * @param [xGetter] X Getter
 * @param [unit] Unit
 * @return Combined Array
 */
function successionCombine<T = any>(array: T[], xGetter: (item: T) => number, unit: number): { start: T; end: T; middle: T[] }[];

multiplePartsCombine

/**
 * Multiple Parts Combine
 * @description Merge multiple arrays into one by identifier, removing duplicates while preserving the first-seen order.
 * @type [T] Data Type
 * @param [array] Array Groups
 * @param [vGetter] Value Getter
 * @return Combined Array
 */
function multiplePartsCombine<T = any>(array: T[][], vGetter: (item: T) => any): T[];

consecutiveDuplicateCompress

/**
 * Consecutive Duplicate Compress
 * @description Compresses the input array by removing consecutive duplicate entries while preserving order.
 * @type [T] Data Type
 * @param [array] Array
 * @param [vGetter] Value Getter
 * @return Compressed Array
 */
function consecutiveDuplicateCompress<T = any>(array: T[], vGetter?: (item: T) => any): T[];

distanceThresholdCompress

/**
 * Distance Threshold Compress
 * @description Compresses the input vector array by removing points whose x-distance to the previous kept point is within the given unit threshold.
 * @type [T] Data Type
 * @param [array] Array
 * @param [xGetter] X Getter
 * @param [unit] Unit Size
 * @returns Compressed Array
 */
function distanceThresholdCompress<T = any>(array: T[], xGetter: (item: T) => number, unit: number): T[];

largestTriangleThreeBucketsCompress

/**
 * Largest Triangle Three Buckets Compress
 * @description Downsamples the input vector array to the requested length using the largest-triangle-three-buckets (LTTB) algorithm.
 * @type [T] Data Type
 * @param [array] Array
 * @param [length] Target Length
 * @return Compressed Array
 */
function largestTriangleThreeBucketsCompress<T = any>(array: T[], xGetter: (item: T) => number, yGetter: (item: T) => number, length: number): T[];

autoGapSplit

/**
 * Auto Gap Split
 * @description Split an array into sub arrays based on gaps between consecutive elements.
 * @type [T] Data Type
 * @param [array] Array to split
 * @param [xGetter] Function to extract the numeric value for gap calculation
 * @param [tolerance] Multiplier for the normal gap to determine the threshold
 * @return Array of Sub Arrays
 */
function autoGapSplit<T extends Vector1 = any>(array: T[], xGetter: (item: T) => number, tolerance?: number): T[][];

ratio

/**
 * Ratio
 * @description Calculate ratio.
 * @type [T] Data Type
 * @param [array] Array
 * @param [xGetter] X Getter
 * @return Array with X Ratio
 */
function ratio<T = any>(array: T[], xGetter: (item: T) => number): { value: T; x: number }[];