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.3
Supply Chain
94.9
Quality
76.1
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
306
Last Day
1
Last Week
11
Last Month
19
Last Year
144
21 Commits
1 Watching
2 Branches
1 Contributors
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
Publised On
14 Mar 2024
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
175%
11
Compared to previous week
Last month
280%
19
Compared to previous month
Last year
-11.1%
144
Compared to previous year
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.