{"id":17472515,"url":"https://github.com/shinnn/node-flex-svg","last_synced_at":"2025-07-29T18:02:29.500Z","repository":{"id":13073880,"uuid":"15754691","full_name":"shinnn/node-flex-svg","owner":"shinnn","description":"Creates SVG of flexible width and height","archived":false,"fork":false,"pushed_at":"2018-12-16T13:37:26.000Z","size":115,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T22:54:18.872Z","etag":null,"topics":["flexible","javascript","nodejs","responsive","svg","xml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"moritz157/moritz157.github.io","license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.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}},"created_at":"2014-01-09T02:35:06.000Z","updated_at":"2018-12-16T13:37:27.000Z","dependencies_parsed_at":"2022-09-26T19:00:38.517Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/node-flex-svg","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fnode-flex-svg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fnode-flex-svg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fnode-flex-svg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fnode-flex-svg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/node-flex-svg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125632,"owners_count":21051766,"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":["flexible","javascript","nodejs","responsive","svg","xml"],"created_at":"2024-10-18T17:25:23.252Z","updated_at":"2025-04-09T22:54:23.512Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flex-svg\n\n[![npm version](https://img.shields.io/npm/v/flex-svg.svg)](https://www.npmjs.com/package/flex-svg)\n[![Build Status](https://travis-ci.com/shinnn/node-flex-svg.svg?branch=master)](https://travis-ci.com/shinnn/node-flex-svg)\n[![Coverage Status](https://img.shields.io/coveralls/shinnn/node-flex-svg.svg)](https://coveralls.io/github/shinnn/node-flex-svg)\n\nA [Node.js](https://nodejs.org/) module to create [SVG](https://www.w3.org/TR/SVG2/) files of flexible width and height\n\n```xml\n\u003c?xml version=\"2.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"50px\" height=\"50px\"\u003e\n  \u003crect width=\"50px\" height=\"50px\"/\u003e\n\u003c/svg\u003e\n```\n\n↓\n\n```xml\n\u003c?xml version=\"2.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003csvg xmlns=\"http://www.w3.org/2000/svg\"\u003e\n  \u003crect width=\"50px\" height=\"50px\"/\u003e\n\u003c/svg\u003e\n```\n\nIf `width` and `height` attributes of outermost svg elements are not specified, they are regarded as `100%` according to the [SVG 2 Specification](https://www.w3.org/TR/SVG2/geometry.html#Sizing).\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install flex-svg\n```\n\n## API\n\n```javascript\nconst flexSvg = require('flex-svg');\n```\n\n### flexSvg(*svgData* [, *options*], *callback*)\n\n*svgData*: `string` `Buffer` (SVG)  \n*options*: `Object` (directly passed to the [xml2js.Parser](https://github.com/Leonidas-from-XIV/node-xml2js#options) options and the [xml2js.Builder](https://github.com/Leonidas-from-XIV/node-xml2js#options-for-the-builder-class) options)  \n*callback*: `Function`\n\n#### callback(*error*, *result*)\n\n*error*: `Error` if it fails to parse SVG, otherwise `null`  \n*result*: `string` of SVG without `width` and `height` attributes\n\n```javascript\nconst {readFile} = require('fs');\nconst flexSvg = require('flex-svg');\n\nreadFile('path/to/file.svg', (readErr, data) =\u003e {\n  if (readErr) {\n    throw readErr;\n  }\n\n  flexSvg(data, (parseErr, result) =\u003e {\n    if (parseErr) {\n      throw parseErr;\n    }\n\n    console.log(result);\n  });\n});\n```\n\n### class flexSvg.FlexSvg([*options*])\n\nReturn: `Function`\n\nCreate a `Function` to which options are bound. This is more efficient way in the case when the program repeatedly runs [`flexSvg`](#flexsvgsvgdata--options-callback) function with the same options.\n\n## License\n\n[ISC License](./LICENSE) © 2017 - 2018 Shinnosuke Watanabe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fnode-flex-svg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Fnode-flex-svg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fnode-flex-svg/lists"}