Home / manager

@okikio/manager

NPM | Github | API Guide | Licence

A superset of the Map class, it extends the Map classes capabilities with awesome new features; it weighs ~325 B (minified and gzipped).

Getting started

The Manager class makes Maps easier to use, as well as adding 7 methods, getMap, last, methodCall, add, remove, keys and values, (methodCall is a separate method from the Manager class, so treeshaking can get rid of it, if it isn’t need).

Note: the behavior of the keys and values methods are slightly modified, to return an Array of keys/values instead of an iterator. You can get the keys and values original effects by using .getMap().keys() or .getMap().values().

Installation

You can install @okikio/manager from npm via

npm i @okikio/manager
Others
yarn add @okikio/manager

or

pnpm i @okikio/manager

You can use @okikio/manager on the web via:

Once installed it can be used like this:

// There is,
//      .cjs - Common JS Module
//      .mjs - Modern ES Module
//      .js - UMD
import ASTRO_ESCAPED_LEFT_CURLY_BRACKET Manager } from "@okikio/manager";
import ASTRO_ESCAPED_LEFT_CURLY_BRACKET Manager } from "https://unpkg.com/@okikio/manager";
import ASTRO_ESCAPED_LEFT_CURLY_BRACKET Manager } from "https://cdn.jsdelivr.net/npm/@okikio/manager";
// Or
import ASTRO_ESCAPED_LEFT_CURLY_BRACKET Manager } from "https://cdn.skypack.dev/@okikio/manager";

// Via script tag
<script src="https://unpkg.com/@okikio/manager/lib/api.js"></script>
// Do note, on the web you need to do this, if you installed it via the script tag:
const ASTRO_ESCAPED_LEFT_CURLY_BRACKET Manager, methodCall } = window.manager;
// or
const ASTRO_ESCAPED_LEFT_CURLY_BRACKET default: Manager, methodCall } = window.manager;

Usage

@okikio/manager is used the same way Map is used.

Like this, in typescript,

import ASTRO_ESCAPED_LEFT_CURLY_BRACKET Manager } from "@okikio/manager";

let elements = new Manager<number, Node>();
let el = document.querySelector(".div");
elements.add(el);
elements.set(1, el.cloneNode());

in javascript,

import ASTRO_ESCAPED_LEFT_CURLY_BRACKET Manager } from "@okikio/manager";

let elements = new Manager();
let el = document.querySelector(".div");
elements.add(el);
elements.set(1, el.cloneNode());

Read through the API guide to learn more.

Browser & Node Support

ChromeEdgeFirefoxIE
> 38> 12> 13> 11

Learn about polyfilling, bundling, and more in the platform support guide.

Contributing

If there is something I missed, a mistake, or a feature you would like added please create an issue or a pull request on the beta branch and I’ll try to get to it.

Read through the contributing documentation for detailed guides.

Licence

See the LICENSE file for license rights and limitations (MIT).