File: tests/lib/getProperties.ts

Recommend this page to a friend!
  Classes of Dom Hastings   JS Webdav Client   tests/lib/getProperties.ts   Download  
File: tests/lib/getProperties.ts
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: JS Webdav Client
Access files of a Webdav server
Author: By
Last change:
Date: 6 months ago
Size: 1,202 bytes
 

Contents

Class file image Download
import { ElementHandle } from 'puppeteer'; export const getRawProperty = async < T extends HTMLElement = HTMLElement, K extends keyof T = keyof T >( element: Promise<ElementHandle<T>> | ElementHandle<T>, property: K ): Promise<T[K]> => (await ( await (await element)?.getProperty(property as string) )?.jsonValue()) as T[K]; export const getRawProperties = async < T extends HTMLElement = HTMLElement, K extends keyof T = keyof T >( element: Promise<ElementHandle<T>> | ElementHandle<T>, ...properties: K[] ) => Promise.all(properties.map((property) => getRawProperty(element, property))); export const getRawPropertyFromMany = async < T extends HTMLElement = HTMLElement, K extends keyof T = keyof T >( elements: Promise<ElementHandle<T>[]> | ElementHandle<T>[], property: K ): Promise<T[K][]> => Promise.all( (await elements).map( async (element): Promise<any> => (['innerText', 'innerHTML'] as K[]).includes(property) ? await element?.evaluate<[string]>( (element: T, property: string) => element[property], property as string ) : getRawProperty<T, K>(element, property) ) );