This package has been deprecated

Author message:

'indexed-object' has been deprecated in favor of '@esfx/indexed-object'

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

1.1.0 • Public • Published

indexed-object

NOTE: indexed-object has been deprecated in favor of @esfx/indexed-object. Please update your references.

The indexed-object package provides a base class that allows for the definition of objects that support integer indexes similar to native Arrays and Typed Arrays.

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

Installation

npm i 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

Readme

Keywords

none

Package Sidebar

Install

npm i indexed-object

Weekly Downloads

2

Version

1.1.0

License

Apache-2.0

Unpacked Size

14.2 kB

Total Files

5

Last publish

Collaborators

  • rbuckton