Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Get Unique Version of (Async) JS Generator/Iterator

I have a function generatorCreator that returns a generator, here an AsyncGenerator (sync/async should not matter). My purpose ...
0
votes
2answers
43 views

Turn array of objects into date-sorted array of objects

I have to turn an array of objects that look this this: ...
0
votes
1answer
25 views

Angular and Typescript page with for loop and array

I have a page that shows the result of a quiz and depends on the number of right answer, the user get some rewards. So, if the user get just one right answer, he will get one reward, the others will ...
0
votes
0answers
36 views

Custom CRUD hook for fetching from an API

I’ve built a basic app that allows a user to create, read, update & delete ‘pages’ (just an object that lists some information; shown below) which uses a ...
1
vote
1answer
43 views

AutoBind TypeScript decorator

Idea is to have an AutoBind decorator which you could append in front of any method to have it preserve its own this, instead of manually binding it when called. <...
0
votes
1answer
27 views

interface different usages issue for two or more different implementations

I am writing a small micro-service in typescript with NestJS. This microservice is responsible of giving a user access to one of our company's systems trial access. At first I used hubspot integration ...
1
vote
0answers
29 views

Is my e-commerce app's code compliant with MVC?

Hi I have spent few days reading about various architectures and decided to use MVC (Model-View-Controller). But I had hard time applying all the theory to my node.js code. I've wrote some minimal ...
1
vote
1answer
103 views

get address parts based on requested parts

I have different format of address in an array, those format looks like this ...
3
votes
0answers
89 views

Create a collection of truly unique objects of custom type

I'm using TypeScript for my Vue app and have a custom type I'm working with ...
0
votes
0answers
70 views

Simple Deck of playing cards in typescript

I begin a simple app who manipulates a deck of playing card here is my first attempt at modeling it, what do you think ? What could be a potential caveat for the future with that model ? Thanks :) <...
2
votes
2answers
68 views

Function to find substring in a list of strings and add them to the resulting list

I am trying to look for a substring in a list of strings. My end result is an array that contains the presence of substring first based on course.name and then ...
1
vote
0answers
41 views

Implement a single page application which fetches data via an endpoint and displays to a html page

I had to make a single-page application that fetches some figures via an endpoint, does some calculations, and displays them to an HTML page. Below is my ...
1
vote
0answers
133 views

My implementation of the Signal protocol for end-to-end encryption in NodeJS and Angular [closed]

I have developed a web app which lets you transfer files from A device to B device, similar to airdrop's concept, working through the server and not peer-to-peer. I didn't go with a P2P solution ...
0
votes
0answers
36 views

Game of Life in Typescript

Just a toy project to learn typescript. I haven't made it interactive in any way, though I think I've programmed it in a way where making it interactive should be fairly straight forward: ...
2
votes
1answer
31 views

Recursive Binary Search in Typescript

I've ran a few tests, not extensive though, and it apparently works. Like many standard binary search algorithms, if the number returned is < 0, you can take the complement (~) of the returned ...
1
vote
0answers
19 views

Typescript React-Native Component Dimension Hook

I did a lot of research trying to find a React Native component which could reference its own dimensions in order to scale different elements in its style, but could not find any solid examples. I ...
1
vote
1answer
80 views

Sort an object array with two variable based on the language

I'm trying to sort a Sector array and a Province array based on the language. sector.ts: <...
0
votes
1answer
87 views

Listing the range from A-Z with special characters in JSX

For generating a list of characters, I currently use a static list, 2 components and some unclear conditional renders. ...
2
votes
3answers
94 views

This code replaces each element of an array with the product of every element of the array except the current one. Suggestions for improvement?

