indexed-object.js 609 B

123456789101112131415
  1. var uncurryThis = require('../internals/function-uncurry-this');
  2. var fails = require('../internals/fails');
  3. var classof = require('../internals/classof-raw');
  4. var $Object = Object;
  5. var split = uncurryThis(''.split);
  6. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  7. module.exports = fails(function () {
  8. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  9. // eslint-disable-next-line no-prototype-builtins -- safe
  10. return !$Object('z').propertyIsEnumerable(0);
  11. }) ? function (it) {
  12. return classof(it) == 'String' ? split(it, '') : $Object(it);
  13. } : $Object;