New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

blurhash-as

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blurhash-as

Blurhash algorithm implementation in AssemblyScript

  • 0.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
1
Weekly downloads
 
Created
Source

blurhash-as

Blurhash implementation in AssemblyScript

NPM JavaScript Style Guide Open in CodeSandbox

Install

npm install --save blurhash-as
yarn add blurhash-as

Usage

import * as blurhash from 'blurhash-as';

// Initialize the wasm module, optional
blurhash.init().then(() => {
  console.log('Initialized!');
});

// Encode image data
const hash = await blurhash.encode(imageData, width, height, xComponent, yComponent);

// Decode hash
const imageData = await blurhash.decode(hash, width, height, punch);
// You can also use any values for width and height, it is recommended
// to use a dimension with the same aspect ratio as your component dimensions.

// Generate a CSS sheet
const sheet = await blurhash.toCSSSheet(hash, displayWidth, displayHeight, punch);

// Or generate a Style Object
const style = await blurhash.toCSSObject(hash, displayWidth, displayHeight, punch);

// Or generate an SVG string
const svg = await blurhash.toSVG(hash, displayWidth, displayHeight, punch);

Browser

For browser context, you'll have to use blurhash-as/browser. The API is the same as blurhash-as with the inclusion of setURL for identifying the target WASM file. setURL is required to be called as-early-as-possible before using the provided blurhash functions.

Example in Vite:

import * as blurhash from 'blurhash-as/browser';
import wasmURL from 'blurhash-as/build/optimized.wasm?url';

blurhash.setURL(wasmURL);

Sponsors

Sponsors

License

MIT © lxsmnsyc

Keywords

FAQs

Package last updated on 03 Mar 2023

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

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