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/es/syntax | |
download | langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.gz langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.bz2 langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.zip |
Commit
Diffstat (limited to 'src/node_modules/inversify/es/syntax')
7 files changed, 364 insertions, 0 deletions
diff --git a/src/node_modules/inversify/es/syntax/binding_in_syntax.js b/src/node_modules/inversify/es/syntax/binding_in_syntax.js new file mode 100644 index 0000000..bbd4bad --- /dev/null +++ b/src/node_modules/inversify/es/syntax/binding_in_syntax.js @@ -0,0 +1,21 @@ +import { BindingScopeEnum } from "../constants/literal_types"; +import { BindingWhenOnSyntax } from "./binding_when_on_syntax"; +var BindingInSyntax = (function () { + function BindingInSyntax(binding) { + this._binding = binding; + } + BindingInSyntax.prototype.inRequestScope = function () { + this._binding.scope = BindingScopeEnum.Request; + return new BindingWhenOnSyntax(this._binding); + }; + BindingInSyntax.prototype.inSingletonScope = function () { + this._binding.scope = BindingScopeEnum.Singleton; + return new BindingWhenOnSyntax(this._binding); + }; + BindingInSyntax.prototype.inTransientScope = function () { + this._binding.scope = BindingScopeEnum.Transient; + return new BindingWhenOnSyntax(this._binding); + }; + return BindingInSyntax; +}()); +export { BindingInSyntax }; diff --git a/src/node_modules/inversify/es/syntax/binding_in_when_on_syntax.js b/src/node_modules/inversify/es/syntax/binding_in_when_on_syntax.js new file mode 100644 index 0000000..211542a --- /dev/null +++ b/src/node_modules/inversify/es/syntax/binding_in_when_on_syntax.js @@ -0,0 +1,70 @@ +import { BindingInSyntax } from "./binding_in_syntax"; +import { BindingOnSyntax } from "./binding_on_syntax"; +import { BindingWhenSyntax } from "./binding_when_syntax"; +var BindingInWhenOnSyntax = (function () { + function BindingInWhenOnSyntax(binding) { + this._binding = binding; + this._bindingWhenSyntax = new BindingWhenSyntax(this._binding); + this._bindingOnSyntax = new BindingOnSyntax(this._binding); + this._bindingInSyntax = new BindingInSyntax(binding); + } + BindingInWhenOnSyntax.prototype.inRequestScope = function () { + return this._bindingInSyntax.inRequestScope(); + }; + BindingInWhenOnSyntax.prototype.inSingletonScope = function () { + return this._bindingInSyntax.inSingletonScope(); + }; + BindingInWhenOnSyntax.prototype.inTransientScope = function () { + return this._bindingInSyntax.inTransientScope(); + }; + BindingInWhenOnSyntax.prototype.when = function (constraint) { + return this._bindingWhenSyntax.when(constraint); + }; + BindingInWhenOnSyntax.prototype.whenTargetNamed = function (name) { + return this._bindingWhenSyntax.whenTargetNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenTargetIsDefault = function () { + return this._bindingWhenSyntax.whenTargetIsDefault(); + }; + BindingInWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) { + return this._bindingWhenSyntax.whenTargetTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenInjectedInto = function (parent) { + return this._bindingWhenSyntax.whenInjectedInto(parent); + }; + BindingInWhenOnSyntax.prototype.whenParentNamed = function (name) { + return this._bindingWhenSyntax.whenParentNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenParentTagged = function (tag, value) { + return this._bindingWhenSyntax.whenParentTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenNoAncestorIs(ancestor); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenAnyAncestorNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenNoAncestorNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenNoAncestorMatches(constraint); + }; + BindingInWhenOnSyntax.prototype.onActivation = function (handler) { + return this._bindingOnSyntax.onActivation(handler); + }; + return BindingInWhenOnSyntax; +}()); +export { BindingInWhenOnSyntax }; diff --git a/src/node_modules/inversify/es/syntax/binding_on_syntax.js b/src/node_modules/inversify/es/syntax/binding_on_syntax.js new file mode 100644 index 0000000..80a847b --- /dev/null +++ b/src/node_modules/inversify/es/syntax/binding_on_syntax.js @@ -0,0 +1,12 @@ +import { BindingWhenSyntax } from "./binding_when_syntax"; +var BindingOnSyntax = (function () { + function BindingOnSyntax(binding) { + this._binding = binding; + } + BindingOnSyntax.prototype.onActivation = function (handler) { + this._binding.onActivation = handler; + return new BindingWhenSyntax(this._binding); + }; + return BindingOnSyntax; +}()); +export { BindingOnSyntax }; diff --git a/src/node_modules/inversify/es/syntax/binding_to_syntax.js b/src/node_modules/inversify/es/syntax/binding_to_syntax.js new file mode 100644 index 0000000..4918d30 --- /dev/null +++ b/src/node_modules/inversify/es/syntax/binding_to_syntax.js @@ -0,0 +1,71 @@ +import * as ERROR_MSGS from "../constants/error_msgs"; +import { BindingTypeEnum } from "../constants/literal_types"; +import { BindingInWhenOnSyntax } from "./binding_in_when_on_syntax"; +import { BindingWhenOnSyntax } from "./binding_when_on_syntax"; +var BindingToSyntax = (function () { + function BindingToSyntax(binding) { + this._binding = binding; + } + BindingToSyntax.prototype.to = function (constructor) { + this._binding.type = BindingTypeEnum.Instance; + this._binding.implementationType = constructor; + return new BindingInWhenOnSyntax(this._binding); + }; + BindingToSyntax.prototype.toSelf = function () { + if (typeof this._binding.serviceIdentifier !== "function") { + throw new Error("" + ERROR_MSGS.INVALID_TO_SELF_VALUE); + } + var self = this._binding.serviceIdentifier; + return this.to(self); + }; + BindingToSyntax.prototype.toConstantValue = function (value) { + this._binding.type = BindingTypeEnum.ConstantValue; + this._binding.cache = value; + this._binding.dynamicValue = null; + this._binding.implementationType = null; + return new BindingWhenOnSyntax(this._binding); + }; + BindingToSyntax.prototype.toDynamicValue = function (func) { + this._binding.type = BindingTypeEnum.DynamicValue; + this._binding.cache = null; + this._binding.dynamicValue = func; + this._binding.implementationType = null; + return new BindingInWhenOnSyntax(this._binding); + }; + BindingToSyntax.prototype.toConstructor = function (constructor) { + this._binding.type = BindingTypeEnum.Constructor; + this._binding.implementationType = constructor; + return new BindingWhenOnSyntax(this._binding); + }; + BindingToSyntax.prototype.toFactory = function (factory) { + this._binding.type = BindingTypeEnum.Factory; + this._binding.factory = factory; + return new BindingWhenOnSyntax(this._binding); + }; + BindingToSyntax.prototype.toFunction = function (func) { + if (typeof func !== "function") { + throw new Error(ERROR_MSGS.INVALID_FUNCTION_BINDING); + } + var bindingWhenOnSyntax = this.toConstantValue(func); + this._binding.type = BindingTypeEnum.Function; + return bindingWhenOnSyntax; + }; + BindingToSyntax.prototype.toAutoFactory = function (serviceIdentifier) { + this._binding.type = BindingTypeEnum.Factory; + this._binding.factory = function (context) { + var autofactory = function () { return context.container.get(serviceIdentifier); }; + return autofactory; + }; + return new BindingWhenOnSyntax(this._binding); + }; + BindingToSyntax.prototype.toProvider = function (provider) { + this._binding.type = BindingTypeEnum.Provider; + this._binding.provider = provider; + return new BindingWhenOnSyntax(this._binding); + }; + BindingToSyntax.prototype.toService = function (service) { + this.toDynamicValue(function (context) { return context.container.get(service); }); + }; + return BindingToSyntax; +}()); +export { BindingToSyntax }; diff --git a/src/node_modules/inversify/es/syntax/binding_when_on_syntax.js b/src/node_modules/inversify/es/syntax/binding_when_on_syntax.js new file mode 100644 index 0000000..4bf0127 --- /dev/null +++ b/src/node_modules/inversify/es/syntax/binding_when_on_syntax.js @@ -0,0 +1,59 @@ +import { BindingOnSyntax } from "./binding_on_syntax"; +import { BindingWhenSyntax } from "./binding_when_syntax"; +var BindingWhenOnSyntax = (function () { + function BindingWhenOnSyntax(binding) { + this._binding = binding; + this._bindingWhenSyntax = new BindingWhenSyntax(this._binding); + this._bindingOnSyntax = new BindingOnSyntax(this._binding); + } + BindingWhenOnSyntax.prototype.when = function (constraint) { + return this._bindingWhenSyntax.when(constraint); + }; + BindingWhenOnSyntax.prototype.whenTargetNamed = function (name) { + return this._bindingWhenSyntax.whenTargetNamed(name); + }; + BindingWhenOnSyntax.prototype.whenTargetIsDefault = function () { + return this._bindingWhenSyntax.whenTargetIsDefault(); + }; + BindingWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) { + return this._bindingWhenSyntax.whenTargetTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenInjectedInto = function (parent) { + return this._bindingWhenSyntax.whenInjectedInto(parent); + }; + BindingWhenOnSyntax.prototype.whenParentNamed = function (name) { + return this._bindingWhenSyntax.whenParentNamed(name); + }; + BindingWhenOnSyntax.prototype.whenParentTagged = function (tag, value) { + return this._bindingWhenSyntax.whenParentTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenNoAncestorIs(ancestor); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenAnyAncestorNamed(name); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenNoAncestorNamed(name); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenNoAncestorMatches(constraint); + }; + BindingWhenOnSyntax.prototype.onActivation = function (handler) { + return this._bindingOnSyntax.onActivation(handler); + }; + return BindingWhenOnSyntax; +}()); +export { BindingWhenOnSyntax }; diff --git a/src/node_modules/inversify/es/syntax/binding_when_syntax.js b/src/node_modules/inversify/es/syntax/binding_when_syntax.js new file mode 100644 index 0000000..b45e728 --- /dev/null +++ b/src/node_modules/inversify/es/syntax/binding_when_syntax.js @@ -0,0 +1,96 @@ +import { BindingOnSyntax } from "./binding_on_syntax"; +import { namedConstraint, taggedConstraint, traverseAncerstors, typeConstraint } from "./constraint_helpers"; +var BindingWhenSyntax = (function () { + function BindingWhenSyntax(binding) { + this._binding = binding; + } + BindingWhenSyntax.prototype.when = function (constraint) { + this._binding.constraint = constraint; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenTargetNamed = function (name) { + this._binding.constraint = namedConstraint(name); + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenTargetIsDefault = function () { + this._binding.constraint = function (request) { + var targetIsDefault = (request.target !== null) && + (!request.target.isNamed()) && + (!request.target.isTagged()); + return targetIsDefault; + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenTargetTagged = function (tag, value) { + this._binding.constraint = taggedConstraint(tag)(value); + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenInjectedInto = function (parent) { + this._binding.constraint = function (request) { + return typeConstraint(parent)(request.parentRequest); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenParentNamed = function (name) { + this._binding.constraint = function (request) { + return namedConstraint(name)(request.parentRequest); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenParentTagged = function (tag, value) { + this._binding.constraint = function (request) { + return taggedConstraint(tag)(value)(request.parentRequest); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenAnyAncestorIs = function (ancestor) { + this._binding.constraint = function (request) { + return traverseAncerstors(request, typeConstraint(ancestor)); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenNoAncestorIs = function (ancestor) { + this._binding.constraint = function (request) { + return !traverseAncerstors(request, typeConstraint(ancestor)); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenAnyAncestorNamed = function (name) { + this._binding.constraint = function (request) { + return traverseAncerstors(request, namedConstraint(name)); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenNoAncestorNamed = function (name) { + this._binding.constraint = function (request) { + return !traverseAncerstors(request, namedConstraint(name)); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenAnyAncestorTagged = function (tag, value) { + this._binding.constraint = function (request) { + return traverseAncerstors(request, taggedConstraint(tag)(value)); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenNoAncestorTagged = function (tag, value) { + this._binding.constraint = function (request) { + return !traverseAncerstors(request, taggedConstraint(tag)(value)); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenAnyAncestorMatches = function (constraint) { + this._binding.constraint = function (request) { + return traverseAncerstors(request, constraint); + }; + return new BindingOnSyntax(this._binding); + }; + BindingWhenSyntax.prototype.whenNoAncestorMatches = function (constraint) { + this._binding.constraint = function (request) { + return !traverseAncerstors(request, constraint); + }; + return new BindingOnSyntax(this._binding); + }; + return BindingWhenSyntax; +}()); +export { BindingWhenSyntax }; diff --git a/src/node_modules/inversify/es/syntax/constraint_helpers.js b/src/node_modules/inversify/es/syntax/constraint_helpers.js new file mode 100644 index 0000000..29a7740 --- /dev/null +++ b/src/node_modules/inversify/es/syntax/constraint_helpers.js @@ -0,0 +1,35 @@ +import * as METADATA_KEY from "../constants/metadata_keys"; +import { Metadata } from "../planning/metadata"; +var traverseAncerstors = function (request, constraint) { + var parent = request.parentRequest; + if (parent !== null) { + return constraint(parent) ? true : traverseAncerstors(parent, constraint); + } + else { + return false; + } +}; +var taggedConstraint = function (key) { return function (value) { + var constraint = function (request) { + return request !== null && request.target !== null && request.target.matchesTag(key)(value); + }; + constraint.metaData = new Metadata(key, value); + return constraint; +}; }; +var namedConstraint = taggedConstraint(METADATA_KEY.NAMED_TAG); +var typeConstraint = function (type) { return function (request) { + var binding = null; + if (request !== null) { + binding = request.bindings[0]; + if (typeof type === "string") { + var serviceIdentifier = binding.serviceIdentifier; + return serviceIdentifier === type; + } + else { + var constructor = request.bindings[0].implementationType; + return type === constructor; + } + } + return false; +}; }; +export { traverseAncerstors, taggedConstraint, namedConstraint, typeConstraint }; |