Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

Filter by
Sorted by
Tagged with
3
votes
1answer
546 views

@angular/fire Firestore cached service

I've written a service for firebase that handles all my Firestore calls. The goal is to only read the database once on app init( load() function) and then keep a copy of the database inside local ...
2
votes
2answers
62 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 ...
2
votes
0answers
61 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
42 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
1answer
27 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
102 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
1answer
54 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. ...
1
vote
0answers
37 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 ...
2
votes
1answer
50 views

build up object[] from raw data set

I have a list of raw data like following mockData and need to generate to a object[] format, some key-value pair are required from raw data like first, last, state. but some key-value pair are option ...
1
vote
1answer
76 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
0answers
33 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: ...
4
votes
1answer
751 views

Parse big JSON for reactive form

I implements big reactive form on angular5. This form get data from JSON. I use formBuilder and several nested formGroups. Every field have default value before rendering form. In console output form ...
1
vote
0answers
16 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
61 views

Format multiple dates to look good in text, using functional approach

I had a piece of code that solved really simple problem - it formated two dates to look better on a webpage. It looked like this: ...
2
votes
3answers
89 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
49 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 ...
1
vote
3answers
99 views

Replace array values with product of all other values

Need help to optimize the following code for lower time complexity: ...
0
votes
0answers
18 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
1answer
32 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
60 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
19 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, ...
3
votes
1answer
75 views

Typescript design pattern for rendering different objects with similarities

It's a web project. The code is working. The question is a design pattern question to write code that's more elegant, you know. I've created a Codepen of this question. I created a ...
0
votes
0answers
23 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 ...
4
votes
1answer
149 views

Extending react hook useState for use in event handlers

I use React with material-ui.com and I love them both, but I'm tired with writing the boilerplate handlers like ...
0
votes
0answers
39 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 ...
0
votes
0answers
28 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
33 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
23 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
22 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
26 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 ...
9
votes
1answer
4k views

Angular 5 Forms - Extending Form Control

I am taking a first pass at Angular Forms with some colleagues and noticed an interesting design pattern implemented by a coworker where the FormControl is being ...
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
56 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
80 views

Obfuscate email React component

I've written this Email component which obfuscates the email until the user hovers over it: ...
1
vote
1answer
87 views

zip_longest without fillvalue in typescript

I would like to create a function like zip_lognest in python and if the array size is uneven, I do not want to filled any value. following is my code and example ...
0
votes
0answers
60 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
62 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
105 views

So many if and else conditions [closed]

I have this class ...
1
vote
1answer
29 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? ...
0
votes
0answers
18 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
71 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 ...
5
votes
4answers
4k views

Cracking the Coding Interview: "Problem 1.5. One Away"

I am going one-by-one through problems in the "Cracking the Coding Interview". This question is about problem 1.5. One Away. Since I was never good in "algorithming", any suggestions are highly ...
0
votes
0answers
31 views
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 ...
2
votes
1answer
64 views

Typescript type checking of hierarchical types

I want to create a hierarchy of Typescript interfaces because I think classes would be an overkill in my case. The main obstacle is checking if an object has a specific type. I solved it this way: <...
1
vote
0answers
49 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 ...

1
2 3 4 5
10