File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,12 @@ var path = require('path');
33
44var constants = require ( './util/constants' ) ;
55var plotlyNode = require ( './util/plotly_node' ) ;
6+ var sortObject = require ( './util/sort_object' ) ;
67
78function makeSchema ( plotlyPath , schemaPath ) {
89 var Plotly = plotlyNode ( plotlyPath ) ;
910
10- var plotSchema = Plotly . PlotSchema . get ( ) ;
11+ var plotSchema = sortObject ( Plotly . PlotSchema . get ( ) ) ;
1112 var plotSchemaStr = JSON . stringify ( plotSchema , null , 1 ) ;
1213 fs . writeFileSync ( schemaPath , plotSchemaStr ) ;
1314
Original file line number Diff line number Diff line change 1+ function caseInsensitive ( a , b ) {
2+ return a . toLowerCase ( ) . localeCompare ( b . toLowerCase ( ) ) ;
3+ }
4+
5+ function sortObject ( obj ) {
6+ var allKeys = Object . keys ( obj ) ;
7+ allKeys . sort ( caseInsensitive ) ;
8+
9+ var newObj = { } ;
10+ for ( var i = 0 ; i < allKeys . length ; i ++ ) {
11+ var key = allKeys [ i ] ;
12+ var v = obj [ key ] ;
13+ newObj [ key ] = ( typeof v === 'object' && v !== null && ! ( v instanceof Array ) ) ?
14+ sortObject ( v ) :
15+ newObj [ key ] = v ;
16+ }
17+
18+ return newObj ;
19+ }
20+
21+ module . exports = sortObject ;
You can’t perform that action at this time.
0 commit comments