UNPKG

@tricoteuses/senat

Version:

Handle French Sénat's open data

30 lines (28 loc) 691 B
export function parseIntFields( fieldsNames: string[], entry: { [fieldName: string]: any } | null, ): { [fieldName: string]: any } | null { if (entry === null) { return null } for (const fieldName of fieldsNames) { if (entry[fieldName] !== null) { entry[fieldName] = parseInt(entry[fieldName]) } } return entry } export function trimFieldsRight( fieldsNames: string[], entry: { [fieldName: string]: any } | null, ): { [fieldName: string]: any } | null { if (entry === null) { return null } for (const fieldName of fieldsNames) { if (entry[fieldName] != null) { entry[fieldName] = entry[fieldName].trimEnd() } } return entry }