UNPKG

@devchristian1337/dev-icons

Version:

A library to serve development-related icons

41 lines (40 loc) 1.46 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DevIcon = void 0; var types_1 = require("./types"); var icons_json_1 = __importDefault(require("./data/icons.json")); var DevIcon_1 = require("./components/DevIcon"); Object.defineProperty(exports, "DevIcon", { enumerable: true, get: function () { return DevIcon_1.DevIcon; } }); var DevIcons = /** @class */ (function () { function DevIcons() { this.icons = icons_json_1.default; } DevIcons.prototype.getAllIcons = function () { return this.icons; }; DevIcons.prototype.getIcon = function (name) { return this.icons[name]; }; DevIcons.prototype.hasIcon = function (name) { return name in this.icons; }; DevIcons.prototype.getIconKeys = function () { return Object.keys(this.icons); }; DevIcons.prototype.addIcon = function (name, icon) { if (!this.validateSvg(icon.icon)) { throw new types_1.IconValidationError('Invalid SVG provided'); } this.icons[name] = icon; }; DevIcons.prototype.validateSvg = function (svg) { // Basic SVG validation return svg.includes('<svg') && svg.includes('</svg>'); }; return DevIcons; }()); var devIcons = new DevIcons(); exports.default = devIcons;