object-stream-infer-types

0.0.2 • Public • Published

object-stream-infer-types

Infer the types of keys from a stream of objects using datalib's type inference:

var infer = require('object-stream-infer-types');
var streamify = require('array-stream');

// assuming an object stream, such as:
var stream = streamify([
  {x: '1', y: 'foo', z: '1/1/2010'},
  {x: '2', y: 'bar', z: '5/5/2015'},
  // etc.
]);

stream
  .pipe(infer())
  // the stream emits an 'infer' event before sending any data
  .on('infer', function(types) {
    // types is an object, namely:
    // {x: 'integer', y: 'string', z: 'date'}
  })
  .on('data', function(d) {
    // coerce your data accordingly
  });

Readme

Keywords

none

Package Sidebar

Install

npm i object-stream-infer-types

Weekly Downloads

0

Version

0.0.2

License

CC0-1.0

Last publish

Collaborators

  • shawnbot