Socket
Socket
Sign inDemoInstall

@tsed/core

Package Overview
Dependencies
Maintainers
5
Versions
1101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsed/core - npm Package Compare versions

Comparing version 4.12.4 to 4.13.0

32

lib/class/Registry.d.ts

@@ -5,2 +5,11 @@ /**

import { Type } from "../interfaces";
export interface RegistryHook<T> {
/**
*
* @param {RegistryKey} key
* @param {T} item
*/
onCreate?(key: RegistryKey, item: T): void;
}
export declare type RegistryKey = Type<any> | symbol;
/**

@@ -12,2 +21,3 @@ *

private _class;
private options;
/**

@@ -17,4 +27,4 @@ * Internal Map

*/
private _map;
constructor(_class: Type<T>);
protected _map: Map<RegistryKey, T>;
constructor(_class: Type<T>, options?: RegistryHook<T>);
/**

@@ -30,3 +40,3 @@ *

*/
get(key: Type<any> | symbol): T | undefined;
get(key: RegistryKey): T | undefined;
/**

@@ -36,3 +46,3 @@ *

*/
createIfNotExists(key: Type<any> | symbol): T;
createIfNotExists(key: RegistryKey): T;
/**

@@ -43,3 +53,3 @@ * The has() method returns a boolean indicating whether an element with the specified key exists or not.

*/
has(key: Type<any> | symbol): boolean;
has(key: RegistryKey): boolean;
/**

@@ -51,3 +61,3 @@ * The set() method adds or updates an element with a specified key and value to a Map object.

*/
set(key: Type<any> | symbol, metadata: T): this;
set(key: RegistryKey, metadata: T): this;
/**

@@ -57,3 +67,3 @@ * The entries() method returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.

*/
entries(): IterableIterator<[Type<any> | symbol, T]>;
entries(): IterableIterator<[RegistryKey, T]>;
/**

@@ -63,3 +73,3 @@ * The keys() method returns a new Iterator object that contains the keys for each element in the Map object in insertion order.

*/
keys(): IterableIterator<Type<any> | symbol>;
keys(): IterableIterator<RegistryKey>;
/**

@@ -70,3 +80,3 @@ *

*/
merge(target: Type<any> | symbol, options: Partial<O>): void;
merge(target: RegistryKey, options: Partial<O>): void;
/**

@@ -81,3 +91,3 @@ * The clear() method removes all elements from a Map object.

*/
delete(key: Type<any> | symbol): boolean;
delete(key: RegistryKey): boolean;
/**

@@ -102,3 +112,3 @@ * The forEach() method executes a provided function once per each key/value pair in the Map object, in insertion order.

*/
forEach(callbackfn: (value: T, key: Type<any>, map: Map<Type<any> | symbol, T>) => void, thisArg?: any): void;
forEach(callbackfn: (value: T, key: Type<any>, map: Map<RegistryKey, T>) => void, thisArg?: any): void;
/**

@@ -105,0 +115,0 @@ * The values() method returns a new Iterator object that contains the values for each element in the Map object in insertion order.

@@ -12,4 +12,5 @@ "use strict";

class Registry {
constructor(_class) {
constructor(_class, options = {}) {
this._class = _class;
this.options = options;
/**

@@ -43,3 +44,7 @@ * Internal Map

if (!this.has(key)) {
this.set(key, new this._class(key));
const item = new this._class(key);
this.set(key, item);
if (this.options && this.options.onCreate) {
this.options.onCreate(key, item);
}
}

@@ -104,3 +109,7 @@ return this.get(key);

delete(key) {
return this._map.delete(utils_1.getClassOrSymbol(key));
const sbl = utils_1.getClassOrSymbol(key);
// if (this.options && this.options.onDelete) {
// this.options.onDelete(sbl);
// }
return this._map.delete(sbl);
}

@@ -107,0 +116,0 @@ /**

/**
* @module common/core
*/ /** */
*/
/** */
/**

@@ -9,4 +10,7 @@ * An example of a `Type` is `MyCustomComponent` filters, which in JavaScript is be represented by

export declare const Type: FunctionConstructor;
/**
*
*/
export interface Type<T> extends Function {
new (...args: any[]): T;
}
"use strict";
/**
* @module common/core
*/ /** */
*/
/** */
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,0 +7,0 @@ /**

{
"name": "@tsed/core",
"version": "4.12.4",
"version": "4.13.0",
"description": "Core module for Ts.ED Framework",

@@ -56,3 +56,3 @@ "main": "./lib/index.js",

"license": "MIT",
"gitHead": "1fbdba863f795b2550045d7b23cd35332564abf9"
"gitHead": "a34af67534b79d5ad9e0944c7c8a36ba25bdce3c"
}

@@ -9,2 +9,19 @@ /**

export interface RegistryHook<T> {
/**
*
* @param {RegistryKey} key
* @param {T} item
*/
onCreate?(key: RegistryKey, item: T): void;
/**
*
* @param {RegistryKey} key
*/
// onDelete?(key: RegistryKey): void;
}
export type RegistryKey = Type<any> | symbol;
/**

@@ -19,5 +36,5 @@ *

*/
private _map: Map<Type<any> | symbol, T> = new Map<Type<any> | symbol, T>();
protected _map: Map<RegistryKey, T> = new Map();
constructor(private _class: Type<T>) {
constructor(private _class: Type<T>, private options: RegistryHook<T> = {}) {
this._class = getClass(this._class);

@@ -39,3 +56,3 @@ }

*/
get(key: Type<any> | symbol): T | undefined {
get(key: RegistryKey): T | undefined {
return this._map.get(getClassOrSymbol(key));

@@ -48,5 +65,9 @@ }

*/
createIfNotExists(key: Type<any> | symbol): T {
createIfNotExists(key: RegistryKey): T {
if (!this.has(key)) {
this.set(key, new this._class(key));
const item = new this._class(key);
this.set(key, item);
if (this.options && this.options.onCreate) {
this.options.onCreate(key, item);
}
}

@@ -61,3 +82,3 @@ return this.get(key)!;

*/
has(key: Type<any> | symbol): boolean {
has(key: RegistryKey): boolean {
return this._map.has(getClassOrSymbol(key));

@@ -72,3 +93,3 @@ }

*/
set(key: Type<any> | symbol, metadata: T): this {
set(key: RegistryKey, metadata: T): this {
this._map.set(getClassOrSymbol(key), metadata);

@@ -82,3 +103,3 @@ return this;

*/
entries(): IterableIterator<[Type<any> | symbol, T]> {
entries(): IterableIterator<[RegistryKey, T]> {
return this._map.entries();

@@ -91,3 +112,3 @@ }

*/
keys(): IterableIterator<Type<any> | symbol> {
keys(): IterableIterator<RegistryKey> {
return this._map.keys();

@@ -101,3 +122,3 @@ }

*/
merge(target: Type<any> | symbol, options: Partial<O>): void {
merge(target: RegistryKey, options: Partial<O>): void {

@@ -125,4 +146,10 @@ const meta: T & { [key: string]: any } = this.createIfNotExists(target);

*/
delete(key: Type<any> | symbol): boolean {
return this._map.delete(getClassOrSymbol(key));
delete(key: RegistryKey): boolean {
const sbl = getClassOrSymbol(key);
// if (this.options && this.options.onDelete) {
// this.options.onDelete(sbl);
// }
return this._map.delete(sbl);
}

@@ -149,3 +176,3 @@

*/
forEach(callbackfn: (value: T, key: Type<any>, map: Map<Type<any> | symbol, T>) => void, thisArg?: any): void {
forEach(callbackfn: (value: T, key: Type<any>, map: Map<RegistryKey, T>) => void, thisArg?: any): void {
this._map.forEach(callbackfn);

@@ -152,0 +179,0 @@ }

/**
* @module common/core
*/ /** */
*/
/** */

@@ -10,4 +11,8 @@ /**

export const Type = Function;
/**
*
*/
export interface Type<T> extends Function {
new (...args: any[]): T;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc