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

imachi

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imachi

Tiny image loader.

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

imachi 🌖

Tiny image loader.

Installation:

# yarn
yarn add -D imachi
# npm
npm install -D imachi
# pnpm
pnpm i -D imachi

Import:

import { imachi } from "imachi";

Usage:

const loader = imachi('img');

// progress
loader.progress((event) => {
  console.log(`Loading progress: ${event.progress.percentage}%`);
});

// done
loader.done((event) => {
  console.log(`All images loaded: ${event.total} images`);
});

// fail
loader.fail((event) => {
  console.error(`Failed to load image: ${event.src}`);
});

Events

.progress

Called each time an image loads successfully.

const loader = imachi('img');

loader.progress((event) => {
  console.log(`Loading progress: ${event.progress.percentage}%`);
});
  • imageElement: HTMLImageElement - Loaded image
  • progress
    • count: number - Current count
    • percentage: number - Load completion (%)
    • total: number - Total count

.done

Called when the entire loader process finishes.

const loader = imachi('img');

loader.done((event) => {
  console.log(`All images loaded: ${event.total} images`);
});
  • images: [] - Loaded images
    • src: string - Image source
    • element: HTMLImageElement - Image element
  • total: number - Total count

.fail

Called when an image fails to load.

const loader = imachi('img');

loader.fail((event) => {
  console.error(`Failed to load image: ${event.src}`);
});
  • src: string - Image source
  • element: HTMLImageElement - Image element
  • error: Error - Error object

FAQs

Package last updated on 27 Feb 2024

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