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() {
|
public get attr() {
|
||||||
const result = {} as { [key: string]: UpEntry[] };
|
if (!this._attr) {
|
||||||
this.attributes.forEach((entry) => {
|
const result = {} as { [key: string]: UpEntry[] };
|
||||||
if (!result[entry.attribute]) {
|
this.attributes.forEach((entry) => {
|
||||||
result[entry.attribute] = [];
|
if (!result[entry.attribute]) {
|
||||||
}
|
result[entry.attribute] = [];
|
||||||
|
}
|
||||||
|
|
||||||
result[entry.attribute].push(entry);
|
result[entry.attribute].push(entry);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.backlinks.forEach((entry) => {
|
this.backlinks.forEach((entry) => {
|
||||||
const attribute = `~${entry.attribute}`;
|
const attribute = `~${entry.attribute}`;
|
||||||
if (!result[attribute]) {
|
if (!result[attribute]) {
|
||||||
result[attribute] = [];
|
result[attribute] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
result[attribute].push(entry);
|
result[attribute].push(entry);
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
this._attr = result;
|
||||||
|
}
|
||||||
|
return this._attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(attr: string) {
|
public get(attr: string) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@upnd/upend",
|
"name": "@upnd/upend",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"description": "Client library to interact with the UpEnd system.",
|
"description": "Client library to interact with the UpEnd system.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --build --verbose",
|
"build": "tsc --build --verbose",
|
||||||
|
|
Loading…
Reference in New Issue