Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1294)

Unified Diff: lib/runtime/dart/convert.js

Issue 1484263002: Use destructuring assignments for named parameters (#180) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | lib/runtime/dart/core.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart/convert.js
diff --git a/lib/runtime/dart/convert.js b/lib/runtime/dart/convert.js
index a535d9b91e0820c432c80e2331e689125d1d299a..e17869ed46d8f315561fdbe3726f7d1adbe865c4 100644
--- a/lib/runtime/dart/convert.js
+++ b/lib/runtime/dart/convert.js
@@ -65,16 +65,14 @@ dart_library.library('dart/convert', null, /* Imports */[
});
const _allowInvalid = Symbol('_allowInvalid');
class AsciiCodec extends Encoding {
- AsciiCodec(opts) {
- let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : false;
+ AsciiCodec({allowInvalid = false} = {}) {
this[_allowInvalid] = allowInvalid;
super.Encoding();
}
get name() {
return "us-ascii";
}
- decode(bytes, opts) {
- let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : null;
+ decode(bytes, {allowInvalid = null} = {}) {
if (allowInvalid == null)
allowInvalid = this[_allowInvalid];
if (dart.notNull(allowInvalid)) {
@@ -278,8 +276,7 @@ dart_library.library('dart/convert', null, /* Imports */[
})
});
class AsciiDecoder extends _UnicodeSubsetDecoder {
- AsciiDecoder(opts) {
- let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : false;
+ AsciiDecoder({allowInvalid = false} = {}) {
super._UnicodeSubsetDecoder(allowInvalid, _ASCII_MASK);
}
startChunkedConversion(sink) {
@@ -781,8 +778,7 @@ dart_library.library('dart/convert', null, /* Imports */[
})
});
class JsonUnsupportedObjectError extends core.Error {
- JsonUnsupportedObjectError(unsupportedObject, opts) {
- let cause = opts && 'cause' in opts ? opts.cause : null;
+ JsonUnsupportedObjectError(unsupportedObject, {cause = null} = {}) {
this.unsupportedObject = unsupportedObject;
this.cause = cause;
super.Error();
@@ -812,9 +808,7 @@ dart_library.library('dart/convert', null, /* Imports */[
const _reviver = Symbol('_reviver');
const _toEncodable$ = Symbol('_toEncodable');
class JsonCodec extends Codec$(core.Object, core.String) {
- JsonCodec(opts) {
- let reviver = opts && 'reviver' in opts ? opts.reviver : null;
- let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null;
+ JsonCodec({reviver = null, toEncodable = null} = {}) {
this[_reviver] = reviver;
this[_toEncodable$] = toEncodable;
super.Codec();
@@ -822,16 +816,14 @@ dart_library.library('dart/convert', null, /* Imports */[
withReviver(reviver) {
this.JsonCodec({reviver: reviver});
}
- decode(source, opts) {
- let reviver = opts && 'reviver' in opts ? opts.reviver : null;
+ decode(source, {reviver = null} = {}) {
if (reviver == null)
reviver = this[_reviver];
if (reviver == null)
return this.decoder.convert(source);
return new JsonDecoder(reviver).convert(source);
}
- encode(value, opts) {
- let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null;
+ encode(value, {toEncodable = null} = {}) {
if (toEncodable == null)
toEncodable = this[_toEncodable$];
if (toEncodable == null)
@@ -1560,16 +1552,14 @@ dart_library.library('dart/convert', null, /* Imports */[
const __CastType2 = dart.typedef('__CastType2', () => dart.functionType(dart.dynamic, [dart.dynamic]));
const __CastType4 = dart.typedef('__CastType4', () => dart.functionType(dart.dynamic, [core.Object]));
class Latin1Codec extends Encoding {
- Latin1Codec(opts) {
- let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : false;
+ Latin1Codec({allowInvalid = false} = {}) {
this[_allowInvalid] = allowInvalid;
super.Encoding();
}
get name() {
return "iso-8859-1";
}
- decode(bytes, opts) {
- let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : null;
+ decode(bytes, {allowInvalid = null} = {}) {
if (allowInvalid == null)
allowInvalid = this[_allowInvalid];
if (dart.notNull(allowInvalid)) {
@@ -1600,8 +1590,7 @@ dart_library.library('dart/convert', null, /* Imports */[
constructors: () => ({Latin1Encoder: [Latin1Encoder, []]})
});
class Latin1Decoder extends _UnicodeSubsetDecoder {
- Latin1Decoder(opts) {
- let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : false;
+ Latin1Decoder({allowInvalid = false} = {}) {
super._UnicodeSubsetDecoder(allowInvalid, _LATIN1_MASK);
}
startChunkedConversion(sink) {
@@ -2069,16 +2058,14 @@ dart_library.library('dart/convert', null, /* Imports */[
const UNICODE_BOM_CHARACTER_RUNE = 65279;
const _allowMalformed = Symbol('_allowMalformed');
class Utf8Codec extends Encoding {
- Utf8Codec(opts) {
- let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalformed : false;
+ Utf8Codec({allowMalformed = false} = {}) {
this[_allowMalformed] = allowMalformed;
super.Encoding();
}
get name() {
return "utf-8";
}
- decode(codeUnits, opts) {
- let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalformed : null;
+ decode(codeUnits, {allowMalformed = null} = {}) {
if (allowMalformed == null)
allowMalformed = this[_allowMalformed];
return new Utf8Decoder({allowMalformed: allowMalformed}).convert(codeUnits);
@@ -2334,8 +2321,7 @@ dart_library.library('dart/convert', null, /* Imports */[
})
});
class Utf8Decoder extends Converter$(core.List$(core.int), core.String) {
- Utf8Decoder(opts) {
- let allowMalformed = opts && 'allowMalformed' in opts ? opts.allowMalformed : false;
+ Utf8Decoder({allowMalformed = false} = {}) {
this[_allowMalformed] = allowMalformed;
super.Converter();
}
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | lib/runtime/dart/core.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698