Giter Club home page Giter Club logo

365-widgets's Introduction

This is the first iteration of the package that can take in a file with sensor readings and reference readings and classify the sensors, based on their type, into several categories according to how precise they are and whether they should be kept or discarded.

The evaluateLogFile function specified in the solution design is exported from index.js.

The basic logic is the following. First, the input string is split into rows of data, each of which is handled in a particular way. The single reference data row is split into indvidual reference readings. For the other 2 types an intermediate object is created. The lines identifying individual sensors are used to add new properties to this object – the sensor name becomes a key in this intermediate object while the sensor type becomes a property on the object representing the value of that key. The lines containing readings for the sensors are used to store these data against the key representing that sensor. Finally, a result object is populated with sensor names as keys and their classification as values (computed based on the sensor's type and the readings – mathjs package is used to take care of the relevant calculations).

On top of that, this current version is able to handle files with some irregularities in the data – in particular, files which do not start with the row with the reference readings and have insufficient data or no data for some sensors. Specifically, any sensor with exactly 1 reading will be put in the "not enough data" category – this of course can and should change and this threshold is chosen for illustration purposes.

In the future versions of this package several improvements could be made:

  • It is currently assumed that rows of data are separated by the new line character (\n). This could change and the relevant regular expression could be put into a separate function and made more flexible.
  • In the same way, some assumptions are currently made about the way the various rows of data are formatted (e.g. for lines that identify sensors). This could change as well and so the relevant regular expressions could become more flexible.
  • The handling of insufficient data should be extracted to a separate method to avoid code duplication.
  • A package like rewire could be introduced to test the functions not exported by the package and so improve the testing coverage and developer experience.
  • TypeScript could and probably should be used to make the code more readable and improve the developer experience, especially as it is dealing with arrays and objects with currently unspecified proeprties.

365-widgets's People

Contributors

ilyafaybisovich avatar

Watchers

Miroslav Paulík avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.