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

@produck/es-abstract-member

v0.4.1

Published

Ready-made parsers for declaring the members of an abstract constructor.

Readme

@produck/es-abstract-member

Ready-made parsers for declaring the members of an abstract constructor built with @produck/es-abstract-token.

Installation

npm install @produck/es-abstract-member

Usage

import Abstract from '@produck/es-abstract-token';
import * as _ from '@produck/es-abstract-member';

const AbstractSample = Abstract(
  class Sample {},
  ...[
    Abstract({
      foo: _.String,
      count: _.Number,
      createdAt: _.Instance(Date),
      check: _.Method().args(_.Number).returns(_.Boolean),
      pending: _.OrPromise(_.Number),
    }),
    Abstract.Static('qux', _.Boolean),
  ],
);

class SubSample extends AbstractSample {
  foo = 'implemented';
  count = 1;
  createdAt = new Date();
  pending = Promise.resolve(1);
  static qux = true;

  check(value) {
    return value > 10;
  }
}

const sample = new SubSample();

sample.foo; // 'implemented'
sample.check(25); // true
await sample.pending; // 1

API

Primitives

Each of them asserts the type of the member value.

  • Undefined — Asserts value is undefined.
  • Object — Asserts value is of type object (including null).
  • Boolean — Asserts value is of type boolean.
  • Number — Asserts value is of type number.
  • BigInt — Asserts value is of type bigint.
  • String — Asserts value is of type string.
  • Symbol — Asserts value is of type symbol.
  • Function — Asserts value is of type function.

Instance(constructor)

Asserts value is an instance of constructor.

_.Instance(Date);

Method()

Creates a member parser for a function member, with chainable operators:

  • .args(...parsers) — a parser for each positional argument.
  • .rest(parser) — the parser applied to every extra argument.
  • .returns(parser) — the parser applied to the return value.

Each operator may be called once, and none of them may be called after the member has been used.

_.Method().args(_.Number).returns(_.Boolean);

Promise(parser?) / OrPromise(parser?)

  • Promise(parser?) — asserts the value is a Promise, then applies parser to the resolved value.
  • OrPromise(parser?) — accepts a Promise or a plain value, and applies parser accordingly.

PromiseLike(parser?) / OrPromiseLike(parser?)

The same as Promise / OrPromise, but accepting any thenable instead of a Promise instance.

Iterable / AsyncIterable

  • Iterable — asserts the value is a synchronous iterable (Symbol.iterator) and returns it unchanged.
  • AsyncIterable — asserts the value is an async iterable (Symbol.asyncIterator) and returns it unchanged.

Strings are iterable, so _.Iterable('ab') passes; a bare next object does not.

Iterator / WellFormedIterator

  • Iterator — asserts the value exposes a callable next, and returns it unchanged.
  • WellFormedIterator — additionally requires Symbol.iterator to return the iterator itself, which is what for...of demands.

An async generator is an Iterator but not a WellFormedIterator.

Generator / AsyncGenerator

  • Generator — asserts the value is a generator function (function*).
  • AsyncGenerator — asserts the value is an async generator function (async function*).

Both check the function itself, not the iterator it produces.

Any / Unknown

A parser that passes any value through without validation. It is also the default parser when a declared member has none.

License

MIT

Author

Produck