@tabuckner/spongebob-case
v0.0.2
Published
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) <!-- [![Greenkeeper badge](https://badges.greenkeeper.io/alexjoverm/typescript-library-starter.svg)](https://greenkeeper.io/) -->
Downloads
3
Readme
SpongeBob Case
An over engineered Typescript library that utilizes the OOP Strategy Pattern. Stackblitz Demo
Usage
Install
yarn add @tabuckner/spongebob-case
Importing library
const SC = require('@tabuckner/spongebob-case.umd');
const simpleTranslator = new SC.SpongebobCase(new SC.SimpleAlternate());
const alternatingTranslator = new SC.SpongebobCase(new SC.AlternateIgnoreSpaces());
const testStr = 'This is a testing string.'
console.log(simpleTranslator.translate(testStr)); // tHiS Is a tEsTiNg sTrInG.
console.log(alternatingTranslator.translate(testStr)); // ThIs Is A tEsTiNg StRiNg.
Or, you can import the transpiled modules from dist/lib
in case you have a modular library:
import something from 'mylib/dist/lib/something'
import { SpongebobCase, SimpleAlternate, AlternateIgnoreSpaces } from '@tabuckner/spongebob-case.es5';
const simpleTranslator = new SpongebobCase(new SimpleAlternate());
const alternatingTranslator = new SpongebobCase(new AlternateIgnoreSpaces());
const testStr = 'This is a testing string.'
console.log(simpleTranslator.translate(testStr)); // tHiS Is a tEsTiNg sTrInG.
console.log(alternatingTranslator.translate(testStr)); // ThIs Is A tEsTiNg StRiNg.
import { SpongebobCase, AlternateIgnoreSpaces, SimpleAlternate } from "@tabuckner/spongebob-case";
import { SCTranslator } from "@tabuckner/spongebob-case/dist/types/translator.interface";
export class MyClass {
private simpleTranslator: SCTranslator;
private alternatingTranslator: SCTranslator;
constructor() {
this.simpleTranslator = new SpongebobCase(new SimpleAlternate());
this.alternatingTranslator = new SpongebobCase(new AlternateIgnoreSpaces());
}
public translateA(str: string): string {
return this.simpleTranslator.translate(str); // tHiS Is a tEsTiNg sTrInG.
}
public translateB(str: string): string {
return this.alternatingTranslator.translate(str); // ThIs Is A tEsTiNg StRiNg.
}
}