Skip to main content
Share Your Experience: Take the 2024 Developer Survey
39 votes
Accepted

Partitioning an array based on a condition in Javascript

Using TypeScript/ECMAScript 6 syntax it can be achieved this way. I am not sure whether it's more or less elegant compared to the original variant, but It does the job; Requires only one run; Can be ...
Igor Soloydenko's user avatar
25 votes

Partitioning an array based on a condition in Javascript

Anything wrong with the naive ways? ...
Qtax's user avatar
  • 396
15 votes

Partitioning an array based on a condition in Javascript

The existing answers do not seem to address the callback. One way to include it could be: ...
morbusg's user avatar
  • 900
11 votes
Accepted

Implementation of a Thread Pool in C++

...
user673679's user avatar
  • 11.8k
9 votes

Implementation of a Thread Pool in C++

Welcome to Code Review! Here's some suggestions: Sort the #include directives in alphabetical order. <sstream> and <...
L. F.'s user avatar
  • 9,560
7 votes
Accepted

Simple helper for making things "disposable"

It's a little difficult to give a full review without the removed null checks, but I'll give an observation: In Dispose(), you depend on ...
Jesse C. Slicer's user avatar
7 votes
Accepted

ViewModels Mediator with multiple generic callbacks

I don't feel like you should override + and -. Fine, it makes the syntax cuter, but it makes your code much less readable for ...
IEatBagels's user avatar
  • 12.4k
7 votes
Accepted

C# asynchronous notification vector

I don't think that screen space is so limited that methods can't be separated by a blank line, and separation makes it slightly easier to see scope. ...
Peter Taylor's user avatar
  • 24.1k
6 votes
Accepted

Simple callback wrapper for an embedded C++ app

A few thoughts about your code: 1. Use of reinterpret_cast ...
πάντα ῥεῖ's user avatar
6 votes

Flattening multiple nested node readline questions

Also, I was looking for an answer how to flatten (and automate) calls to rl.question(). In my solution I used Promises - chained - to display questions sequentially. ...
GoldenChris's user avatar
6 votes
Accepted

Simple implementation of signals and slots mechanism using templates

[code] uint64_t It should be std::uint64_t, not uint64_t for key indexes (the latter is the C version). Or better: use ...
user673679's user avatar
  • 11.8k
6 votes
Accepted

C++ callback multithreaded, can unregister itself

Very good design! And very clean code. As-is, there’s very little I can recommend to improve things. In fact, the only code suggestions I can come up with off the top of my head are: You should ...
indi's user avatar
  • 11.4k
6 votes

TFunction: std::function replacement for event system

Design Tell us what your code does, and also add such a comment to the code. As far as I can tell, it adds equality-comparability, by dropping type-erasure, thus dropping support for all but two ...
Deduplicator's user avatar
  • 19.3k
6 votes

c++ multithreaded message broadcaster with link lifetime management v3

auto ls = std::unique_lock(_senderMut); // to guarantee message ordering this is toxic. Multi-threaded code using locks does not compose. Code that is ...
Yakk's user avatar
  • 921
5 votes

ViewModels Mediator with multiple generic callbacks

You should not be calling it a dictionary because you changed the expected behaviour of the IDictionary interface. The MSDN clearly states that the getter of the ...
t3chb0t's user avatar
  • 44.3k
5 votes

ViewModels Mediator with multiple generic callbacks

I fully agree with TopinFrassi and t3chb0t. Some other points The MultiDictionary and the AddableHashSet are not required and ...
JanDotNet's user avatar
  • 8,538
5 votes

ViewModels Mediator with multiple generic callbacks

Don't test whether a HashSet contains a key if you want to remove it: if(list.Contains(value)) { list.Remove(value); } ...
Deduplicator's user avatar
  • 19.3k
5 votes
Accepted

Extracting data from vue-chartjs into an array of datasets

False alarm! No callback hell here. While this code can certainly be refactored a bit, I fail to see callback hell anywhere around. Callback hell is normally a term applied to the code that is ...
Igor Soloydenko's user avatar
5 votes
Accepted

Simple event dispatcher

Design Is there a need for IEventDispatcher? Defining it as an abstract base class doesn't provide much utility if there's only ever going to be one derived class. ...
hoffmale's user avatar
  • 6,498
5 votes

c++ multithreaded message broadcaster with link lifetime management v3

Lifetime of Broadcaster ...
rioki's user avatar
  • 462
4 votes
Accepted

Flattening multiple nested node readline questions

Flow Control libraries such as Async.js exist for exactly that. With async, your code can become: ...
DrakaSAN's user avatar
  • 210
4 votes

C++14 Event System

Reserved Identifiers Unless you are very sure of the rules about what combinations of leading underscore are reserved for the implementation I would suggest that you do not use underscore (...
Emily L.'s user avatar
  • 16.6k
4 votes
Accepted

Example of Callback Hell

I think your example is sufficient to demonstrate that setTimeout can result in weird interleavings. But if you asked me for an example of callback hell, I'd assume ...
Quuxplusone's user avatar
  • 19.4k
4 votes
Accepted

async.waterfall call

Keep your variable naming consistent. Some of your code uses camelCase variable names, others uses snake_case. In JavaScript, we ...
Dan's user avatar
  • 3,748
4 votes

Nested loop with synchronous and asynchronous behavior

First you can make the database container more precise and accessible if you define it like this: ...
char bugs's user avatar
  • 171
4 votes
Accepted

Make HTML/Javascript Geolocation function more linear

Most native functions require callback instead of Promise because they support older browsers, so what you have to do is to pack the ...
Pavlo's user avatar
  • 418
4 votes
Accepted

Simple Publisher Subscriber in Java

Initializing object variables ...
mdfst13's user avatar
  • 21.6k
4 votes
Accepted

Constraining a property setter fluently

This might actually be useful in some cases, however, we first need to get rid of its weaknesses and clean-up the code a little bit: Every property of ...
t3chb0t's user avatar
  • 44.3k
4 votes
Accepted

Simple replacement for Redux in ES6

I may or may not have seen a certain movie in the cinema, but the Batman in me wants to say this: Not to mention that semicolons don't hurt either. Also, per @Blindman67, it seems that you are ...
konijn's user avatar
  • 33.2k
4 votes

Message Broadcaster

Sorry, I probably should have used a "comment" for this, but it is way bigger than their limited size. In all fairness I did not read your code in full; I only scanned it. The thing that struck me ...
Frank Merrow's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible