Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated readme and tests

  • Loading branch information...
commit 0f7e0927de46c31b9f1e078bac65c59a989c36df 1 parent 6cfdbea
@hughfdjackson authored
View
2  README.markdown
@@ -29,4 +29,4 @@ The callback is called as soon as all images are loaded, and the above callback
## Tests
-[Feel free to run the (one) unit test](http://hughfdjackson.github.com/load_images/src-test/SpecRunner.html)
+[Feel free to run the unit tests](http://hughfdjackson.github.com/load_images/src-test/SpecRunner.html)
View
7 src-test/spec/load_images_spec.js
@@ -1,6 +1,6 @@
describe("load_images", function(){
- it("should load images (duh)", function(){
+ it("should load images from object and *returns* an object in callback", function(){
var to_load = {
'person': '../images/person.png',
'ninja': '../images/ninja.png'
@@ -18,11 +18,12 @@ describe("load_images", function(){
runs(function(){
expect(images.person.complete).toEqual(true)
expect(images.ninja.complete).toEqual(true)
+ expect(images instanceof Array).toEqual(false)
})
})
- it("should load images from array", function(){
+ it("should load images from array and *returns* an array in callback", function(){
var to_load = ["../images/person.png", "../images/ninja.png"],
images = []
@@ -37,7 +38,9 @@ describe("load_images", function(){
runs(function(){
expect(images[0].complete).toEqual(true)
expect(images[1].complete).toEqual(true)
+ expect(images instanceof Array).toEqual(true)
})
})
+
})
View
7 src/load_images.js
@@ -1,7 +1,10 @@
function load_images(image_object, callback){
- var images = {},
- to_load = 0
+ var to_load = 0,
+ images
+ if ( image_object instanceof Array ) images = []
+ else images = {}
+
function on_load(){
to_load -= 1
if ( to_load == 0 && callback ) callback(images)
Please sign in to comment.
Something went wrong with that request. Please try again.