forked from 0x2620/oxjs
check browser version
This commit is contained in:
parent
0e3f49f134
commit
a2dfb0367d
2 changed files with 39 additions and 32 deletions
|
|
@ -329,24 +329,6 @@ Ox.filter = function(obj, fn) {
|
|||
return ret;
|
||||
};
|
||||
|
||||
Ox.flatten = function(arr) {
|
||||
/*
|
||||
>>> Ox.flatten([1, [2, [3], 4], 5])
|
||||
[1, 2, 3, 4, 5]
|
||||
*/
|
||||
var ret = [];
|
||||
arr.forEach(function(v) {
|
||||
if (Ox.isArray(v)) {
|
||||
Ox.flatten(v).forEach(function(v) {
|
||||
ret.push(v);
|
||||
});
|
||||
} else {
|
||||
ret.push(v);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
Ox.find = function(arr, str) {
|
||||
/*
|
||||
returns an array with two arrays as elements:
|
||||
|
|
@ -367,6 +349,24 @@ Ox.find = function(arr, str) {
|
|||
return ret;
|
||||
};
|
||||
|
||||
Ox.flatten = function(arr) {
|
||||
/*
|
||||
>>> Ox.flatten([1, [2, [3], 4], 5])
|
||||
[1, 2, 3, 4, 5]
|
||||
*/
|
||||
var ret = [];
|
||||
arr.forEach(function(v) {
|
||||
if (Ox.isArray(v)) {
|
||||
Ox.flatten(v).forEach(function(v) {
|
||||
ret.push(v);
|
||||
});
|
||||
} else {
|
||||
ret.push(v);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
Ox.forEach = function(obj, fn) {
|
||||
/*
|
||||
Ox.forEach() works for arrays, objects and strings,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue