ysmood / yaku

A lightweight promise library
https://tonicdev.com/ysmood/yaku
MIT License
291 stars 28 forks source link

global.Promise should be non-enumerable and should have correct name property #56

Closed JakeChampion closed 4 years ago

JakeChampion commented 6 years ago

Expected:

> Object.getOwnPropertyDescriptor(global,'Promise');
{ value: [Function: Promise],
  writable: true,
  enumerable: false,
  configurable: true }

> global.Promise.name
'Promise'

Actual:

> Object.getOwnPropertyDescriptor(global,'Promise');
{ value:
   { [Function]
     default: [Circular],
     resolve: [Function],
     reject: [Function],
     race: [Function],
     all: [Function],
     Symbol: [Function: Symbol],
     speciesConstructor: [Function],
     unhandledRejection: [Function],
     rejectionHandled: [Function: en],
     enableLongStackTrace: [Function],
     nextTick: [Function: nextTick],
     _s: 1 },
  writable: true,
  enumerable: true,
  configurable: true }

> global.Promise.name
''
JakeChampion commented 6 years ago

core-js looks to have the enumerability bug but not the name property bug.

> delete global.Promise
true
> // loaded core-js shim.js file
> global.Promise.name
'Promise'
> Object.getOwnPropertyDescriptor(global,'Promise')
{ value: [Function: Promise],
  writable: true,
  enumerable: true,
  configurable: true }
ysmood commented 4 years ago

Sorry, yaku is not a shim, it's a standalone promise lib, I think this should not be supported. The design of this lib is to not pollute the global Promise at all.

Yaku will never override any global value. You easily wrap it with a function to make a shim lib based on yaku that fulfills your needs

JakeChampion commented 4 years ago

It is a shim, it has this file to make it a shim/polyfill -- https://github.com/ysmood/yaku/blob/871ca9376d0c2ba458530acc97b629ae172b935a/src/global.js#L1-L8

ysmood commented 4 years ago

Oh, sorry, I forget we have this file, it's an extra shortcut helper. I can fix this file though.

ysmood commented 4 years ago

@JakeChampion Thanks for the report, fixed and published v1.0.1, please check.