Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

-1
votes
0answers
18 views

better approach on caching data from HTTP call [on hold]

I'm creating a service that will pull data from server, then load that data into a property to be used later on, then notify all component that the service "is ready". The idea of loading data into a ...
2
votes
1answer
53 views

List component using RXJS Angular

I have a small angular project, where I have an Article component to list articles with pagination system. The default page The placeholder loader page The main objectives are: Display the ...
0
votes
0answers
14 views

Deleting a scheduled appointment from Firebase in Angular 7

The following code is a service that lets you delete an item from a firebase collection. I wanted to know if there was a better way to error handle on this function. schedule.service.ts ...
1
vote
0answers
13 views

@bound decorator for TypeScript

I'm working on an angular codebase that very frequently uses constructs like: <c-whatever [action]='doSomething.bind(this)'> to pass reference to the ...
1
vote
0answers
10 views

Organization project and http-Client

I did not have experience with organization project and http-client. I suppose this is the right way. I have data-storage service where I store my data from server. ...
-1
votes
0answers
11 views

Tips for elegant way to assign value of a object based on array search result?

I have this array of number that is based on a dropdown selection of elements, and i have an array of object based on this interface: ...
2
votes
1answer
29 views

Convert 'rgb()' string to hex string

The scenario is the following. I get the string from an HTML element via outerHTML and I need to convert the 'rgb(r, g, b)' part into the hexadecimal representation. I tried this with regex and it ...
2
votes
2answers
54 views

New password generation

...
1
vote
2answers
61 views

ACL express middleware implementation

I come to see you to help me improve an express middleware that allows you to control access resources by checking the rights of the user. The following code is supposed to be as generic as possible ...
3
votes
0answers
51 views

Override prototype inside of constructor of ES6 class for dependency injection

We implemented a small dependency injection mechanism which we use in our project. Now after 2 years of developing our project we need our classes to know who instantiated them via dependency ...
1
vote
1answer
25 views

TypeScript 3 form validation object

Please, correct me with anything that I say in here (The actual question is below the code). I've been quickly prototyping a project (ASP.NET Core 2.1) and haven't found the need to structure it with ...
0
votes
0answers
28 views

Functional, recursive algorithm for flattening a tree

My goals for the algorithm were to use recursion, to avoid mutation, and to decouple the tree walking from the action that we take on each node. My sense is that the result uses mode code is ...
0
votes
0answers
21 views

Is it much better to add a method to String library in Typescript

I'm using Typescript now I want to add another method to the existing library for using my application as below instruction. So I would like to ask about the ...
0
votes
0answers
33 views

Deferred Iteration in TypeScript

I've published a new TypeScript library currently in beta, and was hoping to get feedback on certain aspects of it, particularly implementation details for improving the performance of deferred ...
1
vote
0answers
59 views

Nodemailer class

I created the following class for sending mail in my node.js API : ...
3
votes
0answers
33 views

Automatically generate TypeScript classes from database tables

Made a project to generate TypeScript classes from database tables, and I'm looking for input if the code is reasonable. pg and ...
2
votes
0answers
37 views

Addition of defaults to components in AngularJS

I wrote a small module in typescript that augments the angularjs registerComponent function to provide a new way of default values for the component controller. ...
1
vote
2answers
80 views

DataService that fetches data not loaded already or loads cached values

I load an array from an API that is available throughout the user's whole session. This data is unlikely to change, so it can be cached safely. I have a DataService ...
1
vote
0answers
16 views

Angular2 “Logged In State Watcher”

I have a small website I'm working on as a hobby and I created a login page/home page so far. I wanted to get the basic login/logout functionality going before filling out the main part of my site. ...
3
votes
0answers
67 views

Tic Tac Toe game (Game logic, no UI)

I've implemented a simple class for managing a Tic-Tac-Toe game's logic and state in Typescript. This code is intended to be used by a larger program; it doesn't implement any aspects of a UI. I've ...
0
votes
1answer
30 views

An Angular service to provide window and document objects

In some components and services I need the window and document. So I created a small service, that provides these two objects. ...
1
vote
1answer
39 views

Language switcher, consulting browser's localStorage

I'm using angular 6 and ngx-translate. This is my switch language function ...
1
vote
0answers
290 views

Angular async pipe with loading spinner and manual refresh

I have an Angular 6 app with the following requirements: Get data from a web service. Load the data when the page is displayed. Reload the data when the user requests a reload by through some UI, ...
1
vote
2answers
48 views

Generic function with same logic but different input structure

I have a data structure that looks like this: interface Node { originalWeight: number; currentWeight: number; } where both properties are floats between <...
5
votes
1answer
79 views

Angular directive to disable a button when clicked, allowing re-enabling as needed

I have written an Angular Directive that disables a button after it has been clicked, to prevent double posting / saving of data. This works fine in most of our use cases. However, in some situation ...
5
votes
4answers
55 views

