Socket
Socket
Sign inDemoInstall

ecol

Package Overview
Dependencies
1
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ecol

Event Collections


Version published
Weekly downloads
220
decreased by-10.2%
Maintainers
1
Install size
1.50 MB
Created
Weekly downloads
 

Readme

Source

Event Collections

GitHub license npm version Downloads Build Status Chat on Gitter

Extension of TypeScript-STL Containers dispatching Events.

TSTL is an open-source project providing features of STL, migrated from C++ to TypeScript. You can enjoy the STL's own specific containers, algorithms and functors in the JavaScript. If TypeScript, you also can take advantage of type restrictions and generic programming with the TypeScript.

ECOL is an extension module of such TSTL, providing special collections dispatching events. The special collections are almost similar with the original STL Containers, but you also can observe elements' I/O events with the special collections. Types of the event dispatched by the special collections are "insert", "erase" and "refresh".

Features

Linear Collections

  • ArrayCollection
  • DequeCollection
  • ListCollection

Set Containers

  • Tree-based Collections
    • TreeSetCollection
    • TreeMultiSetCollection
  • Hash-buckets based Collections
    • HashSetCollection
    • HashMultiSetCollection

Map Collections

  • Tree-based Collections
    • TreeMapCollection
    • TreeMultiMapCollection
  • Hash-buckets based Collections
    • HashMapCollection
    • HashMultiMapCollection

Installation

NPM Module

Installing ECOL in NodeJS is very easy. Just install with the npm.

# Install TSTL from the NPM module
npm install --save ecol

Usage

import {TreeMapCollection} from "ecol";

function listener(event: TreeMapCollection.Event<number, string>): void
{
    console.log("Event type is: " + event.type);

    for (let it = event.first; !it.equals(event.last); it = it.next())
        console.log("\t", "An element by that event:", it.value);
}

function main(): void
{
    // CONSTRUCT EVENT TREE-MAP
    let map: TreeMapCollection<number, string> = new TreeMapCollection();
    map.addEventListener("insert", listener);
    map.addEventListener("erase", listener);

    // DISPATCHES INSERT EVENT
    map.set(1, "One");
    map.set(2, "Two");
    map.set(3, "Three");

    // DISPATCHES ERASE EVENT
    map.erase(2);
    map.erase(3);

    // DISPATCHES REFRESH EVENT
    map.set(2, "Second"); // AUTOMATIC
    map.refresh(); // BY USER
}
main();

References

Keywords

FAQs

Last updated on 14 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc