UNPKG

contentful-sdk-core

Version:
1 lines 1.13 kB
{"version":3,"file":"to-plain-object.js","sources":["../../src/to-plain-object.ts"],"sourcesContent":["import copy from 'fast-copy'\n\n/**\n * Mixes in a method to return just a plain object with no additional methods\n * @private\n * @param data - Any plain JSON response returned from the API\n * @return Enhanced object with toPlainObject method\n */\nexport default function toPlainObject<T = Record<string, unknown>, R = T>(\n data: T,\n): T & {\n /**\n * Returns this entity as a plain JS object\n */\n toPlainObject(): R\n} {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n return Object.defineProperty(data, 'toPlainObject', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: function () {\n return copy(this)\n },\n })\n}\n"],"names":[],"mappings":";;AAEA;;;;;AAKG;AACW,SAAU,aAAa,CACnC,IAAO,EAAA;;;AASP,IAAA,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE;AAClD,QAAA,UAAU,EAAE,KAAK;AACjB,QAAA,YAAY,EAAE,KAAK;AACnB,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,KAAK,EAAE,YAAA;AACL,YAAA,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;AACF,KAAA,CAAC;AACJ;;;;"}