🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

bufferish

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufferish

Node.js Buffer Methods for Uint8Array and Array

0.1.0
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

bufferish Build Status

This module provides some compatible methods of Node.js's Buffer API which work with Uint8Array and Array as well as Buffer instance. It's light-weight and just 5KB when minified without Buffer shim.

Build Status

alloc(size)

See Buffer.alloc().

Bufferish.Array.alloc(size)

It creates a new Array instance of size elements.

Bufferish.Buffer.alloc(size)

It creates a new Buffer instance of size bytes. It's available only when Buffer class available.

Bufferish.Uint8Array.alloc(size)

It creates a new Uint8Array instance of size bytes. It's available only when Uint8Array class available.

Bufferish.alloc(size)

It creates a new instance of one of Buffer, Uint8Array or Array, depending on the environment.

Bufferish.alloc.call(ref, size)

It creates the same type instance of ref which is one of Buffer, Uint8Array or Array instances. It may cost less when a native copy methods is available.

from(src)

See Buffer.from(). src is an Array-like instance such as Buffer, Uint8Array or Array. String is also allowed.

Bufferish.Array.from(src)

It creates a new Array instance copied from src.

Bufferish.Buffer.from(src)

It creates a new Buffer instance copied from src.

Bufferish.Uint8Array.from(src)

It creates a new Uint8Array instance copied from src.

Bufferish.from(src)

It creates a copied instance of one of Buffer, Uint8Array or Array, depending on the environment.

concat(list)

See Buffer.concat(). list is an Array which contains an Array-like instances such Buffer, Uint8Array or Array.

Bufferish.Array.concat(list)

It creates a new Array instance concatenated.

Bufferish.Buffer.concat(list)

It creates a new Buffer instance concatenated.

Bufferish.Uint8Array.concat(list)

It creates a new Uint8Array instance concatenated.

Bufferish.concat(list)

It creates a concatenated instance of one of Buffer, Uint8Array or Array, depending on the environment.

Bufferish.isXXX()

Bufferish.isArray(array)

It returns true if array is an Array instance. See Array.isArray().

Bufferish.isArrayBuffer(arraybuffer)

It returns true if arraybuffer is an ArrayBuffer instance.

Bufferish.isBuffer(buffer)

It returns true if buffer is a Buffer instance. See Buffer.isBuffer().

Bufferish.isView(typedarray)

It returns true if typedarray is Uint8Array or other TypedArray instance. See ArrayBuffer.isView().

Bufferish.prototype.XXX.call()

Those methods must be called with call() to perform the trick.

src is an Array-like instance such as Buffer, Uint8Array or Array.

Bufferish.prototype.copy.call(src, target, targetStart, start, end)

It copies data from a region of src to a region in target. See Buffer.prototype.copy().

Bufferish.prototype.slice.call(src, start, end)

It returns a new instance from a region of src. See Buffer.prototype.slice().

Bufferish.prototype.toString.call(src, encoding, start, end)

It returns a String from a region of src. Please note that encoding may not be supported and just ignored. See Buffer.prototype.toString().

Bufferish.prototype.write.call(buf, string, offset)

It writes String to buf at the offset. See Buffer.prototype.write().

Other methods

Any other methods which are not described above are not supported with the module. Please consult with Buffer shim instead.

Installation

npm install bufferish --save

Webpacked

The standalone builds for Web browsers are also shipped.

It's minified WITHOUT Buffer shim. Just 5KB.

It's minified WITH Buffer shim. 26KB. Bufferish.original refers the shim module.

GitHub

License

The MIT License (MIT)

Copyright (c) 2015-2016 Yusuke Kawasaki

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

Array

FAQs

Package last updated on 09 Jul 2016

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