0.1.3 • Published 6 years ago

jsclass-map v0.1.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Build Status

jsclass-map

Simple map class for general purpose.

What Makes "jsclass-map" Unique

"jsclass-map" supports logical operations between two maps like "or", "and", "xor". Since those methods returns "jsclass-map" object, developers can chain logical operations to create a new map, along with clear(), set(), setAll() and remove() methods.

How to Use

Just create a object, using class exported by the module. For more information, please visit GitHub for complete api documentation, under "doc" folder or API.md.

const Map  = require("jsclass-map");

let map = new Map();

map.set("k1", 1);
let val = map.get("k1");

API

Modules

Classes

Functions

jsclass-map

Simple map class, which support logical operator.

Map

Kind: global class

map.clear() ⇒ Map

Remove all elements.

Kind: instance method of Map
Returns: Map - This Map

map.isEmpty() ⇒ Boolean

Check if the map has no element.

Kind: instance method of Map
Returns: Boolean - If map has no element, then true.

map.size() ⇒ Number

Count elements in map.

Kind: instance method of Map
Returns: Number - Count of elements in map.

map.set(key, val) ⇒ Map

Set element to map. If the map already has a same key, old value will be over written by aruguments value. Key may take any object, but null and undefined.

Kind: instance method of Map
Returns: Map - This Map

ParamTypeDescription
keyanyKey of the element to set.
valanyValue of th element to set.

map.setAll(it) ⇒ Map

Set all elemetns in given iterator to map. All elements in the Iterator should have "key" and "value" as property.

Kind: instance method of Map
Returns: Map - This Map

ParamTypeDescription
ititeratorIteratable object with valid elements.

map.get(key) ⇒ any

Returns the value associated with key. If key is not present in map, then undefined will be returned.

Kind: instance method of Map
Returns: any - Associated value.

ParamTypeDescription
keyanyKey of an element tobe located.

map.remove(key) ⇒ Map

Remove element, with given key. If key is not present in map, then nothing happens.

Kind: instance method of Map
Returns: Map - This Map

ParamTypeDescription
keyanyKey of an element to remove.

map.has(key) ⇒ Boolean

Check if given key is present in map

Kind: instance method of Map
Returns: Boolean - If present, then true.

ParamTypeDescription
keyanyKey to check.

map.hasValue(v) ⇒ Boolean

Check if given value is present in map

Kind: instance method of Map
Returns: Boolean - If present, then true.

ParamTypeDescription
vanyvalue to check.

map.keys() ⇒ Array

Returns an array of key, contains in map.

Kind: instance method of Map
Returns: Array - Array of keys.

map.or(map) ⇒ Map

Merge two maps and create a new map. When both maps have elements with same key, vallues are set to match argument map.

Kind: instance method of Map
Returns: Map - Result map.

ParamTypeDescription
mapMapMap to operate.

map.and(map) ⇒ Map

Extract common elements between original map and argument maps. Values are set to match argument map.

Kind: instance method of Map
Returns: Map - Result map.

ParamTypeDescription
mapMapMap to operate.

map.xor(map) ⇒ Map

Merge elements with unique keys between original and argument map. Result Map will be exactly the same map as, sustarcting the intersection from the union of original and argument maps.

Kind: instance method of Map
Returns: Map - Result map.

ParamTypeDescription
mapMapMap to operate.

map.diffVal(map) ⇒ Map

Extract elements between twu maps, which have common key but different values.

Kind: instance method of Map
Returns: Map - Result map.

ParamTypeDescription
mapMapMap to compare.

constructor(it)

Creates map object. You may pass itereator to initialize map at creation. Iterator should contain objects with "key" and "value" property.

Kind: global function

ParamType
itIterator
0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago