new MarcField(field, field_data)
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
field |
string | three character field label. |
||||||||||||
field_data |
object | MARC-JSON field data as Object OR Pass as string for data fields. Properties
|
Properties:
| Name | Type | Description |
|---|---|---|
tag |
string | 3-char MARC field label. |
subfield_data |
Array.<object> | Subfields, as array of { code: {string}, value: {string} } objects. |
ind1 |
string | 1-char indicator 1. |
ind2 |
string | 1-char indicator 2. |
data |
string | If |
Methods
-
add_subfield(index, subfield_data) → {object}
-
Insert single subfield into MarcField at index position.
Parameters:
Name Type Description indexnumber Index of subfield to insert before. Use -1 to append.
subfield_dataobject {code: {string}, value: {string}}object.- Also accepts just the code as a string to add an empty subfield.
Returns:
Reference to subfield data (mutable).
- Type
- object
-
clone() → {MarcField}
-
Clone a field.
Returns:
The cloned field.
- Type
- MarcField
-
delete_subfield(index) → {object}
-
Deletes subfield at given index.
Parameters:
Name Type Description indexnumber index of subfield.
Returns:
1-element array of removed subfield data.
- Type
- object
-
html(options)
-
Output the field as a marc-html string.
Parameters:
Name Type Description optionsProperties
Name Type Description filterEachfunction specify a filter function to pass each subfield through
filterLastfunction apply filter function to last subfield.
delimiterstring character(s) to insert between subfields.
filterstring only include these subfields ('abc' includes all $a, $b, & $c).
reorderboolean reorder by order in filter param.
-
indicator(i) → {string}
-
Value of indicator i.
Parameters:
Name Type Description inumber 1 or 2.
Returns:
1-char indicator value.
- Type
- string
-
replace(subfield_data, position) → {MarcField}
-
Replace all subfield and indicator data in field, or substring in control field at index position.
Parameters:
Name Type Description subfield_dataobject {code: {string}, value: {string}}object.- Or accepts string to replace portion of control field.
positionstring substring, format: '[11]' or '[11-14]'
Returns:
Reference to the field.
- Type
- MarcField
-
replace_subfield(index, subfield_data) → {object}
-
Replace a single subfield in field.
Parameters:
Name Type Description indexnumber index of subfield.
subfield_dataobject {code: {string}, value: {string}}object.Returns:
Reference to the subfield.
- Type
- object
-
subfield(subfield_code) → {string}
-
Ouput single subfield value as a string.
Parameters:
Name Type Description subfield_codestring 1-char subfield code.
Returns:
value of first matching subfield, or null.
- Type
- string
-
subfield_at(index) → {object}
-
Ouput single subfield as
{code: {string}, value: {string}}object.Parameters:
Name Type Description indexnumber index of subfield.
Returns:
Reference to subfield data (mutable), or null.
- Type
- object
-
subfields(filterspec, options) → {Array.<object>}
-
List subfields as code / value objects.
Parameters:
Name Type Description filterspecstring a list of subfields to include in output. e.g. 'abhjm'.
optionsobject options object
Properties
Name Type Description reorderboolean Order output by
filterspec. Iffalse, subfields that match are returned in the order they appear in the record.Returns:
Subfield data as {code: {string}, value: {string}} .
- If NO filterspec is provided, returns references to internal data (modifying will mutate the MarcRecord object).
- If filterspec is provided, this method returns copies of the subfield data.
- Type
- Array.<object>