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 🙏

© 2024 – Pkg Stats / Ryan Hefner

proxc

v1.0.4

Published

ProxC allows you to create extensible classes using ES6 Proxy objects and design declarative APIs that are a joy to use.

Downloads

17

Readme

Build Status Coverage Status TypeScript NPM Version License

ProxC is an NPM Package that allows you to create extensible classes and design declarative APIs that are a joy to use.

Motivation

This package was heavily inspired by C++. In C++, you can overload the functionality of basic operators used on a class. This offers a new level of extensibility for defining custom APIs for your class implementations that are often exclusive to more lower-level programming languages.

In Javascript, Proxy Objects allow you to intercept and define custom behavior for fundamental operations such as property lookup/access [], assignment =, enumeration, and function invocation (). These can be used to design extensible ES6 classes that allow synthetic operator definition with functionality similar to that of operator overloading in languages such as C++.

ProxC aims to combine the functionality of ES6 Proxy Objects with the convenience Javascript Classes. No functionality is gained over using Proxy Objects, however, ProxC allows developers to stay away from convoluted implementation details and define customizable APIs that are both easier to use and maintain.

API Documentation

By extending ProxC in your class definition and defining the following member functions, you are able to design a fully custom interface for your API:

  • __invoke__(...args: any) → any

    Defines custom behavior for the class invocation/call operator, (). Invoked whenever a class instance is called as a function and forwards all arguments. Context is bound to the current class instance enabling you to use this to refer to internal class state.

    If not defined, and the class attempts to be invoked, a TypeError will be thrown.

    Example: myClass(1,2) calls __invoke__(1,2) on myClass.

  • __accessor__(key: number|string) → any

    Defines custom behavior for the class 'get' operator, also known as the 'accessor' or 'index' operator ([] or .). Invoked when bracket notation or dot notation is used on a class instance and the supplied key is not a member of the current class implementation.

    If not defined, default behavior is assumed and the class accessor operator will still work as expected.

    Example: myClass['hello'] invokes __accessor__('hello') on myClass if and only if myClass does not contain a member named hello and __accessor__ is implemented.

  • __iterator__() → any[]

    Defines how the class should be treated as an iterable object. Should return an array of elements that can be yielded to for..of loops.

    If not defined, and the class attempts to be iterated, a TypeError will be thrown.

    Example: for (const elt of myClass) {...} loops over the iterable returned by __iterator__ on myClass.

Examples

  1. Circular Array Data Structure