This code replaces each element in an array with the product of every other element in the array but the current element, without using division. So, for the array [5,2,3], the program outputs [6,18,...
3
votes
0answers
53 views

Use formats phone numbers into XXX-XXX-XXX

I created an input that accepts and formats phone numbers into XXX-XXX-XXX. The user should be able to type numbers and the dashes should insert themselves automatically. Example #1: The user types 1 ...
0
votes
0answers
19 views

Extendable Validation Library

I'm looking to develop a validation library which can be extended by adding custom validation rules. To write a custom rule, simply write a class and apply the ValidationRule decorator like so: ...
0
votes
1answer
32 views

Shorthand of compiling min and max values from an array with object into new object

I'm wondering if there is a nicer way to acomplish what I want: I do have an array with object like that: let data = [ {val1: [1,2,3,4], val2:[6,7,8,9] } ] What ...
1
vote
0answers
13 views

Getting metadata out of a Shoutcast stream

I have written the following class used to get the metadata out of an internet radio station. It takes a Node Stream and transforms it to grab the metadata out of the mp3 stream and then removes the ...
0
votes
0answers
66 views

Improving the Speed of loading records into a ngx-datatable

I am using ngx-datatable to load large volumes of records. However, the larger the volume, the longer it takes. I read somewhere that you can speed it up by sorting then assigning it to the data ...
1
vote
0answers
30 views

Merge and autocrop images with Jimp

The following code uses jimp to merge images, located in the ./in folder, with dots.png. Then it autocrops the images. Finally, ...
0
votes
0answers
26 views

TypeScript + React Native: Button Stepper Component

I built a ButtonStepper component and it's sharing quite a bit of the same logic, so I was wondering if it could be refactored better. It's sharing quite a bit of ...
0
votes
1answer
36 views

Refactor typescript long switch case that run different code in according to property value

I have a typescript function that executes an array of actions on a given string value. This is the code: ...
0
votes
0answers
43 views

Typescript Maybe functor

I have been trying to implement a version of the Maybe functor in Typescript. I'm looking for feedback on whether I can improve the type safety of my implementation. I'm not particularly happy that ...
1
vote
3answers
103 views

Replace array values with product of all other values

Need help to optimize the following code for lower time complexity: ...
0
votes
0answers
34 views

How can I call React useRef conditionally in a Portal wrapper?

I am attempting to make a simple Portal wrapper that does the following. Can render multiple portals on the same view Can render multiple portals by targeting parent ids. This cannot be done by ...
0
votes
0answers
34 views

Map over an Object's keys/values, returning a new Object, ala Array#map

In the process of migrating an ancient CoffeeScript codebase to TypeScript, I'm also attempting to abandon lodash/underscore.js-alikes in favour of modern JavaScript-standard-library-features (or ...
1
vote
0answers
24 views

TypeScript generic higher-order function returned function returned type

I have a higher-order function to create another function given a regular expression: ...
0
votes
0answers
24 views

React component to display emojis from different sources

I'm looking forward for any feedback to help improve in any way this React component that will render an emoji from GitHub, Twitter or OpenEmoji: ...
1
vote
1answer
27 views

Find coordinates of neighbors out of given coordinates

I'm programming a checkers game in typescript. I'd like to explain some important details to understand how the following code works. In my game coordinates are a string, like "b4". I want ...
2
votes
0answers
30 views

Keyboard Tester Web Application in Vue 3 + TypeScript

I'm working on keyboard testing web application. As a mechanical keyboard enthusiast, I need to test that all the keys on my keyboard work whenever I build one, or change the firmware for one. ...
1
vote
1answer
58 views

How can I rewrite this typescript map to be more concise?

I have a short bit of TypeScript code that looks like the following: ...
0
votes
0answers
95 views

React Typescript Project Using Traditional OOP Patterns

I'm writing an app meant to have similar functionality to LucidChart - drawing shapes/diagrams. I'm using React with Typescript (Create React App) and am trying to follow OOP/polymorphic patterns I've ...
0
votes
0answers
100 views

Multilingual React Application using typescript

I'm learning react-typescript programming. Developed a sample application, which supports in multi language. github Souce: https://github.com/phanivaranasi/sownikbackend.git Review the code and share ...
0
votes
0answers
26 views

Refactor Javascript filter that handles click and changing together dropdown filters

I'm looking to rework and make it easier to read this handleFilterChange function This is helper being used in the function ...
-2
votes
2answers
106 views

So many if and else conditions [closed]

I have this class ...
0
votes
0answers
19 views

Trying to secure a payment transaction with mysqljs2

In my web app, I am trying to secure a payment transaction, that is: prevent users spending more than they have, especially in the case of concurrent execution and prevent partial execution. ...
0
votes
1answer
71 views

Having trouble with this Koan - solved it, but I don't think what I wrote is correct in regards to Typing

I'm working through these Koans: https://github.com/paytonrules/typescript.koans#readme I'm on file 3, collections, the very first function foreach: ...
3
votes
1answer
87 views

A React - Typescript custom hook for any request (GET, POST, PUT, DELETE) to my back end

I'm building a full stack exercise app and some of my objects include routines, exercises, exercise sets etc. Instead of writing out specific get, post, put and delete requests for each resource, I ...
0
votes
0answers
97 views

Obfuscate email React component

I've written this Email component which obfuscates the email until the user hovers over it: ...
0
votes
0answers
49 views

React children props array type predicate

Component: ...
1
vote
0answers
50 views

Genetic Algorithm Typescript

I learnt a little about genetic algorithm. And I made a program from typescript that tries to evolve and match word/sentence using genetic algorithm. But if I give a little longer sentence it takes ...
4
votes
1answer
141 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
1answer
33 views

abstract navigationOptions react navigation

I have many stacks with the same navigation options, how do I abstract the navigationOptions part to have it repeat in all my stacks? ...
2
votes
2answers
68 views

Calling functions if certain strings are in an array

I have these few helper function that are used to check if the string in the given array is present and if the certain steps are present and then only have the other function fire. The reason I ...
0
votes
1answer
38 views

Typescript angular queryparams

I have some code like this ...

1
2 3 4 5
10