]> git.kianting.info Git - clo/blob - src/libclo/index.ts
add clo library initially with register of prepocessor
[clo] / src / libclo / index.ts
1 import {tkTree} from "../parser";
2
3
4 function foo(arr : tkTree): tkTree{
5 for (let i = 0; i < arr.length; i++) {
6
7 }
8 if (Array.isArray(arr)){
9 arr.push("balabala");
10 }
11 return arr;
12 }
13
14 export class Clo{
15 mainStream : Array<string>;
16 preprocessors : Array<Function>;
17 attributes: object ; // a4 size(x,y)
18
19
20 constructor(){
21 this.preprocessors = [];
22 this.mainStream = [];
23 this.attributes = {"page" : [793.7, 1122.5]};
24 this.preprocessorRegister(foo);
25 }
26
27 /**
28 * register a function of preprocessor
29 * @param f a function
30 */
31 public preprocessorRegister(f : Function){
32 this.preprocessors.push(f);
33 }
34
35 public generatePdf(){
36 // preprocessed
37 var prepro = this.mainStream;
38 for (var i = 0; i<this.preprocessors.length; i++){
39 prepro = this.preprocessors[i](prepro);
40 }
41 // TODO
42 console.log("test"+prepro);
43 }
44
45
46 }
47
48 export let a = new Clo();
49 export default a;