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

easy-oop

v0.1.0

Published

A small, chainable OOP builder for modern JavaScript.

Readme

EasyOOP

EasyOOP is a small, dependency-free class builder for JavaScript. It creates ordinary classes, so instances behave as expected with new, instanceof, prototypes, and native super.

import OOP from "easy-oop";

const User = OOP
  .class("User")
  .properties({
    name: "",
    age: 0
  })
  .methods({
    hello() {
      console.log(`Hello ${this.name}`);
    }
  })
  .done();

.class() starts a class definition. .properties() adds instance defaults. .methods() adds prototype methods. .done() returns the final class.

Install

npm install easy-oop

EasyOOP requires Node.js 18 or newer and supports both ES modules and CommonJS.

const OOP = require("easy-oop");

Constructors

Use .constructor() for initialization work.

const User = OOP
  .class("User")
  .properties({ name: "", age: 0 })
  .constructor(function (name, age) {
    this.name = name;
    this.age = age;
  })
  .done();

const user = new User("Ada", 36);

Inheritance and parent access

Child classes inherit properties and methods. If a child does not declare a constructor, its nearest parent constructor is used. An overriding constructor can call this.super(...). For methods, use normal JavaScript super with concise method syntax.

const Admin = OOP
  .class("Admin")
  .inheritsFrom(User)
  .properties({ role: "admin" })
  .constructor(function (name, age) {
    this.super(name, age);
  })
  .methods({
    hello() {
      super.hello();
      console.log("Admin access granted");
    }
  })
  .done();

Use concise methods (hello() {}), not arrow functions, when calling super.

Property defaults and validation

Every instance gets its own arrays, plain objects, maps, sets, and dates. A value becomes a validation rule only when it includes type, validate, or factory, so { default: "dark" } remains a normal object default. For values that must be created dynamically, use factory.

const User = OOP
  .class("User")
  .properties({
    tags: [],
    createdAt: { factory: () => new Date() },
    age: { default: 0, type: Number, validate: (value) => value >= 0 }
  })
  .done();

type accepts a constructor such as String, Number, or your own class. validate must return true; it runs for the default and every later assignment.

Static members

const User = OOP
  .class("User")
  .staticProperties({ count: 0 })
  .staticMethods({
    create() {
      this.count += 1;
      return new this();
    }
  })
  .done();

Static methods inherit normally and can use concise-method super as well.

Getters and setters

const Person = OOP
  .class("Person")
  .properties({ firstName: "", lastName: "" })
  .getters({
    fullName() { return `${this.firstName} ${this.lastName}`.trim(); }
  })
  .setters({
    fullName(value) { [this.firstName, this.lastName] = value.split(" "); }
  })
  .done();

Mixins

Mixins are small reusable method objects.

const CanLog = OOP.mixin({
  log(message) { console.log(message); }
});

const User = OOP.class("User").uses(CanLog).done();

Private and protected-style data

JavaScript cannot expose truly private fields to methods supplied in an object literal without changing the method syntax. EasyOOP therefore provides non-enumerable stores available inside methods as $private and $protected.

const Account = OOP
  .class("Account")
  .privateProperties({ password: "" })
  .protectedProperties({ balance: 0 })
  .methods({
    authenticate(password) { return this.$private.password === password; },
    deposit(amount) { this.$protected.balance += amount; }
  })
  .done();

They are intentionally a JavaScript convention, not a security boundary. They do not appear in Object.keys() or JSON output.

Abstract classes and interfaces

.abstract() prevents direct construction but permits subclasses. Interfaces are lightweight runtime method contracts.

const Serializable = OOP.interface("Serializable", ["serialize"]);

const Record = OOP.class("Record").abstract().done();
const User = OOP
  .class("User")
  .inheritsFrom(Record)
  .implements(Serializable)
  .methods({ serialize() { return JSON.stringify(this); } })
  .done();

API

| Method | Purpose | | --- | --- | | .inheritsFrom(Class) | Inherit from another EasyOOP class. | | .properties(values) | Add public instance defaults or validated properties. | | .constructor(fn) | Set an instance constructor. | | .methods(values) | Add prototype methods. | | .staticProperties(values) / .staticMethods(values) | Add static members. | | .getters(values) / .setters(values) | Add accessors. | | .privateProperties(values) / .protectedProperties(values) | Add scoped, non-enumerable stores. | | .uses(mixin) | Add a mixin created by OOP.mixin(). | | .implements(interface) | Enforce methods from OOP.interface(). | | .abstract() | Make a class non-instantiable directly. | | .done() | Finalize and return the class. |

Development

npm test
npm run check
npm run typecheck
npm run benchmark
npm run benchmark:features
npm run benchmark:memory

The package has no runtime dependencies, does not use eval, and does not use proxies.