Adapt JS Code to smooth SVG freehand drawn path in real time

Job ID: 38053237

Budget: $30 – $250 USD

I'm developing an open source WBO whiteboard: https://github.com/lovasoa/whitebophir.
In order to optimize better pen writing I want to implement a smooth SVG freehand drawn path in real time.
The following code snippet makes the curve smoother by calculating the average of the last mouse positions. The level of smoothing depends on the size of the buffer in which these values ​​are kept.
Please look at the example I have attached.
Here is the link to the code snippet https://stackoverflow.com/a/40700068
Please bid only experts.
My requests is:
Adapt this code https://stackoverflow.com/a/40700068 to WBO so that the writing quality is as in this code snippet.
Related categories: JavaScript Algorithm HTML5 Node.js SVG