Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
418 bytes
|
Line | |
---|
1 | /*!
|
---|
2 | * arr-flatten <https://github.com/jonschlinkert/arr-flatten>
|
---|
3 | *
|
---|
4 | * Copyright (c) 2014-2017, Jon Schlinkert.
|
---|
5 | * Released under the MIT License.
|
---|
6 | */
|
---|
7 |
|
---|
8 | 'use strict';
|
---|
9 |
|
---|
10 | module.exports = function (arr) {
|
---|
11 | return flat(arr, []);
|
---|
12 | };
|
---|
13 |
|
---|
14 | function flat(arr, res) {
|
---|
15 | var i = 0, cur;
|
---|
16 | var len = arr.length;
|
---|
17 | for (; i < len; i++) {
|
---|
18 | cur = arr[i];
|
---|
19 | Array.isArray(cur) ? flat(cur, res) : res.push(cur);
|
---|
20 | }
|
---|
21 | return res;
|
---|
22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.