name(name) {
        name = resolveFunc(name);
        if (name) {
            if (typeof name === 'string') {
                return /^\s*\*(\s*)$/.test(name) ? name : formatSqlName(name);
            }
            if (typeof name === 'object') {
                const keys = Array.isArray(name) ? name : Object.keys(name);
                if (!keys.length) {
                    throw new Error('Cannot retrieve sql names from an empty array/object.');
                }
                return keys.map(value => {
                    if (!value || typeof value !== 'string') {
                        throw new Error(`Invalid sql name: ${npm.utils.toJson(value)}`);
                    }
                    return formatSqlName(value);
                }).join();
            }
        }
        throw new TypeError(`Invalid sql name: ${npm.utils.toJson(name)}`);
    }
@method formatting.name
@description
Properly escapes an sql name or identifier, fixing double-quote symbols and wrapping the result in double quotes.

Implements a safe way to format $[SQL Names] that neutralizes SQL Injection.

When formatting a query, a variable makes use of this method via modifier `:name` or `~`. See method {@link formatting.format format}.

@param {string|function|array|object} name
SQL name or identifier, or a function that returns it.

The name must be at least 1 character long.

If `name` doesn't resolve into a non-empty string, it throws {@link external:TypeError TypeError} = `Invalid sql name: ...`

If the `name` contains only a single `*` (trailing spaces are ignored), then `name` is returned exactly as is (unescaped).

- If `name` is an Array, it is formatted as a comma-separated list of $[SQL Names]
- If `name` is a non-Array object, its keys are formatted as a comma-separated list of $[SQL Names]

Passing in an empty array/object will throw {@link external:Error Error} = `Cannot retrieve sql names from an empty array/object.`

@returns {string}
The SQL Name/Identifier, properly escaped for compliance with the PostgreSQL standard for $[SQL Names] and identifiers.

@see
{@link formatting.alias alias},
{@link formatting.format format}

@example

// automatically list object properties as sql names:
format('INSERT INTO table(${this~}) VALUES(${one}, ${two})', {
    one: 1,
    two: 2
});
//=> INSERT INTO table("one","two") VALUES(1, 2)