Socket
Book a DemoInstallSign in
Socket

namedtuplemap

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

namedtuplemap

A Map which accepts a named tuple of objects as a key

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

NamedTupleMap npm version Build Status Dependency Status Coverage Status

A Map which accepts a named tuple as a key. This lib is one of the several possible cache for memoize-immutable, but it can suit other use-cases as it implements a usual Map API.

Install

npm install --save NamedTupleMap

This lib has no dependency, but requires a native implementation of Map.

Usage

var NamedTupleMap = require('NamedTupleMap');

// When the `limit` option is set, NamedTupleMap turns into an LRU cache.
// Clearing the map every X seconds can also be an acceptable strategy sometimes.
var cache = new NamedTupleMap({ limit: 10000 });

var keyPart1 = {};
var keyPart2 = 'yolo';
var keyPart3 = [];
var value = {any: 'thing'};

// Note that following named tuples are wrapped in new objects that are !==
// (otherwise a Map would have been enough).
cache.set({
  oh: keyPart1,
  my: keyPart2,
  goodness: keyPart3
}, value);

cache.has({
  oh: keyPart1,
  my: keyPart2,
  goodness: keyPart3
}) === true;
cache.get({
  oh: keyPart1,
  my: keyPart2,
  goodness: keyPart3
}) === value;

Author

@louis_remi

License

MPL-2.0

Keywords

cache

FAQs

Package last updated on 21 Dec 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.