@tldraw/utils
Advanced tools
Comparing version 3.9.0 to 3.10.0-canary.15f6aaa3d2d3
@@ -102,8 +102,12 @@ import { default as throttle } from 'lodash.throttle'; | ||
/** | ||
* @param dataURL - The file as a string. | ||
* | ||
* from https://stackoverflow.com/a/53817185 | ||
* @deprecated Use `urlToArrayBuffer` instead. | ||
*/ | ||
static dataUrlToArrayBuffer(dataURL: string): Promise<ArrayBuffer>; | ||
/** | ||
* @param url - The url of the file. | ||
*/ | ||
static urlToArrayBuffer(url: string): Promise<ArrayBuffer>; | ||
static urlToBlob(url: string): Promise<Blob>; | ||
static urlToDataUrl(url: string): Promise<string>; | ||
/** | ||
* Convert a file to a base64 encoded data url. | ||
@@ -110,0 +114,0 @@ * |
@@ -161,5 +161,5 @@ "use strict"; | ||
"@tldraw/utils", | ||
"3.9.0", | ||
"3.10.0-canary.15f6aaa3d2d3", | ||
"cjs" | ||
); | ||
//# sourceMappingURL=index.js.map |
@@ -27,5 +27,3 @@ "use strict"; | ||
/** | ||
* @param dataURL - The file as a string. | ||
* | ||
* from https://stackoverflow.com/a/53817185 | ||
* @deprecated Use `urlToArrayBuffer` instead. | ||
*/ | ||
@@ -38,2 +36,18 @@ static async dataUrlToArrayBuffer(dataURL) { | ||
/** | ||
* @param url - The url of the file. | ||
*/ | ||
static async urlToArrayBuffer(url) { | ||
const response = await (0, import_network.fetch)(url); | ||
return await response.arrayBuffer(); | ||
} | ||
static async urlToBlob(url) { | ||
const response = await (0, import_network.fetch)(url); | ||
return await response.blob(); | ||
} | ||
static async urlToDataUrl(url) { | ||
if (url.startsWith("data:")) return url; | ||
const blob = await FileHelpers.urlToBlob(url); | ||
return await FileHelpers.blobToDataUrl(blob); | ||
} | ||
/** | ||
* Convert a file to a base64 encoded data url. | ||
@@ -40,0 +54,0 @@ * |
{ | ||
"name": "@tldraw/utils", | ||
"description": "A tiny little drawing app (private utilities).", | ||
"version": "3.9.0", | ||
"version": "3.10.0-canary.15f6aaa3d2d3", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "tldraw Inc.", |
@@ -10,5 +10,3 @@ import { fetch } from './network' | ||
/** | ||
* @param dataURL - The file as a string. | ||
* | ||
* from https://stackoverflow.com/a/53817185 | ||
* @deprecated Use `urlToArrayBuffer` instead. | ||
*/ | ||
@@ -22,2 +20,21 @@ static async dataUrlToArrayBuffer(dataURL: string) { | ||
/** | ||
* @param url - The url of the file. | ||
*/ | ||
static async urlToArrayBuffer(url: string) { | ||
const response = await fetch(url) | ||
return await response.arrayBuffer() | ||
} | ||
static async urlToBlob(url: string) { | ||
const response = await fetch(url) | ||
return await response.blob() | ||
} | ||
static async urlToDataUrl(url: string) { | ||
if (url.startsWith('data:')) return url | ||
const blob = await FileHelpers.urlToBlob(url) | ||
return await FileHelpers.blobToDataUrl(blob) | ||
} | ||
/** | ||
* Convert a file to a base64 encoded data url. | ||
@@ -24,0 +41,0 @@ * |
@@ -12,2 +12,4 @@ /** @internal */ | ||
/** @internal */ | ||
export function getOwnProperty<O extends object>(obj: O, key: string): O[keyof O] | undefined | ||
/** @internal */ | ||
export function getOwnProperty(obj: object, key: string): unknown | ||
@@ -14,0 +16,0 @@ /** @internal */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
544779
8097
1
4