Completed
Push — master ( 1c6c4e...f7d036 )
by Andres
29s
created

build_scripts/generate_exotic_ranges.js   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 35
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
wmc 1
c 1
b 0
f 0
nc 2
mnd 1
bc 1
fnc 0
dl 0
loc 35
rs 10
bpm 0
cpm 0
noi 0
1
/* eslint-env node */
2
/*jslint node: true */
3
'use strict';
4
5
const jsonfile = require('jsonfile');
6
7
let ranges = [];
8
9
let top = 1e6;
10
let magnitude = 1;
11
let maxValue = 10;
12
13
let range = {};
14
range.top = top;
15
range.range = top;
16
range.max_value = 0;
17
range.midpoint = top/2;
18
let prev = top;
19
top *= Math.pow(10, magnitude);
20
magnitude++;
21
ranges.push(range);
22
while(top < Infinity){
23
  range = {};
24
  range.top = top;
25
  range.range = top-prev;
26
  range.max_value = maxValue;
27
  range.midpoint = range.range/2+prev;
28
  prev = top;
29
  maxValue *= 10;
30
  top *= Math.pow(10, magnitude);
31
  magnitude++;
32
  ranges.push(range);
33
}
34
35
jsonfile.writeFileSync('build/data/exotic_ranges.json', ranges, {
36
  spaces: 2
37
});
38