How to use the traverse.forEach 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 tjworks / angoose / lib / Exception.js View on Github external
function Exception(err, name){
    if(err instanceof Error){
        this.message = err.message;
        this.name = name || err.name;
        require('traverse')(err).forEach(function(){
            if(this.circular) this.remove();
        })
        this.cause = err;
        //this.cause = err;
        //delete this.cause.domain;  
    } 
    else{
        this.message = err;
        this.name =  name || '';    
    } 
}
util.inherits(Exception, Error);
github swisspush / apikana / src / generate.js View on Github external
.on('finish', function () {
                    traverse.forEach(completeApi, function (value) {
                        if (this.key === '$ref' && fileToType[value]) {
                            this.update('#/definitions/' + fileToType[value]);
                        }
                    });
                    var out = 'dist/model/openapi';
                    fse.mkdirsSync(out);
                    fs.writeFileSync(path.resolve(out, 'api.json'), JSON.stringify(restApi, null, 2));
                    fs.writeFileSync(path.resolve(out, 'api.yaml'), yaml.stringify(restApi, 6, 2));
                    fs.writeFileSync(path.resolve(out, 'complete-api.json'), JSON.stringify(completeApi, null, 2));
                    fs.writeFileSync(path.resolve(out, 'complete-api.yaml'), yaml.stringify(completeApi, 6, 2));
                });
        });
github swisspush / apikana / src / generate.js View on Github external
.on('finish', function () {
                    traverse.forEach(completeApi, function (value) {
                        if (this.key === '$ref' && fileToType[value]) {
                            this.update('#/definitions/' + fileToType[value]);
                        }
                    });
                    var out = path.resolve(dest, 'model/openapi');
                    fse.mkdirsSync(out);
                    fs.writeFileSync(path.resolve(out, 'api.json'), JSON.stringify(restApi, null, 2));
                    fs.writeFileSync(path.resolve(out, 'api.yaml'), yaml.stringify(restApi, 6, 2));
                    fs.writeFileSync(path.resolve(out, 'complete-api.json'), JSON.stringify(completeApi, null, 2));
                    fs.writeFileSync(path.resolve(out, 'complete-api.yaml'), yaml.stringify(completeApi, 6, 2));
                });
        });
github joola / joola / lib / dispatch / beacon.js View on Github external
async.map(documents, function(document, cb) {
      if (docCount === 0 || (docCount > 0 && (traverseFound || geoFound))) {
        traverse.forEach(document, function(x) {
          if (x && typeof x === 'object' && x.hasOwnProperty('value')) {
            traverseFound = true;
            this.update(x.value);
          }
        });
        docCount++;
      }
      return cb(null);
    }, function() {
      var d = domain.create();