update dependencies

This commit is contained in:
Philipp Kunz 2017-02-15 22:52:29 +01:00
parent 4031692f6f
commit b00d31b41a
20 changed files with 911 additions and 561 deletions

View File

@ -2,10 +2,10 @@
flexible task management. TypeScript ready! flexible task management. TypeScript ready!
## Availabililty ## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/taskbuffer) [![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/taskbuffer)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/taskbuffer) [![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/taskbuffer)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/taskbuffer) [![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/taskbuffer)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/taskbuffer/) [![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/taskbuffer/)
## Status for master ## Status for master
[![build status](https://GitLab.com/pushrocks/taskbuffer/badges/master/build.svg)](https://GitLab.com/pushrocks/taskbuffer/commits/master) [![build status](https://GitLab.com/pushrocks/taskbuffer/badges/master/build.svg)](https://GitLab.com/pushrocks/taskbuffer/commits/master)
@ -69,4 +69,8 @@ myTask = new taskbuffer.Task({
}) })
``` ```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

10
dist/index.d.ts vendored
View File

@ -1,5 +1,5 @@
export { Task, ITaskFunction } from "./taskbuffer.classes.task"; export { Task, ITaskFunction } from './taskbuffer.classes.task';
export { Taskchain } from "./taskbuffer.classes.taskchain"; export { Taskchain } from './taskbuffer.classes.taskchain';
export { Taskparallel } from "./taskbuffer.classes.taskparallel"; export { Taskparallel } from './taskbuffer.classes.taskparallel';
export { Taskspace } from "./taskbuffer.classes.taskspace"; export { Taskspace } from './taskbuffer.classes.taskspace';
import "./taskbuffer.classes.helpers"; import './taskbuffer.classes.helpers';

View File

@ -1,5 +1,5 @@
import plugins = require("./taskbuffer.plugins"); import plugins = require('./taskbuffer.plugins');
import { Task, ITaskFunction } from "./taskbuffer.classes.task"; import { Task, ITaskFunction } from './taskbuffer.classes.task';
export declare let emptyTaskFunction: ITaskFunction; export declare let emptyTaskFunction: ITaskFunction;
export declare let isTask: (taskArg: Task) => boolean; export declare let isTask: (taskArg: Task) => boolean;
export declare let isTaskTouched: (taskArg: Task, touchedTasksArray: Task[]) => boolean; export declare let isTaskTouched: (taskArg: Task, touchedTasksArray: Task[]) => boolean;

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import * as helpers from "./taskbuffer.classes.helpers"; import * as helpers from './taskbuffer.classes.helpers';
export interface ITaskFunction { export interface ITaskFunction {
(x?: any): PromiseLike<any>; (x?: any): PromiseLike<any>;
} }

View File

@ -8,8 +8,8 @@ class Task {
this.bufferRunner = new helpers.BufferRunner(this); this.bufferRunner = new helpers.BufferRunner(this);
this.cycleCounter = new helpers.CycleCounter(this); this.cycleCounter = new helpers.CycleCounter(this);
this.idle = true; this.idle = true;
this._state = "ready"; this._state = 'ready';
var options = optionsArg; let options = optionsArg;
this.taskFunction = optionsArg.taskFunction; this.taskFunction = optionsArg.taskFunction;
this.preTask = options.preTask; this.preTask = options.preTask;
this.afterTask = options.afterTask; this.afterTask = options.afterTask;
@ -47,13 +47,13 @@ class Task {
return this._state; return this._state;
} }
set state(stateArg) { set state(stateArg) {
if (stateArg == "locked") { if (stateArg === 'locked') {
this._state = "locked"; this._state = 'locked';
} }
else { else {
plugins.beautylog.error("state type " + stateArg + " could not be set"); plugins.beautylog.error('state type ' + stateArg + ' could not be set');
} }
} }
} }
exports.Task = Task; exports.Task = Task;
//# source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vRUMifQ==

View File

