All Projects → jiaola → marc4js

jiaola / marc4js

Licence: Apache-2.0 license
A Node.js API for handling MARC

Programming Languages

javascript
184084 projects - #8 most used programming language
mIRC Script
13 projects

Projects that are alternatives of or similar to marc4js

php-marc
Simple interface for working with MARC records using the File_MARC package
Stars: ✭ 38 (+8.57%)
Mutual labels:  marc-records, marcxml
MARCspec
📄 MARCspec - A common MARC record path language
Stars: ✭ 21 (-40%)
Mutual labels:  marc, marc-records
CSharp MARC
C# class libraries and full featured editor for MARC Records
Stars: ✭ 51 (+45.71%)
Mutual labels:  marc, marc-records
parse-csv
CSV parser for node.js
Stars: ✭ 15 (-57.14%)
Mutual labels:  parse
php-simple-request
php-simple-request is a request parser library designed to simplify requests validation and filtering using annotations, generating at the same time an object representation from the request data.
Stars: ✭ 15 (-57.14%)
Mutual labels:  parse
android-tao-rest-data-processor
Android REST Data Processor library. Easy to build a REST request, to receive and processing data (XML, JSON, CSV and etc.) from REST requests, file system, assets.
Stars: ✭ 24 (-31.43%)
Mutual labels:  parse
mtgsqlive
MTGJSON build scripts to generate alternative data formats
Stars: ✭ 40 (+14.29%)
Mutual labels:  parse
asmdot
[Unstable] Fast, zero-copy and lightweight (Arm | Mips | x86) assembler in (C | C++ | C# | Go | Haskell | Javascript | Nim | OCaml | Python | Rust).
Stars: ✭ 23 (-34.29%)
Mutual labels:  parse
krokus
A library to format numbers and a collection for localization patterns.
Stars: ✭ 16 (-54.29%)
Mutual labels:  parse
limelight
A php Japanese language text analyzer and parser.
Stars: ✭ 76 (+117.14%)
Mutual labels:  parse
elm-html-parser
Parse HTML in Elm!
Stars: ✭ 44 (+25.71%)
Mutual labels:  parse
svg-quick-editor
SVG Quick Editor is a free and open-source SVG editing tool. It offers features such as editing SVG colors, viewing or deleting their paths.
Stars: ✭ 88 (+151.43%)
Mutual labels:  parse
xml-to-json
Simple API that converts dynamic XML feeds to JSON through a URL or pasting the raw XML data. Made 100% in PHP.
Stars: ✭ 38 (+8.57%)
Mutual labels:  parse
xml-spac
Handle streaming XML data with declarative, composable parsers
Stars: ✭ 39 (+11.43%)
Mutual labels:  parse
fluent-plugin-http-pull
The input plugin of fluentd to pull log from rest api.
Stars: ✭ 19 (-45.71%)
Mutual labels:  parse
easyvk
This app helps you create an apps with vk api easy!
Stars: ✭ 97 (+177.14%)
Mutual labels:  streaming-api
Astview
Astview is a graphical viewer for abstract syntax trees
Stars: ✭ 20 (-42.86%)
Mutual labels:  parse
ParseCareKit
Securely synchronize any CareKit 2.1+ based app to a Parse Server Cloud. Compatible with parse-hipaa.
Stars: ✭ 28 (-20%)
Mutual labels:  parse
parse
Parse with an Eloquent-like interface for Laravel
Stars: ✭ 15 (-57.14%)
Mutual labels:  parse
abstract-syntax-tree
A library for working with abstract syntax trees.
Stars: ✭ 77 (+120%)
Mutual labels:  parse

Build Status

A Node.js module for handling MARC records

Installation

npm install marc4js

Features

marc4js provides the following features

  • An easy to use API that can handle large record sets.
  • Uses Node.js stream API and pipe functions for parsing and writing ISO2709 format, MarcEdit text (mrk) format, MARC in JSON, and MARCXML.
  • Offers callback functions for parsing and writing various formats.
  • SAX based MARCXML parsing that doesn't in-memory storage of records while parsing. Able to parse large MARCXML file with ease.
  • A MARC record object model for in-memory editing of MARC records, similar to the Marc4J object model
  • Supports UTF-8 encoded marc files and MARC-8 encoded marc files (It requires marc8 to handle MARC-8 encoded files).

Examples

Examples can be found in the the marc4js_examples. You can also find examples in the test directory.

Usage

var marc4js = require('marc4js');

Parsers

Parsers take various MARC formats and convert them to marc4js.marc.Record objects. Marc4js supports ISO2709, text (MarcEdit .mrc file) and MARCXML formats.

There are three ways to use a parser.

Callback API

marc4js.parse(data, options, function(err, records) {
});

Stream API

var parser = marc4js.parse(options);
parser.on('data', function(record) {
});
parser.on('end', function() {
});
parser.on('error', function(err) {
});
parser.write(data);
parser.end();

All events are based on the Node.js stream API.

Note that the parsers always work in the paused (aka non-flowing) streaming mode - therefore the objectMode option of the stream api is disabled, and is always set to true. Listening to the readable event will throw an erorr.

Pipe function

var parser = marc4js.parse(options);
fs.createReadStream('/path/to/your/file').pipe(parser).pipe(transformer).pipe(process.stdout);

options

format: default iso2709, possible values iso2709, marc, text, mrk, marcxml, xml

Different types of parsers

Iso2709Parser

Parses ISO2709 format. Used by default or when format is iso2709 or marc

MrkParser

Parses MarcEdit text format (.mrk files). Used when format is mrk

Other options:

  • spaceReplace: In MarcEdit mrk files, spaces in data field indicators or control fields are replace by \. By default MrkPaser will convert \ to space in those places. It can be configured with this option.
TextParser

Parses a text format that is slightly different from mrk format. Used when format is text.

MarcxmlParser

Parses MarcEdit text format (.mrk files). Used when format is marcxml or xml

The stream and pipe API is SAX based so it doesn't require in-memory storage of the records. This is suitable for processing large MARCXML file. The callback API will read all records in memory and return it in the callback function and is not advised to process large MARCXML file.

Other options:

  • strict: default is false. When in strict mode, the parser will fail if the XML is not well-formatted. For details, see the strict option in sax-js.
MijParser

Parses MARC-in-JSON format. Used when format is json or mij.

The stream and pipe API uses a sax-like JSON stream parser so it doesn't require in-memory storage of the records. Thus it can process large number of MARC-in-JSON records.

Transformers

Transformers transform the marc4js.marc.Record objects into various MARC formats. Marc4js supports ISO2709, text (MarcEdit .mrc file) and MARCXML formats.

Like parsers, transformers can also be used in three different ways.

Callback API

marc4js.transform(records, options, function(err, output) {
});

Stream API

var transformer = marc4js.transform(options);
transformer.on('readable', function(output) {
});
transformer.on('end', function() {
});
transformer.on('error', function(err) {
});
transformer.write(record); // one record
// or to write an array of records
// records.forEach(function(record) {
//     transformer.write(record);
// });
transformer.end();

Note that even though parsers can be only in the flowing mode, the transformers can use either flowing or paused (aka non-flowing) mode in the stream API. In the above example it's using the paused mode, but it can also use the data event handler if flowing mode is used.

Pipe function

var transformer = marc4js.transform(options);
fs.createReadStream('/path/to/your/file').pipe(parser).pipe(transformer).pipe(process.stdout);

options

format: default iso2709, possible values iso2709, marc, text, mrk, marcxml, xml objectMode: default false. Used to switch between the flowing and paused (aka non-flowing) mode in the stream API.

Different types of Transformers

Iso2709Transformer

Outputs ISO2709 format. Used by default or when format is iso2709 or marc

MrkTransformer

Outputs MarcEdit text format (.mrk files). Used when format is mrk

Other options:

  • spaceReplace: by default space in data field indicators and control fields are replaced with \. But it can be configured with this option.
TextTransformer

Outputs text format, which is slightly different from mrk format. Used when format is text.

MarcxmlTransformer

Outputs MarcEdit text format (.mrk files). Used when format is marcxml or xml

Other options:

  • pretty: default is true. Output XML in pretty format. If set to false, new indentation and line-breakers in outputs.
  • indent: default is ' ' (two spaces). Used to indent lines in pretty format.
  • newline: default is \n. Used in pretty format.
  • declaration: default is true. If set to false, the XML declaration line (<?xml versiont ...>) is not included in the output.
  • root: default is true. If false, the root <collection> element is not included in the output.
MijTransformer

Outputs MARC-in-JSON string. Used when format is json or mij.

Other options:

  • asArray: default is true. By default the output will be in an JSON array format, even if there is only one record. If this option set to false, the output will not write the enclosing brackets [ and ] at the beginning and end of the output.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].