From 6df0b7e6d8baebd4ae471c5342cc3ab0c2494c1c Mon Sep 17 00:00:00 2001 From: Alexandre BERTRAND Date: Tue, 22 Jan 2019 08:39:45 +0100 Subject: [PATCH] add Uint8Array support (#135) * add Uint8Array support * reformat pdfjswrapper --- src/componentFactory.js | 2 +- src/pdfjsWrapper.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/componentFactory.js b/src/componentFactory.js index 00a139e..e0907b1 100644 --- a/src/componentFactory.js +++ b/src/componentFactory.js @@ -36,7 +36,7 @@ export default function(pdfjsWrapper) { }, props: { src: { - type: [String, Object], + type: [String, Object, Uint8Array], default: '', }, page: { diff --git a/src/pdfjsWrapper.js b/src/pdfjsWrapper.js index ae82d1c..777a8fb 100644 --- a/src/pdfjsWrapper.js +++ b/src/pdfjsWrapper.js @@ -12,8 +12,9 @@ export default function(PDFJS) { var source; if ( typeof(src) === 'string' ) source = { url: src }; - else - if ( typeof(src) === 'object' && src !== null ) + else if ( src instanceof Uint8Array ) + source = { data: src }; + else if ( typeof(src) === 'object' && src !== null ) source = Object.assign({}, src); else throw new TypeError('invalid src type');