@tb-dev/prototype-dom 5.2.2 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/package.json +12 -13
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ declare global {
|
|
|
12
12
|
getAttributeStrict: <T extends string>(qualifiedName: string) => T;
|
|
13
13
|
getAttributeAsFloatStrict: (qualifiedName: string, allowNegative?: boolean) => number;
|
|
14
14
|
getAttributeAsIntStrict: (qualifiedName: string, radix?: number, allowNegative?: boolean) => number;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
getTextStrict: <T extends string>() => T;
|
|
16
|
+
getTextAsIntStrict: (radix?: number, allowNegative?: boolean) => number;
|
|
17
|
+
getTextAsFloatStrict: (allowNegative?: boolean) => number;
|
|
18
18
|
queryAsArray: <T = Element>(selector: string, valueSelector?: (element: Element) => T) => T[];
|
|
19
19
|
queryAsSet: <T = Element>(selector: string, valueSelector?: (element: Element) => T) => Set<T>;
|
|
20
20
|
queryStrict: <T extends Element>(selector: string) => T;
|
package/dist/index.js
CHANGED
|
@@ -49,23 +49,23 @@
|
|
|
49
49
|
}
|
|
50
50
|
return parsed;
|
|
51
51
|
};
|
|
52
|
-
Element.prototype.
|
|
52
|
+
Element.prototype.getTextStrict = function () {
|
|
53
53
|
const content = this.textContent?.trim();
|
|
54
54
|
if (typeof content !== 'string' || content.length === 0) {
|
|
55
55
|
throw new Error('element has no text content');
|
|
56
56
|
}
|
|
57
57
|
return content;
|
|
58
58
|
};
|
|
59
|
-
Element.prototype.
|
|
60
|
-
const content = this.
|
|
59
|
+
Element.prototype.getTextAsIntStrict = function (radix = 10) {
|
|
60
|
+
const content = this.getTextStrict();
|
|
61
61
|
const parsed = Number.parseInt(content.replace(/\D/g, ''), radix);
|
|
62
62
|
if (!Number.isInteger(parsed)) {
|
|
63
63
|
throw new TypeError('could not parse text content as integer');
|
|
64
64
|
}
|
|
65
65
|
return parsed;
|
|
66
66
|
};
|
|
67
|
-
Element.prototype.
|
|
68
|
-
const content = this.
|
|
67
|
+
Element.prototype.getTextAsFloatStrict = function () {
|
|
68
|
+
const content = this.getTextStrict();
|
|
69
69
|
const parsed = Number.parseFloat(content);
|
|
70
70
|
if (!Number.isFinite(parsed)) {
|
|
71
71
|
throw new TypeError('could not parse text content as float');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/prototype-dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Adds prototype methods to DOM objects",
|
|
5
5
|
"packageManager": "pnpm@8.15.4",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"homepage": "https://tb.dev.br/prototype-dom",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/ferreira-tb/prototype-dom.git"
|
|
16
|
+
"url": "git+https://github.com/ferreira-tb/prototype-dom.git"
|
|
17
17
|
},
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/ferreira-tb/prototype-dom/issues",
|
|
@@ -22,15 +22,6 @@
|
|
|
22
22
|
"lint-staged": {
|
|
23
23
|
"*.{?(c|m)@(j|t)s,css,vue,md,json}": "prettier --write"
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "rollup --config rollup.config.js",
|
|
27
|
-
"docs": "typedoc --plugin typedoc-plugin-mdn-links",
|
|
28
|
-
"format": "prettier . --write",
|
|
29
|
-
"format-check": "prettier . --check",
|
|
30
|
-
"prepare": "husky",
|
|
31
|
-
"release": "pnpm run build && pnpm publish",
|
|
32
|
-
"type-check": "tsc --noEmit"
|
|
33
|
-
},
|
|
34
25
|
"devDependencies": {
|
|
35
26
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
36
27
|
"@tb-dev/eslint-config": "^2.0.3",
|
|
@@ -51,5 +42,13 @@
|
|
|
51
42
|
"dist/**/*"
|
|
52
43
|
],
|
|
53
44
|
"main": "./dist/index.js",
|
|
54
|
-
"types": "./dist/index.d.ts"
|
|
55
|
-
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "rollup --config rollup.config.js",
|
|
48
|
+
"docs": "typedoc --plugin typedoc-plugin-mdn-links",
|
|
49
|
+
"format": "prettier . --write",
|
|
50
|
+
"format-check": "prettier . --check",
|
|
51
|
+
"release": "pnpm run build && pnpm publish",
|
|
52
|
+
"type-check": "tsc --noEmit"
|
|
53
|
+
}
|
|
54
|
+
}
|