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

ldp-interval

v1.0.2

Published

This library was developed within an Undergraduate Research project to explore Local Differential Privacy (LDP) for protecting sensitive data on the user side. The research and initial development were funded by the Federal University of Goiás (UFG)

Downloads

288

Readme

LDP Interval

LDP Interval is a JS library for protect individual data focusing on AI usage.

The uses local differential privacy pattern for add a noise to the data resultin in a extra layer of protection to the data that are sent to proprietary models of artificila inteligence.

How it Works?

The library applies a Local Differential Privacy (LDP) inspired mechanism to protect sensitive numeric values before they are shared.

Instead of shending the original value, the algorithm:

  1. Determines the possible range of the data;
  2. Uses a privay paramter epsilon to calibrate the amount of noise;
  3. Generates random noise using a Laplace distribution;
  4. Adds the noise to the original value;
  5. Returns an interval derived from the noisy value.

Only the interval is shared with external systems, wich makes it difficult o infer the real value.

Installation

Install using npm:

npm i ldp-interval

or using yarn:

yarn add ldp-interval

Basic Usage

import {generatePrivateInterval} from 'ldp-interval';

const result = generatePrivateInterval(value, epsilon, minValue, maxValue)

// epsilon is related with the level of privacy you want, lowers epsilons corresponds to highers levels of privacy, higher epsilons corrensponds to lowers levels of privacy. Think carefully what`s your ideal epsilon.

// minValue corresponds to the minimum value of the data category, take that from your database.

// maxValue corresponds to the maximum value of the data category, also take that from your database.

output:

    {
        interval: [lower, upper]
    }

The interval will change every single execution because the noise is randomly generated.

Using Options Parameter

    import {generatePrivateInterval} from 'ldp-interval';

const result = generatePrivateInterval(value, epsilon, minValue, maxValue, options = {k = 1})

// the k value is the interval width multiplier, it say how many times the noise wil be multiplied, rainsing au or down the interval width. The default value is 1.

Epsilon Parameter

The privacy parameter controls the privacy vs accuracy trade-off.

| Epsilon value | Effect | |------|------| | small epsilon | stronger privacy | | medium epsilon | balanced privacy | | large epsilon | more accuracy |

Use cases

LDP Interval can be usefull for:

  • protecting user attributes before sending data to AI models;
  • anonymizing telemetry data
  • privacy-preserving analytics
  • knowledge graph anonymization
  • secure data sharing

Limitations

  • This library operates at the individual data level.
    • It does not provide dataset-level Differential Privacy guarantees and should be used as a local perturbation mechanism before data sharing.
  • Interval overlap
    • If the same data is provided a lot of times with different intervals, the real data could be estimated due to overleaps, so use wisely and try to record the same interval to a couple uses

License

MIT

Acknowledge

This library is part of a university research funded by the Federal University of Goiás (UFG) specifically the Vice-Rectorate for Research and Innovation (PRPI)