/*
 * @license MIT License
 *
 * Copyright (c) 2015 Tetsuharu OHZEKI <saneyuki.snyk@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

'use strict';

/**
 *  @deprecated
 *  @constructor
 *  @template   T
 *
 *  @param  {T=}   val (optional)
 *      * if `value` is `T` (not `undefined`), this should be `Some<T>`.
 *      * if `value` is `undefined` or not passed, this should be `None`.
 */
var OptionType = function OptionType(val) {
    /* eslint-disable camelcase */
    /** @type   {boolean}   */
    this.is_some = (val !== undefined);
    /* eslint-enable */

    /** @type   {T}   */
    this.value = val;

    Object.seal(this);
};
OptionType.prototype = Object.seal({

    /**
     *  @deprecated
     *  Return whether this is `Some<T>` or not.
     *
     *  @template   T
     *  @return {boolean}
     */
    get isSome() {
        return this.is_some;
    },

    /**
     *  @deprecated
     *  Returns the inner `T` of a `Some<T>`.
     *
     *  @template   T
     *
     *  @return {T}
     *  @throws {Error}
     *      Throws if the self value equals `None`.
     */
    unwrap: function OptionTypeUnwrap() {
        if (!this.is_some) {
            throw new Error('called `unwrap()` on a `None` value');
        }

        return this.value;
    },

    /**
     *  @deprecated
     *  Maps an `OptionType<T>` to `OptionType<U>` by applying a function to a contained value.
     *
     *  @template   T, U
     *
     *  @param  {function(T):U}    fn
     *      XXX: If `U` is `undefined`, this method will return `None<U>` in such case.
     *           Because this library treats `undefined` as `None`.
     *  @return {OptionType<U>}
     */
    map: function OptionTypeMap(fn) {
        if (!this.is_some) {
            // cheat to escape from a needless allocation.
            return this;
        }

        var value = fn(this.value);
        var option = new OptionType(value);
        return option;
    },

    /**
     *  @deprecated
     *  Returns `None` if the self is `None`,
     *  otherwise calls `fn` with the wrapped value and returns the result.
     *
     *  @template   T, U
     *
     *  @param  {function(T): OptionType<U>}    fn
     *  @return {OptionType<U>}
     */
    flatMap: function OptionTypeFlatMap(fn) {
        if (!this.is_some) {
            // cheat to escape from a needless allocation.
            return this;
        }

        var mapped = fn(this.value);
        if ( !(mapped instanceof OptionType) ) {
            throw new Error('OptionType.flatMap()\' param `fn` should return `OptionType`.');
        }

        return mapped;
    },

    /**
     *  @deprecated
     *  The alias of `OptionType.flatMap()`.
     *
     *  @template   T, U
     *
     *  @param  {function(T): OptionType<U>}    fn
     *  @return {OptionType<U>}
     */
    andThen: function OptionTypeAndThen(fn) {
        return this.flatMap(fn);
    },

    /**
     *  @deprecated
     *  Finalize the self.
     *  After this is called, the object's behavior is not defined.
     *
     *  @return {void}
     */
    drop: function OptionTypeDrop() {
        /* eslint-disable camelcase */
        this.is_some = false;
        /* eslint-enable */

        this.value = null;
        Object.freeze(this);
    },

});

module.exports = OptionType;

@@ -1183,16 +1183,241 @@
 rict';%0A%0A
+var warnDeprecatedAPI = function (name) %7B%0A    if (process.env.NODE_ENV !== 'production' &&%0A        !!console && (typeof console.warn === 'function')) %7B%0A        console.warn(name + ' is deperecated. Use Option%3CT%3E');%0A    %7D%0A%7D;%0A%0A
 /**%0A *  
@@ -1897,16 +1897,53 @@
 (this);%0A
+    warnDeprecatedAPI('OptionType');%0A
 %7D;%0AOptio
@@ -2130,24 +2130,72 @@
  isSome() %7B%0A
+        warnDeprecatedAPI('OptionType.isSome');%0A
         retu
@@ -2471,24 +2471,74 @@
 eUnwrap() %7B%0A
+        warnDeprecatedAPI('OptionType.unwrap()');%0A
         if (
@@ -3095,32 +3095,79 @@
 onTypeMap(fn) %7B%0A
+        warnDeprecatedAPI('OptionType.map()');%0A
         if (!thi
@@ -3703,32 +3703,83 @@
 peFlatMap(fn) %7B%0A
+        warnDeprecatedAPI('OptionType.flatMap()');%0A
         if (!thi
@@ -4353,24 +4353,75 @@
 dThen(fn) %7B%0A
+        warnDeprecatedAPI('OptionType.andThen()');%0A
         retu
@@ -4606,24 +4606,24 @@
 id%7D%0A     */%0A
-
     drop: fu
@@ -4644,24 +4644,72 @@
 ypeDrop() %7B%0A
+        warnDeprecatedAPI('OptionType.drop()');%0A
         /* e

Add warning if a deprecated api is called on non-production env.