Skip to content

Commit

Permalink
refactor: Remove some TS tweaks after updating typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
MorevM committed Mar 24, 2024
1 parent c0630eb commit 5f97dd7
Show file tree
Hide file tree
Showing 4 changed files with 537 additions and 716 deletions.
1 change: 0 additions & 1 deletion src/arrays/array-range/array-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ export const arrayRange = (from: number, to?: number) => {
}

return arrayOfLength(Math.abs(to - from) + 1, (index) => index)
/* @ts-expect-error -- `to` cannot be `undefined` here since the top check */
.map(i => (from > to ? -i : i) + from);
};
6 changes: 3 additions & 3 deletions src/ranges/ranges-crop/ranges-crop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export const rangesCrop = <
isNullish(range[0]) ? -Infinity : range[0],
isNullish(range[1]) ? +Infinity : range[1],
])
.filter(range => range[1] >= start! && range[0] <= end!)
.filter(range => range[1] >= start && range[0] <= end)
.map(range => {
let [first, second] = range;
if (first < start!) first = start!;
if (second > end!) second = end!;
if (first < start) first = start!;
if (second > end) second = end!;

return [
formatInfinity(first, infinityToNull),
Expand Down
6 changes: 3 additions & 3 deletions src/ranges/ranges-invert/ranges-invert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ export const rangesInvert = <
rangesMerge(ranges, true, infinityToNull).reduce<Range[]>((acc, range, i, arr) => {
const res: Range[] = [];

if (i === 0 && arr[0][0]! > start!) {
if (i === 0 && arr[0][0]! > start) {
res.push([
formatInfinity(start, infinityToNull),
formatInfinity(arr[0][0], infinityToNull),
]);
}

const tail = i < arr.length - 1 ? arr[i + 1][0] : end;
if (!rangeIncludes(end!, [range])) {
if (!rangeIncludes(end, [range])) {
res.push([
formatInfinity((range[1] ?? -Infinity) > start! ? range[1] : start, infinityToNull),
formatInfinity((range[1] ?? -Infinity) > start ? range[1] : start, infinityToNull),
formatInfinity(tail, infinityToNull),
]);
}
Expand Down
Loading

0 comments on commit 5f97dd7

Please sign in to comment.