Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

datalist-interface

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datalist-interface

Simple interface for a list functioning as a database

Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

datalist-interface Build Status Coverage Status

A simple interface for a list.

Installation

npm:

$ npm install datalist-interface

Component.js:

$ component install wooorm/datalist-interface

Bower:

$ bower install datalist-interface

Duo:

var DatalistInterface = require('wooorm/datalist-interface');

Usage

var DatalistInterface = require('datalist-interface');

var mammals = new DatalistInterface([
    'common vampire bat',
    'virginia opossum',
    'eastern grey kangaroo',
    'tasmanian devil',
    'human',
    'northern elephant seal',
    'fox squirrel',
    'tree pangolin',
    'african elephant',
    'platypus',
    'colugo',
    'reindeer',
    'humpback whale',
    'star-nosed mole',
    'giant panda',
    'giant armadillo',
    'plains zebra',
    'black and rufous elephant shrew'
]);

mammals.is('human'); // true
mammals.is('unicorn'); // false

mammals.add('unicorn').is('unicorn'); // true

mammals.remove('unicorn').is('unicorn'); // false

API

DatalistInterface(values)

datalist-interface exports a constructor, which can be passed an array.

var DatalistInterface = require('datalist-interface');

var fish = new DatalistInterface(['shark', 'tuna']);

The following functions are available on the instance:

DatalistInterface#is(value)

Alias: DatalistInterface#has(value)

fish.is('shark'); // true
fish.is('human'); // false

Returns whether (true) or not (false) a given value is in the list.

DatalistInterface#add(value...)

fish.add('giant grouper', 'red lionfish');

Add all arguments. Returns self.

DatalistInterface#remove(value...)

fish.remove('giant grouper', 'reindeer');

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

DatalistInterface#all()

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

fish.all(); // ['shark', 'tuna', 'red lionfish']

Return the list as an Array.

DatalistInterface#toString()

fish.toString(); // 'shark,tuna,red lionfish'

Return the list as a string.

License

MIT © Titus Wormer

Keywords

data

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