Skip to content

Commit

Permalink
Apply lint fixes to nested JS files
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslawzalewski committed Apr 24, 2024
1 parent 5f1c6e9 commit b4428d6
Show file tree
Hide file tree
Showing 121 changed files with 254 additions and 2 deletions.
1 change: 1 addition & 0 deletions array/are.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import is from "./is.js";

export default (...xs) => xs.every(is);
3 changes: 3 additions & 0 deletions array/chunk.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import range from "./range.js";

export default count => xs => {
if (count > 0) {
const chunks = Math.ceil(xs.length / count);

return chunks > 0
? range(chunks).map(i => xs.slice(i * count, (i + 1) * count))
: xs;
}

return [];
};
1 change: 1 addition & 0 deletions array/difference.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default (xs, ys) => {
const zs = new Set(ys);

return xs.filter(x => !zs.has(x));
};
1 change: 1 addition & 0 deletions array/differs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import isNonNullable from "../is/nonNullable.js";

export default (xs, ys) =>
Boolean(!xs && ys) ||
Boolean(!ys && xs) ||
Expand Down
1 change: 1 addition & 0 deletions array/exact.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import range from "./range.js";

export default count => xs => range(count).map(index => xs[index]);
5 changes: 5 additions & 0 deletions array/filterInPlace.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
export default f => xs => {
let i = 0;
let j = 0;

while (i < xs.length) {
const value = xs[i];

if (f(value, i, xs)) {
xs[j++] = value;
}

i++;
}

xs.length = j;

return xs;
};
1 change: 1 addition & 0 deletions array/find.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default (predicate, fallback) => xs => {
const targetIndex = xs.findIndex(predicate);

return targetIndex !== -1 ? xs[targetIndex] : fallback;
};
2 changes: 2 additions & 0 deletions array/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import uniqueBy from "./uniqueBy.js";
import zip from "./zip.js";
import zipN from "./zipN.js";
import zipWith from "./zipWith.js";

