{"id":27969242,"url":"https://github.com/anvaka/streaming-svg-parser","last_synced_at":"2025-05-07T21:09:15.995Z","repository":{"id":49341170,"uuid":"352202812","full_name":"anvaka/streaming-svg-parser","owner":"anvaka","description":"Streaming SVG/XML parser with zero dependencies","archived":false,"fork":false,"pushed_at":"2025-01-17T02:32:18.000Z","size":553,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-07T21:09:11.106Z","etag":null,"topics":["parser","xml","xml-parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/anvaka.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-03-27T23:48:08.000Z","updated_at":"2025-01-17T02:32:20.000Z","dependencies_parsed_at":"2023-12-10T05:19:09.299Z","dependency_job_id":"bb7399d8-1899-4447-a00d-11a5aafba79b","html_url":"https://github.com/anvaka/streaming-svg-parser","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"4771a6667d5988a8bc340cd920616350b234dc94"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvaka%2Fstreaming-svg-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvaka%2Fstreaming-svg-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvaka%2Fstreaming-svg-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvaka%2Fstreaming-svg-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anvaka","download_url":"https://codeload.github.com/anvaka/streaming-svg-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954410,"owners_count":21830905,"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":["parser","xml","xml-parser"],"created_at":"2025-05-07T21:09:15.247Z","updated_at":"2025-05-07T21:09:15.986Z","avatar_url":"https://github.com/anvaka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# streaming-svg-parser\n\nVery fast parser of SVG (and likely XML) files, that doesn't need the entire file to start\nparsing it.\n\n## install\n\nYou can get this package via npm:\n\n``` sh\nnpm install streaming-svg-parser\n```\n\nOr via CDN:\n\n```\n  \u003cscript src=\"https://unpkg.com/streaming-svg-parser@1.1.0/dist/streaming-svg-parser.min.js\"\u003e\u003c/script\u003e\n```\n\n## usage\n\nYou can find example of this parser in https://anvaka.github.io/map-of-reddit/ and \nmore specifically - [here](https://github.com/anvaka/map-of-reddit/blob/756ece61fdf246be10076994f7f5876a7af002e8/src/lib/createSVGLoader.js#L10).\nI need to document this better, but here is a quick demo of how the parser could\nwork to print indented elements along with their attributes:\n\n``` js\n// If you are using node.js, you can use require() to load the parser.\n// \n// Otherwise, if you used CDN with \u003cscript src='...'\u003e\u003c/script\u003e tag,\n// `streamingSVGParser` will be available as global variable:\nconst streamingSVGParser = require('streaming-svg-parser');\n\nlet indent = '';\nlet parseText = streamingSVGParser.createStreamingSVGParser(\n  openElement =\u003e {\n    // attributes are in a map, let's print it:\n    let attributes = Array.from(openElement.attributes)\n      .map(pair =\u003e pair.join('='))\n      .join(' ');\n\n    console.log(indent + 'Open ' + openElement.tagName + ' ' + attributes);\n    indent += '  ';\n  },\n  closeElement =\u003e {\n    indent = indent.substring(2);\n    console.log(indent + 'Close ' + closeElement.tagName);\n  }\n);\nparseText('\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e');\nparseText('\u003csvg clip-rule=\"evenodd\" viewBox=\"0 0 42 42\"\u003e')\nparseText('\u003cg id=\"my-id\"\u003e\u003c');\nparseText('/g\u003e\u003c/svg\u003e');\n```\n\nThis will print:\n\n```\nOpen svg clip-rule=evenodd viewBox=0 0 42 42\n  Open g id=my-id\n  Close g\nClose svg\n```\n\n[Open in jsbin](https://jsbin.com/pikilibadu/2/edit?html,js,output)\n\nNote that `parseText()` was fed incomplete chunks of svg, which makes this parser\nideal when you load large SVG files over the network but want to process them without\nwaiting for the entire file to be loaded.\n\n## XML Support\n\nWhile originally this library is written for SVG, it should work for simple XML files \nas well. Please let me know if you find anything missing.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanvaka%2Fstreaming-svg-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanvaka%2Fstreaming-svg-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanvaka%2Fstreaming-svg-parser/lists"}