     }
   }
 }
+
+/// Helper function to wrap the results of `ObjCPromise.when` with the safe `When` enum.
+public func asWhen<Value>(_ value: AnyObject) -> When<Value> {
+  switch value {
+  case let error as NSError:
+    return .error(error)
+  case let value:
+    guard let value = Promise<Value>.asValue(value) else { preconditionFailure() }
+    return .value(value)
+  }
+}
+
+// MARK: - Equatable
 
 /// Equality operators for `When`.
 #if !swift(>=4.1)

  }
}

/// Helper functions that facilitates conversion of `Promise.when` results to the results normally
/// expected from `ObjCPromise.when`.
///

}

#endif  // !swift(>=4.1)