export {
any,
are,
Expand Down Expand Up @@ -96,6 +97,7 @@ export {
zipN,
zipWith
};

export default {
any,
are,
Expand Down
1 change: 1 addition & 0 deletions array/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export default index =>
item =>
([...xs]) => {
xs.splice(index, 0, item);

return xs;
};
1 change: 1 addition & 0 deletions array/map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default (...fs) => {
const f = x => fs.reduce((x, f) => f(x), x);

return xs => xs.map(f);
};
1 change: 1 addition & 0 deletions array/minMax.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default xs => {
const [head, ...tail] = xs;

return tail.reduce(
([min, max], current) => [Math.min(min, current), Math.max(max, current)],
[head, head]
Expand Down
1 change: 1 addition & 0 deletions array/none.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import any from "./any.js";

export default xs => !any(xs);
2 changes: 2 additions & 0 deletions array/partition.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ export default predicate => xs =>
xs.reduce(
([left, right], current) => {
const pass = predicate(current);

const result = pass
? [left, [...right, current]]
: [[...left, current], right];

return result;
},
[[], []]
Expand Down
1 change: 1 addition & 0 deletions array/pop.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import take from "./take.js";

export default xs => take(xs.length - 1)(xs);
2 changes: 2 additions & 0 deletions array/removeAt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ export default index => xs => {
if (index >= xs.length || index < 0) {
return xs;
}

const ys = [...xs];
ys.splice(index, 1);

return ys;
};
1 change: 1 addition & 0 deletions array/reverseIf.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import reverse from "./reverse.js";

export default enabled => xs => (enabled ? reverse(xs) : xs);
1 change: 1 addition & 0 deletions array/second.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default xs => {
const [, x] = xs;

return x;
};
1 change: 1 addition & 0 deletions array/shuffle.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import shuffleInPlace from "./shuffleInPlace.js";

export default (xs, random) => shuffleInPlace([...xs], random);
1 change: 1 addition & 0 deletions array/shuffleInPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export default (xs, random = Math.random) => {
const j = Math.floor(random() * (i + 1));
[xs[i], xs[j]] = [xs[j], xs[i]];
}

return xs;
};
1 change: 1 addition & 0 deletions array/sum.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
const add = (a, b) => a + b;

export default xs => xs.reduce(add, 0);
1 change: 1 addition & 0 deletions array/zip.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import zipWith from "./zipWith.js";

export default zipWith((x, y) => [x, y]);
1 change: 1 addition & 0 deletions array/zipN.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default (...xs) => {
const [head = [], ...tail] = xs;

return head.map((value, index) =>
tail.reduce((x, xs) => [...x, xs[index]], [value])
);
Expand Down
3 changes: 3 additions & 0 deletions async/debounce.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
export default (f, wait) => {
let timeout = undefined;

return (...args) => {
const resolve = () => {
timeout = undefined;
f(...args);
};

if (timeout !== undefined) {
clearTimeout(timeout);
}

timeout = setTimeout(resolve, wait);
};
};
2 changes: 2 additions & 0 deletions async/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import debounce from "./debounce.js";
import delay from "./delay.js";
import sequence from "./sequence.js";

export { debounce, delay, sequence };

export default { debounce, delay, sequence };
2 changes: 2 additions & 0 deletions async/sequence.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export default async tasks => {
const results = [];

for (const task of tasks) {
const result = await task();
results.push(result);
}

return results;
};
1 change: 1 addition & 0 deletions date/clamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export default (min, max) => date => {
const clamped = new Date(
Math.min(max.valueOf(), Math.max(min.valueOf(), date.valueOf()))
);

return clamped;
};
1 change: 1 addition & 0 deletions date/dateInRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export default (from, to) => date => {
const timestamp = date.valueOf();
const fromTimestamp = from.valueOf();
const toTimestamp = to.valueOf();

return timestamp >= fromTimestamp && timestamp <= toTimestamp;
};
1 change: 1 addition & 0 deletions date/dayRange.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import endOfDay from "./endOfDay.js";
import startOfDay from "./startOfDay.js";

export default date => [startOfDay(date), endOfDay(date)];
1 change: 1 addition & 0 deletions date/daysInYear.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import leapYear from "./leapYear.js";

export default year => (leapYear(year) ? 366 : 365);
1 change: 1 addition & 0 deletions date/displayTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export default (source, showSeconds) => {
const padded = [hours, minutes, seconds].map(x => x.padStart(2, "0"));
const [paddedHours, paddedMinutes] = padded;
const parts = showSeconds ? padded : [paddedHours, paddedMinutes];

return parts.join(":");
};
2 changes: 2 additions & 0 deletions date/endOfDay.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import clone from "./clone.js";

export default date => {
const copy = clone(date);
copy.setHours(24, 0, 0, 0);

return copy;
};
1 change: 1 addition & 0 deletions date/formatDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export default date => {
date.getDate(),
date.getFullYear()
].map(_ => _ + "");

return [y.padStart(4, "0"), m.padStart(2, "0"), a.padStart(2, "0")].join("-");
};
2 changes: 2 additions & 0 deletions date/formatDateTime.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import formatDate from "./formatDate.js";
import formatTime from "./formatTime.js";

export default (sourceDate, showSeconds = false) => {
const date = formatDate(sourceDate);
const time = formatTime(sourceDate, showSeconds);

return `${date} ${time}`;
};
3 changes: 3 additions & 0 deletions date/formatDuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import toHours from "./toHours.js";
import toMinutes from "./toMinutes.js";
import toSeconds from "./toSeconds.js";
import displayTime from "./displayTime.js";

export default (duration, showSeconds = false) => {
const hours = Math.floor(toHours(duration));
const minutes = Math.floor(toMinutes(duration - fromHours(hours)));

const seconds = Math.floor(
toSeconds(duration - fromHours(hours) - fromMinutes(minutes))
);

return displayTime([hours, minutes, seconds], showSeconds);
};
2 changes: 2 additions & 0 deletions date/formatTime.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import displayTime from "./displayTime.js";

export default (date, showSeconds = false) => {
const [hours, minutes, seconds] = [
date.getHours(),
date.getMinutes(),
date.getSeconds()
];

return displayTime([hours, minutes, seconds], showSeconds);
};
1 change: 1 addition & 0 deletions date/fromDays.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import fromHours from "./fromHours.js";

export default days => fromHours(days * 24);
1 change: 1 addition & 0 deletions date/fromHours.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import fromMinutes from "./fromMinutes.js";

export default hours => fromMinutes(hours * 60);
1 change: 1 addition & 0 deletions date/fromMinutes.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import fromSeconds from "./fromSeconds.js";

export default minutes => fromSeconds(minutes * 60);
2 changes: 2 additions & 0 deletions date/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import toISO from "./toISO.js";
import toMinutes from "./toMinutes.js";
import toSeconds from "./toSeconds.js";
import valid from "./valid.js";

export {
clamp,
clone,
Expand Down Expand Up @@ -62,6 +63,7 @@ export {
toSeconds,
valid
};

export default {
clamp,
clone,
Expand Down
1 change: 1 addition & 0 deletions date/parseHourMinutePair.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export default (text = "") => {
const [hoursString, minutesString] = text.split(":");
const hours = parseInt(hoursString || "0", 10);
const minutes = parseInt(minutesString || "0", 10);

return [hours, minutes];
};
1 change: 1 addition & 0 deletions date/splitDateTime.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default dateTimeString => {
const [date, time] = dateTimeString.split("T");

return [date, time];
};
2 changes: 2 additions & 0 deletions date/startOfDay.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import clone from "./clone.js";

export default date => {
const copy = clone(date);
copy.setHours(0, 0, 0, 0);

return copy;
};
2 changes: 2 additions & 0 deletions date/subtractDays.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import clone from "./clone.js";

export default (sourceDate, numberOfDays) => {
const date = clone(sourceDate);
date.setDate(date.getDate() - numberOfDays);

return date;
};
1 change: 1 addition & 0 deletions date/toDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default date => {
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();

return [
`${year}`.padStart(4, "0"),
`${month}`.padStart(2, "0"),
Expand Down
1 change: 1 addition & 0 deletions date/toDays.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import toHours from "./toHours.js";

export default milliseconds => toHours(milliseconds) / 24;
1 change: 1 addition & 0 deletions date/toHours.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import toMinutes from "./toMinutes.js";

export default milliseconds => toMinutes(milliseconds) / 60;
1 change: 1 addition & 0 deletions date/toMinutes.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import toSeconds from "./toSeconds.js";

export default milliseconds => toSeconds(milliseconds) / 60;
Loading

0 comments on commit b4428d6

Please sign in to comment.