From fa2480ba613f7828c12e1022ba274fd2fc822036 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 20 Apr 2017 09:06:00 -0700 Subject: [PATCH] Remove more namespaces from tests (#16029) --- types/angular/tslint.json | 1 + types/dagre-d3/dagre-d3-tests.ts | 34 +- types/dagre/dagre-tests.ts | 16 +- types/enzyme/enzyme-tests.tsx | 6 +- types/fetch-jsonp/tslint.json | 7 +- types/flatbuffers/flatbuffers-tests.ts | 2273 ++++++++------------- types/later/later-tests.ts | 64 +- types/lodash/tslint.json | 1 + types/memcached/memcached-tests.ts | 846 ++++---- types/node/tslint.json | 1 + types/node/v0/tslint.json | 1 + types/node/v4/tslint.json | 1 + types/node/v6/tslint.json | 1 + types/pixi.js/pixi.js-tests.ts | 74 +- types/react-dnd-html5-backend/tslint.json | 8 +- types/rx-lite/rx-lite-tests.ts | 92 +- types/sharepoint/tslint.json | 4 +- types/webpack/webpack-tests.ts | 6 +- 18 files changed, 1411 insertions(+), 2025 deletions(-) diff --git a/types/angular/tslint.json b/types/angular/tslint.json index 140b06dc6c..3ace427c86 100644 --- a/types/angular/tslint.json +++ b/types/angular/tslint.json @@ -13,6 +13,7 @@ "jsdoc-format": false, "max-line-length": false, "no-empty-interface": false, + "no-namespace": false, "unified-signatures": false, "void-return": false } diff --git a/types/dagre-d3/dagre-d3-tests.ts b/types/dagre-d3/dagre-d3-tests.ts index 16bfb29b0c..d3dc72b648 100644 --- a/types/dagre-d3/dagre-d3-tests.ts +++ b/types/dagre-d3/dagre-d3-tests.ts @@ -1,21 +1,19 @@ -namespace DagreD3Tests { - const gDagre = new dagreD3.graphlib.Graph(); - const graph = gDagre.graph(); +const gDagre = new dagreD3.graphlib.Graph(); +const graph = gDagre.graph(); - // has graph methods from dagre.d.ts - graph.setNode("a", {}); - const num: number = 251 + graph.height + graph.width; - const predecessors: { [vertex: string]: string[] } = {}; - const successors: { [vertex: string]: string[] } = {}; +// has graph methods from dagre.d.ts +graph.setNode("a", {}); +const num: number = 251 + graph.height + graph.width; +const predecessors: { [vertex: string]: string[] } = {}; +const successors: { [vertex: string]: string[] } = {}; - predecessors["a"] = graph.predecessors("a"); - successors["a"] = graph.successors("a"); - graph.transition = (selection: d3.Selection) => { - return d3.transition(); - }; +predecessors["a"] = graph.predecessors("a"); +successors["a"] = graph.successors("a"); +graph.transition = (selection: d3.Selection) => { + return d3.transition(); +}; - const render = new dagreD3.render(); - const svg = d3.select("svg"); - render.arrows()["arrowType"] = (parent: d3.Selection, id: string, edge: dagre.Edge, type: string) => {}; - render(svg, graph); -} +const render = new dagreD3.render(); +const svg = d3.select("svg"); +render.arrows()["arrowType"] = (parent: d3.Selection, id: string, edge: dagre.Edge, type: string) => {}; +render(svg, graph); diff --git a/types/dagre/dagre-tests.ts b/types/dagre/dagre-tests.ts index 2855055451..d9a62a107b 100644 --- a/types/dagre/dagre-tests.ts +++ b/types/dagre/dagre-tests.ts @@ -1,10 +1,8 @@ -namespace DagreTests { - const gDagre = new dagre.graphlib.Graph(); - gDagre.setGraph({}) - .setDefaultEdgeLabel(() => {}) - .setNode("a", {}) - .setEdge("b", "c") - .setEdge("c", "d", {class: "class"}); +const gDagre = new dagre.graphlib.Graph(); +gDagre.setGraph({}) + .setDefaultEdgeLabel(() => {}) + .setNode("a", {}) + .setEdge("b", "c") + .setEdge("c", "d", {class: "class"}); - dagre.layout(gDagre); -} +dagre.layout(gDagre); diff --git a/types/enzyme/enzyme-tests.tsx b/types/enzyme/enzyme-tests.tsx index 08ab6a5c15..7118fd4403 100644 --- a/types/enzyme/enzyme-tests.tsx +++ b/types/enzyme/enzyme-tests.tsx @@ -25,7 +25,7 @@ class MyComponent extends Component { const MyStatelessComponent = (props: StatelessProps) => ; // ShallowWrapper -namespace ShallowWrapperTest { +function ShallowWrapperTest() { let shallowWrapper: ShallowWrapper = shallow(); @@ -331,7 +331,7 @@ namespace ShallowWrapperTest { } // ReactWrapper -namespace ReactWrapperTest { +function ReactWrapperTest() { let reactWrapper: ReactWrapper = mount(); @@ -631,7 +631,7 @@ namespace ReactWrapperTest { } // CheerioWrapper -namespace CheerioWrapperTest { +function CheerioWrapperTest() { const wrapper: Cheerio = shallow(
).render() || mount(
).render(); diff --git a/types/fetch-jsonp/tslint.json b/types/fetch-jsonp/tslint.json index 5b78762199..3db14f85ea 100644 --- a/types/fetch-jsonp/tslint.json +++ b/types/fetch-jsonp/tslint.json @@ -1,6 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "only-arrow-functions-2": false - } -} +{ "extends": "dtslint/dt.json" } diff --git a/types/flatbuffers/flatbuffers-tests.ts b/types/flatbuffers/flatbuffers-tests.ts index 0edd64d75c..87593106c7 100644 --- a/types/flatbuffers/flatbuffers-tests.ts +++ b/types/flatbuffers/flatbuffers-tests.ts @@ -1,1462 +1,849 @@ -/** - * @enum - */ -export namespace MyGame.Example { - export enum Color { - Red= 1, - Green= 2, - Blue= 8 +enum Color { + Red= 1, + Green= 2, + Blue= 8 +} + +enum Any { + NONE= 0, + Monster= 1, + TestSimpleTableWithEnum= 2, + MyGame_Example2_Monster= 3 +} + +class Monster2 { + bb: flatbuffers.ByteBuffer= null; + + bb_pos: number = 0; + + __init(i: number, bb: flatbuffers.ByteBuffer): Monster2 { + this.bb_pos = i; + this.bb = bb; + return this; + } + + static getRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster2): Monster2 { + return (obj || new Monster2()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + + static startMonster(builder: flatbuffers.Builder) { + builder.startObject(0); + } + + static endMonster(builder: flatbuffers.Builder): flatbuffers.Offset { + const offset = builder.endObject(); + return offset; } } -/** - * @enum - */ -export namespace MyGame.Example { - export enum Any { - NONE= 0, - Monster= 1, - TestSimpleTableWithEnum= 2, - MyGame_Example2_Monster= 3 +class Test { + bb: flatbuffers.ByteBuffer = null; + + bb_pos: number = 0; + + __init(i: number, bb: flatbuffers.ByteBuffer): Test { + this.bb_pos = i; + this.bb = bb; + return this; + } + + a(): number { + return this.bb.readInt16(this.bb_pos); + } + + mutate_a(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 0); + + if (offset === 0) { + return false; + } + + this.bb.writeInt16(this.bb_pos + offset, value); + return true; + } + + b(): number { + return this.bb.readInt8(this.bb_pos + 2); + } + + mutate_b(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 2); + + if (offset === 0) { + return false; + } + + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + + static createTest(builder: flatbuffers.Builder, a: number, b: number): flatbuffers.Offset { + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(b); + builder.writeInt16(a); + return builder.offset(); } } -/** - * @constructor - */ -export namespace MyGame.Example2 { - export class Monster { - /** - * @type {flatbuffers.ByteBuffer} - */ +class TestSimpleTableWithEnum { + bb: flatbuffers.ByteBuffer= null; + + bb_pos: number = 0; + + __init(i: number, bb: flatbuffers.ByteBuffer): TestSimpleTableWithEnum { + this.bb_pos = i; + this.bb = bb; + return this; + } + + static getRootAsTestSimpleTableWithEnum(bb: flatbuffers.ByteBuffer, obj?: TestSimpleTableWithEnum): TestSimpleTableWithEnum { + return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + + color(): Color { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (this.bb.readInt8(this.bb_pos + offset)) : Color.Green; + } + + mutate_color(value: Color): boolean { + const offset = this.bb.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + + static startTestSimpleTableWithEnum(builder: flatbuffers.Builder) { + builder.startObject(1); + } + + static addColor(builder: flatbuffers.Builder, color: Color) { + builder.addFieldInt8(0, color, Color.Green); + } + + static endTestSimpleTableWithEnum(builder: flatbuffers.Builder): flatbuffers.Offset { + const offset = builder.endObject(); + return offset; + } +} + +class Vec3 { + bb: flatbuffers.ByteBuffer= null; + + bb_pos: number = 0; + + __init(i: number, bb: flatbuffers.ByteBuffer): Vec3 { + this.bb_pos = i; + this.bb = bb; + return this; + } + + x(): number { + return this.bb.readFloat32(this.bb_pos); + } + + mutate_x(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 0); + + if (offset === 0) { + return false; + } + + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + + y(): number { + return this.bb.readFloat32(this.bb_pos + 4); + } + + mutate_y(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 4); + + if (offset === 0) { + return false; + } + + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + + z(): number { + return this.bb.readFloat32(this.bb_pos + 8); + } + + mutate_z(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; + } + + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + + test1(): number { + return this.bb.readFloat64(this.bb_pos + 16); + } + + mutate_test1(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 16); + + if (offset === 0) { + return false; + } + + this.bb.writeFloat64(this.bb_pos + offset, value); + return true; + } + + test2(): Color { + return (this.bb.readInt8(this.bb_pos + 24)); + } + + mutate_test2(value: Color): boolean { + const offset = this.bb.__offset(this.bb_pos, 24); + + if (offset === 0) { + return false; + } + + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + + test3(obj?: Test): Test { + return (obj || new Test()).__init(this.bb_pos + 26, this.bb); + } + + static createVec3(builder: flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number): flatbuffers.Offset { + builder.prep(16, 32); + builder.pad(2); + builder.prep(2, 4); + builder.pad(1); + builder.writeInt8(test3_b); + builder.writeInt16(test3_a); + builder.pad(1); + builder.writeInt8(test2); + builder.writeFloat64(test1); + builder.pad(4); + builder.writeFloat32(z); + builder.writeFloat32(y); + builder.writeFloat32(x); + return builder.offset(); + } +} + +class Stat { + bb: flatbuffers.ByteBuffer= null; + + bb_pos: number = 0; + + __init(i: number, bb: flatbuffers.ByteBuffer): Stat { + this.bb_pos = i; + this.bb = bb; + return this; + } + + static getRootAsStat(bb: flatbuffers.ByteBuffer, obj?: Stat): Stat { + return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + + id(optionalEncoding?: flatbuffers.Encoding): string|Uint8Array { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + + val(): flatbuffers.Long { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + + mutate_val(value: flatbuffers.Long): boolean { + const offset = this.bb.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; + } + + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + + count(): number { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; + } + + static startStat(builder: flatbuffers.Builder) { + builder.startObject(3); + } + + static addId(builder: flatbuffers.Builder, idOffset: flatbuffers.Offset) { + builder.addFieldOffset(0, idOffset, 0); + } + + static addVal(builder: flatbuffers.Builder, val: flatbuffers.Long) { + builder.addFieldInt64(1, val, builder.createLong(0, 0)); + } + + static addCount(builder: flatbuffers.Builder, count: number) { + builder.addFieldInt16(2, count, 0); + } + + static endStat(builder: flatbuffers.Builder): flatbuffers.Offset { + const offset = builder.endObject(); + return offset; + } +} + +class Monster { bb: flatbuffers.ByteBuffer= null; - /** - * @type {number} - */ bb_pos: number = 0; - /** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Monster} - */ - __init(i: number, bb: flatbuffers.ByteBuffer): Monster { - this.bb_pos = i; - this.bb = bb; - return this; + __init(i: number, bb: flatbuffers.ByteBuffer): Monster { + this.bb_pos = i; + this.bb = bb; + return this; + } + + static getRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster): Monster { + return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + + static bufferHasIdentifier(bb: flatbuffers.ByteBuffer): boolean { + return bb.__has_identifier('MONS'); + } + + pos(obj?: Vec3): Vec3 { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new Vec3()).__init(this.bb_pos + offset, this.bb) : null; + } + + mana(): number { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 150; + } + + mutate_mana(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 6); + + if (offset === 0) { + return false; } - /** - * @param {flatbuffers.ByteBuffer} bb - * @param {Monster=} obj - * @returns {Monster} - */ - static getRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster): Monster { - return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + this.bb.writeInt16(this.bb_pos + offset, value); + return true; + } + + hp(): number { + const offset = this.bb.__offset(this.bb_pos, 8); + return offset ? this.bb.readInt16(this.bb_pos + offset) : 100; + } + + mutate_hp(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 8); + + if (offset === 0) { + return false; } - /** - * @param {flatbuffers.Builder} builder - */ - static startMonster(builder: flatbuffers.Builder) { - builder.startObject(0); + this.bb.writeInt16(this.bb_pos + offset, value); + return true; + } + + name(): string; + name(optionalEncoding: flatbuffers.Encoding): string|Uint8Array; + name(optionalEncoding?: any): string|Uint8Array { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; + } + + inventory(index: number): number { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + + inventoryLength(): number { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + + inventoryArray(): Uint8Array { + const offset = this.bb.__offset(this.bb_pos, 14); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + + color(): Color { + const offset = this.bb.__offset(this.bb_pos, 16); + return offset ? (this.bb.readInt8(this.bb_pos + offset)) : Color.Blue; + } + + mutate_color(value: Color): boolean { + const offset = this.bb.__offset(this.bb_pos, 16); + + if (offset === 0) { + return false; } - /** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ - static endMonster(builder: flatbuffers.Builder): flatbuffers.Offset { - const offset = builder.endObject(); - return offset; - } - } -} -/** - * @constructor - */ -export namespace MyGame.Example { - export class Test { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos: number = 0; - - /** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Test} - */ - __init(i: number, bb: flatbuffers.ByteBuffer): Test { - this.bb_pos = i; - this.bb = bb; - return this; - } - - /** - * @returns {number} - */ - a(): number { - return this.bb.readInt16(this.bb_pos); - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_a(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - b(): number { - return this.bb.readInt8(this.bb_pos + 2); - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_b(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 2); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} a - * @param {number} b - * @returns {flatbuffers.Offset} - */ - static createTest(builder: flatbuffers.Builder, a: number, b: number): flatbuffers.Offset { - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(b); - builder.writeInt16(a); - return builder.offset(); - } - } -} - -/** - * @constructor - */ -export namespace MyGame.Example { - export class TestSimpleTableWithEnum { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos: number = 0; - - /** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {TestSimpleTableWithEnum} - */ - __init(i: number, bb: flatbuffers.ByteBuffer): TestSimpleTableWithEnum { - this.bb_pos = i; - this.bb = bb; - return this; - } - - /** - * @param {flatbuffers.ByteBuffer} bb - * @param {TestSimpleTableWithEnum=} obj - * @returns {TestSimpleTableWithEnum} - */ - static getRootAsTestSimpleTableWithEnum(bb: flatbuffers.ByteBuffer, obj?: TestSimpleTableWithEnum): TestSimpleTableWithEnum { - return (obj || new TestSimpleTableWithEnum()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - - /** - * @returns {MyGame.Example.Color} - */ - color(): MyGame.Example.Color { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Green; - } - - /** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ - mutate_color(value: MyGame.Example.Color): boolean { - const offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - - /** - * @param {flatbuffers.Builder} builder - */ - static startTestSimpleTableWithEnum(builder: flatbuffers.Builder) { - builder.startObject(1); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ - static addColor(builder: flatbuffers.Builder, color: MyGame.Example.Color) { - builder.addFieldInt8(0, color, MyGame.Example.Color.Green); - } - - /** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ - static endTestSimpleTableWithEnum(builder: flatbuffers.Builder): flatbuffers.Offset { - const offset = builder.endObject(); - return offset; - } - } -} - -/** - * @constructor - */ -export namespace MyGame.Example { - export class Vec3 { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos: number = 0; - - /** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Vec3} - */ - __init(i: number, bb: flatbuffers.ByteBuffer): Vec3 { - this.bb_pos = i; - this.bb = bb; - return this; - } - - /** - * @returns {number} - */ - x(): number { - return this.bb.readFloat32(this.bb_pos); - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_x(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 0); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - y(): number { - return this.bb.readFloat32(this.bb_pos + 4); - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_y(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 4); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - z(): number { - return this.bb.readFloat32(this.bb_pos + 8); - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_z(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - test1(): number { - return this.bb.readFloat64(this.bb_pos + 16); - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_test1(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat64(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {MyGame.Example.Color} - */ - test2(): MyGame.Example.Color { - return /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + 24)); - } - - /** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ - mutate_test2(value: MyGame.Example.Color): boolean { - const offset = this.bb.__offset(this.bb_pos, 24); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - - /** - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ - test3(obj?: MyGame.Example.Test): MyGame.Example.Test { - return (obj || new MyGame.Example.Test()).__init(this.bb_pos + 26, this.bb); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} test1 - * @param {MyGame.Example.Color} test2 - * @param {number} test3_a - * @param {number} test3_b - * @returns {flatbuffers.Offset} - */ - static createVec3(builder: flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: MyGame.Example.Color, test3_a: number, test3_b: number): flatbuffers.Offset { - builder.prep(16, 32); - builder.pad(2); - builder.prep(2, 4); - builder.pad(1); - builder.writeInt8(test3_b); - builder.writeInt16(test3_a); - builder.pad(1); - builder.writeInt8(test2); - builder.writeFloat64(test1); - builder.pad(4); - builder.writeFloat32(z); - builder.writeFloat32(y); - builder.writeFloat32(x); - return builder.offset(); - } - } -} - -/** - * @constructor - */ -export namespace MyGame.Example { - export class Stat { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos: number = 0; - /** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Stat} - */ - __init(i: number, bb: flatbuffers.ByteBuffer): Stat { - this.bb_pos = i; - this.bb = bb; - return this; - } - - /** - * @param {flatbuffers.ByteBuffer} bb - * @param {Stat=} obj - * @returns {Stat} - */ - static getRootAsStat(bb: flatbuffers.ByteBuffer, obj?: Stat): Stat { - return (obj || new Stat()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - - /** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ - id(): string; - id(optionalEncoding: flatbuffers.Encoding): string|Uint8Array; - id(optionalEncoding?: any): string|Uint8Array { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - - /** - * @returns {flatbuffers.Long} - */ - val(): flatbuffers.Long { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); - } - - /** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ - mutate_val(value: flatbuffers.Long): boolean { - const offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - count(): number { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; - } - - /** - * @param {flatbuffers.Builder} builder - */ - static startStat(builder: flatbuffers.Builder) { - builder.startObject(3); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} idOffset - */ - static addId(builder: flatbuffers.Builder, idOffset: flatbuffers.Offset) { - builder.addFieldOffset(0, idOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} val - */ - static addVal(builder: flatbuffers.Builder, val: flatbuffers.Long) { - builder.addFieldInt64(1, val, builder.createLong(0, 0)); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} count - */ - static addCount(builder: flatbuffers.Builder, count: number) { - builder.addFieldInt16(2, count, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ - static endStat(builder: flatbuffers.Builder): flatbuffers.Offset { - const offset = builder.endObject(); - return offset; - } - } -} - -/** - * an example documentation comment: monster object - * - * @constructor - */ -export namespace MyGame.Example { - export class Monster { - /** - * @type {flatbuffers.ByteBuffer} - */ - bb: flatbuffers.ByteBuffer= null; - - /** - * @type {number} - */ - bb_pos: number = 0; - /** - * @param {number} i - * @param {flatbuffers.ByteBuffer} bb - * @returns {Monster} - */ - __init(i: number, bb: flatbuffers.ByteBuffer): Monster { - this.bb_pos = i; - this.bb = bb; - return this; - } - - /** - * @param {flatbuffers.ByteBuffer} bb - * @param {Monster=} obj - * @returns {Monster} - */ - static getRootAsMonster(bb: flatbuffers.ByteBuffer, obj?: Monster): Monster { - return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb); - } - - /** - * @param {flatbuffers.ByteBuffer} bb - * @returns {boolean} - */ - static bufferHasIdentifier(bb: flatbuffers.ByteBuffer): boolean { - return bb.__has_identifier('MONS'); - } - - /** - * @param {MyGame.Example.Vec3=} obj - * @returns {MyGame.Example.Vec3} - */ - pos(obj?: MyGame.Example.Vec3): MyGame.Example.Vec3 { - const offset = this.bb.__offset(this.bb_pos, 4); - return offset ? (obj || new MyGame.Example.Vec3()).__init(this.bb_pos + offset, this.bb) : null; - } - - /** - * @returns {number} - */ - mana(): number { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 150; - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_mana(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 6); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - hp(): number { - const offset = this.bb.__offset(this.bb_pos, 8); - return offset ? this.bb.readInt16(this.bb_pos + offset) : 100; - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_hp(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 8); - - if (offset === 0) { - return false; - } - - this.bb.writeInt16(this.bb_pos + offset, value); - return true; - } - - /** - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ - name(): string; - name(optionalEncoding: flatbuffers.Encoding): string|Uint8Array; - name(optionalEncoding?: any): string|Uint8Array { - const offset = this.bb.__offset(this.bb_pos, 10); - return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null; - } - - /** - * @param {number} index - * @returns {number} - */ - inventory(index: number): number { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; - } - - /** - * @returns {number} - */ - inventoryLength(): number { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - - /** - * @returns {Uint8Array} - */ - inventoryArray(): Uint8Array { - const offset = this.bb.__offset(this.bb_pos, 14); - return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; - } - - /** - * @returns {MyGame.Example.Color} - */ - color(): MyGame.Example.Color { - const offset = this.bb.__offset(this.bb_pos, 16); - return offset ? /** @type {MyGame.Example.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Example.Color.Blue; - } - - /** - * @param {MyGame.Example.Color} value - * @returns {boolean} - */ - mutate_color(value: MyGame.Example.Color): boolean { - const offset = this.bb.__offset(this.bb_pos, 16); - - if (offset === 0) { - return false; - } - - this.bb.writeInt8(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {MyGame.Example.Any} - */ - testType(): MyGame.Example.Any { - const offset = this.bb.__offset(this.bb_pos, 18); - return offset ? /** @type {MyGame.Example.Any} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Example.Any.NONE; - } - - /** - * @param {flatbuffers.Table} obj - * @returns {?flatbuffers.Table} - */ - test(obj: T): T { - const offset = this.bb.__offset(this.bb_pos, 20); - return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; - } - - /** - * @param {number} index - * @param {MyGame.Example.Test=} obj - * @returns {MyGame.Example.Test} - */ - test4(index: number, obj?: MyGame.Example.Test): MyGame.Example.Test { - const offset = this.bb.__offset(this.bb_pos, 22); - return offset ? (obj || new MyGame.Example.Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; - } - - /** - * @returns {number} - */ - test4Length(): number { - const offset = this.bb.__offset(this.bb_pos, 22); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - - /** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ - testarrayofstring(index: number): string; - testarrayofstring(index: number, optionalEncoding: flatbuffers.Encoding): string|Uint8Array; - testarrayofstring(index: number, optionalEncoding?: any): string|Uint8Array { - const offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - - /** - * @returns {number} - */ - testarrayofstringLength(): number { - const offset = this.bb.__offset(this.bb_pos, 24); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - - /** - * an example documentation comment: this will end up in the generated code - * multiline too - * - * @param {number} index - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ - testarrayoftables(index: number, obj?: MyGame.Example.Monster): MyGame.Example.Monster { - const offset = this.bb.__offset(this.bb_pos, 26); - return offset ? (obj || new MyGame.Example.Monster()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - - /** - * @returns {number} - */ - testarrayoftablesLength(): number { - const offset = this.bb.__offset(this.bb_pos, 26); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - - /** - * @param {MyGame.Example.Monster=} obj - * @returns {MyGame.Example.Monster} - */ - enemy(obj?: MyGame.Example.Monster): MyGame.Example.Monster { - const offset = this.bb.__offset(this.bb_pos, 28); - return offset ? (obj || new MyGame.Example.Monster()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - - /** - * @param {number} index - * @returns {number} - */ - testnestedflatbuffer(index: number): number { - const offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; - } - - /** - * @returns {number} - */ - testnestedflatbufferLength(): number { - const offset = this.bb.__offset(this.bb_pos, 30); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - - /** - * @returns {Uint8Array} - */ - testnestedflatbufferArray(): Uint8Array { - const offset = this.bb.__offset(this.bb_pos, 30); - return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; - } - - /** - * @param {MyGame.Example.Stat=} obj - * @returns {MyGame.Example.Stat} - */ - testempty(obj?: MyGame.Example.Stat): MyGame.Example.Stat { - const offset = this.bb.__offset(this.bb_pos, 32); - return offset ? (obj || new MyGame.Example.Stat()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; - } - - /** - * @returns {boolean} - */ - testbool(): boolean { - const offset = this.bb.__offset(this.bb_pos, 34); - return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; - } - - /** - * @returns {number} - */ - testhashs32Fnv1(): number { - const offset = this.bb.__offset(this.bb_pos, 36); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_testhashs32_fnv1(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 36); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - testhashu32Fnv1(): number { - const offset = this.bb.__offset(this.bb_pos, 38); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; - } - - /** - * @returns {flatbuffers.Long} - */ - testhashs64Fnv1(): flatbuffers.Long { - const offset = this.bb.__offset(this.bb_pos, 40); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); - } - - /** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ - mutate_testhashs64_fnv1(value: flatbuffers.Long): boolean { - const offset = this.bb.__offset(this.bb_pos, 40); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {flatbuffers.Long} - */ - testhashu64Fnv1(): flatbuffers.Long { - const offset = this.bb.__offset(this.bb_pos, 42); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); - } - - /** - * @returns {number} - */ - testhashs32Fnv1a(): number { - const offset = this.bb.__offset(this.bb_pos, 44); - return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_testhashs32_fnv1a(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 44); - - if (offset === 0) { - return false; - } - - this.bb.writeInt32(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - testhashu32Fnv1a(): number { - const offset = this.bb.__offset(this.bb_pos, 46); - return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; - } - - /** - * @returns {flatbuffers.Long} - */ - testhashs64Fnv1a(): flatbuffers.Long { - const offset = this.bb.__offset(this.bb_pos, 48); - return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); - } - - /** - * @param {flatbuffers.Long} value - * @returns {boolean} - */ - mutate_testhashs64_fnv1a(value: flatbuffers.Long): boolean { - const offset = this.bb.__offset(this.bb_pos, 48); - - if (offset === 0) { - return false; - } - - this.bb.writeInt64(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {flatbuffers.Long} - */ - testhashu64Fnv1a(): flatbuffers.Long { - const offset = this.bb.__offset(this.bb_pos, 50); - return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); - } - - /** - * @param {number} index - * @returns {boolean} - */ - testarrayofbools(index: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 52); - return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; - } - - /** - * @returns {number} - */ - testarrayofboolsLength(): number { - const offset = this.bb.__offset(this.bb_pos, 52); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - - /** - * @returns {Int8Array} - */ - testarrayofboolsArray(): Int8Array { - const offset = this.bb.__offset(this.bb_pos, 52); - return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; - } - - /** - * @returns {number} - */ - testf(): number { - const offset = this.bb.__offset(this.bb_pos, 54); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159; - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_testf(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 54); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - testf2(): number { - const offset = this.bb.__offset(this.bb_pos, 56); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0; - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_testf2(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 56); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; - } - - /** - * @returns {number} - */ - testf3(): number { - const offset = this.bb.__offset(this.bb_pos, 58); - return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; - } - - /** - * @param {number} value - * @returns {boolean} - */ - mutate_testf3(value: number): boolean { - const offset = this.bb.__offset(this.bb_pos, 58); - - if (offset === 0) { - return false; - } - - this.bb.writeFloat32(this.bb_pos + offset, value); - return true; - } - - /** - * @param {number} index - * @param {flatbuffers.Encoding=} optionalEncoding - * @returns {string|Uint8Array} - */ - testarrayofstring2(index: number): string; - testarrayofstring2(index: number, optionalEncoding: flatbuffers.Encoding): string|Uint8Array; - testarrayofstring2(index: number, optionalEncoding?: any): string|Uint8Array { - const offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; - } - - /** - * @returns {number} - */ - testarrayofstring2Length(): number { - const offset = this.bb.__offset(this.bb_pos, 60); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; - } - - /** - * @param {flatbuffers.Builder} builder - */ - static startMonster(builder: flatbuffers.Builder) { - builder.startObject(29); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} posOffset - */ - static addPos(builder: flatbuffers.Builder, posOffset: flatbuffers.Offset) { - builder.addFieldStruct(0, posOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} mana - */ - static addMana(builder: flatbuffers.Builder, mana: number) { - builder.addFieldInt16(1, mana, 150); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} hp - */ - static addHp(builder: flatbuffers.Builder, hp: number) { - builder.addFieldInt16(2, hp, 100); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} nameOffset - */ - static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset) { - builder.addFieldOffset(3, nameOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} inventoryOffset - */ - static addInventory(builder: flatbuffers.Builder, inventoryOffset: flatbuffers.Offset) { - builder.addFieldOffset(5, inventoryOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {Array.} data - * @returns {flatbuffers.Offset} - */ - static createInventoryVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset { - if (!data) { - return null; - } - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ - static startInventoryVector(builder: flatbuffers.Builder, numElems: number) { - builder.startVector(1, numElems, 1); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Color} color - */ - static addColor(builder: flatbuffers.Builder, color: MyGame.Example.Color) { - builder.addFieldInt8(6, color, MyGame.Example.Color.Blue); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {MyGame.Example.Any} testType - */ - static addTestType(builder: flatbuffers.Builder, testType: MyGame.Example.Any) { - builder.addFieldInt8(7, testType, MyGame.Example.Any.NONE); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testOffset - */ - static addTest(builder: flatbuffers.Builder, testOffset: flatbuffers.Offset) { - builder.addFieldOffset(8, testOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} test4Offset - */ - static addTest4(builder: flatbuffers.Builder, test4Offset: flatbuffers.Offset) { - builder.addFieldOffset(9, test4Offset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ - static startTest4Vector(builder: flatbuffers.Builder, numElems: number) { - builder.startVector(4, numElems, 2); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstringOffset - */ - static addTestarrayofstring(builder: flatbuffers.Builder, testarrayofstringOffset: flatbuffers.Offset) { - builder.addFieldOffset(10, testarrayofstringOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {Array.} data - * @returns {flatbuffers.Offset} - */ - static createTestarrayofstringVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset { - if (!data) { - return null; - } - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ - static startTestarrayofstringVector(builder: flatbuffers.Builder, numElems: number) { - builder.startVector(4, numElems, 4); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayoftablesOffset - */ - static addTestarrayoftables(builder: flatbuffers.Builder, testarrayoftablesOffset: flatbuffers.Offset) { - builder.addFieldOffset(11, testarrayoftablesOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {Array.} data - * @returns {flatbuffers.Offset} - */ - static createTestarrayoftablesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset { - if (!data) { - return null; - } - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ - static startTestarrayoftablesVector(builder: flatbuffers.Builder, numElems: number) { - builder.startVector(4, numElems, 4); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} enemyOffset - */ - static addEnemy(builder: flatbuffers.Builder, enemyOffset: flatbuffers.Offset) { - builder.addFieldOffset(12, enemyOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testnestedflatbufferOffset - */ - static addTestnestedflatbuffer(builder: flatbuffers.Builder, testnestedflatbufferOffset: flatbuffers.Offset) { - builder.addFieldOffset(13, testnestedflatbufferOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {Array.} data - * @returns {flatbuffers.Offset} - */ - static createTestnestedflatbufferVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset { - if (!data) { - return null; - } - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]); - } - return builder.endVector(); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ - static startTestnestedflatbufferVector(builder: flatbuffers.Builder, numElems: number) { - builder.startVector(1, numElems, 1); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testemptyOffset - */ - static addTestempty(builder: flatbuffers.Builder, testemptyOffset: flatbuffers.Offset) { - builder.addFieldOffset(14, testemptyOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {boolean} testbool - */ - static addTestbool(builder: flatbuffers.Builder, testbool: boolean) { - builder.addFieldInt8(15, +testbool, +false); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1 - */ - static addTesthashs32Fnv1(builder: flatbuffers.Builder, testhashs32Fnv1: number) { - builder.addFieldInt32(16, testhashs32Fnv1, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1 - */ - static addTesthashu32Fnv1(builder: flatbuffers.Builder, testhashu32Fnv1: number) { - builder.addFieldInt32(17, testhashu32Fnv1, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1 - */ - static addTesthashs64Fnv1(builder: flatbuffers.Builder, testhashs64Fnv1: flatbuffers.Long) { - builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1 - */ - static addTesthashu64Fnv1(builder: flatbuffers.Builder, testhashu64Fnv1: flatbuffers.Long) { - builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} testhashs32Fnv1a - */ - static addTesthashs32Fnv1a(builder: flatbuffers.Builder, testhashs32Fnv1a: number) { - builder.addFieldInt32(20, testhashs32Fnv1a, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} testhashu32Fnv1a - */ - static addTesthashu32Fnv1a(builder: flatbuffers.Builder, testhashu32Fnv1a: number) { - builder.addFieldInt32(21, testhashu32Fnv1a, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashs64Fnv1a - */ - static addTesthashs64Fnv1a(builder: flatbuffers.Builder, testhashs64Fnv1a: flatbuffers.Long) { - builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Long} testhashu64Fnv1a - */ - static addTesthashu64Fnv1a(builder: flatbuffers.Builder, testhashu64Fnv1a: flatbuffers.Long) { - builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofboolsOffset - */ - static addTestarrayofbools(builder: flatbuffers.Builder, testarrayofboolsOffset: flatbuffers.Offset) { - builder.addFieldOffset(24, testarrayofboolsOffset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {Array.} data - * @returns {flatbuffers.Offset} - */ - static createTestarrayofboolsVector(builder: flatbuffers.Builder, data: boolean[]): flatbuffers.Offset { - if (!data) { - return null; - } - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(+data[i]); - } - return builder.endVector(); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ - static startTestarrayofboolsVector(builder: flatbuffers.Builder, numElems: number) { - builder.startVector(1, numElems, 1); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} testf - */ - static addTestf(builder: flatbuffers.Builder, testf: number) { - builder.addFieldFloat32(25, testf, 3.14159); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} testf2 - */ - static addTestf2(builder: flatbuffers.Builder, testf2: number) { - builder.addFieldFloat32(26, testf2, 3.0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} testf3 - */ - static addTestf3(builder: flatbuffers.Builder, testf3: number) { - builder.addFieldFloat32(27, testf3, 0.0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} testarrayofstring2Offset - */ - static addTestarrayofstring2(builder: flatbuffers.Builder, testarrayofstring2Offset: flatbuffers.Offset) { - builder.addFieldOffset(28, testarrayofstring2Offset, 0); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {Array.} data - * @returns {flatbuffers.Offset} - */ - static createTestarrayofstring2Vector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset { - if (!data) { - return null; - } - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - - /** - * @param {flatbuffers.Builder} builder - * @param {number} numElems - */ - static startTestarrayofstring2Vector(builder: flatbuffers.Builder, numElems: number) { - builder.startVector(4, numElems, 4); - } - - /** - * @param {flatbuffers.Builder} builder - * @returns {flatbuffers.Offset} - */ - static endMonster(builder: flatbuffers.Builder): flatbuffers.Offset { - const offset = builder.endObject(); - builder.requiredField(offset, 10); // name - return offset; - } - - /** - * @param {flatbuffers.Builder} builder - * @param {flatbuffers.Offset} offset - */ - static finishMonsterBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset) { - builder.finish(offset, 'MONS'); + this.bb.writeInt8(this.bb_pos + offset, value); + return true; + } + + testType(): Any { + const offset = this.bb.__offset(this.bb_pos, 18); + return offset ? (this.bb.readUint8(this.bb_pos + offset)) : Any.NONE; + } + + test(obj: T): T { + const offset = this.bb.__offset(this.bb_pos, 20); + return offset ? this.bb.__union(obj, this.bb_pos + offset) : null; + } + + test4(index: number, obj?: Test): Test { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? (obj || new Test()).__init(this.bb.__vector(this.bb_pos + offset) + index * 4, this.bb) : null; + } + + test4Length(): number { + const offset = this.bb.__offset(this.bb_pos, 22); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + + testarrayofstring(index: number): string; + testarrayofstring(index: number, optionalEncoding: flatbuffers.Encoding): string|Uint8Array; + testarrayofstring(index: number, optionalEncoding?: any): string|Uint8Array { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + + testarrayofstringLength(): number { + const offset = this.bb.__offset(this.bb_pos, 24); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + + testarrayoftables(index: number, obj?: Monster): Monster { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + + testarrayoftablesLength(): number { + const offset = this.bb.__offset(this.bb_pos, 26); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + + enemy(obj?: Monster): Monster { + const offset = this.bb.__offset(this.bb_pos, 28); + return offset ? (obj || new Monster()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + + testnestedflatbuffer(index: number): number { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0; + } + + testnestedflatbufferLength(): number { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + + testnestedflatbufferArray(): Uint8Array { + const offset = this.bb.__offset(this.bb_pos, 30); + return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + + testempty(obj?: Stat): Stat { + const offset = this.bb.__offset(this.bb_pos, 32); + return offset ? (obj || new Stat()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; + } + + testbool(): boolean { + const offset = this.bb.__offset(this.bb_pos, 34); + return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; + } + + testhashs32Fnv1(): number { + const offset = this.bb.__offset(this.bb_pos, 36); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + + mutate_testhashs32_fnv1(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 36); + + if (offset === 0) { + return false; } + + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + + testhashu32Fnv1(): number { + const offset = this.bb.__offset(this.bb_pos, 38); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + + testhashs64Fnv1(): flatbuffers.Long { + const offset = this.bb.__offset(this.bb_pos, 40); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + + mutate_testhashs64_fnv1(value: flatbuffers.Long): boolean { + const offset = this.bb.__offset(this.bb_pos, 40); + + if (offset === 0) { + return false; + } + + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + + testhashu64Fnv1(): flatbuffers.Long { + const offset = this.bb.__offset(this.bb_pos, 42); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + + testhashs32Fnv1a(): number { + const offset = this.bb.__offset(this.bb_pos, 44); + return offset ? this.bb.readInt32(this.bb_pos + offset) : 0; + } + + mutate_testhashs32_fnv1a(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 44); + + if (offset === 0) { + return false; + } + + this.bb.writeInt32(this.bb_pos + offset, value); + return true; + } + + testhashu32Fnv1a(): number { + const offset = this.bb.__offset(this.bb_pos, 46); + return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; + } + + testhashs64Fnv1a(): flatbuffers.Long { + const offset = this.bb.__offset(this.bb_pos, 48); + return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + + mutate_testhashs64_fnv1a(value: flatbuffers.Long): boolean { + const offset = this.bb.__offset(this.bb_pos, 48); + + if (offset === 0) { + return false; + } + + this.bb.writeInt64(this.bb_pos + offset, value); + return true; + } + + testhashu64Fnv1a(): flatbuffers.Long { + const offset = this.bb.__offset(this.bb_pos, 50); + return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0); + } + + testarrayofbools(index: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? !!this.bb.readInt8(this.bb.__vector(this.bb_pos + offset) + index) : false; + } + + testarrayofboolsLength(): number { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + + testarrayofboolsArray(): Int8Array { + const offset = this.bb.__offset(this.bb_pos, 52); + return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + + testf(): number { + const offset = this.bb.__offset(this.bb_pos, 54); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159; + } + + mutate_testf(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 54); + + if (offset === 0) { + return false; + } + + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + + testf2(): number { + const offset = this.bb.__offset(this.bb_pos, 56); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0; + } + + mutate_testf2(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 56); + + if (offset === 0) { + return false; + } + + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + + testf3(): number { + const offset = this.bb.__offset(this.bb_pos, 58); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; + } + + mutate_testf3(value: number): boolean { + const offset = this.bb.__offset(this.bb_pos, 58); + + if (offset === 0) { + return false; + } + + this.bb.writeFloat32(this.bb_pos + offset, value); + return true; + } + + testarrayofstring2(index: number): string; + testarrayofstring2(index: number, optionalEncoding: flatbuffers.Encoding): string|Uint8Array; + testarrayofstring2(index: number, optionalEncoding?: any): string|Uint8Array { + const offset = this.bb.__offset(this.bb_pos, 60); + return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null; + } + + testarrayofstring2Length(): number { + const offset = this.bb.__offset(this.bb_pos, 60); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + + static startMonster(builder: flatbuffers.Builder) { + builder.startObject(29); + } + + static addPos(builder: flatbuffers.Builder, posOffset: flatbuffers.Offset) { + builder.addFieldStruct(0, posOffset, 0); + } + + static addMana(builder: flatbuffers.Builder, mana: number) { + builder.addFieldInt16(1, mana, 150); + } + + static addHp(builder: flatbuffers.Builder, hp: number) { + builder.addFieldInt16(2, hp, 100); + } + + static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset) { + builder.addFieldOffset(3, nameOffset, 0); + } + + static addInventory(builder: flatbuffers.Builder, inventoryOffset: flatbuffers.Offset) { + builder.addFieldOffset(5, inventoryOffset, 0); + } + + static createInventoryVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset { + if (!data) { + return null; + } + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + + static startInventoryVector(builder: flatbuffers.Builder, numElems: number) { + builder.startVector(1, numElems, 1); + } + + static addColor(builder: flatbuffers.Builder, color: Color) { + builder.addFieldInt8(6, color, Color.Blue); + } + + static addTestType(builder: flatbuffers.Builder, testType: Any) { + builder.addFieldInt8(7, testType, Any.NONE); + } + + static addTest(builder: flatbuffers.Builder, testOffset: flatbuffers.Offset) { + builder.addFieldOffset(8, testOffset, 0); + } + + static addTest4(builder: flatbuffers.Builder, test4Offset: flatbuffers.Offset) { + builder.addFieldOffset(9, test4Offset, 0); + } + + static startTest4Vector(builder: flatbuffers.Builder, numElems: number) { + builder.startVector(4, numElems, 2); + } + + static addTestarrayofstring(builder: flatbuffers.Builder, testarrayofstringOffset: flatbuffers.Offset) { + builder.addFieldOffset(10, testarrayofstringOffset, 0); + } + + static createTestarrayofstringVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset { + if (!data) { + return null; + } + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + + static startTestarrayofstringVector(builder: flatbuffers.Builder, numElems: number) { + builder.startVector(4, numElems, 4); + } + + static addTestarrayoftables(builder: flatbuffers.Builder, testarrayoftablesOffset: flatbuffers.Offset) { + builder.addFieldOffset(11, testarrayoftablesOffset, 0); + } + + static createTestarrayoftablesVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset { + if (!data) { + return null; + } + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + + static startTestarrayoftablesVector(builder: flatbuffers.Builder, numElems: number) { + builder.startVector(4, numElems, 4); + } + + static addEnemy(builder: flatbuffers.Builder, enemyOffset: flatbuffers.Offset) { + builder.addFieldOffset(12, enemyOffset, 0); + } + + static addTestnestedflatbuffer(builder: flatbuffers.Builder, testnestedflatbufferOffset: flatbuffers.Offset) { + builder.addFieldOffset(13, testnestedflatbufferOffset, 0); + } + + static createTestnestedflatbufferVector(builder: flatbuffers.Builder, data: number[] | Uint8Array): flatbuffers.Offset { + if (!data) { + return null; + } + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(data[i]); + } + return builder.endVector(); + } + + static startTestnestedflatbufferVector(builder: flatbuffers.Builder, numElems: number) { + builder.startVector(1, numElems, 1); + } + + static addTestempty(builder: flatbuffers.Builder, testemptyOffset: flatbuffers.Offset) { + builder.addFieldOffset(14, testemptyOffset, 0); + } + + static addTestbool(builder: flatbuffers.Builder, testbool: boolean) { + builder.addFieldInt8(15, +testbool, +false); + } + + static addTesthashs32Fnv1(builder: flatbuffers.Builder, testhashs32Fnv1: number) { + builder.addFieldInt32(16, testhashs32Fnv1, 0); + } + + static addTesthashu32Fnv1(builder: flatbuffers.Builder, testhashu32Fnv1: number) { + builder.addFieldInt32(17, testhashu32Fnv1, 0); + } + + static addTesthashs64Fnv1(builder: flatbuffers.Builder, testhashs64Fnv1: flatbuffers.Long) { + builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0)); + } + + static addTesthashu64Fnv1(builder: flatbuffers.Builder, testhashu64Fnv1: flatbuffers.Long) { + builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0)); + } + + static addTesthashs32Fnv1a(builder: flatbuffers.Builder, testhashs32Fnv1a: number) { + builder.addFieldInt32(20, testhashs32Fnv1a, 0); + } + + static addTesthashu32Fnv1a(builder: flatbuffers.Builder, testhashu32Fnv1a: number) { + builder.addFieldInt32(21, testhashu32Fnv1a, 0); + } + + static addTesthashs64Fnv1a(builder: flatbuffers.Builder, testhashs64Fnv1a: flatbuffers.Long) { + builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0)); + } + + static addTesthashu64Fnv1a(builder: flatbuffers.Builder, testhashu64Fnv1a: flatbuffers.Long) { + builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0)); + } + + static addTestarrayofbools(builder: flatbuffers.Builder, testarrayofboolsOffset: flatbuffers.Offset) { + builder.addFieldOffset(24, testarrayofboolsOffset, 0); + } + + static createTestarrayofboolsVector(builder: flatbuffers.Builder, data: boolean[]): flatbuffers.Offset { + if (!data) { + return null; + } + builder.startVector(1, data.length, 1); + for (let i = data.length - 1; i >= 0; i--) { + builder.addInt8(+data[i]); + } + return builder.endVector(); + } + + static startTestarrayofboolsVector(builder: flatbuffers.Builder, numElems: number) { + builder.startVector(1, numElems, 1); + } + + static addTestf(builder: flatbuffers.Builder, testf: number) { + builder.addFieldFloat32(25, testf, 3.14159); + } + + static addTestf2(builder: flatbuffers.Builder, testf2: number) { + builder.addFieldFloat32(26, testf2, 3.0); + } + + static addTestf3(builder: flatbuffers.Builder, testf3: number) { + builder.addFieldFloat32(27, testf3, 0.0); + } + + static addTestarrayofstring2(builder: flatbuffers.Builder, testarrayofstring2Offset: flatbuffers.Offset) { + builder.addFieldOffset(28, testarrayofstring2Offset, 0); + } + + static createTestarrayofstring2Vector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset { + if (!data) { + return null; + } + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + + static startTestarrayofstring2Vector(builder: flatbuffers.Builder, numElems: number) { + builder.startVector(4, numElems, 4); + } + + static endMonster(builder: flatbuffers.Builder): flatbuffers.Offset { + const offset = builder.endObject(); + builder.requiredField(offset, 10); // name + return offset; + } + + static finishMonsterBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset) { + builder.finish(offset, 'MONS'); } } diff --git a/types/later/later-tests.ts b/types/later/later-tests.ts index ea21977c5b..e7792d68e0 100644 --- a/types/later/later-tests.ts +++ b/types/later/later-tests.ts @@ -1,6 +1,6 @@ import later = require("later"); -namespace LaterTest_DefineSchedule { +function LaterTest_DefineSchedule() { // define a new schedule const textSched = later.parse.text('at 10:15am every weekday'); const cronSched = later.parse.cron('0 0/5 14,18 * * ?'); @@ -19,7 +19,7 @@ namespace LaterTest_DefineSchedule { .on(3).month(); } -namespace LaterTest_ConfigureTimezone { +function LaterTest_ConfigureTimezone() { // set later to use UTC (the default) later.date.UTC(); @@ -27,8 +27,8 @@ namespace LaterTest_ConfigureTimezone { later.date.localTime(); } -namespace LaterTest_TimePeriods { - export function second() { +function LaterTest_TimePeriods() { + function second() { const d = new Date('2013-03-22T10:02:05Z'); later.second.name; @@ -59,7 +59,7 @@ namespace LaterTest_TimePeriods { // 'Fri, 22 Mar 2013 10:01:27 GMT' } - export function minute() { + function minute() { const d = new Date('2013-03-22T10:02:05Z'); later.minute.name; @@ -90,7 +90,7 @@ namespace LaterTest_TimePeriods { // 'Fri, 22 Mar 2013 09:27:59 GMT' } - export function hour() { + function hour() { const d = new Date('2013-03-22T10:02:05Z'); later.hour.name; @@ -121,7 +121,7 @@ namespace LaterTest_TimePeriods { // 'Thu, 21 Mar 2013 21:59:59 GMT' } - export function time() { + function time() { const d = new Date('2013-03-22T10:02:05Z'); later.time.name; @@ -152,7 +152,7 @@ namespace LaterTest_TimePeriods { // 'Fri, 22 Mar 2013 00:01:00 GMT' } - export function day() { + function day() { const d = new Date('2013-03-22T10:02:05Z'); later.day.name; @@ -183,7 +183,7 @@ namespace LaterTest_TimePeriods { // 'Sat, 02 Mar 2013 23:59:59 GMT' } - export function day_of_week() { + function day_of_week() { const d = new Date('2013-03-22T10:02:05Z'); later.dayOfWeek.name; @@ -214,7 +214,7 @@ namespace LaterTest_TimePeriods { // 'Thu, 21 Mar 2013 23:59:59 GMT' } - export function day_of_week_count() { + function day_of_week_count() { const d = new Date('2013-03-22T10:02:05Z'); later.dayOfWeekCount.name; @@ -249,7 +249,7 @@ namespace LaterTest_TimePeriods { // 'Thu, 14 Mar 2013 23:59:59 GMT' } - export function day_of_year() { + function day_of_year() { const d = new Date('2013-03-22T10:02:05Z'); later.dayOfYear.name; @@ -280,7 +280,7 @@ namespace LaterTest_TimePeriods { // 'Wed, 13 Feb 2013 23:59:59 GMT' } - export function week_of_month() { + function week_of_month() { const d = new Date('2013-03-22T10:02:05Z'); later.weekOfMonth.name; @@ -311,7 +311,7 @@ namespace LaterTest_TimePeriods { // 'Sat, 09 Mar 2013 23:59:59 GMT' } - export function week_of_year() { + function week_of_year() { const d = new Date('2013-03-22T10:02:05Z'); later.weekOfYear.name; @@ -342,7 +342,7 @@ namespace LaterTest_TimePeriods { // 'Sun, 30 Dec 2012 23:59:59 GMT' } - export function month() { + function month() { const d = new Date('2013-03-22T10:02:05Z'); later.month.name; @@ -373,7 +373,7 @@ namespace LaterTest_TimePeriods { // 'Thu, 28 Feb 2013 23:59:59 GMT' } - export function year() { + function year() { const d = new Date('2013-03-22T10:02:05Z'); later.year.name; @@ -404,11 +404,11 @@ namespace LaterTest_TimePeriods { // 'Mon, 31 Dec 2012 23:59:59 GMT' } - export interface PartOfDayLater extends later.Static { + interface PartOfDayLater extends later.Static { partOfDay: later.TimePeriod; } - export function custom() { + function custom() { const customLater = later; customLater.partOfDay = { @@ -497,8 +497,8 @@ namespace LaterTest_TimePeriods { } } -namespace LaterTest_GenerateRecurences { - export function on_method() { +function LaterTest_GenerateRecurences() { + function on_method() { // fires on the 2nd minute every hour later.parse.recur().on(2).minute(); @@ -509,27 +509,27 @@ namespace LaterTest_GenerateRecurences { later.parse.recur().on('08:00:00').time(); } - export function first_method() { + function first_method() { // fires on the 0th minute of every hour later.parse.recur().first().minute(); } - export function last_method() { + function last_method() { // fires on the last day of every month at 5am later.parse.recur().on(5).hour().last().dayOfMonth(); } - export function onWeekend_method() { + function onWeekend_method() { // fires on the 5th minute of every hour during Sat and Sun later.parse.recur().on(5).minute().onWeekend(); } - export function onWeekday_method() { + function onWeekday_method() { // fires on the 5th minute of every hour during Mon,Tues,Wed,Thur,Fri later.parse.recur().on(5).minute().onWeekday(); } - export function every_method() { + function every_method() { // fires on the 0th, 10th, 20th, 30th, 40th, and 50th min of every hour later.parse.recur().every(10).minute(); @@ -537,7 +537,7 @@ namespace LaterTest_GenerateRecurences { later.parse.recur().every(3).month(); } - export function after_method() { + function after_method() { // fires on the 55th, 56th, 57th, 58th, and 59th minute later.parse.recur().after(55).minute(); @@ -545,7 +545,7 @@ namespace LaterTest_GenerateRecurences { later.parse.recur().every(6).hour().after('09:00').time(); } - export function before_method() { + function before_method() { // fires on the first second of January and February later.parse.recur().before(3).month(); @@ -557,17 +557,17 @@ namespace LaterTest_GenerateRecurences { later.parse.recur().after(9).hour().before(18).hour(); } - export function startingOn_method() { + function startingOn_method() { // fires on the 10th, 25th, 40th, and 55th minute of every hour later.parse.recur().every(15).minute().startingOn(10); } - export function between_method() { + function between_method() { // fires on the 10th, 25th, 40th minute of every hour later.parse.recur().every(15).minute().between(10, 40); } - export function and_method() { + function and_method() { // fires every 2 hours on the first day of every month // and 8:00am and 8:00pm on the last day of every month const sched = later.parse.recur() @@ -576,7 +576,7 @@ namespace LaterTest_GenerateRecurences { .on(8, 20).hour().last().dayOfMonth(); } - export function except_method() { + function except_method() { // fires every minute of every hour except on multiples of 2 and 3 const sched = later.parse.recur() .every().minute() @@ -587,7 +587,7 @@ namespace LaterTest_GenerateRecurences { } } -namespace LaterTest_CalculateOccurences { +function LaterTest_CalculateOccurences() { // Initialise next variable. let next: Date[] = []; @@ -602,7 +602,7 @@ namespace LaterTest_CalculateOccurences { next = later.schedule(cronSched).prev(1, new Date(2013, 2, 21)); } -namespace LaterTest_ExecuteCodeUsingSchedule { +function LaterTest_ExecuteCodeUsingSchedule() { // will fire every 5 minutes const textSched = later.parse.text('every 5 min'); diff --git a/types/lodash/tslint.json b/types/lodash/tslint.json index aca1d8682a..d973c102d6 100644 --- a/types/lodash/tslint.json +++ b/types/lodash/tslint.json @@ -13,6 +13,7 @@ "jsdoc-format": false, "max-line-length": false, "no-empty-interface": false, + "no-namespace": false, "no-trailing-whitespace": false, "object-literal-key-quotes": false, "one-line": false, diff --git a/types/memcached/memcached-tests.ts b/types/memcached/memcached-tests.ts index 9101471a8a..6ae024d4b5 100644 --- a/types/memcached/memcached-tests.ts +++ b/types/memcached/memcached-tests.ts @@ -1,429 +1,427 @@ import Memcached = require('memcached'); import assert = require('assert'); -namespace main { - function isString(expected?: string): void { - if (expected !== undefined && typeof expected !== 'string') { - throw new Error(); - } - } - function isArray(expected?: any[]): void { - if (expected !== undefined && !Array.isArray(expected)) { - throw new Error(); - } - } - function isNumber(expected?: number): void { - if (expected !== undefined && typeof expected !== 'number') { - throw new Error(); - } - } - function isBoolean(expected?: boolean): void { - if (expected !== undefined && typeof expected !== 'boolean') { - throw new Error(); - } - } - function isFunction(expected?: (...args: any[]) => void): void { - if (expected !== undefined && typeof expected !== 'function') { - throw new Error(); - } - } - function isVoid(expected?: undefined): void { - if (expected !== undefined) { - throw new Error(); - } - } - - namespace test_global_options { - Memcached.config.maxKeySize = 250; - Memcached.config.maxExpiration = 2592000; - Memcached.config.maxValue = 1048576; - Memcached.config.poolSize = 10; - Memcached.config.algorithm = 'md5'; - Memcached.config.reconnect = 1000; - Memcached.config.timeout = 100; - Memcached.config.retries = 1; - Memcached.config.failures = 5; - Memcached.config.retry = 100; - Memcached.config.remove = false; - Memcached.config.failOverServers = undefined; - Memcached.config.keyCompression = true; - Memcached.config.idle = 5000; - } - - namespace test_constructor_with_string { - const location = '127.0.0.1:11211'; - - const memcached = new Memcached(location); - memcached.end(); - } - - namespace test_constructor_with_array { - const location = [ - '127.0.0.1:11211', - '127.0.0.1:11212', - '127.0.0.1:11213' - ]; - - const memcached = new Memcached(location); - memcached.end(); - } - - namespace test_constructor_with_object { - const location = { - '127.0.0.1:11211': 1, - '127.0.0.1:11212': 2, - '127.0.0.1:11213': 3 - }; - - const memcached = new Memcached(location); - memcached.end(); - } - - namespace test_constructor_with_options { - const location = '127.0.0.1:11211'; - const options: Memcached.options = { - maxKeySize: 250, - maxExpiration: 2592000, - maxValue: 1048576, - poolSize: 10, - algorithm: 'md5', - reconnect: 18000000, - timeout: 5000, - retries: 5, - failures: 5, - retry: 30000, - remove: false, - failOverServers: undefined, - keyCompression: true, - idle: 5000, - }; - - const memcached = new Memcached(location, options); - memcached.end(); - } - - const memcached = new Memcached('127.0.0.1:11211'); - - namespace test_events { - function isIssue(expected: Memcached.IssueData) { - isString(expected.server); - isArray(expected.tokens); - isArray(expected.messages); - isNumber(expected.failures); - isNumber(expected.totalFailures); - isNumber(expected.totalReconnectsAttempted); - isNumber(expected.totalReconnectsSuccess); - isNumber(expected.totalReconnectsFailed); - isNumber(expected.totalDownTime); - } - memcached.on('issue', isIssue); - memcached.on('failure', isIssue); - memcached.on('reconnecting', isIssue); - memcached.on('reconnect', isIssue); - memcached.on('remove', isIssue); - } - - function isCommandData(expected: Memcached.CommandData) { - isNumber(expected.start); - isNumber(expected.execution); - isFunction(expected.callback); - isString(expected.type); - isString(expected.command); - isArray(expected.validate); - isBoolean(expected.redundancyEnabled); - isString(expected.key); - isNumber(expected.lifetime); - isString(expected.cas); - } - namespace test_set { - memcached.set('key', 'value', 3600, function(err) { - isCommandData(this); - }); - } - namespace test_touch { - memcached.touch('key', 3600, function(err) { - isCommandData(this); - }); - } - namespace test_get { - memcached.get('key', function(err, data) { - isCommandData(this); - }); - } - namespace test_getMulti { - memcached.getMulti(['foo', 'bar'], function(err, data) { - isVoid(this); - assert(typeof data, 'object'); - }); - } - namespace test_cas { - const promises = []; - const key = 'caskey'; - const value = 'casvalue'; - - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.set(key, value, 0, function() { - isCommandData(this); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.gets(key, function(err, data) { - isCommandData(this); - memcached.cas(key, value, data.cas, 0, function(err, result) { - isCommandData(this); - assert(result); - resolve(); - }); - }); - })) - .then(() => new Promise(resolve => { - memcached.cas(key, value, '99', 0, function(err, result) { - isCommandData(this); - assert(!result); - resolve(); - }); - })) - ; - } - - namespace test_replace { - const promises = []; - const key = 'replacekey'; - const value = 'replacevalue'; - - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.set(key, value, 0, () => { - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.replace(key, value, 0, function(err, result) { - assert(result); - isCommandData(this); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.replace('noexistss', value, 0, function(err, result) { - assert(!result); - isCommandData(this); - resolve(); - }); - })) - ; - } - namespace test_add { - const promises = []; - const key = 'addkey'; - const value = 'addvalue'; - - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.add(key, value, 0, function(err, result) { - assert(result); - isCommandData(this); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.add(key, value, 0, function(err, result) { - assert(!result); - isCommandData(this); - resolve(); - }); - })) - ; - } - namespace test_append { - const promises = []; - const key = 'appendkey'; - const value = 'appendvalue'; - - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.set(key, value, 0, (err, result) => { - isBoolean(result); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.append(key, value, (err, result) => { - isBoolean(result); - resolve(); - }); - })) - ; - } - namespace test_prepend { - const promises = []; - const key = 'prependkey'; - const value = 'prependvalue'; - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.set(key, value, 0, (err, result) => { - isBoolean(result); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.prepend(key, value, function(err, result) { - isBoolean(result); - isCommandData(this); - resolve(); - }); - })) - ; - } - namespace test_incr { - const promises = []; - const key = 'incrkey'; - const value = 2; - - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.set(key, value, 0, (err, result) => { - isBoolean(result); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.incr(key, value, function(err, result) { - assert.deepStrictEqual(result, 4); - isCommandData(this); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.incr('noexists', value, function(err, result) { - assert.deepStrictEqual(result, false); - isCommandData(this); - resolve(); - }); - })) - ; - } - namespace test_decr { - const promises = []; - const key = 'decrkey'; - const value = 2; - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.set(key, value, 0, function(err, result) { - isCommandData(this); - isBoolean(result); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.decr(key, value, function(err, result) { - assert.deepStrictEqual(result, 0); - isCommandData(this); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.decr('noexists', value, function(err, result) { - assert.deepStrictEqual(result, false); - isCommandData(this); - resolve(); - }); - })) - ; - } - namespace test_decr { - const promises = []; - const key = 'delkey'; - const value = 'delvalue'; - Promise.resolve() - .then(() => new Promise(resolve => { - memcached.set(key, value, 0, (err, result) => { - isBoolean(result); - resolve(); - }); - })) - .then(() => new Promise(resolve => { - memcached.del(key, function(err, result) { - isBoolean(result); - isCommandData(this); - resolve(); - }); - })) - ; - } - - namespace test_version { - memcached.version((err, data) => { - for (const version of data) { - isString(version.server); - isString(version.version); - isString(version.major); - isString(version.minor); - isString(version.bugfix); - } - }); - } - namespace test_stats { - memcached.stats((err: any, data: Memcached.StatusData[]) => { - isArray(data); - for (const stat of data) { - isString(stat.server); - } - }); - } - namespace test_settings { - memcached.settings((err: any, data: Memcached.StatusData[]) => { - isArray(data); - for (const setting of data) { - isString(setting.server); - } - }); - } - namespace test_slabs { - memcached.slabs((err: any, data: Memcached.StatusData[]) => { - isArray(data); - for (const setting of data) { - isString(setting.server); - } - }); - } - let promise: Promise; - namespace test_items { - promise = new Promise(resolve => { - memcached.items((err, data) => { - isArray(data); - for (const setting of data) { - isString(setting.server); - } - resolve(data); - }); - }); - } - namespace test_cachedump { - promise.then(data => { - for (const node of data) { - const server = node.server; - delete node.server; - Object.keys(node).forEach(slabid => { - memcached.cachedump(server, Number(slabid), node[slabid].number, (err, data) => { - if (!Array.isArray(data)) data = [data]; - data.forEach(cache => { - isNumber(cache.b); - isNumber(cache.s); - isString(cache.key); - }); - }); - }); - } - }); - } - - namespace test_flush { - memcached.flush(function(err, results) { - isVoid(this); - isArray(results); - }); +function isString(expected?: string): void { + if (expected !== undefined && typeof expected !== 'string') { + throw new Error(); } } +function isArray(expected?: any[]): void { + if (expected !== undefined && !Array.isArray(expected)) { + throw new Error(); + } +} +function isNumber(expected?: number): void { + if (expected !== undefined && typeof expected !== 'number') { + throw new Error(); + } +} +function isBoolean(expected?: boolean): void { + if (expected !== undefined && typeof expected !== 'boolean') { + throw new Error(); + } +} +function isFunction(expected?: (...args: any[]) => void): void { + if (expected !== undefined && typeof expected !== 'function') { + throw new Error(); + } +} +function isVoid(expected?: undefined): void { + if (expected !== undefined) { + throw new Error(); + } +} + +function test_global_options() { + Memcached.config.maxKeySize = 250; + Memcached.config.maxExpiration = 2592000; + Memcached.config.maxValue = 1048576; + Memcached.config.poolSize = 10; + Memcached.config.algorithm = 'md5'; + Memcached.config.reconnect = 1000; + Memcached.config.timeout = 100; + Memcached.config.retries = 1; + Memcached.config.failures = 5; + Memcached.config.retry = 100; + Memcached.config.remove = false; + Memcached.config.failOverServers = undefined; + Memcached.config.keyCompression = true; + Memcached.config.idle = 5000; +} + +function test_constructor_with_string() { + const location = '127.0.0.1:11211'; + + const memcached = new Memcached(location); + memcached.end(); +} + +function test_constructor_with_array() { + const location = [ + '127.0.0.1:11211', + '127.0.0.1:11212', + '127.0.0.1:11213' + ]; + + const memcached = new Memcached(location); + memcached.end(); +} + +function test_constructor_with_object() { + const location = { + '127.0.0.1:11211': 1, + '127.0.0.1:11212': 2, + '127.0.0.1:11213': 3 + }; + + const memcached = new Memcached(location); + memcached.end(); +} + +function test_constructor_with_options() { + const location = '127.0.0.1:11211'; + const options: Memcached.options = { + maxKeySize: 250, + maxExpiration: 2592000, + maxValue: 1048576, + poolSize: 10, + algorithm: 'md5', + reconnect: 18000000, + timeout: 5000, + retries: 5, + failures: 5, + retry: 30000, + remove: false, + failOverServers: undefined, + keyCompression: true, + idle: 5000, + }; + + const memcached = new Memcached(location, options); + memcached.end(); +} + +const memcached = new Memcached('127.0.0.1:11211'); + +function test_events() { + function isIssue(expected: Memcached.IssueData) { + isString(expected.server); + isArray(expected.tokens); + isArray(expected.messages); + isNumber(expected.failures); + isNumber(expected.totalFailures); + isNumber(expected.totalReconnectsAttempted); + isNumber(expected.totalReconnectsSuccess); + isNumber(expected.totalReconnectsFailed); + isNumber(expected.totalDownTime); + } + memcached.on('issue', isIssue); + memcached.on('failure', isIssue); + memcached.on('reconnecting', isIssue); + memcached.on('reconnect', isIssue); + memcached.on('remove', isIssue); +} + +function isCommandData(expected: Memcached.CommandData) { + isNumber(expected.start); + isNumber(expected.execution); + isFunction(expected.callback); + isString(expected.type); + isString(expected.command); + isArray(expected.validate); + isBoolean(expected.redundancyEnabled); + isString(expected.key); + isNumber(expected.lifetime); + isString(expected.cas); +} +function test_set() { + memcached.set('key', 'value', 3600, function(err) { + isCommandData(this); + }); +} +function test_touch() { + memcached.touch('key', 3600, function(err) { + isCommandData(this); + }); +} +function test_get() { + memcached.get('key', function(err, data) { + isCommandData(this); + }); +} +function test_getMulti() { + memcached.getMulti(['foo', 'bar'], function(err, data) { + isVoid(this); + assert(typeof data, 'object'); + }); +} +function test_cas() { + const promises = []; + const key = 'caskey'; + const value = 'casvalue'; + + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.set(key, value, 0, function() { + isCommandData(this); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.gets(key, function(err, data) { + isCommandData(this); + memcached.cas(key, value, data.cas, 0, function(err, result) { + isCommandData(this); + assert(result); + resolve(); + }); + }); + })) + .then(() => new Promise(resolve => { + memcached.cas(key, value, '99', 0, function(err, result) { + isCommandData(this); + assert(!result); + resolve(); + }); + })) + ; +} + +function test_replace() { + const promises = []; + const key = 'replacekey'; + const value = 'replacevalue'; + + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.set(key, value, 0, () => { + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.replace(key, value, 0, function(err, result) { + assert(result); + isCommandData(this); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.replace('noexistss', value, 0, function(err, result) { + assert(!result); + isCommandData(this); + resolve(); + }); + })) + ; +} +function test_add() { + const promises = []; + const key = 'addkey'; + const value = 'addvalue'; + + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.add(key, value, 0, function(err, result) { + assert(result); + isCommandData(this); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.add(key, value, 0, function(err, result) { + assert(!result); + isCommandData(this); + resolve(); + }); + })) + ; +} +function test_append() { + const promises = []; + const key = 'appendkey'; + const value = 'appendvalue'; + + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.set(key, value, 0, (err, result) => { + isBoolean(result); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.append(key, value, (err, result) => { + isBoolean(result); + resolve(); + }); + })) + ; +} +function test_prepend() { + const promises = []; + const key = 'prependkey'; + const value = 'prependvalue'; + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.set(key, value, 0, (err, result) => { + isBoolean(result); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.prepend(key, value, function(err, result) { + isBoolean(result); + isCommandData(this); + resolve(); + }); + })) + ; +} +function test_incr() { + const promises = []; + const key = 'incrkey'; + const value = 2; + + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.set(key, value, 0, (err, result) => { + isBoolean(result); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.incr(key, value, function(err, result) { + assert.deepStrictEqual(result, 4); + isCommandData(this); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.incr('noexists', value, function(err, result) { + assert.deepStrictEqual(result, false); + isCommandData(this); + resolve(); + }); + })) + ; +} +function test_decr() { + const promises = []; + const key = 'decrkey'; + const value = 2; + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.set(key, value, 0, function(err, result) { + isCommandData(this); + isBoolean(result); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.decr(key, value, function(err, result) { + assert.deepStrictEqual(result, 0); + isCommandData(this); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.decr('noexists', value, function(err, result) { + assert.deepStrictEqual(result, false); + isCommandData(this); + resolve(); + }); + })) + ; +} +function test_decr_2() { + const promises = []; + const key = 'delkey'; + const value = 'delvalue'; + Promise.resolve() + .then(() => new Promise(resolve => { + memcached.set(key, value, 0, (err, result) => { + isBoolean(result); + resolve(); + }); + })) + .then(() => new Promise(resolve => { + memcached.del(key, function(err, result) { + isBoolean(result); + isCommandData(this); + resolve(); + }); + })) + ; +} + +function test_version() { + memcached.version((err, data) => { + for (const version of data) { + isString(version.server); + isString(version.version); + isString(version.major); + isString(version.minor); + isString(version.bugfix); + } + }); +} +function test_stats() { + memcached.stats((err: any, data: Memcached.StatusData[]) => { + isArray(data); + for (const stat of data) { + isString(stat.server); + } + }); +} +function test_settings() { + memcached.settings((err: any, data: Memcached.StatusData[]) => { + isArray(data); + for (const setting of data) { + isString(setting.server); + } + }); +} +function test_slabs() { + memcached.slabs((err: any, data: Memcached.StatusData[]) => { + isArray(data); + for (const setting of data) { + isString(setting.server); + } + }); +} +let promise: Promise; +function test_items() { + promise = new Promise(resolve => { + memcached.items((err, data) => { + isArray(data); + for (const setting of data) { + isString(setting.server); + } + resolve(data); + }); + }); +} +function test_cachedump() { + promise.then(data => { + for (const node of data) { + const server = node.server; + delete node.server; + Object.keys(node).forEach(slabid => { + memcached.cachedump(server, Number(slabid), node[slabid].number, (err, data) => { + if (!Array.isArray(data)) data = [data]; + data.forEach(cache => { + isNumber(cache.b); + isNumber(cache.s); + isString(cache.key); + }); + }); + }); + } + }); +} + +function test_flush() { + memcached.flush(function(err, results) { + isVoid(this); + isArray(results); + }); +} diff --git a/types/node/tslint.json b/types/node/tslint.json index 7ef1d5cd51..7ca0a1dd7c 100644 --- a/types/node/tslint.json +++ b/types/node/tslint.json @@ -16,6 +16,7 @@ "no-consecutive-blank-lines": false, "no-empty-interface": false, "no-internal-module": false, + "no-namespace": false, "no-padding": false, "no-string-throw": false, "no-var": false, diff --git a/types/node/v0/tslint.json b/types/node/v0/tslint.json index a7a879539e..6ee9f3deb4 100644 --- a/types/node/v0/tslint.json +++ b/types/node/v0/tslint.json @@ -15,6 +15,7 @@ "no-consecutive-blank-lines": false, "no-empty-interface": false, "no-internal-module": false, + "no-namespace": false, "no-padding": false, "no-string-throw": false, "no-var": false, diff --git a/types/node/v4/tslint.json b/types/node/v4/tslint.json index a560bfc623..3eccb5c30c 100644 --- a/types/node/v4/tslint.json +++ b/types/node/v4/tslint.json @@ -15,6 +15,7 @@ "no-consecutive-blank-lines": false, "no-empty-interface": false, "no-internal-module": false, + "no-namespace": false, "no-padding": false, "no-string-throw": false, "no-var": false, diff --git a/types/node/v6/tslint.json b/types/node/v6/tslint.json index a904fc31ca..a0dbad4bbd 100644 --- a/types/node/v6/tslint.json +++ b/types/node/v6/tslint.json @@ -16,6 +16,7 @@ "no-consecutive-blank-lines": false, "no-empty-interface": false, "no-internal-module": false, + "no-namespace": false, "no-padding": false, "no-string-throw": false, "no-var": false, diff --git a/types/pixi.js/pixi.js-tests.ts b/types/pixi.js/pixi.js-tests.ts index 72325504da..95c24e08ac 100644 --- a/types/pixi.js/pixi.js-tests.ts +++ b/types/pixi.js/pixi.js-tests.ts @@ -1,5 +1,5 @@ -namespace basics { - export class Basics { +function basics() { + class Basics { private app: PIXI.Application; private bunny: PIXI.Sprite; @@ -20,7 +20,7 @@ namespace basics { } } - export class Click { + class Click { private app: PIXI.Application; private sprite: PIXI.Sprite; @@ -44,7 +44,7 @@ namespace basics { } } - export class ContainerPivot { + class ContainerPivot { private app: PIXI.Application; private container: PIXI.Container; @@ -77,7 +77,7 @@ namespace basics { } } - export class Container { + class Container { private app: PIXI.Application; private container: PIXI.Container; @@ -103,7 +103,7 @@ namespace basics { } } - export class CustomizedFilter extends PIXI.Filter { + class CustomizedFilter extends PIXI.Filter { constructor(fragmentSource: string) { super(null, fragmentSource, { customUniform: { @@ -113,7 +113,7 @@ namespace basics { }); } } - export class CustomFilter { + class CustomFilter { private app: PIXI.Application; private background: PIXI.Sprite; private filter: CustomizedFilter; @@ -142,7 +142,7 @@ namespace basics { } } - export class Graphics { + class Graphics { private app: PIXI.Application; private graphics: PIXI.Graphics; @@ -186,7 +186,7 @@ namespace basics { } } - export class RenderTexture { + class RenderTexture { private app: PIXI.Application; private container: PIXI.Container; private renderTexture: PIXI.RenderTexture; @@ -226,7 +226,7 @@ namespace basics { } } - export class SpriteSheet { + class SpriteSheet { private app: PIXI.Application; private anim: PIXI.extras.AnimatedSprite; @@ -259,7 +259,7 @@ namespace basics { } } - export class Text { + class Text { private app: PIXI.Application; private basicText: PIXI.Text; private richText: PIXI.Text; @@ -297,7 +297,7 @@ namespace basics { } } - export class TexturedMesh { + class TexturedMesh { private app: PIXI.Application; private count: number; private points: PIXI.Point[]; @@ -351,7 +351,7 @@ namespace basics { } } - export class TilingSprite { + class TilingSprite { private app: PIXI.Application; private tilingSprite: PIXI.extras.TilingSprite; private count: number; @@ -382,7 +382,7 @@ namespace basics { } } - export class Video { + class Video { private app: PIXI.Application; private button: PIXI.Graphics; private videoSprite: PIXI.Sprite; @@ -425,8 +425,8 @@ namespace basics { } } -namespace demos { - export class AlphaMask { +function demos() { + class AlphaMask { private app: PIXI.Application; private bg: PIXI.Container; private cells: PIXI.Sprite; @@ -473,7 +473,7 @@ namespace demos { } } - export class AnimatedSpriteDemo { + class AnimatedSpriteDemo { private app: PIXI.Application; constructor() { @@ -508,7 +508,7 @@ namespace demos { } } - export class Batch { + class Batch { private app: PIXI.Application; private sprites: PIXI.particles.ParticleContainer; private maggots: Dude[]; @@ -586,7 +586,7 @@ namespace demos { }); } } - export class Dude extends PIXI.Sprite { + class Dude extends PIXI.Sprite { direction: number = 0; speed: number = 0; turningSpeed: number = 0; @@ -597,7 +597,7 @@ namespace demos { } } - export class BlendModes { + class BlendModes { private app: PIXI.Application; private background: PIXI.Sprite; private dudeArray: Dude[]; @@ -662,7 +662,7 @@ namespace demos { } } - export class CacheAsBitmap { + class CacheAsBitmap { private app: PIXI.Application; private aliens: PIXI.Sprite[]; private count: number; @@ -727,7 +727,7 @@ namespace demos { } } - export class Dragging { + class Dragging { private app: PIXI.Application; private data: PIXI.interaction.InteractionData; private dragging: boolean; @@ -785,7 +785,7 @@ namespace demos { } } - export class GraphicsDemo { + class GraphicsDemo { private app: PIXI.Application; private graphics: PIXI.Graphics; private thing: PIXI.Graphics; @@ -872,7 +872,7 @@ namespace demos { } } - export class Interactivity { + class Interactivity { private app: PIXI.Application; private background: PIXI.Sprite; private buttons: PIXI.Sprite[]; @@ -938,7 +938,7 @@ namespace demos { } } - export class Masking { + class Masking { private app: PIXI.Application; private bg: PIXI.Sprite; private container: PIXI.Container; @@ -1026,7 +1026,7 @@ namespace demos { } } - export class RenderTextureDemo { + class RenderTextureDemo { private app: PIXI.Application; private renderTexture: PIXI.RenderTexture; @@ -1110,7 +1110,7 @@ namespace demos { } } - export class StripDemo { + class StripDemo { private app: PIXI.Application; private count: number; private points: PIXI.Point[]; @@ -1151,7 +1151,7 @@ namespace demos { } } - export class TextDemo { + class TextDemo { private app: PIXI.Application; private bitmapFontText: PIXI.extras.BitmapText; private background: PIXI.Sprite; @@ -1227,7 +1227,7 @@ namespace demos { } } - export class TextureRotate { + class TextureRotate { private app: PIXI.Application; private bol: boolean; private texture: PIXI.Texture; @@ -1288,7 +1288,7 @@ namespace demos { } } - export class TextureSwap { + class TextureSwap { private app: PIXI.Application; private bol: boolean; private texture: PIXI.Texture; @@ -1328,7 +1328,7 @@ namespace demos { } } - export class Tinting { + class Tinting { private app: PIXI.Application; private aliens: Dude[]; @@ -1386,7 +1386,7 @@ namespace demos { } } - export class TransparentBackground { + class TransparentBackground { private app: PIXI.Application; private bunny: PIXI.Sprite; @@ -1410,8 +1410,8 @@ namespace demos { } } -namespace filters { - export class BlurFilter { +function filters() { + class BlurFilter { private app: PIXI.Application; private bg: PIXI.Sprite; private littleDudes: PIXI.Sprite; @@ -1459,7 +1459,7 @@ namespace filters { } } - export class DisplacementMap { + class DisplacementMap { private app: PIXI.Application; private container: PIXI.Container; private maggots: DisplacementMapDude[]; @@ -1563,7 +1563,7 @@ namespace filters { this.ring.y = eventData.data.global.y; } } - export class DisplacementMapDude extends PIXI.Sprite { + class DisplacementMapDude extends PIXI.Sprite { direction: number = 0; speed: number = 0; turnSpeed: number = 0; @@ -1574,7 +1574,7 @@ namespace filters { } } - export class Filter { + class Filter { private app: PIXI.Application; private bg: PIXI.Sprite; private filter: PIXI.filters.ColorMatrixFilter; diff --git a/types/react-dnd-html5-backend/tslint.json b/types/react-dnd-html5-backend/tslint.json index 3db14f85ea..bf6102640b 100644 --- a/types/react-dnd-html5-backend/tslint.json +++ b/types/react-dnd-html5-backend/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-namespace": false + } +} diff --git a/types/rx-lite/rx-lite-tests.ts b/types/rx-lite/rx-lite-tests.ts index fd3cf65663..6b5a88a341 100644 --- a/types/rx-lite/rx-lite-tests.ts +++ b/types/rx-lite/rx-lite-tests.ts @@ -1,63 +1,61 @@ import * as Rx from 'rx-lite'; -namespace Tests.Async { - let obsNum: Rx.Observable; - let obsStr: Rx.Observable; +let obsNum: Rx.Observable; +let obsStr: Rx.Observable; - function fromCallback() { - // 0 arguments - const func0: (cb: (result: number) => void) => void = () => { }; - obsNum = Rx.Observable.fromCallback(func0)(); - obsNum = Rx.Observable.fromCallback(func0, obsStr)(); - obsNum = Rx.Observable.fromCallback(func0, obsStr, (results: number[]) => results[0])(); +function fromCallback() { + // 0 arguments + const func0: (cb: (result: number) => void) => void = () => { }; + obsNum = Rx.Observable.fromCallback(func0)(); + obsNum = Rx.Observable.fromCallback(func0, obsStr)(); + obsNum = Rx.Observable.fromCallback(func0, obsStr, (results: number[]) => results[0])(); - // 1 argument - const func1: (a: string, cb: (result: number) => void) => number = () => 0; - obsNum = Rx.Observable.fromCallback(func1)(""); - obsNum = Rx.Observable.fromCallback(func1, {})(""); - obsNum = Rx.Observable.fromCallback(func1, {}, (results: number[]) => results[0])(""); + // 1 argument + const func1: (a: string, cb: (result: number) => void) => number = () => 0; + obsNum = Rx.Observable.fromCallback(func1)(""); + obsNum = Rx.Observable.fromCallback(func1, {})(""); + obsNum = Rx.Observable.fromCallback(func1, {}, (results: number[]) => results[0])(""); - // 2 arguments - const func2: (a: number, b: string, cb: (result: string) => number) => Date = () => new Date(); - obsStr = Rx.Observable.fromCallback(func2)(1, ""); - obsStr = Rx.Observable.fromCallback(func2, {})(1, ""); - obsStr = Rx.Observable.fromCallback(func2, {}, (results: string[]) => results[0])(1, ""); + // 2 arguments + const func2: (a: number, b: string, cb: (result: string) => number) => Date = () => new Date(); + obsStr = Rx.Observable.fromCallback(func2)(1, ""); + obsStr = Rx.Observable.fromCallback(func2, {})(1, ""); + obsStr = Rx.Observable.fromCallback(func2, {}, (results: string[]) => results[0])(1, ""); - // 3 arguments - const func3: (a: number, b: string, c: boolean, cb: (result: string) => number) => Date = () => new Date(); - obsStr = Rx.Observable.fromCallback(func3)(1, "", true); - obsStr = Rx.Observable.fromCallback(func3, {})(1, "", true); - obsStr = Rx.Observable.fromCallback(func3, {}, (results: string[]) => results[0])(1, "", true); + // 3 arguments + const func3: (a: number, b: string, c: boolean, cb: (result: string) => number) => Date = () => new Date(); + obsStr = Rx.Observable.fromCallback(func3)(1, "", true); + obsStr = Rx.Observable.fromCallback(func3, {})(1, "", true); + obsStr = Rx.Observable.fromCallback(func3, {}, (results: string[]) => results[0])(1, "", true); - // multiple results - const func0m: (cb: (result1: number, result2: number, result3: number) => void) => void = () => { }; - obsNum = Rx.Observable.fromCallback(func0m, obsStr, (results: number[]) => results[0])(); - const func1m: (a: string, cb: (result1: number, result2: number, result3: number) => void) => void = () => { }; - obsNum = Rx.Observable.fromCallback(func1m, obsStr, (results: number[]) => results[0])(""); - const func2m: (a: string, b: number, cb: (result1: string, result2: string, result3: string) => void) => void = () => { }; - obsStr = Rx.Observable.fromCallback(func2m, obsStr, (results: string[]) => results[0])("", 10); - } + // multiple results + const func0m: (cb: (result1: number, result2: number, result3: number) => void) => void = () => { }; + obsNum = Rx.Observable.fromCallback(func0m, obsStr, (results: number[]) => results[0])(); + const func1m: (a: string, cb: (result1: number, result2: number, result3: number) => void) => void = () => { }; + obsNum = Rx.Observable.fromCallback(func1m, obsStr, (results: number[]) => results[0])(""); + const func2m: (a: string, b: number, cb: (result1: string, result2: string, result3: string) => void) => void = () => { }; + obsStr = Rx.Observable.fromCallback(func2m, obsStr, (results: string[]) => results[0])("", 10); +} - function toPromise() { - const promiseImpl: { - new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Rx.IPromise; - } = undefined as any; +function toPromise() { + const promiseImpl: { + new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Rx.IPromise; + } = undefined as any; - Rx.config.Promise = promiseImpl; + Rx.config.Promise = promiseImpl; - let p: Rx.IPromise = obsNum.toPromise(promiseImpl); + let p: Rx.IPromise = obsNum.toPromise(promiseImpl); - p = obsNum.toPromise(); + p = obsNum.toPromise(); - p = p.then(x => x); - p = p.then(x => p); - p = p.then(undefined, reason => 10); - // p = p.then(undefined, reason => p); + p = p.then(x => x); + p = p.then(x => p); + p = p.then(undefined, reason => 10); + // p = p.then(undefined, reason => p); - let ps: Rx.IPromise = p.then(undefined, reason => "error"); - ps = p.then(x => ""); - ps = p.then(x => ps); - } + let ps: Rx.IPromise = p.then(undefined, reason => "error"); + ps = p.then(x => ""); + ps = p.then(x => ps); } function test_scan() { diff --git a/types/sharepoint/tslint.json b/types/sharepoint/tslint.json index 2d56432edb..65ca630b05 100644 --- a/types/sharepoint/tslint.json +++ b/types/sharepoint/tslint.json @@ -1,7 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { + // TODOs "jsdoc-format": false, - "max-line-length": false + "max-line-length": false, + "no-namespace": false } } diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 8572a11b41..066bdfb740 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -618,9 +618,7 @@ function loader(this: webpack.loader.LoaderContext, source: string, sourcemap: s this.callback(null, source); } -namespace loader { - export const raw: boolean = true; - export const pitch = (remainingRequest: string, precedingRequest: string, data: any) => {}; -} +(loader as webpack.loader.Loader).raw = true; +(loader as webpack.loader.Loader).pitch = (remainingRequest: string, precedingRequest: string, data: any) => {}; const loaderRef: webpack.loader.Loader = loader; console.log(loaderRef.raw === true);