From 3a043886eaa98b8b26356971564736d9d7180759 Mon Sep 17 00:00:00 2001 From: andy-ms Date: Tue, 7 Mar 2017 17:00:32 -0800 Subject: [PATCH] Fix broken tests --- combined-stream/tsconfig.json | 2 +- jimp/jimp-tests.ts | 98 ++++++++++--------- .../tedious-connection-pool-tests.ts | 10 +- webpack/index.d.ts | 6 +- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/combined-stream/tsconfig.json b/combined-stream/tsconfig.json index 5ffd68770c..e1986a21be 100644 --- a/combined-stream/tsconfig.json +++ b/combined-stream/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es6", + "lib": ["es6"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, diff --git a/jimp/jimp-tests.ts b/jimp/jimp-tests.ts index 180ce27d7f..fd1ed1d2b7 100644 --- a/jimp/jimp-tests.ts +++ b/jimp/jimp-tests.ts @@ -1,7 +1,7 @@ import Jimp = require('jimp') // All code below is from node-jimp document -Jimp.read("lenna.png", function (err, data) { +Jimp.read("lenna.png", (err, data) => { if (err) throw err; data.resize(256, 256) // resize .quality(60) // set JPEG quality @@ -9,30 +9,30 @@ Jimp.read("lenna.png", function (err, data) { .write("lena-small-bw.jpg"); // save }); -Jimp.read("lenna.png").then(function (lenna) { +Jimp.read("lenna.png").then(lenna => { lenna.resize(256, 256) // resize .quality(60) // set JPEG quality .greyscale() // set greyscale .write("lena-small-bw.jpg"); // save -}).catch(function (err) { +}).catch(err => { console.error(err); }); -Jimp.read("./path/to/image.jpg", function (err, image) { +Jimp.read("./path/to/image.jpg", (err, image) => { // do stuff with the image (if no exception) }); -Jimp.read("./path/to/image.jpg").then(function (image) { +Jimp.read("./path/to/image.jpg").then(image => { // do stuff with the image -}).catch(function (err) { +}).catch(err => { // handle an exception }); -Jimp.read(new Buffer(''), function (err, image) { +Jimp.read(new Buffer(''), (err, image) => { // do stuff with the image (if no exception) }); -Jimp.read("http://www.example.com/path/to/lenna.jpg", function (err, image) { +Jimp.read("http://www.example.com/path/to/lenna.jpg", (err, image) => { // do stuff with the image (if no exception) }); @@ -51,51 +51,55 @@ var hex = 0xFFFFFFFF var r = 0 var n = 1 /* Resize */ -image.contain( w, h); // scale the image to the given width and height, some parts of the image may be letter boxed -image.cover( w, h); // scale the image to the given width and height, some parts of the image may be clipped -image.resize( w, h); // resize the image. Jimp.AUTO can be passed as one of the values. -image.scale(f ); // scale the image by the factor f -image.scaleToFit( w, h ); // scale the image to the largest size that fits inside the given width and height +image.contain(w, h); // scale the image to the given width and height, some parts of the image may be letter boxed +image.cover(w, h); // scale the image to the given width and height, some parts of the image may be clipped +image.resize(w, h); // resize the image. Jimp.AUTO can be passed as one of the values. +image.scale(f); // scale the image by the factor f +image.scaleToFit(w, h); // scale the image to the largest size that fits inside the given width and height // An optional resize mode can be passed with all resize methods. /* Crop */ image.autocrop(); // automatically crop same-color borders from image (if any) -image.crop( x, y, w, h ); // crop to the given region +image.crop(x, y, w, h); // crop to the given region /* Composing */ -image.blit( src, x, y ); +image.blit(src, x, y); // blit the image with another Jimp image at x, y, optionally cropped. -image.composite( src, x, y ); // composites another Jimp image over this image at x, y -image.mask( src, x, y ); // masks the image with another Jimp image at x, y using average pixel value +image.composite(src, x, y); // composites another Jimp image over this image at x, y +image.mask(src, x, y); // masks the image with another Jimp image at x, y using average pixel value /* Flip and rotate */ -image.flip( horz, vert ); // flip the image horizontally or vertically -image.mirror( horz, vert ); // an alias for flip -image.rotate( deg ); // rotate the image clockwise by a number of degrees. Optionally, a resize mode can be passed. If `false` is passed as the second parameter, the image width and height will not be resized. +image.flip(horz, vert); // flip the image horizontally or vertically +image.mirror(horz, vert); // an alias for flip +// rotate the image clockwise by a number of degrees. +// Optionally, a resize mode can be passed. +// If `false` is passed as the second parameter, +// the image width and height will not be resized. +image.rotate(deg); // JPEG images with EXIF orientation data will be automatically re-orientated as appropriate. /* Colour */ -image.brightness( val ); // adjust the brighness by a value -1 to +1 -image.contrast( val ); // adjust the contrast by a value -1 to +1 +image.brightness(val); // adjust the brighness by a value -1 to +1 +image.contrast(val); // adjust the contrast by a value -1 to +1 image.dither565(); // ordered dithering of the image and reduce color space to 16-bits (RGB565) image.greyscale(); // remove colour from the image image.invert(); // invert the image colours image.normalize(); // normalize the channels in an image /* Alpha channel */ -image.fade( f ); // an alternative to opacity, fades the image by a factor 0 - 1. 0 will haven no effect. 1 will turn the image -image.opacity( f ); // multiply the alpha channel by each pixel by the factor f, 0 - 1 +image.fade(f); // an alternative to opacity, fades the image by a factor 0 - 1. 0 will haven no effect. 1 will turn the image +image.opacity(f); // multiply the alpha channel by each pixel by the factor f, 0 - 1 image.opaque(); // set the alpha channel on every pixel to fully opaque -image.background( hex ); // set the default new pixel colour (e.g. 0xFFFFFFFF or 0x00000000) for by some operations (e.g. image.contain and +image.background(hex); // set the default new pixel colour (e.g. 0xFFFFFFFF or 0x00000000) for by some operations (e.g. image.contain and /* Blurs */ -image.gaussian( r ); // Gaussian blur the image by r pixels (VERY slow) -image.blur( r ); // fast blur the image by r pixels +image.gaussian(r); // Gaussian blur the image by r pixels (VERY slow) +image.blur(r); // fast blur the image by r pixels /* Effects */ -image.posterize( n ); // apply a posterization effect with n level +image.posterize(n); // apply a posterization effect with n level image.sepia(); // apply a sepia wash to the image image.clone(); // returns a clone of the image @@ -110,35 +114,35 @@ image.contain(250, 250, Jimp.HORIZONTAL_ALIGN_LEFT | Jimp.VERTICAL_ALIGN_TOP); var path = '' var str = '' var width = 0 -Jimp.loadFont( path ).then(function (font) { // load font from .fnt file +Jimp.loadFont(path).then(font => { // load font from .fnt file image.print(font, x, y, str); // print a message on an image image.print(font, x, y, str, width); // print a message on an image with text wrapped at width }); var cb = (err: Error, data: any) => {} -Jimp.loadFont( path, cb ); // using a callback pattern +Jimp.loadFont(path, cb); // using a callback pattern -Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(function (font) { +Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => { image.print(font, 10, 10, "Hello world!"); }); -image.write( path, cb ); // Node-style callback will be fired when write is successful +image.write(path, cb); // Node-style callback will be fired when write is successful var file = "new_name." + image.getExtension(); image.write(file) var mime = 'image/png' -image.getBuffer( mime, cb ); // Node-style callback will be fired with result -image.getBase64( mime, cb ); // Node-style callback will be fired with result -image.quality( n ); // set the quality of saved JPEG, 0 - 100 +image.getBuffer(mime, cb); // Node-style callback will be fired with result +image.getBase64(mime, cb); // Node-style callback will be fired with result +image.quality(n); // set the quality of saved JPEG, 0 - 100 var bool = true var number = 0 -image.rgba( bool ); // set whether PNGs are saved as RGBA (true, default) or RGB (false) -image.filterType( number ); // set the filter type for the saved PNG -image.deflateLevel( number ); // set the deflate level for the saved PNG -Jimp.deflateStrategy( number ); // set the deflate for the saved PNG (0-3) +image.rgba(bool); // set whether PNGs are saved as RGBA (true, default) or RGB (false) +image.filterType(number); // set the filter type for the saved PNG +image.deflateLevel(number); // set the deflate level for the saved PNG +Jimp.deflateStrategy(number); // set the deflate for the saved PNG (0-3) image.color([ { apply: 'hue', params: [ -90 ] }, @@ -146,11 +150,11 @@ image.color([ { apply: 'xor', params: [ '#06D' ] } ]); image.convolution([ - [-2,-1, 0], + [-2, -1, 0], [-1, 1, 1], [ 0, 1, 2] ]) -image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x, y, idx) { +image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) { // x, y is the position of this pixel on the image // idx is the position start position of this rgba tuple in the bitmap Buffer // this is the image @@ -172,11 +176,11 @@ var a = 0 Jimp.rgbaToInt(r, g, b, a); // e.g. converts 255, 255, 255, 255 to 0xFFFFFFFF Jimp.intToRGBA(hex); // e.g. converts 0xFFFFFFFF to {r: 255, g: 255, b: 255, a:255} -var image = new Jimp(256, 256, function (err, image) { +var image = new Jimp(256, 256, (err, image) => { // this image is 256 x 256, every pixel is set to 0x00000000 }); -var image = new Jimp(256, 256, 0xFF0000FF, function (err, image) { +var image = new Jimp(256, 256, 0xFF0000FF, (err, image) => { // this image is 256 x 256, every pixel is set to 0xFF0000FF }); @@ -202,13 +206,13 @@ if (distance < 0.15 || diff.percent < 0.15) { // not a match } -Jimp.read("lenna.png", function (err, image) { +Jimp.read("lenna.png", function(err, image) { this.greyscale().scale(0.5).write("lena-half-bw.png"); }); -Jimp.read("lenna.png", function (err, image) { - image.greyscale(function(err, image) { - image.scale(0.5, function (err, image) { +Jimp.read("lenna.png", (err, image) => { + image.greyscale((err, image) => { + image.scale(0.5, (err, image) => { image.write("lena-half-bw.png"); }); }); diff --git a/tedious-connection-pool/tedious-connection-pool-tests.ts b/tedious-connection-pool/tedious-connection-pool-tests.ts index bdf504274a..0a2ec38be6 100644 --- a/tedious-connection-pool/tedious-connection-pool-tests.ts +++ b/tedious-connection-pool/tedious-connection-pool-tests.ts @@ -1,11 +1,3 @@ -// Type definitions for tedious-connection-pool -// Project: https://github.com/pekim/tedious-connection-pool -// Definitions by: Cyprien Autexier -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -"use strict"; - import ConnectionPool = require("tedious-connection-pool"); import tedious = require("tedious"); @@ -36,7 +28,7 @@ pool.once('error', (err: Error) => { pool.removeAllListeners(); -pool.acquire((err: Error, connection: ConnectionPool.PooledConnection) =>{ +pool.acquire((err: Error, connection: ConnectionPool.PooledConnection) => { console.log("hurray"); connection.beginTransaction((error: Error): void => {}, "some name"); connection.rollbackTransaction((error: Error): void => {}); diff --git a/webpack/index.d.ts b/webpack/index.d.ts index d21716a6e8..18ab5274ba 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -1,6 +1,10 @@ // Type definitions for webpack 2.2 // Project: https://github.com/webpack/webpack -// Definitions by: Qubo , Matt Lewis , Benjamin Lim , Boris Cherny , Tommy Troy Lin +// Definitions by: Qubo +// Matt Lewis +// Benjamin Lim +// Boris Cherny +// Tommy Troy Lin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped ///