Skip to content

Commit 878a9a2

Browse files
axetroyry
authored andcommitted
bump prettier to 1.18.2 (denoland/std#592)
Original: denoland/std@06958a4
1 parent 08087e9 commit 878a9a2

37 files changed

+778
-714
lines changed

archive/tar.ts

+28-34
Original file line numberDiff line numberDiff line change
@@ -384,27 +384,25 @@ export class Tar {
384384
*/
385385
getReader(): Deno.Reader {
386386
const readers: Deno.Reader[] = [];
387-
this.data.forEach(
388-
(tarData): void => {
389-
let { filePath, reader } = tarData,
390-
headerArr = formatHeader(tarData);
391-
readers.push(new Deno.Buffer(headerArr));
392-
if (!reader) {
393-
reader = new FileReader(filePath!);
394-
}
395-
readers.push(reader);
396-
397-
// to the nearest multiple of recordSize
398-
readers.push(
399-
new Deno.Buffer(
400-
clean(
401-
recordSize -
402-
(parseInt(tarData.fileSize!, 8) % recordSize || recordSize)
403-
)
404-
)
405-
);
387+
this.data.forEach((tarData): void => {
388+
let { filePath, reader } = tarData,
389+
headerArr = formatHeader(tarData);
390+
readers.push(new Deno.Buffer(headerArr));
391+
if (!reader) {
392+
reader = new FileReader(filePath!);
406393
}
407-
);
394+
readers.push(reader);
395+
396+
// to the nearest multiple of recordSize
397+
readers.push(
398+
new Deno.Buffer(
399+
clean(
400+
recordSize -
401+
(parseInt(tarData.fileSize!, 8) % recordSize || recordSize)
402+
)
403+
)
404+
);
405+
});
408406

409407
// append 2 empty records
410408
readers.push(new Deno.Buffer(clean(recordSize * 2)));
@@ -461,22 +459,18 @@ export class Untar {
461459
"mtime",
462460
"uid",
463461
"gid"
464-
]).forEach(
465-
(key): void => {
466-
const arr = trim(header[key]);
467-
if (arr.byteLength > 0) {
468-
meta[key] = parseInt(decoder.decode(arr), 8);
469-
}
462+
]).forEach((key): void => {
463+
const arr = trim(header[key]);
464+
if (arr.byteLength > 0) {
465+
meta[key] = parseInt(decoder.decode(arr), 8);
470466
}
471-
);
472-
(["owner", "group"] as ["owner", "group"]).forEach(
473-
(key): void => {
474-
const arr = trim(header[key]);
475-
if (arr.byteLength > 0) {
476-
meta[key] = decoder.decode(arr);
477-
}
467+
});
468+
(["owner", "group"] as ["owner", "group"]).forEach((key): void => {
469+
const arr = trim(header[key]);
470+
if (arr.byteLength > 0) {
471+
meta[key] = decoder.decode(arr);
478472
}
479-
);
473+
});
480474

481475
// read the file content
482476
const len = parseInt(decoder.decode(header.fileSize), 8);

bundle/utils.ts

+11-13
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,18 @@ export function instantiate(
6969
assert(module != null);
7070
assert(module.factory != null);
7171

72-
const dependencies = module.dependencies.map(
73-
(id): object => {
74-
if (id === "require") {
75-
// TODO(kitsonk) support dynamic import by passing a `require()` that
76-
// can return a local module or dynamically import one.
77-
return (): void => {};
78-
} else if (id === "exports") {
79-
return module.exports;
80-
}
81-
const dep = modules.get(id)!;
82-
assert(dep != null);
83-
return dep.exports;
72+
const dependencies = module.dependencies.map((id): object => {
73+
if (id === "require") {
74+
// TODO(kitsonk) support dynamic import by passing a `require()` that
75+
// can return a local module or dynamically import one.
76+
return (): void => {};
77+
} else if (id === "exports") {
78+
return module.exports;
8479
}
85-
);
80+
const dep = modules.get(id)!;
81+
assert(dep != null);
82+
return dep.exports;
83+
});
8684

8785
if (typeof module.factory === "function") {
8886
module.factory!(...dependencies);

encoding/csv.ts

+31-35
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,23 @@ async function read(
8484
result = line.split(opt.comma!);
8585

8686
let quoteError = false;
87-
result = result.map(
88-
(r): string => {
89-
if (opt.trimLeadingSpace) {
90-
r = r.trimLeft();
91-
}
92-
if (r[0] === '"' && r[r.length - 1] === '"') {
93-
r = r.substring(1, r.length - 1);
94-
} else if (r[0] === '"') {
95-
r = r.substring(1, r.length);
96-
}
87+
result = result.map((r): string => {
88+
if (opt.trimLeadingSpace) {
89+
r = r.trimLeft();
90+
}
91+
if (r[0] === '"' && r[r.length - 1] === '"') {
92+
r = r.substring(1, r.length - 1);
93+
} else if (r[0] === '"') {
94+
r = r.substring(1, r.length);
95+
}
9796

98-
if (!opt.lazyQuotes) {
99-
if (r[0] !== '"' && r.indexOf('"') !== -1) {
100-
quoteError = true;
101-
}
97+
if (!opt.lazyQuotes) {
98+
if (r[0] !== '"' && r.indexOf('"') !== -1) {
99+
quoteError = true;
102100
}
103-
return r;
104101
}
105-
);
102+
return r;
103+
});
106104
if (quoteError) {
107105
throw new ParseError(Startline, lineIndex, 'bare " in non-quoted-field');
108106
}
@@ -226,27 +224,25 @@ export async function parse(
226224
);
227225
i++;
228226
}
229-
return r.map(
230-
(e): unknown => {
231-
if (e.length !== headers.length) {
232-
throw `Error number of fields line:${i}`;
233-
}
234-
i++;
235-
let out: Record<string, unknown> = {};
236-
for (let j = 0; j < e.length; j++) {
237-
const h = headers[j];
238-
if (h.parse) {
239-
out[h.name] = h.parse(e[j]);
240-
} else {
241-
out[h.name] = e[j];
242-
}
243-
}
244-
if (opt.parse) {
245-
return opt.parse(out);
227+
return r.map((e): unknown => {
228+
if (e.length !== headers.length) {
229+
throw `Error number of fields line:${i}`;
230+
}
231+
i++;
232+
let out: Record<string, unknown> = {};
233+
for (let j = 0; j < e.length; j++) {
234+
const h = headers[j];
235+
if (h.parse) {
236+
out[h.name] = h.parse(e[j]);
237+
} else {
238+
out[h.name] = e[j];
246239
}
247-
return out;
248240
}
249-
);
241+
if (opt.parse) {
242+
return opt.parse(out);
243+
}
244+
return out;
245+
});
250246
}
251247
if (opt.parse) {
252248
return r.map((e: string[]): unknown => opt.parse!(e));

encoding/toml.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -403,24 +403,20 @@ class Dumper {
403403
_parse(obj: Record<string, unknown>, path: string = ""): string[] {
404404
const out = [];
405405
const props = Object.keys(obj);
406-
const propObj = props.filter(
407-
(e: string): boolean => {
408-
if (obj[e] instanceof Array) {
409-
const d: unknown[] = obj[e] as unknown[];
410-
return !this._isSimplySerializable(d[0]);
411-
}
412-
return !this._isSimplySerializable(obj[e]);
406+
const propObj = props.filter((e: string): boolean => {
407+
if (obj[e] instanceof Array) {
408+
const d: unknown[] = obj[e] as unknown[];
409+
return !this._isSimplySerializable(d[0]);
413410
}
414-
);
415-
const propPrim = props.filter(
416-
(e: string): boolean => {
417-
if (obj[e] instanceof Array) {
418-
const d: unknown[] = obj[e] as unknown[];
419-
return this._isSimplySerializable(d[0]);
420-
}
421-
return this._isSimplySerializable(obj[e]);
411+
return !this._isSimplySerializable(obj[e]);
412+
});
413+
const propPrim = props.filter((e: string): boolean => {
414+
if (obj[e] instanceof Array) {
415+
const d: unknown[] = obj[e] as unknown[];
416+
return this._isSimplySerializable(d[0]);
422417
}
423-
);
418+
return this._isSimplySerializable(obj[e]);
419+
});
424420
const k = propPrim.concat(propObj);
425421
for (let i = 0; i < k.length; i++) {
426422
const prop = k[i];

flags/mod.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@ export function parse(
7979
? [options.boolean]
8080
: options.boolean;
8181

82-
booleanArgs.filter(Boolean).forEach(
83-
(key: string): void => {
84-
flags.bools[key] = true;
85-
}
86-
);
82+
booleanArgs.filter(Boolean).forEach((key: string): void => {
83+
flags.bools[key] = true;
84+
});
8785
}
8886
}
8987

@@ -114,11 +112,9 @@ export function parse(
114112
flags.strings[key] = true;
115113
const alias = get(aliases, key);
116114
if (alias) {
117-
alias.forEach(
118-
(alias: string): void => {
119-
flags.strings[alias] = true;
120-
}
121-
);
115+
alias.forEach((alias: string): void => {
116+
flags.strings[alias] = true;
117+
});
122118
}
123119
});
124120
}

fmt/sprintf_test.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -587,18 +587,16 @@ const tests: Array<[string, any, string]> = [
587587
];
588588

589589
test(function testThorough(): void {
590-
tests.forEach(
591-
(t, i): void => {
592-
// p(t)
593-
let is = S(t[0], t[1]);
594-
let should = t[2];
595-
assertEquals(
596-
is,
597-
should,
598-
`failed case[${i}] : is >${is}< should >${should}<`
599-
);
600-
}
601-
);
590+
tests.forEach((t, i): void => {
591+
// p(t)
592+
let is = S(t[0], t[1]);
593+
let should = t[2];
594+
assertEquals(
595+
is,
596+
should,
597+
`failed case[${i}] : is >${is}< should >${should}<`
598+
);
599+
});
602600
});
603601

604602
test(function testWeirdos(): void {

0 commit comments

Comments
 (0)