@capturebridge/sdk 0.31.1 → 0.32.0
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/Common.js +24 -0
- package/README.md +2 -2
- package/Version.js +1 -1
- package/package.json +1 -1
package/Common.js
CHANGED
|
@@ -200,6 +200,14 @@ export const DATAURL_PNG = 'data:image/png;base64,'
|
|
|
200
200
|
*/
|
|
201
201
|
export const DATAURL_GIF = 'data:image/gif;base64,'
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* @summary `data:` prefix for JSON
|
|
205
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs|Data URLs}
|
|
206
|
+
* @constant
|
|
207
|
+
* @type {string}
|
|
208
|
+
*/
|
|
209
|
+
export const DATAURL_JSON = 'data:application/json;base64,'
|
|
210
|
+
|
|
203
211
|
/**
|
|
204
212
|
* @summary For a given base64 string, convert it to the appropriate Data URL
|
|
205
213
|
* @constant
|
|
@@ -230,6 +238,22 @@ export const base64ToDataURL = base64 => {
|
|
|
230
238
|
throw new Error('Unknown image format provided in Base64 string')
|
|
231
239
|
}
|
|
232
240
|
|
|
241
|
+
/**
|
|
242
|
+
* @summary Strip the data URL identifier from a string
|
|
243
|
+
* @constant
|
|
244
|
+
* @type {string}
|
|
245
|
+
*/
|
|
246
|
+
export const stripDataUrl = dataUrl => {
|
|
247
|
+
const dataUrls = [DATAURL_JPEG, DATAURL_PNG, DATAURL_GIF, DATAURL_JSON]
|
|
248
|
+
for (const i in dataUrls) {
|
|
249
|
+
const prefix = dataUrls[i]
|
|
250
|
+
if (dataUrl.startsWith(prefix)) {
|
|
251
|
+
return dataUrl.replace(prefix, '')
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
throw new Error(`Data URL prefix must be one of: ${dataUrls.join(',')}`)
|
|
255
|
+
}
|
|
256
|
+
|
|
233
257
|
/**
|
|
234
258
|
* An Async/Await version of
|
|
235
259
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/setTimeout|setTimeout}
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# Capture Bridge JavaScript Client SDK
|
|
2
2
|
|
|
3
|
-
- [SDK Documentation for v0.
|
|
4
|
-
- [SDK CHANGELOG](https://docs.capturebridge.net/client/sdk/javascript/0.
|
|
3
|
+
- [SDK Documentation for v0.32.0](https://docs.capturebridge.net/client/sdk/javascript/0.32.0/index.html)
|
|
4
|
+
- [SDK CHANGELOG](https://docs.capturebridge.net/client/sdk/javascript/0.32.0/CHANGELOG.html)
|
package/Version.js
CHANGED