Posts

CBOR - JSON Encoding

Compact Binary Format for JSON Data Transfer

When you wish to use JSON for its convenience, but also want to send the JSON using a more compact representation to save data that needs to be transfer, you will need to use an information encoder for JSON. These encoders tend to represent the JSON data in binary format for transfer and there are many out there.

Categories: #JavaScript
Tags: #NodeJs
TypeScript - String Enum for Checking Value Type

Ramda's Type Check

Ramda's type checking returns a string, but in order for this to be useful, one needs to know if the returned value matches your intended assertion.

R.type({}); //=> "Object"
R.type(1); //=> "Number"
R.type(false); //=> "Boolean"
R.type('s'); //=> "String"
R.type(null); //=> "Null"
R.type([]); //=> "Array"
R.type(/[A-z]/); //=> "RegExp"
R.type(() => {}); //=> "Function"
R.type(undefined); //=> "Undefined"
Categories: #typescript
Nodejs - Memory Intensive Promise Operations

Backpressure for Promises

When dealing with promises, the processing of long-running tasks is the commonly encountered scenario. However, some long-running task might also be performing memory intensive operations. To deal with running multiple operations at once, it is important to place a limit on the number of promises allowed to run at the same time as to not exhaust the Nodejs JavaScript heap.

Tags: #NodeJs