source: node_modules/es-toolkit/dist/compat/_internal/isKey.js

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

Added visualizations

  • Property mode set to 100644
File size: 679 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const isSymbol = require('../predicate/isSymbol.js');
6
7const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
8const regexIsPlainProp = /^\w*$/;
9function isKey(value, object) {
10 if (Array.isArray(value)) {
11 return false;
12 }
13 if (typeof value === 'number' || typeof value === 'boolean' || value == null || isSymbol.isSymbol(value)) {
14 return true;
15 }
16 return ((typeof value === 'string' && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value))) ||
17 (object != null && Object.hasOwn(object, value)));
18}
19
20exports.isKey = isKey;
Note: See TracBrowser for help on using the repository browser.