Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 1.48 KB

File metadata and controls

39 lines (28 loc) · 1.48 KB

Open Packaging Format

npm version Build Status dependencies Status Coverage Status Code Climate

An simple parser for opf metadata files. This is an incomplete implementation of the OPF specification.

Install

npm install open-packaging-format;

Simple Use:

import { readOPF } from 'open-packaging-format';

readOPF('some/dir/to/metadata.opf')
  .then((opf) => {
    console.log(opf.title);
    console.log(opf.description);
    for (const id of opf.identifiers) {
      console.log(id);
    }
  })
  .catch(console.error);

demonstrating writing data to an OPF and then that data to a file:

import OPF, { writeOPF } from 'open-packaging-format';

const opf = new OPF();
opf.title = 'This is a good title';
o.writeOPF('/path/to/your.xml', opf)
  .catch(console.error);