How to update three.js object with substitution of a new postions array?

First you need to create a typed BufferAttribute from coords array, declaring item size of 3. Then you can directly set position attribute with this object:

var posAttribute = new BufferAttribute(new Float32Array(coords), 3);
e.geometry.setAttribute('position', posAttribute);
e.geometry.attributes.position.needsUpdate = true;