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

memory-allocator

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memory-allocator

Simple ArrayBuffer memory allocator

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
0
Created
Source

memory-allocator

A simple ArrayBuffer memory allocator for JS. It can be found on NPM as memory-allocator or @warriors-life/memory-allocator, or on GitHub Packages as latter.

Not to be confused with the memory-pool package, which removes the overhead of object creation by maintaining a pool of them and modifying their properties (see also PrimitivePool).

License

MIT.

Contributing

Feel free to open an issue or make a pull request! You can find contributing guidelines here and as a start you can work on any issue labelled "good first issue".

Documentation

The package exports MemoryAllocator class as the default and also exports MemoryRef class.

class MemoryAllocator

The main class.

constructor(bufferSize: number = 1024 ** 2)

bufferSize parameters controls minimal size of the new array buffers created by MemoryAllocator when it is impossible to allocate data in old buffers.

.addBuffer(size?: number >= bufferSize): ignore

Manually add a buffer of the specified size.

.allocate(size): MemoryRef

Allocate a slice of memory of the specified size. The resulting memory ref is returned.

class MemoryRef

Reference to a slice of memory. Note that underlying slice may be relocated during a manual defragmentation.

.free(): void

Mark the reference as freed. It can no longer be used after that and the underlying memory may be redistributed.

.toDataView(): DataView

Returns a DataView of the underlying memory, which can be read and written to.

.toTypedArray(class?: Class<? extends TypedArray> = Uint8Array): class

Returns a typed array mapped to the underlying memory, which can be read and written to.

FAQs

Package last updated on 25 Jul 2024

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