You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
773 B
JavaScript

"use strict";
const { validateOptions } = require("@validatem/core");
const wrapValueAsOption = require("./");
const isFunction = require("@validatem/is-function");
const isString = require("@validatem/is-string");
const required = require("@validatem/required");
function someFunction(_optionsOrHandler) {
let optionsOrHandler = validateOptions(arguments, [
wrapValueAsOption("handler"), {
handler: [ required, isFunction ],
label: [ isString ]
}
]);
console.log(optionsOrHandler);
}
someFunction({
handler: function () { /* function body goes here */ },
label: "Hello world!"
});
// { handler: [Function: handler], label: 'Hello world!' }
someFunction(() => { /* function body goes here */ });
// { handler: [Function] }
someFunction();
// undefined