UNPKG

wiser-connector

Version:

Samples data from a Wiser Tracker REST API and reports tag location updates and zone transitions.

24 lines (23 loc) 758 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function uniqueFilterTagReport(tagReport) { const result = []; let unique = {}; tagReport.sort((a, b) => { return a.timestamp >= b.timestamp ? -1 : 1; }); tagReport.forEach(tag => { if (unique[tag.tag]) return; result.push(tag); unique[tag.tag] = true; }); return result; } exports.uniqueFilterTagReport = uniqueFilterTagReport; function getZoneTransitions(lastIdList, nextIdList) { const enter = nextIdList.filter(id => lastIdList.indexOf(id) === -1); const exit = lastIdList.filter(id => nextIdList.indexOf(id) === -1); return { enter, exit }; } exports.getZoneTransitions = getZoneTransitions;