Skip to content

shawnbot/object-stream-infer-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  });

About

Infer the key types from a stream of objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published