Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

askro

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

askro - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

.npmignore

32

lib/config.js

@@ -7,19 +7,19 @@ 'use strict';

/**
* Just parameters, used internally
* @enum
* @type {{
* LAST_MEASUREMENTS_URL: string,
* DAY: number, WEEK: number,
* MONTH: number,
* FIVE_DAYS_IN_MILLISECONDS: number,
* NINETY_DAYS_IN_MILLISECONDS: number,
* MILLISECONDS_IN_TWENTY_FOUR_HOURS: number,
* buildSensorMeasurementsUrl: (Function|string|_.TemplateExecutor|any),
* buildSensorMeasurementsParametrizedUrl: (Function|string|_.TemplateExecutor|any),
* userAgent: string,
* concurrent: number
* }}
*/
module.exports = {
/**
* Just parameters, used internally
* @enum
* @type {{
* LAST_MEASUREMENTS_URL: string,
* DAY: number, WEEK: number,
* MONTH: number,
* FIVE_DAYS_IN_MILLISECONDS: number,
* NINETY_DAYS_IN_MILLISECONDS: number,
* MILLISECONDS_IN_TWENTY_FOUR_HOURS: number,
* buildSensorMeasurementsUrl: (Function|string|_.TemplateExecutor|any),
* buildSensorMeasurementsParametrizedUrl: (Function|string|_.TemplateExecutor|any),
* userAgent: string,
* concurrent: number
* }}
*/
LAST_MEASUREMENTS_URL: 'http://www.russianatom.ru/data_source/last_indications.php',

@@ -26,0 +26,0 @@ DAY: 24,

@@ -50,39 +50,2 @@ 'use strict';

/**
* Stores territory. If there are territory with same Id, it will be replaced
* @param {Territory} territory Territory to store
*/
add: function (territory) {
this.remove(territory.id);
this.territories.push(territory);
},
/**
* Remove territory by it's id
* @param {number} id Id of the Territory
* @returns {boolean} Returns true if there was Territory with provided id and it was deleted, false otherwise
*/
remove: function (id) {
id = Number(id);
var oldLength = this.territories.length;
this.territories = _.filter(this.territories, function iterateThroughTerritories(territory) {
return territory.id !== id;
});
return this.territories.length !== oldLength;
},
/**
* Get territory by it's Id.
* @param {number|string} id Id of the territory
* @returns {Territory|undefined} return Territory instance if it belongs to territory and was found by it's id,
* undefined otherwise
*/
get: function (id) {
id = Number(id);
return _.find(this.territories, function iterateThroughTerritories(territory) {
return territory.id === Number.parseInt(id, 0);
});
},
/**
* Deletes all measurements stored in every sensor in every territory.

@@ -237,2 +200,4 @@ * Leaves territory and sensors untouched.

require('./listInterface')(ListOfTerritories.prototype, 'territories');
module.exports = ListOfTerritories;

@@ -100,2 +100,13 @@ 'use strict';

return request({
url: this.__buildMeasurementsUrl(timeInterval, startDate, endDate, threshold),
userAgent: config.userAgent
}).
spread(this.__parseResponseForMeasurementSeriesRequest.bind(this)).
then(this.__convertParsedDataIntoMeasurementsObjects.bind(this));
},
__buildMeasurementsUrl: function (timeInterval, startDate, endDate, threshold) {
var url;
// get measurements for the last 24 hours by default

@@ -106,4 +117,2 @@ if (!timeInterval) {

var url;
if (startDate && endDate && threshold) {

@@ -125,42 +134,40 @@ url = this.buildSensorMeasurementsParametrizedUrl({

return request({
url: url,
userAgent: config.userAgent
}).
bind(this).
spread(function parseResponseForMeasurementSeriesRequest(response, responseBody) {
if (response.statusCode !== 200) {
throw new Error('Error getting XML for sensor\'s measurements. Status code: ' +
response.statusCode);
}
return url;
},
// parse xml to JS object
var xmlNode = new DOMParser().parseFromString(responseBody);
return simpleConvertXML.getXMLAsObj(xmlNode);
}).
then(function convertParsedDataIntoMeasurementsObjects(data) {
if (data.response.status !== 'ok') {
throw new Error('XML data for sensor\'s measurements is not ok. Status: ' + data.response.status);
}
__convertParsedDataIntoMeasurementsObjects: function (data) {
if (data.response.status !== 'ok') {
throw new Error('XML data for sensor\'s measurements is not ok. Status: ' + data.response.status);
}
this.measurements = this.measurements.concat(_.map(data.response.archive.date,
function convertingValueAndDateFromJsonIntoObjects(measurement) {
return this.__convertValueAndTimeFromRawData(measurement);
}, this)
);
this.measurements = this.measurements.concat(_.map(data.response.archive.date,
function convertingValueAndDateFromJsonIntoObjects(measurement) {
return this.__convertValueAndTimeFromRawData(measurement);
}, this)
);
this.measurements = _.uniq(
this.measurements,
true,
this.__measurementIdentity
);
this.measurements = _.uniq(
this.measurements,
true,
this.__measurementIdentity
);
this.measurements = _.sortBy(this.measurements, this.__measurementIdentity);
this.measurements = _.sortBy(this.measurements, this.__measurementIdentity);
this.validate();
this.validate();
return this;
});
return this;
},
__parseResponseForMeasurementSeriesRequest: function (response, responseBody) {
if (response.statusCode !== 200) {
throw new Error('Error getting XML for sensor\'s measurements. Status code: ' +
response.statusCode);
}
// parse xml to JS object
var xmlNode = new DOMParser().parseFromString(responseBody);
return simpleConvertXML.getXMLAsObj(xmlNode);
},
cleanMeasurements: function () {

@@ -205,3 +212,3 @@ this.measurements.length = 0;

* The main part of the sensor data - series of measurement
* Value are measured in in microsieverts, SI μSv
* Value are measured in microsieverts, SI mSv
* @type {Array.<{time: Date, value: number}>}

@@ -216,3 +223,3 @@ */

/**
* Converts time (from UNIX epoch seconds into Date object) and value (from μR to μSv)
* Converts time (from UNIX epoch seconds into Date object) and value (from mR to mSv)
* @param {{time: string, value: string}} rawData

@@ -225,3 +232,3 @@ * @returns {{time: Date, value: number}}

time: new Date(Number.parseInt(rawData.time, 0) * 1000),
// To convert μR to μSv we need to divide by 100.0
// To convert mR to mSv we need to divide by 100.0
value: parseFloat(rawData.value) / 100.0

@@ -228,0 +235,0 @@ };

@@ -98,41 +98,2 @@ 'use strict';

/**
* Get sensor by it's Id.
* @param {string} id Id of the Sensor
* @returns {Sensor|undefined} return Sensor instance if it belongs to territory and was found by it's id,
* undefined otherwise
*/
getSensor: function (id) {
id = String(id);
return _.find(this.sensors, function compareSensorById(sensor) {
return sensor.id === id;
});
},
/**
* Remove sensor by it's id
* @param {string} id Id of the Sensor
* @returns {boolean} Returns true if there was Sensor with provided id and it was deleted, false otherwise
*/
removeSensor: function (id) {
id = String(id);
var oldLength = this.sensors.length;
this.sensors = _.filter(this.sensors, function compareSensorsById(sensor) {
// TODO: remove duplication
return sensor.id !== id;
});
return this.sensors.length !== oldLength;
},
/**
* Stores provided Sensor. If there are sensor with same Id, it will be replaced
* @param {Sensor} sensor
*/
addSensor: function (sensor) {
this.removeSensor(sensor.id);
sensor.territory = this;
this.sensors.push(sensor);
},
cleanMeasurements: function () {

@@ -209,3 +170,5 @@ _.invoke(this.sensors, 'cleanMeasurements');

_.each(rawData.sensors, function (rawSensorData) {
this.addSensor(new Sensor(rawSensorData));
var sensor = new Sensor(rawSensorData);
sensor.territory = this;
this.add(sensor);
}, this);

@@ -239,2 +202,5 @@ }

// mix list itnterface
require('./listInterface')(Territory.prototype, 'sensors');
module.exports = Territory;
{
"name": "askro",
"version": "0.1.5",
"version": "0.1.6",
"description": "This tool allow you to parse, collect and traverse through the radiation monitoring data provided by ROSATOM SARMS(Sectoral Automated Radiation Monitoring System).",

@@ -48,5 +48,4 @@ "main": "index.js",

"nock": "^0.50.0",
"tap-min": "^0.1.0",
"tape": "^3.0.3"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc