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

sharedarray

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

sharedarray

Int32Array with infinite length using SharedArrayBuffer

unpublished
latest
Source
npmnpm
Version
1.0.8
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

SharedArray

Int32Array with infinite length using SharedArrayBuffer

License npm repo size open issues npm GitHub Workflow Status

Coverage lines Coverage functions Coverage branches Coverage statements

Installation

Run npm install sharedarray in your project

Require using

const SharedArray = require('sharedarray')

Usage

Example

let array = new SharedArray()

await array.set(10, 500)
let a = await array.get(10) // a = 500

await array.concatenate(0, [1, 2, 3])
let x = await array.get(0) // x = 1
let y = await array.get(1) // y = 2
let z = await array.get(2) // z = 3

let array2

//export array
let exportData = array.export((syncData) => {
    array2.sync(syncData)
})

//send that exportData to another thread/worker and then re-recreate array object
array2 = new SharedArray(exportData, (syncData) => {
    array.sync(syncData)
})

let b = await array2.get(10) // b = 500

The two objects need to be able to sync with each other over different threads. You therefore need to pass a sync function upon exporting, you will need to send the data to the other objects sync function. That also needs to happen in reverse, so when creating the second array you need to pass the sync function of the first object.
When using workers you will need to send this data using the postMessage function. The functions give you a the indexNumber and the buffer, this not actual data but rather a pointer.

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