Get Ragnar race data.
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.editorconfig
.gitignore
.travis.yml
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

ragnar-data

Get, format, filter, and sort the data for each Ragnar race.

NPM Build Status js-standard-style Greenkeeper badge

Requires Node >=6

Install

npm install ragnar-data --save
# or for the CLI
npm install ragnar-data --global

Usage

JS

const ragnarData = require('ragnar-data')

ragnarData({
  // Filter the list of races (uses _.filter)
  filter: { type: 'trail' },
  // Pick which keys that will be in each result
  pick: ['name', 'elevation_gain', 'distance'],
  // Omit can also be used to blacklist certain keys
  omit: ['legs']
  // Sort the results (uses _.orderBy)
  sort: ['elevation_gain', 'desc'],
  // Will cache data to this directory and use it for subsequent runs
  // Defaults to prefixed path using env-paths.config
  cache: path.resolve(__dirname, '.your-ragnar-data')
  // Request the data from the API even if cache is available
  refresh: true
})
// Returns a promist
.then((races) => console.log(races))
.catch((err) => console.error(err))

CLI

ragnar-data \
   # A shortcut for filtering based on type
  --type trail \
  # You can always use a properly encoded json object to filter
  --filter '{"type": "trail"}' \
  # Same as above
  --pick name,elevation_gain,distance \
  --omit legs \
  --sort distance,desc \
  --cache .ragnar-data \
  --refresh \
  # How to output the CLI result [table, json, markdown]
  --output table

# See all the options
ragnar-data --help

LICENSE

MIT