bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
84 lines (62 loc) • 1.78 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _defineProperty2() {
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
_defineProperty2 = function () {
return data;
};
return data;
}
/*
* Setting up block level variable to store class state
* set's to null by default.
*/
let instance = null;
const _checkName = name => diagnosis => {
return diagnosis.name === name;
};
class DoctorRegistrar {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
constructor() {
(0, _defineProperty2().default)(this, "diagnoses", void 0);
if (!instance) {
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
instance = this;
} // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
return instance;
}
/**
* Initialize the default diagnoses
*/
static init(diagnoses = []) {
const self = new DoctorRegistrar();
self.diagnoses = diagnoses; // diagnoses.forEach(diagnosis => self.diagnoses.push(diagnosis));
}
/**
* Get the instance of the DoctorRegistrar
* @return {DoctorRegistrar} instance of the DoctorRegistrar
*
*/
static getInstance() {
if (!instance) {
DoctorRegistrar.init();
} // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
return instance;
}
/**
* Register a new diagnosis
* @param {Diagnosis} diagnosis
*/
registerDiagnosis(diagnosis) {
this.diagnoses.push(diagnosis);
}
getDiagnosisByName(name) {
return this.diagnoses.find(_checkName(name));
}
}
exports.default = DoctorRegistrar;
;