-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
40 lines (33 loc) · 819 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*!
* expand-braces <https://github.com/jonschlinkert/expand-braces>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*/
'use strict';
var braces = require('braces');
var uniq = require('array-unique');
var slice = require('array-slice');
module.exports = function expand(array) {
var args = slice(arguments);
var fn;
if (typeof args[args.length - 1] === 'function') {
fn = args.pop();
}
var len = args.length;
var arr = [];
var i = 0;
while (i < len) {
var current = args[i++];
if (Array.isArray(current)) {
var clen = current.length;
var j = 0;
while (j < clen) {
arr.push.apply(arr, braces(current[j++], fn));
}
} else {
arr.push.apply(arr, braces(current, fn));
}
}
return uniq(arr);
};