()
| 20 | } |
| 21 | |
| 22 | toString() { |
| 23 | // Needs to be sorted by key |
| 24 | const sortedKeys = Object.keys(this._items).sort((a, b) => |
| 25 | this._compareKeys(a, b), |
| 26 | ); |
| 27 | |
| 28 | const out = ['<<']; |
| 29 | if (this.limits && sortedKeys.length > 1) { |
| 30 | const first = sortedKeys[0], |
| 31 | last = sortedKeys[sortedKeys.length - 1]; |
| 32 | out.push( |
| 33 | ` /Limits ${PDFObject.convert([this._dataForKey(first), this._dataForKey(last)])}`, |
| 34 | ); |
| 35 | } |
| 36 | out.push(` /${this._keysName()} [`); |
| 37 | for (let key of sortedKeys) { |
| 38 | out.push( |
| 39 | ` ${PDFObject.convert(this._dataForKey(key))} ${PDFObject.convert( |
| 40 | this._items[key], |
| 41 | )}`, |
| 42 | ); |
| 43 | } |
| 44 | out.push(']'); |
| 45 | out.push('>>'); |
| 46 | return out.join('\n'); |
| 47 | } |
| 48 | |
| 49 | _compareKeys(/*a, b*/) { |
| 50 | throw new Error('Must be implemented by subclasses'); |
no test coverage detected