1.0.9 • Published 3 years ago

launch-page v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Using fp-ts with puppeteer

:warning: DISCLAIMER :warning:

This was just a way to learn fp-ts library using puppeteer. The main learning-project is removed from repo.

Eventually I decided to separate the main library from programs.


launch-page centralizes the page for every operation you would do with puppeteer.

Installation

npm install launch-page

Usage

import { 
    LaunchOptions, launchPage
    } from 'launch-page/Puppeteer';
import { 
    log, startFrom 
    } from 'launch-page/utils';

const launchOptions: LaunchOptions = {
    headless: false,
    userDataDir: `path/to/userDataDir`,
    args: ["--lang=it"],
    defaultViewport: { width: 1050, height: 800 }
};

const program: WP.WebProgram<void> = WP.of(undefined);

// returns a `TE.TaskEither<Error, A>`,
// where `A` is the output of `program`.
const taskEitherOfProgram = 
    startFrom(program)(launchPage(launchOptions));

// returns a `TE.Task<void>`.
// Logs the result, taking into 
// account left type Error could have a 
// json message to format. (This is because
// I tried to format error message, keeping
// the stack)
const taskOfProgram = 
    log(startFrom(program)(launchPage(launchOptions)));

To run the two programs, simply call them, as defined for Task type in fp-ts.

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago