src/basis.js
function(fn){
      var token = new Token();
      var setter = function(value){
        this.set(fn.call(this, value));
      };

      if (typeof fn != 'function')
        fn = getter(fn);

      setter.call(token, this.get());

      this.attach(setter, token, token.destroy);
      token.attach($undef, this, function(){
        this.detach(setter, token);
      });

      /** @cut */ devInfoResolver.setInfo(token, 'sourceInfo', {
      /** @cut */   type: 'Token#as',
      /** @cut */   source: this,
      /** @cut */   transform: fn
      /** @cut */ });

      return token;
    }
function(fn){
      var token = new Token();
      var setter = function(value){
        this.set(fn.call(this, value));
      };

      if (typeof fn != 'function')
        fn = getter(fn);

      setter.call(token, this.get());

      this.attach(setter, token, token.destroy);
      token.attach($undef, this, function(){
        this.detach(setter, token);
      });

      /** @cut */ devInfoResolver.setInfo(token, 'sourceInfo', {
      /** @cut */   type: 'Token#as',
      /** @cut */   source: this,
      /** @cut */   transform: fn
      /** @cut */ });

      return token;
    }
function ( fn ) { var token = new Token ( ) ; var setter = function ( value ) { this . set ( fn . call ( this , value ) ) ; } ; if ( typeof fn != 'function' ) fn = getter ( fn ) ; setter . call ( token , this . get ( ) ) ; this . attach ( setter , token , token . destroy ) ; token . attach ( $undef , this , function ( ) { this . detach ( setter , token ) ; } ) ; /** @cut */ devInfoResolver . setInfo ( token , 'sourceInfo' , { /** @cut */ type : 'Token#as' , /** @cut */ source : this , /** @cut */ transform : fn /** @cut */ } ) ; return token ; }
Creates new token from token that contains modified through fn value.
@param {function(value):value} fn
@return {*}
Creates new token from token that contains modified through fn value .