toFunctionName,
toLength,
toPrimitive,
+ toPropertyDescriptor,
type,
+ UNDEFINED,
} from "./value.js";
/**
*/
frozenCopy,
+ /**
+ * Returns the property descriptor record for the own property with
+ * the provided property key on the provided object, or null if none
+ * exists.
+ *
+ * ※ This is effectively an alias for
+ * `Object.getOwnPropertyDescriptor`, but the return value is a
+ * proxied object with null prototype.
+ */
+ getOwnPropertyDescriptor,
+
+ /**
+ * Returns the property descriptors for the own properties on the
+ * provided object.
+ *
+ * ※ This is effectively an alias for
+ * `Object.getOwnPropertyDescriptors`, but the values on the
+ * resulting object are proxied objects with null prototypes.
+ */
+ getOwnPropertyDescriptors,
+
/**
* Returns whether the provided object is frozen.
*
const {
create,
defineProperties,
+ getOwnPropertyDescriptor: objectGetOwnPropertyDescriptor,
getPrototypeOf,
isFrozen,
isSealed,
);
}
},
+ getOwnPropertyDescriptor: (O, P) => {
+ const desc = objectGetOwnPropertyDescriptor(O, P);
+ return desc === UNDEFINED
+ ? UNDEFINED
+ : toPropertyDescriptor(desc);
+ },
+ getOwnPropertyDescriptors: (O) => {
+ const obj = toObject(O);
+ const ownKeys = getOwnPropertyKeys(obj);
+ const descriptors = {};
+ for (let k = 0; k < ownKeys.length; ++k) {
+ const key = ownKeys[k];
+ defineOwnProperty(descriptors, key, {
+ configurable: true,
+ enumerable: true,
+ value: getOwnPropertyDescriptor(O, key),
+ writable: true,
+ });
+ }
+ return descriptors;
+ },
isUnfrozenObject: (O) => !isFrozen(O),
isUnsealedObject: (O) => !isSealed(O),
setPrototype: (O, proto) => {
}
};
-/**
- * Returns the property descriptor for the own property with the
- * provided property key on the provided object, or null if none
- * exists.
- *
- * ※ This is effectively an alias for
- * `Object.getOwnPropertyDescriptor`.
- */
-export const getOwnPropertyDescriptor = createArrowFunction(
- Object.getOwnPropertyDescriptor,
-);
-
-/**
- * Returns the property descriptors for the own properties on the
- * provided object.
- *
- * ※ This is effectively an alias for
- * `Object.getOwnPropertyDescriptors`.
- */
-export const getOwnPropertyDescriptors = createArrowFunction(
- Object.getOwnPropertyDescriptors,
-);
-
/**
* Returns an array of string‐valued own property keys on the
* provided object.