Skip to content

Commit

Permalink
Refactor method names
Browse files Browse the repository at this point in the history
  • Loading branch information
papb committed Sep 16, 2020
1 parent 565fab0 commit 8b83798
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions source/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ function pick(tree: any, field: string): any {
return tree[field];
}

function treeShortcutHelperHelper(tree: any, from: string, to: string, name: string): any {
if (Array.isArray(tree)) return tree.map(x => treeShortcutHelperHelper(x, from, to, name));
function treeShortcutHelper(tree: any, from: string, to: string, name: string): any {
if (Array.isArray(tree)) return tree.map(x => treeShortcutHelper(x, from, to, name));
if (!tree || typeof tree !== 'object') return tree;

const keys = Object.keys(tree);
const result: any = {};

for (const key of keys) {
if (key !== from) {
result[key] = treeShortcutHelperHelper(tree[key], from, to, name);
result[key] = treeShortcutHelper(tree[key], from, to, name);
}
}

Expand All @@ -55,7 +55,7 @@ function treeShortcutHelperHelper(tree: any, from: string, to: string, name: str
return result;
}

export function treeShortcutHelper<
export function treeShortcut<
Tree,
ShortcutTriggerProp extends string,
ShortcutTargetProp extends string,
Expand All @@ -66,5 +66,5 @@ export function treeShortcutHelper<
shortcutTargetProp: ShortcutTargetProp,
shortcutName: ShortcutName,
): TreeShortcut<Tree, ShortcutTriggerProp, ShortcutTargetProp, ShortcutName> {
return treeShortcutHelperHelper(tree, shortcutTriggerProp, shortcutTargetProp, shortcutName);
return treeShortcutHelper(tree, shortcutTriggerProp, shortcutTargetProp, shortcutName);
}
4 changes: 2 additions & 2 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { treeShortcutHelper } from './core';
import { treeShortcut } from './core';

export = treeShortcutHelper;
export = treeShortcut;

0 comments on commit 8b83798

Please sign in to comment.