Skip to main content

FDS Encoder

Build, check, compare and match structural keys.

Package: @vitness/fds-encoder
Version: 0.1.0
License: MIT

Overview​

The FDS Encoder is a command line tool and a TypeScript library for the four structural keys: the exercise key (fxi), the equipment key (fxe), the muscle key (fxm) and the muscle category key (fxmg). The Core Concepts pages say how each key is built. The Encoder applies those rules for you.

KeyFieldExample
ExercisefxiFXI=1.0S/m:el.flex/o:standing/l:bell.dumb@hands, a standing dumbbell curl
EquipmentfxeFXE=1.0S/k:imp/f:bar.ez, an EZ bar
MusclefxmFXM=1.0/biceps-brachii.long, the long head of biceps brachii
Muscle categoryfxmgFXMG=1.0/hamstring, the hamstrings

What it does​

TaskCommandLibrary
Check a key and print its written formcheck <key>…checkKey, writeKey
Check every key in a catalog filecheck --records <file>checkRecord
Compare two keyscompare <a> <b>compareKeys
Place a muscle in a categorycompare <fxm> <fxmg>fxmInFxmg, fxmgCategoriesOf
Build keys by answering questionsask, build, questionsbuild, startAsk, stepAsk, QUESTIONS
Match records against a librarymatch <records> --library <records>match, matchEntryOf

How it fits with the rest of FDS​

  • Core Concepts. The Structural Keys pages are the rules. The Encoder follows them and reports, in plain words, where a key breaks one.
  • The Transformer. The FDS Transformer turns your source data into FDS records. It doesn't fill the key fields. Run the Encoder on its output to add or check them.
  • Your records. The Encoder reads and writes only a record's own key field and the key fields of the references it holds. Everything else in the record stays as it was, down to the spacing and the number literals. A link you confirm between two records belongs in your own data, in attributes or extensions. The Encoder doesn't read or write it.

Quick start​

Install the command from npm:

npm install -g @vitness/fds-encoder

Check a key:

fds-encoder check 'FXI=1.0S/o:standing/m:el.flex/l:bell.dumb@hands'
ok   FXI=1.0S/m:el.flex/o:standing/l:bell.dumb@hands

The key checks, and the Encoder prints it with its layers in the standard order.

Programmatic usage​

The same operations are a TypeScript library. Install the package in your project, then:

import { checkKey, compareKeys } from '@vitness/fds-encoder';

checkKey('FXI=1.0S/o:standing/m:el.flex/l:bell.dumb@hands').written;
// 'FXI=1.0S/m:el.flex/o:standing/l:bell.dumb@hands'

compareKeys('FXM=1.0/biceps-brachii.long', 'FXM=1.0/biceps-brachii').result; // 'more-specific'

The Library API lists every export.

What's next?​

Requirements​

  • Node.js: 20.0.0 or higher