Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

add some jimp helper functionality #77

Merged
merged 1 commit into from
Jul 21, 2018
Merged

add some jimp helper functionality #77

merged 1 commit into from
Jul 21, 2018

Conversation

jlipps
Copy link
Member

@jlipps jlipps commented Jul 19, 2018

was finding that i was having to do lots of bluebird messiness just to use jimp in a few different places. this PR puts all that messiness in one place.

* convenient for our async/await model.
*
* @param {Buffer|string} data - binary image buffer or base64-encoded image
* string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing return description

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* @param {Buffer|string} data - binary image buffer or base64-encoded image
* string
*/
async function getJimpImage (data) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps toJimpImage ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, if this were a method on an object i would like that, but since it's just a bare function that feels confusing to me. open to other ideas though.

async function getJimpImage (data) {
return await new B((resolve, reject) => {
if (!_.isString(data) && !_.isBuffer(data)) {
throw new Error("Must initialize jimp object with string or buffer");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to reject rather than throw in here, so as not to mix metaphors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good idea

@jlipps jlipps merged commit 86965ef into master Jul 21, 2018
@jlipps jlipps deleted the jlipps-jimp branch July 21, 2018 02:58
@jlipps
Copy link
Member Author

jlipps commented Jul 21, 2018

published in 2.19.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants