map(f) {
    if (typeof f !== 'function') throw new TypeError('f must be a function');

    return new this.constructor((state, ok, err) => {
      const nok = (x, _state) => {
        const _x = f(x);
        return ok(_x, {
          ..._state,
          value: _x,
          map: true,
          expected: _state.expected.and(
            new Leaf({
              content: `map ${show(x)} -> ${show(_x)}`,
              ok: true,
              path: _state.path,
            })
          ),
        });
      };
      return this.unValidate(state, nok, err);
    });
  }
/**
   * A method that returns a new validator that behaves exactly like `this`
   * validator, but if `this` validator succeeds it applies the given function
   * to the result and yields the transformed result.
   *
   * Note that the `map` function will always return a validator of the same
   * type as before the transformation, such that you may continue to chain
   * methods as normal. However, this does not work if the transformation
   * function turns the value into a different type, then you need to explicitly
   * `and` (or `then`) the result with the new type in order to continue
   * chaining methods.
   *
   * @example
   * is.string()
   *   .map(x => x.trim())           // transform from string to string
   *   .matching(/^\d+$/)
   *   .map(x => parseInt(x, 10))    // transform from string to number
   *   .then(is
   *     .number()
   *     .between(0, 100));
   *
   * @category instance
   * @method map
   * @memberOf Monadidator
   * @param {Function} f
   * @return {Monadidator}
   */
A method that returns a new validator that behaves exactly like `this`
validator, but if `this` validator succeeds it applies the given function
to the result and yields the transformed result.

Note that the `map` function will always return a validator of the same
type as before the transformation, such that you may continue to chain
methods as normal. However, this does not work if the transformation
function turns the value into a different type, then you need to explicitly
`and` (or `then`) the result with the new type in order to continue
chaining methods.




A method that returns a new validator that behaves exactly like ` this ` validator but if ` this ` validator succeeds it applies the given function to the result and yields the transformed result . Note that the ` map ` function will always return a validator of the same type as before the transformation such that you may continue to chain methods as normal . However this does not work if the transformation function turns the value into a different type then you need to explicitly ` and ` ( or ` then ` ) the result with the new type in order to continue chaining methods .
map(f) {
    if (typeof f !== 'function') throw new TypeError('f must be a function');
    return new this.constructor((state, ok, err) => {
      const nok = (x, _state) => {
        const _x = f(x);
        return ok(_x, {
          ..._state,
          value: _x,
          map: true,
          expected: _state.expected.and(
            new Leaf({
              content: `map ${show(x)} -> ${show(_x)}`,
              ok: true,
              path: _state.path,
            })
          ),
        });
      };
      return this.unValidate(state, nok, err);
    });
  }
map ( f ) { if ( typeof f !== 'function' ) throw new TypeError ( 'f must be a function' ) ; return new this . constructor ( ( state , ok , err ) => { const nok = ( x , _state ) => { const _x = f ( x ) ; return ok ( _x , { ... _state , value : _x , map : true , expected : _state . expected . and ( new Leaf ( { content : ` ${ show ( x ) } ${ show ( _x ) } ` , ok : true , path : _state . path , } ) ) , } ) ; } ; return this . unValidate ( state , nok , err ) ; } ) ; }
A method that returns a new validator that behaves exactly like `this`
 validator, but if `this` validator succeeds it applies the given function
 to the result and yields the transformed result.
A method that returns a new validator that behaves exactly like ` this ` validator but if ` this ` validator succeeds it applies the given function to the result and yields the transformed result .