Works in both NodeJS and the browser.
const url = "https://cdn.rawgit.com/mbostock/shapefile/master/test/points.shp"
const points = new ShpToGeoJson({
remotePath: url
})
let stream = null
let featureIterator = null
const l = L.geoJSON(null).addTo(map)
points.load()
.then(() => {
stream = points.streamGeoJsonFeatures()
})
// Our function that runs on the button click
function loadNext () {
// If the generator is done we do nothing
if (featureIterator.done) return
// call stream.next() to get the next feature
featureIterator = stream.next()
const feature = featureIterator.value
l.addData(feature)
}