@ -1,4 +1,4 @@
import { Task } from "./taskbuffer.classes.task"; import { Task } from './taskbuffer.classes.task';
export declare class Taskchain extends Task { export declare class Taskchain extends Task {
taskArray: Task[]; taskArray: Task[];
private _oraObject; private _oraObject;

View File

@ -4,15 +4,15 @@ const taskbuffer_classes_task_1 = require("./taskbuffer.classes.task");
class Taskchain extends taskbuffer_classes_task_1.Task { class Taskchain extends taskbuffer_classes_task_1.Task {
constructor(optionsArg) { constructor(optionsArg) {
let options = plugins.lodash.merge({ let options = plugins.lodash.merge({
name: "unnamed Taskchain", name: 'unnamed Taskchain',
log: false log: false
}, optionsArg, { }, optionsArg, {
taskFunction: (x) => { taskFunction: (x) => {
let done = plugins.q.defer(); // this is the starting Deferred object let done = plugins.q.defer(); // this is the starting Deferred object
let taskCounter = 0; // counter for iterating async over the taskArray let taskCounter = 0; // counter for iterating async over the taskArray
let iterateTasks = (x) => { let iterateTasks = (x) => {
if (typeof this.taskArray[taskCounter] != "undefined") { if (typeof this.taskArray[taskCounter] !== 'undefined') {
this._oraObject.text(this.name + " running: Task" + this.taskArray[taskCounter].name); this._oraObject.text(this.name + ' running: Task' + this.taskArray[taskCounter].name);
this.taskArray[taskCounter].trigger(x) this.taskArray[taskCounter].trigger(x)
.then((x) => { .then((x) => {
plugins.beautylog.ok(this.taskArray[taskCounter].name); plugins.beautylog.ok(this.taskArray[taskCounter].name);
@ -21,7 +21,7 @@ class Taskchain extends taskbuffer_classes_task_1.Task {
}); });
} }
else { else {
this._oraObject.endOk("Taskchain \"" + this.name + "\" completed successfully"); this._oraObject.endOk('Taskchain "' + this.name + '" completed successfully');
done.resolve(x); done.resolve(x);
} }
}; };
@ -31,7 +31,7 @@ class Taskchain extends taskbuffer_classes_task_1.Task {
}); });
super(options); super(options);
this.taskArray = optionsArg.taskArray; this.taskArray = optionsArg.taskArray;
this._oraObject = new plugins.beautylog.Ora("Taskchain idle", "blue"); this._oraObject = plugins.beautylog.ora;
if (optionsArg.log === true) { if (optionsArg.log === true) {
this._oraObject.start(); this._oraObject.start();
} }
@ -50,5 +50,4 @@ class Taskchain extends taskbuffer_classes_task_1.Task {
; ;
} }
exports.Taskchain = Taskchain; exports.Taskchain = Taskchain;
; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGdEQUFnRDtBQUNoRCx1RUFBaUQ7QUFHakQsZUFBdUIsU0FBUSw4QkFBSTtJQUdqQyxZQUFZLFVBTVg7UUFDQyxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FDaEM7WUFDRSxJQUFJLEVBQUUsbUJBQW1CO1lBQ3pCLEdBQUcsRUFBRSxLQUFLO1NBQ1gsRUFDRCxVQUFVLEVBQ1Y7WUFDRSxZQUFZLEVBQUUsQ0FBQyxDQUFNO2dCQUNuQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFBLENBQUMsdUNBQXVDO2dCQUNwRSxJQUFJLFdBQVcsR0FBRyxDQUFDLENBQUEsQ0FBQyxpREFBaUQ7Z0JBQ3JFLElBQUksWUFBWSxHQUFHLENBQUMsQ0FBQztvQkFDbkIsRUFBRSxDQUFDLENBQUMsT0FBTyxJQUFJLENBQUMsU0FBUyxDQUFFLFdBQVcsQ0FBRSxLQUFLLFdBQVcsQ0FBQyxDQUFDLENBQUM7d0JBQ3pELElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLEdBQUcsZ0JBQWdCLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBRSxXQUFXLENBQU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sR0FBRyxJQUFJLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLGdCQUFnQixFQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQ3JFLEVBQUUsQ0FBQSxDQUFDLFVBQVUsQ0FBQyxHQUFHLEtBQUssSUFBSSxDQUFDLENBQUEsQ0FBQztZQUN4QixJQUFJLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxDQUFDO1FBQzVCLENBQUM7UUFBQSxDQUFDO0lBQ04sQ0FBQztJQUNELE9BQU8sQ0FBQyxPQUFZO1FBQ2hCLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ2pDLENBQUM7SUFBQSxDQUFDO0lBQ0YsVUFBVSxDQUFDLE9BQVk7UUFDbkIsTUFBTTtJQUNWLENBQUM7SUFBQSxDQUFDO0lBQ0YsU0FBUztJQUVULENBQUM7SUFBQSxDQUFDO0NBQ0w7QUF2REQsOEJBdURDO0FBQUEsQ0FBQyJ9

View File

@ -1,6 +1,6 @@
import "typings-global"; import 'typings-global';
import * as beautylog from "beautylog"; import * as beautylog from 'beautylog';
import * as lodash from "lodash"; import * as lodash from 'lodash';
import * as rxjs from "rxjs"; import * as rxjs from 'rxjs';
import * as q from 'smartq'; import * as q from 'smartq';
export { beautylog, lodash, rxjs, q }; export { beautylog, lodash, rxjs, q };

View File

@ -26,16 +26,15 @@
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme", "homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
"dependencies": { "dependencies": {
"@types/lodash": "4.x.x", "@types/lodash": "4.x.x",
"beautylog": "^6.0.0", "beautylog": "^6.1.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"q": "^1.4.1", "rxjs": "^5.1.1",
"rxjs": "^5.0.3", "smartq": "^1.1.1",
"smartq": "^1.0.2",
"typings-global": "^1.0.14" "typings-global": "^1.0.14"
}, },
"devDependencies": { "devDependencies": {
"npmts-g": "^6.0.0", "npmts-g": "^6.0.0",
"should": "^11.1.2", "smartchai": "^1.0.1",
"typings-test": "^1.0.3" "typings-test": "^1.0.3"
} }
} }

2
test/test.d.ts vendored
View File

@ -1 +1 @@
import "typings-test"; import 'typings-test';

File diff suppressed because one or more lines are too long

View File

@ -1,223 +1,223 @@
import "typings-test"; import 'typings-test'
import taskbuffer = require("../dist/index"); import taskbuffer = require('../dist/index')
import should = require("should"); import { expect } from 'smartchai'
import q = require("q") import * as q from 'smartq'
// setup some testData to work with // setup some testData to work with
let testTask: taskbuffer.Task; let testTask: taskbuffer.Task
let testTaskFunction = function () { let testTaskFunction = function () {
let done = q.defer(); let done = q.defer()
console.log("main function executed!") console.log('main function executed!')
done.resolve(); done.resolve()
return done.promise; return done.promise
}; }
let testTaskFunctionTimeout = function () { let testTaskFunctionTimeout = function () {
let done = q.defer(); let done = q.defer()
console.log("main function started!"); console.log('main function started!')
setTimeout(() => { setTimeout(() => {
console.log("main function ended!"); console.log('main function ended!')
done.resolve(); done.resolve()
},2000); }, 2000)
return done.promise; return done.promise
}; }
let testPreTask = new taskbuffer.Task({ let testPreTask = new taskbuffer.Task({
taskFunction: function () { taskFunction: function () {
let done = q.defer(); let done = q.defer()
console.log("preTask executed"); console.log('preTask executed')
done.resolve(); done.resolve()
return done.promise; return done.promise
}, },
preTask: testTask preTask: testTask
}); })
// some more tasks to wirj with // some more tasks to wirj with
let task1 = new taskbuffer.Task({ let task1 = new taskbuffer.Task({
name: "Task 1", name: 'Task 1',
taskFunction: () => { taskFunction: () => {
let done = q.defer(); let done = q.defer()
console.log("Task1 started"); console.log('Task1 started')
setTimeout(() => { setTimeout(() => {
console.log("Task1 executed"); console.log('Task1 executed')
done.resolve(); done.resolve()
}, 5000) }, 5000)
return done.promise; return done.promise
} }
}); })
let task2 = new taskbuffer.Task({ let task2 = new taskbuffer.Task({
name: "Task 1", name: 'Task 1',
taskFunction: () => { taskFunction: () => {
let done = q.defer(); let done = q.defer()
console.log("Task2 started"); console.log('Task2 started')
setTimeout(() => { setTimeout(() => {
console.log("Task2 executed"); console.log('Task2 executed')
done.resolve(); done.resolve()
}, 5000) }, 5000)
return done.promise; return done.promise
} }
}); })
let task3 = new taskbuffer.Task({ let task3 = new taskbuffer.Task({
name: "Task 3", name: 'Task 3',
taskFunction: () => { taskFunction: () => {
let done = q.defer(); let done = q.defer()
console.log("Task3 started"); console.log('Task3 started')
setTimeout(() => { setTimeout(() => {
console.log("Task3 executed"); console.log('Task3 executed')
done.resolve(); done.resolve()
}, 5000) }, 5000)
return done.promise; return done.promise
} }
}); })
// the actual tests // the actual tests
describe("taskbuffer", function () { describe('taskbuffer', function () {
describe(".Task", function () { describe('.Task', function () {
it("new Task() should return a new task", function () { it('new Task() should return a new task', function () {
testTask = new taskbuffer.Task({ taskFunction: testTaskFunction, preTask: testPreTask }); testTask = new taskbuffer.Task({ taskFunction: testTaskFunction, preTask: testPreTask })
}); })
it("testTask should be and instance of Task", function () { it('testTask should be and instance of Task', function () {
should(testTask).be.instanceof(taskbuffer.Task); expect(testTask).to.be.instanceof(taskbuffer.Task)
}); })
it("testTask.idle is true", function () { it('testTask.idle is true', function () {
if (!testTask.idle) { if (!testTask.idle) {
throw new Error("testTask.idle is not true"); throw new Error('testTask.idle is not true')
} }
}); })
it("testTask.running is type boolean and initially false", function () { it('testTask.running is type boolean and initially false', function () {
should(testTask.running).be.type("boolean"); expect(testTask.running).to.be.a('boolean')
should(testTask.running).be.false(); expect(testTask.running).to.be.false
}); })
it("testTask.trigger() should return Promise", function () { it('testTask.trigger() expect return Promise', function () {
should(testTask.trigger()).be.Promise(); expect(testTask.trigger()).to.be.instanceof(Promise)
}); })
it("testTask.trigger() returned Promise should be fullfilled", function (done) { it('testTask.trigger() returned Promise expect be fullfilled', function (done) {
testTask.trigger() testTask.trigger()
.then(done); .then(done)
}); })
it("should run a task without pre and afterTask", function (done) { it('expect run a task without pre and afterTask', function (done) {
let localTestTask = new taskbuffer.Task({ taskFunction: testTaskFunction }); let localTestTask = new taskbuffer.Task({ taskFunction: testTaskFunction })
localTestTask.trigger().then(done); localTestTask.trigger().then(done)
}); })
it("should run buffered", function (done) { it('expect run buffered', function (done) {
this.timeout(10000); this.timeout(10000)
let localTestTask = new taskbuffer.Task({ let localTestTask = new taskbuffer.Task({
taskFunction: testTaskFunctionTimeout, taskFunction: testTaskFunctionTimeout,
buffered: true, buffered: true,
bufferMax: 2 bufferMax: 2
});
localTestTask.trigger();
localTestTask.trigger();
localTestTask.trigger();
localTestTask.trigger().then(() => {
done();
}) })
}); localTestTask.trigger()
}); localTestTask.trigger()
describe("Taskchain", function () { localTestTask.trigger()
let testTaskchain; localTestTask.trigger().then(() => {
done()
})
})
})
describe('Taskchain', function () {
let testTaskchain
let testTaskArray = [ let testTaskArray = [
new taskbuffer.Task({ new taskbuffer.Task({
name: "task1", name: 'task1',
taskFunction: function () { taskFunction: function () {
let done = q.defer(); let done = q.defer()
setTimeout(done.resolve, 2000); setTimeout(done.resolve, 2000)
return done.promise; return done.promise
} }
}), }),
new taskbuffer.Task({ new taskbuffer.Task({
name: "task2", name: 'task2',
taskFunction: function () { taskFunction: function () {
let done = q.defer(); let done = q.defer()
setTimeout(done.resolve, 2000); setTimeout(done.resolve, 2000)
return done.promise; return done.promise
} }
}), })
]; ]
it("should run tasks in sequence", function (done) { it('expect run tasks in sequence', function (done) {
this.timeout(5000); this.timeout(5000)
testTaskchain = new taskbuffer.Taskchain({ testTaskchain = new taskbuffer.Taskchain({
name: "Taskchain1", name: 'Taskchain1',
taskArray: testTaskArray taskArray: testTaskArray
}); })
testTaskchain.trigger().then(done); testTaskchain.trigger().then(done)
}); })
}); })
describe("taskparallel", function () { describe('taskparallel', function () {
it("should run in Parallel", function (done) { it('expect run in Parallel', function (done) {
this.timeout(7000); this.timeout(7000)
let testTaskparallel = new taskbuffer.Taskparallel({ let testTaskparallel = new taskbuffer.Taskparallel({
taskArray: [ task1, task2, task3 ] taskArray: [ task1, task2, task3 ]
});
testTaskparallel.trigger().then(() => {
done();
});
}) })
}); testTaskparallel.trigger().then(() => {
describe("some flowtests",function(){ done()
})
})
})
describe('some flowtests', function () {
let flowTask1 = new taskbuffer.Task({ let flowTask1 = new taskbuffer.Task({
taskFunction: (x: number) => { taskFunction: (x: number) => {
let done = q.defer(); let done = q.defer()
console.log("flowTask1"); console.log('flowTask1')
console.log(x); console.log(x)
done.resolve(x); done.resolve(x)
return done.promise; return done.promise
} }
}); })
let flowTaskBuffered = new taskbuffer.Task({ let flowTaskBuffered = new taskbuffer.Task({
taskFunction: (x: number) => { taskFunction: (x: number) => {
let done = q.defer(); let done = q.defer()
console.log("flowTask1"); console.log('flowTask1')
console.log(x); console.log(x)
done.resolve(x); done.resolve(x)
return done.promise; return done.promise
}, },
buffered: true, buffered: true,
bufferMax: 1 bufferMax: 1
}); })
let flowTask2 = new taskbuffer.Task({ let flowTask2 = new taskbuffer.Task({
taskFunction: (x: number) => { taskFunction: (x: number) => {
let done = q.defer(); let done = q.defer()
console.log("flowTask2"); console.log('flowTask2')
console.log(x); console.log(x)
done.resolve(x); done.resolve(x)
return done.promise; return done.promise
}, },
preTask: flowTask1 preTask: flowTask1
}); })
let flowTask3 = new taskbuffer.Taskchain({ let flowTask3 = new taskbuffer.Taskchain({
taskArray: [ flowTask1, flowTask2 ] taskArray: [ flowTask1, flowTask2 ]
});
it("should let a value flow through a task",function(done){
flowTask1.trigger(12).then((x) => {
should.equal(x,12);
done();
}).catch(done);
});
it("should let a values flow between tasks",function(done){
flowTask2.trigger(12).then((x) => {
should.equal(x,12);
done();
}).catch(done);
});
it("should let a values flow between tasks when buffered",function(done){
flowTaskBuffered.trigger(12).then((x) => {
should.equal(x,12);
done();
}).catch(done);
});
it("should let a values flow between tasks in Taskchain",function(done){
flowTask3.trigger(12).then((x) => {
should.equal(x,12);
done();
}).catch(done);
});
}) })
}); it('should let a value flow through a task', function (done) {
flowTask1.trigger(12).then((x) => {
expect(x).to.equal(12)
done()
}).catch(done)
})
it('should let a values flow between tasks', function (done) {
flowTask2.trigger(12).then((x) => {
expect(x).to.equal(12)
done()
}).catch(done)
})
it('expect let a values flow between tasks when buffered', function (done) {
flowTaskBuffered.trigger(12).then((x) => {
expect(x).to.equal(12)
done()
}).catch(done)
})
it('should let a values flow between tasks in Taskchain', function (done) {
flowTask3.trigger(12).then((x) => {
expect(x).to.equal(12)
done()
}).catch(done)
})
})
})

View File

@ -1,7 +1,7 @@
export {Task,ITaskFunction} from "./taskbuffer.classes.task"; export {Task,ITaskFunction} from './taskbuffer.classes.task';
export {Taskchain} from "./taskbuffer.classes.taskchain"; export {Taskchain} from './taskbuffer.classes.taskchain';
export {Taskparallel} from "./taskbuffer.classes.taskparallel"; export {Taskparallel} from './taskbuffer.classes.taskparallel';
export {Taskspace} from "./taskbuffer.classes.taskspace"; export {Taskspace} from './taskbuffer.classes.taskspace';
// import for naming only // import for naming only
import "./taskbuffer.classes.helpers" import './taskbuffer.classes.helpers'

View File

@ -1,83 +1,83 @@
import plugins = require("./taskbuffer.plugins"); import plugins = require('./taskbuffer.plugins');
import { Task, ITaskFunction } from "./taskbuffer.classes.task"; import { Task, ITaskFunction } from './taskbuffer.classes.task'
export let emptyTaskFunction: ITaskFunction = function (x) { export let emptyTaskFunction: ITaskFunction = function (x) {
let done = plugins.q.defer(); let done = plugins.q.defer()
done.resolve(); done.resolve()
return done.promise; return done.promise
}; }
export let isTask = function (taskArg: Task): boolean { export let isTask = function (taskArg: Task): boolean {
if ( if (
taskArg instanceof Task taskArg instanceof Task
&& typeof taskArg.taskFunction === "function" && typeof taskArg.taskFunction === 'function'
) { ) {
return true; return true
} else { } else {
return false; return false
}
} }
};
export let isTaskTouched = (taskArg: Task, touchedTasksArray: Task[]): boolean => { export let isTaskTouched = (taskArg: Task, touchedTasksArray: Task[]): boolean => {
let result = false; let result = false
for (let keyArg in touchedTasksArray) { for (let keyArg in touchedTasksArray) {
if (taskArg === touchedTasksArray[ keyArg ]) { if (taskArg === touchedTasksArray[ keyArg ]) {
result = true; result = true
} }
} }
return result; return result
} }
export let runTask = function (taskArg: Task, optionsArg: { x?, touchedTasksArray?: Task[] }) { export let runTask = function (taskArg: Task, optionsArg: { x?, touchedTasksArray?: Task[] }) {
let done = plugins.q.defer(); let done = plugins.q.defer()
// set running params // set running params
taskArg.running = true; taskArg.running = true
done.promise.then(function () { taskArg.running = false }); done.promise.then(function () { taskArg.running = false })
// handle options // handle options
let options = plugins.lodash.merge( let options = plugins.lodash.merge(
{ x: undefined, touchedTasksArray: [] }, { x: undefined, touchedTasksArray: [] },
optionsArg optionsArg
) )
let x = options.x; let x = options.x
let touchedTasksArray: Task[] = options.touchedTasksArray; let touchedTasksArray: Task[] = options.touchedTasksArray
touchedTasksArray.push(taskArg); touchedTasksArray.push(taskArg)
// run the task cascade // run the task cascade
let localDeferred = plugins.q.defer(); let localDeferred = plugins.q.defer()
localDeferred.promise localDeferred.promise
.then(() => { .then(() => {
if (taskArg.preTask && !isTaskTouched(taskArg.preTask, touchedTasksArray)) { if (taskArg.preTask && !isTaskTouched(taskArg.preTask, touchedTasksArray)) {
return runTask(taskArg.preTask, { x: x, touchedTasksArray: touchedTasksArray }) return runTask(taskArg.preTask, { x: x, touchedTasksArray: touchedTasksArray })
} else { } else {
let done2 = plugins.q.defer(); let done2 = plugins.q.defer()
done2.resolve(x); done2.resolve(x)
return done2.promise; return done2.promise
} }
}) })
.then(x => { .then(x => {
return taskArg.taskFunction(x); return taskArg.taskFunction(x)
}) })
.then(x => { .then(x => {
if (taskArg.afterTask && !isTaskTouched(taskArg.afterTask, touchedTasksArray)) { if (taskArg.afterTask && !isTaskTouched(taskArg.afterTask, touchedTasksArray)) {
return runTask(taskArg.afterTask, {x:x, touchedTasksArray: touchedTasksArray }); return runTask(taskArg.afterTask, { x: x, touchedTasksArray: touchedTasksArray })
} else { } else {
let done2 = plugins.q.defer(); let done2 = plugins.q.defer()
done2.resolve(x); done2.resolve(x)
return done2.promise; return done2.promise
} }
}) })
.then(x => { .then(x => {
done.resolve(x); done.resolve(x)
}).catch((err) => { }).catch((err) => {
console.log(err); console.log(err)
}); })
localDeferred.resolve(); localDeferred.resolve()
return done.promise; return done.promise
}; }
export interface cycleObject { export interface cycleObject {
@ -86,72 +86,72 @@ export interface cycleObject {
} }
export class CycleCounter { export class CycleCounter {
task:Task; task: Task
cycleObjectArray:cycleObject[] = []; cycleObjectArray: cycleObject[] = []
constructor(taskArg: Task) { constructor(taskArg: Task) {
this.task = taskArg; this.task = taskArg
}; };
getPromiseForCycle(cycleCountArg: number) { getPromiseForCycle(cycleCountArg: number) {
let done = plugins.q.defer(); let done = plugins.q.defer()
let cycleObject: cycleObject = { let cycleObject: cycleObject = {
cycleCounter: cycleCountArg, cycleCounter: cycleCountArg,
deferred: done deferred: done
}; }
this.cycleObjectArray.push(cycleObject); this.cycleObjectArray.push(cycleObject)
return done.promise; return done.promise
}; };
informOfCycle(x) { informOfCycle(x) {
let newCycleObjectArray:cycleObject[] = []; let newCycleObjectArray: cycleObject[] = []
this.cycleObjectArray.forEach(cycleObjectArg => { this.cycleObjectArray.forEach(cycleObjectArg => {
cycleObjectArg.cycleCounter--; cycleObjectArg.cycleCounter--
if (cycleObjectArg.cycleCounter <= 0) { if (cycleObjectArg.cycleCounter <= 0) {
cycleObjectArg.deferred.resolve(x); cycleObjectArg.deferred.resolve(x)
} else { } else {
newCycleObjectArray.push(cycleObjectArg); newCycleObjectArray.push(cycleObjectArg)
}; };
}); })
this.cycleObjectArray = newCycleObjectArray; this.cycleObjectArray = newCycleObjectArray
} }
} }
export class BufferRunner { export class BufferRunner {
task:Task; task: Task
// initialze by default // initialze by default
bufferCounter:number = 0; bufferCounter: number = 0
bufferMax:number = 1; bufferMax: number = 1
running:boolean = false; running: boolean = false
constructor(taskArg: Task) { constructor(taskArg: Task) {
this.task = taskArg; this.task = taskArg
}; };
private _run(x) { private _run(x) {
let recursiveBufferRunner = (x) => { let recursiveBufferRunner = (x) => {
if (this.bufferCounter >= 0) { if (this.bufferCounter >= 0) {
this.running = true; this.running = true
this.task.running = true; this.task.running = true
runTask(this.task, { x: x }) runTask(this.task, { x: x })
.then((x) => { .then((x) => {
this.bufferCounter--; this.bufferCounter--
this.task.cycleCounter.informOfCycle(x); this.task.cycleCounter.informOfCycle(x)
recursiveBufferRunner(x); recursiveBufferRunner(x)
}); })
} else { } else {
this.running = false; this.running = false
this.task.running = false; this.task.running = false
} }
}; }
recursiveBufferRunner(x); recursiveBufferRunner(x)
}; };
setBufferMax(bufferMaxArg: number) { setBufferMax(bufferMaxArg: number) {
this.bufferMax = bufferMaxArg; this.bufferMax = bufferMaxArg
}; };
trigger(x): Promise<any> { trigger(x): Promise<any> {
if (!(this.bufferCounter >= this.bufferMax)) { if (!(this.bufferCounter >= this.bufferMax)) {
this.bufferCounter++ this.bufferCounter++
}; };
let returnPromise:Promise<any> = this.task.cycleCounter.getPromiseForCycle(this.bufferCounter + 1); let returnPromise: Promise<any> = this.task.cycleCounter.getPromiseForCycle(this.bufferCounter + 1)
if (!this.running) { if (!this.running) {
this._run(x); this._run(x)
} }
return returnPromise; return returnPromise
}; };
}; };

View File

@ -1,5 +1,5 @@
import * as plugins from "./taskbuffer.plugins" import * as plugins from './taskbuffer.plugins'
import * as helpers from "./taskbuffer.classes.helpers" import * as helpers from './taskbuffer.classes.helpers'
export interface ITaskFunction { export interface ITaskFunction {
(x?: any): PromiseLike<any>; (x?: any): PromiseLike<any>;
@ -7,17 +7,17 @@ export interface ITaskFunction {
export class Task { export class Task {
name: string; name: string;
taskFunction:ITaskFunction; taskFunction: ITaskFunction
buffered:boolean; buffered: boolean
preTask:Task; preTask: Task
afterTask:Task; afterTask: Task
// initialize by default // initialize by default
running:boolean = false; running: boolean = false
bufferRunner = new helpers.BufferRunner(this); bufferRunner = new helpers.BufferRunner(this)
cycleCounter = new helpers.CycleCounter(this); cycleCounter = new helpers.CycleCounter(this)
idle:boolean = true; idle: boolean = true
private _state:string = "ready"; private _state: string = 'ready'
constructor(optionsArg: { constructor(optionsArg: {
taskFunction: ITaskFunction, taskFunction: ITaskFunction,
@ -27,14 +27,14 @@ export class Task {
bufferMax?: number, bufferMax?: number,
name?: string name?: string
}) { }) {
var options = optionsArg; let options = optionsArg
this.taskFunction = optionsArg.taskFunction; this.taskFunction = optionsArg.taskFunction
this.preTask = options.preTask; this.preTask = options.preTask
this.afterTask = options.afterTask; this.afterTask = options.afterTask
this.idle = !this.running; this.idle = !this.running
this.buffered = options.buffered; this.buffered = options.buffered
this.bufferRunner.setBufferMax(options.bufferMax); this.bufferRunner.setBufferMax(options.bufferMax)
this.name = options.name; this.name = options.name
} }
/** /**
@ -45,7 +45,7 @@ export class Task {
return this.triggerBuffered(x) return this.triggerBuffered(x)
} }
else { else {
return this.triggerUnBuffered(x); return this.triggerUnBuffered(x)
}; };
}; };
@ -53,24 +53,24 @@ export class Task {
* trigger task unbuffered. * trigger task unbuffered.
*/ */
triggerUnBuffered(x?): Promise<any> { triggerUnBuffered(x?): Promise<any> {
return helpers.runTask(this,{x:x}); return helpers.runTask(this, { x: x })
} }
/** /**
* trigger task buffered. * trigger task buffered.
*/ */
triggerBuffered(x?): Promise<any> { triggerBuffered(x?): Promise<any> {
return this.bufferRunner.trigger(x); return this.bufferRunner.trigger(x)
} }
get state(): string { get state(): string {
return this._state; return this._state
} }
set state(stateArg: string) { set state(stateArg: string) {
if (stateArg == "locked"){ if (stateArg === 'locked') {
this._state = "locked"; this._state = 'locked'
} else { } else {
plugins.beautylog.error("state type " + stateArg + " could not be set"); plugins.beautylog.error('state type ' + stateArg + ' could not be set')
} }
} }
} }

View File

@ -1,10 +1,10 @@
import * as plugins from "./taskbuffer.plugins"; import * as plugins from './taskbuffer.plugins';
import {Task} from "./taskbuffer.classes.task"; import { Task } from './taskbuffer.classes.task';
import helpers = require("./taskbuffer.classes.helpers"); import helpers = require('./taskbuffer.classes.helpers');
export class Taskchain extends Task { export class Taskchain extends Task {
taskArray:Task[]; taskArray: Task[]
private _oraObject:plugins.beautylog.Ora; private _oraObject
constructor(optionsArg: { constructor(optionsArg: {
taskArray: Task[], taskArray: Task[],
name?: string, name?: string,
@ -14,42 +14,42 @@ export class Taskchain extends Task {
}) { }) {
let options = plugins.lodash.merge( let options = plugins.lodash.merge(
{ {
name:"unnamed Taskchain", name: 'unnamed Taskchain',
log: false log: false
}, },
optionsArg, optionsArg,
{ {
taskFunction: (x: any) => { // this is the function that gets executed when TaskChain is triggered taskFunction: (x: any) => { // this is the function that gets executed when TaskChain is triggered
let done = plugins.q.defer(); // this is the starting Deferred object let done = plugins.q.defer() // this is the starting Deferred object
let taskCounter = 0; // counter for iterating async over the taskArray let taskCounter = 0 // counter for iterating async over the taskArray
let iterateTasks = (x) => { let iterateTasks = (x) => {
if(typeof this.taskArray[taskCounter] != "undefined"){ if (typeof this.taskArray[ taskCounter ] !== 'undefined') {
this._oraObject.text(this.name + " running: Task" + this.taskArray[taskCounter].name); this._oraObject.text(this.name + ' running: Task' + this.taskArray[ taskCounter ].name)
this.taskArray[ taskCounter ].trigger(x) this.taskArray[ taskCounter ].trigger(x)
.then((x) => { .then((x) => {
plugins.beautylog.ok(this.taskArray[taskCounter].name); plugins.beautylog.ok(this.taskArray[ taskCounter ].name)
taskCounter++; taskCounter++
iterateTasks(x); iterateTasks(x)
}); })
} else { } else {
this._oraObject.endOk("Taskchain \"" + this.name + "\" completed successfully"); this._oraObject.endOk('Taskchain "' + this.name + '" completed successfully')
done.resolve(x); done.resolve(x)
}
};
iterateTasks(x);
return done.promise;
} }
} }
); iterateTasks(x)
super(options); return done.promise
this.taskArray = optionsArg.taskArray; }
this._oraObject = new plugins.beautylog.Ora("Taskchain idle","blue"); }
)
super(options)
this.taskArray = optionsArg.taskArray
this._oraObject = plugins.beautylog.ora
if (optionsArg.log === true) { if (optionsArg.log === true) {
this._oraObject.start(); this._oraObject.start()
}; };
} }
addTask(taskArg: Task) { addTask(taskArg: Task) {
this.taskArray.push(taskArg); this.taskArray.push(taskArg)
}; };
removeTask(taskArg: Task) { removeTask(taskArg: Task) {
// TODO // TODO
@ -57,4 +57,4 @@ export class Taskchain extends Task {
shiftTask() { shiftTask() {
}; };
}; }

View File

@ -1,7 +1,7 @@
import "typings-global" import 'typings-global'
import * as beautylog from "beautylog" import * as beautylog from 'beautylog'
import * as lodash from "lodash" import * as lodash from 'lodash'
import * as rxjs from "rxjs" import * as rxjs from 'rxjs'
import * as q from 'smartq' import * as q from 'smartq'
export { export {

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}

345
yarn.lock Normal file
View File

@ -0,0 +1,345 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/chai-as-promised@0.0.29":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-0.0.29.tgz#43d52892aa998e185a3de3e2477edb8573be1d77"
dependencies:
"@types/chai" "*"
"@types/promises-a-plus" "*"
"@types/chai@*", "@types/chai@^3.4.34":
version "3.4.34"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.4.34.tgz#d5335792823bb09cddd5e38c3d211b709183854d"
"@types/lodash@4.x.x":
version "4.14.52"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.52.tgz#de5c7ab14da1289733233c9b0ec6f9e377db90f5"
"@types/mocha@^2.2.31":
version "2.2.39"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.39.tgz#f68d63db8b69c38e9558b4073525cf96c4f7a829"
"@types/node@*":
version "7.0.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.5.tgz#96a0f0a618b7b606f1ec547403c00650210bfbb7"
"@types/promises-a-plus@*":
version "0.0.27"
resolved "https://registry.yarnpkg.com/@types/promises-a-plus/-/promises-a-plus-0.0.27.tgz#c64651134614c84b8f5d7114ce8901d36a609780"
"@types/q@0.x.x":
version "0.0.32"
resolved "https://registry.yarnpkg.com/@types/q/-/q-0.0.32.tgz#bd284e57c84f1325da702babfc82a5328190c0c5"
"@types/shelljs@^0.3.33":
version "0.3.33"
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.3.33.tgz#df613bddb88225ed09ce5c835f620dcaaf155e6b"
dependencies:
"@types/node" "*"
ansi-256-colors@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz#910de50efcc7c09e3d82f2f87abd6b700c18818a"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
assertion-error@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
beautycolor@^1.0.5:
version "1.0.7"
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.7.tgz#a4715738ac4c8221371e9cbeb5a6cc6d11ecbf7c"
dependencies:
ansi-256-colors "^1.1.0"
typings-global "^1.0.14"
beautylog@^6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/beautylog/-/beautylog-6.1.1.tgz#2a83603ad7e2a0a09701ac63d7d3064a588dc779"
dependencies:
"@types/lodash" "4.x.x"
beautycolor "^1.0.5"
figlet "^1.2.0"
lodash "^4.17.4"
ora "^1.1.0"
smartenv "^2.0.0"
smartq "^1.0.4"
typings-global "^1.0.14"
brace-expansion@^1.0.0:
version "1.1.6"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9"
dependencies:
balanced-match "^0.4.1"
concat-map "0.0.1"
chai-as-promised@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-6.0.0.tgz#1a02a433a6f24dafac63b9c96fa1684db1aa8da6"
dependencies:
check-error "^1.0.2"
chai@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247"
dependencies:
assertion-error "^1.0.1"
deep-eql "^0.1.3"
type-detect "^1.0.0"
chalk@^1.0.0, chalk@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
dependencies:
ansi-styles "^2.2.1"
escape-string-regexp "^1.0.2"
has-ansi "^2.0.0"
strip-ansi "^3.0.0"
supports-color "^2.0.0"
check-error@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
dependencies:
restore-cursor "^2.0.0"
cli-spinners@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.0.0.tgz#ef987ed3d48391ac3dab9180b406a742180d6e6a"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
deep-eql@^0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2"
dependencies:
type-detect "0.1.1"
escape-string-regexp@^1.0.2:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
figlet@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/figlet/-/figlet-1.2.0.tgz#6c46537378fab649146b5a6143dda019b430b410"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
glob@^7.0.0:
version "7.1.1"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.2"
once "^1.3.0"
path-is-absolute "^1.0.0"
has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
dependencies:
ansi-regex "^2.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
interpret@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c"
lodash@^4.17.2, lodash@^4.17.4:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
log-symbols@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18"
dependencies:
chalk "^1.0.0"
mimic-fn@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"
minimatch@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
dependencies:
brace-expansion "^1.0.0"
npmts-g@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/npmts-g/-/npmts-g-6.0.0.tgz#491fd50f110967f1b68f14237e7ea5157bf4ddb3"
dependencies:
"@types/shelljs" "^0.3.33"
semver "^5.3.0"
shelljs "^0.7.5"
typings-global "^1.0.14"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"
onetime@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.0.tgz#52aa8110e52fc5126ffc667bd8ec21c2ed209ce6"
dependencies:
mimic-fn "^1.0.0"
ora@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ora/-/ora-1.1.0.tgz#69aaa4a209630e43b142c5f7ff41820da87e2faf"
dependencies:
chalk "^1.1.1"
cli-cursor "^2.1.0"
cli-spinners "^1.0.0"
log-symbols "^1.0.2"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
q@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e"
rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
dependencies:
resolve "^1.1.6"
resolve@^1.1.6:
version "1.2.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c"
restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
dependencies:
onetime "^2.0.0"
signal-exit "^3.0.2"
rxjs@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.1.1.tgz#fc48922965bc6c5efbcc0fe46e90a3af64137a7b"
dependencies:
symbol-observable "^1.0.1"
semver@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
shelljs@^0.7.4, shelljs@^0.7.5:
version "0.7.6"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.6.tgz#379cccfb56b91c8601e4793356eb5382924de9ad"
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"
signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
smartchai@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.1.tgz#cde7776212fa5145d62dc4195405929807a3e0e5"
dependencies:
"@types/chai" "^3.4.34"
"@types/chai-as-promised" "0.0.29"
chai "^3.5.0"
chai-as-promised "^6.0.0"
smartenv@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/smartenv/-/smartenv-2.0.0.tgz#ede4e2044efcf9bec318388bb1dab53024ee3d16"
dependencies:
"@types/q" "0.x.x"
lodash "^4.17.2"
q "^1.4.1"
typings-global "^1.0.14"
smartq@^1.0.4, smartq@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.1.tgz#efb358705260d41ae18aef7ffd815f7b6fe17dd3"
dependencies:
typed-promisify "^0.3.0"
typings-global "^1.0.14"
strip-ansi@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
dependencies:
ansi-regex "^2.0.0"
supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
symbol-observable@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
type-detect@0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"
type-detect@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
typed-promisify@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/typed-promisify/-/typed-promisify-0.3.0.tgz#1ba0af5e444c87d8047406f18ce49092a1191853"
typings-global@*, typings-global@^1.0.14:
version "1.0.14"
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.14.tgz#ab682720a03d6b9278869fb5c30c30d7dc61d12c"
dependencies:
semver "^5.3.0"
shelljs "^0.7.4"
typings-test@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/typings-test/-/typings-test-1.0.3.tgz#fbab895eb3f0c44842e73db059f65946b971e369"
dependencies:
"@types/mocha" "^2.2.31"
typings-global "*"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"