### Install downsample Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Installation instructions for the downsample package using npm or yarn. ```bash # for all the npm people out there npm install downsample # or if you are a fan of yarn yarn add downsample ``` -------------------------------- ### TypedArray Support Example Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Demonstrates the support for TypedArray input, where the output type matches the input type, such as Int16Array. ```typescript const input: Int16Array = new Int16Array(...); const result: Int16Array = LTD(input, 1000); ``` -------------------------------- ### createASAP Function Signature Source: https://github.com/janjakubnanista/downsample/blob/master/README.md A factory function to create an ASAP smoothing function for a specific point data type 'P', allowing custom extraction of x and y values and conversion back to a point. ```typescript function createASAP({ x: string | number | (point: P) => number, y: string | number | (point: P) => number, toPoint: (x: number, y: number) => P }): ASAP; ``` -------------------------------- ### createSMA Function Signature Source: https://github.com/janjakubnanista/downsample/blob/master/README.md A factory function to create an SMA smoothing function for a specific point data type 'P', enabling custom x and y value extraction and point creation. ```typescript function createSMA({ x: string | number | (point: P) => number, y: string | number | (point: P) => number, toPoint: (x: number, y: number) => P }): SMA; ``` -------------------------------- ### createLTD Function Signature Source: https://github.com/janjakubnanista/downsample/blob/master/README.md A factory function to create an LTD downsampling function for a specific point data type 'P', allowing custom x and y value extraction from points. ```typescript function createLTD({ x: string | number | (point: P) => number, y: string | number | (point: P) => number }): LTD; ``` -------------------------------- ### DataPoint Type Definition Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Defines the structure of a data point, supporting various formats including [number, number], [Date, number], { x: number; y: number }, and { x: Date; y: number }. ```typescript type DataPoint = [number, number] | [Date, number] | { x: number; y: number } | { x: Date; y: number } ``` -------------------------------- ### SMA Downsampling Method Source: https://github.com/janjakubnanista/downsample/blob/master/README.md The SMA (Simple Moving Average) method calculates a moving average over a specified window size, with an optional slide parameter to control window shifting. It accepts data points or a TypedArray and returns points in XYDataPoint format. ```typescript function SMA(data: DataPoint[], windowSize: number, slide?: number = 1): XYDataPoint[] ``` ```javascript import { SMA } from 'downsample'; // Or if your codebase does not supprot tree-shaking import { SMA } from 'downsample/methods/SMA'; const chartWidth = 1000; const smooth = SMA([ [0, 1000], [1, 1243], // ... ], chartWidth); ``` -------------------------------- ### Create LTOB Downsampling Function (TypeScript) Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Creates an LTOB downsampling function for a specific point data type 'P'. It takes an object with 'x' and 'y' properties, which can be strings, numbers, or accessor functions. ```typescript function createLTOB({ x: string | number | (point: P) => number, y: string | number | (point: P) => number }): LTOB; ``` -------------------------------- ### Create LTTB Downsampling Function (TypeScript) Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Creates an LTTB downsampling function for a specific point data type 'P'. It takes an object with 'x' and 'y' properties, which can be strings, numbers, or accessor functions. ```typescript function createLTTB({ x: string | number | (point: P) => number, y: string | number | (point: P) => number }): LTTB; ``` -------------------------------- ### LTD Downsampling Function Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Implements the Largest Triangle Dynamic (LTD) downsampling algorithm, known for its simplicity. It accepts data points or TypedArray and a target resolution, preserving the data format. ```typescript function LTD(data: DataPoint[], targetResolution: number): DataPoint[] ``` ```typescript import { LTD } from 'downsample'; // Or if your codebase does not supprot tree-shaking import { LTD } from 'downsample/methods/LTD'; const chartWidth = 1000; const downsampled = LTD([ [0, 1000], [1, 1243], // ... ], chartWidth); ``` -------------------------------- ### ASAP Downsampling Method Source: https://github.com/janjakubnanista/downsample/blob/master/README.md The ASAP (Automatic Smoothing for Attention Prioritization) method smooths time series data by removing short-term noise to reveal large-scale deviations. It accepts an array of data points or a TypedArray and a target resolution, returning points in XYDataPoint format. ```typescript function ASAP(data: DataPoint[], targetResolution: number): XYDataPoint[] ``` ```javascript import { ASAP } from 'downsample'; // Or if your codebase does not supprot tree-shaking import { ASAP } from 'downsample/methods/ASAP'; const chartWidth = 1000; const smooth = ASAP([ [0, 1000], [1, 1243], // ... ], chartWidth); ``` -------------------------------- ### LTTB Downsampling Function Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Implements the Largest Triangle Three Buckets (LTTB) downsampling algorithm. It accepts an array of data points or a TypedArray and a target resolution, preserving the data format. ```typescript function LTTB(data: DataPoint[], targetResolution: number): DataPoint[] ``` ```typescript import { LTTB } from 'downsample'; // Or if your codebase does not supprot tree-shaking import { LTTB } from 'downsample/methods/LTTB'; const chartWidth = 1000; const downsampled = LTTB([ [0, 1000], [1, 1243], // ... ], chartWidth); ``` -------------------------------- ### LTOB Downsampling Function Source: https://github.com/janjakubnanista/downsample/blob/master/README.md Implements the Largest Triangle One Bucket (LTOB) downsampling algorithm, which performs similarly to LTTB. It accepts data points or TypedArray and a target resolution, maintaining data format. ```typescript function LTOB(data: DataPoint[], targetResolution: number): DataPoint[] ``` ```typescript import { LTOB } from 'downsample'; // Or if your codebase does not supprot tree-shaking import { LTOB } from 'downsample/methods/LTOB'; const chartWidth = 1000; const downsampled = LTOB([ [0, 1000], [1, 1243], // ... ], chartWidth); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.