mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 05:52:57 +00:00
refactor: replace rfdc with native structuredClone
This commit is contained in:
@@ -76,8 +76,9 @@ export class ConnectorClient extends Client {
|
||||
* @param thing Thing to remove references from
|
||||
*/
|
||||
static removeReferences<THING extends SCThings>(thing: THING): SCAssociatedThingWithoutReferences<THING> {
|
||||
const thingWithoutReferences = JSON.parse(JSON.stringify(thing));
|
||||
const thingWithoutReferences = structuredClone(thing);
|
||||
|
||||
// @ts-expect-error it still thinks it's a thing with references
|
||||
delete thingWithoutReferences.origin;
|
||||
|
||||
// iterate over all properties
|
||||
@@ -134,7 +135,7 @@ export class ConnectorClient extends Client {
|
||||
}
|
||||
}
|
||||
|
||||
return thingWithoutReferences as SCAssociatedThingWithoutReferences<THING>;
|
||||
return thingWithoutReferences as unknown as SCAssociatedThingWithoutReferences<THING>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -378,7 +378,7 @@ describe('ConnectorClient', function () {
|
||||
);
|
||||
|
||||
for (const testInstance of testInstances) {
|
||||
const checkInstance = JSON.parse(JSON.stringify(testInstance));
|
||||
const checkInstance = structuredClone(testInstance);
|
||||
const testInstanceWithoutReferences = ConnectorClient.removeReferences(testInstance);
|
||||
|
||||
expect(doesContainThings(testInstanceWithoutReferences)).to.be.equal(
|
||||
|
||||
Reference in New Issue
Block a user