unjs / unenv

๐Ÿ•Š๏ธ Convert javaScript code to be runtime agnostic
MIT License
358 stars 19 forks source link

feat: expose `__unenv__` flag for unenv classes and functions #125

Closed pi0 closed 1 year ago

pi0 commented 1 year ago

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

it is commonly required to identify if something is coming from unenv or not specially for classes and mocked objects.

This PR adds __unenv__ property to class (instances) and functions to identify.

Note: Since we were already using req.__unenv__ for another purpose (https://github.com/unjs/unenv/issues/72), the type for IncommingMessage and Readable classes is unknown/object.

๐Ÿ“ Checklist