Skip to content

Commit

Permalink
refactor: remove top-level arrow sytnax use (#3687)
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua authored Oct 11, 2023
1 parent c028b8a commit a8a133e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
13 changes: 8 additions & 5 deletions crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,13 @@ export type DigestAlgorithmObject = {

export type DigestAlgorithm = DigestAlgorithmName | DigestAlgorithmObject;

const normalizeAlgorithm = (algorithm: DigestAlgorithm) =>
((typeof algorithm === "string") ? { name: algorithm.toUpperCase() } : {
...algorithm,
name: algorithm.name.toUpperCase(),
}) as DigestAlgorithmObject;
function normalizeAlgorithm(algorithm: DigestAlgorithm) {
return ((typeof algorithm === "string")
? { name: algorithm.toUpperCase() }
: {
...algorithm,
name: algorithm.name.toUpperCase(),
}) as DigestAlgorithmObject;
}

export { stdCrypto as crypto };
5 changes: 3 additions & 2 deletions encoding/base64url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ function convertBase64urlToBase64(b64url: string): string {
return addPaddingToBase64url(b64url).replace(/\-/g, "+").replace(/_/g, "/");
}

const convertBase64ToBase64url = (b64: string) =>
b64.endsWith("=")
function convertBase64ToBase64url(b64: string) {
return b64.endsWith("=")
? b64.endsWith("==")
? b64.replace(/\+/g, "-").replace(/\//g, "_").slice(0, -2)
: b64.replace(/\+/g, "-").replace(/\//g, "_").slice(0, -1)
: b64.replace(/\+/g, "-").replace(/\//g, "_");
}

/**
* @deprecated (will be removed in 0.210.0) Use a `encodeBase64Url` instead.
Expand Down
5 changes: 3 additions & 2 deletions fmt/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
* @module
*/

const addZero = (num: number, digits: number) =>
String(num).padStart(digits, "0");
function addZero(num: number, digits: number) {
return String(num).padStart(digits, "0");
}

interface DurationObject {
d: number;
Expand Down
7 changes: 2 additions & 5 deletions yaml/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ export type KindType = "sequence" | "scalar" | "mapping";
export type StyleVariant = "lowercase" | "uppercase" | "camelcase" | "decimal";
export type RepresentFn = (data: Any, style?: StyleVariant) => Any;

const DEFAULT_RESOLVE = (): boolean => true;
const DEFAULT_CONSTRUCT = (data: Any): Any => data;

interface TypeOptions {
kind: KindType;
resolve?: (data: Any) => boolean;
Expand Down Expand Up @@ -42,8 +39,8 @@ export class Type {
this.tag = checkTagFormat(tag);
if (options) {
this.kind = options.kind;
this.resolve = options.resolve || DEFAULT_RESOLVE;
this.construct = options.construct || DEFAULT_CONSTRUCT;
this.resolve = options.resolve || (() => true);
this.construct = options.construct || ((data: Any): Any => data);
this.instanceOf = options.instanceOf;
this.predicate = options.predicate;
this.represent = options.represent;
Expand Down

0 comments on commit a8a133e

Please sign in to comment.