Skip to content

Commit

Permalink
Added mediaCount to Archive
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinhammond committed Dec 9, 2023
1 parent 3d0956c commit 55fdc8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class Archive : public Napi::ObjectWrap<Archive> {
}
}

Napi::Value getMediaCount(const Napi::CallbackInfo &info) {
try {
return Napi::Value::From(info.Env(), archive_->getMediaCount());
} catch (const std::exception &err) {
throw Napi::Error::New(info.Env(), err.what());
}
}

Napi::Value getUuid(const Napi::CallbackInfo &info) {
try {
// TODO(kelvinhammond): convert this to
Expand Down Expand Up @@ -446,6 +454,7 @@ class Archive : public Napi::ObjectWrap<Archive> {
InstanceAccessor<&Archive::getAllEntryCount>("allEntryCount"),
InstanceAccessor<&Archive::getEntryCount>("entryCount"),
InstanceAccessor<&Archive::getArticleCount>("articleCount"),
InstanceAccessor<&Archive::getMediaCount>("mediaCount"),
InstanceAccessor<&Archive::getUuid>("uuid"),
InstanceMethod<&Archive::getMetadata>("getMetadata"),
InstanceMethod<&Archive::getMetadataItem>("getMetadataItem"),
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class Archive {
get allEntryCount(): number;
get entryCount(): number;
get articleCount(): number;
get mediaCount(): number;
get uuid(): string;
getMetadata(name: string): string;
getMetadataItem(name: string): Item;
Expand Down
1 change: 1 addition & 0 deletions test/zim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ describe("Archive", () => {
expect(archive.allEntryCount).toBeGreaterThanOrEqual(items.length);
expect(archive.entryCount).toBe(entries.length);
expect(archive.articleCount).toBe(items.length);
expect(archive.mediaCount).toBe(0);
expect(archive.uuid).toBeDefined();

// test metadata
Expand Down

0 comments on commit 55fdc8d

Please sign in to comment.