@esfx/indexed-object
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@esfx/indexed-object

The @esfx/indexed-object package provides a A base class for custom integer-indexed collections.

The underlying implementation uses a Proxy to trap integer indexes in a fashion similar to the Integer-Indexed Exotic Object in the ECMAScript specification.

Overview

Installation

npm i @esfx/indexed-object

Usage

import { IntegerIndexedObject } from "indexed-object";

class BooleansCollection extends IntegerIndexedObject {
    getLength() {
        return 2;
    }
    getIndex(index) {
        switch (index) {
            case 0: return false;
            case 1: return true;
            default: return undefined;
        }
    }
    // hasIndex(index): boolean
    // setIndex(index, value): boolean
    // deleteIndex(index): boolean
}

const booleans = new BooleansCollection();
console.log(booleans[0]); // false
console.log(booleans[1]); // true

API

You can read more about the API here.

Readme

Keywords

none

Package Sidebar

Install

npm i @esfx/indexed-object

Weekly Downloads

44

Version

1.0.0

License

Apache-2.0

Unpacked Size

34.3 kB

Total Files

8

Last publish

Collaborators

  • rbuckton