diff options
Diffstat (limited to 'lib/documents.js')
| -rw-r--r-- | lib/documents.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/documents.js b/lib/documents.js index 26c0ce7..9088ed9 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -151,12 +151,22 @@ function noteKey(noteType, id) { function Image(options) { return { type: types.image, - read: options.readImage, - readAsText: function(encoding) { - if (!encoding) { - throw new Error("Missing encoding argument"); + // `read` is retained for backwards compatibility, but other read + // methods should be preferred. + read: function(encoding) { + if (encoding) { + return options.readImage(encoding); + } else { + return options.readImage().then(function(arrayBuffer) { + return Buffer.from(arrayBuffer); + }); } - return options.readImage(encoding); + }, + readAsArrayBuffer: function() { + return options.readImage(); + }, + readAsBase64String: function() { + return options.readImage("base64"); }, altText: options.altText, contentType: options.contentType |
