How to use the adaptive-expressions.FunctionUtils function in adaptive-expressions

To help you get started, we’ve selected a few adaptive-expressions 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 microsoft / BotBuilder-Samples / experimental / generation / generator / packages / library / src / substitutions.ts View on Github external
if (!generated.has(newline)) {
                                generated.add(newline)
                                result.push(newline)
                                tries = 0
                            }
                        } while (tries > 0)
                    }
                } while (!increment(state))
            }
        }
    }
    return result.join(os.EOL)
}

export let SubstitutionsEvaluator = new expr.ExpressionEvaluator('substitutions',
    expr.FunctionUtils.apply(
        args => {
            let path = args[0]
            let bindings = args[1]
            let replications = args.length > 2 ? args[2] : undefined
            let seed = args.length > 3 ? args[3] : undefined
            return substitutions(path, bindings, replications, seed)
        },
        (val, expr, pos) => {
            let error
            switch (pos) {
                case 0:
                    if (typeof val !== 'string') error = `${expr} does not have a path.`
                    break
                case 1:
                    if (typeof val !== 'object') error = `${expr} does not have bindings.`
                    break;
github microsoft / BotBuilder-Samples / experimental / generation / generator / packages / library / src / substitutions.ts View on Github external
    e => expr.FunctionUtils.validateOrder(e,
        [expr.ReturnType.Number, expr.ReturnType.String],
        expr.ReturnType.String,
        expr.ReturnType.Object))