diff --git a/build/webpack.config.js b/build/webpack.config.js index 16efdba809..8aefb1a65c 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -27,7 +27,8 @@ const languages = isProd ? locales : ['en-US']; // Only 1 language needed for de /* eslint-disable key-spacing, require-jsdoc */ function updateConfig(conf, language, index) { - const config = Object.assign(conf, { + const config = { + ...conf, entry: { annotations: ['box-annotations'], preview: [`${lib}/Preview.js`], @@ -64,7 +65,7 @@ function updateConfig(conf, language, index) { inline: true, port: 8000, }, - }); + }; if (index === 0) { config.plugins.push(new RsyncPlugin(thirdParty, staticFolder)); diff --git a/build/webpack.karma.config.js b/build/webpack.karma.config.js index 67d3d76591..c5a061c6ea 100644 --- a/build/webpack.karma.config.js +++ b/build/webpack.karma.config.js @@ -10,14 +10,15 @@ const commonConfig = require('./webpack.common.config'); const baseConfig = commonConfig('en-US'); -const config = Object.assign(baseConfig, { +const config = { + ...baseConfig, mode: 'development', resolve: { alias: { sinon: 'sinon/pkg/sinon', }, }, -}); +}; if (isDebug) { config.devtool = 'inline-source-map'; diff --git a/src/lib/Preview.js b/src/lib/Preview.js index 5067318b21..7ea6ec2182 100644 --- a/src/lib/Preview.js +++ b/src/lib/Preview.js @@ -238,7 +238,7 @@ class Preview extends EventEmitter { // Token can also be null or undefined for offline use case. // But it cannot be a random object. if (token === null || typeof token !== 'object') { - this.previewOptions = Object.assign({}, options, { token }); + this.previewOptions = { ...options, token }; } else { throw new Error('Bad access token!'); } @@ -331,9 +331,7 @@ class Preview extends EventEmitter { fileIds.push(fileOrId.toString()); } else if (fileOrId && typeof fileOrId === 'object' && isValidFileId(fileOrId.id)) { // Possible well-formed file object found in the collection - const wellFormedFileObj = Object.assign({}, fileOrId, { - id: fileOrId.id.toString(), - }); + const wellFormedFileObj = { ...fileOrId, id: fileOrId.id.toString() }; fileIds.push(wellFormedFileObj.id); files.push(wellFormedFileObj); } else { @@ -537,7 +535,7 @@ class Preview extends EventEmitter { } // This allows the browser to download representation content - const params = Object.assign({ response_content_disposition_type: 'attachment' }, queryParams); + const params = { response_content_disposition_type: 'attachment', ...queryParams }; const downloadUrl = appendQueryParams( this.viewer.createContentUrlWithAuthParams(contentUrlTemplate, this.viewer.getAssetPath()), params, @@ -869,7 +867,7 @@ class Preview extends EventEmitter { * @return {void} */ parseOptions(previewOptions) { - const options = Object.assign({}, previewOptions); + const options = { ...previewOptions }; // Reset all options this.options = {}; @@ -986,14 +984,14 @@ class Preview extends EventEmitter { * @return {Object} combined options */ createViewerOptions(moreOptions) { - return cloneDeep( - Object.assign({}, this.options, moreOptions, { - api: this.api, - location: this.location, - cache: this.cache, - ui: this.ui, - }), - ); + return cloneDeep({ + ...this.options, + ...moreOptions, + api: this.api, + location: this.location, + cache: this.cache, + ui: this.ui, + }); } /** @@ -1023,12 +1021,10 @@ class Preview extends EventEmitter { */ loadFromServer() { const { apiHost, previewWMPref, queryParams } = this.options; - const params = Object.assign( - { - watermark_preference: convertWatermarkPref(previewWMPref), - }, - queryParams, - ); + const params = { + watermark_preference: convertWatermarkPref(previewWMPref), + ...queryParams, + }; const fileVersionId = this.getFileOption(this.file.id, FILE_OPTION_FILE_VERSION_ID) || ''; @@ -1639,12 +1635,10 @@ class Preview extends EventEmitter { */ prefetchNextFiles() { const { apiHost, previewWMPref, queryParams, skipServerUpdate } = this.options; - const params = Object.assign( - { - watermark_preference: convertWatermarkPref(previewWMPref), - }, - queryParams, - ); + const params = { + watermark_preference: convertWatermarkPref(previewWMPref), + ...queryParams, + }; // Don't bother prefetching when there aren't more files or we need to skip server update if (this.collection.length < 2 || skipServerUpdate) { diff --git a/src/lib/__tests__/Preview-test.js b/src/lib/__tests__/Preview-test.js index 8b20c11d1a..3a3f29be3e 100644 --- a/src/lib/__tests__/Preview-test.js +++ b/src/lib/__tests__/Preview-test.js @@ -235,7 +235,7 @@ describe('lib/Preview', () => { preview.show(file, token, options); - expect(stubs.parseOptions).to.be.calledWith(Object.assign({}, options, { token })); + expect(stubs.parseOptions).to.be.calledWith({ ...options, token }); }); }); diff --git a/src/lib/file.js b/src/lib/file.js index ec423b51c6..b3a39ca133 100644 --- a/src/lib/file.js +++ b/src/lib/file.js @@ -120,7 +120,7 @@ export function checkFileValid(file) { * @return {Object} File version object normalized to a file object from the API */ export function normalizeFileVersion(fileVersion, fileId) { - const file = Object.assign({}, fileVersion); + const file = { ...fileVersion }; file.id = fileId; // ID returned by file versions API is file version ID, so we need to set to file ID file.shared_link = {}; // File versions API does not return shared link object file.file_version = { diff --git a/src/lib/viewers/BaseViewer.js b/src/lib/viewers/BaseViewer.js index dab7dd6df5..30fc39181c 100644 --- a/src/lib/viewers/BaseViewer.js +++ b/src/lib/viewers/BaseViewer.js @@ -1121,14 +1121,14 @@ class BaseViewer extends EventEmitter { whoDrew: __('annotation_who_drew'), }; - return cloneDeep( - Object.assign({}, this.options, moreOptions, { - isMobile: this.isMobile, - hasTouch: this.hasTouch, - locale: this.options.location.locale, - localizedStrings, - }), - ); + return cloneDeep({ + ...this.options, + ...moreOptions, + isMobile: this.isMobile, + hasTouch: this.hasTouch, + locale: this.options.location.locale, + localizedStrings, + }); } /** diff --git a/src/lib/viewers/box3d/model3d/Model3DSettingsPullup.js b/src/lib/viewers/box3d/model3d/Model3DSettingsPullup.js index bbd355e274..74b4c0bbad 100644 --- a/src/lib/viewers/box3d/model3d/Model3DSettingsPullup.js +++ b/src/lib/viewers/box3d/model3d/Model3DSettingsPullup.js @@ -134,7 +134,7 @@ class Model3DSettingsPullup extends EventEmitter { // Render Mode dropdown const renderPanelData = RENDER_MODES.map(entry => { - const entryCopy = Object.assign({}, entry); + const entryCopy = { ...entry }; this.convertToValidCallback(entryCopy); return entryCopy; }); @@ -181,7 +181,7 @@ class Model3DSettingsPullup extends EventEmitter { // Camera Projection dropdown const projectionPanelData = PROJECTION_MODES.map(entry => { - const entryCopy = Object.assign({}, entry); + const entryCopy = { ...entry }; this.convertToValidCallback(entryCopy); return entryCopy; }); diff --git a/src/lib/viewers/office/__tests__/OfficeLoader-test.js b/src/lib/viewers/office/__tests__/OfficeLoader-test.js index 7e13cab07e..6f92fcbd33 100644 --- a/src/lib/viewers/office/__tests__/OfficeLoader-test.js +++ b/src/lib/viewers/office/__tests__/OfficeLoader-test.js @@ -26,9 +26,9 @@ describe('lib/viewers/office/OfficeLoader', () => { describe('determineViewer()', () => { const fakeFiles = [ - Object.assign({}, fakeFileTemplate, { extension: 'xlsx' }), - Object.assign({}, fakeFileTemplate, { extension: 'xlsm' }), - Object.assign({}, fakeFileTemplate, { extension: 'xlsb' }), + { ...fakeFileTemplate, extension: 'xlsx' }, + { ...fakeFileTemplate, extension: 'xlsm' }, + { ...fakeFileTemplate, extension: 'xlsb' }, ]; fakeFiles.forEach(fakeFile => {