Skip to content

Commit 05dd9f6

Browse files
removed: generator loader
1 parent b459457 commit 05dd9f6

File tree

4 files changed

+3
-70
lines changed

4 files changed

+3
-70
lines changed

README.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![NPM downloads][npm-downloads-image]][npm-url]
66
[![MIT License][license-image]][license-url]
77

8-
Modern images loader helpers written in es2015 using generators and promises
8+
Modern images loader helpers written in es2015 using promises
99

1010
## Usage
1111

@@ -58,35 +58,6 @@ loadImages($('img', '.main-content'))
5858
})
5959
```
6060

61-
#### Lazy load sequentially images using a generator
62-
63-
```js
64-
import { loadImagesGen } from 'bianco.images-loader'
65-
66-
const infiniteList = loadImagesGen([...many images])
67-
68-
// load the first 10 images
69-
let i = 10
70-
while (i--) {
71-
infiniteList.next().value.then(onImageLoaded)
72-
}
73-
74-
// do something
75-
76-
// load other 5 images
77-
i = 5
78-
while (i--) {
79-
infiniteList.next().value.then(onImageLoaded)
80-
}
81-
82-
// do something else
83-
84-
// load the remaining images
85-
for (let promise of infiniteList) {
86-
promise.next().value.then(onImageLoaded)
87-
}
88-
```
89-
9061
[travis-image]: https://img.shields.io/travis/biancojs/images-loader.svg?style=flat-square
9162

9263
[travis-url]: https://travis-ci.org/biancojs/images-loader
@@ -124,11 +95,3 @@ Load in parallel a collection of images
12495
- `imgs` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList))** array of strings or <img> HTML elements
12596

12697
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** a promise that will be resolved when all the images will be loaded
127-
128-
### loadImagesGen
129-
130-
Load sequentially a collection of images
131-
132-
**Parameters**
133-
134-
- `imgs` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList))** array of strings or <img> HTML elements

index.next.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,8 @@ export function loadImages(imgs) {
3030
return Promise.all(domToArray(imgs).map(loadImage))
3131
}
3232

33-
/**
34-
* Load sequentially a collection of images
35-
* @param { Array|NodeList } imgs - array of strings or <img> HTML elements
36-
* @yields { Promise } a promise that will be resolved when the image will be completely loaded
37-
*/
38-
export function * loadImagesGen (imgs) {
39-
const list = domToArray(imgs)
40-
41-
for (let img of list) {
42-
yield loadImage(img)
43-
}
44-
}
4533

4634
export default {
4735
loadImage,
48-
loadImages,
49-
loadImagesGen
36+
loadImages
5037
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939
"jsdom-global": "2.1.0"
4040
},
4141
"dependencies": {
42-
"bianco.dom-to-array": "^0.0.4"
42+
"bianco.dom-to-array": "0.0.8"
4343
}
4444
}

test.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,4 @@ describe('Bianco images-loader', function() {
4646
done()
4747
})
4848
})
49-
50-
it('It can load images sequentially with a generator', function(done) {
51-
const gen = loadImagesGen([pathGen.next().value, pathGen.next().value])
52-
gen.next().value.then(function (i) {
53-
assert.equal(typeof i.src, 'string')
54-
done()
55-
})
56-
})
57-
58-
it('It can loop generator sequences', function(done) {
59-
const gen = loadImagesGen([pathGen.next().value, pathGen.next().value])
60-
const promises = []
61-
for (let p of gen) {
62-
promises.push(p)
63-
}
64-
Promise.all(promises).then(_ => done())
65-
})
6649
})

0 commit comments

Comments
 (0)