function map(arr, iter) {
    if (Immutable.Map.isMap(arr)) {
        var type = 'Map';
        if (Immutable.OrderedMap.isOrderedMap(arr)) {
            type = 'OrderedMap';
        }

        return mapAsList(arr, function(value, key) {
            return Q(iter(value, key))
            .then(function(result) {
                return [key, result];
            });
        })
        .then(function(result) {
            return Immutable[type](result);
        });
    } else {
        return mapAsList(arr, iter)
        .then(function(result) {
            return Immutable.List(result);
        });
    }
}
function map(arr, iter) {
    if (Immutable.Map.isMap(arr)) {
        var type = 'Map';
        if (Immutable.OrderedMap.isOrderedMap(arr)) {
            type = 'OrderedMap';
        }

        return mapAsList(arr, function(value, key) {
            return Q(iter(value, key))
            .then(function(result) {
                return [key, result];
            });
        })
        .then(function(result) {
            return Immutable[type](result);
        });
    } else {
        return mapAsList(arr, iter)
        .then(function(result) {
            return Immutable.List(result);
        });
    }
}
function map ( arr , iter ) { if ( Immutable . Map . isMap ( arr ) ) { var type = 'Map' ; if ( Immutable . OrderedMap . isOrderedMap ( arr ) ) { type = 'OrderedMap' ; } return mapAsList ( arr , function ( value , key ) { return Q ( iter ( value , key ) ) . then ( function ( result ) { return [ key , result ] ; } ) ; } ) . then ( function ( result ) { return Immutable [ type ] ( result ) ; } ) ; } else { return mapAsList ( arr , iter ) . then ( function ( result ) { return Immutable . List ( result ) ; } ) ; } }
Map an array or map

@param {Array|List|Map|OrderedMap} arr
@param {Function(element, key)}
@return {Promise<List|Map|OrderedMap>}
Map an array or map
mapAsList - Map - Iterator - Iterator - Function