4 ms·
Interesting. When I tried it (using GPT4), and told it "but won't that leak memory because we're not removing the other listener?", it gave me: const EventEm
by fragmede 3y ago
Interesting. When I tried it (using GPT4), and told it "but won't that leak memory because we're not removing the other listener?", it gave me:
const EventEmitter = require('events');
let eventEmitter = new EventEmitter();
function eventPromise(eventEmitter, eventName) {
return new Promise((resolve, reject) => {
const successHandler = (data) => {
eventEmitter.off('error', errorHandler);
resolve(data);
};
const errorHandler = (error) => {
eventEmitter.off(eventName, successHandler);
reject(error);
};
eventEmitter.once(eventName, successHandler);
eventEmitter.once('error', errorHandler);
});
}
// Use like so:
eventPromise(eventEmitter, 'data').then(console.log).catch(console.error);
Which seems to be what you're asking for?
https://chat.openai.com/share/89cf1cc8-4ae1-40f6-aa34-0629eb4e1028 https://chat.openai.com/share/89cf1cc8-4ae1-40f6-aa34-0629eb...
- chmod775 3y agoKind of: The point is making it find and correct the mistake itself, instead of spelling out the fix. We want it to replace a competent coder who can do code reviews by themselves, rather than just being a fancy input method that turns English into code. That said, sometimes you can even get it to write correct code on the first try. It's completely random.
- fragmede 3y agoA tool is only as useful as the one wielding it, and it doesn't have to be perfect to be useful. I'm faster with LLM guided development than without in unfamiliar territory. Jack of all trades, LLM-grade proficiency in all of them. See, the thing is I don't actually want it to take my job, I like having a job, for many reasons. As a translator that turns Jira tickets into English and then turns them into code, if it makes my job easier and I'm more productive, great! If it takes deep domain knowledge before it's useful and it can be tricked into missing subtle things, that sounds like job security.
- deleted 3y ago[deleted]