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

@ryanmorr/fastmap

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@ryanmorr/fastmap

Accelerated hash maps

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

fastmap

Version Badge License Build Status

Accelerated hash maps

Description

Creates an efficient key/value store by instantiating a constructor function with an empty prototype. This is faster than using Object.create(null) to create "bare" objects, particularly in V8, making it the superior alternative for hash maps in memory intensive tasks. Full credit to Node.js for the technique.

Install

Download the CJS, ESM, UMD versions or install via NPM:

npm install @ryanmorr/fastmap

Usage

Use just like an object literal:

import fastmap from '@ryanmorr/fastmap';

const map = fastmap();

map.foo = 1;
map.bar = 2;

{}.toString.call(map); //=> "[object Object]"
JSON.stringify(map); //=> "{\"foo\":1,\"bar\":2}"

Unlike object literals, the object is empty:

'toString' in {}; //=> true
'toString' in fastmap(); //=> false

for (const key in map) {
    // `hasOwnProperty` check is unnecessary
}

Provide an object to pre-populate the map:

const map = fastmap(foo: 1, bar: 2, baz: 3});

map.foo; //=> 1
map.bar; //=> 2
map.baz; //=> 3

License

This project is dedicated to the public domain as described by the Unlicense.

Keywords

javascript

FAQs

Package last updated on 18 Jan 2024

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