npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

s3-models

v3.9.0

Published

Models, Interfaces, Enums for Voyager S3

Downloads

33

Readme

s3-models

Overview

s3-models is a library that provides models, interfaces, and services for managing events and data in Angular applications. It includes support for profile tokens, translations, and event buses for managing language and currency events.

Installation

To install the library, use npm:

npm install s3-models

Models

ProfileTokenModel

The ProfileTokenModel class represents a profile token with the following properties:

  • token: The token associated with the profile.
  • initials: The initials of the profile.
  • profilePictureUri: The URI of the profile picture (optional).

Example usage:

import { ProfileTokenModel } from 's3-models';

const profile = new ProfileTokenModel({
  token: 'test-token',
  initials: 'TT',
  profilePictureUri: 'http://example.com/pic.jpg'
});

console.log(profile.isLogged); // Output: true

Interfaces

Translation

The Translation interface defines methods for translating keys and managing language settings.

EventEmitter

The EventEmitter interface defines methods for emitting events and getting the current value of the event stream.

export interface EventEmitter<T> {
  emitEvent(event: T): void;
  get getCurrentValue(): T;
}

EventReader

The EventReader interface defines a property for reading events.

import { Observable } from 'rxjs';

export interface EventReader<T> {
  readonly event$: Observable<T>;
}

Services

Registering Services in Angular DI

To use the services provided by s3-models in your Angular application, you need to register them in your Angular module's providers array.

Example:

import { InjectionToken } from '@angular/core';
import { Translation } from 's3-models';

