phantom-marmiton/docs/modules/utils_browser.md
2022-01-08 00:55:27 +01:00

101 lines
2.4 KiB
Markdown

[phantom-exo](../README.md) / [Modules](../modules.md) / utils/browser
# Module: utils/browser
## Table of contents
### Functions
- [optionsToUrlParams](utils_browser.md#optionstourlparams)
- [withBrowserOpened](utils_browser.md#withbrowseropened)
- [withPageOpened](utils_browser.md#withpageopened)
## Functions
### optionsToUrlParams
`Const` **optionsToUrlParams**<`T`, `V`\>(`opts`, `whitelist`): `string`
transform object to url parameters
array will write multiple time the same argument name
#### Type parameters
| Name | Type |
| :--- | :--------------------------------------- |
| `T` | `T` |
| `V` | extends `string` \| `number` \| `symbol` |
#### Parameters
| Name | Type | Description |
| :---------- | :---- | :----------------------- |
| `opts` | `T` | object to transform |
| `whitelist` | `V`[] | key to write from object |
#### Returns
`string`
#### Defined in
utils/browser.ts:50
---
### withBrowserOpened
`Const` **withBrowserOpened**<`T`\>(`func`): `Promise`<`T`\>
open a browser with puppeteer and call the parameter function within it
the browser will be closed after func execution
#### Type parameters
| Name |
| :--- |
| `T` |
#### Parameters
| Name | Type | Description |
| :----- | :---------------------------------------- | :------------------------------------------------------------------ |
| `func` | (`browser`: `Browser`) => `Promise`<`T`\> | function to execute after opening the browser and before closing it |
#### Returns
`Promise`<`T`\>
#### Defined in
utils/browser.ts:9
---
### withPageOpened
`Const` **withPageOpened**<`T`\>(`func`): `Promise`<`T`\>
open a page with puppeteer and call the parameter function within it
the page will be closed after func execution
#### Type parameters
| Name |
| :--- |
| `T` |
#### Parameters
| Name | Type | Description |
| :----- | :---------------------------------- | :------------------------------------------------------------- |
| `func` | (`page`: `Page`) => `Promise`<`T`\> | function to execute after opening a page and before closing it |
#### Returns
`Promise`<`T`\>
#### Defined in
utils/browser.ts:29