hkdf.js
function hkdf( ikm, length, { salt='', info='', hash='SHA-256' } = {} ) {
    hash = hash.toLowerCase().replace( '-', '' );

    // 0. Hash length
    const hash_len = hash_length( hash );

    // 1. extract
    const prk = hkdf_extract( hash, hash_len, ikm, salt );

    // 2. expand
    return hkdf_expand( hash, hash_len, prk, length, info );
}
function hkdf( ikm, length, { salt='', info='', hash='SHA-256' } = {} ) {
    hash = hash.toLowerCase().replace( '-', '' );

    // 0. Hash length
    const hash_len = hash_length( hash );

    // 1. extract
    const prk = hkdf_extract( hash, hash_len, ikm, salt );

    // 2. expand
    return hkdf_expand( hash, hash_len, prk, length, info );
}
HMAC-based Extract-and-Expand Key Derivation Function (HKDF)

@param {Buffer|string} ikm - Initial Keying Material
@param {integer} length - Required byte length of output
@param {Buffer|string} salt='' - Optional salt (recommended)
@param {Buffer|string} info='' - Optional context (safe to skip)
@param {string} hash='SHA-256' - HMAC hash function to use
@returns {Buffer} Raw buffer with derived key of @p length bytes