Nature's Particle Manager

    @tabuckner/spongebob-case
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.2 • Public • Published

    SpongeBob Case

    styled with prettier

    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.
      }
    }

    Keywords

    none

    Install

    npm i @tabuckner/spongebob-case

    DownloadsWeekly Downloads

    4

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    37.8 kB

    Total Files

    25

    Last publish

    Collaborators

    • tabuckner