Questions tagged [typescript]
Typescript is a language which is a super set of JavaScript
519
questions
1
vote
0
answers
25
views
Simple Todo app using latest React and TypeScript
I would like to ask your advice on the frontend code of todo app.
Main functionalities:
The app has authorization and authentication using backend.
The CRUD functionality for managing tasks
What may ...
0
votes
1
answer
71
views
Move timestamp to the next Monday 10:01 AM
I've been battling ChatGPT for hours now and can't get satisfied with this simple algorithm in TypeScript. These two (hopefully correct) TypeScript+ReactNative solutions should move the timestamp ...
0
votes
0
answers
19
views
matching generic items
Hello fellow developers
I was wondering if anyone, with more understanding of javascript, is able to detect some potential flaws or performance issues with this recursive function.
It works as ...
3
votes
1
answer
216
views
Find the closest named color
I have a .json file with name (string) and RGB (r, g, b: numbers) with 30.000 key-value pairs. I am looping the json multiple times per second to find the closest name to a given RGB color. Any idea ...
0
votes
0
answers
17
views
Object-based Radix Sort via an Iteratee
I recently finished implementing a radix sort for objects where either one of the keys is numeric, or can be expressed numerically via an iteratee.
...
0
votes
0
answers
32
views
Is there a better way to design this React TS filter component?
(React TS)
I'm trying to get better at composition & make components more reusable for different purposes. As well as improve my general JS/React skills. (Side note: I feel like TS makes it a bit ...
1
vote
1
answer
84
views
Simple Curry function
This is a interview practice question from BFE.dev.
Currying is a useful technique used in JavaScript applications.
Please implement a curry() function, which ...
1
vote
0
answers
103
views
Simple Table With Collaborative Editing
The following is my React code to create a simple app containing a table which can be edited by multiple people at the same time. Each client connects to a WebSocket via a custom hook. The WebSocket ...
1
vote
0
answers
43
views
Functional style dependency injection to make business logic unit-testable
My project is a blogging app, which is a recruitment assignment. It is now finished and working.
Following function handles updating a comment votes, very similar as on StackExchange sites, preventing ...
0
votes
0
answers
31
views
Typewriter component that updates span one char at a time in Next.js + TailwindCSS
I have created a Typewriter component that animates a span to display text for my portfolio website. The goal was to have an array of strings that are cycled through and an animation that types them ...
1
vote
3
answers
242
views
List consecutive days
I created this method for consecutive days to be listed with a dash, non-consecutive are separated by “and”. In my UI control I am only getting back a ...
1
vote
0
answers
56
views
Calculate total running time for movie series
Which of these 2 functions is better and more readable and why? (Both functions do the same thing).
My goal is to get the total time of a series, using the TMDB API (which has a limit of 20 different ...
0
votes
3
answers
59
views
0
votes
0
answers
15
views
React component for size control of CSS variable
So I spend a day trying to understand how could I resize components, I came up with this method which surely isn't the best, but I liked it:
Create component
This component uses mouse events to ...
0
votes
1
answer
158
views
Spring Boot Account API with React Frontend and Identicon Integration
I have recently been exploring React and Spring Boot, and I would greatly appreciate your feedback on a practice application that I have developed. The application consists of a Spring Boot backend ...
0
votes
0
answers
41
views
Removing Brackets and Bracketed Content from a String
I have a site that I made to parse parts of Wikipedia articles for me. Part of this is removing parentheticals and citations.
I came up with the following implementation:
...
1
vote
1
answer
269
views
Movies App with Vue 3 and TypeScript
I have made a Movies App with Vue 3, TypeScript and The Movie Database (TMDB) API. For aesthetics, I rely on Bootstrap 5.
In src\App.vue I have:
...
1
vote
0
answers
30
views
Asynchronous Generic Resource Pooler
A personal project I'm working on needs Worker (thread) pool. The libraries I looked at were too high-level for my needs, as I simply needed access to the Worker itself while the libraries offered ...
0
votes
1
answer
36
views
Creating functions in a hierarchy where they get the same arguments
When I write code, I tend to follow functional paradigms often. The main thing I try to do is use values returned from functions.
What I notice though, is I end up having a sort of function argument ...
0
votes
0
answers
53
views
Chaining react hooks using uniswap style template
I'm trying to chain react hooks together. I need to do the following
Obtain the Balance of NFT's a user has
Enumerate the balance of nft's and generate index arguments to call the RPC to get the ...
1
vote
0
answers
63
views
Angular Lazy Loading Component into HTML template
I want create a generic component for lazy loading other component
Demo online (click on load button)
https://stackblitz.com/edit/angular-v7xfwb
this is the code
...
0
votes
0
answers
275
views
Promise queue Typescript
As an exercise, I wrote a promise queue in Typescript. The point of it is to parallelise a maximum number of promises, and not just Promise.all() to batter the ...
5
votes
1
answer
293
views
Most compact data format for a shopping cart
I'm trying to build a format that can represent the user's cart on my website in the most compact way. The website is related to computer parts and there are 23 product categories. Each product has an ...
0
votes
1
answer
32
views
Choose a marker for the map based on the alerts it has
I need help to refactor this code, I think I can avoid the first two functions that filter the array. Also in the third part where I use the result of these two filters:
...
2
votes
0
answers
530
views
React hook to play audio with Web Audio API
My goal was to make playing sounds in my React game easy and efficient. Using <audio> tags wasn't an option, because on mobile it creates huge delays between ...
1
vote
1
answer
130
views
Function component wrapper for the js-year-calendar widget
I have this class component from the rc-year-calendar library.
...
1
vote
1
answer
117
views
Rock, paper, scissors game in expressjs typescript
This is a simple 2 player game made in NodeJS and the ExpressJS framework with typescript. I've built using OOP approach to as far of an extent as I know of it. I'm really curious as to how further ...
1
vote
0
answers
562
views
NextJS NextAuth Implementation using Custom Token Source
I am new to NextJS, it has somewhat been forced on me and the existing code was not authenticating correctly (after a period the site would hang - not return to login - this was due to the way we were ...
1
vote
1
answer
64
views
PaginationBar component that renders links or buttons depending on optional callback prop
I have several components/pages in my personal project that contain complex logic and even nested ternary operators. Since I'm the only person working on this project, I don't have a hard time ...
0
votes
2
answers
97
views
Complex statement in typescript get?
I have some get function like this
...
0
votes
1
answer
151
views
Filter based on object field in TypeScript
I have four arrays of the same object which I use for a form.
They work as pairs such as list_1 contains all possible values and ...
0
votes
2
answers
98
views
How to write repetitive styled components in a cleaner way
I'm using Styled Components for styling and there are many icons defined in the project so in the style file we have this code:
my-component.styles.ts
...
0
votes
1
answer
144
views
How to reduce the 'useEffect` hook to make more performance
I have created a tab Accordion. at present it works fine. it should:
open and close on click ( shuffling )
on click of a tab other tabs should be closed if open ...
0
votes
1
answer
119
views
Check if string starts with vowel
I am using a template for a text inputs and feedback messages to simplify my html code. This passes in variable string called label and populates the placeholder ...
1
vote
2
answers
105
views
Optimizing - formatting a person's name
I need to take a user's name and format it 'lastName, firstName middleName'. If firstName and middleName are not present then the comma should not be included with lastName. Below is what I came up ...
2
votes
2
answers
255
views
React component which uses another component for rendering
Having this React component:
...
1
vote
0
answers
149
views
Set-new-password form, including validation
I've got to make a form using Bootstrap and Angular, which validates the following requirements:
Old password, new password and confirm password are mandatory fields.
New password has to be equal ...
1
vote
1
answer
137
views
A graph interface for Wikipedia
I'm building a graph-based interface to explore Wikipedia, but I'm not really familiar with TypeScript/React (especially state management), so I really feel like I'm just Frankensteining things ...
0
votes
0
answers
33
views
Asynchronously building a service container in TypeScript
The compiler provides a synchronous use() method which accepts a middleware - that is a function that creates any services it wants, the ...
3
votes
2
answers
145
views
Get an `Object` that is the difference between O & O1
There was this type challenge:
Get an Object that is the difference between O & O1
I ...
2
votes
1
answer
229
views
Two Sum Leetcode problem using Typescript
I've recently gotten into Typescript and I'm solving some Leetcodes to learn.
Problem description:
Given an array of integers nums and an integer ...
1
vote
0
answers
25
views
Figure out all paths of all nodes up to k depth
I'm trying to figure out all the paths of all the nodes up to K depth.
It seems to be a dynamic programming problem, my attempt seems to be working however its slower than I expected
I would think ...
0
votes
1
answer
74
views
typescript poker filter pairs from 7 card deck
I am making a poker game and poker-evaluator that I am using to tell me only the outcome from the cards
...
1
vote
1
answer
52
views
DRY-ness of two typescript functions
Is there a way to make this code bellow more DRY or is this fine as it is? I am wondering if there could for instance be a way to combine the two functions in to 1, the output type of which would be ...
2
votes
0
answers
144
views
Angular: ViewModel for safe two-way binding & MVVM
Introduction: Any angular dev should know that Angular tends to provide multiple ways of doing things. When it comes to forms, I tend to prefer to rely on forms of the template-driven variety, and ...
0
votes
1
answer
323
views
Awaited store for Svelte
In my Svelte app, I need to reactively fetch data from the server and then render the result. The ideal data struture for this is a store whose values are promises – eg. like this:
...
-1
votes
1
answer
35
views
A better way to write if this then this = this / number or * number [closed]
Im wondering if there is a better way to write these expressions in Angular 13, They dont fit most of my more senior compatriots code, And i'd like to not add messy conditionals if not needed. They ...
0
votes
1
answer
38
views
Function to evaluate loan eligibility
I have a function and am wondering whether I have written it the most performant way by using multiple guard clauses in the code above some of the variable declaraciont.
Here is my code:
...
1
vote
1
answer
72
views
Generic function accepting object and validators for this object's fields
I recently started TS.
I was looking for feedback on my below function (for example maybe it can be written in shorter way). Let's assume we still use the reduce ...
3
votes
3
answers
94
views
Display random simpson quotes
I'm new to Typescript though I've got a few years experience with plain Javascript. This is the first full program I've built in Typescript using Next.js. I'm just curious about areas where I can ...