const util = require('util'); const Transform = require('stream').Transform; const intercomDrinks = require('intercom-drinks').default; function Stream(latitude, longitude, radius) { if (!(this instanceof Stream)) { return new Stream(); } Transform.call(this, { readableObjectMode: true, writableObjectMode: true }); this._latitude = latitude; this._longitude = longitude; this._radius = radius; } util.inherits(Stream, Transform); Stream.prototype._transform = function (customer, encoding, done) { // 5. calculate distance and filter if (intercomDrinks.isNearbyCustomer(this._latitude, this._longitude, this._radius, customer)) { this.push(customer); } done(); }; module.exports = Stream;