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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ibm-wch-sdk-rendition-utils

v5.0.361

Published

Software development kit to simplify the development of Angular based single page applications against Watson Content Hub.

Downloads

2

Readme

ibm-wch-sdk-rendition-utils

Exposes framework independent APIs to support the implementation of ibm-wch-sdk-ng and similar SDK.

Details

Refer to the documentation.

Changes

CHANGELOG

Class documentation

Refer to the documentation.

Utils

TBD

Changelog

Current

Added

  • Initial version

Utils

TBD

Index

External modules


ibm-wch-sdk-rendition-utils > "index"

External module: "index"

Index


ibm-wch-sdk-rendition-utils > "utils/rendition.utils"

External module: "utils/rendition.utils"

Index

Interfaces

Variables

Functions


Variables

<Const> LOGGER

● LOGGER: "RenditionDirective" = "RenditionDirective"

Defined in utils/rendition.utils.ts:4


<Const> RENDITION_REGEXP

● RENDITION_REGEXP: RegExp = /resize=(\d+)(?:px)?:(\d+)(?:px)?&crop=(\d+)(?:px)?:(\d+)(?:px)?;(\d+)(?:px)?,(\d+)(?:px)?/

Defined in utils/rendition.utils.ts:257

Regular expression to detect the renditions settings. Make sure to not use the 'g' flag!


<Const> _mathFloor

● _mathFloor: floor = Math.floor

Defined in utils/rendition.utils.ts:48


<Const> _mathRound

● _mathRound: round = Math.round

Defined in utils/rendition.utils.ts:49


<Const> jsonStringify

● jsonStringify: stringify = JSON.stringify

Defined in utils/rendition.utils.ts:6


Functions

_appendQueryString

_appendQueryString(aBaseUrl: string, aQueryString: string): string

Defined in utils/rendition.utils.ts:59

Appends a query string to a base URL that may or may not have a query part. If it has a query, the previous query is removed

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aBaseUrl | string | current base URL | | aQueryString | string | string to append |

Returns: string the resulting URL


_approx

_approx(aNumber: number): number

Defined in utils/rendition.utils.ts:73

Approximate a floating number to a fixed number of decimals

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aNumber | number | number to approximate |

Returns: number the approximated number


_binaryIndexOf

_binaryIndexOf<T,K>(aSearchElement: K, aArray: T[], aCmp: function): number

Defined in utils/rendition.utils.ts:110

Executes a binary search for an element

Type parameters:

T

K

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aSearchElement | K | element to look for | | aArray | T[] | array to search | | aCmp | function | comparision function |

Returns: number the index


_clip

_clip(aValue: number, aMin: number, aMax: number): number

Defined in utils/rendition.utils.ts:304

Clips a value against the given boundaries

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aValue | number | the value to clip | | aMin | number | the min value | | aMax | number | the max value |

Returns: number the clipped value


_compareByAspect

_compareByAspect(aLeft: RenditionBean, aRight: RenditionBean): number

Defined in utils/rendition.utils.ts:150

Compares renditions by aspect

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aLeft | RenditionBean | left value to compare | | aRight | RenditionBean | right value to compare |

Returns: number comparison result


_compareByWidth

_compareByWidth(aLeft: * Rendition | RenditionBean, aRight: * Rendition | RenditionBean): number

Defined in utils/rendition.utils.ts:161

Compares renditions by width

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aLeft | Rendition | RenditionBean| left value to compare | | aRight | Rendition | RenditionBean| right value to compare |

Returns: number comparison result


_compareByWidthAndHeight

_compareByWidthAndHeight(aLeft: * Rendition | RenditionBean, aRight: * Rendition | RenditionBean): number

Defined in utils/rendition.utils.ts:173

Compares renditions by width

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aLeft | Rendition | RenditionBean| left value to compare | | aRight | Rendition | RenditionBean| right value to compare |

Returns: number comparison result


_compareNumbers

_compareNumbers(aLeft: number, aRight: number): number

Defined in utils/rendition.utils.ts:139

Safe number comparison

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aLeft | number | left value to compare | | aRight | number | right value to compare |

Returns: number comparison result


_createDimension

_createDimension(aWidth: number, aHeight: number): Dimension

Defined in utils/rendition.utils.ts:16

Constructs a dimensions object based on width and height

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aWidth | number | the width | | aHeight | number | the height |

Returns: Dimension the dimension object


_createRenditionBean

_createRenditionBean(aTargetAspect: number, aRendition: Rendition): RenditionBean

Defined in utils/rendition.utils.ts:85

Constructs the rendition bean based on the actual rendition

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aTargetAspect | number | desired target aspect | | aRendition | Rendition | the rendition |

