https://github.com/pavjacko/svg2js
Handy tool convert SVG format into inline JS
https://github.com/pavjacko/svg2js
javascript renative utility
Last synced: 9 months ago
JSON representation
Handy tool convert SVG format into inline JS
- Host: GitHub
- URL: https://github.com/pavjacko/svg2js
- Owner: pavjacko
- Created: 2018-01-25T12:29:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-26T20:18:58.000Z (over 8 years ago)
- Last Synced: 2025-08-17T03:51:31.985Z (10 months ago)
- Topics: javascript, renative, utility
- Language: JavaScript
- Size: 231 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# svg2js #
Handy utility to convert SVG images to inline Javascript
## Installation
`npm install --save svg2js`
## Usage
Svg2Js API is Promise based
#### Usage 1 (Save to file as Javascript Module):
```js
import Svg2Js from 'svg2js'
Svg2Js.create({
source: '/Users/userX/myImage.svg',
destination: '/Users/userX/myImage.js'
}).then(() => console.log('SUCCESS!'))
```
after conversion JS SVG can be used as regular JS module
```js
var MySvgImage = require('../../../../selectorAssets/runtime/icons/myImage.js')
//USE MySvgImage as inline value for rendering in various tools/libs
```
#### Usage 2 (Get inline value):
```js
import Svg2Js from 'svg2js'
Svg2Js.convert({
source: '/Users/userX/myImage.svg'
}).then((result) => console.log('SUCCESS!', result))
```
## Contributing ##
Basicaly clone, change, test, push and pull request.
## License ##
icon-toolkit is licensed under the MIT license.