1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | module.exports = function normalizeKeypath (keypath, isArguments) {
|
10 | if (typeof keypath === 'string') {
|
11 | return keypath.split('.')
|
12 | } else if (isArguments && keypath.length === 1) {
|
13 | if (Array.isArray(keypath[0])) return keypath[0].map(function (k) { return '' + k })
|
14 | if (typeof keypath[0] === 'number') return [ '' + keypath[0] ]
|
15 | return ('' + keypath[0]).split('.')
|
16 | } else {
|
17 | if (isArguments) keypath = Array.prototype.slice.call(keypath)
|
18 | return keypath.map(function (k) { return '' + k })
|
19 | }
|
20 | }
|