base

Pure JavaScript stuff. Nothing here should be WEB API aware, except Logger's use of console (and apparently crypto).

Version:
  • 73

Classes

DefaultMap

Dispatcher

Logger

MessageQueue

Service

FactoryTypeError

NumberOp

Members

static, constant Code :number

Mapping of Google's Canonical Error Codes.

Properties:
Name Type Description
OK number
CANCELLED number
INVALID_ARGUMENT number
DEADLINE_EXCEEDED number
NOT_FOUND number
ALREADY_EXISTS number
PERMISSION_DENIED number
UNAUTHENTICATED number
RESOURCE_EXHAUSTED number
FAILED_PRECONDITION number
ABORTED number
OUT_OF_RANGE number
UNIMPLEMENTED number
INTERNAL number
UNAVAILABLE number
DATA_LOSS number

static, constant LAST_ITEM :number

Identify the last item in a collection like at(-1).

static, constant NOT_FOUND :number

Returned by some APIs like findIndex().

static, constant ONE_ITEM :number

Useful for testing length of an array.

static, constant version :number

Bumped per release.

Methods

static ensure(versions) → {object}

Ensures appropriate versions of NexusHoratio libraries are loaded.

Parameters:
Name Type Description
versions Array.<module:base~Version>

Versions required.

Throws:

When requirements not met.

Type
Error
Returns:
object -

Namespace with only ensured libraries present.

static safeId(input) → {string}

Normalize a string to be safe to use as an HTML element id.

Parameters:
Name Type Description
input string

The string to normalize.

Returns:
string -

Normalized string.

static sha256(string) → {string}

Parameters:
Name Type Description
string string

String to hash.

Returns:
string -

Hex digest of the string.

Deprecated:
  • Compute the SHA-256 digest of a string.

static simpleParseWords(text) → {Array.<string>}

Separate a string of concatenated words along transitions.

Transitions are: lower to upper (lowerUpper -> lower Upper) grouped upper to lower (ABCd -> AB Cd) underscores (snake_case -> snake case) spaces character/numbers (lower2Upper -> lower 2 Upper) Likely only works with ASCII. Empty strings return an empty array. Extra separators are consolidated.

Parameters:
Name Type Description
text string

Text to parse.

Returns:
Array.<string> -

Parsed text.

static strHash(s) → {string}

Jenkins one at a time hash.

https://en.wikipedia.org/wiki/Jenkins_hash_function#one_at_a_time

Parameters:
Name Type Description
s string

String to hash.

Returns:
string -

Hash value.

static uuId(strBase) → {string}

Create a UUID-like string with a base.

Parameters:
Name Type Description
strBase string

Base value for the string.

Returns:
string -

A unique string.

inner runTests()

Basic test runner.

This depends on Logger, hence the location in this file instead of module:xunit.

Type Definitions

Version

Properties:
Name Type Attributes Default Description
name string

Library name.

minVersion number <optional>
0

Minimal version needed.