403Webshell
Server IP : 172.67.158.161  /  Your IP : 18.224.44.186
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/giankuin/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/base/context/cart-checkout/event-emit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/giankuin/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/assets/js/base/context/cart-checkout/event-emit/reducer.js
/**
 * External dependencies
 */
import { uniqueId } from 'lodash';

export const TYPES = {
	ADD_EVENT_CALLBACK: 'add_event_callback',
	REMOVE_EVENT_CALLBACK: 'remove_event_callback',
};

export const actions = {
	addEventCallback: ( eventType, callback, priority = 10 ) => {
		return {
			id: uniqueId(),
			type: TYPES.ADD_EVENT_CALLBACK,
			eventType,
			callback,
			priority,
		};
	},
	removeEventCallback: ( eventType, id ) => {
		return {
			id,
			type: TYPES.REMOVE_EVENT_CALLBACK,
			eventType,
		};
	},
};

/**
 * Handles actions for emmitters
 *
 * @param {Object} state  Current state.
 * @param {Object} action Incoming action object
 */
export const reducer = (
	state = {},
	{ type, eventType, id, callback, priority }
) => {
	const newEvents = new Map( state[ eventType ] );
	switch ( type ) {
		case TYPES.ADD_EVENT_CALLBACK:
			newEvents.set( id, { priority, callback } );
			return {
				...state,
				[ eventType ]: newEvents,
			};
		case TYPES.REMOVE_EVENT_CALLBACK:
			newEvents.delete( id );
			return {
				...state,
				[ eventType ]: newEvents,
			};
	}
	return state;
};

Youez - 2016 - github.com/yon3zu
LinuXploit