moved to es6 module system

This commit is contained in:
Dolan Miu
2016-03-28 00:53:24 +01:00
parent 5c419cd3c4
commit 7a78dacf8c
19 changed files with 19265 additions and 24 deletions

3
ts/docx/body.ts Normal file
View File

@ -0,0 +1,3 @@
export class Body {
}

11
ts/docx/document.ts Normal file
View File

@ -0,0 +1,11 @@
export class Document {
private body: string;
constructor() {
this.body = "ggg";
}
test() {
return "hello";
}
}

View File

@ -1,6 +0,0 @@
module docx {
export class Docx {
}
}

2
ts/docx/index.ts Normal file
View File

@ -0,0 +1,2 @@
export {Document} from "./document";
export {Paragraph} from "./paragraph";

View File

@ -1,5 +1,7 @@
module docx {
export class Paragraph {
export class Paragraph {
private p: Array<string>;
constructor() {
this.p = ['stuff']
}
}

View File

@ -1,5 +1,3 @@
module docx {
export class Row {
}
}

View File

@ -1,5 +1,3 @@
module docx {
export class TapStop {
}
}

View File

@ -1,5 +1,3 @@
module docx {
export class Table {
}
}

View File

@ -1,5 +1,3 @@
module docx {
export class Text {
}
}

25
ts/export/formatter.ts Normal file
View File

@ -0,0 +1,25 @@
import * as _ from "lodash";
export class Formatter {
format(input: any) {
var stringified = JSON.stringify(input);
var newJson = JSON.parse(stringified);
this.deepTraverseJson(newJson, (parent, value, key) => {
parent.blah = parent[key];
});
return newJson;
}
private deepTraverseJson(json, lambda: (json: any, value: any, key: string) => void) {
_.forOwn(json, function(value, key) {
if (_.isObject(value)) {
this.deepTraverseJson(value, lambda);
return;
}
lambda(json, value, key);
});
};
}

1
ts/index.ts Normal file
View File

@ -0,0 +1 @@
export * from "./docx";

View File

@ -1,7 +1,8 @@
/// <reference path="../docx/docx.ts" />
/// <reference path="../typings/mocha/mocha.d.ts" />
import * as docx from "../docx";
describe('Calculator', () => {
var document : docx.Docx;
var document : docx.Document;
/*beforeEach(function () {
subject = new Calculator();
@ -16,6 +17,10 @@ describe('Calculator', () => {
});
});*/
describe('#test', () => {
console.log(new docx.Docx);
var document = new docx.Document();
var paragraph = new docx.Paragraph();
//var body = new docx.Body();
console.log(JSON.stringify(paragraph));
console.log(document.test());
});
});

19
ts/tests/formatterTest.ts Normal file
View File

@ -0,0 +1,19 @@
/// <reference path="../typings/mocha/mocha.d.ts" />
/// <reference path="../typings/lodash/lodash.d.ts" />
import {Formatter} from "../export/Formatter";
describe('Formatter', () => {
var formatter: Formatter;
beforeEach(() => {
formatter = new Formatter();
});
describe('#format()', () => {
it("should work", () => {
var newJson = formatter.format('{"p":["stuff"]}');
console.log(newJson);
});
});
});

View File

@ -4,9 +4,11 @@
"sourceMap": true,
"removeComments": true,
"preserveConstEnums": true,
"outFile": "../build/build.js",
//"outFile": "../build/build.js",
"outDir": "../build",
"sourceRoot": "./",
"rootDir": "./"
"rootDir": "./",
"module": "commonjs"
},
"exclude": [
"tests"

View File

@ -7,6 +7,9 @@
"installed": {
"mocha/mocha.d.ts": {
"commit": "299b5caa22876ef27dc8e9a5b7fd7bf93457b6f4"
},
"lodash/lodash.d.ts": {
"commit": "299b5caa22876ef27dc8e9a5b7fd7bf93457b6f4"
}
}
}

19172
ts/typings/lodash/lodash.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

1
ts/typings/tsd.d.ts vendored
View File

@ -1,2 +1,3 @@
/// <reference path="mocha/mocha.d.ts" />
/// <reference path="lodash/lodash.d.ts" />