0.2.0 • Published 1 year ago

as-virtual v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Virtual Type

The Virtual type is an efficient implementation for referencing segments of data without the need for constant memory allocations. This is particularly useful for tasks such as JSON parsing, where frequent slicing of strings can lead to high allocation rates. By using Virtual, you can reference memory segments directly, improving performance significantly. For example, this JSON implementation perviously parsed a Vec3 at 8,159,838m ops/s and with as-variant, it hit 39,260,740m ops/s.

Installation

npm install as-virtual

Usage

import { Virtual } from "as-virtual/assembly";

const virt = new Virtual<string>("foo bar", 3 << 1);
// Equiv. to "foo bar".slice(3)
// Note that we are referencing the memory directly and are using UTF-16

virt.equals("foo"); // true
virt.equals("baz"); // false

const virt2 = new Virtual<string>(" baz");
// Reinstantiate Virtual with new data
virt.reinst("bar", 6 << 1);

// Concat "bar" and " baz"
virt.merge(virt2);

console.log(virt.copyOut());
0.2.0

1 year ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago