How to use the @hpcc-js/util.isArray function in @hpcc-js/util

To help you get started, we’ve selected a few @hpcc-js/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hpcc-systems / Visualization / packages / common / src / Utility.ts View on Github external
if (arguments.length === 2 && typeof arguments[1] === "object") {
        args = arguments[1];
    } else {
        args = new Array(arguments.length - 1);
        for (let i = 1; i < arguments.length; ++i) {
            args[i - 1] = arguments[i];
        }
    }

    if (!args || !args.hasOwnProperty) {
        args = {};
    }

    //  Array handling
    for (const key in args) {
        if (isArray(args[key])) {
            args[key].forEach(function (row, idx) {
                args[key + "[" + idx + "]"] = row;
            });
        }
    }

    return tpl
        .replace(nargs2, function replaceArg(match, i) {
            const result = args.hasOwnProperty(i) ? args[i] : null;
            if (result === null || result === undefined) {
                return match;
            }
            return removeHTMLFromString(result);
        })
        .replace(nargs, function replaceArg(match, i, index) {
            const result = args.hasOwnProperty(i) ? args[i] : null;
github hpcc-systems / Visualization / packages / marshaller / src / ddl2 / activities / databomb.ts View on Github external
private fieldType(field: any): DDL2.IFieldType {
        if (isArray(field)) {
            return "dataset";
        }
        const type = typeof field;
        switch (type) {
            case "boolean":
            case "number":
            case "string":
            case "object":
                return type;
        }
        return "string";
    }
github hpcc-systems / Visualization / packages / marshaller / src / ddl2 / javascriptadapter.ts View on Github external
private joinWithPrefix(props: DDL2.IWidgetProperties, imports: Imports, joinStr: string, postFix: string): string {
        let retVal: string = "";
        let meta: ClassMeta;
        if (props.__class) {
            meta = classID2Meta(props.__class);
            imports.append(meta);
            retVal += `new ${meta.class}()`;
        }
        for (const prop in props) {
            if (prop === "__class") {
            } else if (isArray(props[prop])) {
                const arr = `${(props[prop] as any[]).map(item => this.joinWithPrefix(item, imports, joinStr + "        ", "")).join(`,${joinStr}        `)}`;
                if (arr) {
                    retVal += `${joinStr}    .${prop}([${joinStr}        ${arr}${joinStr}    ])${postFix}`;
                }
            } else {
                retVal += `${joinStr}    .${prop}(${JSON.stringify(props[prop])})${postFix}`;
            }
        }
        return retVal;
    }