{"id":23789962,"url":"https://github.com/blackglory/extra-dom","last_synced_at":"2026-06-22T19:01:53.380Z","repository":{"id":44955717,"uuid":"323980235","full_name":"BlackGlory/extra-dom","owner":"BlackGlory","description":"🌲 Utilities for DOM","archived":false,"fork":false,"pushed_at":"2023-06-10T17:55:14.000Z","size":1009,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-04T04:58:54.765Z","etag":null,"topics":["browser","esm","library","npm-package","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/extra-dom","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BlackGlory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-23T18:58:48.000Z","updated_at":"2023-02-23T07:22:35.000Z","dependencies_parsed_at":"2024-06-21T18:56:41.065Z","dependency_job_id":"af37126f-f9c8-47e3-a110-7a5badd432b6","html_url":"https://github.com/BlackGlory/extra-dom","commit_stats":{"total_commits":151,"total_committers":2,"mean_commits":75.5,"dds":"0.052980132450331174","last_synced_commit":"0c4654a587a100c4b01ad3b0568c83c6812a0028"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-dom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-dom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-dom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-dom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlackGlory","download_url":"https://codeload.github.com/BlackGlory/extra-dom/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240018690,"owners_count":19734872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","esm","library","npm-package","typescript"],"created_at":"2025-01-01T17:17:49.306Z","updated_at":"2026-06-22T19:01:53.355Z","avatar_url":"https://github.com/BlackGlory.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# extra-dom\nUtilities for DOM.\n\n## Install\n```sh\nnpm install --save extra-dom\n# or\nyarn add extra-dom\n```\n\n## API\n### flatMap\n```ts\nfunction flatMap(node: Node, fn: (node: Node) =\u003e Node[]): Node[]\n```\n\nTraverse the node tree and do `flatMap`.\n\n- `[]`: remove current node\n- `[node]`: replace current node\n- `[node1, node2, ...nodeN]`: replace current node with more nodes\n\n### map\n```ts\nfunction map(node: Node, fn: (node: Node) =\u003e Node): Node\n```\n\nTraverse the node tree and do `map`.\n\n### filter\n```ts\nfunction filter(node: Node, predicate: (node: Node) =\u003e unknown): Node | undefined\n```\n\nTraverse the node tree and do `filter`.\n\n### unwrap\n```ts\nfunction unwrap(node: Node, predicate: (node: Node) =\u003e unknown): Node[]\n```\n\nTraverse the node tree and do `unwrap`.\n\n### find\n```ts\nfunction find(node: Node, predicate: (node: Node) =\u003e unknown): Node | undefined\n```\n\nTraverse the node tree and do `find`.\n\n### parseNodes\n```ts\nfunction parseNodes(htmlFragment: string): Node[]\n```\n\n### stringifyNodes\n```ts\nfunction stringifyNodes(nodes: Node[]): string\n```\n\n### parseFragment\n```ts\nfunction parseFragment(htmlFragment: string): DocumentFragment\n```\n\n### stringifyFragment\n```ts\nfunction stringifyFragment(fragment: DocumentFragment): string\n```\n\n### removeAllChildren\n```ts\nfunction removeAllChildren(node: Node): void\n```\n\n### removeAttributes\n```ts\nfunction removeAttributes(\n  node: Node\n, predicate?: (attributeName: string) =\u003e unknown\n): void\n```\n\n### getBySelector\n```ts\nfunction getBySelector\u003cT extends Element\u003e(\n  this: void | Element | Document\n, selectors: string\n): T\n```\n\nReturn the first matched element.\n\nIf cannot find any elements, it throws.\n\n### getAllBySelector\n```ts\nfunction getAllBySelector\u003cT extends Element\u003e(\n  this: void | Element | Document\n, selectors: string\n): T[]\n```\n\nReturn matched elements.\n\nIf cannot find any elements, it throws.\n\n### traverseAncestorNodes\n```ts\nfunction traverseAncestorNodes(node: Node): Iterable\u003cNode \u0026 ParentNode\u003e\n```\n\n### traverseDescendantNodes\n```ts\nfunction traverseDescendantNodes(node: Node): Iterable\u003cChildNode\u003e\n```\n\n### traversePrecedingSiblingNodes\n```ts\nfunction traversePrecedingSiblingNodes(node: Node): Iterable\u003cNode\u003e\n```\n\n### traverseFollowingSiblingNodes\n```ts\nfunction traverseFollowingSiblingNodes(node: Node): Iterable\u003cNode\u003e\n```\n\n### traverseDescendantNodes\n```ts\nfunction traverseDescendantNodes(node: Node): Iterable\u003cChildNode\u003e\n```\n\n### findInAncestorNodes\n```ts\nfunction findInAncestorNodes(\n  node: Node\n, predicate: (node: Node \u0026 ParentNode) =\u003e unknown\n): (Node \u0026 ParentNode) | undefined\n```\n\n### findInDescendantNodes\n```ts\nfunction find(node: Node, predicate: (node: ChildNode) =\u003e unknown): ChildNode | undefined\n```\n\n### findInPrecedingSiblingNodes\n```ts\nfunction findInPrecedingSiblingNodes(\n  node: Node\n, predicate: (node: Node) =\u003e unknown\n): Node | undefined\n```\n\nThis function uses `Node.previousSibling` to traverse the preceding sibling nodes.\n\n### findInFollowingSiblingNodes\n```ts\nfunction findInFollowingSiblingNodes(\n  node: Node\n, predicate: (node: Node) =\u003e unknown\n): Node | undefined\n```\n\nThis function uses `Node.nextSibling` to traverse the following sibling nodes.\n\n### parentNode\n```ts\nfunction parentNode(node: Node, distance: number = 1): (Node \u0026 ParentNode) | undefined\n```\n\n### nextSibling\n```ts\nfunction nextSibling(node: Node, distance: number = 1): ChildNode | undefined\n```\n\n### previousSibling\n```ts\nfunction previousSibling(node: Node, distance: number = 1): ChildNode | undefined\n```\n\n### nextElementSibling\n```ts\nfunction nextElementSibling(node: Node, distance: number = 1): Element | undefined\n```\n\n### previousElementSibling\n```ts\nfunction previousElementSibling(node: Node, distance: number = 1): Element | undefined\n```\n\n### isDocument\n```ts\nfunction isDocument(val: unknown): val is Document\n```\n\n### isntDocument\n```ts\nfunction isntDocument\u003cT\u003e(val: T): val is Exclude\u003cT, Document\u003e\n```\n\n### isElement\n```ts\nfunction isElement(val: unknown): val is Element\n```\n\n### isntElement\n```ts\nfunction isntElement\u003cT\u003e(val: T): val is Exclude\u003cT, Element\u003e\n```\n\n### isTextNode\n```ts\nfunction isTextNode(val: unknown): val is Text\n```\n\n### isntTextNode\n```ts\nfunction isntTextNode\u003cT\u003e(val: unknown): node is Exclude\u003cT, Text\u003e\n```\n\n### isNode\n```ts\nfunction isNode(val: unknown): val is Node\n```\n\n### isntNode\n```ts\nfunction isntNode\u003cT\u003e(val: T): val is Exclude\u003cT, Node\u003e\n```\n\n### isParentNode\n```ts\nfunction isParentNode(val: unknown): val is Node \u0026 ParentNode\n```\n\n### isntParentNode\n```ts\nfunction isntParentNode\u003cT\u003e(val: unknown): val is Exclude\u003cT, Node \u0026 ParentNode\u003e\n```\n\n### isBefore\n```ts\nfunction isBefore(subject: Node, object: Node): boolean\n```\n\n### isAfter\n```ts\nfunction isAfter(subject: Node, object: Node): boolean\n```\n\n### createDOMParser\n```ts\nfunction createDOMParser(): DOMParser\n```\n\n### NodeType\n```ts\nenum NodeType {\n  ELEMENT_NODE\n, ATTRIBUTE_NODE\n, TEXT_NODE\n, CDATA_SECTION_NODE\n, ENTITY_REFERENCE_NODE\n, ENTITY_NODE\n, PROCESSING_INSTRUCTION_NODE\n, COMMENT_NODE\n, DOCUMENT_NODE\n, DOCUMENT_TYPE_NODE\n, DOCUMENT_FRAGMENT_NODE\n, NOTATION_NODE\n}\n```\n\n### XPathResultType\n```ts\nenum XPathResultType {\n  ANY_TYPE\n, NUMBER_TYPE\n, STRING_TYPE\n, BOOLEAN_TYPE\n, UNORDERED_NODE_ITERATOR_TYPE\n, ORDERED_NODE_ITERATOR_TYPE\n, UNORDERED_NODE_SNAPSHOT_TYPE\n, ORDERED_NODE_SNAPSHOT_TYPE\n, ANY_UNORDERED_NODE_TYPE\n, FIRST_ORDERED_NODE_TYPE\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fextra-dom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackglory%2Fextra-dom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fextra-dom/lists"}