Created
August 20, 2020 12:53
-
-
Save roytouw7/b0ee0cba7bb3e672c5453ff9503d9b45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isObjectOrSubjectConstructor: Classifier = classifierTemplate((node) => { | |
if (ts.isNewExpression(node) && ts.isIdentifier(node.expression)) { | |
if ([...rxjsObjectKinds, ...rxjsSubjectKinds].some(operator => operator === node.expression.getText())) { | |
return true; | |
} | |
} | |
return false; | |
}); | |
// Classify node by set of classifiers, if classified return true. | |
export const classify = (node: Touched<ts.Node>): RxJSPart => { | |
const classifiers: [Classifier, RxJSPart][] = [ | |
[isRxJSCreationOperator, RxJSPart.observable], | |
[isRxJSJoinCreationOperator, RxJSPart.observable], | |
[isObjectOrSubjectConstructor, RxJSPart.observable], | |
[isSubscribe, RxJSPart.subscriber], | |
[isPipeOperator, RxJSPart.pipeOperator] | |
]; | |
const classification = classifiers | |
.filter(tuple => tuple[0](node)) | |
.map(tuple => tuple[1]) | |
.pop(); | |
return classification ? classification : RxJSPart.unclassified; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment