New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mappedlist

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mappedlist

A mapped list like arrays are in PHP. Supporting only string keys and values at the moment.

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

mappedlist

A small and fast library for creating mapped lists like arrays in PHP.

This class was created because I am very used to working with arrays in PHP, and really missed the same structure in JavaScript/TypeScript.

This library only supports string as datatype for keys and values at the moment.

Usage

// Create a new list and populate it with some data
var list = new MappedList();
list.add("il", "Israel");
list.add("no", "Norway");
list.add("es", "Spain");
list.add("en", "England");

// Iterate list of IDs, check if each ID is a key in the
// list, and get the object in that case
var ids = ["il", "no", "se"];
ids.forEach(function(id) {
    if (list.has(id)) {
        var value = list.get(id);
        console.log("ID "+id+" has value '"+value+"'");
    }
    else {
        console.log("ID "+id+" does not exist in list");
    }
});

// Delete an element
list.delete("es");

// Get the number of elements in the list
console.log(list.length()); // outputs 3

console.log(list.getKey("Norway")); // Outputs "no"

##Build If you need to include this library on you webpage, you can build the javascript version by running the command "npm run build".

Keywords

mapped

FAQs

Package last updated on 08 May 2020

Did you know?

Socket

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