Comparing version 2.0.2 to 2.1.0
27
index.js
@@ -9,6 +9,14 @@ var USE_OLD_API = false, | ||
CONFIG_GENERATOR, | ||
prototype; | ||
prototype, | ||
nextGCThreshold = 0, | ||
gcThreshold = 0; | ||
function WrappedImage(width, height) { | ||
if (!(this instanceof WrappedImage)) return new WrappedImage(width, height); | ||
if (gcThreshold && nextGCThreshold) { | ||
if (images.getUsedMemory() > nextGCThreshold) { | ||
images.gc(); | ||
nextGCThreshold = images.getUsedMemory() + gcThreshold; | ||
} | ||
} | ||
this._handle = new _Image(width, height); | ||
@@ -56,4 +64,4 @@ } | ||
resize: function( width, height, filter ){ | ||
this._handle.resize( width, height, filter ); | ||
resize: function(width, height, filter) { | ||
this._handle.resize(width, height, filter); | ||
return this; | ||
@@ -174,2 +182,15 @@ }, | ||
images.setGCThreshold = function(value) { | ||
gcThreshold = value; | ||
nextGCThreshold = value; | ||
}; | ||
images.getUsedMemory = function() { | ||
return _images.usedMemory; | ||
}; | ||
images.gc = function() { | ||
return _images.gc(); | ||
}; | ||
module.exports = USE_OLD_API ? _images : images; |
17
map.json
@@ -7,9 +7,11 @@ { | ||
"0.9.7", | ||
"0.9.11" | ||
"0.9.11", | ||
"0.12.0" | ||
], | ||
"x64": [ | ||
"0.8.0", | ||
"0.8.0", | ||
"0.9.3", | ||
"0.9.7", | ||
"0.9.11" | ||
"0.9.11", | ||
"0.12.0" | ||
] | ||
@@ -23,3 +25,4 @@ }, | ||
"0.9.7", | ||
"0.9.11" | ||
"0.9.11", | ||
"0.12.0" | ||
], | ||
@@ -30,3 +33,4 @@ "x64": [ | ||
"0.9.7", | ||
"0.9.11" | ||
"0.9.11", | ||
"0.12.0" | ||
] | ||
@@ -40,5 +44,6 @@ }, | ||
"0.9.7", | ||
"0.9.11" | ||
"0.9.11", | ||
"0.12.0" | ||
] | ||
} | ||
} |
{ | ||
"name": "images", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Cross-platform image decoder(png/jpeg/gif) and encoder(png/jpeg) for Node.js", | ||
@@ -32,4 +32,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"nan": "^1.6.2", | ||
"step": "0.0.5" | ||
} | ||
} |
@@ -106,2 +106,6 @@  | ||
### .resize(width[, height]) | ||
Set the size of the image,if the height is not specified, then scaling based on the current width and height | ||
设置图像宽高,如果height未指定,则根据当前宽高等比缩放, 默认采用 bicubic 算法。 | ||
### .width([width]) | ||
@@ -117,2 +121,14 @@ Get width for the image or set width of the image | ||
Set the limit size of each image | ||
设置库处理图片的大小限制,设置后对所有新的操作生效(如果超限则抛出异常)。 | ||
设置库处理图片的大小限制,设置后对所有新的操作生效(如果超限则抛出异常) | ||
### images.setGCThreshold(value) | ||
Set the garbage collection threshold | ||
设置图像处理库自动gc的阈值(当*新增*内存使用超过该阈值时,执行垃圾回收) | ||
### images.getUsedMemory() | ||
Get used memory (in bytes) | ||
得到图像处理库占用的内存大小(单位为字节) | ||
### images.gc() | ||
Forced call garbage collection | ||
强制调用V8的垃圾回收机制 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
105195
22
411
133
2
+ Addednan@^1.6.2
+ Addednan@1.9.0(transitive)