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

Unified Diff: third_party/pkg/angular/lib/utils.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
Index: third_party/pkg/angular/lib/utils.dart
diff --git a/third_party/pkg/angular/lib/utils.dart b/third_party/pkg/angular/lib/utils.dart
index 9f0324747d4162ac9dca3ce8d372cfe0d5f72e26..1a476b7373de2f804f18484809942ceb77fde4a4 100644
--- a/third_party/pkg/angular/lib/utils.dart
+++ b/third_party/pkg/angular/lib/utils.dart
@@ -1,6 +1,6 @@
library angular.util;
-toBool(x) {
+bool toBool(x) {
if (x is bool) return x;
if (x is num) return x != 0;
return false;
@@ -44,6 +44,12 @@ relaxFnArgs1(Function fn) {
if (fn is FnWith0Args) return (_1) => fn();
}
+relaxFnArgs2(Function fn) {
+ if (fn is FnWith2Args) return fn;
+ if (fn is FnWith1Args) return (_1, _2) => fn(_1);
+ if (fn is FnWith0Args) return (_1, _2) => fn();
+}
+
relaxFnArgs3(Function fn) {
if (fn is FnWith3Args) return fn;
if (fn is FnWith2Args) return (_1, _2, _3) => fn(_1, null);
@@ -71,18 +77,44 @@ relaxFnArgs(Function fn) {
}
}
-camelcase(String s) {
- var part = s.split('-').map((s) => s.toLowerCase());
- if (part.length <= 1) {
- return part.join();
- }
- return part.first + part.skip(1).map(capitalize).join();
-}
-
capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1);
-var SNAKE_CASE_REGEXP = new RegExp("[A-Z]");
-snakecase(String name, [separator = '-']) =>
- name.replaceAllMapped(SNAKE_CASE_REGEXP, (Match match) =>
- (match.start != 0 ? separator : '') + match.group(0).toLowerCase());
+/// Returns whether or not the given identifier is a reserved word in Dart.
+bool isReservedWord(String identifier) => RESERVED_WORDS.contains(identifier);
+
+final Set<String> RESERVED_WORDS = new Set<String>.from(const [
+ "assert",
+ "break",
+ "case",
+ "catch",
+ "class",
+ "const",
+ "continue",
+ "default",
+ "do",
+ "else",
+ "enum",
+ "extends",
+ "false",
+ "final",
+ "finally",
+ "for",
+ "if",
+ "in",
+ "is",
+ "new",
+ "null",
+ "rethrow",
+ "return",
+ "super",
+ "switch",
+ "this",
+ "throw",
+ "true",
+ "try",
+ "var",
+ "void",
+ "while",
+ "with"
+]);

Powered by Google App Engine
This is Rietveld 408576698