@@ -5,21 +5,31 @@ var through = require('through2');
5
5
* of the plotly.js bundles
6
6
*/
7
7
8
- var attributeNamesToRemove = [
9
- 'description' , 'requiredOpts' , 'otherOpts' , 'hrName' , 'role'
10
- ] ;
11
8
12
- // ref: http://www.regexr.com/3cmac
13
- var regexStr = '' ;
14
- attributeNamesToRemove . forEach ( function ( attr , i ) {
15
- // one line string with or without trailing comma
16
- regexStr += attr + ': \'.*\'' + ',?' + '|' ;
9
+ // one line string with or without trailing comma
10
+ function makeStringRegex ( attr ) {
11
+ return attr + ': \'.*\'' + ',?' ;
12
+ }
13
+
14
+ // joined array of strings with or without trailing comma
15
+ function makeJoinedArrayRegex ( attr ) {
16
+ return attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?' ;
17
+ }
17
18
18
- // joined array of strings with or without trailing comma
19
- regexStr += attr + ': \\[[\\s\\S]*?\\]\\.join\\(.*' + ',?' ;
19
+ // array with or without trailing comma
20
+ function makeArrayRegex ( attr ) {
21
+ return attr + ': \\[[\\s\\S]*?\\]' + ',?' ;
22
+ }
20
23
21
- if ( i !== attributeNamesToRemove . length - 1 ) regexStr += '|' ;
22
- } ) ;
24
+ // ref: http://www.regexr.com/3cmac
25
+ var regexStr = [
26
+ makeStringRegex ( 'description' ) ,
27
+ makeJoinedArrayRegex ( 'description' ) ,
28
+ makeArrayRegex ( 'requiredOpts' ) ,
29
+ makeArrayRegex ( 'otherOpts' ) ,
30
+ makeStringRegex ( 'hrName' ) ,
31
+ makeStringRegex ( 'role' )
32
+ ] . join ( '|' ) ;
23
33
24
34
var regex = new RegExp ( regexStr , 'g' ) ;
25
35
0 commit comments