1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | var typeOf = require('kind-of');
|
11 |
|
12 | module.exports = function toPath(args) {
|
13 | if (typeOf(args) !== 'arguments') {
|
14 | args = arguments;
|
15 | }
|
16 | return filter(args).join('.');
|
17 | };
|
18 |
|
19 | function filter(arr) {
|
20 | var len = arr.length;
|
21 | var idx = -1;
|
22 | var res = [];
|
23 |
|
24 | while (++idx < len) {
|
25 | var ele = arr[idx];
|
26 | if (typeOf(ele) === 'arguments' || Array.isArray(ele)) {
|
27 | res.push.apply(res, filter(ele));
|
28 | } else if (typeof ele === 'string') {
|
29 | res.push(ele);
|
30 | }
|
31 | }
|
32 | return res;
|
33 | }
|