Merge remote-tracking branch 'borisyankov/master'

This commit is contained in:
Jan Bevers
2015-10-12 13:38:44 +02:00
5 changed files with 120 additions and 0 deletions

View File

@@ -108,6 +108,8 @@ declare module "express" {
use(path: string, handler: ErrorRequestHandler): T;
use(path: string[], ...handler: RequestHandler[]): T;
use(path: string[], handler: ErrorRequestHandler): T;
use(path: RegExp, ...handler: RequestHandler[]): T;
use(path: RegExp, handler: ErrorRequestHandler): T;
}
export function Router(options?: any): Router;

View File

@@ -13,6 +13,7 @@ import * as dgram from "dgram";
import * as querystring from "querystring";
import * as path from "path";
import * as readline from "readline";
import * as childProcess from "child_process";
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
@@ -401,3 +402,10 @@ rl.prompt(true);
rl.question("do you like typescript?", function(answer: string) {
rl.close();
});
//////////////////////////////////////////////////////////////////////
/// Child Process tests: https://nodejs.org/api/child_process.html ///
//////////////////////////////////////////////////////////////////////
childProcess.exec("echo test");
childProcess.spawnSync("echo test");

20
node/node.d.ts vendored
View File

@@ -868,6 +868,26 @@ declare module "child_process" {
env?: any;
encoding?: string;
}): ChildProcess;
export function spawnSync(command: string, args?: string[], options?: {
cwd?: string;
input?: string | Buffer;
stdio?: any;
env?: any;
uid?: number;
gid?: number;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
encoding?: string;
}): {
pid: number;
output: string[];
stdout: string | Buffer;
stderr: string | Buffer;
status: number;
signal: string;
error: Error;
};
export function execSync(command: string, options?: {
cwd?: string;
input?: string|Buffer;

26
pngjs2/pngjs2-tests.ts Normal file
View File

@@ -0,0 +1,26 @@
/// <reference path="pngjs2.d.ts" />
import * as fs from "fs";
import { PNG } from "pngjs2";
let png = new PNG({ filterType: 4 });
fs.createReadStream("in.png")
.pipe(png)
.on("parsed", () => {
for (let y = 0; y < png.height; y++) {
for (let x = 0; x < png.width; x++) {
let idx = (png.width * y + x) << 2;
// invert color
png.data[idx] = 255 - png.data[idx];
png.data[idx+1] = 255 - png.data[idx+1];
png.data[idx+2] = 255 - png.data[idx+2];
// and reduce opacity
png.data[idx+3] = png.data[idx+3] >> 1;
}
}
png.pack().pipe(fs.createWriteStream('out.png'));
});

64
pngjs2/pngjs2.d.ts vendored Normal file
View File

@@ -0,0 +1,64 @@
// Type definitions for pngjs2 2.0.0
// Project: https://www.npmjs.com/package/pngjs2
// Definitions by: Elisée Maurer <https://sparklinlabs.com/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "pngjs2" {
import fs = require("fs");
import events = require("events");
import stream = require("stream");
interface PNGOptions {
width?: number;
height?: number;
checkCRC?: boolean;
deflateChunkSize?: number;
deflateLevel?: number;
deflateStrategy?: number;
deflateFactory?: any;
filterType?: number|number[];
colorType?: number;
inputHasAlpha?: boolean;
}
interface PNGMetadata {
width: number;
height: number;
palette: boolean;
color: boolean;
alpha: boolean;
interlace: boolean;
}
export class PNG extends stream.Writable {
constructor(options?: PNGOptions);
width: number;
height: number;
data: Buffer;
gamma: number;
on(event: string, callback: Function): PNG;
on(event: "metadata", callback: (metadata: PNGMetadata) => void): PNG;
on(event: "parsed", callback: (data: Buffer) => void): PNG;
on(event: "error", callback: (err: Error) => void): PNG;
parse(data: string|Buffer, callback?: (err: Error, data: Buffer) => void): PNG;
pack(): PNG;
pipe(destination: fs.WriteStream): PNG;
static bitblt(src: PNG, dst: PNG, srcX: number, srcY: number,
width: number, height: number, deltaX: number, deltaY: number): void;
bitblt(dst: PNG, srcX: number, srcY: number,
width: number, height: number, deltaX: number, deltaY: number): PNG;
}
export namespace PNG {
namespace sync {
function read(buffer: string|Buffer, options?: PNGOptions): PNG;
}
}
}