key-of.js 290 B

1234567891011121314151617
  1. "use strict";
  2. var eq = require("./eq")
  3. , some = require("./some");
  4. module.exports = function (obj, searchValue) {
  5. var result;
  6. return some(obj, function (value, name) {
  7. if (eq(value, searchValue)) {
  8. result = name;
  9. return true;
  10. }
  11. return false;
  12. })
  13. ? result
  14. : null;
  15. };