Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blocksuite/global

Package Overview
Dependencies
Maintainers
5
Versions
1141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/global - npm Package Compare versions

Comparing version 0.4.0-20230124211050-22f6e52 to 0.4.0-20230125204655-410ba23

tests/utils.unit.ts

1

dist/utils.d.ts

@@ -20,3 +20,4 @@ export { isFirefox, isWeb, caretRangeFromPoint } from './utils/web.js';

export declare function assertEquals<T extends Allowed, U extends T>(val: T, expected: U): asserts val is U;
export declare function isEqual<T extends Allowed, U extends T>(val: T, expected: U): boolean;
export declare function sleep(ms: number): Promise<void>;
//# sourceMappingURL=utils.d.ts.map

18

dist/utils.js

@@ -30,2 +30,7 @@ export { isFirefox, isWeb, caretRangeFromPoint } from './utils/web.js';

export function assertEquals(val, expected) {
if (!isEqual(val, expected)) {
throw new Error('val is not same as expected');
}
}
export function isEqual(val, expected) {
const a = isPrimitive(val);

@@ -35,7 +40,7 @@ const b = isPrimitive(expected);

if (!Object.is(val, expected)) {
throw new Error('val is not same as expected');
return false;
}
}
else if (a !== b) {
throw new Error('val is not same as expected');
return false;
}

@@ -45,5 +50,5 @@ else {

if (val.length !== expected.length) {
throw new Error('val is not same as expected');
return false;
}
val.every((x, i) => assertEquals(x, expected[i]));
return val.every((x, i) => isEqual(x, expected[i]));
}

@@ -54,7 +59,8 @@ else if (typeof val === 'object' && typeof expected === 'object') {

if (obj1.length !== obj2.length) {
throw new Error('val is not same as expected');
return false;
}
obj1.every((x, i) => assertEquals(x, obj2[i]));
return obj1.every((x, i) => isEqual(x, obj2[i]));
}
}
return true;
}

@@ -61,0 +67,0 @@ export async function sleep(ms) {

{
"name": "@blocksuite/global",
"version": "0.4.0-20230124211050-22f6e52",
"version": "0.4.0-20230125204655-410ba23",
"types": "./index.d.ts",

@@ -5,0 +5,0 @@ "type": "module",

@@ -62,2 +62,11 @@ export { isFirefox, isWeb, caretRangeFromPoint } from './utils/web.js';

): asserts val is U {
if (!isEqual(val, expected)) {
throw new Error('val is not same as expected');
}
}
export function isEqual<T extends Allowed, U extends T>(
val: T,
expected: U
): boolean {
const a = isPrimitive(val);

@@ -67,12 +76,12 @@ const b = isPrimitive(expected);

if (!Object.is(val, expected)) {
throw new Error('val is not same as expected');
return false;
}
} else if (a !== b) {
throw new Error('val is not same as expected');
return false;
} else {
if (Array.isArray(val) && Array.isArray(expected)) {
if (val.length !== expected.length) {
throw new Error('val is not same as expected');
return false;
}
val.every((x, i) => assertEquals(x, expected[i]));
return val.every((x, i) => isEqual(x, expected[i]));
} else if (typeof val === 'object' && typeof expected === 'object') {

@@ -82,7 +91,8 @@ const obj1 = Object.entries(val as Record<string, unknown>);

if (obj1.length !== obj2.length) {
throw new Error('val is not same as expected');
return false;
}
obj1.every((x, i) => assertEquals(x, obj2[i]));
return obj1.every((x, i) => isEqual(x, obj2[i]));
}
}
return true;
}

@@ -89,0 +99,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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