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

asset-gopher

v0.0.3

Published

Promise-based asset loader designed for fetching resources from remote machines in a browser

Downloads

14

Readme

#Asset loading At a glance For some types of browser applications, namely video games and other media-rich applications, it is necessary to request batches of assets to be fetched programmatically. Often times this is done before caching them in memory, localStorage, or a webDB to be consumed syncronously by your application.

WEBSERVER <------> BROWSER -> CACHE?

#Why an asset loader? It is absolutely true that each asset could simply be requested individually and then processed. However, the semantics required by a web-browser to fetch files from a remote machine differ by file type. IE. Audio objects, Image objects, JSON data, even other javascripts are all fetched slightly differently.

The purpose of this loader is to allow the details of that fetching to remain opaque to the consumer while providing a single higher-level API for fetching a wide variety of assets.

#Supported data types The asset loader supports several data types out of the box AND has a simple api for overriding these built-ins OR for adding additional fetching routines.

##Loader.Asset (url, type, name) This is a constructor function used to define assets prior to fetching. All parameters are required and are strings

##Loader.addType (typeName, fetchFn) Add a handler for a specified type. N.B. Type is an arbitrary distinction specified by the consumer of this library. The provided fetchFn should return a promise for the eventual LoadedAsset.

##Loader.removeType (typeName) Remove a handler for a specified type.

##Loader.getType (typeName) Return the fetch function for a specified type

##Loader.fetch (Asset) Fetch a single asset and return a promise for a Loaded Asset.

##Loader.fetchMany (Assets) Fetch many assets and callback when all have either succeeded/failed. The param to the resolve handler of the promise will be an array of objects. Each object has an attribute "succeeded" which is true/false and an attribute "result" which is either a LoadedAsset or the origin Asset.