Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed exports

  • Loading branch information...
commit d3348703df716a923788617767d613d34542b535 1 parent 6c25ceb
@hughfdjackson authored
Showing with 34 additions and 27 deletions.
  1. +0 −1  index.html
  2. +34 −26 src/load_images.js
View
1  index.html
@@ -3,4 +3,3 @@
load_images({ninja: "images/ninja.png"}, function(images){ console.log(images)})
</script>
-huh
View
60 src/load_images.js
@@ -1,30 +1,38 @@
-function load_images(image_object, callback){
-
- var to_load = 0,
- images
+void function(root){
- // logic
- if ( image_object instanceof Array ) images = []
- else images = {}
-
- for ( var prop in image_object ){
- load(prop, image_object[prop])
- }
- // helper methods (impure)
- function on_load(){
- to_load -= 1
- if ( to_load == 0 && callback ) callback(images)
- }
-
- function load(name, url){
- var image = new Image()
- to_load += 1
- image.src = url
- image.onload = on_load
- images[name] = image
- }
+ function load_images(image_object, callback){
+
+ var to_load = 0,
+ images
-}
+ // logic
+ if ( image_object instanceof Array ) images = []
+ else images = {}
+
+ for ( var prop in image_object ){
+ load(prop, image_object[prop])
+ }
+
+ // helper methods (impure)
+ function on_load(){
+ to_load -= 1
+ if ( to_load == 0 && callback ) callback(images)
+ }
+
+ function load(name, url){
+ var image = new Image()
+ to_load += 1
+ image.src = url
+ image.onload = on_load
+ images[name] = image
+ }
+
+ }
-module.exports = load_images
+ if ( typeof module == 'object' && module.exports )
+ module.exports = load_images
+ else
+ root.load_images = load_images
+
+}(this)
Please sign in to comment.
Something went wrong with that request. Please try again.