This NODE module enables you to read existing MARC records from a file, string, or from a Z39.50 source. You can also use this package to create new MARC records.
The standard for machine-readable cataloging (MARC) records is documented at
util-marc exports three functions which are Record, Reader and Writer.
var Marc = require('util-marc'); var record = new Marc.Record();
Now, you can play with the record instance. Adding Field(s). Adding a field to record instance is easy, you can add both Control and Data Feilds by using the same interface, addField(); If you pass 2 arguments to the addField() interface, field will be added as Control Field. Otherwise, if you pass 1 argument, field will be added as Data Field.
Let's add some Control Fields.
record.addField(1, "001 value"); record.addField(3, "003 value");
Adding Data Field returns the field instance, then you can chain easily, like:
record.addField(245) .ind1("1") .ind2("0") .subfield("a", "subfield a value") .subfield("a", "subfield a2 value") .subfield("b", "subfield b value") .subfield("c", "subfield c value");
Here, you can ignore indicator1 (ind1()) and indicator2 (ind2()) values, then their default values, ' ', are proccessed.
Now, you can create leader info dynamically, which is the coolest thing of util-marc. You can follow the standard here : [http://www.loc.gov/marc/bibliographic/bdleader.html] First, you need to set some record information by using the following interface:
record.info() .record_status('n') .type_of_record('a') .bibliographic_level('a') .type_of_control('#') .character_coding_scheme('#') .indicator_count(2) .subfield_code_count(2) .encoding_level('#') .descriptive_cataloging_form('#') .multipart_resource_record_level('#') .length_of_length_field(4) .length_of_starting_char_position(5) .length_of_implementation_defined_portion(0);
The default values of record.info() instance are
bibliographic_level: " ",
TODO - Documentation
TODO - Documentation
Pre: npm install mocha -h
You can now run this to perform the unit tests
cd <util-marc directory> mocha ./test/ -u tdd
- Tolga Aktüz - email@example.com
Copyright (c) 2012, Tolga Akyüz.
All rights reserved.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Tolga Akyüz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of the Tolga Akyüz.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.