Consolidate object vs primitive testing
MODIFY
packages/ses/src/commons.js
packages/ses/src/commons.js
@@ -219,7 +219,7 @@ export const getConstructorOf = fn =>
/**
* immutableObject
- * An immutable (frozen) exotic object and is safe to share.
+ * An immutable (frozen) empty object that is safe to share.
*/
export const immutableObject = freeze(create(null));

MODIFY
packages/ses/src/intrinsics.js
packages/ses/src/intrinsics.js
import {
- Object,
TypeError,
WeakSet,
arrayFilter,
@@ -10,6 +9,7 @@ import {
getOwnPropertyDescriptors,
globalThis,
is,
+ isObject,
objectHasOwnProperty,
values,
weaksetHas,
@@ -83,7 +83,7 @@ export const makeIntrinsicsCollector = () => {
// to the intrinsics.
const completePrototypes = () => {
for (const [name, intrinsic] of entries(intrinsics)) {
- if (intrinsic !== Object(intrinsic)) {
+ if (!isObject(intrinsic)) {
// eslint-disable-next-line no-continue
continue;
}

MODIFY
packages/ses/src/tame-locale-methods.js
packages/ses/src/tame-locale-methods.js
import {
- Object,
String,
TypeError,
defineProperty,
getOwnPropertyNames,
+ isObject,
regexpExec,
} from './commons.js';
import { assert } from './error/assert.js';
@@ -51,7 +51,7 @@ export default function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
for (const intrinsicName of getOwnPropertyNames(intrinsics)) {
const intrinsic = intrinsics[intrinsicName];
- if (intrinsic === Object(intrinsic)) {
+ if (isObject(intrinsic)) {
for (const methodName of getOwnPropertyNames(intrinsic)) {
const match = regexpExec(localePattern, methodName);
if (match) {

Consolidate object vs primitive testing (#888)