콘텐츠로 이동

normalizeRouteForWrite — @gj-kit/expo-workouts

@gj-kit/expo-workouts에서 공개하는 function입니다. package version 0.1.1의 release declaration을 그대로 표시합니다.

import { normalizeRouteForWrite } from '@gj-kit/expo-workouts';
/**
* Apply the write-side hygiene the library performs, so you can see what will happen before you call
* `saveWorkout`. Throws `invalidArgument` for out-of-range coordinates. The rules and their order
* are §8.2's and are pinned by `tests/fixtures/route-vectors.json`, which also drives the Swift and
* Kotlin tests.
*
* Order (do not reorder — the platforms disagree and this order is what makes them agree):
* 1. an EMPTY array is `invalidArgument` — say `route: 'none'` instead;
* 2. non-finite `t`/`lat`/`lon`, or `lat` outside ±90 / `lon` outside ±180, is `invalidArgument`
* (rejected, NOT dropped — silently discarding hides a data-corruption signal);
* 3. points with `hAccM < 0` or `hAccM > 50` are DROPPED (`hAccM === undefined` is kept);
* 4. points outside `[window.startMs, window.endMs)` are DROPPED — deliberately not clamped:
* clamping piles every out-of-window point onto one boundary instant and rule 5 then collapses
* them into a single point, i.e. it fabricates timestamps AND destroys more data;
* 5. sorted ascending by `t`, and for equal `t` the LAST point in input order wins — matching what
* HealthKit silently does, so that both platforms agree instead of one throwing.
*
* Zero survivors is not an error here: `saveWorkout` reports it as `route: 'dropped'`.
*/
declare function normalizeRouteForWrite(points: readonly RoutePoint[], window: Interval): readonly RoutePoint[];

이 선언은 매개변수, optionality, 제네릭, 반환값, 공개 union/type 계약의 정본입니다. 호출 전 필요한 환경·권한·오류 경계는 패키지 Golden path와 이 subpath의 import 조건을 함께 확인하세요.

  • 패키지: @gj-kit/expo-workouts
  • 버전: 0.1.1
  • 공개 entry: .
  • 소스: GitHub

Apply the write-side hygiene the library performs, so you can see what will happen before you call saveWorkout. Throws invalidArgument for out-of-range coordinates. The rules and their order are §8.2’s and are pinned by tests/fixtures/route-vectors.json, which also drives the Swift and Kotlin tests.

Order (do not reorder — the platforms disagree and this order is what makes them agree):

  1. an EMPTY array is invalidArgument — say route: 'none' instead;
  2. non-finite t/lat/lon, or lat outside ±90 / lon outside ±180, is invalidArgument (rejected, NOT dropped — silently discarding hides a data-corruption signal);
  3. points with hAccM < 0 or hAccM > 50 are DROPPED (hAccM === undefined is kept);
  4. points outside [window.startMs, window.endMs) are DROPPED — deliberately not clamped: clamping piles every out-of-window point onto one boundary instant and rule 5 then collapses them into a single point, i.e. it fabricates timestamps AND destroys more data;
  5. sorted ascending by t, and for equal t the LAST point in input order wins — matching what HealthKit silently does, so that both platforms agree instead of one throwing.

Zero survivors is not an error here: saveWorkout reports it as route: 'dropped'.