UNPKG

@swrve/smarttv-sdk

Version:

Swrve marketing engagement platform SDK for SmartTV OTT devices

36 lines (35 loc) 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SwrveResource = void 0; class SwrveResource { constructor(attributes) { attributes = typeof attributes === "object" ? attributes : {}; this.getAttributeAsString = (attributeId, defaultValue) => { if (attributeId in attributes) { return String(attributes[attributeId]); } return defaultValue; }; this.getAttributeAsNumber = (attributeId, defaultValue) => { if (attributeId in attributes) { const value = Number(attributes[attributeId]); if (!isNaN(value)) { return value; } } return defaultValue; }; this.getAttributeAsBoolean = (attributeId, defaultValue) => { if (attributeId in attributes) { const value = attributes[attributeId]; if (String(value).match(/^true|yes$/i)) { return true; } return false; } return defaultValue; }; this.toJSON = () => (Object.assign({}, attributes)); } } exports.SwrveResource = SwrveResource;