Security update for permissions_by_term
[yaffs-website] / node_modules / expand-range / index.js
1 /*!
2  * expand-range <https://github.com/jonschlinkert/expand-range>
3  *
4  * Copyright (c) 2014-2015, Jon Schlinkert.
5  * Licensed under the MIT license.
6  */
7
8 'use strict';
9
10 var fill = require('fill-range');
11
12 module.exports = function expandRange(str, options, fn) {
13   if (typeof str !== 'string') {
14     throw new TypeError('expand-range expects a string.');
15   }
16
17   if (typeof options === 'function') {
18     fn = options;
19     options = {};
20   }
21
22   if (typeof options === 'boolean') {
23     options = {};
24     options.makeRe = true;
25   }
26
27   // create arguments to pass to fill-range
28   var opts = options || {};
29   var args = str.split('..');
30   var len = args.length;
31   if (len > 3) { return str; }
32
33   // if only one argument, it can't expand so return it
34   if (len === 1) { return args; }
35
36   // if `true`, tell fill-range to regexify the string
37   if (typeof fn === 'boolean' && fn === true) {
38     opts.makeRe = true;
39   }
40
41   args.push(opts);
42   return fill.apply(null, args.concat(fn));
43 };