key-of.js 271 B

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