• This repository has been archived on 22/Nov/2021
  • Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

âš¡ A very easy-to-use, blazing fast asset-loader using promises. Support older-browsers and preload images, audios and videos.

Build Status license license license

A very easy-to-use asset-loader using promises. Supports images, audio and video. Fully documented for a perfect usage in your TypeScript projects.

Installation

Install using yarn or npm:

  • yarn add loaderz
  • npm install loaderz --save

Usage

// Default export of Loaderz is the Loader.
import Loader from 'loaderz';

// A list of heavy images to load, it could be art-assets for your HTML5 game
const images = [
  'https://images.unsplash.com/photo-1549360336-6a77ea5193eb',
  'https://images.unsplash.com/photo-1549379458-e8f7034360a9',
  'https://images.unsplash.com/photo-1548175850-b5a765959436',
];

// Some audio elements to spice-up your HTML5 game
const audios = [
  'http://www.sample-videos.com/audio/mp3/crowd-cheering.mp3',
  'http://www.sample-videos.com/audio/mp3/wave.mp3',
];

// Instanciate the loader, you can easily implement it anywhere in your project
const loader = new Loader();

// Queue all our different resources (we can chain since queue returns the
// instance of loader)
loader
  .queue('image', images)
  .queue('audio', audios);

// Start loading the resources and have a full control of the global loading
// state using a promise and return a response with all elements loaded
loader.start()
  .then(response => console.log('All urls have been loaded, do whatever you want here:', response));

Docs

  • Loader#queue(type: string, src: string | string[]): accepts 3 different types of medias (audio, image, video).

  • Loader#start(): used to load all the queued resources. Returns a global promise of the resources loading.

  • Loader#queuedImages: an array of URLs of images queued to load.

  • Loader#queuedMedias: an array of MediaData elements queued to load.

Contribute

All the code is written in TypeScript. Feel free to contribute by creating issues, PRs or suggesting new features:

  1. Fork and clone the repo: [email protected]:username/loaderz.git
  2. Install all dev-deps: yarn install or npm install
  3. Run the demo: yarn demo (localhost:8080)
  4. Edit some files
  5. Run tests: yarn test or npm test
    • (optional) run yarn lint or npm run lint to automatically lint the files
  6. Commit and push your edits on a separate branch
  7. Create a PR which points on the develop branch

License

Under MIT license, view the license file for more informations.

More Repositories

1

totominc.github.io

Old repo for my old learning projects (mostly incremental-games).
JavaScript
74
star
2

skid-inc

Terminal-based idle-game, write commands to earn money, levelup and expand your botnet network.
JavaScript
40
star
3

vue3-select-component

A flexible & modern select-input control for Vue 3.
Vue
37
star
4

discord-stream

A music-streaming bot for Discord, made to be performant and used on thousands of servers.
TypeScript
4
star
5

vue-blaze-slider

A Vue 3 integration for the Blaze Slider library.
Vue
4
star
6

soundcloud-rich-presence

Set your Discord rich-presence to what you are listening on SoundCloud, similar to Spotify integration.
JavaScript
3
star
7

eslint-config-vue

My public ESLint config for Vue 3 + TypeScript.
JavaScript
2
star
8

TotomInc

2
star
9

mcdonald-price-comparator

TypeScript
1
star
10

node-express-mongo-rest-api

Node.js REST-API with Express and MongoDB (mongoose), written in TypeScript.
TypeScript
1
star
11

bookshelf-react

React exercice projet by creating a Bookshelf web-application.
TypeScript
1
star
12

command-parser

A modulable terminal command-parser trying to re-create a basic UNIX command-parser.
TypeScript
1
star
13

ExtraSkills-docs

Docusaurus documentation website for the ExtraSkills Spigot plugin.
JavaScript
1
star
14

eslint-config-react

My public ESLint config for React + TypeScript.
JavaScript
1
star
15

ExtraSkills

Add skills and level-up passives to make your survival server grindier like an RPG.
Java
1
star
16

js-garden-next

Personal blog with Next.js and SSR.
TypeScript
1
star
17

eslint-config-next

An enhanced ESLint config for Next.js with Airbnb + TypeScript + Prettier + TailwindCSS support.
JavaScript
1
star
18

gatsby-steelseries

A replica of the SteelSeries website made with Gatsby (React SSR), Prismic.io (headless CMS) and deployed with Netlify. Fully static, easily scalable.
JavaScript
1
star
19

poe-rain-of-arrow-guide

A small guide for levelling Rain of Arrow, made for readability for experienced players. Based on Fuzzy Duckzy build.
1
star