Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@bnaya/objectbuffer
Advanced tools
For Modern browsers and node.
Save, read and update plain javascript objects into ArrayBuffer
, using regular javascript object api,
without intermediate serialization/deserialization.
No pre-defined schema is required. In other words, It's a user-land implementation of javascript objects, using a single ArrayBuffer as the heap.
That's enables us to transfer
or share objects with a WebWorker
or other, same-origin, browsing contexts without data duplication or full serialization.
Using this library, and workers in general, will not necessarily make you code runs faster.
First be sure where your bottlenecks are, and if you don't have a better and more simple workaround.
I personally also really like what's going on around the main thread scheduling proposal and react userland scheduler that powers concurrent react
import { createObjectBuffer, getUnderlyingArrayBuffer } from "@bnaya/objectbuffer";
const initialValue = {
foo: { bar: new Date(), arr: [1], nesting:{ WorksTM: true } }
};
// ArrayBuffer is created under the hood
const myObject = createObjectBuffer(
// size in bytes
1024,
initialValue
);
myObject.additionalProp = "new Value";
myObject.arr.push(2);
const arrayBuffer = getUnderlyingArrayBuffer(myObject);
See also main.js for shared memory example.
to run it: clone the repo, yarn install
and yarn browser-playground
Participants is Adhere to the Code of Conduct.
The quickest way to get up and running is via and to run the tests.
Go over the contributing document.
Pick an issue with "good first" or "help wanted", or do some cool by your own!
Feel free to open an issue, or contact me directly at me@bnaya.net
Exchanging plain objects with WebWorkers
is done by serializing and copying the data to the other side.
for some use-cases, it's slow and memory expensive.
ArrayBuffer
can be transferred
without a copy, and SharedArrayBuffer
can be directly shared, but out of the box, it's hard to use ArrayBuffer
as more than a TypedArray.
I'm working on it mostly from personal interest, It's not in use in any production use-case.
Before putting any eggs in the basket, please go over the implementation details document
foo.bar2 = foo.bar
will not create a copy, but a reference)disposeWrapperObject
or to have WeakRef supportfoo.bar === foo.bar
will be true)ArrayBuffer
. When exceed that size, exception will be thrown. (Can be extended later with a utility function, but not automatically)bigint
bigger than 64 bitJSON.stringify
Symbol
0.32.1
FAQs
Object-like api, backed by an array buffer
The npm package @bnaya/objectbuffer receives a total of 31 weekly downloads. As such, @bnaya/objectbuffer popularity was classified as not popular.
We found that @bnaya/objectbuffer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.