|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
680 bytes
|
| Line | |
|---|
| 1 | const functionToString = Function.prototype.toString;
|
|---|
| 2 | const REGEXP_SYNTAX_CHARS = /[\\^$.*+?()[\]{}|]/g;
|
|---|
| 3 | const IS_NATIVE_FUNCTION_REGEXP = RegExp(`^${functionToString
|
|---|
| 4 | .call(Object.prototype.hasOwnProperty)
|
|---|
| 5 | .replace(REGEXP_SYNTAX_CHARS, '\\$&')
|
|---|
| 6 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?')}$`);
|
|---|
| 7 | function isNative(value) {
|
|---|
| 8 | if (typeof value !== 'function') {
|
|---|
| 9 | return false;
|
|---|
| 10 | }
|
|---|
| 11 | if (globalThis?.['__core-js_shared__'] != null) {
|
|---|
| 12 | throw new Error('Unsupported core-js use. Try https://npms.io/search?q=ponyfill.');
|
|---|
| 13 | }
|
|---|
| 14 | return IS_NATIVE_FUNCTION_REGEXP.test(functionToString.call(value));
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | export { isNative };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.