Index: lib/runtime/_operations.js |
diff --git a/lib/runtime/_operations.js b/lib/runtime/_operations.js |
index 1dfae7521d77167646681dad5585e86007e3ba3b..c018641c47b2daa9051e886bc7b2d646f0395e90 100644 |
--- a/lib/runtime/_operations.js |
+++ b/lib/runtime/_operations.js |
@@ -62,6 +62,7 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[ |
// TODO(vsm): Implement NSM and type checks. |
// See: https://github.com/dart-lang/dev_compiler/issues/170 |
obj[field] = value; |
+ return value; |
} |
exports.dput = dput; |
@@ -168,7 +169,8 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[ |
exports.dindex = dindex; |
function dsetindex(obj, index, value) { |
- return callMethod(obj, 'set', [index, value], '[]='); |
+ callMethod(obj, 'set', [index, value], '[]='); |
+ return value; |
} |
exports.dsetindex = dsetindex; |
@@ -318,6 +320,23 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[ |
} |
exports.stackTrace = stackTrace; |
+ /** |
+ * Implements a sequence of .? operations. |
+ * |
+ * Will call each successive callback, unless one returns null, which stops |
+ * the sequence. |
+ */ |
+ function nullSafe(obj /*, ...callbacks*/) { |
+ let callbacks = slice.call(arguments, 1); |
+ if (obj == null) return obj; |
+ for (const callback of callbacks) { |
+ obj = callback(obj); |
+ if (obj == null) break; |
+ } |
+ return obj; |
+ } |
+ exports.nullSafe = nullSafe; |
+ |
let _value = Symbol('_value'); |
/** |
* Looks up a sequence of [keys] in [map], recursively, and |