Skip to content

Commit

Permalink
name functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Jul 21, 2021
1 parent 081b559 commit bc3dd3d
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/client/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function getClient(_config: IChainForkConfig, baseUrl: string): Api {
// EventSource will try to reconnect always on all errors
// `eventSource.onerror` events are informative but don't indicate the EventSource closed
// The only way to abort the connection from the client is via eventSource.close()
eventSource.onerror = function (err) {
eventSource.onerror = function onerror(err) {
const errEs = (err as unknown) as EventSourceError;
// Consider 400 and 500 status errors unrecoverable, close the eventsource
if (errEs.status === 400) {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/utils/urlFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function compileRouteUrlFormater(path: string): (arg: Args) => string {
}
});

return function (args: Args) {
return function urlFormater(args: Args) {
// Don't use .map() or .join(), it's x3 slower
let s = "";
for (const fn of fns) s += fn(args);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const yamlSchema = new Schema({
implicit: [
new Type("tag:yaml.org,2002:str", {
kind: "scalar",
construct: function (data) {
construct: function construct(data) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return data !== null ? data : "";
},
Expand Down
2 changes: 1 addition & 1 deletion packages/lodestar/src/network/gossip/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getGossipValidatorFn<K extends GossipType>(
const {config, logger, metrics, uncompressCache, gossipTopicCache} = modules;
const getGossipObjectAcceptMetadata = getGossipAcceptMetadataByType[type] as GetGossipAcceptMetadataFn;

return async function (topicStr, gossipMsg) {
return async function gossipValidatorFn(topicStr, gossipMsg) {
try {
const topic = gossipTopicCache.getTopic(topicStr);
const encoding = topic.encoding ?? DEFAULT_ENCODING;
Expand Down
2 changes: 1 addition & 1 deletion packages/lodestar/src/network/gossip/validation/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function wrapWithQueue(
: undefined
);

return async function (topicStr, gossipMsg) {
return async function gossipValidatorFnWithQueue(topicStr, gossipMsg) {
await jobQueue.push(async () => gossipValidatorFn(topicStr, gossipMsg));
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {readEncodedPayload} from "../encodingStrategies";
export function requestDecode(
protocol: Pick<Protocol, "method" | "encoding">
): (source: AsyncIterable<Buffer | BufferList>) => Promise<RequestBody> {
return async function (source) {
return async function requestDecodeSink(source) {
const type = getRequestSzzTypeByMethod(protocol.method);
if (!type) {
// method has no body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function responseDecode(
forkDigestContext: IForkDigestContext,
protocol: Protocol
): (source: AsyncIterable<Buffer>) => AsyncGenerator<ResponseBody> {
return async function* (source) {
return async function* responseDecodeSink(source) {
const deserializeToTree = deserializeToTreeByMethod[protocol.method];
const contextBytesType = contextBytesTypeByProtocol(protocol);
const bufferedSource = new BufferedSource(source as AsyncGenerator<Buffer>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function responseEncodeSuccess(
): (source: AsyncIterable<ResponseBody>) => AsyncIterable<Buffer> {
const contextBytesType = contextBytesTypeByProtocol(protocol);

return async function* (source) {
return async function* responseEncodeSuccessTransform(source) {
for await (const chunk of source) {
// <result>
yield Buffer.from([RespStatus.SUCCESS]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function responseTimeoutsHandler<T>(
responseDecoder: (source: AsyncIterable<Buffer>) => AsyncGenerator<T>,
options?: Partial<typeof timeoutOptions>
): (source: AsyncIterable<Buffer>) => AsyncGenerator<T> {
return async function* (source) {
return async function* responseTimeoutsHandlerTransform(source) {
const {TTFB_TIMEOUT, RESP_TIMEOUT} = {...timeoutOptions, ...options};

const ttfbTimeoutController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion packages/lodestar/src/network/reqresp/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function handleRequest(
// Yields success chunks and error chunks in the same generator
// This syntax allows to recycle stream.sink to send success and error chunks without returning
// in case request whose body is a List fails at chunk_i > 0, without breaking out of the for..await..of
(async function* () {
(async function* requestHandlerSource() {
try {
const requestBody = await withTimeout(
() => pipe(stream.source, requestDecode(protocol)),
Expand Down
2 changes: 1 addition & 1 deletion packages/lodestar/src/network/reqresp/utils/onChunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Useful for logging, or cancelling timeouts
*/
export function onChunk<T>(callback: (chunk: T) => void): (source: AsyncIterable<T>) => AsyncIterable<T> {
return async function* (source) {
return async function* onChunkTransform(source) {
for await (const chunk of source) {
callback(chunk);
yield chunk;
Expand Down
25 changes: 0 additions & 25 deletions packages/lodestar/src/util/io.ts

This file was deleted.

11 changes: 9 additions & 2 deletions packages/spec-test-util/src/multi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any,@typescript-eslint/no-unused-vars */
import {writeFile} from "fs";
import {expect} from "chai";
import {loadYamlFile} from "./util";

/* eslint-disable
@typescript-eslint/no-unsafe-call,
@typescript-eslint/no-unsafe-member-access,
@typescript-eslint/no-unsafe-return,
@typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-explicit-any,
@typescript-eslint/no-unused-vars,
func-names */

export interface IBaseCase {
description: string;
}
Expand Down
8 changes: 7 additions & 1 deletion packages/spec-test-util/src/single.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any */
import {expect} from "chai";
import {readdirSync, readFileSync, existsSync} from "fs";
import {basename, join, parse} from "path";
import {Type, CompositeType} from "@chainsafe/ssz";
import {uncompress} from "snappyjs";
import {isDirectory, loadYamlFile} from "./util";

/* eslint-disable
@typescript-eslint/no-unsafe-assignment,
@typescript-eslint/no-unsafe-member-access,
@typescript-eslint/no-unsafe-return,
@typescript-eslint/no-explicit-any,
func-names */

export enum InputType {
SSZ = "ssz",
SSZ_SNAPPY = "ssz_snappy",
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/src/yaml/int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,22 @@ export const intType = new Type("tag:yaml.org,2002:int", {
represent: {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
binary: function (obj: number) {
binary: function binary(obj: number) {
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
octal: function (obj: number) {
octal: function octal(obj: number) {
return obj >= 0 ? "0" + obj.toString(8) : "-0" + obj.toString(8).slice(1);
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
decimal: function (obj: number) {
decimal: function decimal(obj: number) {
return obj.toString(10);
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
hexadecimal: function (obj: number) {
hexadecimal: function hexadecimal(obj: number) {
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
},
},
Expand Down

0 comments on commit bc3dd3d

Please sign in to comment.