From d186dce48408237b559e9e8295052ec6ca934655 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 30 Jun 2023 23:28:48 -0300 Subject: [PATCH] postman: add second argument for custom props --- packages/typescript/postman/src/postman/item.ts | 17 +++++++++-------- .../typescript/postman/src/postman/request.ts | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/typescript/postman/src/postman/item.ts b/packages/typescript/postman/src/postman/item.ts index 97bdb0882..a7988724b 100644 --- a/packages/typescript/postman/src/postman/item.ts +++ b/packages/typescript/postman/src/postman/item.ts @@ -6,6 +6,7 @@ export type Item = { group: Group requestId: RequestID href: string + props?: Partial }; export type FontItem = { @@ -22,39 +23,39 @@ export default { }; }, - image(href: string): Item { + image(href: string, props?: Partial): Item { return { priority: 2, group: 'images', requestId: 'image', - href + href, props }; }, - css(href: string): Item { + css(href: string, props?: Partial): Item { return { priority: 3, group: 'css', requestId: 'css', - href + href, props }; }, - script(href: string): Item { + script(href: string, props?: Partial): Item { return { priority: 4, group: 'scripts', requestId: 'script', - href + href, props }; }, - json(href: string): Item { + json(href: string, props?: Partial): Item { return { priority: 5, group: 'json', requestId: 'json', - href + href, props } }, diff --git a/packages/typescript/postman/src/postman/request.ts b/packages/typescript/postman/src/postman/request.ts index 8cb47a6d1..6db03b05e 100644 --- a/packages/typescript/postman/src/postman/request.ts +++ b/packages/typescript/postman/src/postman/request.ts @@ -47,6 +47,7 @@ export default { return fetch(href, fetchOptions()) .then((res) => res.text()) .then((text) => ({type: 'application/json', text})) + .then((props) => Object.assign(props, item.props || {})) .then((props) => Object.assign(document.createElement('script'), props)); } };