Naughty Pinching Mannequins

    @gs-libs/utils
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.1 • Public • Published

    GS Utilities Package

    This package contains GS's most commonly used utility functions

    Util Functions

    decodeHtml


    When we fetch a hub story using JSBridge-API, the description and the title of the story in mobile platforms are returned with encoded char. And we need to decode them before displaying it.

    import { decodeHtml } from '@gs-libs/utils'
    
    const encodedNoHTML =
      'Welcome to our New Partner© & Strategy™ Portal!';
    
    const decoded = decodeHtml(encodedNoHTML); // => Welcome to our New Partner© & Strategy™ Portal!
    

    encodeHtml


    import { encodeHtml } from '@gs-libs/utils'
    
    const decodedHtml =
      'Welcome to our New Partner© & Strategy™ Portal!';
    
    const encoded = encodeHtml(decodedHtml); // => Welcome to our New Partner© & Strategy™ Portal!
    

    ensure


    To make sure a promise doesn't throw and wrap the result into the Result object.

    import { ensure } from '@gs-libs/utils';
    import { BridgeServices, Story } from '@gs-libs/bridge';
    
    const bridge = new BridgeServices();
    
    // ------ The below code is possible to throw ------
    const data = await bridge.getEntity<Story>({
        entityName: 'story', id: 123
      });
    const storyTitle = data.title;
    
    // ------ The below code won't throw ------
    const data = await ensure(() => bridge.getEntity<Story>({
      entityName: 'story',
      id: 123
    }))
    
    if (data.hasError) {
      ...
    } eles {
      const storyTitle = data.value.title;
    }
    
    

    Install

    npm i @gs-libs/utils

    DownloadsWeekly Downloads

    6

    Version

    1.2.1

    License

    SEE LICENSE IN LICENSE

    Unpacked Size

    91.1 kB

    Total Files

    18

    Last publish

    Collaborators

    • bigtincan_gs