New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

undoo

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

undoo - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

4

CHANGELOG.md

@@ -7,2 +7,6 @@ # Change Log

[0.2.0] - 2018-02-14
- **Added** `import` method, now it's possible load external array history
- **Added** `history` method, now it's possible get current history
[0.1.0] - 2018-02-13

@@ -9,0 +13,0 @@ - **Added** items equals check,

@@ -1,2 +0,2 @@

// [AIV] Undoo Build version: 0.1.0
// [AIV] Undoo Build version: 0.2.0
(function webpackUniversalModuleDefinition(root, factory) {

@@ -115,3 +115,19 @@ if(typeof exports === 'object' && typeof module === 'object')

this.opts = extend.copy(opts, {
Object.defineProperties(this, {
_opts: {
writable: true
},
_history: {
writable: true
},
_position: {
writable: true
},
_onUpdate: {
writable: true,
value: function value() {}
}
});
this._opts = extend.copy(opts, {
provider: null,

@@ -121,5 +137,3 @@ maxLength: 20

this._history = [];
this._position = 0;
this._onUpdate = function () {};
this._initiliaze();
}

@@ -134,5 +148,17 @@

_createClass(Undoo, [{
key: '_initiliaze',
value: function _initiliaze() {
this._history = [];
this._position = 0;
}
/**
* @ignore
* @private
*/
}, {
key: '_checkExceeded',
value: function _checkExceeded() {
if (this.count() > this.opts.maxLength) this._history = this._history.slice(1, this.count());
if (this.count() > this._opts.maxLength) this._history = this._history.slice(1, this.count());
}

@@ -165,2 +191,31 @@

/**
* Import external history
* @param history {Array}
* @returns {Undoo}
*/
}, {
key: 'import',
value: function _import() {
var history = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
if (!Array.isArray(history)) throw new TypeError('Items must be an array');
this._initiliaze();
this._history = history;
this._position = this.count();
return this;
}
/**
* Get history
* @returns {Array}
*/
}, {
key: 'history',
value: function history() {
return this._history;
}
/**
* Save history

@@ -175,3 +230,3 @@ * @param [item] {*}

if (typeof item === 'undefined' && typeof this.opts.provider === 'function') item = this.opts.provider();
if (typeof item === 'undefined' && typeof this._opts.provider === 'function') item = this._opts.provider();

@@ -199,4 +254,3 @@ if (isEqual(item, this.current())) return this;

value: function clear() {
this._history = [];
this._position = 0;
this._initiliaze();
this._onUpdate.call(null, null, 'clear');

@@ -214,3 +268,3 @@ return this;

* Undo
* @param callback {Undoo~undoCallback} callback function
* @param [callback] {Undoo~undoCallback} callback function
* @returns {Undoo}

@@ -238,3 +292,3 @@ */

* Redo
* @param callback {Undoo~redoCallback} callback function
* @param [callback] {Undoo~redoCallback} callback function
* @returns {Undoo}

@@ -241,0 +295,0 @@ */

4

dist/undoo.min.js

@@ -1,2 +0,2 @@

// [AIV] Undoo Build version: 0.1.0
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("Undoo",[],n):"object"==typeof exports?exports.Undoo=n():t.Undoo=n()}("undefined"!=typeof self?self:this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,e){"use strict";t.exports=e(1)},function(t,n,e){"use strict";function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),i=e(2),u=e(4),c=function(){function t(n){o(this,t),this.opts=i.copy(n,{provider:null,maxLength:20}),this._history=[],this._position=0,this._onUpdate=function(){}}return r(t,[{key:"_checkExceeded",value:function(){this.count()>this.opts.maxLength&&(this._history=this._history.slice(1,this.count()))}},{key:"_canUndo",value:function(){return this._position>0}},{key:"_canRedo",value:function(){return this._position<this.count()}},{key:"save",value:function(t){return void 0===t&&"function"==typeof this.opts.provider&&(t=this.opts.provider()),u(t,this.current())?this:(this._position<this.count()&&(this._history=this._history.slice(0,this._position)),void 0!==t&&this._history.push(t),this._checkExceeded(),this._position=this.count(),this._onUpdate.call(null,this.current(),"save"),this)}},{key:"clear",value:function(){return this._history=[],this._position=0,this._onUpdate.call(null,null,"clear"),this}},{key:"undo",value:function(t){return this._canUndo()&&(this._position--,"function"==typeof t&&t(this.current()),this._onUpdate.call(null,this.current(),"undo")),this}},{key:"redo",value:function(t){return this._canRedo()&&(this._position++,"function"==typeof t&&t(this.current()),this._onUpdate.call(null,this.current(),"redo")),this}},{key:"current",value:function(){return this.count()?this._history[this._position-1]:null}},{key:"count",value:function(){return this._history.length}},{key:"onUpdate",value:function(t){return this._onUpdate=t,this}}]),t}();t.exports=c},function(t,n,e){"use strict";(function(t){var e,o,r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u,c){"object"===i(n)&&"object"===i(t)?t.exports=c():(o=[],e=c,void 0!==(r="function"==typeof e?e.apply(n,o):e)&&(t.exports=r))}("undefined"!=typeof self&&self,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,e){t.exports=e(1)},function(t,n,e){var o="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(t){return void 0===t?"undefined":i(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":i(t)},r=e(2),u=function t(n,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(var i in e)e.hasOwnProperty(i)&&-1===r.indexOf(i)&&(n.hasOwnProperty(i)&&void 0!==n[i]?"object"===o(n[i])&&t(n[i],e[i]):n[i]=e[i]);return n},c=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];return n[0]=r(n[0]),u.apply(void 0,n)};t.exports=u,t.exports.copy=c},function(t,n,e){var o,r,u="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(t){return void 0===t?"undefined":i(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":i(t)};!function(i,c,f){"object"===u(n)?t.exports=f():(o=f,void 0!==(r="function"==typeof o?o.call(n,e,n,t):o)&&(t.exports=r))}(0,0,function(){function t(t,n,e){return t instanceof Array?(t.push(e),t[t.length-1]):t instanceof Object?(t[n]=e,t[n]):void 0}return function(n){function e(n,o){for(var r in n){var i=n[r];if(i instanceof Date){var u=new Date(i.getTime());t(o,r,u)}else if(i instanceof Function){var u=i;t(o,r,u)}else if(i instanceof Array){var u=[],c=t(o,r,u);e(i,c)}else if(i instanceof Object){var u={},c=t(o,r,u);e(i,c)}else{var u=i;t(o,r,u)}}}if(/number|string|boolean/.test(void 0===n?"undefined":u(n)))return n;if(n instanceof Date)return new Date(n.getTime());var o=n instanceof Array?[]:{};return e(n,o),o}})}])})}).call(n,e(3)(t))},function(t,n,e){"use strict";t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,n,e){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function t(n,e){if(n===e)return!0;var r,i=Array.isArray(n),u=Array.isArray(e);if(i&&u){if(n.length!=e.length)return!1;for(r=0;r<n.length;r++)if(!t(n[r],e[r]))return!1;return!0}if(i!=u)return!1;if(n&&e&&"object"===(void 0===n?"undefined":o(n))&&"object"===(void 0===e?"undefined":o(e))){var c=Object.keys(n);if(c.length!==Object.keys(e).length)return!1;var f=n instanceof Date,s=e instanceof Date;if(f&&s)return n.getTime()==e.getTime();if(f!=s)return!1;var l=n instanceof RegExp,a=e instanceof RegExp;if(l&&a)return n.toString()==e.toString();if(l!=a)return!1;for(r=0;r<c.length;r++)if(!Object.prototype.hasOwnProperty.call(e,c[r]))return!1;for(r=0;r<c.length;r++)if(!t(n[c[r]],e[c[r]]))return!1;return!0}return!1}}])});
// [AIV] Undoo Build version: 0.2.0
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("Undoo",[],n):"object"==typeof exports?exports.Undoo=n():t.Undoo=n()}("undefined"!=typeof self?self:this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,e){"use strict";t.exports=e(1)},function(t,n,e){"use strict";function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),i=e(2),u=e(4),c=function(){function t(n){o(this,t),Object.defineProperties(this,{_opts:{writable:!0},_history:{writable:!0},_position:{writable:!0},_onUpdate:{writable:!0,value:function(){}}}),this._opts=i.copy(n,{provider:null,maxLength:20}),this._initiliaze()}return r(t,[{key:"_initiliaze",value:function(){this._history=[],this._position=0}},{key:"_checkExceeded",value:function(){this.count()>this._opts.maxLength&&(this._history=this._history.slice(1,this.count()))}},{key:"_canUndo",value:function(){return this._position>0}},{key:"_canRedo",value:function(){return this._position<this.count()}},{key:"import",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!Array.isArray(t))throw new TypeError("Items must be an array");return this._initiliaze(),this._history=t,this._position=this.count(),this}},{key:"history",value:function(){return this._history}},{key:"save",value:function(t){return void 0===t&&"function"==typeof this._opts.provider&&(t=this._opts.provider()),u(t,this.current())?this:(this._position<this.count()&&(this._history=this._history.slice(0,this._position)),void 0!==t&&this._history.push(t),this._checkExceeded(),this._position=this.count(),this._onUpdate.call(null,this.current(),"save"),this)}},{key:"clear",value:function(){return this._initiliaze(),this._onUpdate.call(null,null,"clear"),this}},{key:"undo",value:function(t){return this._canUndo()&&(this._position--,"function"==typeof t&&t(this.current()),this._onUpdate.call(null,this.current(),"undo")),this}},{key:"redo",value:function(t){return this._canRedo()&&(this._position++,"function"==typeof t&&t(this.current()),this._onUpdate.call(null,this.current(),"redo")),this}},{key:"current",value:function(){return this.count()?this._history[this._position-1]:null}},{key:"count",value:function(){return this._history.length}},{key:"onUpdate",value:function(t){return this._onUpdate=t,this}}]),t}();t.exports=c},function(t,n,e){"use strict";(function(t){var e,o,r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(u,c){"object"===i(n)&&"object"===i(t)?t.exports=c():(o=[],e=c,void 0!==(r="function"==typeof e?e.apply(n,o):e)&&(t.exports=r))}("undefined"!=typeof self&&self,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=0)}([function(t,n,e){t.exports=e(1)},function(t,n,e){var o="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(t){return void 0===t?"undefined":i(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":i(t)},r=e(2),u=function t(n,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(var i in e)e.hasOwnProperty(i)&&-1===r.indexOf(i)&&(n.hasOwnProperty(i)&&void 0!==n[i]?"object"===o(n[i])&&t(n[i],e[i]):n[i]=e[i]);return n},c=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];return n[0]=r(n[0]),u.apply(void 0,n)};t.exports=u,t.exports.copy=c},function(t,n,e){var o,r,u="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(t){return void 0===t?"undefined":i(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":i(t)};!function(i,c,s){"object"===u(n)?t.exports=s():(o=s,void 0!==(r="function"==typeof o?o.call(n,e,n,t):o)&&(t.exports=r))}(0,0,function(){function t(t,n,e){return t instanceof Array?(t.push(e),t[t.length-1]):t instanceof Object?(t[n]=e,t[n]):void 0}return function(n){function e(n,o){for(var r in n){var i=n[r];if(i instanceof Date){var u=new Date(i.getTime());t(o,r,u)}else if(i instanceof Function){var u=i;t(o,r,u)}else if(i instanceof Array){var u=[],c=t(o,r,u);e(i,c)}else if(i instanceof Object){var u={},c=t(o,r,u);e(i,c)}else{var u=i;t(o,r,u)}}}if(/number|string|boolean/.test(void 0===n?"undefined":u(n)))return n;if(n instanceof Date)return new Date(n.getTime());var o=n instanceof Array?[]:{};return e(n,o),o}})}])})}).call(n,e(3)(t))},function(t,n,e){"use strict";t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,n,e){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function t(n,e){if(n===e)return!0;var r,i=Array.isArray(n),u=Array.isArray(e);if(i&&u){if(n.length!=e.length)return!1;for(r=0;r<n.length;r++)if(!t(n[r],e[r]))return!1;return!0}if(i!=u)return!1;if(n&&e&&"object"===(void 0===n?"undefined":o(n))&&"object"===(void 0===e?"undefined":o(e))){var c=Object.keys(n);if(c.length!==Object.keys(e).length)return!1;var s=n instanceof Date,f=e instanceof Date;if(s&&f)return n.getTime()==e.getTime();if(s!=f)return!1;var a=n instanceof RegExp,l=e instanceof RegExp;if(a&&l)return n.toString()==e.toString();if(a!=l)return!1;for(r=0;r<c.length;r++)if(!Object.prototype.hasOwnProperty.call(e,c[r]))return!1;for(r=0;r<c.length;r++)if(!t(n[c[r]],e[c[r]]))return!1;return!0}return!1}}])});
{
"name": "undoo",
"version": "0.1.0",
"version": "0.2.0",
"description": "Undo/redo manager",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -34,5 +34,5 @@ # Undoo

myHistory
.save('one');
.save('two');
.save('three');
.save('one')
.save('two')
.save('three')
.save('four');

@@ -75,6 +75,8 @@

* _instance_
* [.import(history)](#Undoo+import) ⇒ [<code>Undoo</code>](#Undoo)
* [.history()](#Undoo+history) ⇒ <code>Array</code>
* [.save([item])](#Undoo+save) ⇒ [<code>Undoo</code>](#Undoo)
* [.clear()](#Undoo+clear) ⇒ [<code>Undoo</code>](#Undoo)
* [.undo(callback)](#Undoo+undo) ⇒ [<code>Undoo</code>](#Undoo)
* [.redo(callback)](#Undoo+redo) ⇒ [<code>Undoo</code>](#Undoo)
* [.undo([callback])](#Undoo+undo) ⇒ [<code>Undoo</code>](#Undoo)
* [.redo([callback])](#Undoo+redo) ⇒ [<code>Undoo</code>](#Undoo)
* [.current()](#Undoo+current) ⇒ <code>\*</code>

@@ -112,2 +114,26 @@ * [.count()](#Undoo+count) ⇒ <code>number</code>

<a name="Undoo+import"></a>
### undoo.import(history) ⇒ [<code>Undoo</code>](#Undoo)
Import external history
**Kind**: instance method of [<code>Undoo</code>](#Undoo)
<table>
<thead>
<tr>
<th>Param</th><th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>history</td><td><code>Array</code></td>
</tr> </tbody>
</table>
<a name="Undoo+history"></a>
### undoo.history() ⇒ <code>Array</code>
Get history
**Kind**: instance method of [<code>Undoo</code>](#Undoo)
<a name="Undoo+save"></a>

@@ -139,3 +165,3 @@

### undoo.undo(callback) ⇒ [<code>Undoo</code>](#Undoo)
### undoo.undo([callback]) ⇒ [<code>Undoo</code>](#Undoo)
Undo

@@ -152,3 +178,3 @@

<tr>
<td>callback</td><td><code><a href="#Undoo..undoCallback">undoCallback</a></code></td><td><p>callback function</p>
<td>[callback]</td><td><code><a href="#Undoo..undoCallback">undoCallback</a></code></td><td><p>callback function</p>
</td>

@@ -160,3 +186,3 @@ </tr> </tbody>

### undoo.redo(callback) ⇒ [<code>Undoo</code>](#Undoo)
### undoo.redo([callback]) ⇒ [<code>Undoo</code>](#Undoo)
Redo

@@ -173,3 +199,3 @@

<tr>
<td>callback</td><td><code><a href="#Undoo..redoCallback">redoCallback</a></code></td><td><p>callback function</p>
<td>[callback]</td><td><code><a href="#Undoo..redoCallback">redoCallback</a></code></td><td><p>callback function</p>
</td>

@@ -278,2 +304,2 @@ </tr> </tbody>

## Author
<a target="_blank" href="http://rica.li">Fabio Ricali</a>
<a target="_blank" href="http://rica.li">Fabio Ricali</a>

@@ -16,3 +16,20 @@ const extend = require('defaulty');

constructor(opts) {
this.opts = extend.copy(opts, {
Object.defineProperties(this, {
_opts: {
writable: true
},
_history: {
writable: true
},
_position: {
writable: true
},
_onUpdate: {
writable: true,
value: ()=>{}
}
});
this._opts = extend.copy(opts, {
provider: null,

@@ -22,6 +39,12 @@ maxLength: 20

this._initiliaze();
}
/**
* @ignore
* @private
*/
_initiliaze() {
this._history = [];
this._position = 0;
this._onUpdate = () => {
};
}

@@ -34,3 +57,3 @@

_checkExceeded() {
if (this.count() > this.opts.maxLength)
if (this.count() > this._opts.maxLength)
this._history = this._history.slice(1, this.count());

@@ -58,2 +81,24 @@ }

/**
* Import external history
* @param history {Array}
* @returns {Undoo}
*/
import(history = []) {
if(!Array.isArray(history))
throw new TypeError('Items must be an array');
this._initiliaze();
this._history = history;
this._position = this.count();
return this;
}
/**
* Get history
* @returns {Array}
*/
history() {
return this._history;
}
/**
* Save history

@@ -65,4 +110,4 @@ * @param [item] {*}

if (typeof item === 'undefined' && typeof this.opts.provider === 'function')
item = this.opts.provider();
if (typeof item === 'undefined' && typeof this._opts.provider === 'function')
item = this._opts.provider();

@@ -90,4 +135,3 @@ if (isEqual(item, this.current()))

clear() {
this._history = [];
this._position = 0;
this._initiliaze();
this._onUpdate.call(null, null, 'clear');

@@ -105,3 +149,3 @@ return this;

* Undo
* @param callback {Undoo~undoCallback} callback function
* @param [callback] {Undoo~undoCallback} callback function
* @returns {Undoo}

@@ -127,3 +171,3 @@ */

* Redo
* @param callback {Undoo~redoCallback} callback function
* @param [callback] {Undoo~redoCallback} callback function
* @returns {Undoo}

@@ -130,0 +174,0 @@ */

@@ -138,6 +138,26 @@ const Undoo = require('../');

myUndo.save('foo');
console.log(myUndo._history);
console.log(myUndo);
be.err.equal('foo', myUndo.current());
be.err(done).equal([ 'world', 'ciao', 'miao', 'bau', 'foo' ], myUndo._history);
});
it('import and history', function (done) {
const myUndo = new Undoo();
myUndo.import([ 'world', 'ciao', 'miao', 'bau', 'foo' ]);
console.log(myUndo.count());
be.err.equal('foo', myUndo.current());
be.err(done).equal([ 'world', 'ciao', 'miao', 'bau', 'foo' ], myUndo.history());
});
it('import with error', function (done) {
const myUndo = new Undoo();
try {
myUndo.import({a: 1});
} catch (e) {
done();
}
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc