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

@ralph-yoan/product-predictor

v1.0.0

Published

A modular library to predict store stocks using nostra-data.

Downloads

95

Readme

Product Predictor

A TypeScript library for predicting store stock levels using the nostra-data prediction algorithm.

Description

product-predictor is a specialized TypeScript module designed to interface with store inventory data and advanced prediction algorithms. It bridges the gap between raw historical stock data and future inventory requirements by leveraging the nostra-data algorithm to analyze trends, sales velocity, and seasonal patterns.

Goal

The primary goal of this library is to empower store managers and automated systems to transition from reactive to proactive inventory management. By predicting stock levels across various time horizons (days, months, or years), the library helps in:

  • Minimizing Stockouts: Anticipting when a product will fall below its minimum threshold.
  • Optimizing Reorders: Providing data-driven insights for timely procurement.
  • Reducing Costs: Avoiding overstocking by accurately forecasting long-term demand.

Installation

npm install

Usage

Basic Example

import { createPredictor, StockData } from 'product-predictor';
import stockData from './data/stock-data.json';

// Initialize the predictor with your stock data
const predictor = createPredictor(stockData as StockData);

// Predict stock for a product in 30 days
const prediction = predictor.predictProductStock('PRD-0001', '30d');

console.log(`Product: ${prediction.productName}`);
console.log(`Current Stock: ${prediction.currentStock}`);
console.log(`Predicted Stock (30 days): ${prediction.predictedStock}`);

if (prediction.isBelowMinimum) {
    console.warn('Warning: Stock predicted to fall below minimum level!');
}

Getting Alerts

You can easily get a list of all products that are predicted to fall below their minimum stock levels within a specific timeframe:

const alerts = predictor.getAlerts('7d');
alerts.forEach(alert => {
    console.log(`Alert: ${alert.productName} will reach ${alert.predictedStock} in 7 days.`);
});

API Reference

createPredictor(jsonData: StockData)

Factory function to create a new StockPredictor instance.

StockPredictor Class

  • predictProductStock(productId: string, horizon: string): PredictionResult
  • getAlerts(horizon: string): PredictionResult[]

Types

  • StockData: The structure of the input JSON data.
  • PredictionResult: The object returned by prediction methods.

Data Structure

The library expects a JSON structure containing:

  • produits: Array of product details including stock_actuel and stock_minimum.
  • mouvements_stock: Historical movements (entrées/sorties) used for the prediction algorithm.

License

ISC