
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
sharedarray
Advanced tools
Run npm install sharedarray in your project
Require using
const SharedArray = require('sharedarray')
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((number, buffer) => {
array2.sync(number, buffer)
})
//send that exportData to another thread/worker and then re-recreate array object
array2 = new SharedArray(exportData, (number, buffer) => {
array.sync(number, buffer)
})
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 two parameters 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
Did you know?

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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.