UnicodeExtensionValue = function (extension, key) {
        const size = extension.length;

        // search for the key-value pair
        let pos = _.stringIndexOf(extension, `-${key}-`);
        if (pos !== -1) {
            const start = pos + 4;
            let end = start;
            let k = start;
            let done = false;
            while (!done) {
                const e = _.stringIndexOf(extension, "-", k);
                const len = e === -1 ? size - k : e - k;
                if (len === 2) {
                    done = true;
                } else if (e === -1) {
                    end = size;
                    done = true;
                } else {
                    end = e;
                    k = e + 1;
                }
            }

            return _.substring(extension, start, end);
        }

        // search for the key with no associated value
        pos = _.stringIndexOf(extension, `-${key}`);
        if (pos !== -1 && pos + 3 === size) {
            return "";
        } else {
            return undefined;
        }
    }
Determine a value for a given key in the given extension string

ECMA-402: #sec-unicodeextensionvalue

@param {String} extension the full unicode extension, such as "-u-co-phonebk-kf-true"
@param {String} key the specific key we are looking for in the extension, such as "co"