@fallencodes/seyfert-utils 1.2.7 → 1.2.8
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.
- package/build/utilities.d.ts +1 -0
- package/build/utilities.d.ts.map +1 -1
- package/build/utilities.js +16 -0
- package/package.json +1 -1
package/build/utilities.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export declare function replacer(_key: string, value: any): any;
|
|
|
13
13
|
export declare function numberToHex(color: number): string;
|
|
14
14
|
export declare function apiRoleColorsToArray(apiColors: APIRoleColors | ObjectToLower<APIRoleColors>): number[];
|
|
15
15
|
export declare function getValueFromPath<T extends Record<string, any>>(object: T, path: string): unknown | undefined;
|
|
16
|
+
export declare function truncateStringArray(array: string[], maxLength?: number, separator?: string): string[];
|
|
16
17
|
export {};
|
|
17
18
|
//# sourceMappingURL=utilities.d.ts.map
|
package/build/utilities.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,wBAAgB,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzC;AAGD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C;AAGD,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnD;AAGD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAI3D;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM,CAI9E;AAED,KAAK,QAAQ,G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,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM,CAI9E;AAED,KAAK,QAAQ,GACX,SAAS,GACT,WAAW,GACX,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,GACb,eAAe,CAAA;AAGjB,wBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,GAAG,sBAAsB,EAAE,IAAI,GAAE,QAAoB,GAAG,MAAM,CAW1G;AAGD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAG/C;AAGD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAIhD;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,UAExC;AAGD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAUtG;AAID,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE5G;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,GAAE,MAAa,EAAE,SAAS,GAAE,MAAa,YActG"}
|
package/build/utilities.js
CHANGED
|
@@ -89,3 +89,19 @@ export function getValueFromPath(object, path) {
|
|
|
89
89
|
return path.split('.').reduce((acc, key) => ((acc && (key in acc)) ? acc[key] : undefined), object);
|
|
90
90
|
}
|
|
91
91
|
;
|
|
92
|
+
/* Truncates an array of strings to a specific character length. */
|
|
93
|
+
export function truncateStringArray(array, maxLength = 1000, separator = ', ') {
|
|
94
|
+
const string = array.join(separator);
|
|
95
|
+
const stringLength = length(string);
|
|
96
|
+
if (stringLength <= maxLength)
|
|
97
|
+
return array;
|
|
98
|
+
const truncated = string.slice(0, maxLength);
|
|
99
|
+
const lastSep = truncated.lastIndexOf(separator);
|
|
100
|
+
if (lastSep === -1)
|
|
101
|
+
return [];
|
|
102
|
+
const newArray = truncated.slice(0, lastSep).split(separator);
|
|
103
|
+
const removedItems = array.length - newArray.length;
|
|
104
|
+
newArray.push(`${removedItems} more...`);
|
|
105
|
+
return newArray;
|
|
106
|
+
}
|
|
107
|
+
;
|
package/package.json
CHANGED