+ Added clear function to ASet
* fixed pathedEvent fullPath casing
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	"name": "@ztimson/utils",
 | 
						"name": "@ztimson/utils",
 | 
				
			||||||
	"version": "0.24.4",
 | 
						"version": "0.24.5",
 | 
				
			||||||
	"description": "Utility library",
 | 
						"description": "Utility library",
 | 
				
			||||||
	"author": "Zak Timson",
 | 
						"author": "Zak Timson",
 | 
				
			||||||
	"license": "MIT",
 | 
						"license": "MIT",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,6 +29,14 @@ export class ASet<T> extends Array {
 | 
				
			|||||||
		return this;
 | 
							return this;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Remove all elements
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						clear() {
 | 
				
			||||||
 | 
							this.splice(0, this.length);
 | 
				
			||||||
 | 
							return this;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Delete elements from set
 | 
						 * Delete elements from set
 | 
				
			||||||
	 * @param items Elements that will be deleted
 | 
						 * @param items Elements that will be deleted
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,9 +90,9 @@ export class PathEvent {
 | 
				
			|||||||
	get delete(): boolean { return !this.methods.has('n') && (this.methods.has('*') || this.methods.has('d')) }
 | 
						get delete(): boolean { return !this.methods.has('n') && (this.methods.has('*') || this.methods.has('d')) }
 | 
				
			||||||
	set delete(v: boolean) { v ? this.methods.delete('n').delete('*').add('d') : this.methods.delete('d'); }
 | 
						set delete(v: boolean) { v ? this.methods.delete('n').delete('*').add('d') : this.methods.delete('d'); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	constructor(Event: string | PathEvent) {
 | 
						constructor(e: string | PathEvent) {
 | 
				
			||||||
		if(typeof Event == 'object') return Object.assign(this, Event);
 | 
							if(typeof e == 'object') return Object.assign(this, e);
 | 
				
			||||||
		let [p, scope, method] = Event.replaceAll(/\/{2,}/g, '/').split(':');
 | 
							let [p, scope, method] = e.replaceAll(/\/{2,}/g, '/').split(':');
 | 
				
			||||||
		if(!method) method = scope || '*';
 | 
							if(!method) method = scope || '*';
 | 
				
			||||||
		if(p == '*' || !p && method == '*') {
 | 
							if(p == '*' || !p && method == '*') {
 | 
				
			||||||
			p = '';
 | 
								p = '';
 | 
				
			||||||
@@ -100,8 +100,8 @@ export class PathEvent {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		let temp = p.split('/').filter(p => !!p);
 | 
							let temp = p.split('/').filter(p => !!p);
 | 
				
			||||||
		this.module = temp.splice(0, 1)[0]?.toLowerCase() || '';
 | 
							this.module = temp.splice(0, 1)[0]?.toLowerCase() || '';
 | 
				
			||||||
		this.fullPath = p;
 | 
					 | 
				
			||||||
		this.path = temp.join('/');
 | 
							this.path = temp.join('/');
 | 
				
			||||||
 | 
							this.fullPath = `${this.module}${this.module && this.path ? '/' : ''}${this.path}`;
 | 
				
			||||||
		this.name = temp.pop() || '';
 | 
							this.name = temp.pop() || '';
 | 
				
			||||||
		this.methods = new ASet(<any>method.split(''));
 | 
							this.methods = new ASet(<any>method.split(''));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -206,7 +206,7 @@ export class PathEvent {
 | 
				
			|||||||
	 * @return {string} String representation of Event
 | 
						 * @return {string} String representation of Event
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	static toString(path: string | string[], methods: Method | Method[]): string {
 | 
						static toString(path: string | string[], methods: Method | Method[]): string {
 | 
				
			||||||
		let p = makeArray(path).filter(p => p != null).join('/');
 | 
							let p = makeArray(path).filter(p => !!p).join('/');
 | 
				
			||||||
		p = p?.trim().replaceAll(/\/{2,}/g, '/').replaceAll(/(^\/|\/$)/g, '');
 | 
							p = p?.trim().replaceAll(/\/{2,}/g, '/').replaceAll(/(^\/|\/$)/g, '');
 | 
				
			||||||
		if(methods?.length) p += `:${makeArray(methods).map(m => m.toLowerCase()).join('')}`;
 | 
							if(methods?.length) p += `:${makeArray(methods).map(m => m.toLowerCase()).join('')}`;
 | 
				
			||||||
		return p;
 | 
							return p;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user