coer-elements 2.0.72 → 2.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,11 @@
1
- import { Strings, Tools } from 'coer-elements/tools';
1
+ import { Collections, Strings, Tools } from 'coer-elements/tools';
2
+
3
+ Array.prototype.Distinct = function () {
4
+ return Collections.Distinct(this);
5
+ };
6
+ Array.prototype.Except = function (exceptions) {
7
+ return Collections.Except(this, exceptions);
8
+ };
2
9
 
3
10
  //import { Tools } from "coer-elements/tools";
4
11
  //
@@ -1 +1 @@
1
- {"version":3,"file":"coer-elements-extensions.mjs","sources":["../../../projects/coer-elements/extensions/lib/object.extension.ts","../../../projects/coer-elements/extensions/lib/string.extension.ts","../../../projects/coer-elements/extensions/coer-elements-extensions.ts"],"sourcesContent":["//import { Tools } from \"coer-elements/tools\";\r\n//\r\n//declare global {\r\n// interface Object {\r\n// \r\n// /** Avoid Null value */\r\n// AvoidNull<T>(type: 'string' | 'number' | 'boolean' | null): T; \r\n//\r\n// /** Get properties of an object */\r\n// GetPropertyList(): string[];\r\n//\r\n// /** Break reference of a object or array */\r\n// BreakReference<T>(object: T): T;\r\n// }\r\n//}\r\n//\r\n//Object.prototype.AvoidNull = function<T>(type: 'string' | 'number' | 'boolean' | null = null): T {\r\n// return Tools.AvoidNull<T>(this as T, type);\r\n//}\r\n//\r\n//Object.prototype.GetPropertyList = function(): string[] {\r\n// return Tools.GetPropertyList(this);\r\n//}\r\n//\r\n//Object.prototype.BreakReference = function<T>(): T {\r\n// return Tools.BreakReference<T>(this as T);\r\n//}\r\n\r\nexport {};","import { Strings, Tools } from \"coer-elements/tools\";\r\n\r\ndeclare global {\r\n interface String {\r\n\r\n /** Sets the first character to lowercase */\r\n firstCharToLower(): string;\r\n\r\n /** Sets the first character to uppercase */\r\n firstCharToUpper(): string;\r\n\r\n /** Clean extra whitespaces */\r\n cleanUpBlanks(): string;\r\n\r\n /** Apply title formatting */\r\n toTitle(): string;\r\n\r\n /** Removes the last character */\r\n removeLastChar(): string;\r\n\r\n /** Removes accents */\r\n removeAccents(except?: string[]): string; \r\n \r\n /** Removes special characters */\r\n removeSpecialCharacters(): string; \r\n \r\n /** Only alphaNumeric */\r\n onlyAlphanumeric(): string; \r\n\r\n /** Only Numbers */\r\n onlyNumbers(): string;\r\n\r\n /** Validates if both strings are equal */\r\n equals(value: string | number | null | undefined, sensitive?: boolean): boolean;\r\n\r\n /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */\r\n isOnlyWhiteSpace(): boolean;\r\n\r\n /** Returns true if has string value and is not only whitespace, false otherwise */\r\n isNotOnlyWhiteSpace(): boolean; \r\n }\r\n}\r\n\r\n\r\nString.prototype.firstCharToLower = function(): string {\r\n return Strings.FirstCharToLower(this.toString());\r\n}; \r\n\r\n\r\nString.prototype.firstCharToUpper = function(): string {\r\n return Strings.FirstCharToUpper(this.toString());\r\n};\r\n\r\n\r\nString.prototype.cleanUpBlanks = function(): string {\r\n return Strings.CleanUpBlanks(this.toString());\r\n}; \r\n\r\n\r\nString.prototype.toTitle = function(): string {\r\n return Strings.ToTitle(this.toString());\r\n};\r\n\r\n\r\nString.prototype.removeLastChar = function(): string {\r\n return Strings.RemoveLastChar(this.toString());\r\n} \r\n\r\n\r\nString.prototype.removeAccents = function(except: string[] = []): string { \r\n return Strings.RemoveAccents(this.toString(), except);\r\n};\r\n\r\n\r\nString.prototype.removeSpecialCharacters = function(): string { \r\n return Strings.RemoveSpecialCharacters(this.toString());\r\n};\r\n\r\n\r\nString.prototype.onlyAlphanumeric = function(): string { \r\n return Strings.OnlyAlphanumeric(this.toString());\r\n};\r\n\r\n\r\nString.prototype.onlyNumbers = function(): string { \r\n return Strings.OnlyNumbers(this.toString());\r\n};\r\n\r\n\r\nString.prototype.equals = function(value: string | number | null | undefined, sensitive: boolean = false): boolean { \r\n return Strings.Equals(this.toString(), value, sensitive);\r\n} \r\n\r\n\r\nString.prototype.isOnlyWhiteSpace = function(): boolean {\r\n return Tools.IsOnlyWhiteSpace(this);\r\n}\r\n\r\n\r\nString.prototype.isNotOnlyWhiteSpace = function(): boolean {\r\n return Tools.IsNotOnlyWhiteSpace(this);\r\n}\r\n\r\nexport {};","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACkBA,MAAM,CAAC,SAAS,CAAC,gBAAgB,GAAG,YAAA;IAChC,OAAO,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AACpD,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,gBAAgB,GAAG,YAAA;IAChC,OAAO,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AACpD,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,aAAa,GAAG,YAAA;IAC7B,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AACjD,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,YAAA;IACvB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC3C,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,cAAc,GAAG,YAAA;IAC9B,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAClD,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,aAAa,GAAG,UAAS,SAAmB,EAAE,EAAA;IAC3D,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC;AACzD,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,uBAAuB,GAAG,YAAA;IACvC,OAAO,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC3D,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,gBAAgB,GAAG,YAAA;IAChC,OAAO,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AACpD,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,WAAW,GAAG,YAAA;IAC3B,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC/C,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,UAAS,KAAyC,EAAE,SAAA,GAAqB,KAAK,EAAA;AACpG,IAAA,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC;AAC5D,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,gBAAgB,GAAG,YAAA;AAChC,IAAA,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC;AACvC,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,mBAAmB,GAAG,YAAA;AACnC,IAAA,OAAO,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC;AAC1C,CAAC;;ACrGD;;AAEG"}
1
+ {"version":3,"file":"coer-elements-extensions.mjs","sources":["../../../projects/coer-elements/extensions/lib/array.extension.ts","../../../projects/coer-elements/extensions/lib/object.extension.ts","../../../projects/coer-elements/extensions/lib/string.extension.ts","../../../projects/coer-elements/extensions/coer-elements-extensions.ts"],"sourcesContent":["import { Collections } from \"coer-elements/tools\";\r\n\r\ndeclare global {\r\n interface Array<T> { \r\n\r\n /** */\r\n Distinct(): T[];\r\n\r\n /** */\r\n Except(exceptions: T[]): T[];\r\n }\r\n} \r\n\r\n\r\nArray.prototype.Distinct = function<T>(): T[] {\r\n return Collections.Distinct(this); \r\n}\r\n\r\n\r\nArray.prototype.Except = function<T>(exceptions: T[]): T[] {\r\n return Collections.Except(this, exceptions); \r\n}\r\n\r\n\r\nexport {};","//import { Tools } from \"coer-elements/tools\";\r\n//\r\n//declare global {\r\n// interface Object {\r\n// \r\n// /** Avoid Null value */\r\n// AvoidNull<T>(type: 'string' | 'number' | 'boolean' | null): T; \r\n//\r\n// /** Get properties of an object */\r\n// GetPropertyList(): string[];\r\n//\r\n// /** Break reference of a object or array */\r\n// BreakReference<T>(object: T): T;\r\n// }\r\n//}\r\n//\r\n//Object.prototype.AvoidNull = function<T>(type: 'string' | 'number' | 'boolean' | null = null): T {\r\n// return Tools.AvoidNull<T>(this as T, type);\r\n//}\r\n//\r\n//Object.prototype.GetPropertyList = function(): string[] {\r\n// return Tools.GetPropertyList(this);\r\n//}\r\n//\r\n//Object.prototype.BreakReference = function<T>(): T {\r\n// return Tools.BreakReference<T>(this as T);\r\n//}\r\n\r\nexport {};","import { Strings, Tools } from \"coer-elements/tools\";\r\n\r\ndeclare global {\r\n interface String {\r\n\r\n /** Sets the first character to lowercase */\r\n firstCharToLower(): string;\r\n\r\n /** Sets the first character to uppercase */\r\n firstCharToUpper(): string;\r\n\r\n /** Clean extra whitespaces */\r\n cleanUpBlanks(): string;\r\n\r\n /** Apply title formatting */\r\n toTitle(): string;\r\n\r\n /** Removes the last character */\r\n removeLastChar(): string;\r\n\r\n /** Removes accents */\r\n removeAccents(except?: string[]): string; \r\n \r\n /** Removes special characters */\r\n removeSpecialCharacters(): string; \r\n \r\n /** Only alphaNumeric */\r\n onlyAlphanumeric(): string; \r\n\r\n /** Only Numbers */\r\n onlyNumbers(): string;\r\n\r\n /** Validates if both strings are equal */\r\n equals(value: string | number | null | undefined, sensitive?: boolean): boolean;\r\n\r\n /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */\r\n isOnlyWhiteSpace(): boolean;\r\n\r\n /** Returns true if has string value and is not only whitespace, false otherwise */\r\n isNotOnlyWhiteSpace(): boolean; \r\n }\r\n}\r\n\r\n\r\nString.prototype.firstCharToLower = function(): string {\r\n return Strings.FirstCharToLower(this.toString());\r\n}; \r\n\r\n\r\nString.prototype.firstCharToUpper = function(): string {\r\n return Strings.FirstCharToUpper(this.toString());\r\n};\r\n\r\n\r\nString.prototype.cleanUpBlanks = function(): string {\r\n return Strings.CleanUpBlanks(this.toString());\r\n}; \r\n\r\n\r\nString.prototype.toTitle = function(): string {\r\n return Strings.ToTitle(this.toString());\r\n};\r\n\r\n\r\nString.prototype.removeLastChar = function(): string {\r\n return Strings.RemoveLastChar(this.toString());\r\n} \r\n\r\n\r\nString.prototype.removeAccents = function(except: string[] = []): string { \r\n return Strings.RemoveAccents(this.toString(), except);\r\n};\r\n\r\n\r\nString.prototype.removeSpecialCharacters = function(): string { \r\n return Strings.RemoveSpecialCharacters(this.toString());\r\n};\r\n\r\n\r\nString.prototype.onlyAlphanumeric = function(): string { \r\n return Strings.OnlyAlphanumeric(this.toString());\r\n};\r\n\r\n\r\nString.prototype.onlyNumbers = function(): string { \r\n return Strings.OnlyNumbers(this.toString());\r\n};\r\n\r\n\r\nString.prototype.equals = function(value: string | number | null | undefined, sensitive: boolean = false): boolean { \r\n return Strings.Equals(this.toString(), value, sensitive);\r\n} \r\n\r\n\r\nString.prototype.isOnlyWhiteSpace = function(): boolean {\r\n return Tools.IsOnlyWhiteSpace(this);\r\n}\r\n\r\n\r\nString.prototype.isNotOnlyWhiteSpace = function(): boolean {\r\n return Tools.IsNotOnlyWhiteSpace(this);\r\n}\r\n\r\nexport {};","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAcA,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,YAAA;AACvB,IAAA,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;AACrC,CAAC;AAGD,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,UAAY,UAAe,EAAA;IAChD,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC;AAC/C,CAAC;;ACrBD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAC/C,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,UAAS,KAAyC,EAAE,SAAA,GAAqB,KAAK,EAAA;AACpG,IAAA,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC;AAC5D,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,gBAAgB,GAAG,YAAA;AAChC,IAAA,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC;AACvC,CAAC;AAGD,MAAM,CAAC,SAAS,CAAC,mBAAmB,GAAG,YAAA;AACnC,IAAA,OAAO,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC;AAC1C,CAAC;;ACrGD;;AAEG"}
@@ -623,23 +623,19 @@ class Collections {
623
623
  }
624
624
  }
625
625
  /** */
626
- static Distinct(array, ...args) {
627
- for (const arg of args) {
628
- array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
629
- }
630
- return Array.from(new Set(array));
626
+ static Distinct(array) {
627
+ return Tools.IsNotNull(array)
628
+ ? Array.from(new Set(array))
629
+ : [];
631
630
  }
632
631
  /** */
633
- static Except(array, filter, ...properties) {
634
- const result = [];
635
- for (const item of array) {
636
- if (typeof item === 'object' && Tools.IsNotNull(properties) && properties.length > 0) {
637
- if (!filter.some(x => x[properties[0]] === item[properties[0]])) {
638
- result.push(item);
639
- }
640
- }
641
- }
642
- return [...result];
632
+ static Except(array, exceptions) {
633
+ if (Tools.IsNull(array))
634
+ return [];
635
+ if (Tools.IsNull(exceptions) || exceptions.length <= 0)
636
+ return [...array];
637
+ exceptions = Collections.Distinct(exceptions);
638
+ return [...array].filter(item => !exceptions.includes(item));
643
639
  }
644
640
  }
645
641