MCPcopy
hub / github.com/yabwe/medium-editor / dataURItoBlob

Function dataURItoBlob

spec/helpers/util.js:80–103  ·  view source on GitHub ↗
(dataURI)

Source from the content-addressed store, hash-verified

78}
79
80function dataURItoBlob(dataURI) {
81 // convert base64/URLEncoded data component to raw binary data held in a string
82 var byteString,
83 mimeString,
84 ia,
85 i;
86
87 if (dataURI.split(',')[0].indexOf('base64') >= 0) {
88 byteString = atob(dataURI.split(',')[1]);
89 } else {
90 byteString = unescape(dataURI.split(',')[1]);
91 }
92
93 // separate out the mime component
94 mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
95
96 // write the bytes of the string to a typed array
97 ia = new Uint8Array(byteString.length);
98 for (i = 0; i < byteString.length; i += 1) {
99 ia[i] = byteString.charCodeAt(i);
100 }
101
102 return new Blob([ia], {type: mimeString});
103}
104
105// keyCode, ctrlKey, target, relatedTarget, shiftKey, altKey
106function fireEvent(element, eventName, options) {

Callers 1

prepareEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…