update structure for better ES6 support
This commit is contained in:
parent
71c883609b
commit
771539dae3
10
ts/index.ts
10
ts/index.ts
@ -1,10 +1,2 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./taskbuffer.plugins");
|
||||
import task = require("./taskbuffer.task");
|
||||
import taskchain = require("./taskbuffer.taskchain");
|
||||
|
||||
var taskbuffer = {
|
||||
task: task
|
||||
};
|
||||
|
||||
export = taskbuffer;
|
||||
export * from "./taskbuffer.classes"
|
52
ts/taskbuffer.classes.task.ts
Normal file
52
ts/taskbuffer.classes.task.ts
Normal file
@ -0,0 +1,52 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import * as plugins from "./taskbuffer.plugins"
|
||||
import * as helpers from "./taskbuffer.classes.helpers"
|
||||
|
||||
export class Task {
|
||||
task:any;
|
||||
idle:boolean;
|
||||
running:boolean;
|
||||
buffered:boolean;
|
||||
private _counterBufferRelative;
|
||||
private _counterTriggerAbsolute;
|
||||
private _state:string;
|
||||
preTask:Task;
|
||||
afterTask:Task;
|
||||
|
||||
constructor(taskArg,optionsArg:{preTask?:Task,afterTask?:Task, buffered?:boolean} = {}){
|
||||
var options = optionsArg;
|
||||
this.task = taskArg;
|
||||
this.preTask = options.preTask;
|
||||
this.afterTask = options.afterTask;
|
||||
this.idle = true;
|
||||
this.running = false;
|
||||
if (typeof options.buffered === "boolean"){
|
||||
this.buffered = options.buffered;
|
||||
} else {
|
||||
this.buffered = false;
|
||||
}
|
||||
}
|
||||
trigger(){
|
||||
helpers.runTask(this.preTask)
|
||||
.then(function(){
|
||||
|
||||
})
|
||||
.then(function(){
|
||||
|
||||
})
|
||||
};
|
||||
triggerBuffered(){
|
||||
var done = plugins.Q.defer();
|
||||
}
|
||||
|
||||
get state():string {
|
||||
return this._state;
|
||||
}
|
||||
set state(stateArg:string){
|
||||
if (stateArg == "locked"){
|
||||
this._state = "locked";
|
||||
} else {
|
||||
plugins.beautylog.error("state type" );
|
||||
}
|
||||
}
|
||||
}
|
12
ts/taskbuffer.classes.taskchain.ts
Normal file
12
ts/taskbuffer.classes.taskchain.ts
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
import helpers = require("./taskbuffer.classes.helpers");
|
||||
import * as classes from "./taskbuffer.classes"
|
||||
|
||||
|
||||
export class Taskchain extends classes.Task {
|
||||
constructor(taskArrayArg:classes.Task[]){
|
||||
super({
|
||||
task: function(){}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,60 +1,2 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./taskbuffer.plugins");
|
||||
import helpers = require("./taskbuffer.classes.helpers");
|
||||
export class Task {
|
||||
task:any;
|
||||
idle:boolean;
|
||||
running:boolean;
|
||||
buffered:boolean;
|
||||
private _counterBufferRelative;
|
||||
private _counterTriggerAbsolute;
|
||||
private _state:string;
|
||||
preTask:Task;
|
||||
afterTask:Task;
|
||||
|
||||
constructor(taskArg,optionsArg:{preTask?:Task,afterTask?:Task, buffered?:boolean} = {}){
|
||||
var options = optionsArg;
|
||||
this.task = taskArg;
|
||||
this.preTask = options.preTask;
|
||||
this.afterTask = options.afterTask;
|
||||
this.idle = true;
|
||||
this.running = false;
|
||||
if (typeof options.buffered === "boolean"){
|
||||
this.buffered = options.buffered;
|
||||
} else {
|
||||
this.buffered = false;
|
||||
}
|
||||
}
|
||||
trigger(){
|
||||
helpers.runTask(this.preTask)
|
||||
.then(function(){
|
||||
|
||||
})
|
||||
.then(function(){
|
||||
|
||||
})
|
||||
};
|
||||
triggerBuffered(){
|
||||
var done = plugins.Q.defer();
|
||||
}
|
||||
|
||||
get state():string {
|
||||
return this._state;
|
||||
}
|
||||
set state(stateArg:string){
|
||||
if (stateArg == "locked"){
|
||||
this._state = "locked";
|
||||
} else {
|
||||
plugins.beautylog.error("state type" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class TaskChain extends Task {
|
||||
constructor(taskArrayArg:Task[]){
|
||||
super({
|
||||
task: function(){}
|
||||
});
|
||||
}
|
||||
}
|
||||
export * from "./taskbuffer.classes.task"
|
||||
export * from "./taskbuffer.classes.taskchain"
|
@ -1 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
@ -1,7 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import classes = require("./taskbuffer.classes");
|
||||
var task = function(taskArg,options?){
|
||||
var task = taskArg
|
||||
return new classes.Task(task,options);
|
||||
};
|
||||
export = task;
|
@ -1,7 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import classes = require("./taskbuffer.classes");
|
||||
var taskChain = function(taskArrayArg:classes.Task[]){
|
||||
|
||||
return new classes.TaskChain(taskArrayArg);
|
||||
};
|
||||
export = taskChain;
|
Loading…
Reference in New Issue
Block a user