Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
017c0789ca | |||
6e6d056617 | |||
3f7f38ee17 | |||
5bfc72a602 | |||
ca8882962e | |||
df6bf2c681 | |||
310a683e14 | |||
3f275ebc08 |
2
dist/taskbuffer.classes.helpers.d.ts
vendored
2
dist/taskbuffer.classes.helpers.d.ts
vendored
@ -21,10 +21,8 @@ export declare class CycleCounter {
|
||||
export declare class BufferRunner {
|
||||
task: Task;
|
||||
bufferCounter: number;
|
||||
bufferMax: number;
|
||||
running: boolean;
|
||||
constructor(taskArg: Task);
|
||||
setBufferMax(bufferMaxArg: number): void;
|
||||
trigger(x: any): Promise<any>;
|
||||
private _run(x);
|
||||
}
|
||||
|
28
dist/taskbuffer.classes.helpers.js
vendored
28
dist/taskbuffer.classes.helpers.js
vendored
File diff suppressed because one or more lines are too long
25
dist/taskbuffer.classes.task.d.ts
vendored
25
dist/taskbuffer.classes.task.d.ts
vendored
@ -6,6 +6,8 @@ export declare class Task {
|
||||
name: string;
|
||||
taskFunction: ITaskFunction;
|
||||
buffered: boolean;
|
||||
bufferMax: number;
|
||||
execDelay: number;
|
||||
preTask: Task;
|
||||
afterTask: Task;
|
||||
running: boolean;
|
||||
@ -14,11 +16,34 @@ export declare class Task {
|
||||
idle: boolean;
|
||||
private _state;
|
||||
constructor(optionsArg: {
|
||||
/**
|
||||
* the task function to run, must return promise
|
||||
*/
|
||||
taskFunction: ITaskFunction;
|
||||
/**
|
||||
* any other task to run before
|
||||
*/
|
||||
preTask?: Task;
|
||||
/**
|
||||
* any other task to run after
|
||||
*/
|
||||
afterTask?: Task;
|
||||
/**
|
||||
* wether this task should run buffered
|
||||
*/
|
||||
buffered?: boolean;
|
||||
/**
|
||||
* the maximum buffer
|
||||
*/
|
||||
bufferMax?: number;
|
||||
/**
|
||||
* the execution delay, before the task is executed
|
||||
* only makes sense when running in buffered mode
|
||||
*/
|
||||
execDelay?: number;
|
||||
/**
|
||||
* the name of the task
|
||||
*/
|
||||
name?: string;
|
||||
});
|
||||
/**
|
||||
|
14
dist/taskbuffer.classes.task.js
vendored
14
dist/taskbuffer.classes.task.js
vendored
@ -10,14 +10,14 @@ class Task {
|
||||
this.cycleCounter = new helpers.CycleCounter(this);
|
||||
this.idle = true;
|
||||
this._state = 'ready';
|
||||
let options = optionsArg;
|
||||
this.taskFunction = optionsArg.taskFunction;
|
||||
this.preTask = options.preTask;
|
||||
this.afterTask = options.afterTask;
|
||||
this.preTask = optionsArg.preTask;
|
||||
this.afterTask = optionsArg.afterTask;
|
||||
this.idle = !this.running;
|
||||
this.buffered = options.buffered;
|
||||
this.bufferRunner.setBufferMax(options.bufferMax);
|
||||
this.name = options.name;
|
||||
this.buffered = optionsArg.buffered;
|
||||
this.bufferMax = optionsArg.bufferMax;
|
||||
this.execDelay = optionsArg.execDelay;
|
||||
this.name = optionsArg.name;
|
||||
}
|
||||
/**
|
||||
* trigger the task. Will trigger buffered if this.buffered is true
|
||||
@ -55,4 +55,4 @@ class Task {
|
||||
}
|
||||
}
|
||||
exports.Task = Task;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90YXNrYnVmZmVyLmNsYXNzZXMudGFzay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGdEQUErQztBQUMvQyx3REFBdUQ7QUFNdkQ7SUFjRSxZQUFhLFVBT1o7UUFkRCx3QkFBd0I7UUFDeEIsWUFBTyxHQUFZLEtBQUssQ0FBQTtRQUN4QixpQkFBWSxHQUFHLElBQUksT0FBTyxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUM3QyxpQkFBWSxHQUFHLElBQUksT0FBTyxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUM3QyxTQUFJLEdBQVksSUFBSSxDQUFBO1F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Uc7SUFDSCxlQUFlLENBQUMsQ0FBRTtRQUNoQixNQUFNLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFDckMsQ0FBQztJQUVELElBQUksS0FBSztRQUNQLE1BQU0sQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFBO0lBQ3BCLENBQUM7SUFFRCxJQUFJLEtBQUssQ0FBQyxRQUFnQjtRQUN4QixFQUFFLENBQUMsQ0FBQyxRQUFRLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQztZQUMxQixJQUFJLENBQUMsTUFBTSxHQUFHLFFBQVEsQ0FBQTtRQUN4QixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxhQUFhLEdBQUcsUUFBUSxHQUFHLG1CQUFtQixDQUFDLENBQUE7UUFDekUsQ0FBQztJQUNILENBQUM7Q0FDRjtBQWxHRCxvQkFrR0MifQ==
|
79
docs/index.md
Normal file
79
docs/index.md
Normal file
@ -0,0 +1,79 @@
|
||||
# taskbuffer
|
||||
flexible task management. TypeScript ready!
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/taskbuffer)
|
||||
[](https://GitLab.com/pushrocks/taskbuffer)
|
||||
[](https://github.com/pushrocks/taskbuffer)
|
||||
[](https://pushrocks.gitlab.io/taskbuffer/)
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://GitLab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://www.npmjs.com/package/taskbuffer)
|
||||
[](https://david-dm.org/pushrocks/taskbuffer)
|
||||
[](https://www.bithound.io/github/pushrocks/taskbuffer/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/taskbuffer)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install taskbuffer --save
|
||||
```
|
||||
|
||||
## Concepts
|
||||
|
||||
### class `Task`
|
||||
* A Task in its most simple form is a function that is executed when the task runs.
|
||||
* A Task can have a **preTask** and an **afterTask**
|
||||
(those are run before or after the main function whenever the task is called)
|
||||
* A Task can be buffered.
|
||||
That means it can be called multiple times in a very short time.
|
||||
However execution happens in line:
|
||||
meaning execution of the task's main function is on halt until the previous task call has finished.
|
||||
You can set bufferMax number, which is the max number of buffered task calls.
|
||||
Any additional calls will then be truncated
|
||||
* Task.trigger() and Task.triggerBuffered() always return a Promise
|
||||
which is fullfilled once the related task call has completed.
|
||||
* Task.triggered() is an Observable stream that emits events every time a task call is called and every time a call is completed.
|
||||
* Task is compatible to gulp streams.
|
||||
|
||||
### class `TaskChain`
|
||||
* TaskChain extends Task.
|
||||
* Multiple Tasks can be combined in a bigger task using a TaskChain.
|
||||
* While the tasks are async in themselve, TaskChain **runs Tasks serialized** (one after the other)
|
||||
* that means that tasks can rely on each other and
|
||||
|
||||
### class `TaskParallel`
|
||||
* TaskParallel extends Task.
|
||||
* like TaskChain, however **tasks run in parallel**
|
||||
* Tasks cannot rely on each other.
|
||||
|
||||
### Usage
|
||||
We highly recommend TypeScript as this module supports **TypeScript intellisense**.
|
||||
```javascript
|
||||
import * as taskbuffer from "taskbuffer";
|
||||
|
||||
myTask = new taskbuffer.Task({
|
||||
preTask: someOtherTask // optional, don't worry loops are prevented
|
||||
afterTask: someOtherTask // optional, don't worry loops are prevented
|
||||
name:"myTask1",
|
||||
buffered: true, // optional
|
||||
bufferMax: 3, // optional, call qeues greater than this are truncated
|
||||
execDelay: 1000, // optional, time in ms to wait before executing task call
|
||||
taskFunction:() => {
|
||||
// do some stuff and return promise
|
||||
// pass on any data through promise resolution
|
||||
// Use TypeScript for better understanding and code completion
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
|
||||
[](https://push.rocks)
|
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "taskbuffer",
|
||||
"version": "1.0.17",
|
||||
"version": "1.0.21",
|
||||
"description": "flexible task management. TypeScript ready!",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
@ -29,14 +29,14 @@
|
||||
"@types/lodash": "4.x.x",
|
||||
"beautylog": "^6.1.10",
|
||||
"cron": "^1.2.1",
|
||||
"lik": "^1.0.32",
|
||||
"lik": "^1.0.38",
|
||||
"lodash": "^4.17.4",
|
||||
"rxjs": "^5.4.1",
|
||||
"rxjs": "^5.4.2",
|
||||
"smartdelay": "^1.0.3",
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.17"
|
||||
"smartq": "^1.1.6",
|
||||
"typings-global": "^1.0.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tapbundle": "^1.0.14"
|
||||
"tapbundle": "^1.1.0"
|
||||
}
|
||||
}
|
||||
|
29
readme.md
Normal file
29
readme.md
Normal file
@ -0,0 +1,29 @@
|
||||
# taskbuffer
|
||||
flexible task management. TypeScript ready!
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/taskbuffer)
|
||||
[](https://GitLab.com/pushrocks/taskbuffer)
|
||||
[](https://github.com/pushrocks/taskbuffer)
|
||||
[](https://pushrocks.gitlab.io/taskbuffer/)
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://GitLab.com/pushrocks/taskbuffer/commits/master)
|
||||
[](https://www.npmjs.com/package/taskbuffer)
|
||||
[](https://david-dm.org/pushrocks/taskbuffer)
|
||||
[](https://www.bithound.io/github/pushrocks/taskbuffer/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/taskbuffer)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
@ -28,12 +28,18 @@ export let isTaskTouched = (taskArg: Task, touchedTasksArray: Task[]): boolean =
|
||||
return result
|
||||
}
|
||||
|
||||
export let runTask = function (taskArg: Task, optionsArg: { x?, touchedTasksArray?: Task[] }) {
|
||||
export let runTask = async (taskArg: Task, optionsArg: { x?, touchedTasksArray?: Task[] }) => {
|
||||
let done = plugins.q.defer()
|
||||
|
||||
// pay respect to execDelay
|
||||
if (taskArg.execDelay) {
|
||||
await plugins.smartdelay.delayFor(taskArg.execDelay)
|
||||
}
|
||||
|
||||
// set running params
|
||||
taskArg.running = true
|
||||
done.promise.then(function () { taskArg.running = false })
|
||||
|
||||
done.promise.then(async () => { taskArg.running = false })
|
||||
|
||||
// handle options
|
||||
let options = plugins.lodash.merge(
|
||||
@ -75,7 +81,7 @@ export let runTask = function (taskArg: Task, optionsArg: { x?, touchedTasksArra
|
||||
console.log(err)
|
||||
})
|
||||
localDeferred.resolve()
|
||||
return done.promise
|
||||
return await done.promise
|
||||
}
|
||||
|
||||
export interface cycleObject {
|
||||
@ -116,18 +122,13 @@ export class BufferRunner {
|
||||
task: Task
|
||||
// initialze by default
|
||||
bufferCounter: number = 0
|
||||
bufferMax: number = 1
|
||||
running: boolean = false
|
||||
constructor(taskArg: Task) {
|
||||
this.task = taskArg
|
||||
}
|
||||
|
||||
setBufferMax (bufferMaxArg: number) {
|
||||
this.bufferMax = bufferMaxArg
|
||||
}
|
||||
|
||||
trigger (x): Promise<any> {
|
||||
if (!(this.bufferCounter >= this.bufferMax)) {
|
||||
if (!(this.bufferCounter >= this.task.bufferMax)) {
|
||||
this.bufferCounter++
|
||||
}
|
||||
let returnPromise: Promise<any> = this.task.cycleCounter.getPromiseForCycle(this.bufferCounter + 1)
|
||||
|
@ -6,9 +6,15 @@ export interface ITaskFunction {
|
||||
}
|
||||
|
||||
export class Task {
|
||||
// man datory properties
|
||||
name: string
|
||||
taskFunction: ITaskFunction
|
||||
buffered: boolean
|
||||
|
||||
bufferMax: number
|
||||
execDelay: number
|
||||
|
||||
// tasks to run before and after
|
||||
preTask: Task
|
||||
afterTask: Task
|
||||
|
||||
@ -16,31 +22,55 @@ export class Task {
|
||||
running: boolean = false
|
||||
bufferRunner = new helpers.BufferRunner(this)
|
||||
cycleCounter = new helpers.CycleCounter(this)
|
||||
|
||||
idle: boolean = true
|
||||
private _state: string = 'ready'
|
||||
|
||||
constructor (optionsArg: {
|
||||
taskFunction: ITaskFunction,
|
||||
preTask?: Task,
|
||||
afterTask?: Task,
|
||||
buffered?: boolean,
|
||||
bufferMax?: number,
|
||||
constructor(optionsArg: {
|
||||
/**
|
||||
* the task function to run, must return promise
|
||||
*/
|
||||
taskFunction: ITaskFunction
|
||||
/**
|
||||
* any other task to run before
|
||||
*/
|
||||
preTask?: Task
|
||||
/**
|
||||
* any other task to run after
|
||||
*/
|
||||
afterTask?: Task
|
||||
/**
|
||||
* wether this task should run buffered
|
||||
*/
|
||||
buffered?: boolean
|
||||
/**
|
||||
* the maximum buffer
|
||||
*/
|
||||
bufferMax?: number
|
||||
/**
|
||||
* the execution delay, before the task is executed
|
||||
* only makes sense when running in buffered mode
|
||||
*/
|
||||
execDelay?: number
|
||||
/**
|
||||
* the name of the task
|
||||
*/
|
||||
name?: string
|
||||
}) {
|
||||
let options = optionsArg
|
||||
this.taskFunction = optionsArg.taskFunction
|
||||
this.preTask = options.preTask
|
||||
this.afterTask = options.afterTask
|
||||
this.preTask = optionsArg.preTask
|
||||
this.afterTask = optionsArg.afterTask
|
||||
this.idle = !this.running
|
||||
this.buffered = options.buffered
|
||||
this.bufferRunner.setBufferMax(options.bufferMax)
|
||||
this.name = options.name
|
||||
this.buffered = optionsArg.buffered
|
||||
this.bufferMax = optionsArg.bufferMax
|
||||
this.execDelay = optionsArg.execDelay
|
||||
this.name = optionsArg.name
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger the task. Will trigger buffered if this.buffered is true
|
||||
*/
|
||||
trigger (x?): Promise<any> {
|
||||
trigger(x?): Promise<any> {
|
||||
if (this.buffered) {
|
||||
return this.triggerBuffered(x)
|
||||
} else {
|
||||
@ -51,21 +81,22 @@ export class Task {
|
||||
/**
|
||||
* trigger task unbuffered.
|
||||
*/
|
||||
triggerUnBuffered (x?): Promise<any> {
|
||||
triggerUnBuffered(x?): Promise<any> {
|
||||
return helpers.runTask(this, { x: x })
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger task buffered.
|
||||
*/
|
||||
triggerBuffered (x?): Promise<any> {
|
||||
triggerBuffered(x?): Promise<any> {
|
||||
return this.bufferRunner.trigger(x)
|
||||
}
|
||||
|
||||
get state (): string {
|
||||
get state(): string {
|
||||
return this._state
|
||||
}
|
||||
set state (stateArg: string) {
|
||||
|
||||
set state(stateArg: string) {
|
||||
if (stateArg === 'locked') {
|
||||
this._state = 'locked'
|
||||
} else {
|
||||
|
171
yarn.lock
171
yarn.lock
@ -15,7 +15,11 @@
|
||||
dependencies:
|
||||
"@types/chai" "*"
|
||||
|
||||
"@types/chai@*", "@types/chai@^3.4.35":
|
||||
"@types/chai@*":
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.1.tgz#37fea779617cfec3fd2b19a0247e8bbdd5133bf6"
|
||||
|
||||
"@types/chai@^3.4.35":
|
||||
version "3.5.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.5.2.tgz#c11cd2817d3a401b7ba0f5a420f35c56139b1c1e"
|
||||
|
||||
@ -23,29 +27,29 @@
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/cron/-/cron-1.2.1.tgz#95c1e432d6106ca34c92f0743638bc786c073faa"
|
||||
|
||||
"@types/lodash@4.x.x", "@types/lodash@^4.14.55", "@types/lodash@^4.14.62":
|
||||
version "4.14.66"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.66.tgz#3dbb83477becf130611f8fac82a8fdb199805981"
|
||||
"@types/lodash@4.x.x", "@types/lodash@^4.14.55", "@types/lodash@^4.14.67":
|
||||
version "4.14.68"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.68.tgz#754fbab68bd2bbb69547dc8ce7574f7012eed7f6"
|
||||
|
||||
"@types/minimatch@2.x.x":
|
||||
version "2.0.29"
|
||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-2.0.29.tgz#5002e14f75e2d71e564281df0431c8c1b4a2a36a"
|
||||
|
||||
"@types/node@*", "@types/node@^7.0.29":
|
||||
version "7.0.31"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86"
|
||||
"@types/node@*":
|
||||
version "8.0.9"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.9.tgz#19f44c3b6cb8a70d261d366f73650e3e3891ab2d"
|
||||
|
||||
"@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@1.x.x":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.0.1.tgz#dbccb01bd8f0f801a12a4604c7d7af59bb02ae2f"
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.0.2.tgz#41f0b0f6ae0eeed3a51b003e2e08cba5525b74f6"
|
||||
|
||||
"@types/shelljs@^0.6.0":
|
||||
version "0.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.6.0.tgz#090b705c102ce7fc5c0c5ea9b524418ff15840df"
|
||||
"@types/shelljs@^0.7.2":
|
||||
version "0.7.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.7.2.tgz#c2bdb3fe80cd7a3da08750ca898ae44c589671f3"
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
@ -162,6 +166,13 @@ deep-eql@^0.1.3:
|
||||
dependencies:
|
||||
type-detect "0.1.1"
|
||||
|
||||
define-properties@^1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
|
||||
dependencies:
|
||||
foreach "^2.0.5"
|
||||
object-keys "^1.0.8"
|
||||
|
||||
early@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/early/-/early-2.1.1.tgz#841e23254ea5dc54d8afaeee82f5ab65c00ee23c"
|
||||
@ -170,6 +181,23 @@ early@^2.1.1:
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.16"
|
||||
|
||||
es-abstract@^1.5.1:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
|
||||
dependencies:
|
||||
es-to-primitive "^1.1.1"
|
||||
function-bind "^1.1.0"
|
||||
is-callable "^1.1.3"
|
||||
is-regex "^1.0.3"
|
||||
|
||||
es-to-primitive@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
|
||||
dependencies:
|
||||
is-callable "^1.1.1"
|
||||
is-date-object "^1.0.1"
|
||||
is-symbol "^1.0.1"
|
||||
|
||||
es6-error@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.0.2.tgz#eec5c726eacef51b7f6b73c20db6e1b13b069c98"
|
||||
@ -182,10 +210,18 @@ figlet@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/figlet/-/figlet-1.2.0.tgz#6c46537378fab649146b5a6143dda019b430b410"
|
||||
|
||||
foreach@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
|
||||
|
||||
fs.realpath@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||
|
||||
function-bind@^1.0.2, function-bind@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
|
||||
|
||||
glob@^7.0.0:
|
||||
version "7.1.2"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
|
||||
@ -203,6 +239,12 @@ has-ansi@^2.0.0:
|
||||
dependencies:
|
||||
ansi-regex "^2.0.0"
|
||||
|
||||
has@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
|
||||
dependencies:
|
||||
function-bind "^1.0.2"
|
||||
|
||||
inflight@^1.0.4:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
||||
@ -218,6 +260,24 @@ interpret@^1.0.0:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90"
|
||||
|
||||
is-callable@^1.1.1, is-callable@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
|
||||
|
||||
is-date-object@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
|
||||
|
||||
is-regex@^1.0.3:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
|
||||
dependencies:
|
||||
has "^1.0.1"
|
||||
|
||||
is-symbol@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
|
||||
|
||||
isexe@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||
@ -236,20 +296,19 @@ left-pad@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a"
|
||||
|
||||
lik@^1.0.32:
|
||||
version "1.0.32"
|
||||
resolved "https://registry.yarnpkg.com/lik/-/lik-1.0.32.tgz#41ee6c8edd483eaa11bd089775263955f5555060"
|
||||
lik@^1.0.38:
|
||||
version "1.0.38"
|
||||
resolved "https://registry.yarnpkg.com/lik/-/lik-1.0.38.tgz#ccff0abd3d9236a5e4b7d80d514c5c210f18469b"
|
||||
dependencies:
|
||||
"@types/lodash" "^4.14.62"
|
||||
"@types/lodash" "^4.14.67"
|
||||
"@types/minimatch" "2.x.x"
|
||||
"@types/q" "1.x.x"
|
||||
lodash "^4.17.4"
|
||||
minimatch "^3.0.3"
|
||||
minimatch "^3.0.4"
|
||||
q "^1.5.0"
|
||||
rxjs "^5.3.0"
|
||||
rxjs "^5.4.1"
|
||||
smartq "^1.1.1"
|
||||
tapbundle "^1.0.14"
|
||||
typings-global "^1.0.14"
|
||||
typings-global "^1.0.19"
|
||||
|
||||
lodash@^4.17.4:
|
||||
version "4.17.4"
|
||||
@ -272,7 +331,7 @@ 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.3, minimatch@^3.0.4:
|
||||
minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
dependencies:
|
||||
@ -296,6 +355,17 @@ nan@^2.3.2:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45"
|
||||
|
||||
object-keys@^1.0.8:
|
||||
version "1.0.11"
|
||||
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
|
||||
|
||||
object.getownpropertydescriptors@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
|
||||
dependencies:
|
||||
define-properties "^1.1.2"
|
||||
es-abstract "^1.5.1"
|
||||
|
||||
once@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||
@ -352,9 +422,9 @@ restore-cursor@^2.0.0:
|
||||
onetime "^2.0.0"
|
||||
signal-exit "^3.0.2"
|
||||
|
||||
rxjs@^5.3.0, rxjs@^5.4.1:
|
||||
version "5.4.1"
|
||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.1.tgz#b62f757f279445d265a18a58fb0a70dc90e91626"
|
||||
rxjs@^5.4.1, rxjs@^5.4.2:
|
||||
version "5.4.2"
|
||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.2.tgz#2a3236fcbf03df57bae06fd6972fd99e5c08fcf7"
|
||||
dependencies:
|
||||
symbol-observable "^1.0.1"
|
||||
|
||||
@ -362,7 +432,7 @@ semver@^5.3.0:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
|
||||
|
||||
shelljs@^0.7.6:
|
||||
shelljs@^0.7.8:
|
||||
version "0.7.8"
|
||||
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3"
|
||||
dependencies:
|
||||
@ -400,22 +470,23 @@ smartenv@^2.0.0:
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.14"
|
||||
|
||||
smartq@^1.1.0, smartq@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.1.tgz#efb358705260d41ae18aef7ffd815f7b6fe17dd3"
|
||||
smartq@^1.1.1, smartq@^1.1.6:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
|
||||
dependencies:
|
||||
typed-promisify "^0.3.0"
|
||||
typings-global "^1.0.14"
|
||||
typings-global "^1.0.19"
|
||||
util.promisify "^1.0.0"
|
||||
|
||||
smartshell@^1.0.6:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/smartshell/-/smartshell-1.0.6.tgz#27b1c79029784abe72ac7e91fe698b7ebecc6629"
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/smartshell/-/smartshell-1.0.8.tgz#1535756c0fe8069f7e6da1e3f9cb6c8f77094e42"
|
||||
dependencies:
|
||||
"@types/shelljs" "^0.6.0"
|
||||
"@types/shelljs" "^0.7.2"
|
||||
"@types/which" "^1.0.28"
|
||||
shelljs "^0.7.6"
|
||||
smartq "^1.1.0"
|
||||
which "^1.2.12"
|
||||
shelljs "^0.7.8"
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.19"
|
||||
which "^1.2.14"
|
||||
|
||||
strip-ansi@^3.0.0:
|
||||
version "3.0.1"
|
||||
@ -431,16 +502,16 @@ symbol-observable@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
|
||||
|
||||
tapbundle@^1.0.14:
|
||||
version "1.0.14"
|
||||
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.0.14.tgz#75827e335fcb02216f0267a26a26d702ddc02e3c"
|
||||
tapbundle@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.1.0.tgz#e0547f683ae36260f639ecd7435df95f0af01683"
|
||||
dependencies:
|
||||
early "^2.1.1"
|
||||
leakage "^0.3.0"
|
||||
smartchai "^1.0.3"
|
||||
smartdelay "^1.0.3"
|
||||
smartq "^1.1.1"
|
||||
typings-global "^1.0.16"
|
||||
typings-global "^1.0.19"
|
||||
|
||||
type-detect@0.1.1:
|
||||
version "0.1.1"
|
||||
@ -450,19 +521,21 @@ 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@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.17:
|
||||
version "1.0.17"
|
||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.17.tgz#41edc331ccec3168289adc8849e1e255efbe7152"
|
||||
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.19:
|
||||
version "1.0.19"
|
||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.19.tgz#3376a72d4de1e5541bf5702248ff64c3e6ea316c"
|
||||
dependencies:
|
||||
"@types/node" "^7.0.29"
|
||||
semver "^5.3.0"
|
||||
smartshell "^1.0.6"
|
||||
|
||||
which@^1.2.12:
|
||||
util.promisify@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
|
||||
dependencies:
|
||||
define-properties "^1.1.2"
|
||||
object.getownpropertydescriptors "^2.0.3"
|
||||
|
||||
which@^1.2.14:
|
||||
version "1.2.14"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"
|
||||
dependencies:
|
||||
|
Reference in New Issue
Block a user