Light-Arrow: Composable and Type Safe Asynchronous Programming for Typescript

Light-Arrow: Composable and Type Safe Asynchronous Programming for Typescript

Welcome to part 1 of this series on using the typescript library Light Arrow for functional programming in Typescript. In part 1 we will cover the Arrow data type. In part 2 we will build a fully type-safe http server.

Welcome to part 1 of this series on using the typescript library Light Arrow for functional programming in Typescript. In part 1 we will cover the Arrow data type. In part 2 we will build a fully type-safe http server.

I am the author of Light Arrow and the project is still in its early stages, please_get in touch if you have any feedback, thanks!

Arrows and Promises

Arrows are data structures that describe asynchronous operations that can succeed with a result value R or error with a value E that depend on some dependencies D. Practically many programs or parts of programs we write fit that description, and often Promises are used for this purpose. However, there are some drawbacks with Promises.

Lets first look take a look at the Promise Type signature.

Promise<A> represents an asynchronous operation that can succeed with a value of type A. But what about failure? this isn’t represented in the type signature, so we have to look inside the implementation of our particular promise and determine what types our catch error handler needs to handle. Promises are also eagerly evaluated and not referentially transparent which can cause issues when we are refactoring. Referential transparency means we can replace all expressions in our program with the values returned from those expressions, without changing the programs behaviour. For more on potential issues with Promises check out this article.

javascript async-functions typescript nodejs

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

The Difference Between Regular Functions and Arrow Functions in JavaScript

<p>Other then the syntactical differences. The main difference is the way the this keyword behaves? In an arrow function, the this keyword remains the same throughout the life-cycle of the function and is always bound to the value of this in the...

Function Expression vs Function Declaration in JavaScript

In this article, we will acquaint ourselves with three simple terms: function declaration, function expression, and hoisting.

JavaScript Factory Functions

In this video tutorial, we'll learn JavaScript Factory Functions. If you are still wondering about it then this video is for you.

The real reason why JavaScript has arrow functions

The real reason why JavaScript has arrow functions Nowadays, all my code is based on the use of arrow functions. If you are still not using them yourself, then don’t be ashamed of who you are. That’s your parent’s job. Instead, find about all the benefits that you can get by using arrow functions like the cool kids. You may notice that the code is shorter and that there is an arrow. Everything before the arrow is arguments of the function and everything after the arrow is always returned as the result of the function.

Arrow Functions vs. Regular Functions in JavaScript

The regular functions contains the list of arguments. Learn when and when not to use the arrow function. Arrow Functions vs. Regular Functions in JavaScript. JavaScript arrow functions are roughly the equivalent of lambda functions in python or blocks in Ruby, but they have more intricate details.