Skip to content

Commit 6a3713e

Browse files
Merge pull request #183 from renderforest/project-data-upgrade
project-data-upgrade
2 parents 5b3d9c5 + 2d74f22 commit 6a3713e

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

lib/project-data.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,9 @@ class ProjectData {
473473
* @return {result}
474474
*/
475475
setText: function (text) {
476-
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
476+
const areaChecker = checkAreaType(area, 'text')
477+
areaChecker(NotTextAreaError.of(`Area with id: ${id} is not text.`))
478+
477479
area.value = text
478480
self.patchProperties.push('screens')
479481
return this
@@ -484,7 +486,9 @@ class ProjectData {
484486
* @return {result}
485487
*/
486488
setTextScale: function (scale) {
487-
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
489+
const areaChecker = checkAreaType(area, 'text')
490+
areaChecker(NotTextAreaError.of(`Area with id: ${id} is not text.`))
491+
488492
if (scale < 80 || scale > 120) {
489493
throw new InvalidTextScaleValue('The text scale value must be between 80 and 120.')
490494
}
@@ -498,34 +502,42 @@ class ProjectData {
498502
* @throws {NotTextAreaError}
499503
*/
500504
getRecommendedCharacterCount: () => {
501-
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
505+
const areaChecker = checkAreaType(area, 'text')
506+
areaChecker(NotTextAreaError.of(`Area with id: ${id} is not text.`))
507+
502508
return Math.floor(parseInt(wordCount) * AVERAGE_CHARS_IN_WORD)
503509
},
504510
/**
505511
* Checks if area is `image`, then sets the new image.
506512
* @param {Object} image - The image properties.
507513
* @throws {NotImageAreaError}
508514
*/
509-
setImage: (image) => {
510-
checkAreaType(area, 'image')(NotImageAreaError.of(`Area with id: ${id} is not image.`))
515+
setImage: function (image) {
516+
const areaChecker = checkAreaType(area, 'image')
517+
areaChecker(NotImageAreaError.of(`Area with id: ${id} is not image.`))
518+
511519
Object.assign(result, {
512520
fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, imageCropParams
513521
})
514522
ProjectData.setAreaImage(area, image)
515-
this.patchProperties.push('screens')
523+
self.patchProperties.push('screens')
524+
return this
516525
},
517526
/**
518527
* Checks if area is `video`, then sets the new video.
519528
* @param {Object} video - The image properties.
520529
* @throws {NotImageAreaError}
521530
*/
522-
setVideo: (video) => {
523-
checkAreaType(area, 'video')(NotVideoAreaError.of(`Area with id: ${id} is not video.`))
531+
setVideo: function (video) {
532+
const areaChecker = checkAreaType(area, 'video')
533+
areaChecker(NotVideoAreaError.of(`Area with id: ${id} is not video.`))
534+
524535
Object.assign(result, {
525536
fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, videoCropParams
526537
})
527538
ProjectData.setAreaVideo(area, video)
528-
this.patchProperties.push('screens')
539+
self.patchProperties.push('screens')
540+
return this
529541
},
530542
/**
531543
* Returns project data instance for further development.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@renderforest/sdk-node",
33
"description": "Renderforest SDK for Node.js",
4-
"version": "0.5.1",
4+
"version": "0.5.2",
55
"author": "RenderForest LLC",
66
"bugs": {
77
"url": "https://github.com/renderforest/renderforest-sdk-node/issues"

0 commit comments

Comments
 (0)