diff options
Diffstat (limited to 'deps/npm/node_modules/cli-table2/node_modules/lodash/internal/isKey.js')
-rw-r--r-- | deps/npm/node_modules/cli-table2/node_modules/lodash/internal/isKey.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cli-table2/node_modules/lodash/internal/isKey.js b/deps/npm/node_modules/cli-table2/node_modules/lodash/internal/isKey.js new file mode 100644 index 0000000000..44ccfd4894 --- /dev/null +++ b/deps/npm/node_modules/cli-table2/node_modules/lodash/internal/isKey.js @@ -0,0 +1,28 @@ +var isArray = require('../lang/isArray'), + toObject = require('./toObject'); + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + var type = typeof value; + if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') { + return true; + } + if (isArray(value)) { + return false; + } + var result = !reIsDeepProp.test(value); + return result || (object != null && value in toObject(object)); +} + +module.exports = isKey; |