{"id":34547439,"url":"https://github.com/xusd320/niddle","last_synced_at":"2025-12-24T07:29:10.864Z","repository":{"id":249268619,"uuid":"828166927","full_name":"xusd320/niddle","owner":"xusd320","description":"A super fast nodejs addon for html parsing and manipulation written in rust.","archived":false,"fork":false,"pushed_at":"2025-08-07T06:40:33.000Z","size":2936,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T22:41:47.288Z","etag":null,"topics":["cheerio","htmlparser","jquery","napi","node-addon","rust"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/niddle","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xusd320.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-07-13T10:13:29.000Z","updated_at":"2025-09-08T03:42:07.000Z","dependencies_parsed_at":"2024-10-28T01:56:04.445Z","dependency_job_id":"5fe4e6fc-1d53-494a-af64-70d59ae37e6b","html_url":"https://github.com/xusd320/niddle","commit_stats":null,"previous_names":["umijs/niddle","xusd320/niddle"],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/xusd320/niddle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusd320%2Fniddle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusd320%2Fniddle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusd320%2Fniddle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusd320%2Fniddle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xusd320","download_url":"https://codeload.github.com/xusd320/niddle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusd320%2Fniddle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27997233,"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","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cheerio","htmlparser","jquery","napi","node-addon","rust"],"created_at":"2025-12-24T07:29:09.687Z","updated_at":"2025-12-24T07:29:10.858Z","avatar_url":"https://github.com/xusd320.png","language":"JavaScript","readme":"# niddle\n\nA super fast Node.js addon for HTML parsing and manipulation, written in Rust.\n\n## Features\n\n- High-performance DOM parsing and manipulation\n- Exposes a simple JavaScript API via NAPI-RS\n- Designed for both server-side and CLI HTML processing\n- Written in Rust for speed and safety\n\n## Installation\n\n```bash\nyarn add niddle\n# or\nnpm install niddle\n```\n\n## Usage\n\n```js\nconst { parse } = require('niddle');\nconst root = parse('\u003cdiv id=\"foo\" class=\"bar\"\u003ehello \u003cspan\u003eworld\u003c/span\u003e\u003c/div\u003e');\n\nconst div = root.select('div');\nconsole.log(div.getAttribute('id')); // \"foo\"\nconsole.log(div.text()); // \"hello world\"\ndiv.setAttribute('title', 'my-title');\nconsole.log(div.outerHtml()); // \u003cdiv id=\"foo\" class=\"bar\" title=\"my-title\"\u003ehello \u003cspan\u003eworld\u003c/span\u003e\u003c/div\u003e\n```\n\n## API Documentation\n\n### `parse(html: string): NodeRepr`\n\nParses an HTML string and returns a `NodeRepr` instance representing the root node.\n\n#### Parameters\n\n- `html` (string): The HTML content to parse.\n\n#### Returns\n\n- `NodeRepr`: The parsed root node.\n\n---\n\n### `NodeRepr` Class\n\nRepresents a DOM node and provides various manipulation methods.\n\n#### Methods\n\n- **append(content: string | NodeRepr): void**\n  - Appends a new node or HTML string as a child.\n- **appendSequence(nodes: NodeRepr[]): void**\n  - Appends multiple nodes.\n- **clone(): NodeRepr**\n  - Clones the current node (not including descendants).\n- **cloneRecursive(): NodeRepr**\n  - Clones the node and all descendants.\n- **getAttribute(name: string): string**\n  - Gets an attribute value by name.\n- **getAttributes(): Record\u003cstring, string\u003e**\n  - Gets all attributes as a key-value object.\n- **getChildren(): NodeRepr[]**\n  - Returns all child nodes.\n- **innerHtml(): string**\n  - Gets the HTML content of all descendants.\n- **insertAfter(node: NodeRepr): void**\n  - Inserts the current node after the specified node.\n- **insertBefore(node: NodeRepr): void**\n  - Inserts the current node before the specified node.\n- **insertSequenceAfter(nodes: NodeRepr[]): void**\n  - Inserts multiple nodes after the current node.\n- **insertSequenceBefore(nodes: NodeRepr[]): void**\n  - Inserts multiple nodes before the current node.\n- **outerHtml(): string**\n  - Gets the HTML content including the node itself.\n- **prepend(content: string | NodeRepr): void**\n  - Prepends a new node or HTML string as a child.\n- **prependSequence(nodes: NodeRepr[]): void**\n  - Prepends multiple nodes.\n- **remove(): void**\n  - Removes the node from the DOM.\n- **removeAllAttributes(): void**\n  - Removes all attributes from the node.\n- **removeAttribute(name: string): void**\n  - Removes an attribute by name.\n- **select(selectors: string): NodeRepr**\n  - Selects the first node matching the selector.\n- **selectAll(selectors: string): NodeRepr[]**\n  - Selects all nodes matching the selector.\n- **setAttribute(name: string, value: string): void**\n  - Sets an attribute value.\n- **setAttributes(attrs: Record\u003cstring, string\u003e): void**\n  - Sets multiple attributes.\n- **text(): string**\n  - Gets the text content of the node.\n\n\n## Contributing\n\n```bash\nyarn install\nyarn build\nyarn test\n```\n\n## Benchmark\n\n```bash\ncargo benchmark\nyarn benchmark\n```\n\n---\n\nFor more usage examples and advanced API, see the source code and benchmarks in the repository.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxusd320%2Fniddle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxusd320%2Fniddle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxusd320%2Fniddle/lists"}