How to use the traverse.clone function in traverse

To help you get started, we’ve selected a few traverse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crcn / node-awsm / lib / base / loadableCollection.js View on Github external
this.load({}, outcome.e(next).s(function(models) {

      // doesn't work for regexp

      if (typeof query === "object") {
        query = traverse.clone(query);
        // query = JSON.parse(JSON.stringify(query));

      }


      var sifter = sift(query);


      next(null, models.filter(function (model) {
        return sifter.test(model.context());
      }));
    }));
  },
github chinedufn / solid-state / index.js View on Github external
State.prototype.set = function (key, value) {
  if (arguments.length === 2) {
    // If a key and value were provided we use dot-prop
    dotProp.set(this.__ImmutableState__, key, value)
  } else {
    // If only a value was provided we overwrite state
    this.__ImmutableState__ = traverse.clone(key)
  }
  this.listeners(this.get())
}
github lyzidiamond / terrarium / instrument.js View on Github external
}
      if (node.trailingComments) {
        for (j = 0; j < node.trailingComments.length; j++) {
          comment = node.trailingComments[j];
          id = comment.range.join('-');
          if (!coveredComments[id] && isInstrumentComment(comment)) {
            pp(insertions, i + 1, instrumentCall(comment, type, tick));
            TODO.push(instrumentName(comment));
            coveredComments[id] = true;
          }
        }
      }
    }

    if (this.key === 'body') {
      var nextValue = traverse.clone(node);
      for (var k = 0; k < node.length; k++) {
        instrumentComments(node[k], k);
      }
      // inserting things in places is hard with arrays, since when you
      // push something into i, it changes the positions of other stuff.
      // we avoid this problem by
      // 1: doing batch insertions with splice
      // 2: iterating backwards
      insertions = pairs(insertions);
      insertions.sort(function(a, b) { return b[0] - a[0]; });
      for (var m = 0; m < insertions.length; m++) {
        nextValue.splice.apply(nextValue, [+insertions[m][0], 0].concat(insertions[m][1]));
      }
      this.update(nextValue);
    } else if (node && node.type === 'Program' && node.body.length === 0) {
      // a bare program consisting only of comments falls into this ditch:
github benatkin / outliner.js / public / vendor / bundle.js View on Github external
Hash.clone = function (ref) {
    return Traverse.clone(ref);
};
github fsiaonma / N-Builder / node_modules / hashish / index.js View on Github external
Hash.clone = function (ref) {
    return Traverse.clone(ref);
};
github nanha / nodejs_black_edition / lib / hashish.js View on Github external
Hash.clone = function (ref) {
    return Traverse.clone(ref);
};
github chinedufn / solid-state / index.js View on Github external
State.prototype.get = function () {
  return traverse.clone(this.__ImmutableState__)
}
github backstage / loopback-jsonschema / lib / http / ljs-request.js View on Github external
LJSRequest.prototype.safeHeaders = function() {
    var safeHeaders = traverse.clone(this.req.headers);
    if (safeHeaders.authorization) {
        safeHeaders.authorization = 'CONFIDENTIAL';
    }
    return safeHeaders;
};