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

@garfish/loader

Package Overview
Dependencies
Maintainers
8
Versions
364
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@garfish/loader

loader module.

  • 1.4.2-beta-20220309105146.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
133
decreased by-91.23%
Maintainers
8
Weekly downloads
 
Created
Source

@garfish/loader

NPM version

Usage

import { Loader } from '@garfish/loader';

const loader = new Loader({
  maxSize: 1024 * 1024 * 15, // default number is "1024 * 1024 * 15"
});

loader.hooks.usePlugin({
  name: 'test-plugin1',

  beforeLoad({ url, config }) {
    // You can changed the request config
    if (url.includes('xx')) {
      url = url.replace('xx', '');
    }
    return { url, config };
  },

  loaded(data) {
    const { result, value } = data;
    data.n = 1;
    return data;
  },
});

loader.hooks.usePlugin({
  name: 'test-plugin2',

  loaded(data) {
    console.log(data.n); // 1
    // The "data.value" will be cached this time.
    // So, you can transform the request result.
    return data;
  },
});

loader.load('appName', 'https://xxx').then((result) => {
  console.log(result); // 2
});

Clear cache

const loader = new Loader();

loader.clear('appName'); // Clear all cached resources under "appName"
loader.clear('appName', 'js'); // Clear all "js" cache resources under "appName"

loader.clearAll(); // Clear all cached resources
loader.clearAll('css'); // Clear all "css" cached resources

Keywords

FAQs

Package last updated on 09 Mar 2022

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