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

@otorp/core

v1.0.0

Published

Otorp.js is a lightweight, zero-overhead JavaScript layer that standardizes and optimizes native APIs for better performance and ergonomics. It provides direct path execution, optimized methods, and configurable architectural governance. Designed for safe

Readme

Latest Release pipeline status

Otorp.js

A Safe, Governed Prototype Extension Engine

🎯 Objective

Otorp is an architecture-grade governance engine for extending native JavaScript and DOM prototypes safely and consistently.

It does not add any methods by default. Instead, it provides a structured, configuration-driven runtime that plugins and modules use to install aliases or custom methods onto native prototypes — with built-in collision avoidance, naming conventions, and selective exclusion.



📦 Installation

Otorp runs a single initialization pass then disappears from memory. All plugins and modules must be registered before Otorp loads.

<!-- 1. Optional configuration -->
<script>
  otorpConfig = { case: 'pascal', prefix: '', conflict: false }
</script>

<!-- 2. Plugins (must come before Otorp) -->
<script src="path/to/my-plugin.js"></script>

<!-- 3. Otorp core (always last) -->
<script src="path/to/otorp.js"></script>

Without at least one plugin or module registered, Otorp does nothing.


⚙️ How It Works

Otorp processes each registered plugin's endpoints during its init pass:

  1. Resolves each query string to a native descriptor or a plugin-provided factory.
  2. Applies naming conventions (case, prefix) and alias maps.
  3. Installs the resulting descriptor on the target prototype via Object.definePropertynon-enumerable, writable, configurable.
  4. Exits. No runtime footprint remains.

Query string format:

"source.meta1.meta2.methodName"
   │                    └── method name installed on the prototype
   │      └────────────── optional metadata forwarded to the factory
   └────────────────────── "Element", "Math", "Document", or a plugin source name

For native sources (Element, Math, Document, Array…), no factory is needed — Otorp retrieves the descriptor directly from the native prototype. For plugin sources, Otorp calls the registered factory with (methodName, ...meta) and installs the returned function.


🛡️ Configuration

All options are optional. Define otorpConfig as a plain object before loading Otorp.

| Option | Type | Default | Description | | :--- | :--- | :---: | :--- | | conflict | boolean | false | false — Safety default: skips any alias that already exists on the target prototype. Prevents overwriting native or third-party properties. true — Semantic lock: installs all aliases unconditionally. Use when you need guaranteed long-term behavioral stability. | | prefix | string | "" | Prepends a string to every alias (e.g. "$"element.$setAttr()). Eliminates collision risk at the cost of slightly longer names. | | case | string | "camel" | Casing convention for generated aliases. Accepted values: "camel", "pascal", "snake". Non-camel conventions further reduce native collision risk since native methods are always camelCase. | | exclude | string[] | [] | Native method names to skip entirely, regardless of which plugin registers them. Useful for controlled adoption of new native standards. | | warn | boolean | false | When true, logs a summary of all added and skipped methods to the console via console.warn after Otorp's init pass completes. Intended for development and debugging only. |

<script>
  otorpConfig = {
    case: 'pascal',       // → element.SetAttr(), document.Query()
    prefix: '',
    conflict: true,       // Semantic lock — override existing properties
    exclude: ['removeAttribute'],
    warn: true            // Log added/skipped methods via console.warn (dev only)
  }
</script>

🔌 Plugins

Any script that registers into otorp:modules before Otorp loads is a valid plugin. The recommended way is via @otorp/plugin-utils:

import setMod from '@otorp/plugin-utils';

setMod({
  source: 'myPlugin',
  endpoints: {
    HTMLElement: ['myPlugin.customMethod', 'myPlugin.meta.anotherMethod']
  },
  factory(methodName, ...meta) {
    return function (...args) {
      // `this` is the target instance
    };
  },
  aliases: {
    customMethod: ['custom', 'method']
  }
});

For plugins that only alias native methods, factory can be omitted — Otorp resolves descriptors directly from the native prototype.

See @otorp/plugin-utils for the full registration API and @otorp/native-aliases for a reference implementation.


❓ FAQ

Is Otorp a framework? No. It runs once at init time, configures prototypes, and exits. It imposes no project structure, rendering model, or runtime dependency.

Is prototype extension risky?
It can be without governance. Otorp mitigates this with:

  1. warn: true — Predictability is the main issue of prototype mutation.List all of otorp's
  2. conflict: false (default) — never overwrites existing prototype properties.
  3. prefix / case — makes collisions structurally impossible when used.
  4. exclude — opt out of specific utility at any time.

Does Otorp add anything by default? No. Without a plugin or module registered, Otorp's init pass completes instantly and leaves no trace.

How does Otorp handle future native additions?

  • conflict: false (default): new native methods automatically take precedence over Otorp aliases — no action needed.
  • conflict: true: Otorp aliases hold. Use exclude to selectively yield to specific native additions when ready.

🤝 Contributing

Contributions, bug reports, and feature requests are welcome! Please read CONTRIBUTING.md for guidelines.