New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

datamap-interface

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datamap-interface

Simple interface for a map functioning as a database

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

datamap-interface Build Status Coverage Status

A simple interface for a map.

Installation

npm:

$ npm install datamap-interface

Component.js:

$ component install wooorm/datamap-interface

Bower:

$ bower install datamap-interface

Duo:

var DatamapInterface = require('wooorm/datamap-interface');

Usage

var DatamapInterface = require('datamap-interface');

var animals = new DatamapInterface({
    'shark' : 'fish',
    'tuna' : 'fish',
    'colugo' : 'mammal',
    'human' : 'mammal'
});

animals.get('human'); // 'mammal'
animals.get('unicorn'); // null

animals.add('unicorn', 'mammal').get('unicorn'); // 'mammal'

animals.remove('unicorn').has('unicorn'); // false

API

DatamapInterface(values)

datamap-interface exports a constructor, which can be passed an object.

var DatamapInterface = require('datamap-interface');

var animals = new DatamapInterface({
    'unicorn' : 'mystical creature',
    'shark' : 'fish',
    'tuna' : 'fish',
    'colugo' : 'mammal',
    'human' : 'mammal'
});

DatamapInterface#has(key)

Alias: DatamapInterface#is()

animals.has('unicorn'); // true
animals.has('rainbow'); // false

Returns whether (true) or not (false) a key is in the map.

DatamapInterface#get(key)

animals.get('unicorn'); // 'mystical creature'
animals.get('rainbow'); // null

Get the value for key in map, or null.

DatamapInterface#add()

animals.add('giant grouper', 'fish');

animals.add({
    'dragon' : 'mystical creature'
});
  • DatamapInterface#add(key, value): Add value as key to map;
  • DatamapInterface#add(values): Add every item in values to map.

Returns self.

DatamapInterface#remove(keys)

animals.remove(['giant grouper', 'human']);
animals.remove('dragon');
  • DatamapInterface#remove(key): Remove key from map;
  • DatamapInterface#remove(keys): Remove every key in keys from map.

Returns self. No error is thrown when non-existent values are removed.

DatamapInterface#keys()

animals.keys(); // ['shark', 'tuna', 'colugo', 'unicorn']

Return the map as an Object.

DatamapInterface#all()

Alias: DatamapInterface#valueOf(), DatamapInterface#toJSON()

animals.all();
/**
 * {
 *    'shark' : 'fish',
 *    'tuna' : 'fish',
 *    'colugo' : 'mammal',
 *    'unicorn' : 'mystical creature'
 * }
 */

Return the map as an Object.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 06 Jan 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc