benchmarks/scenarios/ember.js
function chain(value, fn, label) {
    _emberMetalDebug.assert('Must call chain with a label', !!label);
    if (isStream(value)) {
      var stream = new _emberMetalStreamsStream.Stream(fn, function () {
        return label + '(' + labelFor(value) + ')';
      });
      stream.addDependency(value);
      return stream;
    } else {
      return fn();
    }
  }
function chain(value, fn, label) {
    _emberMetalDebug.assert('Must call chain with a label', !!label);
    if (isStream(value)) {
      var stream = new _emberMetalStreamsStream.Stream(fn, function () {
        return label + '(' + labelFor(value) + ')';
      });
      stream.addDependency(value);
      return stream;
    } else {
      return fn();
    }
  }
function chain ( value , fn , label ) { _emberMetalDebug . assert ( 'Must call chain with a label' , ! ! label ) ; if ( isStream ( value ) ) { var stream = new _emberMetalStreamsStream . Stream ( fn , function ( ) { return label + '(' + labelFor ( value ) + ')' ; } ) ; stream . addDependency ( value ) ; return stream ; } else { return fn ( ) ; } }
Generate a new stream by providing a source stream and a function that can
be used to transform the stream's value. In the case of a non-stream object,
returns the result of the function.

The value to transform would typically be available to the function you pass
to `chain()` via scope. For example:

```javascript
var source = ...;  // stream returning a number
or a numeric (non-stream) object
var result = chain(source, function() {
var currentValue = read(source);
return currentValue + 1;
});
```

In the example, result is a stream if source is a stream, or a number of
source was numeric.

@private
@for Ember.stream
@function chain
@param {Object|Stream} value A stream or non-stream object.
@param {Function} fn Function to be run when the stream value changes, or to
be run once in the case of a non-stream object.
@return {Object|Stream} In the case of a stream `value` parameter, a new
stream that will be updated with the return value of
the provided function `fn`. In the case of a
non-stream object, the return value of the provided
function `fn`.
Generate a new stream by providing a source stream and a function that can be used to transform the stream s value . In the case of a non - stream object returns the result of the function .