question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Promise based write/getBuffer

See original GitHub issue

Currently, write needs callback. I’d like to be able to do this:

image.getBuffer(Jimp.MIME_JPEG).then(function(buffer) {
  res.writeHead(200, {
     'Content-Type': Jimp.MIME_JPEG,
     'Content-Length': buffer.length
   });
   res.end(buffer);
})

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:29
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
majiycommented, Sep 28, 2017

As a workaround for the time being, using Bluebird promisify:

const bluebird = require('bluebird');
const jimp = require('jimp');
jimp.prototype.getBufferAsync = bluebird.promisify( jimp.prototype.getBuffer );
5reactions
oliver-morancommented, Jul 26, 2016

@efernandesng, thanks and apologies for delay getting back. I’ll look into this for the release after next.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using JavaScript Promises - AWS Documentation
promise method provides a way to call a service operation and manage asynchronous flow instead of using callbacks. In Node.js and browser scripts,...
Read more >
golang s3 download to buffer using s3manager.downloader
It downloads to a file. How do I get the download content into a []byte slice (buffer) directly. I tried something like: var...
Read more >
Using JavaScript Promises - Amazon SDK for JavaScript
Use JavaScript promises for asynchronous calls with the SDK for JavaScript. ... Key: 'example2.txt', Body: 'Uploaded text using the promise-based method!
Read more >
How to implement a promise-based API - MDN Web Docs
This is a much less common task than using promise-based APIs, but it's still worth knowing about. Prerequisites: Basic computer literacy, a ...
Read more >
promise-buffer - npm
Buffers promises and run them in order on the next tick. Installation. promise-buffer can be installed using. $ npm install --save promise- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found