UNPKG

317 BJavaScriptView Raw
1const no = require('not-defined')
2
3/**
4 * Extract data attribute, if any, and check it
5 *
6 * @param {*} arg
7 *
8 * @returns {*} data
9 */
10
11function toData (arg) {
12 var data
13
14 if (no(arg.data)) data = arg
15 else data = arg.data
16
17 if (no(data)) throw new TypeError('No data')
18
19 return data
20}
21
22module.exports = toData