json.js 378 B

123456789101112131415161718
  1. 'use strict';
  2. var traverse = require('traverse');
  3. var id = 54;
  4. var callbacks = {};
  5. var obj = { moo: function () {}, foo: [2, 3, 4, function () {}] };
  6. var scrubbed = traverse(obj).map(function (x) {
  7. if (typeof x === 'function') {
  8. callbacks[id] = { id: id, f: x, path: this.path };
  9. this.update('[Function]');
  10. id++;
  11. }
  12. });
  13. console.dir(scrubbed);
  14. console.dir(callbacks);