Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stdlib/buffer-alloc-unsafe

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/buffer-alloc-unsafe

Allocate a buffer having a specified number of bytes.

Source
npmnpm
Version
0.0.7
Version published
Weekly downloads
3.5K
-4.9%
Maintainers
4
Weekly downloads
 
Created
Source

alloc

NPM version Build Status Coverage Status

Allocate a buffer having a specified number of bytes.

Installation

npm install @stdlib/buffer-alloc-unsafe

Usage

var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );

allocUnsafe( size )

Unsafely allocates a buffer having a specified number of bytes.

var buf = allocUnsafe( 10 );
// returns <Buffer>

Notes

  • The underlying memory of returned Buffer instances is not initialized. Memory contents are unknown and may contain sensitive data.
  • When the size is less than half the pool size (specified on the Buffer constructor in modern Node.js environments), memory is allocated from the Buffer pool for faster allocation of new Buffer instances.

Examples

var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );

var buf;
var i;

// Repeatedly unsafely allocate memory and inspect the buffer contents...
for ( i = 0; i < 100; i++ ) {
    buf = allocUnsafe( 100 );
    console.log( buf.toString() );
}

See Also

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat

License

See LICENSE.

Copyright © 2016-2022. The Stdlib Authors.

Keywords

stdlib

FAQs

Package last updated on 16 Feb 2022

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