Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- createComponents(doc, itemResult, intervals) {
- let components = []
- // Create full component array in buying
- itemResult.components.forEach(entry => {
- // Create component
- let component = {
- name: entry.name,
- avg: null,
- median: null,
- min: Number.POSITIVE_INFINITY,
- max: Number.NEGATIVE_INFINITY,
- offers: {
- count: 0,
- percentage: 0,
- ignore: 0,
- },
- intervals: [],
- requests: [],
- }
- // Fill component with intervals
- for (let i = 0; i < intervals; i++) {
- // Create interval
- let interval = {
- avg: null,
- median: null,
- min: Number.POSITIVE_INFINITY,
- max: Number.NEGATIVE_INFINITY,
- offers: {
- count: 0,
- percentage: 0,
- ignore: 0,
- medianNullStart: -1,
- },
- requests: [],
- }
- // Add interval to component
- component.intervals.push(interval)
- }
- // Push to component array
- components.push(component)
- })
- // Add to buying/selling/combined
- doc.buying.components = doc.buying.components.concat(components)
- doc.selling.components = doc.selling.components.concat(components)
- doc.combined.components = doc.combined.components.concat(components)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement