npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@a-2-c-2-anpm/vel-fugiat-consectetur

v1.0.0

Published

[![NPM Version](http://img.shields.io/npm/v/@a-2-c-2-anpm/vel-fugiat-consectetur.svg?style=flat-square)](https://npmjs.com/package/@a-2-c-2-anpm/vel-fugiat-consectetur) [![License](http://img.shields.io/npm/l/@a-2-c-2-anpm/vel-fugiat-consectetur.svg?style

Downloads

9

Maintainers

tranduc345zztranduc345zz

Keywords

logginglanguagenpmajaxebsqueryflattenES3assertionnopecensorrdsstatelesswrapMapArray.prototype.flatMaphttpsnamesbrowsercommandlengthtoArrayconcatMapfind-upserializernumberasciiECMAScript 2017jasmineStyleSheetpolyfillfindLastposecommanderreact-hook-formawscacheobjectsymboljoienumerableArrayBuffer.prototype.slicebyteLengthJSON-Schemaobjrm -frviewWeakSetnegative zerobuffersES2023reducemapreduceupES8swfshimenderassignes7rangeerrorpluginlazyfast-deep-clonedefineglacierObject.entriesconsolemaphelperkinesisArray.prototype.flattypesafepackagedebugsequenceECMAScript 2018setArrayBufferfunction.lengthsharedarraybufferinstallermergeshamObject.getPrototypeOfcliutilityeventEmitterlimitfullwidthchildES2016jsonairbnbterminaliteratemanagerredactfinduppropconfigurablees-shimsspinnerssimpledbrmregular-expressionespreeECMAScript 2019css-in-jscharacterfunctionprogressparserspeces-abstractspringdirflagsexpressionbindautoscalingdom-testing-libraryfull-widthstringifygetlockfilepackage.jsonfastclonetelephoneperformancevalueisConcatSpreadableslotenvironmentremovethrottleartredirectYAMLes2015minimalpackage managertddinstallwidthtostringtaglintgroupCSSESses_.extendlasthttpworkflowdeletevalidatejestObjectmobileUint8ClampedArrayES5ponyfilltoolkitArrayBuffer#slicestyled-componentsscheme-validationECMAScript 2020schemetrimdragtc39testercallbindfunctionsfigletarraybuffer0nameatommulti-packagetransformrecursiveoptimizercjkpackages__proto__modulewgetmkdirsjsxextracall-boundglobalcall-bindresolvehtmlInt8ArrayshebangclientcopyquotebinaryHyBisubprocessprotocol-buffersdataviewhigher-orderdeep-clonezodECMAScript 2021-0taskintrinsiccloudwatchvestformates5formattingendpointbddfindLastIndextypeofimmutabledata

Readme

@a-2-c-2-anpm/vel-fugiat-consectetur

NPM Version License Build Status

Evaluate a script function on a page with Chrome

This module let you evaluate a script function on a page using Chrome (controlled with puppeteer) and get the return value of the evaluation in node.

Usage

<!-- sample.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Test page</title>
</head>
<body>
  <div class="content">1</div>
  <div class="content">2</div>
  <div class="content">3</div>
  <div class="content">4</div>
</body>
</html>
const puppeteer = require('puppeteer')
const chromePageEval = require('@a-2-c-2-anpm/vel-fugiat-consectetur')
const chromeEval = chromePageEval({ puppeteer })

(async () => {
  try {
    const result = await chromeEval({
      html: '/path/to/sample.html',
      scriptFn: `
        function () {
          let title = document.title

          let content = Array.from(document.querySelectorAll('.content'), (node) => {
            return node.textContent
          })

          return {
            title,
            content
          }
        }
      `
    })

    console.log(result.title) // -> Test page
    console.log(result.content) // -> [1, 2, 3, 4]
  } catch (e) {
    console.error('Error while trying to evaluate script:', e)
  }
})()

Constructor options

const chromePageEval = require('@a-2-c-2-anpm/vel-fugiat-consectetur')
const chromeEval = chromePageEval({ /*[constructor options here]*/ })

Evaluate options

const puppeteer = require('puppeteer')
const chromePageEval = require('@a-2-c-2-anpm/vel-fugiat-consectetur')
const chromeEval = chromePageEval({ puppeteer })

(async () => {
  const result = await chromeEval({ /*[evaluate options here]*/ })
})()
  • html string [required] - the path to the html file to load in a Chrome page
  • scriptFn string [required] - the script to evaluate in the Chrome page. the script must be a function that returns a value. ex: scriptFn: 'function () { return 1 + 2}'
  • viewport object - object with any of the viewport options supported by puppeteer
  • args array - a list of custom arguments to pass to the scriptFn function. ex: args: [1, 2] and with scriptFn: function (a, b) { return a + b}' will produce 3 as result
  • styles array - array of css strings to insert at the beginning of page's head element. ex: styles: ['* { font-family: 'Calibri'; font-size: 16px; }']
  • waitForJS boolean - when true the scriptFn won't be executed until the variable specified in waitForJSVarName option is set to true in page's javscript. defaults to false
  • waitForJSVarName string - name of the variable that will be used as trigger of scriptFn. defaults to "CHROME_PAGE_EVAL_READY"
  • waitUntil string - a value that specifies when a page is considered to be loaded, for the list of all possible values and its meanings see waitUntil option in puppeteer docs. defaults to the the default value of puppeteer
  • timeout number - time in ms to wait for the script evaluation to complete, when the timeout is reached the evaluation is cancelled. defaults to 30000

Requirements

  • Install puppeteer >= 1.0.0 with npm install puppeteer --save in your project and pass it to @a-2-c-2-anpm/vel-fugiat-consectetur constructor function.

Caveats

  • What you return in your script function (scriptFn option) must be a serializable value in order to receive it properly, if a non serializable value is returned you will get undefined as the result.

Debugging

  • To get more information (internal debugging logs of the module) about what's happening during the evaluation on the page start your app in this way: DEBUG=@a-2-c-2-anpm/vel-fugiat-consectetur* node [your-entry-file-here].js (on Windows use set DEBUG=@a-2-c-2-anpm/vel-fugiat-consectetur* && node [your-entry-file-here].js). This will print out to the console some additional information about what's going on.

  • To see the Chrome instance created (the visible chrome window) run your app with the CHROME_PAGE_EVAL_DEBUGGING env var: CHROME_PAGE_EVAL_DEBUGGING=true node [your-entry-file-here].js (on Windows use set CHROME_PAGE_EVAL_DEBUGGING=true && node [your-entry-file-here].js).

License

See license