mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-09 09:11:56 +02:00
modified
This commit is contained in:
-25
@@ -1,25 +0,0 @@
|
||||
sudo: false
|
||||
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "1"
|
||||
- "2"
|
||||
- "3"
|
||||
- "4"
|
||||
- "5"
|
||||
- "6"
|
||||
- "7"
|
||||
- "8"
|
||||
|
||||
install:
|
||||
- PATH="`npm bin`:`npm bin -g`:$PATH"
|
||||
# Install dependencies and build
|
||||
- npm install
|
||||
|
||||
script:
|
||||
# Output useful info for debugging
|
||||
- node --version
|
||||
- npm --version
|
||||
# Run tests
|
||||
- npm test
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
|
||||
2.0.0 / 2017-07-18
|
||||
==================
|
||||
|
||||
* More correct media type handling
|
||||
* add typings for Typescript
|
||||
|
||||
1.2.0 / 2017-07-18
|
||||
==================
|
||||
|
||||
* Essentially identical to v1.0.0. Reverting changes from v1.1.0 because they are breaking changes and should be part of a major version bump
|
||||
* Revert "More correct media type handling"
|
||||
* Revert "add typings for Typescript"
|
||||
|
||||
1.1.0 / 2017-07-17
|
||||
==================
|
||||
|
||||
* More correct media type handling
|
||||
* Add typings for Typescript
|
||||
|
||||
1.0.0 / 2017-06-09
|
||||
==================
|
||||
|
||||
* Bumping to v1.0.0 for semver semantics
|
||||
* random updates for newer Node.js versions
|
||||
* travis: test more node versions and fix v0.8
|
||||
|
||||
0.0.4 / 2015-06-29
|
||||
==================
|
||||
|
||||
* package: update "mocha" to v2
|
||||
* package: add RFC to the "keywords" section
|
||||
* travis: test node v0.8, v0.10, and v0.12
|
||||
* README: use SVG for Travis-CI badge
|
||||
* test: more tests
|
||||
|
||||
0.0.3 / 2014-01-08
|
||||
==================
|
||||
|
||||
* index: fix a URI with a comma in the data portion
|
||||
|
||||
0.0.2 / 2014-01-08
|
||||
==================
|
||||
|
||||
* index: use unescape() instead of decodeURIComponent()
|
||||
* test: add more tests from Mozilla
|
||||
|
||||
0.0.1 / 2014-01-02
|
||||
==================
|
||||
|
||||
* add `README.md`
|
||||
* index: default the `charset` property to "US-ASCII"
|
||||
* default encoding is "ascii"
|
||||
* default `type` to "text/plain" when none is given
|
||||
* initial commit
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
data-uri-to-buffer
|
||||
==================
|
||||
### Generate a Buffer instance from a [Data URI][rfc] string
|
||||
[](https://travis-ci.org/TooTallNate/node-data-uri-to-buffer)
|
||||
|
||||
This module accepts a ["data" URI][rfc] String of data, and returns a
|
||||
node.js `Buffer` instance with the decoded data.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install data-uri-to-buffer
|
||||
```
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
``` js
|
||||
var dataUriToBuffer = require('data-uri-to-buffer');
|
||||
|
||||
// plain-text data is supported
|
||||
var uri = 'data:,Hello%2C%20World!';
|
||||
var decoded = dataUriToBuffer(uri);
|
||||
console.log(decoded.toString());
|
||||
// 'Hello, World!'
|
||||
|
||||
// base64-encoded data is supported
|
||||
uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
|
||||
decoded = dataUriToBuffer(uri);
|
||||
console.log(decoded.toString());
|
||||
// 'Hello, World!'
|
||||
```
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
### dataUriToBuffer(String uri) → Buffer
|
||||
|
||||
The `type` property on the Buffer instance gets set to the main type portion of
|
||||
the "mediatype" portion of the "data" URI, or defaults to `"text/plain"` if not
|
||||
specified.
|
||||
|
||||
The `typeFull` property on the Buffer instance gets set to the entire
|
||||
"mediatype" portion of the "data" URI (including all parameters), or defaults
|
||||
to `"text/plain;charset=US-ASCII"` if not specified.
|
||||
|
||||
The `charset` property on the Buffer instance gets set to the Charset portion of
|
||||
the "mediatype" portion of the "data" URI, or defaults to `"US-ASCII"` if the
|
||||
entire type is not specified, or defaults to `""` otherwise.
|
||||
|
||||
*Note*: If the only the main type is specified but not the charset, e.g.
|
||||
`"data:text/plain,abc"`, the charset is set to the empty string. The spec only
|
||||
defaults to US-ASCII as charset if the entire type is not specified.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
[rfc]: http://tools.ietf.org/html/rfc2397
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
declare class MimeBuffer extends Buffer {
|
||||
type: string;
|
||||
typeFull: string;
|
||||
charset: string;
|
||||
}
|
||||
|
||||
declare function dataUriToBuffer(uri: string): MimeBuffer;
|
||||
export = dataUriToBuffer;
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = dataUriToBuffer;
|
||||
|
||||
/**
|
||||
* Returns a `Buffer` instance from the given data URI `uri`.
|
||||
*
|
||||
* @param {String} uri Data URI to turn into a Buffer instance
|
||||
* @return {Buffer} Buffer instance from Data URI
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function dataUriToBuffer(uri) {
|
||||
if (!/^data\:/i.test(uri)) {
|
||||
throw new TypeError(
|
||||
'`uri` does not appear to be a Data URI (must begin with "data:")'
|
||||
);
|
||||
}
|
||||
|
||||
// strip newlines
|
||||
uri = uri.replace(/\r?\n/g, '');
|
||||
|
||||
// split the URI up into the "metadata" and the "data" portions
|
||||
var firstComma = uri.indexOf(',');
|
||||
if (-1 === firstComma || firstComma <= 4) {
|
||||
throw new TypeError('malformed data: URI');
|
||||
}
|
||||
|
||||
// remove the "data:" scheme and parse the metadata
|
||||
var meta = uri.substring(5, firstComma).split(';');
|
||||
|
||||
var type = meta[0] || 'text/plain';
|
||||
var typeFull = type;
|
||||
var base64 = false;
|
||||
var charset = '';
|
||||
for (var i = 1; i < meta.length; i++) {
|
||||
if ('base64' == meta[i]) {
|
||||
base64 = true;
|
||||
} else {
|
||||
typeFull += ';' + meta[i];
|
||||
if (0 == meta[i].indexOf('charset=')) {
|
||||
charset = meta[i].substring(8);
|
||||
}
|
||||
}
|
||||
}
|
||||
// defaults to US-ASCII only if type is not provided
|
||||
if (!meta[0] && !charset.length) {
|
||||
typeFull += ';charset=US-ASCII';
|
||||
charset = 'US-ASCII';
|
||||
}
|
||||
|
||||
// get the encoded data portion and decode URI-encoded chars
|
||||
var data = unescape(uri.substring(firstComma + 1));
|
||||
|
||||
var encoding = base64 ? 'base64' : 'ascii';
|
||||
var buffer = Buffer.from ? Buffer.from(data, encoding) : new Buffer(data, encoding);
|
||||
|
||||
// set `.type` and `.typeFull` properties to MIME type
|
||||
buffer.type = type;
|
||||
buffer.typeFull = typeFull;
|
||||
|
||||
// set the `.charset` property
|
||||
buffer.charset = charset;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"name": "data-uri-to-buffer",
|
||||
"version": "2.0.2",
|
||||
"description": "Generate a Buffer instance from a Data URI string",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-data-uri-to-buffer.git"
|
||||
},
|
||||
"keywords": [
|
||||
"data",
|
||||
"uri",
|
||||
"datauri",
|
||||
"data-uri",
|
||||
"buffer",
|
||||
"convert",
|
||||
"rfc2397",
|
||||
"2397"
|
||||
],
|
||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-data-uri-to-buffer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/TooTallNate/node-data-uri-to-buffer",
|
||||
"devDependencies": {
|
||||
"@types/node": "^8.0.7",
|
||||
"mocha": "^3.4.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user