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

tulpar

v1.0.3

Published

A comprehensive JavaScript and TypeScript enhancement library providing runtime type safety, performance optimizations, and modern syntax transformations

Readme

Tulpar

A comprehensive JavaScript and TypeScript enhancement library providing runtime type safety, performance optimizations, and modern syntax transformations.

npm version License: MIT

Tulpar is a powerful JavaScript module designed to address common limitations in JavaScript and TypeScript development. It provides runtime type checking, performance optimizations, modern syntax support, and advanced build-time tools to enhance your development experience and application performance.

Table of Contents

Features

Runtime Type Safety

Tulpar provides comprehensive runtime type checking that complements TypeScript's compile-time validation, ensuring type safety at runtime when it matters most.

  • Runtime Type Validation: Validate data structures at runtime with detailed error messages
  • Schema Definitions: Create reusable type schemas with support for primitives, objects, arrays, and custom validators
  • Type Inference: Automatic type inference with explicit validation
  • Error Reporting: Detailed validation errors with path information

Modern Syntax Support

Bring functional programming patterns and modern JavaScript features to your codebase.

  • Pattern Matching: Functional-style pattern matching for cleaner conditional logic
  • Pipeline Operator: Chain transformations elegantly without nested function calls
  • Lazy Evaluation: Defer expensive computations until needed
  • Immutability Helpers: Safe object manipulation with immutable updates

Performance Optimizations

Built-in performance tools to help you build faster applications.

  • Function Memoization: Automatic caching of function results for expensive computations
  • Tree Shaking: Remove unused code and exports to reduce bundle size
  • Code Splitting: Intelligent bundle splitting for optimal loading
  • Minification: Advanced code minification with size reporting

Build Tools

Production-ready build tools for optimizing your application bundles.

  • Dead Code Elimination: Automatically remove unreachable code
  • Side-effect Analysis: Detect and handle module side effects
  • Bundle Optimization: Optimize output bundles for size and performance

Developer Tools

Monitor and optimize your application's runtime behavior.

  • Memory Leak Detection: Automatic detection of potential memory leaks
  • Performance Monitoring: Track and analyze slow operations
  • Code Transformation: Transform modern syntax to compatible JavaScript

Installation

npm install tulpar

Requirements

  • Node.js 14.0.0 or higher
  • TypeScript 4.0.0 or higher (optional, for TypeScript projects)

Quick Start

Runtime Type Checking

import { type, validate } from 'tulpar/runtime';

// Define a schema
const UserSchema = type({
  name: String,
  age: Number,
  email: String
});

// Validate data at runtime
const user = validate(UserSchema, {
  name: 'John Doe',
  age: 30,
  email: '[email protected]'
});

Pattern Matching

import { match } from 'tulpar/runtime';

const result = match(value)
  .case(x => x > 10, () => 'large')
  .case(x => x > 5, () => 'medium')
  .default(() => 'small');

Pipeline Operator

import { pipe } from 'tulpar/runtime';

const result = pipe([1, 2, 3, 4, 5])
  .through(arr => arr.filter(x => x % 2 === 0))
  .through(arr => arr.map(x => x * 2))
  .value();

Memoization

import { memoize } from 'tulpar/runtime';

const expensiveFunction = (n: number) => {
  // Expensive computation
  return n * n;
};

const memoized = memoize(expensiveFunction);
memoized(5); // Computes and caches
memoized(5); // Returns cached result

Documentation

Runtime Type Checking

Tulpar's runtime type checking system provides comprehensive validation capabilities:

import { type, validate, validateSafe, optional, union, pattern } from 'tulpar/runtime';

// Basic type definition
const UserSchema = type({
  name: String,
  age: Number,
  email: String
});

// Optional fields
const OptionalSchema = type({
  name: String,
  age: optional(Number)
});

// Union types
const StringOrNumber = union(String, Number);

// Pattern validation
const EmailSchema = pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/);

Build Tools

Optimize your bundles with Tulpar's build tools:

import { TreeShaker, Bundler, Minifier } from 'tulpar/build-tool';

// Tree shaking
const result = TreeShaker.shake(modules, {
  removeUnusedExports: true,
  removeDeadCode: true
});

// Code bundling
const bundle = Bundler.bundle(modules, {
  codeSplitting: true,
  lazyLoading: true
});

// Minification
const minified = Minifier.minify(code, {
  removeComments: true,
  removeWhitespace: true
});

Performance Monitoring

Monitor your application's performance:

import { getPerformanceMonitor, getMemoryLeakDetector } from 'tulpar/runtime';

// Performance monitoring
const monitor = getPerformanceMonitor();
monitor.start('operation');
// ... perform operation ...
monitor.end('operation');
const report = monitor.getReport('operation');

// Memory leak detection
const detector = getMemoryLeakDetector();
detector.startMonitoring(5000); // Check every 5 seconds

API Reference

Runtime API

Type Checking

  • type(schema: TypeSchema): TypeDefinition - Create a type definition
  • validate<T>(schema: TypeSchema | TypeDefinition, value: any): T - Validate and throw on error
  • validateSafe<T>(schema: TypeSchema | TypeDefinition, value: any): ValidationResult<T> - Validate and return result
  • optional(schema: TypeSchema): CustomValidator - Make a field optional
  • union(...schemas: TypeSchema[]): CustomValidator - Create a union type
  • pattern(regex: RegExp): CustomValidator - String pattern validation

Utilities

  • match<T, R>(value: T): Match<T, R> - Pattern matching
  • pipe<T>(value: T): Pipeline<T> - Pipeline operator
  • memoize<T extends (...args: any[]) => any>(fn: T): MemoizedFunction<T> - Function memoization
  • lazy<T>(factory: () => T): Lazy<T> - Lazy value
  • deepClone<T>(obj: T): T - Deep clone
  • update<T, K extends keyof T>(obj: T, path: K, updater: (value: T[K]) => T[K]): T - Immutable update

Build Tools API

  • TreeShaker.shake(modules: Module[], options?: TreeShakeOptions): TreeShakeResult - Tree shaking
  • Bundler.bundle(modules: Module[], options?: BundleOptions): BundleResult - Code bundling
  • Minifier.minify(code: string, options?: MinifyOptions): string - Code minification

Compiler API

  • compile(code: string, options?: CompileOptions): CompileResult - Compile code with transformations
  • compileToES5(code: string, options?: CompileOptions): CompileResult - Compile to ES5
  • Parser.parse(code: string): ASTNode[] - Parse code into AST nodes
  • Transformer.transform(code: string, options?: CompileOptions): CompileResult - Transform code

Performance

Tulpar is designed with performance in mind. Benchmark results show significant improvements:

  • Memoization: Up to 40-60% faster for repeated computations
  • Tree Shaking: 30-50% bundle size reduction
  • Minification: 20-40% size reduction
  • Lazy Loading: 20-30% faster initial load times

Run benchmarks locally:

npm run test:benchmark

Examples

Comprehensive examples are available in the examples/ directory:

  • runtime-type-checking.ts - Runtime type validation examples
  • runtime-utilities.ts - Pattern matching, pipelines, and more
  • build-tool.ts - Tree shaking and bundling examples
  • performance-monitoring.ts - Performance monitoring examples
  • compiler.ts - Code transformation examples

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

tuna4l


Made with ❤️ for the JavaScript community