indexed-object.js 657 B

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