How to use the typed-inject.Scope.Transient function in typed-inject

To help you get started, we’ve selected a few typed-inject examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stryker-mutator / stryker / packages / stryker-test-helpers / src / TestInjector.ts View on Github external
config.set(this.options);
    return config;
  }
  private readonly provideOptions = () => {
    return this.options;
  }

  public pluginResolver: sinon.SinonStubbedInstance;
  public options: StrykerOptions;
  public logger: sinon.SinonStubbedInstance;
  public injector: Injector = rootInjector
    .provideValue(commonTokens.getLogger, this.provideLogger)
    .provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
    .provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
    .provideFactory(commonTokens.config, this.provideConfig, Scope.Transient)
    .provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient);

  public reset() {
    this.options = factory.strykerOptions();
    this.logger = factory.logger();
    this.pluginResolver = {
      resolve: sinon.stub(),
      resolveAll: sinon.stub()
    };
  }
}

export const testInjector = new TestInjector();
testInjector.reset();
github stryker-mutator / stryker / packages / stryker-test-helpers / src / TestInjector.ts View on Github external
}
  private readonly provideConfig = () => {
    const config = new Config();
    config.set(this.options);
    return config;
  }
  private readonly provideOptions = () => {
    return this.options;
  }

  public pluginResolver: sinon.SinonStubbedInstance;
  public options: StrykerOptions;
  public logger: sinon.SinonStubbedInstance;
  public injector: Injector = rootInjector
    .provideValue(commonTokens.getLogger, this.provideLogger)
    .provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
    .provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
    .provideFactory(commonTokens.config, this.provideConfig, Scope.Transient)
    .provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient);

  public reset() {
    this.options = factory.strykerOptions();
    this.logger = factory.logger();
    this.pluginResolver = {
      resolve: sinon.stub(),
      resolveAll: sinon.stub()
    };
  }
}

export const testInjector = new TestInjector();
testInjector.reset();
github stryker-mutator / stryker / packages / test-helpers / src / TestInjector.ts View on Github external
return this.logger;
  };
  private readonly provideOptions = () => {
    return this.options;
  };
  private readonly provideMutatorDescriptor = () => {
    return this.mutatorDescriptor;
  };

  public pluginResolver: sinon.SinonStubbedInstance;
  public options: StrykerOptions;
  public mutatorDescriptor: MutatorDescriptor;
  public logger: sinon.SinonStubbedInstance;
  public injector: Injector = rootInjector
    .provideValue(commonTokens.getLogger, this.provideLogger)
    .provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
    .provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
    .provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient)
    .provideFactory(commonTokens.mutatorDescriptor, this.provideMutatorDescriptor, Scope.Transient);

  public reset() {
    this.mutatorDescriptor = factory.mutatorDescriptor();
    this.options = factory.strykerOptions();
    this.logger = factory.logger();
    this.pluginResolver = {
      resolve: sinon.stub(),
      resolveAll: sinon.stub()
    };
  }
}

export const testInjector = new TestInjector();
github stryker-mutator / stryker / packages / test-helpers / src / TestInjector.ts View on Github external
private readonly provideOptions = () => {
    return this.options;
  };
  private readonly provideMutatorDescriptor = () => {
    return this.mutatorDescriptor;
  };

  public pluginResolver: sinon.SinonStubbedInstance;
  public options: StrykerOptions;
  public mutatorDescriptor: MutatorDescriptor;
  public logger: sinon.SinonStubbedInstance;
  public injector: Injector = rootInjector
    .provideValue(commonTokens.getLogger, this.provideLogger)
    .provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
    .provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
    .provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient)
    .provideFactory(commonTokens.mutatorDescriptor, this.provideMutatorDescriptor, Scope.Transient);

  public reset() {
    this.mutatorDescriptor = factory.mutatorDescriptor();
    this.options = factory.strykerOptions();
    this.logger = factory.logger();
    this.pluginResolver = {
      resolve: sinon.stub(),
      resolveAll: sinon.stub()
    };
  }
}

export const testInjector = new TestInjector();
testInjector.reset();

typed-inject

Type safe dependency injection framework for TypeScript

Apache-2.0
Latest version published 9 days ago

Package Health Score

81 / 100
Full package analysis