Wondering what’s next for npm?Check out our public roadmap! »

    split-tracker
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.8 • Public • Published

    Split-Tracker

    A simple JS library for calculating running track split times.

    Installing:

    Install with npm:

    $ npm install split-tracker --save
    

    with yarn:

    $ yarn add split-tracker
    

    or add it directly to your webpage using a CDN:

    <head>
    	<script src="https://cdn.jsdelivr.net/npm/split-tracker@1.0.8/dist/index.min.js"></script>
    </head>

    if you are working off an older version of the CDN, simply replace split-tracker@X.X.X with a more precise version #

    Implementing:

    const splitTracker = require('split-tracker');
    
    splitTracker.calculateSplitByMileTime(6, 200);
    import { calculateSplitByMileTime, calculateSplitByKilometerTime } from 'split-tracker';
    
    splitTracker.calculateSplitByMileTime(6, 200);
    
    splitTracker.calculateSplitByKilometerTime('3:30', 400);

    Using the CDN:

    	
    <html> 
    	<head>
    		<script src="https://cdn.jsdelivr.net/npm/split-tracker@1.0.8/dist/index.min.js"></script>
    	</head>
    </head>
    
    
    // inside of js file (or script tag)
    document.querySelector("body").onload = function() {
    	var split = splitTracker.calculateSplitByMileTime(6, 200);
    
    	console.log('split: ', split);
    }

    API:

    convertSecondsToMMSS

    		
    const seconds = 6.5; 
    
    convertSecondsToMMSS(seconds) // => '6:30'

    convertMMSSToSeconds

    		
    const time = '15:30';
    
    convertMMSSToSeconds(time); // => 930 (seconds)

    convertMinutesInDecimalsToMMSS

    		
    const minutes = 1.512;
    
    convertMinutesInDecimalsToMMSS(minutes); // => 1:31

    calculateSplitByMileTime

    		
    const mileTime = '6:00'; 
    // may be a formatted string (mm:ss) or a valid number (e.g. 6 or 6.0)
    
    const splitDistance = 200; 
    // must be a valid number in meters
    
    calculateSplitByMileTime(mileTime, splitDistance); 
    // => { precise_split: 44.74, formatted_split: ':45' }
    // yields both the precise_split time in seconds and a rounded, formatted split in MM:SS

    calculateSplitByKilometerTime

    		
    const kilometerTime = '3:30'; 
    // may be a formatted string (mm:ss) or a valid number (e.g. 3.5)
    
    const splitDistance = 5000; 
    // must be a valid number in meters
    
    calculateSplitByKilometerTime(kilometerTime, splitDistance); 
    // => { precise_split: 1050, formatted_split: '17:30' }
    // yields both the precise_split time in seconds and a rounded, formatted split in MM:SS

    Install

    npm i split-tracker

    DownloadsWeekly Downloads

    11

    Version

    1.0.8

    License

    ISC

    Unpacked Size

    7.28 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar