Skip to content

kojiy7214/jsclass-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

jsclass-map

Simple map class, which support logical operator.

Classes

Map

Functions

constructor(it)

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

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

Param Type Description
key any Key of the element to set.
val any Value 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

Param Type Description
it iterator Iteratable 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.

Param Type Description
key any Key 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

Param Type Description
key any Key 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.

Param Type Description
key any Key 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.

Param Type Description
v any value 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.

Param Type Description
map Map Map 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.

Param Type Description
map Map Map 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.

Param Type Description
map Map Map 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.

Param Type Description
map Map Map 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

Param Type
it Iterator

About

A normal map object with tiny foor prints

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published