Version 1
[yaffs-website] / node_modules / grunt-legacy-log / node_modules / lodash / internal / isKey.js
diff --git a/node_modules/grunt-legacy-log/node_modules/lodash/internal/isKey.js b/node_modules/grunt-legacy-log/node_modules/lodash/internal/isKey.js
new file mode 100644 (file)
index 0000000..44ccfd4
--- /dev/null
@@ -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;