]> git.kianting.info Git - clo/blobdiff - src/libclo/index.ts
add clo library initially with register of prepocessor
[clo] / src / libclo / index.ts
diff --git a/src/libclo/index.ts b/src/libclo/index.ts
new file mode 100644 (file)
index 0000000..b83b050
--- /dev/null
@@ -0,0 +1,49 @@
+import {tkTree} from "../parser";
+
+
+function foo(arr : tkTree): tkTree{
+    for (let i = 0; i < arr.length; i++) {
+        
+    }
+    if (Array.isArray(arr)){
+        arr.push("balabala");
+    }
+    return arr;
+}
+
+export class Clo{
+    mainStream : Array<string>;
+    preprocessors : Array<Function>;
+    attributes: object ; // a4 size(x,y)
+
+    
+    constructor(){
+        this.preprocessors = [];
+        this.mainStream = [];
+        this.attributes = {"page" : [793.7, 1122.5]};
+        this.preprocessorRegister(foo);
+    }
+
+    /**
+     * register a function of preprocessor
+     * @param f a function
+     */
+    public preprocessorRegister(f : Function){
+        this.preprocessors.push(f);
+    }
+
+    public generatePdf(){
+        // preprocessed
+        var prepro = this.mainStream;
+        for (var i = 0; i<this.preprocessors.length; i++){
+            prepro = this.preprocessors[i](prepro);
+        }
+        // TODO
+        console.log("test"+prepro);
+    }
+
+    
+}
+
+export let a = new Clo();
+export default a;
\ No newline at end of file