npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

memory-allocator

v0.1.0

Published

Simple ArrayBuffer memory allocator

Downloads

11

Readme

memory-allocator

A simple ArrayBuffer memory allocator for JS.

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 create 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.

async .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.