function createSegment(typeKey, value) {
    // 1-byte unsigned integer
    if (typeKey <= 20) {
        return (new Buffer([ typeKey, value ]));
    }
    // 2-byte unsigned integer
    if (typeKey <= 40) {
        let content = new Buffer(3);
        content.writeUInt8(typeKey, 0);
        content.writeUInt16BE(value, 1);
        return (content);
    }
    // 4-byte unsigned integer
    else if (typeKey <= 90) {
        let content = new Buffer(5);
        content.writeUInt8(typeKey, 0);
        content.writeUInt32BE(value, 1);
        return (content);
    }
    // string
    else if (typeKey <= 155) {
        let content = Buffer.from(value);
        let header = new Buffer([ typeKey, content.length ]);
        return (Buffer.concat([ header, content ]));
    }
    // uuid
    else if (typeKey <= 165) {
        return (Buffer.concat([ new Buffer( [ typeKey ] ), value ]));
    }
    // byte string
    else if (typeKey <= 180) {
        let content = value;
        let header = new Buffer([ typeKey, content.length ]);
        return (Buffer.concat([ header, content ]));
    }
    else {
        throw new Error("typeKey not supported");
    }
}