Open 2zH opened 6 years ago
const astTypes = recast.types;
var types = astTypes.namedTypes;
const NodePath = astTypes.NodePath;
const Node = types.Node;
class Collection { ... }
function _inferTypes(paths) { ... }
function _toTypeArray(value) { ... }
function fromPaths(paths, parent, type) { ... }
function fromNodes(nodes, parent, type) { ... }
const CPt = Collection.prototype;
function registerMethods(methods, type) { ... }
function installTypedMethod(methodName) { ... }
function hasConflictingRegistration(methodName, type) { ... }
var _defaultType = []
function setDefaultCollectionType(type) { ... }
exports.fromPaths = fromPaths;
exports.fromNodes = fromNodes;
exports.registerMethods = registerMethods;
exports.hasConflictingRegistration = hasConflictingRegistration;
exports.setDefaultCollectionType = setDefaultCollectionType;
class Collection:
class Collection {
constructor(paths, parent, types)
filter(callback)
some(callback)
every(callback)
map(callback, type)
size()
get length()
nodes()
paths()
getAST()
toSource(options)
at(index)
get()
getTypes()
isOfType(type)
}
fromPaths:
Creates a new collection from an array of node paths.
registerMethods:
This function adds the provided methods to the prototype of the corresponding typed collection.
traversalMethods:
mutationMethods:
globalMethods:
filterMethods:
transformMethods:
globalMethods:
filterMethods:
traversalMethods:
mappingMethods:
Directory Structure:
main of dependencies:
recipes: https://github.com/facebook/jscodeshift/blob/master/recipes/retain-first-comment.md