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

mloader

v0.0.2

Published

A cross platform Haxe library for loading resources with utilities for queueing and caching requests

Downloads

2

Readme

Overview

MLoader is a cross platform Haxe library for loading resources with utilities for queueing and caching requests. Supports AVM2, JavaScript, Neko and C++.

  • Signal based notification of loading events and errors
  • Leverages type parameters to type loaded content
  • Utilities for caching and queuing loaders
  • Supports local urls in Neko

Note: MassiveLoader includes a patch to haxe.Http to enable abortable Http requests. The patch is clearly documented in haxe/Http.hx

Installation

Install mloader from haxelib:

haxelib install mloader

Or if you want to install the latest directly from github:

haxelib git mloader https://github.com/massiveinteractive/mloader.git src/lib

And to point to your local fork:

haxelib dev mloader /ABSOLUTE_PATH_TO_REPO/src/lib

Basic Usage

You can download an more comprehensive cross platform example project here.

To load a string:

import mloader.Loader;

class Main
{
	public static function main()
	{
		var loader = new mloader.StringLoader("something.txt");
		loader.loaded.add(onLoaded);
		loader.load();
	}

	static function onLoaded(event:LoaderEvent<String>)
	{
		switch (event.type)
		{
			case Complete: trace(event.target.content);
			case Fail(e): trace("Loader failed: " + e);
		}
	}
}

You can also listen for specific events using msignal's forType method:

loader.loaded.add(onComplete).forType(Complete);

XmlLoader and JsonLoader will attempt to parse the response:

import mloader.Loader;

class Main
{
	public static function main()
	{
		var loader = new mloader.XmlLoader("something.xml");
		loader.loaded.add(onLoaded);
		loader.load();
	}

	static function onLoaded(event:LoaderEvent<Xml>)
	{
		switch (event.type)
		{
			case Complete:
				trace(event.target.content.firstElement());

			case Fail(e):
				switch (e)
				{
					case Format(info): trace("Could not parse Xml: " + info);
					case IO(info): trace("URL could not be reached: " + info);
					default: trace(e);
				}
		}
	}
}

LoaderQueue will sequentially load a list of loaders:

import mloader.Loader;
import mloader.LoaderQueue;
import mloader.ImageLoader;
import mloader.JsonLoader;

class Main
{
	public static function main()
	{
		var queue = new LoaderQueue();
		queue.maxLoading = 2; // max concurrent
		queue.ignoreFailures = false; // carry on regardless
		queue.loaded.addOnce(queueComplete).forType(Complete);

		var json = new JsonLoader("data.json");
		json.loaded.addOnce(jsonComplete).forType(Complete);

		queue.add(new ImageLoader("image-01.jpg"));
		queue.add(new ImageLoader("image-02.jpg"));
		queue.add(new ImageLoader("image-03.jpg"));
		queue.add(new ImageLoader("image-04.jpg"));
		queue.addWithPriority(jsonLoader, 1); // load first

		// start the queue
		queue.load();
	}
}

function queueComplete(event:LoaderEvent<Dynamic>)
{
	trace("LoaderQueue completed!");
}

function jsonComplete(event:LoaderEvent<Dynamic>)
{
	trace("JSON data loaded " + Std.string(event.target.content));
}

Documentation

The API documentation is available on the haxelib project page.

Or you can just read through the source ;)

How to contribute

If you find a bug, report it.

If you want to help, fork it.

If you want to make sure it works, install munit so you can run the test suite from the project root:

haxelib run munit test -js -as3 -neko

Credits

This project is brought to you by David and Mike from Massive Interactive