ashupp / js-image-generator Goto Github PK
View Code? Open in Web Editor NEWJavaScript random image generator
JavaScript random image generator
node_modules/js-image-generator/index.d.ts:5:13 - error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type.
5 callback: function(Error|null, RawImageData<Buffer>)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/js-image-generator/index.d.ts:5:13 - error TS8020: JSDoc types can only be used inside documentation comments.
5 callback: function(Error|null, RawImageData<Buffer>)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/js-image-generator/index.d.ts:5:34 - error TS2552: Cannot find name 'RawImageData'. Did you mean 'ImageData'?
5 callback: function(Error|null, RawImageData<Buffer>)
~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:9123:13
9123 declare var ImageData: {
~~~~~~~~~
'ImageData' is declared here.
index.d.ts should be something alone the lines of
export interface RawImageData<T> {
data: T;
}
export declare function generateImage(
width: number,
height: number,
quality: number,
callback: (error: Error | null, imageData: RawImageData<Buffer>) => any
): void
Successive calls to generateImage keep getting slower, up to a max of about 7 seconds per call.
The following code:
let now = Date.now();
for(var i = 0; i < 1000; i++){
imgGen.generateImage(2000,2000,80, function(err, image){
console.log(i, (now - (now = Date.now())) * -1 + ' ms');//calculate and reassign both at once
});
}
Results in the following output:
0 '1024 ms'
1 '1060 ms'
2 '1079 ms'
3 '1045 ms'
4 '1089 ms'
5 '1051 ms'
6 '1122 ms'
7 '1142 ms'
8 '1900 ms'
9 '1919 ms'
10 '1943 ms'
11 '2016 ms'
12 '2043 ms'
13 '2057 ms'
14 '2712 ms'
15 '3323 ms'
16 '5265 ms'
17 '5340 ms'
18 '7192 ms'
19 '7220 ms'
20 '7184 ms'
It stays at around 7.2 seconds after that.
If I have some time, I'll clone your code and see if I can figure out what's going on.
(PS: Thanks for creating this module)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.