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

Unified Diff: packages/polymer/lib/deserialize.dart

Issue 2312183003: Removed Polymer from Observatory deps (Closed)
Patch Set: Created 4 years, 3 months 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 | « packages/polymer/lib/deploy.dart ('k') | packages/polymer/lib/html_element_names.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/polymer/lib/deserialize.dart
diff --git a/packages/polymer/lib/deserialize.dart b/packages/polymer/lib/deserialize.dart
deleted file mode 100644
index 6d07acaa09aaa0298846c1fcaf32b0be2ff99704..0000000000000000000000000000000000000000
--- a/packages/polymer/lib/deserialize.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library polymer.deserialize;
-
-import 'dart:convert' show JSON;
-
-final _typeHandlers = {
- String: (x, _) => x,
- Null: (x, _) => x,
- DateTime: (x, def) {
- // TODO(jmesserly): shouldn't need to try-catch here
- // See: https://code.google.com/p/dart/issues/detail?id=1878
- try {
- return DateTime.parse(x);
- } catch (e) {
- return def;
- }
- },
- bool: (x, _) => x != 'false',
- int: (x, def) => int.parse(x, onError: (_) => def),
- double: (x, def) => double.parse(x, (_) => def),
-};
-
-/// Convert representation of [value] based on [type] and [currentValue].
-Object deserializeValue(String value, Object currentValue, Type type) {
- var handler = _typeHandlers[type];
- if (handler != null) return handler(value, currentValue);
-
- try {
- // If the string is an object, we can parse is with the JSON library.
- // include convenience replace for single-quotes. If the author omits
- // quotes altogether, parse will fail.
- return JSON.decode(value.replaceAll("'", '"'));
-
- // TODO(jmesserly): deserialized JSON is not assignable to most objects in
- // Dart. We should attempt to convert it appropriately.
- } catch (e) {
- // The object isn't valid JSON, return the raw value
- return value;
- }
-}
« no previous file with comments | « packages/polymer/lib/deploy.dart ('k') | packages/polymer/lib/html_element_names.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698