Home Reference Source Repository
import TsugiUtils from 'tsugi-node/src/util/TsugiUtils.js'
public class | source

TsugiUtils

Utilities to avoid repeating ourselves.

Static Method Summary

Static Public Methods
public static

copy(to: *, to_key: *, from: *, from_key: *, from_key_2: *)

Copy a property from one list to another

public static

emptyPromise(val: mixed): *

Generate an empty Promise NodeJS style

public static

emptyPromiseFail(val: mixed): *

Generate an empty Promise NodeJS style

public static

isset(v: *): boolean

Mimic the PHP isset

public static

requestUrl(req: dsdsljk): *

Get the full url for the request

public static

toNull(v: *): *

Reduce non real values to null

public static

Reduce non real values to null for an object

public static

trimToNull(v: *): *

Reduce non real values and empty strings to null

public static

Static Public Methods

public static copy(to: *, to_key: *, from: *, from_key: *, from_key_2: *) source

Copy a property from one list to another

Params:

NameTypeAttributeDescription
to *
to_key *
from *
from_key *
  • optional
  • default: null
from_key_2 *
  • optional
  • default: null

public static emptyPromise(val: mixed): * source

Generate an empty Promise NodeJS style

Params:

NameTypeAttributeDescription
val mixed

The value to resolve with

Return:

*

public static emptyPromiseFail(val: mixed): * source

Generate an empty Promise NodeJS style

Params:

NameTypeAttributeDescription
val mixed

The value to reject with

Return:

*

public static isset(v: *): boolean source

Mimic the PHP isset

Params:

NameTypeAttributeDescription
v *

Return:

boolean

public static requestUrl(req: dsdsljk): * source

Get the full url for the request

Params:

NameTypeAttributeDescription
req dsdsljk

The http request object

Return:

*

public static toNull(v: *): * source

Reduce non real values to null

Params:

NameTypeAttributeDescription
v *

Return:

*

public static toNullAll(v: object) source

Reduce non real values to null for an object

Params:

NameTypeAttributeDescription
v object

public static trimToNull(v: *): * source

Reduce non real values and empty strings to null

Params:

NameTypeAttributeDescription
v *

Return:

*

public static unitTesting(): * source

Return:

*