npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

web-background

v1.0.3

Published

Running background in browser Worker

Downloads

4

Readme

Web Background

This module provides background runtime available on the web.
웹에서 사용할 수 있는 백그라운드 실행환경을 제공합니다.

API

background(fn)

  type FunctionInBackground<Fn> = (...params: Parameters<Fn>) => Promise<ReturnType<Fn>>;

  background<Fn>(fn: Fn): FunctionInBackground<Fn>

Example

CodeSandbox

async function runLongTask () {
  const getVertexCoordinates = background((imageData: ImageData) => {
    const { data, width } = imageData;
    let [minX, minY, maxX, maxY] = [Infinity, Infinity, 0, 0];

    for(let i = 0, leng = data.length; i < leng; i += 4) {
      const [r, g, b, a] = data.slice(i, i+4);
      const isFilled = Math.max(r, g, b, a) > 0;
      if(isFilled) {
        const y = Math.floor(i / 4 / width);
        const x = Math.floor(i / 4 - width * y);

        minX = Math.min(minX, x);
        minY = Math.min(minY, y);
        maxX = Math.max(maxX, x);
        maxY = Math.max(maxY, y);
      }
    }

    return {
      x: minX === Infinity ? 0 : minX,
      y: minY === Infinity ? 0 : minY,
      width: maxX,
      height: maxY
    };
  })

  const coordinate = await getVertexCoordinates(
    canvas.getContext('2d').getImageData(0, 0, 1000, 1000)
  )
}

Tip

  • Web Background is implemented as a Web Worker and is available in web browsers.
    Web Background는 웹 워커로 구현되며 브라우저에서 사용할 수 있습니다.

  • In most cases, you don't need to use it. It's recommended to use it for long working
    대부분의 경우 이 모듈을 사용할 필요는 없으나, 비용이 큰 작업을 처리해야 할 경우 사용할 것을 추천합니다.

  • Most WebAPIs including DOM APIs are cannot be used.
    DOM API를 포함한 대부분의 WebAPI를 사용하지 못합니다.
    Read More

  • To send arguments, you must use data from structured clone algorithm types.
    인자로 전송 가능한 데이터 유형은 복사 가능한 타입의 데이터만 가능합니다.
    Read More

  • It runs in isolation, cannot be access external variables and modules 격리된 환경에서 실행되므로 외부 모듈 및 외부 변수에 접근할 수 없습니다.