data-uri-utils 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +33 -0
- package/package.json +91 -0
- package/src/index.js +15 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2022 Kiko Beats <josefrancisco.verdu@gmail.com> (kikobeats.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# data-uri-utils
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://coveralls.io/github/Kikobeats/data-uri-utils)
|
|
5
|
+
[](https://www.npmjs.org/package/data-uri-utils)
|
|
6
|
+
|
|
7
|
+
> A set of functions for manipuliating data URIs.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ npm install data-uri-utils --save
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
const dataUri = require('data-uri-utils')
|
|
19
|
+
|
|
20
|
+
const uri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
|
|
21
|
+
|
|
22
|
+
dataUri.normalize(uri)
|
|
23
|
+
dataUri.toBuffer(uri).byteLength // => 89
|
|
24
|
+
dataUri.test(uri) // => true
|
|
25
|
+
dataUri.exec(uri)[2] // => 'image/png'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
**data-uri-utils** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/data-uri-utils/blob/master/LICENSE.md) License.<br>
|
|
31
|
+
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/Kikobeats/data-uri-utils/contributors).
|
|
32
|
+
|
|
33
|
+
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · Twitter [@Kikobeats](https://twitter.com/Kikobeats)
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "data-uri-utils",
|
|
3
|
+
"description": "A set of functions for manipuliating data URIs",
|
|
4
|
+
"homepage": "https://nicedoc.io/Kikobeats/data-uri-utils",
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"author": {
|
|
8
|
+
"email": "josefrancisco.verdu@gmail.com",
|
|
9
|
+
"name": "Kiko Beats",
|
|
10
|
+
"url": "https://kikobeats.com"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/Kikobeats/data-uri-utils.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/Kikobeats/data-uri-utils/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"data-uri"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"data-uri-regex": "~0.1.4",
|
|
24
|
+
"data-uri-to-buffer": "~3.0.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@commitlint/cli": "latest",
|
|
28
|
+
"@commitlint/config-conventional": "latest",
|
|
29
|
+
"ava": "latest",
|
|
30
|
+
"c8": "latest",
|
|
31
|
+
"ci-publish": "latest",
|
|
32
|
+
"conventional-github-releaser": "latest",
|
|
33
|
+
"finepack": "latest",
|
|
34
|
+
"git-authors-cli": "latest",
|
|
35
|
+
"nano-staged": "latest",
|
|
36
|
+
"npm-check-updates": "latest",
|
|
37
|
+
"prettier-standard": "latest",
|
|
38
|
+
"simple-git-hooks": "latest",
|
|
39
|
+
"standard": "latest",
|
|
40
|
+
"standard-markdown": "latest",
|
|
41
|
+
"standard-version": "latest"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">= 14"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"src"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"clean": "rm -rf node_modules",
|
|
51
|
+
"contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
52
|
+
"coverage": "c8 report --reporter=text-lcov > coverage/lcov.info",
|
|
53
|
+
"lint": "standard-markdown README.md && standard",
|
|
54
|
+
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
55
|
+
"prerelease": "npm run update:check && npm run contributors",
|
|
56
|
+
"pretest": "npm run lint",
|
|
57
|
+
"release": "standard-version -a",
|
|
58
|
+
"release:github": "conventional-github-releaser -p angular",
|
|
59
|
+
"release:tags": "git push --follow-tags origin HEAD:master",
|
|
60
|
+
"test": "c8 ava",
|
|
61
|
+
"update": "ncu -u",
|
|
62
|
+
"update:check": "ncu -- --error-level 2"
|
|
63
|
+
},
|
|
64
|
+
"license": "MIT",
|
|
65
|
+
"ava": {
|
|
66
|
+
"files": [
|
|
67
|
+
"!test/helpers.js",
|
|
68
|
+
"test/**/*.js"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"commitlint": {
|
|
72
|
+
"extends": [
|
|
73
|
+
"@commitlint/config-conventional"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"nano-staged": {
|
|
77
|
+
"*.js,!*.min.js,": [
|
|
78
|
+
"prettier-standard"
|
|
79
|
+
],
|
|
80
|
+
"*.md": [
|
|
81
|
+
"standard-markdown"
|
|
82
|
+
],
|
|
83
|
+
"package.json": [
|
|
84
|
+
"finepack"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"simple-git-hooks": {
|
|
88
|
+
"commit-msg": "npx commitlint --edit",
|
|
89
|
+
"pre-commit": "npx nano-staged"
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/* based on https://github.com/ragingwind/data-uri-regex/blob/master/index.js
|
|
4
|
+
the last update never published at npm */
|
|
5
|
+
const regex = () => /^(data:)([\w/+-]*)(;charset=[\w-]+|;base64){0,1},(.*)/gi
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
normalize: input =>
|
|
9
|
+
input
|
|
10
|
+
.replace('data:;', 'data:null;')
|
|
11
|
+
.replace('data:null;', 'data:image/png;'),
|
|
12
|
+
toBuffer: require('data-uri-to-buffer'),
|
|
13
|
+
test: input => regex().test(input),
|
|
14
|
+
exec: input => regex().exec(input)
|
|
15
|
+
}
|