New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

object-shape-tester

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-shape-tester - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

10

dist/cjs/define-shape/type-equality.js

@@ -5,6 +5,10 @@ "use strict";

const run_time_assertions_1 = require("run-time-assertions");
function haveEqualTypes(a, b) {
const constructorsMatch = a?.constructor === b?.constructor;
return (0, run_time_assertions_1.getRunTimeType)(a) === (0, run_time_assertions_1.getRunTimeType)(b) && constructorsMatch;
function haveEqualTypes(subject, shape) {
const shapeConstructor = shape?.constructor;
const subjectPrototype = subject?.constructor?.prototype;
const constructorsEqual = subject?.constructor === shapeConstructor;
const constructorsInstanceOf = shapeConstructor && subjectPrototype ? subjectPrototype instanceof shapeConstructor : false;
const constructorsMatch = constructorsEqual || constructorsInstanceOf;
return (0, run_time_assertions_1.getRunTimeType)(subject) === (0, run_time_assertions_1.getRunTimeType)(shape) && constructorsMatch;
}
exports.haveEqualTypes = haveEqualTypes;

@@ -241,4 +241,10 @@ "use strict";

if ((0, common_1.isObject)(shape)) {
const shapeKeys = new Set((0, common_1.getObjectTypedKeys)(shape));
const subjectKeys = new Set((0, common_1.getObjectTypedKeys)(subject));
const shapeKeys = new Set((0, common_1.getObjectTypedKeys)(shape));
shapeKeys.forEach((shapeKey) => {
// try to account for non-enumerable keys
if (shapeKey in subject) {
subjectKeys.add(shapeKey);
}
});
if (!options.ignoreExtraKeys) {

@@ -245,0 +251,0 @@ subjectKeys.forEach((subjectKey) => {

import { getRunTimeType } from 'run-time-assertions';
export function haveEqualTypes(a, b) {
const constructorsMatch = a?.constructor === b?.constructor;
return getRunTimeType(a) === getRunTimeType(b) && constructorsMatch;
export function haveEqualTypes(subject, shape) {
const shapeConstructor = shape?.constructor;
const subjectPrototype = subject?.constructor?.prototype;
const constructorsEqual = subject?.constructor === shapeConstructor;
const constructorsInstanceOf = shapeConstructor && subjectPrototype ? subjectPrototype instanceof shapeConstructor : false;
const constructorsMatch = constructorsEqual || constructorsInstanceOf;
return getRunTimeType(subject) === getRunTimeType(shape) && constructorsMatch;
}

@@ -236,4 +236,10 @@ import { combineErrorMessages, getObjectTypedKeys, isLengthAtLeast, isObject, mapObjectValues, } from '@augment-vir/common';

if (isObject(shape)) {
const shapeKeys = new Set(getObjectTypedKeys(shape));
const subjectKeys = new Set(getObjectTypedKeys(subject));
const shapeKeys = new Set(getObjectTypedKeys(shape));
shapeKeys.forEach((shapeKey) => {
// try to account for non-enumerable keys
if (shapeKey in subject) {
subjectKeys.add(shapeKey);
}
});
if (!options.ignoreExtraKeys) {

@@ -240,0 +246,0 @@ subjectKeys.forEach((subjectKey) => {

@@ -1,1 +0,1 @@

export declare function haveEqualTypes(a: unknown, b: unknown): boolean;
export declare function haveEqualTypes(subject: unknown, shape: unknown): boolean;
{
"name": "object-shape-tester",
"version": "2.3.1",
"version": "2.3.2",
"description": "Test object properties and value types.",

@@ -5,0 +5,0 @@ "keywords": [],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc