Skip to content

Commit

Permalink
refactor(metadata): Remove unusable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mdy-m committed Aug 20, 2024
1 parent d2ca876 commit 77cdb1f
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions lib/metadata/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ namespace Reflect {
return get(metadataKey, target, propertyKey) !== undefined;
}

export function hasOwn(metadataKey: MetadataKey, target: MetadataTarget, propertyKey?: MetadataKey): boolean {
const targetMetadata = metadataStorage.get(target);
if (!targetMetadata) {
return false;
}

const key = propertyKey !== undefined ? `${propertyKey.toString()}:${String(metadataKey)}` : metadataKey;
return targetMetadata.has(key);
}

export function get(metadataKey: MetadataKey, target: MetadataTarget, propertyKey?: MetadataKey): MetadataValue {
const targetMetadata = metadataStorage.get(target);
if (!targetMetadata) {
Expand All @@ -47,41 +37,6 @@ namespace Reflect {
const key = propertyKey !== undefined ? `${propertyKey.toString()}:${String(metadataKey)}` : metadataKey;
return targetMetadata.get(key);
}

export function getKeys(target: MetadataTarget, propertyKey?: MetadataKey): MetadataKey[] {
const targetMetadata = metadataStorage.get(target);
if (!targetMetadata) {
return [];
}

const keys: MetadataKey[] = [];
targetMetadata.forEach((_, key) => {
if (propertyKey !== undefined) {
const prefix = `${propertyKey.toString()}:`;
if (key.toString().startsWith(prefix)) {
keys.push(key.toString().substring(prefix.length));
}
} else {
keys.push(key);
}
});

return keys;
}

export function getOwnKeys(target: MetadataTarget, propertyKey?: MetadataKey): MetadataKey[] {
return getKeys(target, propertyKey);
}

export function del(metadataKey: MetadataKey, target: MetadataTarget, propertyKey?: MetadataKey): boolean {
const targetMetadata = metadataStorage.get(target);
if (!targetMetadata) {
return false;
}

const key = propertyKey !== undefined ? `${propertyKey.toString()}:${String(metadataKey)}` : metadataKey;
return targetMetadata.delete(key);
}
}

export default Reflect;

0 comments on commit 77cdb1f

Please sign in to comment.