flave
Version:
A Razor like View transpiler for JavaScript
45 lines (44 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var Configuration = /** @class */ (function () {
function Configuration(defaults, layers) {
this.layers = [];
if (layers)
this.layers = layers;
this.layer(defaults);
}
Configuration.prototype.layer = function (config) {
return !!(this.layers.unshift(config || {}));
};
Configuration.prototype.unlayer = function () {
return !!(this.layers.shift());
};
Configuration.prototype.relayer = function () {
return !!(this.layers[0] = {});
};
Configuration.prototype.clone = function (config) {
return new Configuration(config, this.layers);
};
Configuration.prototype.global = function (property, value) {
if (typeof value != 'undefined')
this.layers[this.layers.length - 1][property] = value;
else
return this.layers[this.layers.length - 1][property];
};
Configuration.prototype.override = function (property, value) {
if (typeof value != 'undefined')
this.layers.map(function (layer) { return layer[property] = value; });
else
this.layers.map(function (layer) { return layer[property]; });
};
Configuration.prototype.value = function (property, value) {
if (typeof value != 'undefined')
this.layers[0][property] = value;
else
for (var i = 0; i < this.layers.length; i++)
if (this.layers[i].hasOwnProperty(property))
return this.layers[i][property];
};
return Configuration;
}());
exports.Configuration = Configuration;