Skip to content

Commit

Permalink
Update to Prettier 2 and use ES Private Fields (denoland/deno#4498)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk authored and denobot committed Feb 1, 2021
1 parent 2761dd0 commit 7914eae
Show file tree
Hide file tree
Showing 190 changed files with 1,247 additions and 1,253 deletions.
46 changes: 23 additions & 23 deletions archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,68 +104,68 @@ struct posix_header { // byte offset
const ustarStructure: Array<{ field: string; length: number }> = [
{
field: "fileName",
length: 100
length: 100,
},
{
field: "fileMode",
length: 8
length: 8,
},
{
field: "uid",
length: 8
length: 8,
},
{
field: "gid",
length: 8
length: 8,
},
{
field: "fileSize",
length: 12
length: 12,
},
{
field: "mtime",
length: 12
length: 12,
},
{
field: "checksum",
length: 8
length: 8,
},
{
field: "type",
length: 1
length: 1,
},
{
field: "linkName",
length: 100
length: 100,
},
{
field: "ustar",
length: 8
length: 8,
},
{
field: "owner",
length: 32
length: 32,
},
{
field: "group",
length: 32
length: 32,
},
{
field: "majorNumber",
length: 8
length: 8,
},
{
field: "minorNumber",
length: 8
length: 8,
},
{
field: "fileNamePrefix",
length: 155
length: 155,
},
{
field: "padding",
length: 12
}
length: 12,
},
];

/**
Expand All @@ -175,7 +175,7 @@ function formatHeader(data: TarData): Uint8Array {
const encoder = new TextEncoder(),
buffer = clean(512);
let offset = 0;
ustarStructure.forEach(function(value): void {
ustarStructure.forEach(function (value): void {
const entry = encoder.encode(data[value.field as keyof TarData] || "");
buffer.set(entry, offset);
offset += value.length; // space it out with nulls
Expand All @@ -190,7 +190,7 @@ function formatHeader(data: TarData): Uint8Array {
function parseHeader(buffer: Uint8Array): { [key: string]: Uint8Array } {
const data: { [key: string]: Uint8Array } = {};
let offset = 0;
ustarStructure.forEach(function(value): void {
ustarStructure.forEach(function (value): void {
const arr = buffer.subarray(offset, offset + value.length);
data[value.field] = arr;
offset += value.length;
Expand Down Expand Up @@ -350,15 +350,15 @@ export class Tar {
owner: opts.owner || "",
group: opts.group || "",
filePath: opts.filePath,
reader: opts.reader
reader: opts.reader,
};

// calculate the checksum
let checksum = 0;
const encoder = new TextEncoder();
Object.keys(tarData)
.filter((key): boolean => ["filePath", "reader"].indexOf(key) < 0)
.forEach(function(key): void {
.forEach(function (key): void {
checksum += encoder
.encode(tarData[key as keyof TarData])
.reduce((p, c): number => p + c, 0);
Expand Down Expand Up @@ -424,7 +424,7 @@ export class Untar {
decoder = new TextDecoder("ascii");
Object.keys(header)
.filter((key): boolean => key !== "checksum")
.forEach(function(key): void {
.forEach(function (key): void {
checksum += header[key].reduce((p, c): number => p + c, 0);
});
checksum += encoder.encode(" ").reduce((p, c): number => p + c, 0);
Expand All @@ -440,7 +440,7 @@ export class Untar {

// get meta data
const meta: UntarOptions = {
fileName: decoder.decode(trim(header.fileName))
fileName: decoder.decode(trim(header.fileName)),
};
const fileNamePrefix = trim(header.fileNamePrefix);
if (fileNamePrefix.byteLength > 0) {
Expand Down
6 changes: 3 additions & 3 deletions archive/tar_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Deno.test(async function createTarArchive(): Promise<void> {
const content = new TextEncoder().encode("hello tar world!");
await tar.append("output.txt", {
reader: new Deno.Buffer(content),
contentSize: content.byteLength
contentSize: content.byteLength,
});

// put a file
Expand All @@ -49,7 +49,7 @@ Deno.test(async function deflateTarArchive(): Promise<void> {
const content = new TextEncoder().encode(text);
await tar.append(fileName, {
reader: new Deno.Buffer(content),
contentSize: content.byteLength
contentSize: content.byteLength,
});

// read data from a tar archive
Expand All @@ -73,7 +73,7 @@ Deno.test(async function appendFileWithLongNameToTarArchive(): Promise<void> {
const content = new TextEncoder().encode(text);
await tar.append(fileName, {
reader: new Deno.Buffer(content),
contentSize: content.byteLength
contentSize: content.byteLength,
});

// read data from a tar archive
Expand Down
4 changes: 2 additions & 2 deletions bytes/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
equal,
hasPrefix,
repeat,
concat
concat,
} from "./mod.ts";
import { assertEquals, assertThrows, assert } from "../testing/asserts.ts";
import { encode, decode } from "../strings/mod.ts";
Expand Down Expand Up @@ -58,7 +58,7 @@ Deno.test("[bytes] repeat", () => {
["-", "", 0],
["-", "-", -1, "bytes: negative repeat count"],
["-", "----------", 10],
["abc ", "abc abc abc ", 3]
["abc ", "abc abc abc ", 3],
];
for (const [input, output, count, errMsg] of repeatTestCase) {
if (errMsg) {
Expand Down
2 changes: 1 addition & 1 deletion datetime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ parseDateTime("16:34 01-20-2019", "hh:mm mm-dd-yyyy") // output : new Date(2019,
```ts
import {
dayOfYear,
currentDayOfYear
currentDayOfYear,
} from "https://deno.land/std/datetime/mod.ts";

dayOfYear(new Date("2019-03-11T03:24:00")); // output: 70
Expand Down
2 changes: 1 addition & 1 deletion datetime/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function toIMF(date: Date): string {
"Sep",
"Oct",
"Nov",
"Dec"
"Dec",
];
return `${days[date.getUTCDay()]}, ${d} ${
months[date.getUTCMonth()]
Expand Down
4 changes: 2 additions & 2 deletions datetime/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Deno.test({
const actual = datetime.toIMF(new Date(Date.UTC(1994, 3, 5, 15, 32)));
const expected = "Tue, 05 Apr 1994 15:32:00 GMT";
assertEquals(actual, expected);
}
},
});

Deno.test({
Expand All @@ -91,5 +91,5 @@ Deno.test({
const actual = datetime.toIMF(new Date(0));
const expected = "Thu, 01 Jan 1970 00:00:00 GMT";
assertEquals(actual, expected);
}
},
});
6 changes: 3 additions & 3 deletions encoding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const string = "a,b,c\nd,e,f";

console.log(
await parseCsv(string, {
header: false
header: false,
})
);
// output:
Expand Down Expand Up @@ -161,9 +161,9 @@ import { stringify } from "./parser.ts";
const obj = {
bin: [
{ name: "deno", path: "cli/main.rs" },
{ name: "deno_core", path: "src/foo.rs" }
{ name: "deno_core", path: "src/foo.rs" },
],
nib: [{ name: "node", path: "not_found" }]
nib: [{ name: "node", path: "not_found" }],
};
const tomlString = stringify(obj);
```
Expand Down
38 changes: 19 additions & 19 deletions encoding/base32_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { encode, decode } from "./base32.ts";

// Lifted from https://stackoverflow.com/questions/38987784
const fromHexString = (hexString: string): Uint8Array =>
new Uint8Array(hexString.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16)));
new Uint8Array(hexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16)));
const toHexString = (bytes: Uint8Array): string =>
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");

Expand Down Expand Up @@ -34,56 +34,56 @@ const testCases = [
["ddf80ebe21bf1b1e12a64c5cc6a74b5d92dd", "3X4A5PRBX4NR4EVGJROMNJ2LLWJN2==="],
[
"c0cae52c6f641ce04a7ee5b9a8fa8ded121bca",
"YDFOKLDPMQOOAST64W42R6UN5UJBXSQ="
"YDFOKLDPMQOOAST64W42R6UN5UJBXSQ=",
],
[
"872840a355c8c70586f462c9e669ee760cb3537e",
"Q4UEBI2VZDDQLBXUMLE6M2POOYGLGU36"
"Q4UEBI2VZDDQLBXUMLE6M2POOYGLGU36",
],
[
"5773fe22662818a120c5688824c935fe018208a496",
"K5Z74ITGFAMKCIGFNCECJSJV7YAYECFESY======"
"K5Z74ITGFAMKCIGFNCECJSJV7YAYECFESY======",
],
[
"416e23abc524d1b85736e2bea6cfecd5192789034a28",
"IFXCHK6FETI3QVZW4K7KNT7M2UMSPCIDJIUA===="
"IFXCHK6FETI3QVZW4K7KNT7M2UMSPCIDJIUA====",
],
[
"83d2386ebdd7e8e818ec00e3ccd882aa933b905b7e2e44",
"QPJDQ3V527UOQGHMADR4ZWECVKJTXEC3PYXEI==="
"QPJDQ3V527UOQGHMADR4ZWECVKJTXEC3PYXEI===",
],
[
"a2fa8b881f3b8024f52745763c4ae08ea12bdf8bef1a72f8",
"UL5IXCA7HOACJ5JHIV3DYSXAR2QSXX4L54NHF6A="
"UL5IXCA7HOACJ5JHIV3DYSXAR2QSXX4L54NHF6A=",
],
[
"b074ae8b9efde0f17f37bccadde006d039997b59c8efb05add",
"WB2K5C467XQPC7ZXXTFN3YAG2A4ZS62ZZDX3AWW5"
"WB2K5C467XQPC7ZXXTFN3YAG2A4ZS62ZZDX3AWW5",
],
[
"764fef941aee7e416dc204ae5ab9c5b9ce644567798e6849aea9",
"OZH67FA25Z7EC3OCASXFVOOFXHHGIRLHPGHGQSNOVE======"
"OZH67FA25Z7EC3OCASXFVOOFXHHGIRLHPGHGQSNOVE======",
],
[
"4995d9811f37f59797d7c3b9b9e5325aa78277415f70f4accf588c",
"JGK5TAI7G72ZPF6XYO43TZJSLKTYE52BL5YPJLGPLCGA===="
"JGK5TAI7G72ZPF6XYO43TZJSLKTYE52BL5YPJLGPLCGA====",
],
[
"24f0812ca8eed58374c11a7008f0b262698b72fd2792709208eaacb2",
"ETYICLFI53KYG5GBDJYAR4FSMJUYW4X5E6JHBEQI5KWLE==="
"ETYICLFI53KYG5GBDJYAR4FSMJUYW4X5E6JHBEQI5KWLE===",
],
[
"d70692543810d4bf50d81cf44a55801a557a388a341367c7ea077ca306",
"24DJEVBYCDKL6UGYDT2EUVMADJKXUOEKGQJWPR7KA56KGBQ="
"24DJEVBYCDKL6UGYDT2EUVMADJKXUOEKGQJWPR7KA56KGBQ=",
],
[
"6e08a89ca36b677ff8fe99e68a1241c8d8cef2570a5f60b6417d2538b30c",
"NYEKRHFDNNTX76H6THTIUESBZDMM54SXBJPWBNSBPUSTRMYM"
"NYEKRHFDNNTX76H6THTIUESBZDMM54SXBJPWBNSBPUSTRMYM",
],
[
"f2fc2319bd29457ccd01e8e194ee9bd7e97298b6610df4ab0f3d5baa0b2d7ccf69829edb74edef",
"6L6CGGN5FFCXZTIB5DQZJ3U327UXFGFWMEG7JKYPHVN2UCZNPTHWTAU63N2O33Y="
]
"6L6CGGN5FFCXZTIB5DQZJ3U327UXFGFWMEG7JKYPHVN2UCZNPTHWTAU63N2O33Y=",
],
];

Deno.test({
Expand All @@ -92,7 +92,7 @@ Deno.test({
for (const [bin, b32] of testCases) {
assertEquals(encode(fromHexString(bin)), b32);
}
}
},
});

Deno.test({
Expand All @@ -101,7 +101,7 @@ Deno.test({
for (const [bin, b32] of testCases) {
assertEquals(toHexString(decode(b32)), bin);
}
}
},
});

Deno.test({
Expand All @@ -117,7 +117,7 @@ Deno.test({
errorCaught = true;
}
assert(errorCaught);
}
},
});

Deno.test({
Expand All @@ -131,5 +131,5 @@ Deno.test({
errorCaught = true;
}
assert(errorCaught);
}
},
});
2 changes: 1 addition & 1 deletion encoding/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const rawTypeSizes = {
int64: 8,
uint64: 8,
float32: 4,
float64: 8
float64: 8,
};

/** Returns the number of bytes required to store the given data-type. */
Expand Down
2 changes: 1 addition & 1 deletion encoding/binary_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
varbig,
varnum,
writeVarbig,
writeVarnum
writeVarnum,
} from "./binary.ts";

Deno.test(async function testGetNBytes(): Promise<void> {
Expand Down
Loading

0 comments on commit 7914eae

Please sign in to comment.