perf(jslib): add `attr` cache
ci/woodpecker/push/woodpecker Pipeline failed
Details
ci/woodpecker/push/woodpecker Pipeline failed
Details
parent
b99f9bc15c
commit
2027b543fd
|
@ -66,26 +66,31 @@ export class UpObject {
|
|||
);
|
||||
}
|
||||
|
||||
private _attr: { [key: string]: UpEntry[] } | undefined;
|
||||
|
||||
public get attr() {
|
||||
const result = {} as { [key: string]: UpEntry[] };
|
||||
this.attributes.forEach((entry) => {
|
||||
if (!result[entry.attribute]) {
|
||||
result[entry.attribute] = [];
|
||||
}
|
||||
if (!this._attr) {
|
||||
const result = {} as { [key: string]: UpEntry[] };
|
||||
this.attributes.forEach((entry) => {
|
||||
if (!result[entry.attribute]) {
|
||||
result[entry.attribute] = [];
|
||||
}
|
||||
|
||||
result[entry.attribute].push(entry);
|
||||
});
|
||||
result[entry.attribute].push(entry);
|
||||
});
|
||||
|
||||
this.backlinks.forEach((entry) => {
|
||||
const attribute = `~${entry.attribute}`;
|
||||
if (!result[attribute]) {
|
||||
result[attribute] = [];
|
||||
}
|
||||
this.backlinks.forEach((entry) => {
|
||||
const attribute = `~${entry.attribute}`;
|
||||
if (!result[attribute]) {
|
||||
result[attribute] = [];
|
||||
}
|
||||
|
||||
result[attribute].push(entry);
|
||||
});
|
||||
result[attribute].push(entry);
|
||||
});
|
||||
|
||||
return result;
|
||||
this._attr = result;
|
||||
}
|
||||
return this._attr;
|
||||
}
|
||||
|
||||
public get(attr: string) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@upnd/upend",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "Client library to interact with the UpEnd system.",
|
||||
"scripts": {
|
||||
"build": "tsc --build --verbose",
|
||||
|
|
Loading…
Reference in New Issue