diff options
author | Minteck <contact@minteck.org> | 2021-12-21 16:52:28 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2021-12-21 16:52:28 +0100 |
commit | 46e43f4bde4a35785b4997b81e86cd19f046b69b (patch) | |
tree | c53c2f826f777f9d6b2d249dab556feb72a6c3a6 /src/node_modules/inversify/lib/planning/target.js | |
download | langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.gz langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.bz2 langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.zip |
Commit
Diffstat (limited to 'src/node_modules/inversify/lib/planning/target.js')
-rw-r--r-- | src/node_modules/inversify/lib/planning/target.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/node_modules/inversify/lib/planning/target.js b/src/node_modules/inversify/lib/planning/target.js new file mode 100644 index 0000000..a97d228 --- /dev/null +++ b/src/node_modules/inversify/lib/planning/target.js @@ -0,0 +1,90 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var METADATA_KEY = require("../constants/metadata_keys"); +var id_1 = require("../utils/id"); +var metadata_1 = require("./metadata"); +var queryable_string_1 = require("./queryable_string"); +var Target = (function () { + function Target(type, name, serviceIdentifier, namedOrTagged) { + this.id = id_1.id(); + this.type = type; + this.serviceIdentifier = serviceIdentifier; + this.name = new queryable_string_1.QueryableString(name || ""); + this.metadata = new Array(); + var metadataItem = null; + if (typeof namedOrTagged === "string") { + metadataItem = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, namedOrTagged); + } + else if (namedOrTagged instanceof metadata_1.Metadata) { + metadataItem = namedOrTagged; + } + if (metadataItem !== null) { + this.metadata.push(metadataItem); + } + } + Target.prototype.hasTag = function (key) { + for (var _i = 0, _a = this.metadata; _i < _a.length; _i++) { + var m = _a[_i]; + if (m.key === key) { + return true; + } + } + return false; + }; + Target.prototype.isArray = function () { + return this.hasTag(METADATA_KEY.MULTI_INJECT_TAG); + }; + Target.prototype.matchesArray = function (name) { + return this.matchesTag(METADATA_KEY.MULTI_INJECT_TAG)(name); + }; + Target.prototype.isNamed = function () { + return this.hasTag(METADATA_KEY.NAMED_TAG); + }; + Target.prototype.isTagged = function () { + return this.metadata.some(function (m) { + return (m.key !== METADATA_KEY.INJECT_TAG) && + (m.key !== METADATA_KEY.MULTI_INJECT_TAG) && + (m.key !== METADATA_KEY.NAME_TAG) && + (m.key !== METADATA_KEY.UNMANAGED_TAG) && + (m.key !== METADATA_KEY.NAMED_TAG); + }); + }; + Target.prototype.isOptional = function () { + return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true); + }; + Target.prototype.getNamedTag = function () { + if (this.isNamed()) { + return this.metadata.filter(function (m) { return m.key === METADATA_KEY.NAMED_TAG; })[0]; + } + return null; + }; + Target.prototype.getCustomTags = function () { + if (this.isTagged()) { + return this.metadata.filter(function (m) { + return (m.key !== METADATA_KEY.INJECT_TAG) && + (m.key !== METADATA_KEY.MULTI_INJECT_TAG) && + (m.key !== METADATA_KEY.NAME_TAG) && + (m.key !== METADATA_KEY.UNMANAGED_TAG) && + (m.key !== METADATA_KEY.NAMED_TAG); + }); + } + return null; + }; + Target.prototype.matchesNamedTag = function (name) { + return this.matchesTag(METADATA_KEY.NAMED_TAG)(name); + }; + Target.prototype.matchesTag = function (key) { + var _this = this; + return function (value) { + for (var _i = 0, _a = _this.metadata; _i < _a.length; _i++) { + var m = _a[_i]; + if (m.key === key && m.value === value) { + return true; + } + } + return false; + }; + }; + return Target; +}()); +exports.Target = Target; |