UNPKG

600 BJavaScriptView Raw
1import copy from 'fast-copy';
2/**
3 * Mixes in a method to return just a plain object with no additional methods
4 * @private
5 * @param data - Any plain JSON response returned from the API
6 * @return Enhanced object with toPlainObject method
7 */
8export default function toPlainObject(data) {
9 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10 // @ts-expect-error
11 return Object.defineProperty(data, 'toPlainObject', {
12 enumerable: false,
13 configurable: false,
14 writable: false,
15 value: function () {
16 return copy(this);
17 },
18 });
19}