export const TRANSLATION_TOKEN = new InjectionToken<Translation>('Translation');
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ProfileEventBusService, LanguageEventBusService, CurrencyEventBusService, StringEventBusService, ProfileEventEmitter, ProfileEventReader, LanguageEventEmitter, LanguageEventReader, CurrencyEventEmitter, CurrencyEventReader } from 's3-models';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  providers: [
		ProfileEventBusService,
		{ provide: ProfileEventEmitter, useFactory: (profileService: ProfileEventBusService) => new ProfileEventEmitter(profileService), deps: [ProfileEventBusService] },
		{ provide: ProfileEventReader, useFactory: (profileService: ProfileEventBusService) => new ProfileEventReader(profileService), deps: [ProfileEventBusService] },
		CurrencyEventBusService,
		{ provide: CurrencyEventEmitter, useFactory: (currencyService: CurrencyEventBusService) => new CurrencyEventEmitter(currencyService), deps: [CurrencyEventBusService] },
		{ provide: CurrencyEventReader, useFactory: (currencyService: CurrencyEventBusService) => new CurrencyEventReader(currencyService), deps: [CurrencyEventBusService] },
		LanguageEventBusService,
		{ provide: LanguageEventEmitter, useFactory: (languageService: LanguageEventBusService) => new LanguageEventEmitter(languageService), deps: [LanguageEventBusService] },
		{ provide: LanguageEventReader, useFactory: (languageService: LanguageEventBusService) => new LanguageEventReader(languageService), deps: [LanguageEventBusService] },
		{ provide: TRANSLATION_TOKEN, useClass: TranslationService },
		{ provide: LanguageTranslationService, useFactory: (languageEventReader: LanguageEventReader, translation: TranslationService) => new LanguageTranslationService(languageEventReader, translation), deps: [LanguageEventReader, TranslationService] }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

LanguageTranslationService

The LanguageTranslationService class provides methods for managing language translations and reacting to language changes.

Example usage:

import { Inject } from '@angular/core';
import { LanguageTranslationService } from 's3-models';

constructor(
  private languageTranslationService: LanguageTranslationService
) {
  this.languageTranslationService.language$.subscribe(language => {
    console.log('Language changed:', language);
  });

  const translatedText = this.languageTranslationService.translate('HELLO');
  console.log(translatedText); // Output: HELLO-translated

  this.languageTranslationService.getTranslation$('HELLO').subscribe(translated => {
    console.log(translated); // Output: HELLO-translated
  });
}

CurrencyEventBusService

The CurrencyEventBusService class extends the EventBus class to handle events of type string, with 'PLN' as the default currency.

Example usage:

import { Inject } from '@angular/core';
import { CurrencyEventBusService, CurrencyEventEmitter, CurrencyEventReader } from 's3-models';

constructor(
  @Inject('CurrencyEventEmitter') private currencyEventEmitter: CurrencyEventEmitter,
  @Inject('CurrencyEventReader') private currencyEventReader: CurrencyEventReader
) {
  this.currencyEventReader.event$.subscribe(currency => {
    console.log('Currency changed:', currency);
  });

  this.currencyEventEmitter.emitEvent('USD');
}

ProfileEventBusService

The ProfileEventBusService class extends the EventBus class to handle events of type ProfileTokenModel.

Example usage:

import { Inject } from '@angular/core';
import { ProfileEventBusService, ProfileTokenModel, ProfileEventEmitter, ProfileEventReader } from 's3-models';

constructor(
  @Inject('ProfileEventEmitter') private profileEventEmitter: ProfileEventEmitter,
  @Inject('ProfileEventReader') private profileEventReader: ProfileEventReader
) {
  this.profileEventReader.event$.subscribe(profile => {
    console.log('Profile changed:', profile);
  });

  const newProfile = new ProfileTokenModel({
    token: 'new-token',
    initials: 'NT',
    profilePictureUri: 'http://example.com/new-pic.jpg'
  });
  this.profileEventEmitter.emitEvent(newProfile);
}

LanguageEventBusService

The LanguageEventBusService class extends the EventBus class to handle events of type string, with 'pl' as the default language.

Example usage:

import { Inject } from '@angular/core';
import { LanguageEventBusService } from 's3-models';

constructor(
  @Inject('LanguageEventEmitter') private languageEventEmitter: LanguageEventBusService,
  @Inject('LanguageEventReader') private languageEventReader: LanguageEventBusService
) {
  this.languageEventReader.event$.subscribe(language => {
    console.log('Language changed:', language);
  });

  this.languageEventEmitter.emitEvent('en');
}

CurrencyEventBusService

The CurrencyEventBusService class extends the EventBus class to handle events of type string, with 'PLN' as the default currency.

Example usage:

import { Inject } from '@angular/core';
import { CurrencyEventBusService } from 's3-models';

constructor(
  @Inject('CurrencyEventEmitter') private currencyEventEmitter: CurrencyEventBusService,
  @Inject('CurrencyEventReader') private currencyEventReader: CurrencyEventBusService
) {
  this.currencyEventReader.event$.subscribe(currency => {
    console.log('Currency changed:', currency);
  });

  this.currencyEventEmitter.emitEvent('USD');
}

CurrencyEventBusService

The CurrencyEventBusService class extends the EventBus class to handle events of type string, with 'PLN' as the default currency.

Example usage:

import { Inject } from '@angular/core';
import { CurrencyEventEmitter, CurrencyEventReader } from 's3-models';

constructor(
  @Inject('CurrencyEventEmitter') private currencyEventEmitter: CurrencyEventEmitter,
  @Inject('CurrencyEventReader') private currencyEventReader: CurrencyEventReader
) {
  this.currencyEventReader.event$.subscribe(currency => {
    console.log('Currency changed:', currency);
  });

  this.currencyEventEmitter.emitEvent('USD');
}

StringEventBusService

The StringEventBusService class extends the EventBus class to handle events of type string.

Example usage:

import { Inject } from '@angular/core';
import { StringEventBusService } from 's3-models';

constructor(
  @Inject('StringEventEmitter') private stringEventEmitter: StringEventBusService,
  @Inject('StringEventReader') private stringEventReader: StringEventBusService
) {
  this.stringEventReader.event$.subscribe(event => {
    console.log('Event received:', event);
  });

  this.stringEventEmitter.emitEvent('Hello, World!');
}

Abstract Classes

EventBus

The EventBus class is an abstract class that provides a mechanism for emitting and subscribing to events of type T. It uses RxJS's BehaviorSubject to manage the event stream.

License

This project is licensed under the MIT License.