Skip to content

Commit

Permalink
feat: add entries() on APTBase
Browse files Browse the repository at this point in the history
  • Loading branch information
tale committed Feb 21, 2022
1 parent 3bce9a9 commit 01f74e7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class CaseCopyMap extends Map<string, string> {
if (actualKey) return super.get(actualKey)
}


public get size() : number {
return super.size / 2
}
Expand All @@ -38,10 +37,25 @@ export class APTBase {
* @param {string} key raw field name to search for
* @returns {string?} Field value
*/
get(key: string): string | undefined {
get(key: string): string | undefined {
return this.raw.get(key)
}

/**
* Iterate through all keys and values from the raw contents
* @returns IterableIterator of all keys and values
*/
entries(): IterableIterator<[string, string]> {
const builder: [string, string][] = []
for (const [key, value] of this.raw.entries()) {
if (!key.startsWith('case_copying')) {
builder.push([key, value])
}
}

return builder[Symbol.iterator]()
}

/**
* Retrieve the number of fields defined in the raw contents
* @returns {number} Field count
Expand Down

0 comments on commit 01f74e7

Please sign in to comment.