https://github.com/gavinning/images-request-queue
图片请求队列
https://github.com/gavinning/images-request-queue
Last synced: 10 months ago
JSON representation
图片请求队列
- Host: GitHub
- URL: https://github.com/gavinning/images-request-queue
- Owner: gavinning
- Created: 2017-05-09T11:30:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-10T05:57:48.000Z (over 8 years ago)
- Last Synced: 2025-02-01T12:46:37.834Z (12 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Images-request-queue
---
图片处理队列
```sh
npm i images-request-queue --save
```
### Usage
```js
const IR = require('images-request-queue')
const ir = new IR([ imgurls ])
ir.load(2).then(res => console.log(res))
```
简单url列表的递归应用
```js
const IR = require('images-request-queue')
const ir = new IR( easyList )
function render() {
ir.load(2).then(res => {
if(!res.length) return
res.forEach((img, index) => {
document.body.appendChild(img)
if(index === res.length-1){
render()
}
})
})
}
render()
```
深度url列表的递归应用
```js
const IR = require('images-request-queue')
const ir = new IR({
deep: 'img.url',
list: deepList
})
function render() {
ir.load(2).then(res => {
if(!res.length) return
res.forEach((img, index) => {
document.body.appendChild(img)
if(index === res.length-1){
render()
}
})
})
}
render()
```
简单url列表
```js
var easyList = [
'http://a.com/1.jpg',
'http://a.com/2.jpg',
'http://a.com/3.jpg',
'http://a.com/4.jpg',
'http://a.com/5.jpg',
]
```
深度url列表
```js
var deepList = [
{
id: 1,
img: {
url: 'http://a.com/1.jpg'
}
},
{
id: 2,
img: {
url: 'http://a.com/2.jpg'
}
},
{
id: 3,
img: {
url: 'http://a.com/3.jpg'
}
},
{
id: 4,
img: {
url: 'http://a.com/4.jpg'
}
},
{
id: 5,
img: {
url: 'http://a.com/5.jpg'
}
},
]
```