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');
3
3
4
4
var constants = require ( './util/constants' ) ;
5
5
var plotlyNode = require ( './util/plotly_node' ) ;
6
+ var sortObject = require ( './util/sort_object' ) ;
6
7
7
8
function makeSchema ( plotlyPath , schemaPath ) {
8
9
var Plotly = plotlyNode ( plotlyPath ) ;
9
10
10
- var plotSchema = Plotly . PlotSchema . get ( ) ;
11
+ var plotSchema = sortObject ( Plotly . PlotSchema . get ( ) ) ;
11
12
var plotSchemaStr = JSON . stringify ( plotSchema , null , 1 ) ;
12
13
fs . writeFileSync ( schemaPath , plotSchemaStr ) ;
13
14
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