diff --git a/Response.js b/Response.js index fb25a89..691e80c 100644 --- a/Response.js +++ b/Response.js @@ -277,7 +277,7 @@ State.prototype.invoke = function (fnc, args, context) { * @returns {State} */ State.prototype.destroy = function (recursive) { - if (recursive === true) { + if (recursive === true && this.stateData) { destroyItems(this.stateData); } @@ -1007,7 +1007,6 @@ function Queue(items, start) { .onState(STATE_RESOLVED, this.stop) .onState(STATE_REJECTED, this.stop); - if (typeof start === 'boolean' && start) { this.start(); } @@ -1110,7 +1109,7 @@ Queue.prototype.item = null; Queue.prototype.context = null; /** - * @param {Array} args - аргументы для первой задачи + * @param {Array} [args] - аргументы для первой задачи * @returns {Queue} */ Queue.prototype.start = function (args) { diff --git a/package.json b/package.json index 1f212e8..8a4f61c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Response", "author": "Vladislav Kurkin (https://github.com/B-Vladi)", - "version": "0.1.8", + "version": "0.1.9", "main": "Response.js", "license": "MIT", "repository": { diff --git a/spec/State.spec.js b/spec/State.spec.js index a7c7fc1..8464183 100644 --- a/spec/State.spec.js +++ b/spec/State.spec.js @@ -543,6 +543,12 @@ describe('State:', function () { } }); + it('destroy with an empty State object don`t throw exception', function () { + state + .setState(1, [new State().destroy()]) + .destroy(true); + }); + describe('invoke', function () { it('without arguments', function () { state.invoke(listener);