Wondering what’s next for npm?Check out our public roadmap! »

    multi-encoder
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.3 • Public • Published

    «-(¯`v´¯)-« 【🇲​🇺​🇱​🇮​🇹​-🇪​🇳​🇨​🇴​🇩​🇪​​】 »-(¯`v´¯)-»
    multi-encoder string encode and decode

    multi-encoder

    Encodes and Decodes to several formats:

    • encode Base64
    • decode Base64
    • encode Uri
    • decode Uri
    • encode UriComponent
    • decode UriComponent
    • encode Javascript
    • decode JavaScript
    • encode TypeScript
    • decode TypeStript

    Install

    $ npm install --save base64-string

    Usage

    import { codeString, eKind, eProcess } from 'multi-encoder';
    // other code
     
    // encodes hello world as base64
    // result is aGVsbG8gd29ybGQ=
    let str = codeString('hello world', eKind.base64, eProcess.encode);
     
    // decodes base64 into hello world
    let str = codeString('aGVsbG8gd29ybGQ=', eKind.base64, eProcess.decode);
     
    let uriStr = 'my test.asp?name=ståle&car=saab';
    // encodes as uri result: 'my%20test.asp?name=st%C3%A5le&car=saab'
    const uriEnc = codeString(uriStr, eKind.uri, eProcess.encode);
     
    // decodes uri value result: 'my test.asp?name=ståle&car=saab'
    str = codeString(uriEnc, eKind.uri, eProcess.decode);
     
    uriStr = 'https://someurl.com/my test.asp?name=ståle&car=saab';
    // encodes as urlComponent
    // result: 'https%3A%2F%2Fsomeurl.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab' 
    uriEnc = codeString(uriStr, eKind.uriComponent, eProcess.encode);
     
    // decodes urlComponent
    // result: 'https://someurl.com/my test.asp?name=ståle&car=saab'
    str = codeString(uriEnc, eKind.uriComponent, eProcess.decode);
     
    // also encode / decode JavaScript or TypeScript for safe JavaScript or TypeScript string
    str = codeString('some JavaScript code', eKind.jsString, eProcess.encode);
    str = codeString('some encoded JavaScript code', eKind.jsString, eProcess.decode);
     
    str = codeString('some TypeScript code', eKind.tsString, eProcess.encode);
    str = codeString('some encoded TypeScript code', eKind.tsString, eProcess.decode);

    Install

    npm i multi-encoder

    DownloadsWeekly Downloads

    8

    Version

    0.4.3

    License

    MIT

    Unpacked Size

    11.4 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar