Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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";
}
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;
}