function transformContactsConcurrent({
        contacts,
        transform,
        progressSpeed = 100,
        cancellationToken = createCancellationToken(),
        progressBar = false
    }) {
        const privateKeys = keysModel.getPrivateKeys(MAIN_KEY);
        const publicKeys = keysModel.getPublicKeys(MAIN_KEY);
        const total = contacts.length;
        const reporter = progressBar ? contactProgressReporter(0, progressSpeed, total) : () => {};

        /**
         * Call the given transform function on one of the contacts that is passed in,
         * trigger the progressBar updates for our modal and check if we cancelled the request in the modal already
         * @param data The contact data
         * @returns {*}
         */
        const handler = (data) => {
            return transform(data, publicKeys, privateKeys).then((data) => {
                cancellationToken.check();
                reporter();

                return data;
            });
        };

        const concurrency = getMaxConcurrency();
        const chunkedContacts = chunk(contacts, Math.ceil(CONTACTS_LIMIT_ENCRYPTION / concurrency));

        const doubleChunkedContacts = chunk(chunkedContacts, Math.ceil(chunkedContacts.length / concurrency));
        const handleChunkedContacts = chunkHandler(handler);

        return Promise.all(doubleChunkedContacts.map(handleChunkedContacts)).then((chunks) =>
            chunks.reduce((acc, val) => acc.concat(val), [])
        );
    }
/**
     * Transform each contact by applying transform to each of the contacts passed in. This works similar to map,
     * but instead it is optimized to enhance the speed for multiple cores.
     * @param {Array} contacts
     * @param {Callback} transform
     * @param {Integer} progressSpeed
     * @param {Object} cancellationToken
     * @param {Boolean} progressBar
     * @returns {*}
     */
Transform each contact by applying transform to each of the contacts passed in. This works similar to map,
but instead it is optimized to enhance the speed for multiple cores.
Transform each contact by applying transform to each of the contacts passed in . This works similar to map but instead it is optimized to enhance the speed for multiple cores .
function transformContactsConcurrent({
        contacts,
        transform,
        progressSpeed = 100,
        cancellationToken = createCancellationToken(),
        progressBar = false
    }) {
        const privateKeys = keysModel.getPrivateKeys(MAIN_KEY);
        const publicKeys = keysModel.getPublicKeys(MAIN_KEY);
        const total = contacts.length;
        const reporter = progressBar ? contactProgressReporter(0, progressSpeed, total) : () => {};
        const handler = (data) => {
            return transform(data, publicKeys, privateKeys).then((data) => {
                cancellationToken.check();
                reporter();
                return data;
            });
        };
        const concurrency = getMaxConcurrency();
        const chunkedContacts = chunk(contacts, Math.ceil(CONTACTS_LIMIT_ENCRYPTION / concurrency));
        const doubleChunkedContacts = chunk(chunkedContacts, Math.ceil(chunkedContacts.length / concurrency));
        const handleChunkedContacts = chunkHandler(handler);
        return Promise.all(doubleChunkedContacts.map(handleChunkedContacts)).then((chunks) =>
            chunks.reduce((acc, val) => acc.concat(val), [])
        );
    }
function transformContactsConcurrent ( { contacts , transform , progressSpeed = 100 , cancellationToken = createCancellationToken ( ) , progressBar = false } ) { const privateKeys = keysModel . getPrivateKeys ( MAIN_KEY ) ; const publicKeys = keysModel . getPublicKeys ( MAIN_KEY ) ; const total = contacts . length ; const reporter = progressBar ? contactProgressReporter ( 0 , progressSpeed , total ) : ( ) => { } ; const handler = ( data ) => { return transform ( data , publicKeys , privateKeys ) . then ( ( data ) => { cancellationToken . check ( ) ; reporter ( ) ; return data ; } ) ; } ; const concurrency = getMaxConcurrency ( ) ; const chunkedContacts = chunk ( contacts , Math . ceil ( CONTACTS_LIMIT_ENCRYPTION / concurrency ) ) ; const doubleChunkedContacts = chunk ( chunkedContacts , Math . ceil ( chunkedContacts . length / concurrency ) ) ; const handleChunkedContacts = chunkHandler ( handler ) ; return Promise . all ( doubleChunkedContacts . map ( handleChunkedContacts ) ) . then ( ( chunks ) => chunks . reduce ( ( acc , val ) => acc . concat ( val ) , [ ] ) ) ; }
Transform each contact by applying transform to each of the contacts passed in.
Transform each contact by applying transform to each of the contacts passed in .
/**
         * Call the given transform function on one of the contacts that is passed in,
         * trigger the progressBar updates for our modal and check if we cancelled the request in the modal already
         * @param data The contact data
         * @returns {*}
         */