Gathering detailed insights and metrics for poopoodom
Gathering detailed insights and metrics for poopoodom
Gathering detailed insights and metrics for poopoodom
Gathering detailed insights and metrics for poopoodom
npm install poopoodom
Typescript
Module System
Node Version
NPM Version
81.2
Supply Chain
94.9
Quality
75.2
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
351
Last Day
1
Last Week
2
Last Month
15
Last Year
115
MIT License
21 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Nov 17, 2023
Latest Version
0.1.1
Package Id
poopoodom@0.1.1
Unpacked Size
16.57 MB
Size
2.40 MB
File Count
21
NPM Version
10.2.5
Node Version
20.5.0
Published on
Mar 14, 2024
Cumulative downloads
Total Downloads
1
7
Type declarations of dom lib.
You are developing in a non-browser environment, but you need typings of DOM. Perhaps you are using puppeteer.
You may consider to use dom
lib. However, it inserts lots of globals. So dirty!
1import type { Document, HTMLElement } from 'poopoodom' // ✓ good 2// import { Document, HTMLElement } from 'poopoodom' // ✗ bad 3 4function getElementByIdAndCheck<Element extends HTMLElement>( 5 document: Document, 6 id: string 7): Element { 8 const element = document.getElementById(id) 9 if (element === null) { 10 throw new Error(`Element not found: ${id}`) 11 } 12 return element as Element 13}
Always import types only: This package assumes everything is available at runtime and does not provide any implementation.
Modern browsers now provide dom.iterable
API. To use it, import whatever you need from
poopoodom/iterable
. Note that types from poopoodom
and poopoodom/iterable
are irrelevant.
1import type { Document as OldDocument, HTMLElement as OldHTMLElement } from 'poopoodom' 2import type { Document, HTMLElement } from 'poopoodom/iterable' 3 4function getWideElementsInOldBrowser(document: OldDocument): OldHTMLElement[] { 5 const elements = document.body.querySelectorAll<OldHTMLElement>('*') 6 const ret: OldHTMLElement[] = [] 7 for (let i = 0; i < elements.length; i++) { 8 if (elements[i].offsetWidth > 1000) { 9 ret.push(elements[i]) 10 } 11 } 12 return ret 13} 14 15function getWideElementsInModernBrowser(document: Document): HTMLElement[] { 16 const elements = document.body.querySelectorAll<HTMLElement>('*') 17 const ret: HTMLElement[] = [] 18 for (const element of elements) { 19 if (element.offsetWidth > 1000) { 20 ret.push(element) 21 } 22 } 23 return ret 24}
Add a typescript-eslint rule to prevent accidentally importing non-type elements.
1// .eslintrc.cjs 2module.exports = { 3 rules: { 4 '@typescript-eslint/no-restricted-imports': ['error', { 5 paths: [{ 6 name: 'poopoodom', 7 allowTypeImports: true 8 }] 9 }] 10 } 11}
No vulnerabilities found.
No security vulnerabilities found.
Last Day
0%
1
Compared to previous day
Last Week
-50%
2
Compared to previous week
Last Month
0%
15
Compared to previous month
Last Year
-51.3%
115
Compared to previous year