Calculating total size of player data

I am writing a function to calculate the total size of a "player appearance". There are various "item slots" the player has, and if they are empty then 1 byte will be sent, otherwise there will be 2. ...
3
votes
0answers
52 views

Optimizing NICK binary thresholding

NICK binary thresholding essentially boils down to a convolution where the kernel at each pixel calculates the sum and squared sum (for the standard deviation). These values are then used in the ...
1
vote
0answers
38 views

Test for an array being subset of another master array

This is my first question in this forum. I was trying to build a small utility function to check if array is part of other array. Testing if an array is subset of another master array. ...
2
votes
1answer
75 views

Angular service for fetching and passing data with observables

I have an Angular service consisting of three methods: This method makes a call to my server to get a URL ...
0
votes
0answers
35 views

Asynchronous API handler function to update a game

I think mainly the GameController can use some optimization Game Entity.ts ...
1
vote
1answer
768 views

Checking whether an array contains a value or another array

I'm designing an isIn method that takes a value:any and checks whether it exists in an array. It's working, but I'm wondering ...
0
votes
0answers
28 views

I have three classes which all make API requests, how can I refactor their similar methods?

I'd first off like to apologize if this is the wrong place to post this question, but I figured that code review would be the most relevant place (compared to stackoverflow and softwareengineering). ...
0
votes
0answers
354 views

Checkboxes behave like radio buttons with angular

This is short Angular 5 code which works as intended: check boxes behave like radio buttons - only one can be selected at a time. Both versions of 'toggleCheckbox' works but I am interested is if ...
0
votes
2answers
247 views

JS code that search through every property in a nested object

I wrote code to search by keyword, and it will check all of the values from the object property, including an array in the object. But apparently the code is not optimized as it takes some time to ...
1
vote
0answers
97 views

Angular form data over multiple components

I have a form that I have broken into several different components in Angular. By the end of the form, all the data needs to be submitted together. My thought process was to create a provider to ...
1
vote
0answers
20 views

Firebase Plotter for Ionic

I've written this plotter for Ionic in Typescript to plot data that I push to a Firebase list. I'm new to Typescript so I'm interested in all kinds of feedback, especially on the style. First I've ...
7
votes
3answers
155 views

Find the fastest run of each year from a list of running results

Problem Explained: Imagine there is a list of running results of 1000m, like following: ...
3
votes
2answers
186 views

Creating nested objects from string

I implemented a method, to create an object based on a series of strings that are passed to it, of any depth or length. The way I implemented the solution was to map over the arguments. Assuming that ...
0
votes
0answers
28 views

An npm package to mirror/clone text areas without jQuery

I've been trying to get away from jQuery lately and needed to re-create a script I used for mirroring text inputs. npm i mirror-txt.js to include GitHub <...
0
votes
1answer
164 views

Promise-based fixed delay poller with timeout

I have the following functions for polling some function periodically with a timeout ...
5
votes
1answer
171 views

Factory method done on reactjs component,

A Factory Pattern or Factory Method Pattern says that just define an interface or abstract class for creating an object but let the subclasses decide which class to instantiate. In other words, ...
2
votes
0answers
183 views

Robot on a Grid: Find a path between two corners with forbidden cells on the road

Problem statement The problem is defined in the book as following: 8.2 Robot in a Grid Imagine a robot sitting on the upper left corner of grid with r rows and <...
0
votes
0answers
133 views

ReactJS Component that retrieves quotes

I have created the following React Component and wanted to have feedback about if its SOLID or not, and what can I do to make it SOLID? I do believe its SOLID but would like feedback from guys with ...
0
votes
0answers
60 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
49 views

Redux-like implementation in TypeScript

I need to write a custom reducer utility. It should take a dictionary of reducers and a publish subject to return a state, with a dispatch method to dispatch ...
1
vote
0answers
41 views

React Text Highlighter HOC in TypeScript

I'm shifting my focus towards frontend as much as I can, but I'm still quite unsure if I'm writing good code or not. Please take a look ...
0
votes
0answers
33 views

Jasmine tests for tax calculations in Angular 4

I am writing Jasmine tests in an Angular application and need to verify if I am testing correctly. If not, I would like suggestions in what area I should actually test. If you see in the code, ...
2
votes
1answer
49 views

Which will be better declaration go to with TypeScript? [closed]

This is a simple question, but during my migration to TypeScript, I'm seeing that in many cases my code could take these two directions... which one could be a better direction to go with: ...
0
votes
2answers
38 views

Picking a time based on when the app was last used

I am trying to set up a time variable as a local storage property to be retrieved when I open my app in my browser. If I open it for the first time, today, I'll set it up to today at midnight. ...
10
votes
1answer
125 views

Checkers Board Creator

A year or so ago, I wrote a checkers game for the Universal Windows Platform. Now, I wrote a web-based version of it hosted at http://checkerstreasury.azurewebsites.net. This is the first of a series ...