Questions tagged [promise]
"Promises" are a particular tactic for deferred computing, suitable for several styles of concurrency: thread and event loop concurrency for local computation, and both synchronous and asynchronous remote messaging.
250 questions
4
votes
1
answer
104
views
A class that will manage a thread and execute tasks (e.g., SQL queries) within it
I am interested in creating a class that manages a thread and executes SQL queries sequentially within it. The queries would be submitted from various parts of the program, and the results would be ...
1
vote
1
answer
107
views
Axios wrapper used with API requests
I have created Axios wrapper following SOLID principles. Is there any feedback on improving it's structure in a more cleaner and better way?
axiosconfig.ts
...
6
votes
2
answers
287
views
Timezone-based VPN-detection
I use the following snippet with my browser homepage to detect whether or not I have my VPN connection turned on. If the IP timezone is different from the browser timezone, then it is most likely the ...
4
votes
2
answers
429
views
Full Promise implementation
I have attempted to implement the native Promise object provided by the browser in JavaScript. The code is pretty easy to understand. It supports most of the promise functionalities, such as chaining, ...
0
votes
1
answer
117
views
Handling pure in browser HTTP request in Service Worker fetch event
I was suggested by @Bergi on StackOverflow that Async Promise constructors are any pattern.
The argument behind this is that async Promise swallows the errors. In my case, I have try..catch so I'm not ...
4
votes
2
answers
160
views
Idempotent JavaScript script loader
I wrote an idempotent script loader (for the browser), where the same script won't be loaded more than once.
scriptLoader.js:
...
2
votes
1
answer
137
views
Basic node login routes for authentication system
I am building a basic authentication system with a node backend and wonder whether I am using the try-catch block excessively. I have this example controller:
...
2
votes
0
answers
315
views
JavaScript proxy for better stack traces from external libraries
I've been using the excellent pg-promise library for a few years now, but my primary irk with it is that the stack traces are sometimes unhelpful. For example, the following test will fail (currently ...
1
vote
1
answer
453
views
React Native login, sign up and sign out using Firebase project
I have built a basic app which uses firebase for authentication.
The app is pretty simple.
Sign up the user to firebase using email and password.
Sign in the user
Sign out the user
Also, I have ...
1
vote
1
answer
103
views
Managing file names in a file
The scenario here is to get a filename from the console and create it if it does not exist. I have two main questions;
Is the way I used promises the best way?
is there a better way?
Here is my code;...
2
votes
1
answer
311
views
Check RSS feed and post to Discord
I'm new to using JS for anything other than DOM manipulation, so I'm not sure if the following code is taking full advantage of the Async concept in JS.
This is an example of a function I'm writing in ...
2
votes
2
answers
112
views
Blog API implementation in node.js
This code is from my blog project. This project is almost done. This is working well.
I can create new posts and update and display all saved posts.
...
4
votes
1
answer
1k
views
Wrap async method in a way that the method is invoked only once for all calls that occur while the first of them is not resolved
Imagine we have a function that returns a Promise, ie call a GET endpoint of an api and return the response data.
...
1
vote
2
answers
609
views
Racing promises and consuming them in the order of their resolution time
The ideas are
When multiple async calls are made, to be able to start consuming from the first resolving one regardless in what order the promises are fired.
To construct a modern emitter of async ...
2
votes
1
answer
49
views
Typescript : Adding types to a function that takes in a string and returns a different promise based on the string
I have a function that takes in a string and based on the string hits different APIs to fetch images.
I have solved it by writing an interface and then as the return type of the function, it returns a ...