deleight
Version:
A library with 9 modules for writing more expressive web applications with traditional HTML, CSS and JavaScript.
27 lines (26 loc) • 930 B
TypeScript
/**
* Returns a function that will call
* the reverse action automatically with the last argument called
* with it before calling the action with the current argument.
*
* Suitable for things like tabs and selections...
*
* @example
* import { rev } from 'deleight/function'
* const hide = (dialog: HTMLDialogElement) => dialog.style.display = 'none';
* const show = rev(
* (dialog: HTMLDialogElement) => dialog.style.display = null,
* hide
* );
* show(document.querySelector('#dialog1'));
* show(document.querySelector('#dialog2')); // dialog 1 is hidden automatically
* show(document.querySelector('#dialog3')); // dialog 2 is hidden automatically
*
* @param action
* @param reverseAction
*/
export declare function reversible(action: Function, reverseAction: Function, lateReverse?: boolean): (arg: any) => any;
/**
* Alias for {@link reversible}
*/
export declare const rev: typeof reversible;