Codes: @zaes/sidc
@zaes/sidc reads, validates and writes symbol identification codes, with no dependencies. @zaes/military-symbols uses it; a host that only needs codes installs it alone.
bash
npm install @zaes/sidcRead
ts
import {parseSidc} from '@zaes/sidc';
const r = parseSidc('130310000012110000000000000000');
if (r.ok) {
r.sidc.standard; // '2525E'
r.sidc.symbolSet; // '10'
r.sidc.entityCode; // '121100'
r.sidc.standardIdentity; // '3', friend
}
r.problems; // values the tables do not defineparseSidc takes a 20- or 30-digit numeric code (2525D, 2525E, APP-6 D/E) or a 15-character letter code (2525C and its kin): a code starting with a letter is a letter code. It reports, it does not refuse: a well-formed code with a value the tables do not define parses, and the value is in problems. Only a wrong length or stray characters fail. A letter code given without its trailing dashes (SFGPUCI) is read as if they were there, with a problem saying so.
Write
ts
import {formatNumericSidc} from '@zaes/sidc';
formatNumericSidc({version: '13', standardIdentity: '3', symbolSet: '10', entityCode: '121100'});
// '130310000012110000000000000000'The tables it reads with are exported too, each named for the standard table it transcribes (identities, statuses, echelons, mobility, sector modifier identifiers...), and gencCountry('840') gives a country's GENC trigraph, digraph and name.
The catalog
@zaes/sidc/catalog is every 2525E Change 1 entity and sector modifier: its name, its place in the hierarchy, its kind and its Appendix A geometry. It is a separate entry so reading a code does not pay for the tables.
ts
import {describeSidc, getEntity, listEntities} from '@zaes/sidc/catalog';
describeSidc('130310000012110000000000000000').entity?.path; // ['Movement and Maneuver', 'Infantry']
getEntity('10', '121100')?.kind; // 'icon'
listEntities({symbolSet: '25', kind: 'point'}).length; // the single-point control measureskind is icon, frame, point, multipoint or hierarchy.
2525C letter codes as 2525D codes
ts
import {convert2525C} from '@zaes/sidc/2525c';
convert2525C('SFGPUCI----E---').sidc; // '110310001512110000000000000000'Identity, status, headquarters and task force, echelon, mobility and country carry over by 2525C's Tables A-I and A-II; a function ID with no row converts as its nearest listed parent, with a problem.