JSFiddle - React, Tailwind, and code Playground

by Tenderfeel

JavaScript

var user = function(datas){
    
    var that = {};
    that.status = {};
        
    /** @type {string} アメーバID */
    that.status['amebaId'] = datas['amebaId'];
    
    /** @type {string} ニックネーム */
    that.status['nickName'] = datas['nickName'];

    that.get = function(key){
              if(that.status[key]){
                    return that.status[key] || '';
              }
              return '';
         };
    that.set = function(key, val){
              if(that.status[key]){
                    that.status[key] = val;
                    return true;
              }
              
              return false;
         };
     that.has = function(key){
             return !!this.get(key);
         };
     that.add = function(key, val){
             that.status[key] = val;
         };
    return that;
};

/** */
var profile = function(datas){
    
    var that = user(datas);
    var status = that.status || {};
    
    /** @type {string} 誕生日 */
    status['birthday'] = datas['birthday'];
    
    /** @type {string} 血液型 */
    status['broodType'] = datas['bloodtype'];
    
    /** @type {string} 紹介文 */
    status['description'] = datas['description'];
    
    /** @type {string} 性別 */
    status['gender'] = datas['gender'];
    
    /** @type {string} 所在地 */
    status['livingRegion'] = datas['libingRegion'];
    
    /** @type {number} アメの数 */
    status['amepoint'] = Number(datas['amepoint']);
    
    /** @type {number} グッピグ数 */
    status['goodCount'] = Number(datas['goodCount']);
    
    /** @type {number} ピグとも数 */
    status['friendCount'] = Number(datas['friendCount']);
    
    return that;
};

var datas = {
        "amebaId":"kariblo-05005",
        "birthday":"1939年2月11日 16時頃",
        "bloodtype":"A型",
        "description":"プロフィール紹介文",
        "gender":"男",
        "livingRegion":"非公開",
        "nickName":"センテキテストその他"
};

var datas2 = {
        "amebaId":"kariblo-01234",
        "nickName":"センテキテストその他",
        "birthday":"2010年2月11日...