You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

safe-traverse.js 378B

12345678910111213141516
  1. "use strict";
  2. var value = require("./valid-value")
  3. , isValue = require("./is-value");
  4. module.exports = function (obj/*, …names*/) {
  5. var length, current = 1;
  6. value(obj);
  7. length = arguments.length - 1;
  8. if (!length) return obj;
  9. while (current < length) {
  10. obj = obj[arguments[current++]];
  11. if (!isValue(obj)) return undefined;
  12. }
  13. return obj[arguments[current]];
  14. };