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

blurhash

Package Overview
Dependencies
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blurhash - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

.DS_Store

9

CHANGELOG.md
# Changelog
## 1.1.2 (June 29, 2019)
- added `isBlurhashValid()` utility
## 1.1.1 (June 29, 2019)
* fixed incorrect type declaration path in package.json
* improved error handling
- fixed incorrect type declaration path in package.json
- improved error handling

@@ -0,2 +1,6 @@

export declare const isBlurhashValid: (blurhash: string) => {
result: boolean;
errorReason?: string;
};
declare const decode: (blurhash: string, width: number, height: number, punch?: number) => Uint8ClampedArray;
export default decode;

@@ -6,2 +6,26 @@ "use strict";

var error_1 = require("./error");
/**
* Returns an error message if invalid or undefined if valid
* @param blurhash
*/
var validateBlurhash = function (blurhash) {
if (!blurhash || blurhash.length < 6) {
throw new error_1.ValidationError("The blurhash string must be at least 6 characters");
}
var sizeFlag = base83_1.decode83(blurhash[0]);
var numY = Math.floor(sizeFlag / 9) + 1;
var numX = (sizeFlag % 9) + 1;
if (blurhash.length !== 4 + 2 * numX * numY) {
throw new error_1.ValidationError("blurhash length mismatch: length is " + blurhash.length + " but it should be " + (4 + 2 * numX * numY));
}
};
exports.isBlurhashValid = function (blurhash) {
try {
validateBlurhash(blurhash);
}
catch (error) {
return { result: false, errorReason: error.message };
}
return { result: true };
};
var decodeDC = function (value) {

@@ -25,6 +49,4 @@ var intR = value >> 16;

var decode = function (blurhash, width, height, punch) {
validateBlurhash(blurhash);
punch = punch | 1;
if (blurhash.length < 6) {
throw new error_1.ValidationError("The blurhash string must be at least 6 characters");
}
var sizeFlag = base83_1.decode83(blurhash[0]);

@@ -35,6 +57,2 @@ var numY = Math.floor(sizeFlag / 9) + 1;

var maximumValue = (quantisedMaximumValue + 1) / 166;
if (blurhash.length !== 4 + 2 * numX * numY) {
throw new error_1.ValidationError("blurhash length mismatch: length is " + blurhash.length + " but it should be " + (4 + 2 * numX * numY));
return null;
}
var colors = new Array(numX * numY);

@@ -41,0 +59,0 @@ for (var i = 0; i < colors.length; i++) {

@@ -1,3 +0,3 @@

export { default as decode } from "./decode";
export { default as decode, isBlurhashValid } from "./decode";
export { default as encode } from "./encode";
export * from "./error";

@@ -8,2 +8,3 @@ "use strict";

exports.decode = decode_1.default;
exports.isBlurhashValid = decode_1.isBlurhashValid;
var encode_1 = require("./encode");

@@ -10,0 +11,0 @@ exports.encode = encode_1.default;

{
"name": "blurhash",
"version": "1.1.1",
"version": "1.1.2",
"description": "Encoder and decoder for the Wolt BlurHash algorithm.",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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