forked from videojs/video.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions-customizer.js
49 lines (47 loc) · 1.48 KB
/
options-customizer.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
41
42
43
44
45
46
47
48
49
import _ from 'lodash';
/**
* Customizes _.merge behavior in `gruntOptions` to concatenate
* arrays. This can be overridden on a per-call basis to
*
* @see https://lodash.com/docs#merge
* @function GruntCustomizer
* @private
* @param {Mixed} objectValue
* @param {Mixed} sourceValue
* @return {Object}
*/
function gruntCustomizer(objectValue, sourceValue) {
if (Array.isArray(objectValue)) {
return objectValue.concat(sourceValue);
}
}
/**
* Creates a gruntOptions instance for the specific defaultOptions and gruntCustomizer
*
* @function browserifyGruntOptions
* @private
* @param {Object} [options]
* @param {Function} [customizer=gruntCustomizer]
* If the default array-concatenation behavior is not desireable,
* pass _.noop or a unique customizer (https://lodash.com/docs#merge).
*
* @return {Function}
*/
function gruntOptionsMaker(defaultOptions, gruntCustomizer) {
/**
* Creates a unique object of Browserify Grunt task options.
*
* @function gruntOptions
* @private
* @param {Object} [options]
* @param {Function} [customizer=browserifyGruntCustomizer]
* If the default array-concatenation behavior is not desireable,
* pass _.noop or a unique customizer (https://lodash.com/docs#merge).
*
* @return {Object}
*/
return function gruntOptions(options = null, customizer = gruntCustomizer) {
return _.merge({}, defaultOptions, options, customizer);
}
};
export { gruntCustomizer, gruntOptionsMaker };