It's basis on khadan's algorithm which provides us calculate maximum sub-array sum of an array in linear time O(n).
npm i max-sub-arr-sum --save
....
const {maxSubArrSum} = require('max-sub-arr-sum');
let result = maxSubArrSum([-2, -3, 4, -1, -2, 1, 5, -3]);
....
If the given array is empty then it will return "undefined".
And every time array will be a numeric array. String or non-numeric elements are not allowed.