source: node_modules/es-toolkit/dist/compat/predicate/isNative.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 680 bytes
Line 
1const functionToString = Function.prototype.toString;
2const REGEXP_SYNTAX_CHARS = /[\\^$.*+?()[\]{}|]/g;
3const IS_NATIVE_FUNCTION_REGEXP = RegExp(`^${functionToString
4 .call(Object.prototype.hasOwnProperty)
5 .replace(REGEXP_SYNTAX_CHARS, '\\$&')
6 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?')}$`);
7function 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
17export { isNative };
Note: See TracBrowser for help on using the repository browser.