@intervals-icu/js-data-model
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

js-data-model

Data model for Javascript code for custom Intervals.icu fields, charts, streams etc. Generated from the Intervals.icu source code. Intervals.icu is an online service for sports analytics and planning with Javascript extension points and an open API.

This package just contains types and no code. Use it to write Intervals.icu scripts in your favourite IDE with code completion. You still need to cut and paste the JS code into the Intervals.icu web app to run it.

Getting Started

You need to have Nodejs installed:

  • Follow the instructions on the website to download and install it
  • OR install nvm (Node version manager) a tool that makes it easy to work with multiple versions of Node on one machine

Create a new directory for your Intervals.icu scripts project and install this package:

mkdir intervals-icu-scripts
cd intervals-icu-scripts
npm install @intervals-icu/js-data-model --save

Open that project in your IDE and create a Typescript file, Types.ts:

import {ActivityJsData, Interval} from "@intervals-icu/js-data-model"
export var icu: ActivityJsData
export var interval: Interval

Typescript is a strongly typed superset of Javascript. Intervals.icu does not support Typescript, but it is useful here to let the IDE know what "icu" and "interval" are.

Now create a Javascript file for your script (PedallingTime.js):

import {icu} from "./Types"

// paste everything below into Intervals.icu to run your script
{
  let activity = icu.activity
  let pedalling_time = activity.moving_time - activity.coasting_time
  pedalling_time
}

You should get code completion help from your IDE for all the types.

To upgrade an existing project to the latest version:

npm install @intervals-icu/js-data-model@latest --save

Intervals.icu JS extension points

These are some of the places where Intervals.icu is extensible with JS:

Readme

Keywords

none

Package Sidebar

Install

npm i @intervals-icu/js-data-model

Weekly Downloads

27

Version

1.0.4

License

MIT

Unpacked Size

44.6 kB

Total Files

5

Last publish

Collaborators

  • evanyholm
  • davidtinker