Module: @bldr/core-browser

@bldr/core-browser

Base core functionality for the code running in the browser without node.

Run npm run build to build the node version of this code. The node version uses the CommonJS module system instead of the ES module system.

Classes

AssetTypes
RawDataObject

Members

module:@bldr/core-browser.jsYamlConfig staticconstant

Methods

module:@bldr/core-browser.camelToSnake (str)String static

Convert camelCase into snake_case strings.

Name Type Description
str String

A camel cased string.

See:
Returns:
Type Description
String

module:@bldr/core-browser.convertPropertiesToCamelCase (object)Object static

Convert all properties in an object to camelCase in a recursive fashion.

Name Type Description
object Object
Returns:
Type Description
Object

module:@bldr/core-browser.deepCopy () static

module:@bldr/core-browser.escapeHtml () static

See:

module:@bldr/core-browser.formatMultiPartAssetFileName (firstFileName, no)String static

Generate from the file name or the url of the first element of a multipart asset the nth file name or the url. The parameter firstFileName must have a extension (for example .jpg). The parameter no must be smaller then 100. Only two digit or smaller integers are allowed.

  1. multipart-asset.jpg
  2. multipart-asset_no02.jpg
  3. multipart-asset_no03.jpg
  4. ...
Name Type Description
firstFileName String

A file name, a path or a URL.

no Number

The number in the multipart asset list. The first element has the number 1.

Returns:
Type Description
String

module:@bldr/core-browser.formatToLocalDate (dateSpec)String static

Format a date specification string into a local date string, for example 28. August 1749

Name Type Description
dateSpec String

A valid input for the Date() class. If the input is invalid the raw dateSpec is returned.

Returns:
Type Description
String

module:@bldr/core-browser.formatToLocalDateTime (timeStampMsec)String static

Format a timestamp into a string like this example: Mo 17.2.2020 07:57:53

Name Type Description
timeStampMsec Number

The timestamp in milliseconds.

Returns:
Type Description
String

module:@bldr/core-browser.formatWikidataUrl ()String static

https://www.wikidata.org/wiki/Q42

Returns:
Type Description
String

module:@bldr/core-browser.formatWikipediaUrl (nameSpace)String static

https://en.wikipedia.org/wiki/A_Article

Name Type Description
nameSpace String

The name space of the Wikipedia article (for example A_Article or en:A_article)

Returns:
Type Description
String

module:@bldr/core-browser.formatYoutubeUrl (id)String static

https://youtu.be/CQYypFMTQcE

Name Type Description
id String

The id of a Youtube video (for example CQYypFMTQcE).

Returns:
Type Description
String

module:@bldr/core-browser.getExtension (filePath)String static

Get the extension from a file path.

Name Type Description
filePath String
Returns:
Type Description
String
  • The extension in lower case charcters.

module:@bldr/core-browser.plainText (html)String static

Name Type Description
html String
Returns:
Type Description
String

module:@bldr/core-browser.selectSubset (subsetSelector, options)Array static

Select a subset of elements by a string (subsetSelector). 1 is the first element of the elements array.

  • `` (emtpy string or a falsy value): All elements
  • 1: The first element
  • 1,3,5:
  • 1-3,5-7
  • -7:
  • 7-
Name Type Description
subsetSelector String

See above.

options object
Properties:
Name Type Description
options.sort String | boolean

numeric, or a truety value.

options.elements Array

An array of elements to build a subset from.

options.elementsCount Number

If elements is undefined, an array with integers is created und used as elements.

options.firstElementNo Number
options.shiftSelector Number

Shift all selector numbers by this number: For example -1: 2-5 is internally treated as 1-4

Returns:
Type Description
Array

module:@bldr/core-browser.shortenText (text, options)String static

Name Type Description
text String
options Object
Returns:
Type Description
String

module:@bldr/core-browser.snakeToCamel (str)String static

Convert snake_case or kebab-case strings into camelCase strings.

Name Type Description
str String

A snake or kebab cased string

See:
Returns:
Type Description
String

module:@bldr/core-browser.sortObjectsByProperty (property) static

Sort alphabetically an array of objects by some specific properties.

Name Type Description
property String

Key of the object to sort.

See: