@@ -5,21 +5,31 @@ var through = require('through2');
55 * of the plotly.js bundles
66 */
77
8- var attributeNamesToRemove = [
9- 'description' , 'requiredOpts' , 'otherOpts' , 'hrName' , 'role'
10- ] ;
118
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+ }
1718
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+ }
2023
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 ( '|' ) ;
2333
2434var regex = new RegExp ( regexStr , 'g' ) ;
2535
0 commit comments