Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump prettier to 1.18.2 #592

Merged
merged 4 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 28 additions & 34 deletions archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,27 +384,25 @@ export class Tar {
*/
getReader(): Deno.Reader {
const readers: Deno.Reader[] = [];
this.data.forEach(
(tarData): void => {
let { filePath, reader } = tarData,
headerArr = formatHeader(tarData);
readers.push(new Deno.Buffer(headerArr));
if (!reader) {
reader = new FileReader(filePath!);
}
readers.push(reader);

// to the nearest multiple of recordSize
readers.push(
new Deno.Buffer(
clean(
recordSize -
(parseInt(tarData.fileSize!, 8) % recordSize || recordSize)
)
)
);
this.data.forEach((tarData): void => {
let { filePath, reader } = tarData,
headerArr = formatHeader(tarData);
readers.push(new Deno.Buffer(headerArr));
if (!reader) {
reader = new FileReader(filePath!);
}
);
readers.push(reader);

// to the nearest multiple of recordSize
readers.push(
new Deno.Buffer(
clean(
recordSize -
(parseInt(tarData.fileSize!, 8) % recordSize || recordSize)
)
)
);
});

// append 2 empty records
readers.push(new Deno.Buffer(clean(recordSize * 2)));
Expand Down Expand Up @@ -461,22 +459,18 @@ export class Untar {
"mtime",
"uid",
"gid"
]).forEach(
(key): void => {
const arr = trim(header[key]);
if (arr.byteLength > 0) {
meta[key] = parseInt(decoder.decode(arr), 8);
}
]).forEach((key): void => {
const arr = trim(header[key]);
if (arr.byteLength > 0) {
meta[key] = parseInt(decoder.decode(arr), 8);
}
);
(["owner", "group"] as ["owner", "group"]).forEach(
(key): void => {
const arr = trim(header[key]);
if (arr.byteLength > 0) {
meta[key] = decoder.decode(arr);
}
});
(["owner", "group"] as ["owner", "group"]).forEach((key): void => {
const arr = trim(header[key]);
if (arr.byteLength > 0) {
meta[key] = decoder.decode(arr);
}
);
});

// read the file content
const len = parseInt(decoder.decode(header.fileSize), 8);
Expand Down
24 changes: 11 additions & 13 deletions bundle/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,18 @@ export function instantiate(
assert(module != null);
assert(module.factory != null);

const dependencies = module.dependencies.map(
(id): object => {
if (id === "require") {
// TODO(kitsonk) support dynamic import by passing a `require()` that
// can return a local module or dynamically import one.
return (): void => {};
} else if (id === "exports") {
return module.exports;
}
const dep = modules.get(id)!;
assert(dep != null);
return dep.exports;
const dependencies = module.dependencies.map((id): object => {
if (id === "require") {
// TODO(kitsonk) support dynamic import by passing a `require()` that
// can return a local module or dynamically import one.
return (): void => {};
} else if (id === "exports") {
return module.exports;
}
);
const dep = modules.get(id)!;
assert(dep != null);
return dep.exports;
});

if (typeof module.factory === "function") {
module.factory!(...dependencies);
Expand Down
66 changes: 31 additions & 35 deletions encoding/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,23 @@ async function read(
result = line.split(opt.comma!);

let quoteError = false;
result = result.map(
(r): string => {
if (opt.trimLeadingSpace) {
r = r.trimLeft();
}
if (r[0] === '"' && r[r.length - 1] === '"') {
r = r.substring(1, r.length - 1);
} else if (r[0] === '"') {
r = r.substring(1, r.length);
}
result = result.map((r): string => {
if (opt.trimLeadingSpace) {
r = r.trimLeft();
}
if (r[0] === '"' && r[r.length - 1] === '"') {
r = r.substring(1, r.length - 1);
} else if (r[0] === '"') {
r = r.substring(1, r.length);
}

if (!opt.lazyQuotes) {
if (r[0] !== '"' && r.indexOf('"') !== -1) {
quoteError = true;
}
if (!opt.lazyQuotes) {
if (r[0] !== '"' && r.indexOf('"') !== -1) {
quoteError = true;
}
return r;
}
);
return r;
});
if (quoteError) {
throw new ParseError(Startline, lineIndex, 'bare " in non-quoted-field');
}
Expand Down Expand Up @@ -226,27 +224,25 @@ export async function parse(
);
i++;
}
return r.map(
(e): unknown => {
if (e.length !== headers.length) {
throw `Error number of fields line:${i}`;
}
i++;
let out: Record<string, unknown> = {};
for (let j = 0; j < e.length; j++) {
const h = headers[j];
if (h.parse) {
out[h.name] = h.parse(e[j]);
} else {
out[h.name] = e[j];
}
}
if (opt.parse) {
return opt.parse(out);
return r.map((e): unknown => {
if (e.length !== headers.length) {
throw `Error number of fields line:${i}`;
}
i++;
let out: Record<string, unknown> = {};
for (let j = 0; j < e.length; j++) {
const h = headers[j];
if (h.parse) {
out[h.name] = h.parse(e[j]);
} else {
out[h.name] = e[j];
}
return out;
}
);
if (opt.parse) {
return opt.parse(out);
}
return out;
});
}
if (opt.parse) {
return r.map((e: string[]): unknown => opt.parse!(e));
Expand Down
28 changes: 12 additions & 16 deletions encoding/toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,24 +403,20 @@ class Dumper {
_parse(obj: Record<string, unknown>, path: string = ""): string[] {
const out = [];
const props = Object.keys(obj);
const propObj = props.filter(
(e: string): boolean => {
if (obj[e] instanceof Array) {
const d: unknown[] = obj[e] as unknown[];
return !this._isSimplySerializable(d[0]);
}
return !this._isSimplySerializable(obj[e]);
const propObj = props.filter((e: string): boolean => {
if (obj[e] instanceof Array) {
const d: unknown[] = obj[e] as unknown[];
return !this._isSimplySerializable(d[0]);
}
);
const propPrim = props.filter(
(e: string): boolean => {
if (obj[e] instanceof Array) {
const d: unknown[] = obj[e] as unknown[];
return this._isSimplySerializable(d[0]);
}
return this._isSimplySerializable(obj[e]);
return !this._isSimplySerializable(obj[e]);
});
const propPrim = props.filter((e: string): boolean => {
if (obj[e] instanceof Array) {
const d: unknown[] = obj[e] as unknown[];
return this._isSimplySerializable(d[0]);
}
);
return this._isSimplySerializable(obj[e]);
});
const k = propPrim.concat(propObj);
for (let i = 0; i < k.length; i++) {
const prop = k[i];
Expand Down
16 changes: 6 additions & 10 deletions flags/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ export function parse(
? [options.boolean]
: options.boolean;

booleanArgs.filter(Boolean).forEach(
(key: string): void => {
flags.bools[key] = true;
}
);
booleanArgs.filter(Boolean).forEach((key: string): void => {
flags.bools[key] = true;
});
}
}

Expand Down Expand Up @@ -114,11 +112,9 @@ export function parse(
flags.strings[key] = true;
const alias = get(aliases, key);
if (alias) {
alias.forEach(
(alias: string): void => {
flags.strings[alias] = true;
}
);
alias.forEach((alias: string): void => {
flags.strings[alias] = true;
});
}
});
}
Expand Down
22 changes: 10 additions & 12 deletions fmt/sprintf_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,18 +587,16 @@ const tests: Array<[string, any, string]> = [
];

test(function testThorough(): void {
tests.forEach(
(t, i): void => {
// p(t)
let is = S(t[0], t[1]);
let should = t[2];
assertEquals(
is,
should,
`failed case[${i}] : is >${is}< should >${should}<`
);
}
);
tests.forEach((t, i): void => {
// p(t)
let is = S(t[0], t[1]);
let should = t[2];
assertEquals(
is,
should,
`failed case[${i}] : is >${is}< should >${should}<`
);
});
});

test(function testWeirdos(): void {
Expand Down