functions/node_modules/@google-cloud/firestore/build/src/util.js
/**
 * Generate a unique client-side identifier.
 *
 * Used for the creation of new documents.
 *
 * @private
 * @returns {string} A unique 20-character wide identifier.
 */
Generate a unique client-side identifier.
Used for the creation of new documents.

@private
@returns {string} A unique 20-character wide identifier.
Generate a unique client - side identifier . Used for the creation of new documents . @private @returns { string } A unique 20 - character wide identifier .
function autoId() {
    const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    let autoId = '';
    while (autoId.length < 20) {
        const bytes = crypto_1.randomBytes(40);
        bytes.forEach(b => {
            const maxValue = 62 * 4 - 1;
            if (autoId.length < 20 && b <= maxValue) {
                autoId += chars.charAt(b % 62);
            }
        });
    }
    return autoId;
}
function autoId ( ) { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ; let autoId = '' ; while ( autoId . length < 20 ) { const bytes = crypto_1 . randomBytes ( 40 ) ; bytes . forEach ( b => { const maxValue = 62 * 4 - 1 ; if ( autoId . length < 20 && b <= maxValue ) { autoId += chars . charAt ( b % 62 ) ; } } ) ; } return autoId ; }
Generate a unique client-side identifier.
Generate a unique client - side identifier .
// Length of `chars` is 62. We only take bytes between 0 and 62*4-1 // (both inclusive). The value is then evenly mapped to indices of `char` // via a modulo operation.