<commit_before>// You can map and chain promises using the map() and futureMap() functions:

import CBGPromise

class Client {
    func getIntegerValue() -> Future<Int> {
        let promise = Promise<Int>()

        otherAsyncCall {
            promise.resolve(42)
        }

        return promise.future
    }

    func getArrayValue(int: Int) -> Future<[String]> {
        let promise = Promise<[String]>()

        someAsyncCall(int) {
            promise.resolve(["Test 1", "Test 2"])
        }

        return promise.future
    }
}

class MappingExample {
    func main() {
        let client = Client()

        let integerFuture = client.getIntegerValue()

        let arrayFuture = integerFuture.futureMap { int -> Future<[String]> in
            return client.getArrayValue(int)
        }

        let stringFuture = arrayFuture.map { arr -> String? in
            return arr.first
        }

        stringFuture.then { value in
            print(value)
        }
    }
}<commit_msg>Updated Mapping example<commit_after>// You can map and chain promises using the map() and futureMap() functions:

import CBGPromise

class Client {
    func getIntegerValue() -> Future<Int> {
        let promise = Promise<Int>()

        otherAsyncCall {
            promise.resolve(42)
        }

        return promise.future
    }

    func getArrayValue(int: Int) -> Future<[String]> {
        let promise = Promise<[String]>()

        someAsyncCall(int) {
            promise.resolve(["Test 1", "Test 2"])
        }

        return promise.future
    }
}

class MappingExample {
    func main() {
        let client = Client()

        let integerFuture = client.getIntegerValue()

        let arrayFuture = integerFuture.map { int -> Future<[String]> in
            return client.getArrayValue(int)
        }

        let stringFuture = arrayFuture.map { arr -> String? in
            return arr.first
        }

        stringFuture.then { value in
            print(value)
        }
    }
}
{'fraction_non_alphanumeric': 0.10320641282565131, 'fraction_numerical': 0.004008016032064128, 'mean_word_length': 1.923865300146413, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6574486', 'n_tokens_mistral': 559, 'n_tokens_neox': 535, 'n_words': 144}