Skip to content

Commit 689d861

Browse files
committed
feat: Array / Reverse
1 parent 19fd3c6 commit 689d861

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/nodes/Array.Reverse.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ModuleCompute, ModuleDefinition } from '@nodescript/core/types';
2+
3+
type P = {
4+
array: unknown[];
5+
};
6+
7+
type R = unknown[];
8+
9+
export const module: ModuleDefinition<P, R> = {
10+
version: '1.0.0',
11+
moduleName: 'Array / Reverse',
12+
description: `
13+
Returns a new array with elements in reversed order.
14+
`,
15+
keywords: ['invert', 'flip'],
16+
params: {
17+
array: {
18+
schema: {
19+
type: 'array',
20+
items: { type: 'any' },
21+
},
22+
hideEntries: true,
23+
},
24+
},
25+
result: {
26+
schema: {
27+
type: 'array',
28+
items: { type: 'any' },
29+
}
30+
},
31+
};
32+
33+
export const compute: ModuleCompute<P, R> = params => {
34+
const { array } = params;
35+
return [...array].reverse();
36+
};

0 commit comments

Comments
 (0)