Skip to content

Commit 07c9cb5

Browse files
committed
chore: rename main func
1 parent 091b70b commit 07c9cb5

13 files changed

Lines changed: 105 additions & 105 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type DropFirst<T extends readonly unknown[]> = T extends readonly [unknown, ...i
99
* @param {string} Args - A value of `process.argv`.
1010
* @returns A filtered `process.argv` with only options and their values.
1111
*/
12-
export function PreProcessing<Args extends typeof Process.argv>(Args: Args): DropFirstANDTwo<Args> | DropFirst<Args> {
12+
export function FilterArgumentsForOptions<Args extends typeof Process.argv>(Args: Args): DropFirstANDTwo<Args> | DropFirst<Args> {
1313
if (Args[2].startsWith('--')) {
1414
return Args.slice(2) as DropFirstANDTwo<Args>
1515
} else {

sources/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export { PostProcessing } from './postprocessing/index.js'
1+
export { ParseArgumentsAndOptions } from './parse-args/index.js'
22

3-
export { PreProcessing } from './preprocessing/index.js'
3+
export { FilterArgumentsForOptions } from './filter-args/index.js'
44

55
export type { JSONValue, JSONArray, JSONObject, JSONPrimitive, IParsingOptions } from './types.js'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { JSONValue, IParsingOptions } from '../types.js'
99
* @param FuncOptions - Configuration for post-processing behavior, such as the naming convention transformer.
1010
* @returns A promise resolving to an object containing the parsed options and remaining positional arguments.
1111
*/
12-
export async function PostProcessing<I extends JSONValue>(Args: string[], FuncOptions: IParsingOptions = {
12+
export async function ParseArgumentsAndOptions<I extends JSONValue>(Args: string[], FuncOptions: IParsingOptions = {
1313
NamingConvention: ESToolkit.pascalCase
1414
}): Promise<{ Options: I, Positional: string[] }> {
1515
const Options: Record<string, boolean | string> = Object.create(null)
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import test from 'ava'
2-
import { PreProcessing } from '@/index.js'
2+
import { FilterArgumentsForOptions } from '@/index.js'
33

4-
test('PreProcessing strips Node executable from argv (nvm and 24.11.1)', T => {
4+
test('FilterArgumentsForOptions strips Node executable from argv (nvm and 24.11.1)', T => {
55
let Input = ['/usr/local/share/nvm/versions/node/v24.11.1/bin/node', '/path/to/node.js', '--sample', 'sample1']
66
let Expected = ['--sample', 'sample1']
77

8-
let Processed = PreProcessing(Input)
8+
let Processed = FilterArgumentsForOptions(Input)
99
T.deepEqual(Processed, Expected)
1010
})
1111

12-
test('PreProcessing strips Node executable from argv (alpine package manager)', T => {
12+
test('FilterArgumentsForOptions strips Node executable from argv (alpine package manager)', T => {
1313
let Input = ['/usr/bin/node', '/path/to/node.js', '--sample', 'sample1']
1414
let Expected = ['--sample', 'sample1']
1515

16-
let Processed = PreProcessing(Input)
16+
let Processed = FilterArgumentsForOptions(Input)
1717
T.deepEqual(Processed, Expected)
1818
})
1919

20-
test('PreProcessing strips Node executable from argv (node:24-alpine container)', T => {
20+
test('FilterArgumentsForOptions strips Node executable from argv (node:24-alpine container)', T => {
2121
let Input = ['/usr/local/bin/node', '/path/to/node.js', '--sample', 'sample1']
2222
let Expected = ['--sample', 'sample1']
2323

24-
let Processed = PreProcessing(Input)
24+
let Processed = FilterArgumentsForOptions(Input)
2525
T.deepEqual(Processed, Expected)
2626
})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import test from 'ava'
2+
import { FilterArgumentsForOptions } from '@/index.js'
3+
4+
test('FilterArgumentsForOptions strips Node executable from argv (nvm and 24.11.1)', T => {
5+
let Input = ['/usr/local/share/nvm/versions/node/v24.11.1/bin/node', '--sample', 'sample1']
6+
let Expected = ['--sample', 'sample1']
7+
8+
let Processed = FilterArgumentsForOptions(Input)
9+
T.deepEqual(Processed, Expected)
10+
})
11+
12+
test('FilterArgumentsForOptions strips Node executable from argv (alpine package manager)', T => {
13+
let Input = ['/usr/bin/node', '--sample', 'sample1']
14+
let Expected = ['--sample', 'sample1']
15+
16+
let Processed = FilterArgumentsForOptions(Input)
17+
T.deepEqual(Processed, Expected)
18+
})
19+
20+
test('FilterArgumentsForOptions strips Node executable from argv (node:24-alpine container)', T => {
21+
let Input = ['/usr/local/bin/node', '--sample', 'sample1']
22+
let Expected = ['--sample', 'sample1']
23+
24+
let Processed = FilterArgumentsForOptions(Input)
25+
T.deepEqual(Processed, Expected)
26+
})

tests/postprocessing/boolean-parameter.test.ts renamed to tests/parse-args/boolean-parameter.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import { PostProcessing } from '@/index.js'
2+
import { ParseArgumentsAndOptions } from '@/index.js'
33

44
test('boolean flag located at beginning without value should be true', async T => {
55
let Input = ['--enable-feature', '--parameter', 'value']
@@ -8,7 +8,7 @@ test('boolean flag located at beginning without value should be true', async T =
88
Parameter: 'value'
99
}
1010

11-
T.deepEqual(await PostProcessing(Input), { Options: Expected, Positional: []})
11+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: []})
1212
})
1313

1414
test('boolean flag located at end without value should be true', async T => {
@@ -18,7 +18,7 @@ test('boolean flag located at end without value should be true', async T => {
1818
EnableFeature: true
1919
}
2020

21-
T.deepEqual(await PostProcessing(Input), { Options: Expected, Positional: []})
21+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: []})
2222
})
2323

2424
test('boolean flag located in middle without value should be true', async T => {
@@ -29,5 +29,5 @@ test('boolean flag located in middle without value should be true', async T => {
2929
Parameter2: 'value2'
3030
}
3131

32-
T.deepEqual(await PostProcessing(Input), { Options: Expected, Positional: []})
32+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: []})
3333
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import test from 'ava'
2+
import { ParseArgumentsAndOptions } from '@/index.js'
3+
4+
test('ParseArgumentsAndOptions a single parameter',async T => {
5+
let Input = ['--Parameter1', 'Value1', '--Parameter2', 'Value2', '--', '--deserunt', 'tempor', '--dolor', 'tempor']
6+
let Expected = {
7+
Parameter1: 'Value1',
8+
Parameter2: 'Value2'
9+
}
10+
11+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: ['--deserunt', 'tempor', '--dolor', 'tempor']})
12+
})
13+
14+
test('ParseArgumentsAndOptions a single parameter with no upper case', async T => {
15+
let Input = ['--parameter1', 'value1', '--parameter2', 'value2', '--', '--deserunt', 'tempor', '--dolor', 'tempor']
16+
let Expected = {
17+
Parameter1: 'value1',
18+
Parameter2: 'value2'
19+
}
20+
21+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: ['--deserunt', 'tempor', '--dolor', 'tempor']})
22+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import test from 'ava'
2+
import { ParseArgumentsAndOptions } from '@/index.js'
3+
4+
test('ParseArgumentsAndOptions a single parameter', async T => {
5+
let Input = ['--Parameter1', 'Value1']
6+
let Expected = {
7+
Parameter1: 'Value1'
8+
}
9+
10+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: []})
11+
})
12+
13+
test('ParseArgumentsAndOptions a single parameter with no upper case', async T => {
14+
let Input = ['--parameter1', 'value1']
15+
let Expected = {
16+
Parameter1: 'value1'
17+
}
18+
19+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: []})
20+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import test from 'ava'
2+
import { ParseArgumentsAndOptions } from '@/index.js'
3+
4+
test('ParseArgumentsAndOptions a single parameter',async T => {
5+
let Input = ['--Parameter1', 'Value1', '--Parameter2', 'Value2']
6+
let Expected = {
7+
Parameter1: 'Value1',
8+
Parameter2: 'Value2'
9+
}
10+
11+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: []})
12+
})
13+
14+
test('ParseArgumentsAndOptions a single parameter with no upper case', async T => {
15+
let Input = ['--parameter1', 'value1', '--parameter2', 'value2']
16+
let Expected = {
17+
Parameter1: 'value1',
18+
Parameter2: 'value2'
19+
}
20+
21+
T.deepEqual(await ParseArgumentsAndOptions(Input), { Options: Expected, Positional: []})
22+
})

tests/postprocessing/remaining-normal-value.test.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)