MCPcopy
hub / github.com/KilledByAPixel/LittleJS / saveDataURL

Function saveDataURL

src/engineUtilities.js:163–175  ·  view source on GitHub ↗

Save a data url to disk * @param {string} url * @param {string} [filename] * @param {number} [revokeTime] - how long before revoking the url * @memberof Utilities

(url, filename='download', revokeTime)

Source from the content-addressed store, hash-verified

161 * @param {number} [revokeTime] - how long before revoking the url
162 * @memberof Utilities */
163function saveDataURL(url, filename='download', revokeTime)
164{
165 ASSERT(isStringLike(url), 'saveDataURL requires url string');
166 ASSERT(isStringLike(filename), 'saveDataURL requires filename string');
167
168 // create link for saving screenshots
169 const link = document.createElement('a');
170 link.download = filename;
171 link.href = url;
172 link.click();
173 if (revokeTime !== undefined)
174 setTimeout(()=> URL.revokeObjectURL(url), revokeTime);
175}
176
177/** Share content using the native share dialog if available
178 * @param {string} title - title of the share

Callers 3

debugVideoCaptureStartFunction · 0.85
saveTextFunction · 0.85
saveCanvasFunction · 0.85

Calls 3

isStringLikeFunction · 0.85
ASSERTFunction · 0.70
clickMethod · 0.45

Tested by

no test coverage detected