Comparing version
@@ -22,3 +22,3 @@ /** | ||
*/ | ||
export declare function reversible(action: Function, reverseAction: Function): (arg: any) => any; | ||
export declare function reversible(action: Function, reverseAction: Function, lateReverse?: boolean): (arg: any) => any; | ||
/** | ||
@@ -25,0 +25,0 @@ * Alias for {@link reversible} |
@@ -25,10 +25,16 @@ "use strict"; | ||
*/ | ||
function reversible(action, reverseAction) { | ||
function reversible(action, reverseAction, lateReverse) { | ||
let lastArg; | ||
return function (arg) { | ||
if (lastArg) | ||
if (lastArg === arg) { | ||
reverseAction.call(this, lastArg); | ||
const result = action.call(this, arg); | ||
lastArg = arg; | ||
return result; | ||
lastArg = null; | ||
} | ||
else { | ||
if (lastArg) | ||
reverseAction.call(this, lastArg); | ||
const result = action.call(this, arg); | ||
lastArg = arg; | ||
return result; | ||
} | ||
}; | ||
@@ -35,0 +41,0 @@ } |
@@ -22,3 +22,3 @@ /** | ||
*/ | ||
export declare function reversible(action: Function, reverseAction: Function): (arg: any) => any; | ||
export declare function reversible(action: Function, reverseAction: Function, lateReverse?: boolean): (arg: any) => any; | ||
/** | ||
@@ -25,0 +25,0 @@ * Alias for {@link reversible} |
@@ -22,10 +22,16 @@ /** | ||
*/ | ||
export function reversible(action, reverseAction) { | ||
export function reversible(action, reverseAction, lateReverse) { | ||
let lastArg; | ||
return function (arg) { | ||
if (lastArg) | ||
if (lastArg === arg) { | ||
reverseAction.call(this, lastArg); | ||
const result = action.call(this, arg); | ||
lastArg = arg; | ||
return result; | ||
lastArg = null; | ||
} | ||
else { | ||
if (lastArg) | ||
reverseAction.call(this, lastArg); | ||
const result = action.call(this, arg); | ||
lastArg = arg; | ||
return result; | ||
} | ||
}; | ||
@@ -32,0 +38,0 @@ } |
{ | ||
"name": "deleight", | ||
"version": "5.5.7", | ||
"version": "5.5.8", | ||
"description": "A library with 9 modules for writing more expressive web applications with traditional HTML, CSS and JavaScript.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
540856
0.07%16360
0.07%