Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
typedarray
Advanced tools
Package description
The typedarray package provides a polyfill for TypedArray functionality that is available in modern browsers. It allows for the manipulation of binary data in a similar way to how it's done in native implementations.
Buffer creation
This feature allows for the creation of a buffer with a specified size. In this case, a Uint8Array with 1024 bytes is created.
var typedarray = require('typedarray');
var uint8 = new typedarray.Uint8Array(1024);
Buffer manipulation
This feature allows for the manipulation of the buffer's contents. Here, the first byte is set to 255 and the second byte to 0.
var typedarray = require('typedarray');
var buffer = new typedarray.Uint8Array(2);
buffer[0] = 255;
buffer[1] = 0;
Buffer slicing
This feature allows for the slicing of the buffer, creating a new view of the original buffer without copying the underlying memory. In this example, a slice from the second byte to the third byte is created.
var typedarray = require('typedarray');
var buffer = new typedarray.Uint8Array(4);
var slice = buffer.subarray(1, 3);
The 'buffer' package provides similar functionality for handling binary data in Node.js. It is a Node.js core module, so it's more commonly used and has a broader API than 'typedarray'.
The 'arraybuffer' package offers a minimalistic implementation for array buffer which is similar to typed arrays. It is less known and has fewer features compared to 'typedarray'.
The 'feross-buffer' package is a 'buffer' module from feross, which is browser-friendly. It's a drop-in replacement for Node's buffer module but designed to be used in the browser, similar to 'typedarray'.
Readme
TypedArray polyfill ripped from this module.
var Uint8Array = require('typedarray').Uint8Array;
var ua = new Uint8Array(5);
ua[1] = 256 + 55;
console.log(ua[1]);
output:
55
var TA = require('typedarray')
The TA
object has the following constructors:
With npm do:
npm install typedarray
To use this module in the browser, compile with browserify or download a UMD build from browserify CDN:
http://wzrd.in/standalone/typedarray@latest
MIT
FAQs
TypedArray polyfill for old browsers
The npm package typedarray receives a total of 17,003,169 weekly downloads. As such, typedarray popularity was classified as popular.
We found that typedarray demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.