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

sharedhashmap

Package Overview
Dependencies
Maintainers
1
Versions
6
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

sharedhashmap

HashMap using SharedArrayBuffer

unpublished
latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

SharedHashMap

HashMap using SharedArrayBuffer

License npm repo size open issues npm GitHub Workflow Status

Coverage lines Coverage functions Coverage branches Coverage statements

Installation

Run npm install sharedhashmap in your project

Require using

const SharedHashMap = require('sharedhashmap')

Usage

Example

const map = new SharedHashMap()

await map.set('test', 'testvalue')
let x = await map.get('test') // x = 'testvalue'

let keys = await map.keys // keys = ['test']

let map2
// export hashmap
let exportedMap = map.export((syncData) => {
    map2.sync(syncData)
})

//send that exportedMap to another thread/worker and re-create map object
map2 = new SharedHashMap(exportedMap, (syncData) => {
    map.sync(syncData)
})
let y = await map2.get('test') // y = 'testvalue'

The sync functions are needed because the buffers are created dynamically. This is more memory efficient but requires you to implement the sync functions. You need to pass them when exporting the map and when creating the second map object. No actual data is sent over this, just the SharedArrayBuffers which acts like a pointer. When using workers you will want to send this using postMessage.

FAQs

Package last updated on 24 Apr 2022

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