ind2?: string;
subfields?: MarcSubfield[];
+ // Fields are immutable when it comes to controlfield vs.
+ // data field. Stamp the value when stamping field IDs.
+ isCtrlField: boolean;
+
+ // Pass-through to marcrecord.js
isControlfield(): boolean;
deleteExactSubfields(...subfield: MarcSubfield[]): number;
this.fields.forEach(f => this.stampFieldId(f));
}
+ // Stamp field IDs the the initial isCtrlField state.
stampFieldId(field: MarcField) {
if (!field.fieldId) {
field.fieldId = Math.floor(Math.random() * 10000000);
}
+
+ if (field.isCtrlField === undefined) {
+ field.isCtrlField = field.isControlfield();
+ }
}
field(spec: string, wantArray?: boolean): MarcField | MarcField[] {
}
controlFields(): MarcField[] {
- return this.record.fields.filter(f => f.isControlfield());
+ return this.record.fields.filter(f => f.isCtrlField);
}
dataFields(): MarcField[] {
- return this.record.fields.filter(f => !f.isControlfield());
+ return this.record.fields.filter(f => !f.isCtrlField);
}
}