This article focus on a few common ways to read a file in Node.js (also using typescript for the code examples).
EventStreamopen source npm library
A common mistake when reading a file line-by-line in Node.js is to read the whole file into memory and then split its content by line breaks. Doing this might overload your system, especially when dealing with large files.
Here is a sample file with many lines which needs to be processed line by line.
# app.logLine 1
There may be times when you need to compose a new type from already existing string literal union type.
Composing here could be just removing some entries from the original type or adding new ones along with the removal.
from TS official documentation: https://www.typescriptlang.org/docs/handbook/advanced-types.html#string-literal-types
String literal types allow you to specify the exact value a string must have. In practice string literal types combine nicely with union types, type guards, and type aliases. You can use these features together to get enum-like behavior with strings.
TLDR; A string literal type can be considered a subtype of the string type. This…
In this article, We will be looking at how to migrate an AWS lambda function deployed as a Serverless application into a Pulumi project without modifying the underlying lambda code.
This article assumes that you have a basic understanding of serverless framework and .
You can find the complete code for this article on GitHub.
Let us first imagine that we have a serverless application with a single lambda function (
createTodo) deployed in AWS. To make it interesting, we will use the code from typescript todo rest api example serverless examples repository.
The project structure could look something like…