jscodeshift
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -84,5 +84,5 @@ /* | ||
*/ | ||
Collection.prototype.filter=function(callback) { | ||
Object.defineProperty(Collection.prototype,"filter",{writable:true,configurable:true,value:function(callback) { | ||
return new this.constructor(this.__paths.filter(callback), this); | ||
}; | ||
}}); | ||
@@ -95,6 +95,6 @@ /** | ||
*/ | ||
Collection.prototype.forEach=function(callback) { | ||
Object.defineProperty(Collection.prototype,"forEach",{writable:true,configurable:true,value:function(callback) { | ||
this.__paths.forEach(function(path) {return callback.apply(path, arguments);}); | ||
return this; | ||
}; | ||
}}); | ||
@@ -114,3 +114,3 @@ /** | ||
*/ | ||
Collection.prototype.map=function(callback, type) { | ||
Object.defineProperty(Collection.prototype,"map",{writable:true,configurable:true,value:function(callback, type) { | ||
var paths = []; | ||
@@ -131,3 +131,3 @@ this.forEach(function(path) { | ||
return fromPaths(paths, this, type); | ||
}; | ||
}}); | ||
@@ -139,5 +139,5 @@ /** | ||
*/ | ||
Collection.prototype.size=function() { | ||
Object.defineProperty(Collection.prototype,"size",{writable:true,configurable:true,value:function() { | ||
return this.__paths.length; | ||
}; | ||
}}); | ||
@@ -149,11 +149,11 @@ /** | ||
*/ | ||
Collection.prototype.nodes=function() { | ||
Object.defineProperty(Collection.prototype,"nodes",{writable:true,configurable:true,value:function() { | ||
return this.__paths.map(function(p) {return p.value;}); | ||
}; | ||
}}); | ||
Collection.prototype.paths=function() { | ||
Object.defineProperty(Collection.prototype,"paths",{writable:true,configurable:true,value:function() { | ||
return this.__paths; | ||
}; | ||
}}); | ||
Collection.prototype.getAST=function() { | ||
Object.defineProperty(Collection.prototype,"getAST",{writable:true,configurable:true,value:function() { | ||
if (this.$Collection_parent) { | ||
@@ -163,5 +163,5 @@ return this.$Collection_parent.getAST(); | ||
return this.__paths; | ||
}; | ||
}}); | ||
Collection.prototype.toSource=function(options) { | ||
Object.defineProperty(Collection.prototype,"toSource",{writable:true,configurable:true,value:function(options) { | ||
if (this.$Collection_parent) { | ||
@@ -175,3 +175,3 @@ return this.$Collection_parent.toSource(); | ||
} | ||
}; | ||
}}); | ||
@@ -184,5 +184,5 @@ /** | ||
*/ | ||
Collection.prototype.at=function(index) { | ||
Object.defineProperty(Collection.prototype,"at",{writable:true,configurable:true,value:function(index) { | ||
return fromPaths(this.__paths.slice(index, index+1), this); | ||
}; | ||
}}); | ||
@@ -194,6 +194,6 @@ /** | ||
*/ | ||
Collection.prototype.get=function() { | ||
Object.defineProperty(Collection.prototype,"get",{writable:true,configurable:true,value:function() { | ||
var path = this.__paths[0]; | ||
return path.get.apply(path, arguments); | ||
}; | ||
}}); | ||
@@ -200,0 +200,0 @@ |
{ | ||
"name": "jscodeshift", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A toolkit for JavaScript codemods", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -36,3 +36,3 @@ # jscodeshift | ||
-c, --cpus (all by default) Determines the number of processes started. | ||
-v, --verbosity Repeate to show more information about the transform process [0] | ||
-v, --verbosity Show more information about the transform process [0] | ||
-d, --dry Dry run (no changes are made to files) | ||
@@ -176,5 +176,6 @@ -p, --print Print output, useful for development | ||
Recast itself relies heavily on [ast-types][] which defines methods to traverse the AST, access node fields and build new nodes. ast-types | ||
wraps every AST node into a *path object*. Paths contain meta-information and | ||
helper methods to process AST nodes. | ||
Recast itself relies heavily on [ast-types][] which defines methods to traverse | ||
the AST, access node fields and build new nodes. ast-types wraps every AST node | ||
into a *path object*. Paths contain meta-information and helper methods to | ||
process AST nodes. | ||
@@ -185,3 +186,4 @@ For example, the child-parent relationship between two nodes is not explicitly | ||
For more information about the path object API, please [ast-types][]. | ||
For more information about the path object API, please have a look at | ||
[ast-types][]. | ||
@@ -219,3 +221,6 @@ #### Builders | ||
Collections are "typed" which means that the type of a collection is the "lowest" type all AST nodes in the collection have in common. That means you cannot call a method for a `FunctionExpression` collection on a `Identifier` collection. | ||
Collections are "typed" which means that the type of a collection is the | ||
"lowest" type all AST nodes in the collection have in common. That means you | ||
cannot call a method for a `FunctionExpression` collection on a `Identifier` | ||
collection. | ||
@@ -253,7 +258,6 @@ Here is an example of how one would find/traverse all `Identifier` nodes with | ||
There are two types of extensions: generic extensions and type-specific | ||
extensions. Generic extensions are applicable to all collections. As such, they | ||
typically don't access specific node data, but rather traverse the AST from the | ||
nodes in the collection. | ||
Type-specific extensions work only on specific node types and are not callable | ||
on differently typed collections. | ||
extensions. **Generic extensions** are applicable to all collections. As such, | ||
they typically don't access specific node data, but rather traverse the AST from | ||
the nodes in the collection. **Type-specific** extensions work only on specific | ||
node types and are not callable on differently typed collections. | ||
@@ -260,0 +264,0 @@ #### Examples |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49453
21
1102
288