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 index
number Index of subfield to insert before. Use -1 to append.
subfield_data
object {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 index
number 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 options
Properties
Name Type Description filterEach
function specify a filter function to pass each subfield through
filterLast
function apply filter function to last subfield.
delimiter
string character(s) to insert between subfields.
filter
string only include these subfields ('abc' includes all $a, $b, & $c).
reorder
boolean reorder by order in filter param.
-
indicator(i) → {string}
-
Value of indicator i.
Parameters:
Name Type Description i
number 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_data
object {code: {string}, value: {string}}
object.- Or accepts string to replace portion of control field.
position
string 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 index
number index of subfield.
subfield_data
object {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_code
string 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 index
number 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 filterspec
string a list of subfields to include in output. e.g. 'abhjm'.
options
object options object
Properties
Name Type Description reorder
boolean 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>