ad04d07366a5b7dd56e1e5fd9324265ac45bc37c
[platform/framework/web/crosswalk-tizen.git] /
1 define(['./kindOf', './GLOBAL'], function (kindOf, GLOBAL) {
2
3     /**
4      * Convert array-like object into array
5      */
6     function toArray(val){
7         var ret = [],
8             kind = kindOf(val),
9             n;
10
11         if (val != null) {
12             if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === GLOBAL ) {
13                 //string, regexp, function have .length but user probably just want
14                 //to wrap value into an array..
15                 ret[ret.length] = val;
16             } else {
17                 //window returns true on isObject in IE7 and may have length
18                 //property. `typeof NodeList` returns `function` on Safari so
19                 //we can't use it (#58)
20                 n = val.length;
21                 while (n--) {
22                     ret[n] = val[n];
23                 }
24             }
25         }
26         return ret;
27     }
28     return toArray;
29 });