Skip to content

Commit 8a6b7ba

Browse files
committed
feat: allow plugin and array of plugins to be passed to nebu.process
…instead of an options object
1 parent ffdfab1 commit 8a6b7ba

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/nebu.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ export interface NebuResult {
3131
}
3232

3333
interface Nebu {
34+
process<State extends object>(
35+
input: string,
36+
plugin: Plugin<State> | PluginOption<State>[]
37+
): NebuResult
3438
process<State extends object>(
3539
input: string,
3640
opts: NebuOptions<State>
3741
): NebuResult
42+
process(input: string, plugin: Plugin | PluginOption[]): NebuResult
3843
process(input: string, opts: NebuOptions): NebuResult
3944

4045
/**
@@ -50,7 +55,16 @@ interface Nebu {
5055
}
5156

5257
export const nebu: Nebu = {
53-
process<State>(input: string, opts: NebuOptions<State>): NebuResult {
58+
process(
59+
input: string,
60+
opts: NebuOptions<any> | Plugin<any> | PluginOption<any>[]
61+
): NebuResult {
62+
if (Array.isArray(opts)) {
63+
opts = { plugins: opts }
64+
} else if (!('plugins' in opts)) {
65+
opts = { plugins: [opts] }
66+
}
67+
5468
const visitors = mergePlugins(opts.plugins)
5569
if (!visitors.size) {
5670
return { js: input }

0 commit comments

Comments
 (0)