Skip to content

Commit

Permalink
Simplify docs of UtilInherits
Browse files Browse the repository at this point in the history
Refs #33
  • Loading branch information
nene committed Sep 16, 2016
1 parent 054091f commit 3160772
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/transform/class/inheritance/UtilInherits.js
Expand Up @@ -7,9 +7,9 @@ import isVarWithRequireCalls from '../../../utils/isVarWithRequireCalls';
* transformation.
*
* Detects:
*
* var util = require('util');
* function Class1() {}
* function Class2() {}
* ...
* util.inherits(Class1, Class2);
*/
export default class UtilInherits {
Expand Down Expand Up @@ -48,8 +48,6 @@ export default class UtilInherits {
// Will store the discovered nodes in:
// this.utilNode
// this.inheritsNode
//
// @param {Object} node
discoverIdentifiers(node) {
const declaration = _.find(node.declarations, (dec) =>
isAstMatch(dec, {
Expand Down Expand Up @@ -83,14 +81,8 @@ export default class UtilInherits {

// Discover usage of this.utilNode or this.inheritsNode
//
// Examples:
// util.inherits(Class, SuperClass);
// inherits(Class, SuperClass);
//
// @param {Object} node
// @return {Object} m
// {String} m.className
// {Node} m.superClass
// Matches: util.inherits(<className>, <superClass>);
// Matches: inherits(<className>, <superClass>);
match(node) {
return isAstMatch(node, {
type: 'ExpressionStatement',
Expand All @@ -108,15 +100,15 @@ export default class UtilInherits {
});
}

// Match example: inherits
// Matches: inherits
matchesInherits(callee) {
return this.inheritsNode && isAstMatch(callee, {
type: 'Identifier',
name: this.inheritsNode.name
});
}

// Match example: util.inherits
// Matches: util.inherits
matchesUtil(callee) {
return this.utilNode && isAstMatch(callee, {
type: 'MemberExpression',
Expand Down

0 comments on commit 3160772

Please sign in to comment.