Skip to content

Commit dc7552a

Browse files
committed
refactor(eff): remove unused code
1 parent 0029030 commit dc7552a

File tree

1 file changed

+14
-41
lines changed

1 file changed

+14
-41
lines changed

packages/utilities/eff/src/index.ts

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,49 +1060,15 @@ export function zipWith<T, U, V>(
10601060
return result;
10611061
}
10621062

1063-
/**
1064-
* Creates a new array with `element` interspersed in between each element of `input`
1065-
* if there is more than 1 value in `input`. Otherwise, returns the existing array.
1066-
* @param input - The input array.
1067-
* @param element - The element to intersperse.
1068-
* @returns A new array with the element interspersed.
1069-
*/
1070-
export function intersperse<T>(input: T[], element: T): T[] {
1071-
if (input.length <= 1) {
1072-
return input;
1073-
}
1074-
const result: T[] = [];
1075-
for (let i = 0, n = input.length; i < n; i++) {
1076-
if (i !== 0) result.push(element);
1077-
result.push(input[i]!);
1078-
}
1079-
return result;
1080-
}
1081-
1082-
export function concatenate<T>(array1: T[], array2: T[]): T[];
1083-
export function concatenate<T>(array1: readonly T[], array2: readonly T[]): readonly T[];
1084-
export function concatenate<T>(array1: T[], array2: T[] | undefined): T[];
1085-
export function concatenate<T>(array1: T[] | undefined, array2: T[]): T[];
1086-
export function concatenate<T>(array1: readonly T[], array2: readonly T[] | undefined): readonly T[];
1087-
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[]): readonly T[];
1088-
export function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[] | undefined;
1089-
export function concatenate<T>(
1090-
array1: readonly T[] | undefined,
1091-
array2: readonly T[] | undefined,
1092-
): readonly T[] | undefined;
1093-
export function concatenate<T>(
1094-
array1: readonly T[] | undefined,
1095-
array2: readonly T[] | undefined,
1096-
): readonly T[] | undefined {
1097-
if (array2 === undefined || array2.length === 0) return array1;
1098-
if (array1 === undefined || array1.length === 0) return array2;
1099-
return [...array1, ...array2];
1100-
}
1101-
1102-
// #endregion
1103-
11041063
// #region Map & Set
11051064

1065+
/**
1066+
* Retrieves a value from a Map if the key exists, or computes and stores a new value if it doesn't.
1067+
* @param map - The Map to get from or update
1068+
* @param key - The key to look up in the Map
1069+
* @param callback - The function to call to generate a new value if the key doesn't exist
1070+
* @returns The existing value for the key, or the newly computed value
1071+
*/
11061072
export function getOrUpdate<K, V>(map: Map<K, V>, key: K, callback: () => V): V {
11071073
if (map.has(key)) {
11081074
return map.get(key)!;
@@ -1112,6 +1078,13 @@ export function getOrUpdate<K, V>(map: Map<K, V>, key: K, callback: () => V): V
11121078
return value;
11131079
}
11141080

1081+
/**
1082+
* Attempts to add a value to a Set, but only if it doesn't already exist.
1083+
*
1084+
* @param set - The Set to potentially add to
1085+
* @param value - The value to add if it doesn't already exist in the Set
1086+
* @returns true if the value was added, false if it already existed
1087+
*/
11151088
export function tryAddToSet<T>(set: Set<T>, value: T): boolean {
11161089
if (!set.has(value)) {
11171090
set.add(value);

0 commit comments

Comments
 (0)