Format using new version of Prettier.

This commit is contained in:
David 2021-02-08 15:20:06 -06:00
parent fd503a978c
commit ecdabfe51e
2 changed files with 36 additions and 36 deletions

View file

@ -3,21 +3,21 @@
require(`setimmediate`);
// An order represents a pending push or shift.
const Order = channel => {
const Order = (channel) => {
let order;
const preonFulfilleds = [];
const promise = new Promise((resolve, reject) => {
order = {
resolve: value => {
preonFulfilleds.forEach(preonFulfilled => {
resolve: (value) => {
preonFulfilleds.forEach((preonFulfilled) => {
preonFulfilled(value);
});
resolve(value);
},
reject
reject,
};
});
@ -28,9 +28,9 @@ const Order = channel => {
channel,
prethen: onFulfilled => {
prethen: (onFulfilled) => {
preonFulfilleds.push(onFulfilled);
}
},
});
return { order, promise };
@ -46,7 +46,7 @@ const Channel = function(length = 0) {
const pushes = [];
const shifts = [];
const matchPushesAndShifts = index => {
const matchPushesAndShifts = (index) => {
while (index.push < pushes.length && index.shift < shifts.length) {
const push = pushes[index.push];
const shift = shifts[index.shift];
@ -67,7 +67,7 @@ const Channel = function(length = 0) {
};
// Resolve push promises up to the end of the buffer.
const resolveBufferedPushes = index => {
const resolveBufferedPushes = (index) => {
for (
let resolvedIndex = index.push + buffered;
resolvedIndex < pushes.length && buffered < length;
@ -82,7 +82,7 @@ const Channel = function(length = 0) {
}
};
const resolveClosedShifts = index => {
const resolveClosedShifts = (index) => {
for (; index.shift < shifts.length; index.shift++) {
const { cancelled, resolve } = shifts[index.shift];
@ -160,7 +160,7 @@ const Channel = function(length = 0) {
const output = Channel();
(async () => {
await readOnly.forEach(async value => {
await readOnly.forEach(async (value) => {
if (await callbackfn.call(thisArg, value)) {
await output.push(value);
}
@ -172,11 +172,11 @@ const Channel = function(length = 0) {
return output;
},
flat: depth => {
flat: (depth) => {
const output = Channel();
(async () => {
await readOnly.forEach(async value => {
await readOnly.forEach(async (value) => {
if (Channel.isChannel(value)) {
const input = depth > 1 ? value.flat(depth - 1) : value;
await input.forEach(output.push);
@ -206,13 +206,13 @@ const Channel = function(length = 0) {
}
},
join: async separator => (await readOnly.values()).join(separator),
join: async (separator) => (await readOnly.values()).join(separator),
map: (callbackfn, thisArg) => {
const output = Channel();
(async () => {
await readOnly.forEach(value =>
await readOnly.forEach((value) =>
output.push(callbackfn.call(thisArg, value))
);
@ -228,7 +228,7 @@ const Channel = function(length = 0) {
let previousValue = initialValue[0];
let previousValueDefined = initialValue.length > 0;
await readOnly.forEach(currentValue => {
await readOnly.forEach((currentValue) => {
if (previousValueDefined) {
previousValue = callbackfn(previousValue, currentValue);
} else {
@ -301,12 +301,12 @@ const Channel = function(length = 0) {
values: async () => {
const array = [];
await readOnly.forEach(item => {
await readOnly.forEach((item) => {
array.push(item);
});
return array;
}
},
})
);
@ -355,7 +355,7 @@ const Channel = function(length = 0) {
return promise;
},
writeOnly: () => writeOnly
writeOnly: () => writeOnly,
})
);
@ -364,14 +364,14 @@ const Channel = function(length = 0) {
);
};
Channel.all = channels => {
Channel.all = (channels) => {
const output = Channel();
(async () => {
for (;;) {
const values = await Promise.all(channels.map(Channel.shift));
if (values.every(value => value === undefined)) {
if (values.every((value) => value === undefined)) {
break;
} else {
await output.push(values);
@ -436,23 +436,23 @@ Channel.from = (values, mapfn, thisArg) => {
Channel.of = (...values) => Channel.from(values);
Channel.isChannel = value =>
Channel.isChannel = (value) =>
value !== undefined &&
value !== null &&
Object.getPrototypeOf(value) === prototype;
Channel.select = methodPromises => {
Channel.select = (methodPromises) => {
if (!Array.isArray(methodPromises)) {
throw new TypeError(`Channel.select: Argument must be an array.`);
}
const selectPromise = new Promise((resolve, reject) => {
methodPromises.forEach(async promise => {
methodPromises.forEach(async (promise) => {
try {
promise.prethen(() => {
// We've been given a heads-up that this method will complete first
// so cancel the other method calls.
methodPromises.forEach(other => {
methodPromises.forEach((other) => {
if (other !== promise) {
other.cancel();
}
@ -477,7 +477,7 @@ Channel.select = methodPromises => {
});
return Object.assign(selectPromise, {
cancel: () => methodPromises.forEach(promise => promise.cancel())
cancel: () => methodPromises.forEach((promise) => promise.cancel()),
});
};
@ -490,15 +490,15 @@ Channel.select = methodPromises => {
const channel = Channel();
const methods = Object.keys(channel).filter(
method => typeof channel[method] === `function`
(method) => typeof channel[method] === `function`
);
const arities = {
reduce: 2,
slice: 2
slice: 2,
};
methods.forEach(method => {
methods.forEach((method) => {
const bound = function(...args) {
const arity = arities[method] || channel[method].length;