Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge commit '95da10a'

  • Loading branch information...
commit 29a71e3e366c82b6430b90a4d4b0a56bba23ecfb 2 parents 57fef1a + 95da10a
@mbebenita authored
Showing with 62 additions and 1 deletion.
  1. +62 −1 src/estransform.js
View
63 src/estransform.js
@@ -409,6 +409,67 @@
};
};
+ exports.makePass = function makePass(name, prop, backward) {
+ return function (o) {
+ var trans, arr;
+ var child, children = this._children;
+ var i, k;
+ for (var x = 0, j = children.length; x < j; x++) {
+ i = backward ? children.length - 1 - x : x;
+ if (!(child = this[children[i]])) {
+ continue;
+ }
+
+ if (child instanceof Array) {
+ arr = this[children[i]] = [];
+ var y;
+ for (var y = 0, l = child.length; y < l; y++) {
+ k = backward ? child.length - 1 - y : y;
+ if (!child[k]) {
+ if (backward) {
+ arr.unshift(child[k]);
+ } else {
+ arr.push(child[k]);
+ }
+ } else if (typeof child[k][name] === "function") {
+ trans = child[k][name](o);
+ if (trans !== null) {
+ if (backward) {
+ arr.unshift(trans);
+ } else {
+ arr.push(trans);
+ }
+ }
+ }
+ }
+ } else if (typeof child[name] === "function") {
+ trans = child[name](o);
+ if (trans === null) {
+ this[children[i]] = undefined;
+ } else {
+ this[children[i]] = trans;
+ }
+ }
+ }
+
+ if (typeof this[prop] === "function") {
+ if (o.logger && typeof this.loc !== "undefined") {
+ o.logger.push(this);
+ trans = this[prop](o);
+ o.logger.pop();
+ } else {
+ trans = this[prop](o);
+ }
+ if (trans === null) {
+ return null;
+ }
+ return trans ? trans : this;
+ }
+
+ return this;
+ };
+ };
+
exports.lift = function lift(raw) {
if (!raw) {
return raw;
@@ -416,7 +477,7 @@
if (raw instanceof Array) {
return raw.map(function (r) {
- return lift(r);
+ return r ? lift(r) : r;
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.