source: node_modules/es-toolkit/dist/compat/_internal/isKey.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: 576 bytes
Line 
1import { isSymbol } from '../predicate/isSymbol.mjs';
2
3const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
4const regexIsPlainProp = /^\w*$/;
5function isKey(value, object) {
6 if (Array.isArray(value)) {
7 return false;
8 }
9 if (typeof value === 'number' || typeof value === 'boolean' || value == null || isSymbol(value)) {
10 return true;
11 }
12 return ((typeof value === 'string' && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value))) ||
13 (object != null && Object.hasOwn(object, value)));
14}
15
16export { isKey };
Note: See TracBrowser for help on using the repository browser.