docs: rebuild
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
- [capitalizeFirstChar](modules.md#capitalizefirstchar)
|
||||
- [classNames](modules.md#classnames)
|
||||
- [conditionalJoin](modules.md#conditionaljoin)
|
||||
- [extractTextFromHTML](modules.md#extracttextfromhtml)
|
||||
- [isDeepWeakEqual](modules.md#isdeepweakequal)
|
||||
- [randomInRange](modules.md#randominrange)
|
||||
- [removeFromArrayByKeyValue](modules.md#removefromarraybykeyvalue)
|
||||
@@ -45,7 +46,7 @@ console.log(capitalizeFirstChar("lorem ipsum"))
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/capitalizeFirstChar.ts:32](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/capitalizeFirstChar.ts#L32)
|
||||
[functions/capitalizeFirstChar.ts:32](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/capitalizeFirstChar.ts#L32)
|
||||
|
||||
___
|
||||
|
||||
@@ -78,7 +79,7 @@ console.log(classNames("bg-blue-300", isVisible ? "block" : "hidden"))
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/classNames.ts:34](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/classNames.ts#L34)
|
||||
[functions/classNames.ts:34](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/classNames.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
@@ -112,7 +113,64 @@ console.log(conditionalJoin(["Hello,", isAdmin ? "Administrator!" : "User!"], "
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/conditionalJoin.ts:35](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/conditionalJoin.ts#L35)
|
||||
[functions/conditionalJoin.ts:35](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/conditionalJoin.ts#L35)
|
||||
|
||||
___
|
||||
|
||||
### extractTextFromHTML
|
||||
|
||||
▸ **extractTextFromHTML**(`html`, `domParser?`): ``null`` \| `string`
|
||||
|
||||
Extracts text content from an HTML string
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :------ | :------ | :------ |
|
||||
| `html` | `string` | HTML to extract text from |
|
||||
| `domParser` | `DOMParser` | DOMParser to use |
|
||||
|
||||
#### Returns
|
||||
|
||||
``null`` \| `string`
|
||||
|
||||
**`Remarks`**
|
||||
|
||||
By default this function uses `new window.DOMParser()` to parse HTML, however
|
||||
on the server you might need to use alternative DOM Parser such as JSDOM,
|
||||
puppeteer or cheerio as `window` object is not defined in NodeJS
|
||||
|
||||
**`See`**
|
||||
|
||||
[Why doesn't Node.js have a native DOM?](https://stackoverflow.com/q/32723111/14544732)
|
||||
for more information on why this function is made the way it is
|
||||
|
||||
**`Example`**
|
||||
|
||||
Here's how you would use this function in browser
|
||||
```ts
|
||||
let HTML = '<p><a>Lorem ipsum</a> dolor sit</p>'
|
||||
|
||||
// prints "Lorem ipsum dolor sit"
|
||||
console.log(extractTextFromHTML(HTML))
|
||||
```
|
||||
|
||||
**`Example`**
|
||||
|
||||
Here's how you would use this function on server
|
||||
```ts
|
||||
import { JSDOM } from "jsdom";
|
||||
const domParser = new new JSDOM().window.DOMParser();
|
||||
|
||||
let HTML = '<p><a>Lorem ipsum</a> dolor sit</p>'
|
||||
|
||||
// prints "Lorem ipsum dolor sit"
|
||||
console.log(extractTextFromHTML(HTML, domParser))
|
||||
```
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/extractTextFromHTML.ts:56](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/extractTextFromHTML.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
@@ -160,7 +218,7 @@ console.log(
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/isDeepWeakEqual.ts:47](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/isDeepWeakEqual.ts#L47)
|
||||
[functions/isDeepWeakEqual.ts:47](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/isDeepWeakEqual.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
@@ -197,7 +255,7 @@ console.log(randomInRange(1, 100))
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/randomInRange.ts:37](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/randomInRange.ts#L37)
|
||||
[functions/randomInRange.ts:37](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/randomInRange.ts#L37)
|
||||
|
||||
___
|
||||
|
||||
@@ -243,7 +301,7 @@ console.log(removeFromArrayByKeyValue([{ a: "1", b: "0" }, { a: "2", b: "0" }, {
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/removeFromArrayByKeyValue.ts:40](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/removeFromArrayByKeyValue.ts#L40)
|
||||
[functions/removeFromArrayByKeyValue.ts:40](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/removeFromArrayByKeyValue.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
@@ -282,7 +340,7 @@ console.log(removeObjectProperty({ a: "1", b: "2", c: "3" }, "c"))
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/removeObjectProperty.ts:33](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/removeObjectProperty.ts#L33)
|
||||
[functions/removeObjectProperty.ts:33](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/removeObjectProperty.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
@@ -330,7 +388,7 @@ console.log(replaceFromArrayByKeyValue([{ a: "1", b: "0" }, { a: "2", b: "0" },
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/replaceFromArrayByKeyValue.ts:42](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/replaceFromArrayByKeyValue.ts#L42)
|
||||
[functions/replaceFromArrayByKeyValue.ts:42](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/replaceFromArrayByKeyValue.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
@@ -368,4 +426,4 @@ console.log(splitIntoChunks(["a", "b", "c", "d", "e", "f"], 3));
|
||||
|
||||
#### Defined in
|
||||
|
||||
[functions/splitIntoChunks.ts:33](https://git.resultium.net/public/utils/src/commit/ea3cb13/src/functions/splitIntoChunks.ts#L33)
|
||||
[functions/splitIntoChunks.ts:33](https://git.resultium.net/public/utils/src/commit/2305e3505a1249a9cf9aa9dc7e97de0b43fb0948/src/functions/splitIntoChunks.ts#L33)
|
||||
|
||||
Reference in New Issue
Block a user