
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
"Keyed and Indexed Map", a pure javascript object that simulates the native 'Map' object with indexing features and others useful methods.
Pure javascript object that simulates the native 'Map' object with indexing features and others useful methods.
npm install --save kiMap
let kiMap = require('ki-map');
let map = new kiMap();
Set the logger object. By default is the native console object.
map.setLogger(mylogger);
map.setLogger(null); //To disable internal logging just pass a null object.
Show the internal data-structures and makes some simple checks.
map.debug({
label:'', // for a labeled debug output
complete:false // print all the internal structures
});
Current size of the collection.
let length = map.size;
Empty all internal structures and reset the counters. After this, the kiMap is totally cleaned.
map.clear();
Removes the specified element from the collection.
map.delete(3);
map.delete('label6');
if(map.delete(4)<0) console.warn('No object found!');
All the elements stored within the collection.
let it1 = map.entries();
let d1 = it1.next();
while(!d1.done){
console.log('index:',d1.value.i);
console.log('key:',d1.value.k);
console.log('data:',d1.value.d);
d1 = it1.next();
}
Executes a provided function once per each key/value pair in the Map object, in insertion order.
// Simple forEach
x.forEach(function(i,k,d,map){
console.log('index:',i);
console.log('key:',k);
console.log('data:',d);
});
// Usage of thisArg
class exampleClass{
fn(){
map.forEach(function(i,k,d,this_map){
this.show(i,k,d,this_map);
},this);
}
show(i,k,d,this_map){
console.log('index:',i);
console.log('key:',k);
console.log('data:',d);
}
}
let myObj = new exampleClass();
myObj.fn();
Get an element from the collection.
map.get(1);
map.get('label');
Returns a boolean indicating whether an element with the specified key exists or not.
map.has(1);
map.has('label');
All the keys within the collection.
map.keys(); //returns ['label1','label2','label3']
Adds or updates an element with a specified index and/or key and value.
// Insertion with label
x.set('label1',{oo:'obj1',cc:1}); // 1
// Simple insertion (the label will be 'autokey_1')
x.set({oo:'obj2',cc:2}); // 2
// Insertion in the specified position 3
x.set(3,{oo:'obj3',cc:3}); // 3
// Insertion in the specified position 3 with label 'mykey44'
x.set(4,{oo:'obj44',cc:44},{
key:'mykey44'
})); // 4
Returns a new Iterator object that contains the values for each element in the Map object in insertion order.
let it1 = map.entries();
let d1 = it1.next();
while(!d1.done){
console.log('data:',d1.value);
d1 = it1.next();
}
Returns the index of the element stored with the specified key.
map.indexOf('label3');
Returns the key of the element stored within the specified index.
map.keyOf(3);
Update the key of an item. If an item with new_key already exists, this method does nothing. To force the update and the overwrite, set force=true.
map.keyUpdate('label1', 'newlabel1'); // 1
map.keyUpdate('label3', 'label1'); // -1 - no update
map.keyUpdate('label3', 'label1', true); // 3 - the element 1 will have 'autokey_4'
Insert a bunch of values from an array. In case of key collisions, the key of the new element will be changed with an 'autokey_xx'.
map.setMany([
['tag20',{oo:'obj20',cc:20}],
['tag21',{oo:'obj21',cc:21}]
]);
map.setMany([
{oo:'obj30',cc:30},
{oo:'obj31',cc:31}
]);
Extends the current map with the values inside the 'map' argument. In case of key collisions, the key of the new element will be changed with an 'autokey_xx'.
map1.merge(map2);
Swap two items.
map.swap('label1','label2');
map.swap('label1',1);
map.swap(0,'label2');
map.swap(0,1);
Move the item with ki to the specified position
map.move('label1',4);
map.move(0,4);
The directory '/examples' has some useful examples ready to be executed as node scripts.
node ./examples/e1.js
I am still working on this project. So, please, report me any kind of bug or requests about new features. You can do it on GitHub Issues or via email. I will try to solve each issues in a reasonable time.
FAQs
"Keyed and Indexed Map", a pure javascript object that simulates the native 'Map' object with indexing features and others useful methods.
We found that ki-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.