From 7bd05a76feb13ce643cd268b1e1d64c1d1a4a3c6 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 10 Sep 2024 13:04:17 +0200 Subject: [PATCH] Remove toPlainObject function. This function was originally implemented using Lodash' toPlainObject. I have personally never understood the use case of this function. --- src/data/Helper.ts | 10 ---------- src/data/orders/orderlines/OrderLine.ts | 16 ++-------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/data/Helper.ts b/src/data/Helper.ts index f03736f1..ce8dd060 100644 --- a/src/data/Helper.ts +++ b/src/data/Helper.ts @@ -35,16 +35,6 @@ export default class Helper>, U> { return this.networkClient.get(this.links.self.href); } - /** - * Converts this object to a plain one. - */ - public toPlainObject(this: Model): any { - // Previously, we used Lodash' toPlainObject here. However, back then we used classes for our models instead of - // interfaces. This should have the same effect on the new object as _.toPlainObject had on the old ones: returning - // a plain object with no prototype. - return Object.assign({}, this); - } - public get [Symbol.toStringTag]() { return capitalize((this as unknown as Model).resource); } diff --git a/src/data/orders/orderlines/OrderLine.ts b/src/data/orders/orderlines/OrderLine.ts index d0786be4..fac9ca22 100644 --- a/src/data/orders/orderlines/OrderLine.ts +++ b/src/data/orders/orderlines/OrderLine.ts @@ -149,12 +149,7 @@ export interface OrderLineData extends Model<'orderline'> { metadata: any; } -type OrderLine = Seal< - OrderLineData, - { - toPlainObject(): any; - } ->; +type OrderLine = Seal; export default OrderLine; @@ -184,12 +179,5 @@ export enum OrderLineType { } export function transform(input: OrderLineData): OrderLine { - return Object.assign( - Object.create({ - toPlainObject: function toPlainObject(this: Model): any { - return Object.assign({}, this); - }, - }), - input, - ); + return input; }