src/document/index.js
function add(name, methods) {

  // Create a container class that extends Document for our methods.
  class ConcreteDocument extends Document {
    constructor(document, root) {
      super(name, document, root);
    }
  }

  // Assign the methods to the new classes prototype.
  assignIn(ConcreteDocument.prototype, methods);

  // Add a factory method for the new type.
  Document.factory[name] = (document, root) => new ConcreteDocument(document, root);
}
function add(name, methods) {

  // Create a container class that extends Document for our methods.
  class ConcreteDocument extends Document {
    constructor(document, root) {
      super(name, document, root);
    }
  }

  // Assign the methods to the new classes prototype.
  assignIn(ConcreteDocument.prototype, methods);

  // Add a factory method for the new type.
  Document.factory[name] = (document, root) => new ConcreteDocument(document, root);
}
function add ( name , methods ) { // Create a container class that extends Document for our methods. class ConcreteDocument extends Document { constructor ( document , root ) { super ( name , document , root ) ; } } // Assign the methods to the new classes prototype. assignIn ( ConcreteDocument . prototype , methods ) ; // Add a factory method for the new type. Document . factory [ name ] = ( document , root ) => new ConcreteDocument ( document , root ) ; }
Creates and adds a a factory method for a new subtype of document.

@param {string} name    The name of the subtype.
@param {object} methods The methods the class will have.
Creates and adds a a factory method for a new subtype of document .