@leafer/image 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/image",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "@leafer/image",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/task": "1.4.1",
26
- "@leafer/file": "1.4.1",
27
- "@leafer/platform": "1.4.1"
25
+ "@leafer/task": "1.5.0",
26
+ "@leafer/file": "1.5.0",
27
+ "@leafer/platform": "1.5.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.4.1"
30
+ "@leafer/interface": "1.5.0"
31
31
  }
32
32
  }
@@ -6,6 +6,8 @@ import { TaskProcessor } from '@leafer/task'
6
6
 
7
7
  export const ImageManager: IImageManager = {
8
8
 
9
+ maxRecycled: 100,
10
+
9
11
  recycledList: [],
10
12
 
11
13
  patternTasker: new TaskProcessor(),
@@ -24,13 +26,8 @@ export const ImageManager: IImageManager = {
24
26
 
25
27
  clearRecycled(): void {
26
28
  const list = I.recycledList
27
- if (list.length > 100) { // cache 100
28
- list.forEach(image => {
29
- if (!image.use && image.url) {
30
- Resource.remove(image.url)
31
- image.destroy()
32
- }
33
- })
29
+ if (list.length > I.maxRecycled) {
30
+ list.forEach(image => (!image.use && image.url) && Resource.remove(image.url))
34
31
  list.length = 0
35
32
  }
36
33
  },