IsConcatSpreadable.js 626 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $isConcatSpreadable = GetIntrinsic('%Symbol.isConcatSpreadable%', true);
  4. var Get = require('./Get');
  5. var IsArray = require('./IsArray');
  6. var ToBoolean = require('./ToBoolean');
  7. var Type = require('./Type');
  8. // https://ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable
  9. module.exports = function IsConcatSpreadable(O) {
  10. if (Type(O) !== 'Object') {
  11. return false;
  12. }
  13. if ($isConcatSpreadable) {
  14. var spreadable = Get(O, $isConcatSpreadable);
  15. if (typeof spreadable !== 'undefined') {
  16. return ToBoolean(spreadable);
  17. }
  18. }
  19. return IsArray(O);
  20. };