Skip to content

Commit 68058b6

Browse files
committed
Fix arguments not added to function
1 parent dc6ee81 commit 68058b6

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

src/findStackPositions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default async function findStackPositions(
3535
}
3636

3737
// Find the position of 'in:'
38-
let inputPosition = findNextKeyword('input', i, stackIndex);
38+
let inputPosition = findNextKeyword('in', i, stackIndex);
3939
if (inputPosition) {
4040
positionObject['inputPosition'] = inputPosition;
4141
console.log('inputPosition added:', positionObject.inputPosition);

test-workspace/fixtures/2KeysInOutput/output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ await exampleFunction('this is a brief');
1212
/**
1313
* Brief: this is an example
1414
*/
15-
export default async function exampleFunction(): Promise<null> {
16-
console.log("This is an example.");
15+
export default async function exampleFunction(in: string): Promise<null> {
16+
console.log(`Input string is: ${in}`);
1717
return null;
1818
}
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
stack(
2-
'brief',
3-
{
4-
'in': ['this is an example', 'this is an example']
5-
}
6-
);
7-
8-
import getNullValue from '../../stacks/getNullValue';
9-
10-
await getNullValue('this is an example', 'this is an example');
2+
'brief',
3+
{
4+
'in': ['this is an example', 'this is an example']
5+
}
6+
);
7+
8+
// TODO: allow the usage of in a string, but for now incentiviwe people to use in: ['this is an example', 'this is an example']
9+
import processInputArray from '../../stacks/processInputArray';
1110

11+
await processInputArray('this is an example', 'this is an example');
12+
13+
// TODO: allow the usage of in a string, but for now incentiviwe people to use in: ['this is an example', 'this is an example']
1214

1315
/**
1416
* Brief: brief
1517
*/
16-
export default async function getNullValue(): Promise<null> {
17-
const result = await Promise.resolve(null);
18-
return result;
18+
export default async function processInputArray(in: string[]): Promise<null> {
19+
in.forEach((item) => {
20+
console.log(item);
21+
});
22+
return null;
1923
}

test-workspace/fixtures/inputEmptyString/output.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ stack('this is an example', {
33
out: true,
44
});
55

6-
import exampleAsyncFunction from '../../stacks/exampleAsyncFunction';
6+
import convertStringToBoolean from '../../stacks/convertStringToBoolean';
77

8-
await exampleAsyncFunction('');
8+
await convertStringToBoolean('');
99

1010

1111
/**
1212
* Brief: this is an example
1313
*/
14-
export default async function exampleAsyncFunction(): Promise<string> {
15-
let result: string = "This is an example";
16-
return result;
14+
export default async function convertStringToBoolean(in: string): Promise<boolean> {
15+
if (in.toLowerCase() === 'true') return true;
16+
if (in.toLowerCase() === 'false') return false;
17+
throw new Error('Input must be a string of "true" or "false".');
1718
}

test-workspace/fixtures/simple/output.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ stack('this is an example', {
55

66

77

8-
import exampleAsyncFunction from '../../stacks/exampleAsyncFunction';
8+
import convertStringToBoolean from '../../stacks/convertStringToBoolean';
99

10-
await exampleAsyncFunction('this is an example');
10+
await convertStringToBoolean('this is an example');
1111

1212

1313

1414

1515
/**
1616
* Brief: this is an example
1717
*/
18-
export default async function exampleAsyncFunction(): Promise<string> {
19-
let result: string = "This is an example";
20-
return result;
18+
export default async function convertStringToBoolean(in: string): Promise<boolean> {
19+
if (in.toLowerCase() === 'true') return true;
20+
if (in.toLowerCase() === 'false') return false;
21+
throw new Error('Input must be a string of "true" or "false".');
2122
}

0 commit comments

Comments
 (0)