Skip to content

Commit

Permalink
refactor: rename the parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkChampagne17 committed Sep 21, 2023
1 parent 231afe8 commit 4b2fe59
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions packages/ts-nameof-proxy/src/name-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export function nameOf<T>(selector: NameSelector<T>): string;
export function nameOf<T>(obj: T, selector: NameSelector<T>): string;

export function nameOf<T>(
arg1: T | NameSelector<T>,
arg2?: NameSelector<T>
objOrSelector: T | NameSelector<T>,
selectorOrNil?: NameSelector<T>
): string {
// @ts-ignore
const names = namesOf(arg1, arg2);
const names = namesOf(objOrSelector, selectorOrNil);
if (names.length === 0) {
throw new Error("ts-nameof-proxy: No properties were read.");
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ts-nameof-proxy/src/names-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function namesOf<T>(selector: NameSelector<T>): string[];
export function namesOf<T>(obj: T, selector: NameSelector<T>): string[];

export function namesOf<T>(
arg1: T | NameSelector<T>,
arg2?: NameSelector<T>
objOrSelector: T | NameSelector<T>,
selectorOrNil?: NameSelector<T>
): string[] {
return pathsOf(arg1, arg2).map(last);
return pathsOf(objOrSelector, selectorOrNil).map(last);
}
6 changes: 3 additions & 3 deletions packages/ts-nameof-proxy/src/path-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function pathOf<T>(selector: NameSelector<T>): string[];
export function pathOf<T>(obj: T, selector?: NameSelector<T>): string[];

export function pathOf<T>(
arg1: T | NameSelector<T>,
arg2?: NameSelector<T>
objOrSelector: T | NameSelector<T>,
selectorOrNil?: NameSelector<T>
): string[] {
return pathsOf(arg1, arg2)[0] ?? [];
return pathsOf(objOrSelector, selectorOrNil)[0] ?? [];
}
6 changes: 3 additions & 3 deletions packages/ts-nameof-proxy/src/path-string-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export function pathStringOf<T>(selector: NameSelector<T>): string;
export function pathStringOf<T>(obj: T, selector: NameSelector<T>): string;

export function pathStringOf<T>(
arg1: T | NameSelector<T>,
arg2?: NameSelector<T>
objOrSelector: T | NameSelector<T>,
selectorOrNil?: NameSelector<T>
): string {
// @ts-ignore
const separatedPath = pathStringsOf(arg1, arg2);
const separatedPath = pathStringsOf(objOrSelector, selectorOrNil);
if (separatedPath.length === 0) {
throw new Error("ts-nameof-proxy: No properties were read.");
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ts-nameof-proxy/src/path-strings-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export function pathStringsOf<T>(selector: NameSelector<T>): string[];
export function pathStringsOf<T>(obj: T, selector: NameSelector<T>): string[];

export function pathStringsOf<T>(
arg1: T | NameSelector<T>,
arg2?: NameSelector<T>
objOrSelector: T | NameSelector<T>,
selectorOrNil?: NameSelector<T>
): string[] {
return pathsOf(arg1, arg2).map(mapper);
return pathsOf(objOrSelector, selectorOrNil).map(mapper);
}

function mapper(separatedPath: string[]) {
Expand Down
6 changes: 3 additions & 3 deletions packages/ts-nameof-proxy/src/paths-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export function pathsOf<T>(selector: NameSelector<T>): string[][];
export function pathsOf<T>(obj: T, selector?: NameSelector<T>): string[][];

export function pathsOf<T>(
arg1: T | NameSelector<T>,
arg2?: NameSelector<T>
objOrSelector: T | NameSelector<T>,
selectorOrNil?: NameSelector<T>
): string[][] {
const paths: string[][] = [];
const handler = generateProxyHandler(paths, true);
const proxy = new Proxy(emptyObj, handler);
const selector = (
typeof arg2 === "function" ? arg2 : arg1
typeof selectorOrNil === "function" ? selectorOrNil : objOrSelector
) as NameSelector<T>;
selector(proxy as T);
return paths;
Expand Down

0 comments on commit 4b2fe59

Please sign in to comment.