src/parse/patterns.js
function buildCollection(collectionObj, options) {
  const items = buildPatterns(collectionObj, options);
  const pseudoFile = { path: collectionPath(items) };
  return readFiles(collectionGlob(items), options).then(collData => {
    const collectionMeta = collData.length ? collData[0].contents : {};
    collectionObj.collection = Object.assign(
      {
        name: titleCase(collectionKey(items)),
        resourceType: options.keys.collections.singular,
        id: resourceId(
          pseudoFile,
          options.src.patterns.basedir,
          options.keys.collections.plural
        )
      },
      collectionMeta
    );
    checkNamespaceCollision(
      ['items', 'patterns'],
      collectionObj.collection,
      `Collection ${collectionObj.collection.name}`,
      options
    );
    collectionObj.collection.items = items;
    collectionObj.collection.patterns = buildOrderedPatterns(
      collectionObj.collection
    );
    return collectionObj;
  });
}
function buildCollection(collectionObj, options) {
  const items = buildPatterns(collectionObj, options);
  const pseudoFile = { path: collectionPath(items) };
  return readFiles(collectionGlob(items), options).then(collData => {
    const collectionMeta = collData.length ? collData[0].contents : {};
    collectionObj.collection = Object.assign(
      {
        name: titleCase(collectionKey(items)),
        resourceType: options.keys.collections.singular,
        id: resourceId(
          pseudoFile,
          options.src.patterns.basedir,
          options.keys.collections.plural
        )
      },
      collectionMeta
    );
    checkNamespaceCollision(
      ['items', 'patterns'],
      collectionObj.collection,
      `Collection ${collectionObj.collection.name}`,
      options
    );
    collectionObj.collection.items = items;
    collectionObj.collection.patterns = buildOrderedPatterns(
      collectionObj.collection
    );
    return collectionObj;
  });
}
function buildCollection ( collectionObj , options ) { const items = buildPatterns ( collectionObj , options ) ; const pseudoFile = { path : collectionPath ( items ) } ; return readFiles ( collectionGlob ( items ) , options ) . then ( collData => { const collectionMeta = collData . length ? collData [ 0 ] . contents : { } ; collectionObj . collection = Object . assign ( { name : titleCase ( collectionKey ( items ) ) , resourceType : options . keys . collections . singular , id : resourceId ( pseudoFile , options . src . patterns . basedir , options . keys . collections . plural ) } , collectionMeta ) ; checkNamespaceCollision ( [ 'items' , 'patterns' ] , collectionObj . collection , ` ${ collectionObj . collection . name } ` , options ) ; collectionObj . collection . items = items ; collectionObj . collection . patterns = buildOrderedPatterns ( collectionObj . collection ) ; return collectionObj ; } ) ; }
Build an individual collection object. Give it some metadata based on
defaults and any metadata file found in its path. Build the Array of
patterns that should appear on this pattern collection's page.

@param {Object} collectionObj  The containing object that holds the patterns
that are part of this collection.
@param {Object} options
@return {Promise} resolving to {Object} representing the containing object
for this collection (as distinct from
collectionObj.collection, which is what this
function tacks on).
Build an individual collection object . Give it some metadata based on defaults and any metadata file found in its path . Build the Array of patterns that should appear on this pattern collection s page .