react-shields.io
Version:
Shields.io for react component, Quality metadata badges for open source projects.
83 lines (66 loc) • 2.96 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
import Base from '../common/Base';
/**
* Npm Size
*
* `/bundlephobia/:format/:packageName`
* npm bundle size: npm bundle size badge
*
* `/bundlephobia/:format/:scope/:packageName`
* npm bundle size (scoped): npm bundle size (scoped) badge
*
* `/bundlephobia/:format/:packageName/:version`
* npm bundle size (version): npm bundle size (version) badge
*
* `/bundlephobia/:format/:scope/:packageName/:version`
* npm bundle size (scoped version): npm bundle size (scoped version) badge
*
*/
var Size = /*#__PURE__*/function (_Base) {
_inherits(Size, _Base);
var _super = _createSuper(Size);
function Size(props) {
var _this;
_classCallCheck(this, Size);
_this = _super.call(this, props, {
format: 'min'
}, {
platform: 'npm'
});
_this.getUrl = function () {
var _this$state = _this.state,
base = _this$state.base,
type = _this$state.type,
platform = _this$state.platform,
format = _this$state.format,
packageName = _this$state.packageName,
scope = _this$state.scope,
version = _this$state.version;
if (platform !== 'npm') return '';
var baseData = [base, 'bundlephobia'];
var url = '';
if (packageName && format) {
url = [].concat(baseData, [format, packageName]).join('/');
}
if (packageName && format && scope) {
url = [].concat(baseData, [format, scope, packageName]).join('/');
}
if (packageName && format && scope && version) {
url = [].concat(baseData, [format, scope, packageName, version]).join('/');
}
if (packageName && format && version) {
url = [].concat(baseData, [format, packageName, version]).join('/');
}
return url;
};
return _this;
}
return Size;
}(Base);
export { Size as default };
//# sourceMappingURL=Size.js.map