sweetalert2
Version:
A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert
25 lines (22 loc) • 592 B
JavaScript
import { error } from '../utils/utils.js'
export const argsToParams = (args) => {
const params = {}
switch (typeof args[0]) {
case 'object':
Object.assign(params, args[0])
break
default:
['title', 'html', 'type'].forEach((name, index) => {
switch (typeof args[index]) {
case 'string':
params[name] = args[index]
break
case 'undefined':
break
default:
error(`Unexpected type of ${name}! Expected "string", got ${typeof args[index]}`)
}
})
}
return params
}