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 🙏

© 2025 – Pkg Stats / Ryan Hefner

res-manager

v0.9.0

Published

A class for better loading and managing resources.

Downloads

4

Readme

ResourceManager

A class for better loading and managing resources.

Demo

You can view the live demo here.

Usage

npm install res-manager --save

IResourceEntry

This interface is used for describing a resource.

interface IResourceEntry {
  // a switch for preloading
  preload: boolean;
  // name of this resource
  name: string;
  // url of this resource
  src: string;
  // type of this resource
  type: 'image' | 'video' | 'audio';
  // weight of this resource
  weight: number;
}

ResourceManager

Main class for managing resources.

|Method|Type|Description| |-|-|-| |constructor|() => ResourceManager|Constructor function.| |registerOnProgress|(onProgress: (progress: number, string: string) => ResourceManager) => void|Register an callback for progress.| |registerOnError|onError: (error: Error, current: string) => ResourceManager) => ResourceManager|Register an callback for error.| |registerOnComplete|onComplete: () => ResourceManager) => ResourceManager|Register an callback for completing.| |init|(list: IResourceEntry[], timeout?: number) => ResourceManager|Initialize manager by new resources and timeout.| |load|(onProgress?: (progress: number, string: string) => void, onComplete?: () => void, onError?: (error: Error, current: string) => void) => ResourceManager|Trigger loading, you can register callbacks here.| |getSrc|(name: string) => string|Get source by name.| |reset|() => ResourceManager|Reset all options and state.|

|Accessors|Type|Description| |-|-|-| |progress|number|Progress of loading.| |loadDone|boolean|If the loading was done.|

import {IResourceEntry}, ResourceManager from 'res-manager';

const resourceManager = new ResourceManager();
const resources: IResourceEntry = [
  {
    preload: true,
    name: 'H光大小姐',
    src: 'http://oekm6wrcq.bkt.clouddn.com/hh.png',
    type: 'image',
    weight: 1
  },
  {
    preload: true,
    name: '秦皇岛',
    src: 'http://oekm6wrcq.bkt.clouddn.com/秦皇岛.mp3',
    type: 'audio',
    weight: 1
  },
  {
    preload: true,
    name: 'bml2017',
    src: 'http://oekm6wrcq.bkt.clouddn.com/bml-h5.mp4',
    type: 'video',
    weight: 1
  }
];
resourceManager.load(
  (progress, current) => {
    console.log(current, progress);
  },
  (error, current) => {
    console.log(error, progress);
  }
);
const imgSrc = resourceManager.getSrc('H光大小姐');

Contribute

Development

Run:

npm run dev

then open localhost:4444.

Build

Run:

npm run build

License

Copyright © 2017, 戴天宇, Tianyu Dai (dtysky < [email protected] >). All Rights Reserved. This project is free software and released under the MIT License.