Returns: RenditionBean the bean


_equalsWidth

_equalsWidth(aLeft: * Rendition | RenditionBean, aRight: * Rendition | RenditionBean): boolean

Defined in utils/rendition.utils.ts:185

Tests if the width of two renditions is equal

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aLeft | Rendition | RenditionBean| left rendition | | aRight | Rendition | RenditionBean| right rendition |

Returns: boolean true if equal


_findBestAspects

_findBestAspects(aRenditions: RenditionBean[], aLogger: Logger): RenditionBean[]

Defined in utils/rendition.utils.ts:207

Returns a list of renditions with the best matching aspect ratio

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aRenditions | RenditionBean[] | the renditions | | aLogger | Logger | the logger |

Returns: RenditionBean[] the renditions with the best matching aspect ratio


_findBestWidth

_findBestWidth(aWidth: number, aRenditions: RenditionBean[], aLogger: Logger): RenditionBean | undefined

Defined in utils/rendition.utils.ts:231

Find the rendition with the best width, i.e. the closest width that is larger than the given width

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aWidth | number | desired width | | aRenditions | RenditionBean[] | renditions | | aLogger | Logger | the logger |

Returns: RenditionBean | undefined

the selected rendition


_findByWidth

_findByWidth(aLeft: number, aRight: * Rendition | RenditionBean*): number

Defined in utils/rendition.utils.ts:196

Compares renditions by width

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aLeft | number | left value to compare | | aRight | Rendition | RenditionBean| right value to compare |

Returns: number comparison result


_getDecodedQueryString

_getDecodedQueryString(aUrl: string): string | undefined

Defined in utils/rendition.utils.ts:265

Checks if the URL has a query string and decodes it if so.

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aUrl | string | the URL |

Returns: string | undefined

the decoded query string or undefined


_getRendition

_getRendition(aDstWidth: number, aDstHeight: number, aImage: Image, aLogger: Logger): ScaledImage

Defined in utils/rendition.utils.ts:323

Builds a query string for the Akamai rendition service such that the resulting image matches the desired dimensions. The algorithm first finds the renditions with the best matching aspect ratio. Out of the result set it then selects the nearest rendition that is large or equal in size, because that most likely represents the desired excerpt best. It then fixes the aspect ration and computes the new transform.

In case the image would be scaled up, we return the identity scaling and let the browser scale the image.

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aDstWidth | number | desired image width | | aDstHeight | number | desired image height | | aImage | Image | the image | | aLogger | Logger | the logger |

Returns: ScaledImage the URL string


_getSourceSet

_getSourceSet(aImage: Image, aOrigin: string): string

Defined in utils/rendition.utils.ts:432

Computes the source set from the available renditions

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aImage | Image | the image | | aOrigin | string | the origin |

Returns: string the source set


_parseNumber

_parseNumber(aValue: string): number

Defined in utils/rendition.utils.ts:282

Parses a string into a number

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aValue | string | the value to parse |

Returns: number the decoded string


_round

_round(aValue: number): number

Defined in utils/rendition.utils.ts:292

Rounding function

Parameters:

| Param | Type | Description | | ------ | ------ | ------ | | aValue | number | the value to round |

Returns: number the rounded value


Utils

TBD

Index

External modules


ibm-wch-sdk-rendition-utils > "utils/rendition.utils" > Dimension

Interface: Dimension

Exposes the concept of a dimension

Hierarchy

Dimension

Index

Properties


Properties

h

● h: number

Defined in utils/rendition.utils.ts:28


w

● w: number

Defined in utils/rendition.utils.ts:27


ibm-wch-sdk-rendition-utils > "utils/rendition.utils" > RenditionBean

Interface: RenditionBean

Hierarchy

RenditionBean

Index

Properties


Properties

aspect

● aspect: number

Defined in utils/rendition.utils.ts:41


diff

● diff: number

Defined in utils/rendition.utils.ts:44


height

● height: number

Defined in utils/rendition.utils.ts:43


rendition

● rendition: Rendition

Defined in utils/rendition.utils.ts:40


width

● width: number

Defined in utils/rendition.utils.ts:42


ibm-wch-sdk-rendition-utils > "utils/rendition.utils" > ScaledImage

Interface: ScaledImage

Hierarchy

ScaledImage

Index

Properties


Properties

container

● container: Dimension

Defined in utils/rendition.utils.ts:35


image

● image: Image

Defined in utils/rendition.utils.ts:33


img

● img: Dimension

Defined in utils/rendition.utils.ts:34


url

● url: string

Defined in utils/rendition.utils.ts:36