Skip to content

Commit 84dd295

Browse files
Move combineCallbacks to its own module (#3963)
1 parent 0897ec7 commit 84dd295

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/plugins/line-highlight/prism-line-highlight.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isActive } from '../../shared/dom-util';
2-
import { combineCallbacks } from '../../shared/hooks-util';
2+
import { combineCallbacks } from '../../util/combine-callbacks';
33
import { lazy, noop } from '../../shared/util';
44
import type { Prism } from '../../core';
55
import type { PluginProto } from '../../types';

src/plugins/line-numbers/prism-line-numbers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getParentPre, isActive } from '../../shared/dom-util';
2-
import { combineCallbacks } from '../../shared/hooks-util';
2+
import { combineCallbacks } from '../../util/combine-callbacks';
33
import { isNonNull, noop } from '../../shared/util';
44
import type { PluginProto } from '../../types';
55

src/shared/hooks-util.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1+
import { combineCallbacks } from '../util/combine-callbacks';
12
import type { HookCallback, HookEnvMap, Hooks } from '../core/hooks';
23

3-
/**
4-
* Returns a single function that calls all the given functions.
5-
*/
6-
export function combineCallbacks (...callbacks: (() => void)[]): () => void {
7-
return () => {
8-
for (const callback of callbacks) {
9-
callback();
10-
}
11-
};
12-
}
13-
144
/**
155
* TODO: Add description
166
*/

src/util/combine-callbacks.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Returns a single function that calls all the given functions.
3+
*/
4+
export function combineCallbacks (...callbacks: (() => void)[]): () => void {
5+
return () => {
6+
for (const callback of callbacks) {
7+
callback();
8+
}
9+
};
10+
}

0 commit comments

Comments
 (0)