mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: dev tools
This commit is contained in:
1 parent
74b821ac13
commit
edce64c1bd
24 files changed
+698
-93
No files matched your search
@@ -1,14 +1,17 @@
|
||||
import { CatalogItem } from '@protos/blitz_items';
|
||||
import { Any } from '@protos/google/protobuf/any';
|
||||
import { lowerFirst } from 'lodash-es';
|
||||
import { compareUint8Arrays } from '../../../scripts/src/core/github/compareUint8Arrays';
|
||||
import { MessageFns } from '../protos';
|
||||
|
||||
export class CatalogItemAccessor {
|
||||
public id: string;
|
||||
components: Record<string, Any> = {};
|
||||
count: number;
|
||||
|
||||
constructor(item: CatalogItem) {
|
||||
constructor(private item: CatalogItem) {
|
||||
this.id = item.catalog_id;
|
||||
this.count = item.components.length;
|
||||
|
||||
for (const component of item.components) {
|
||||
if (
|
||||
@@ -77,4 +80,20 @@ export class CatalogItemAccessor {
|
||||
encode() {
|
||||
return CatalogItem.encode(this.pack()).finish();
|
||||
}
|
||||
|
||||
equals(other: CatalogItemAccessor) {
|
||||
return (
|
||||
this.count === other.count &&
|
||||
this.item.components.every(
|
||||
(component) =>
|
||||
component.value === undefined ||
|
||||
(component.key in other.components &&
|
||||
(component.value.component === undefined ||
|
||||
compareUint8Arrays(
|
||||
other.components[component.key].value,
|
||||
component.value.component.value,
|
||||
))),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -118,4 +118,14 @@ export class MetadataAccessor {
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
toArray() {
|
||||
return Object.values(this.items);
|
||||
}
|
||||
|
||||
toSortedArray() {
|
||||
return this.toArray().sort((a, b) =>
|
||||
a.catalog_id.localeCompare(b.catalog_id),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user