Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

to-uint8

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-uint8 - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

20

index.js

@@ -25,3 +25,3 @@ /* @module to-float32 */

for (var i = 0; i < src.length; i++) {
if (src[i].length != null) {
if (src[i] && src[i].length != null) {
src = flat(src)

@@ -39,3 +39,3 @@ break

if (src[i] > 1 || src[i] < 0) {
return new Uint8Array(src)
return uninfinite(new Uint8Array(src), src)
}

@@ -47,6 +47,6 @@ }

for (var i = 0; i < src.length; i++) {
pixels[i] = clamp(src[i] * 255, 0, 255)
pixels[i] = clamp(src[i], 0, 1) * 255
}
return pixels
return uninfinite(pixels, src)
}

@@ -56,3 +56,3 @@

if (src.length != null && typeof src !== 'string') {
return new Uint8Array(src)
return uninfinite(new Uint8Array(src), src)
}

@@ -63,3 +63,11 @@

if (!buf) return null
return new Uint8Array(buf)
return uninfinite(new Uint8Array(buf), src)
}
// disclose infinities
function uninfinite(u, src) {
for (var i = 0; i < src.length; i++) {
if (src[i] === Infinity) u[i] = 255
}
return u
}
{
"name": "to-uint8",
"version": "1.4.0",
"version": "1.4.1",
"description": "Convert data to Uint8Array",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -34,4 +34,7 @@ 'use strict'

// detect nested uints
a.deepEqual(u8({data: [0, 1, 1]}), [0, 255, 255])
// handle NaNs
a.deepEqual(u8([[null, undefined], [NaN, -0], [/abc/, Infinity, -Infinity]]), [0, 0, 0, 0, 0, 255, 0])
a.deepEqual(u8([null, undefined, NaN, -0, /abc/, Infinity, -Infinity]), [0, 0, 0, 0, 0, 255, 0])
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