CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
isPlainObject.js63 linesDownload Raw Back to lodash
1var baseGetTag = require('./_baseGetTag'),2    getPrototype = require('./_getPrototype'),3    isObjectLike = require('./isObjectLike');4 5/** `Object#toString` result references. */6var objectTag = '[object Object]';7 8/** Used for built-in method references. */9var funcProto = Function.prototype,10    objectProto = Object.prototype;11 12/** Used to resolve the decompiled source of functions. */13var funcToString = funcProto.toString;14 15/** Used to check objects for own properties. */16var hasOwnProperty = objectProto.hasOwnProperty;17 18/** Used to infer the `Object` constructor. */19var objectCtorString = funcToString.call(Object);20 21/**22 * Checks if `value` is a plain object, that is, an object created by the23 * `Object` constructor or one with a `[[Prototype]]` of `null`.24 *25 * @static26 * @memberOf _27 * @since 0.8.028 * @category Lang29 * @param {*} value The value to check.30 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.31 * @example32 *33 * function Foo() {34 *   this.a = 1;35 * }36 *37 * _.isPlainObject(new Foo);38 * // => false39 *40 * _.isPlainObject([1, 2, 3]);41 * // => false42 *43 * _.isPlainObject({ 'x': 0, 'y': 0 });44 * // => true45 *46 * _.isPlainObject(Object.create(null));47 * // => true48 */49function isPlainObject(value) {50  if (!isObjectLike(value) || baseGetTag(value) != objectTag) {51    return false;52  }53  var proto = getPrototype(value);54  if (proto === null) {55    return true;56  }57  var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;58  return typeof Ctor == 'function' && Ctor instanceof Ctor &&59    funcToString.call(Ctor) == objectCtorString;60}61 62module.exports = isPlainObject;63 
basant307/AI_Governance_Project · CoolFace