New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

as-buffers

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-buffers

Some Buffer classes for AssemblyScript

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

as-buffers

as-buffers provides some Buffer types for reading/writing string/bytes efficiently and simply.

Usage

There are 2 useful buffer classes here: BytesBuffer and StringBuffer.

  • BytesBuffer provides bytes related/endian related methods.
  • StringBuffer(is forked from MaxGraey) provides string (UTF16) related methods.

Write/Read bytes

let buf = BytesBuffer.wrap(new ArrayBuffer(0));
let val = 0x11 as i8;
buf.writeNumberBE<i8>(val);
let res = buf.readNumberBE<i8>(0);
expect(res).toBe(val);

Write/Read string

let buf = new StringBuffer();
buf.write("hello");
expect(buf.toString()).toBe("hello");

More usages

In addition to some safe methods, they also have some unsafe methods to improve performance. You need to pay attention to the buffer capacity and read/write offset.

See unit tests and source comments.

Keywords

FAQs

Package last updated on 01 Mar 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc