Questions tagged [typescript]

Typescript is a language which is a super set of JavaScript

Filter by
Sorted by
Tagged with
5
votes
0answers
38 views

Macao, a General Game Playing AI library - Game state goes in, best move comes out

I'm working on a simple General Game Playing AI library. The idea is that it should work with almost any kind of game, with a minimum of configuration. At the moment, I have it working on 2 player ...
3
votes
1answer
91 views

Updating an offset in a buffer after each read

I'm having a bit of a debate at work regarding when to replace numeric literals with variable names. I have a function that reads data from a buffer and after each read, updates the offset so that ...
2
votes
1answer
531 views

Storing a fetched list of printers in Angular

I have a need to store data retrieved my ASP.NET Web Api to stop making redundant API calls for the same data when I navigate through my Angular page. On my API I have a database which stores a list ...
4
votes
1answer
185 views

Local weather app made with Typescript

I would like feedback on my Local weather app. This site simply gets the local weather. I refactored it from jQuery to Typescript to try to learn more about Typescript. Here is a demo: https://...
6
votes
1answer
277 views

State Monad in TypeScript

Here's my implementation of State Monad in TypeScript, based on a canonical Haskell implementation. I would like it to get code reviewed. ...
3
votes
1answer
87 views

Transforming data from an API using Typescript and Lodash

As a front-end developer, I am given the following result from an API, an array of objects that looks like: ...
3
votes
0answers
363 views

Filter properties and format values if they are currency

The function I've written in Typescript works great, but I'm not convinced that it's the cleanest and most efficient function. The function takes an object, omits properties found in an array, and ...
3
votes
0answers
63 views

Boilerplate-free mixin pattern for a TypeScript charting library

The TypeScript handbook provides a mixin pattern but it requires a bunch of boilerplate, doesn't work for getters/setters and doesn't support defining default values (or any constructor work) in the ...
2
votes
0answers
100 views

Space shooter game in TypeScript

I recently started learning TypeScript and created a small space shooter. I would like to get some feedback on the structure of my code. I have some classes with both static and instance methods with ...
6
votes
1answer
2k views

Iterating through nested array of objects

I have the following JSON list of objects, and I'm able to find the required object, and pass it back to the caller, given the id. Everything works fine, I'm just ...
1
vote
0answers
39 views

Fetching student and teacher data from a given date range

I have two APIs which fetch data of teachers and students from a given date range. I am using forkJoin to get both APIresponse and display the data with a regular interval of 10 ms. This is working ...
1
vote
1answer
77 views

Group orders with Ramda

I made some crude code using RamdaJS to essentially group orders by their states. There are some nested structures. Currently, I have a working code, but I wondering if Ramda can perhaps help to clean ...
3
votes
2answers
966 views

Extracting First, Last & Middle Name from a full name

My function takes a string of Name and returns First Name, Last Name and Middle Name as output. Please review and help me optimize it. ...
1
vote
1answer
111 views

Monkey-patching Jasmine's it() function to log errors

The introduction of async native support in Jasmine doesn't log the errors (i.e., specific line number where the error occurs) to the console. So, to get around this behavior and to make the errors ...
3
votes
0answers
148 views

Build dynamic HTTP service with Angular

I have an Ionic application, this application contains set of pages and services. Since I'm working with Ionic and Angular I decided to build reusable code for different projects, for example: HTTP ...
3
votes
0answers
343 views

Blocking Promise-driven queues with ECMAScript's async/await and generators

I implemented an AsyncQueue, whose dequeue() operation returns a Promise. The ...
1
vote
0answers
47 views

Class to handle complex form using Angular ReactiveForms

I'm working with the ReactiveForms in Angular5 and trying to find a good way to do this. So, in my use case, I have a FormGroup inside my example.component.ts and when I need to add some FormControl ...
-1
votes
1answer
893 views

Javascript RabbitMQ -> Pull Single Message [closed]

I'm trying to pull a single message off of rabbitmq, process it, and acknowledge that single message. I don't want it to continue after acknowledgement pulling messages off the queue. If I don't do ch....
1
vote
1answer
264 views

Using Vue to help form validation with weight for age

I am refactoring a very old web page which calculates bolus and infusion drug doses for children from premature through to young adulthood. One of the most common drug errors is accidental 10 fold ...
1
vote
2answers
169 views

Generator function to enumerate files

I want to implement a function that enumerates all files in directory. I think the function should Return a Promise, because underlying readdir call is prefered ...
4
votes
1answer
42 views

Converting Object to Map using Generics

Problem I am loading things from the localStorage and this has to be saved as json, so it needs to have a simple Object ...
2
votes
0answers
1k views

Angular 5 Forms - Extending Form Control

Currently taking a first pass at Angular Forms with some colleagues and I'm noticing an interesting design pattern implemented by a coworker where the FormControl is being extended to allow for ...
2
votes
0answers
1k views

RXJS queue up multiple http requests and send when x conditions happens

Just started to use rxjs few weeks ago, I think I'm getting most of it right, but my code seems to be not that efficient and prone to bugs I haven't run into yet! I need to be able to send http ...
1
vote
1answer
130 views

Async database helper function in TypeScript

I have made an async function in TypeScript that responds to Events and returns an object with methods that return a promise. I ...
4
votes
1answer
375 views

Text adventure game - text input processing

As a fun project with my wife, I decided to make a small text adventure game à la Zork. Instead of using available engines, I decided to roll my own. It won't be that hard since there are no graphics. ...
4
votes
1answer
179 views

TypeScript based Promise/A+ compliant, awaitable promise class for Node.js

This is yet another Node.js Promise implementation, but this is written in TypeScript, and it strives for type safety and clarity. The full project is located here. Feel free to download it and test ...
0
votes
1answer
719 views

Exception handling and releasing of OracleDB connection

Before I start implementing several REST API service endpoints, I'd like to make sure that I'm not doing it totally wrong. ...
5
votes
3answers
576 views

Poker Holdem Hand Evaluation 7 cards to 5

I'm building a poker Hold'em hand evaluator. Ultimately my goal after building the evaluator is to build a client on the browser but that's far from now. What I've done so far is a hand analyzer that ...
1
vote
2answers
65 views

Weather application data structures and design

Relevant files are script.ts, WeatherData.ts, index.html. I made a simple weather 5-day forecast application using mainly TypeScript. I was wondering how I can improve my code since I originally ...
0
votes
1answer
352 views

Mock customer DAO using abstract factory pattern in React

I wanted to implement abstract factory method in typescript with react for sharepoint framework webpart. So I tried to translate ideas from this Java tutorial. I don't have method implementations ...
1
vote
0answers
58 views

Calling Service and Initiate under ngOnOnit (not in Constructor) Hook in Angular4

I am using WP REST API V2 with Angular v5. I am display all items available from API for /do route inside WeDoComponent ...
3
votes
1answer
295 views

Angular + Redux app organization and initialization: transfer from a PHP-driven website

Our system is largely a PHP-driven system. We're not doing the full split back/front-end. Most pages are plain HTML served directly by PHP. However, a few parts of the system are very dynamic and ...
1
vote
0answers
50 views

Pig game in Angular4

I am a newb in Angular 4. I have written a component but have some questions. I used member variables of class and modified variables within functions. Is this right approach or I should implement it ...
8
votes
1answer
382 views

Lightweight Angular tooltip component

I made a small Popup component to show different error/success...etc. messages. Template: ...
3
votes
0answers
53 views

“Academic interest” implementation of a Finite State Machine

Context I'm playing around the concept of a Finite State Machine. While I understand the basic principles behind it, I want to implement a simple, yet generic class which could be reused in the ...
1
vote
1answer
37 views

Logging observable values while extending service

I'm trying to extend a service function which returns an Observable<T>. The idea is to extend the function so I can add logging functionality whenever the ...
-2
votes
1answer
60 views

rewriting simple conditional loop

I'm doing some refactoring and was wondering if from this original code: ...
3
votes
1answer
2k 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 ...
1
vote
0answers
30 views

Factory method to make JSON requests for various types of list items

I have the following code: ...
1
vote
0answers
380 views

Last element pivot Quicksort exercise in TypeScript

Never being good in "algorithming", I'm now trying to improve the situation a bit. An algorithm below is the attempt to home brew yet another quicksort. This time, specifically with a "last-element" ...
3
votes
1answer
3k views

TypeScript Generics: Create a generic map

Exercise from a TypeScript course: Create a map using TypeScript Generics. The key is always a string. The value can be a string or a number. It has to work with both types. It's got to ...
2
votes
1answer
46 views

Angular2 Toggling showing and hiding between two elements

I have a tabs nav element that has two tabs, it needs to show a component based on what tab was clicked and hide the other component. If the clicked tab is already "active", the component needs to ...
1
vote
1answer
252 views

Rendering SharePoint lists into tables with any number of columns

I have the following code, but first the explanation. I am using a REACTJS Office UI Component called details list: https://developer.microsoft.com/en-us/fabric#/components/detailslist And I want my ...
2
votes
2answers
4k views

Find the most common number in an array of numbers

Exercise description: Find the most common number in an array of numbers. Create a software that takes an array of numbers as parameter. The return of the function shall be the most common number. ...
0
votes
1answer
1k views

JSON API call in an Angular service

I have followed this format in my application to call the API and get data from it: ...
1
vote
1answer
130 views

Implementing a generic Comparator

I'm familiar with JS, however just today started TypeScript. Experimenting with the type system and generics, I thought to implement a comparator yielding 3 distinct results and created the following: ...
1
vote
1answer
222 views

Changing http-requests conditionally

I'm new to RXJS and I have a working piece of code for http-request and subscribing to Observables from a shared service in Angular. This works, but I'd want to get rid of the nested subscriptions, ...
0
votes
1answer
75 views

Promisifying a third-party JS library with minimal code overhead

Context and Existing Code I am trying to "promisify" a third-party authentication library (auth0-js) written in JavaScript. Right now it uses callback functions and there are no plans to expose an <...
3
votes
2answers
304 views

Quiz component with different but similar data models

I have a component with this template: ...
0
votes
2answers
1k views

Angular 4 Application

I have created an application with Angular 4. I set up the Angular application with Angular CLI. Can anybody check this and suggest some improvements? Following is the folder structure I used: In <...