diff options
author | Axetroy <axetroy.dev@gmail.com> | 2019-09-12 11:31:23 +0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-09-11 23:31:23 -0400 |
commit | 878a9a29e77bcaedd4242618ccf57d1be7dfd7d8 (patch) | |
tree | 53fd448fa9cf0295c2498f4f7970f1a720435dcc /encoding | |
parent | 08087e921ede553d1eaeb682d264c3d4c217a3cd (diff) |
bump prettier to 1.18.2 (denoland/deno_std#592)
Original: https://github.com/denoland/deno_std/commit/06958a4ada960665a48ac34f919423e0d8d16951
Diffstat (limited to 'encoding')
-rw-r--r-- | encoding/csv.ts | 66 | ||||
-rw-r--r-- | encoding/toml.ts | 28 |
2 files changed, 43 insertions, 51 deletions
diff --git a/encoding/csv.ts b/encoding/csv.ts index afd011f51..ccbfcba9e 100644 --- a/encoding/csv.ts +++ b/encoding/csv.ts @@ -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'); } @@ -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)); diff --git a/encoding/toml.ts b/encoding/toml.ts index 8a53a8300..228c1180b 100644 --- a/encoding/toml.ts +++ b/encoding/toml.ts @@ -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]; |