strong-tie/inbound-calls
0
1data-uri-to-buffer2==================3### Generate a Buffer instance from a [Data URI][rfc] string4[](https://travis-ci.org/TooTallNate/node-data-uri-to-buffer)5 6This module accepts a ["data" URI][rfc] String of data, and returns a7node.js `Buffer` instance with the decoded data.8 9 10Installation11------------12 13Install with `npm`:14 15``` bash16$ npm install data-uri-to-buffer17```18 19 20Example21-------22 23``` js24import dataUriToBuffer from 'data-uri-to-buffer';25 26// plain-text data is supported27let uri = 'data:,Hello%2C%20World!';28let decoded = dataUriToBuffer(uri);29console.log(decoded.toString());30// 'Hello, World!'31 32// base64-encoded data is supported33uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';34decoded = dataUriToBuffer(uri);35console.log(decoded.toString());36// 'Hello, World!'37```38 39 40API41---42 43### dataUriToBuffer(String uri) → Buffer44 45The `type` property on the Buffer instance gets set to the main type portion of46the "mediatype" portion of the "data" URI, or defaults to `"text/plain"` if not47specified.48 49The `typeFull` property on the Buffer instance gets set to the entire50"mediatype" portion of the "data" URI (including all parameters), or defaults51to `"text/plain;charset=US-ASCII"` if not specified.52 53The `charset` property on the Buffer instance gets set to the Charset portion of54the "mediatype" portion of the "data" URI, or defaults to `"US-ASCII"` if the55entire type is not specified, or defaults to `""` otherwise.56 57*Note*: If the only the main type is specified but not the charset, e.g.58`"data:text/plain,abc"`, the charset is set to the empty string. The spec only59defaults to US-ASCII as charset if the entire type is not specified.60 61 62License63-------64 65(The MIT License)66 67Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>68 69Permission is hereby granted, free of charge, to any person obtaining70a copy of this software and associated documentation files (the71'Software'), to deal in the Software without restriction, including72without limitation the rights to use, copy, modify, merge, publish,73distribute, sublicense, and/or sell copies of the Software, and to74permit persons to whom the Software is furnished to do so, subject to75the following conditions:76 77The above copyright notice and this permission notice shall be78included in all copies or substantial portions of the Software.79 80THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,81EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF82MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.83IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY84CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,85TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE86SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.87 88[rfc]: http://tools.ietf.org/html/rfc239789 