UNPKG

2.32 kBSource Map (JSON)View Raw
1{"version":3,"file":"Pedometer.js","sourceRoot":"","sources":["../src/Pedometer.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,qBAAqB,GAAG,IAAI,kBAAkB,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;AAMtF,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB,MAAM,UAAU,cAAc,CAAC,QAAiC;IAC9D,IAAI,cAAc,KAAK,CAAC,EAAE;QACxB,aAAa,CAAC,iBAAiB,CAAC,cAAc,EAAE,CAAC;KAClD;IACD,cAAc,EAAE,CAAC;IAEjB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,WAAW,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC;IAEzF,OAAO;QACL,MAAM;YACJ,QAAQ,CAAC,MAAM,EAAE,CAAC;YAClB,cAAc,EAAE,CAAC;YACjB,IAAI,cAAc,KAAK,CAAC,EAAE;gBACxB,aAAa,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC;aACzD;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAAW,EAAE,GAAS;IAC5D,SAAS,CAAC,KAAK,IAAI,GAAG,EAAE,sDAAsD,CAAC,CAAC;IAChF,OAAO,MAAM,aAAa,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AACjG,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,MAAM,aAAa,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;AAClE,CAAC","sourcesContent":["import invariant from 'invariant';\nimport { NativeEventEmitter, NativeModules } from 'react-native';\n\nconst PedometerEventEmitter = new NativeEventEmitter(NativeModules.ExponentPedometer);\n\ntype PedometerResult = { steps: number };\ntype PedometerUpdateCallback = (result: PedometerResult) => void;\ntype PedometerListener = { remove: () => void };\n\nlet _listenerCount = 0;\n\nexport function watchStepCount(callback: PedometerUpdateCallback): PedometerListener {\n if (_listenerCount === 0) {\n NativeModules.ExponentPedometer.watchStepCount();\n }\n _listenerCount++;\n\n const listener = PedometerEventEmitter.addListener('Exponent.pedometerUpdate', callback);\n\n return {\n remove() {\n listener.remove();\n _listenerCount--;\n if (_listenerCount === 0) {\n NativeModules.ExponentPedometer.stopWatchingStepCount();\n }\n },\n };\n}\n\nexport async function getStepCountAsync(start: Date, end: Date): Promise<PedometerResult> {\n invariant(start <= end, 'Pedometer: The start date must precede the end date.');\n return await NativeModules.ExponentPedometer.getStepCountAsync(start.getTime(), end.getTime());\n}\n\nexport async function isAvailableAsync(): Promise<boolean> {\n return await NativeModules.ExponentPedometer.isAvailableAsync();\n}\n"]}
\No newline at end of file