import { toPlainObject } from 'contentful-sdk-core' ; import copy from 'fast-copy' ; import { Collection , CollectionProp , CursorPaginatedCollection , CursorPaginatedCollectionProp , MakeRequest , } from './common-types' ; private export const wrapCollection = < R , T , Rest extends any [ ] > ( fn ) => ( makeRequest , data , ... rest ) : Collection < R , T > => { const collectionData = toPlainObject ( copy ( data ) ) ; collectionData . items = collectionData . items . map ( ( entity ) => fn ( makeRequest , entity , ... rest ) ) ; return collectionData ; } ; export const wrapCursorPaginatedCollection = < R , T , Rest extends any [ ] > ( fn ) => ( makeRequest , data , ... rest ) : CursorPaginatedCollection < R , T > => { const collectionData = toPlainObject ( copy ( data ) ) ; collectionData . items = collectionData . items . map ( ( entity ) => fn ( makeRequest , entity , ... rest ) ) ; return collectionData ; } ;