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

lawkit-js

v2.6.1

Published

Node.js bindings for lawkit - statistical law analysis toolkit for fraud detection, data quality assessment, and audit compliance. Powered by Rust for blazing fast performance.

Readme

lawkit

Node.js wrapper for the lawkit CLI tool - comprehensive statistical law analysis toolkit for fraud detection, data quality assessment, and business intelligence.

Installation

npm install lawkit

Includes all platform binaries (universal bundle) - no download required.

Supported Platforms

  • Linux: x86_64
  • macOS: x86_64 and Apple Silicon (ARM64)
  • Windows: x86_64

All binaries are pre-bundled in the package for immediate use:

bin/
├── linux-x64/lawkit
├── darwin-x64/lawkit  
├── darwin-arm64/lawkit
└── win32-x64/lawkit.exe

Quick Start

CLI Usage

# Fraud detection with Benford Law
lawkit benf financial-data.csv

# Business analysis with Pareto principle
lawkit pareto sales.csv --business-analysis

# Multi-law analysis
lawkit analyze data.csv --laws benf,pareto,zipf

# Data validation
lawkit validate data.csv --consistency-check

# Conflict diagnosis
lawkit diagnose data.csv --report detailed

# Generate test data
lawkit generate benf --count 1000 --output-file test-data.csv

JavaScript API (Unified API)

const { law } = require('lawkit');

// Benford's Law analysis on JavaScript array
const numbers = [123, 187, 234, 298, 345, 456, 567, 678, 789, 1234];
const benfordResult = law("benford", numbers);

console.log(`Benford analysis: ${benfordResult[0].data.analysis_summary}`);
console.log(`Risk level: ${benfordResult[0].data.risk_level}`);
console.log(`P-value: ${benfordResult[0].data.p_value}`);

// Pareto analysis
const salesData = [10000, 9500, 9000, 8500, 1000, 950, 900, 850, 800, 750];
const paretoResult = law("pareto", salesData);

console.log(`Top 20% contribution: ${paretoResult[0].data.top_20_percent_contribution}%`);

// Normal distribution analysis
const qualityScores = [98.5, 99.2, 100.1, 99.8, 100.4, 99.6, 100.8, 99.9];
const normalResult = law("normal", qualityScores);

console.log(`Mean: ${normalResult[0].data.mean}`);
console.log(`Standard deviation: ${normalResult[0].data.std_dev}`);

// Data validation
const testData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const validationResult = law("validate", testData);

console.log(`Validation passed: ${validationResult[0].data.validation_passed}`);
console.log(`Data quality score: ${validationResult[0].data.data_quality_score}`);

// Generate sample data
const config = { type: "benford", count: 100 };
const generatedResult = law("generate", config);

console.log(`Generated ${generatedResult[0].data.count} data points`);
console.log(`Sample data: ${generatedResult[0].data.sample_data.slice(0, 5)}...`);

// Comprehensive analysis
const comprehensiveData = {
  financial_data: [123, 187, 234, 298, 345],
  quality_scores: [98.5, 99.2, 100.1, 99.8, 100.4]
};
const analysisResult = law("analyze", comprehensiveData);

console.log(`Found ${analysisResult.length} analyses`);
analysisResult.forEach(result => {
  console.log(`${result.type}: ${result.data.analysis_summary}`);
});

API Reference

Unified API

law(subcommand, data, options?)

The unified function for all statistical law analysis.

Parameters:

  • subcommand: String - The analysis type ("benford", "pareto", "zipf", "normal", "poisson", "analyze", "validate", "diagnose", "generate")
  • data: Array or Object - The data to analyze (or configuration object for "generate")
  • options: Object (optional) - Analysis options

Supported Subcommands:

  • "benford" - Benford's Law analysis for fraud detection
  • "pareto" - Pareto Principle analysis for business insights
  • "zipf" - Zipf's Law analysis for frequency distributions
  • "normal" - Normal distribution analysis for quality control
  • "poisson" - Poisson distribution analysis for event analysis
  • "validate" - Data quality validation
  • "diagnose" - Data anomaly diagnosis
  • "generate" - Sample data generation
  • "analyze" - Comprehensive multi-law analysis

Return Value: Returns an array of analysis result objects, each containing:

  • type: The analysis type (e.g., 'BenfordAnalysis', 'ParetoAnalysis')
  • data: Analysis results with statistical measures and summary

Options

All analysis functions accept these common options:

interface LawkitOptions {
  output?: 'text' | 'json' | 'csv' | 'yaml' | 'toml' | 'xml';
  minCount?: number;
  confidence?: number;
  sampleSize?: number;
  minValue?: number;
  quiet?: boolean;
  verbose?: boolean;
  outputFile?: string;
  businessAnalysis?: boolean;
  giniCoefficient?: boolean;
  percentiles?: string;
  crossValidation?: boolean;
  consistencyCheck?: boolean;
  confidenceLevel?: number;
  report?: boolean;
}

Error Handling

const { law } = require('lawkit');

try {
  const result = law("benford", [1, 2, 3]);
  console.log(result);
} catch (error) {
  console.error('lawkit error:', error.message);
  // Handle error appropriately
}

Features

  • Universal Binary Support: Automatic platform detection and binary download
  • Comprehensive API: Full JavaScript API with TypeScript definitions
  • Statistical Laws: Benford, Pareto, Zipf, Normal, Poisson distributions
  • Advanced Analysis: Multi-law comparison, validation, diagnostics
  • Data Generation: Create test datasets for validation
  • Multiple Output Formats: JSON, CSV, YAML, TOML, XML support
  • Business Intelligence: Built-in business analysis features
  • Cross-platform: Linux, macOS (Intel & ARM), Windows support

Requirements

  • Node.js 12.0.0 or higher
  • Internet connection for initial binary download

License

MIT

Links