Skip to main content
Home

Built and signed on GitHub Actions

Impute missing coordinates for a piecewise linear function

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 years ago (1.0.0)
function impute
impute<
X extends string | symbol,
Y extends string | symbol,
P extends [_ in X]: number & [_ in Y]: number,
>
(
points: P[],
x: X,
y: Y,
x0: number,
y0: number,
): void

Fill in missing (NaN) values in a list of points in a reasonable manner.

Examples

Illustrated usage

const points = [
 { x: 0.5, y: 1 },
 { x: 2, y: Number.NaN },
 { x: Number.NaN, y: 2 },
 { x: 3, y: 3 },
];

impute(points, "x", "y", 0, 0);

// `impute` has updated `points` as follows:
// points[1].y === 1.5
// points[2].x === 2.5

Type Parameters

X extends string | symbol
Y extends string | symbol
P extends [_ in X]: number & [_ in Y]: number

Parameters

points: P[]

The list of points to update in place

x: X

The x-coordinate property

y: Y

The y-coordinate property

The "central" x-value to fill, if no other data available

The "central" y-value to fill, if no other data available

Return Type

void

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@asymptoticgroup/pwl-impute

Import symbol

import module from "@asymptoticgroup/pwl-impute";
or

Import directly with a jsr specifier

import module from "jsr:@asymptoticgroup/pwl-impute";

Add Package

pnpm i jsr:@asymptoticgroup/pwl-impute
or (using pnpm 10.8 or older)
pnpm dlx jsr add @asymptoticgroup/pwl-impute

Import symbol

import module from "@asymptoticgroup/pwl-impute";

Add Package

yarn add jsr:@asymptoticgroup/pwl-impute
or (using Yarn 4.8 or older)
yarn dlx jsr add @asymptoticgroup/pwl-impute

Import symbol

import module from "@asymptoticgroup/pwl-impute";

Add Package

vlt install jsr:@asymptoticgroup/pwl-impute

Import symbol

import module from "@asymptoticgroup/pwl-impute";

Add Package

npx jsr add @asymptoticgroup/pwl-impute

Import symbol

import module from "@asymptoticgroup/pwl-impute";

Add Package

bunx jsr add @asymptoticgroup/pwl-impute

Import symbol

import module from "@asymptoticgroup/pwl-impute";