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

protoface

v0.0.2

Published

Prototype-Interface for JavaScript.

Readme

Protoface

Like OO Interfaces, we need to ensure the prototypal objects must implement specific methods.

Why ?

The Mixin pattern allows us to write extendable plugins. But what if we need these plugins to exactly have specific methods? It is like we need the object to implement some methods, with desired arguments.

How it works

Protoface validates objects in plain JSON format through JSON Schema. Using JJV validator it extends the core functionality and allow JSON Schema to accept function data type.

It is a slim wrapper over JJV, and exposes a single instance of it, allowing the rest of the object to be validated through JJV.

Example

var p = require('protoface');

// How functions are validated through Json Schema.
var schema = {
  "type": "object",
  "properties": {
    "fn": {
      "type": "function",
      "arguments": ["arg1", "arg2"]
    }
  }
};

var data = {
  fn: function(arg1, arg2) {}
};

var err = p(schema, data); // err === null

...

// The implemntation of method and arguments should be correct.
var schema = {
  "type": "object",
  "properties": {
    "fn": {
      "type": "function",
      "arguments": ["arg1", "arg2"]
    }
  }
};

var data = {
  fn: function(arg1) {}
};

var err = p(schema, data); // { validation: { fn: { arguments: true } } }

...

// The existence of extra arguments should not break the validation, alongside 
// other different typed properties. 
var schema = {
  "type": "object",
  "properties": {
    "fn": {
      "type": "function",
      "arguments": ["arg1", "arg2"]
    },
    "coords": {
      "type": "object",
      "properties": {
        "x": {
          "type": 'number'
        },
        "y": {
          "type": 'number'
        }
      },
      "required": ["x", "y"]
    }
  }
};
var data = {
  fn: function(arg2, arg1, arg3) {},
  coords: {x: 1, y: 2}
};

var err = p(schema, data); // err === null

...

// JJV functionality is still exposed.

var p = require('protoface'); // Based on require('jjv')().

var err = p({
  type: 'object',
  properties: {
      x: {
          type: 'number'
      },
      y: {
          type: 'number'
      }
  },
  required: ['x', 'y']
 }, {x: 20, y: 50}); // err === null

License

MIT