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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ffp

v1.0.0

Published

Farthest feasible point algorithm implementation

Downloads

6

Readme

Farthest feasible point algorithm implementation

Algorithm is used to filter timeseries points to speed up rendering by defining maximum error on ordinate axis and skipping all points that fit in resulting corridor.

FFP algorithm is described in this paper, authored by Guilin Xinyu and Zhe Cheng.

The library is distributed as ES module.

Check spec/ffp.spec.js to see usage example.

Built in collaboration with Erohina Elena, original version of FFP implementation can be found here.

Installation

$ yarn add ffp
# or
$ npm install --save ffp

Usage

FFP is instantiated and used like this:

import FFP from "ffp";
const ffp = FFP()
  .maxDeltaY(0.5) // define maximum delta
  .x(({ x }) => x) // define x accessor
  .y(({ y }) => y) // define y accessor
  .result(({ value }) => value); // consume filtered points

const array = [
  { x: 0, y: 3 },
  { x: 1, y: 4 },
  { x: 2, y: 5 },
  // ...
  { x: 5, y: 0 },
];

ffp(array);

FFP library exports a function.

FFP()

Creates FFP utility.

ffp(array)

FFP utility is a function, invoke it on array of elements to filter them out.

ffp.maxDeltaY([delta])

If delta is specified, sets the maximum delta to the specified number. If delta is not specified, returns the current maximum delta value, which defaults to 1.

Maximum delta determines maximum variation between resulting trend and point position on ordinate axis.

ffp.epsilon([epsilon])

If epsilon is specified, sets the epsilon to the specified number. If epsilon is not specified, returns the current epsilon value, which defaults to 1/2³².

epsilon determines the maximum margin of error.

ffp.x([xAccessor])

If xAccessor is specified, sets the x accessor to the specified function. If xAccessor is not specified, returns the current x accessor, which defaults to (value, index) => index.

x accessor is invoked for each point.

ffp.y([yAccessor])

If yAccessor is specified, sets the y accessor to the specified function. If yAccessor is not specified, returns the current y accessor, which defaults to (value) => value.

x accessor is invoked for each point.

ffp.result([resultMapper])

If resultMapper is specified, sets the result mapper to the specified function. If resultMapper is not specified, returns the current result mapper, which defaults to ({ value }) => value.

result mapper is invoked for each point. By default, ffp(array) returns an array of objects with value and index keys. Define custom result mapper to modify this behavior.

Development

  • Run tests: yarn test;

License

MIT © Dmitriy Semyushkin