Skip to content

Commit

Permalink
feat: now requires typescript argument T for input type
Browse files Browse the repository at this point in the history
  • Loading branch information
dalisoft committed Oct 17, 2021
1 parent 1158c0c commit e1dabac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import eachStringLine from './utils/each-str-line';
import functionToString from './utils/fn-to-string';
import stringSplit from './utils/string-split';

function analyze(func: (...args: never[]) => never): IBlock[] {
function analyze<T>(func: T): IBlock[] {
const blocks: IBlock[] = [];
eachStringLine(
babelCompilerManipulationNormalize(functionToString(func)),
babelCompilerManipulationNormalize(functionToString<T>(func)),
(line, index) => {
const caseFinder = caseRequestModeFinder(line, index);

Expand Down
6 changes: 2 additions & 4 deletions src/utils/fn-to-string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export default function functionToString(
func: (...args: never[]) => never
): string {
return func.toString().trim();
export default function functionToString<T>(func: T): string {
return (func as any).toString().trim();
}

0 comments on commit e1dabac

Please sign in to comment.