Module: rgjs/utils

RGJS6 Utils module.

Methods


<static> evalf(str [, bindTo] [, args])

Eval() may be bad, but we can at least try to do it as efficiently as possible. Note: If provided with a string without () and it turns out to be a function, evalf() will be able to run it more efficiently.

Parameters:
Name Type Argument Description
str string

The string to be evaluated. May also be a function.

bindTo object <optional>

Optional. The object the function call will be bound to ('this' will be whatever 'bindTo' is).

args * <optional>
<repeatable>

Optional. Arguments to be passed.

Examples
// Optimized: results in alert.apply(null, 'hello');
rgjs.utils.evalf('alert', null, 'hello');
// Non-optimized: results in eval('alert()');
rgjs.utils.evalf('alert()');
// Function
rgjs.utils.evalf(function(){ alert(); });

<static> unique( [adv] [, prefix] [, suffix])

Get a unique ID.

Parameters:
Name Type Argument Default Description
adv boolean <optional>

If true, will try to create an actual unique id.

prefix string <optional>
''

Optional. You may provide a prefix.

suffix string <optional>
''

Optional. You may provide a suffix.

Returns:
Type
string
Examples
// Simple unique id
rgjs.utils.unique(); // '1'
rgjs.utils.unique(); // '2'
// Advanced unique id
rgjs.utils.unique(true); // '3c9db38c-c664-42fa-8e9f-d9521bb167b9-0'

<inner> getUniqueId()

Get a unique ID.
Alias of unique().

See:
  • rgjs/utils/unique