/*
PDFNameTree - represents a name tree object
*/

import PDFObject from './object';

class PDFNameTree {

   constructor() {
    this._items = {};
  }

   add(key, val) {
    return this._items[key] = val;
  }

   get(key) {
    return this._items[key];
  }

   toString() {
    // Needs to be sorted by key
    const sortedKeys = (Object.keys(this._items)).sort((a, b) => a.localeCompare(b));

    const out = ['<<'];
    if (sortedKeys.length > 1) {
      const first = sortedKeys[0], last = sortedKeys[sortedKeys.length - 1];
      out.push(`  /Limits ${PDFObject.convert([new String(first), new String(last)])}`);
    }
    out.push('  /Names [');
    for (let key of sortedKeys) {
      out.push(`    ${PDFObject.convert(new String(key))} ${PDFObject.convert(this._items[key])}`);
    }
    out.push(']');
    out.push('>>');
    return out.join('\n');
  }
 }

export default PDFNameTree;
@@ -102,17 +102,16 @@
 ee %7B%0A%0A  
- 
 construc
@@ -114,24 +114,24 @@
 tructor() %7B%0A
+
     this._it
@@ -145,17 +145,16 @@
 %7D;%0A  %7D%0A%0A
- 
   add(ke
@@ -159,24 +159,24 @@
 key, val) %7B%0A
+
     return t
@@ -203,17 +203,16 @@
 l;%0A  %7D%0A%0A
- 
   get(ke
@@ -212,24 +212,24 @@
  get(key) %7B%0A
+
     return t
@@ -250,17 +250,16 @@
 %5D;%0A  %7D%0A%0A
- 
   toStri
@@ -852,17 +852,16 @@
 ');%0A  %7D%0A
- 
 %7D%0A%0Aexpor

fix format