16 lines
369 B
TypeScript
16 lines
369 B
TypeScript
/**
|
|
* Internal dependencies
|
|
*/
|
|
import type { EventObserversType, ObserverType } from './types';
|
|
|
|
export const getObserversByPriority = (
|
|
observers: EventObserversType,
|
|
eventType: string
|
|
): ObserverType[] => {
|
|
return observers[ eventType ]
|
|
? Array.from( observers[ eventType ].values() ).sort( ( a, b ) => {
|
|
return a.priority - b.priority;
|
|
} )
|
|
: [];
|
|
};
|