@up-group-ui/react-controls
Version:
Up shared react controls
69 lines • 2.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dictionary = exports.FilterProps = exports.getTestableComponentProps = void 0;
function getTestableComponentProps(props) {
var testableComponentProps = {};
if (props.dataTestId) {
testableComponentProps['data-testid'] = props.dataTestId;
}
return testableComponentProps;
}
exports.getTestableComponentProps = getTestableComponentProps;
function FilterProps(refObject, propsObject) {
var persistableO1 = {};
Object.keys(propsObject).forEach(function (key) {
if (Object.keys(refObject).indexOf(key) >= 0) {
persistableO1[key] = refObject[key];
}
});
return persistableO1;
}
exports.FilterProps = FilterProps;
var Dictionary = (function () {
function Dictionary(init) {
this._keys = new Array();
this._values = new Array();
this._dictionary = {};
for (var x = 0; x < init.length; x++) {
this._dictionary[init[x].key.toString()] = init[x].value;
this._keys.push(init[x].key);
this._values.push(init[x].value);
}
}
Dictionary.prototype.set = function (key, value) {
this._dictionary[key.toString()] = value;
this._keys.push(key);
this._values.push(value);
};
Dictionary.prototype.unset = function (key) {
var index = this._keys.indexOf(key, 0);
this._keys.splice(index, 1);
this._values.splice(index, 1);
delete this._dictionary[key.toString()];
};
Dictionary.prototype.keys = function () {
return this._keys;
};
Dictionary.prototype.values = function () {
return this._values;
};
Dictionary.prototype.containsKey = function (key) {
if (typeof this._dictionary[key.toString()] === 'undefined') {
return false;
}
return true;
};
Dictionary.prototype.toLookup = function () {
return this;
};
Dictionary.prototype.get = function (key) {
var _value = null;
if (this.containsKey(key)) {
_value = this._dictionary[key.toString()];
}
return _value;
};
return Dictionary;
}());
exports.Dictionary = Dictionary;
//# sourceMappingURL=types.js.map