Skip to content

Commit

Permalink
Merge pull request #362 from mollie/pimm/no-to-plain-object
Browse files Browse the repository at this point in the history
Remove toPlainObject function
  • Loading branch information
janpaepke authored Sep 10, 2024
2 parents 476dc50 + d3c0f70 commit a8d0ed2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
10 changes: 0 additions & 10 deletions src/data/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ export default class Helper<R extends Model<string, Maybe<string>>, U> {
return this.networkClient.get<R, U>(this.links.self.href);
}

/**
* Converts this object to a plain one.
*/
public toPlainObject(this: Model<string>): 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<string>).resource);
}
Expand Down
16 changes: 2 additions & 14 deletions src/data/orders/orderlines/OrderLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,7 @@ export interface OrderLineData extends Model<'orderline'> {
metadata: any;
}

type OrderLine = Seal<
OrderLineData,
{
toPlainObject(): any;
}
>;
type OrderLine = Seal<OrderLineData, {}>;

export default OrderLine;

Expand Down Expand Up @@ -184,12 +179,5 @@ export enum OrderLineType {
}

export function transform(input: OrderLineData): OrderLine {
return Object.assign(
Object.create({
toPlainObject: function toPlainObject(this: Model<any>): any {
return Object.assign({}, this);
},
}),
input,
);
return input;
}

0 comments on commit a8d0ed2

Please sign in to comment.