@dms/io
I/O wrapper for using supplies in Node.js
Last updated 3 years ago by pbinggeser .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @dms/io 
SYNC missed versions from official npm registry.

The official Data Mining & Supply IO wrapper module.

Currently, DMS is in a private beta release and this package requires an active DMS account. Once out of beta, installing and using public supplies will no longer require an account or login prompt. Full documentation and more information can be found in the DMS Docs.

Loading the module:

var supply = require('@dms/io');

The @dms/io wrapper module loads as a function. Calling this function loads and initializes an instance of the Supply class.

Initializing a Supply:

Some examples for loading a supply using the /s/running-numbers supply:

// Using the default options
var mySupply = supply('running-numbers')
// If we have data that looks like this:
var data = [
  {
    id: "ABC",
    number: 10
  },
  {
    id: "ABC",
    number: 12
  },
  {
    id: "ABC",
    number: 15
  }
]


// ... then we might want to add some options
var mySupply = supply('running-numbers', {
    inputs: { // Renaming inputs
      value: "number" 
    },
    parameters: { // tuning parameters
      population: false
    },
    bypass: [ "id" ] // adding bypass fields
  });

supply(name [,options])

  • name - string name of the supply to load

  • options - optional object

    • inputs - object for remapping input names
    • parameters - object for tuning this supply's parameters
    • bypass - array of field names to pass around this supply's logic
    • version - specific version to load, defaults to newest installed

Using a Supply

Data can be sent through a supply as an array of data points, or one point at a time. The loaded supply object will remember whatever is required to mine the next data point. If the data argument is left out, it will default to {}.

Using a supply's $main route

// asynchronously
mySupply(data, function(err, result){
  console.log(err, result);
});

// synchronously
var result = mySupply(data);

Some supplies have multiple routes for data:

Using a supply's custom $on route

// asynchronously
mySupply.$on('routeName', data, function(err, result){
  console.log(err, result);
});

// synchronously
var result = mySupply.$on('routeName', data);

Extra Stuff

// Check how many points a supply has mined
console.log(mySupply.points_mined);

// Access a supply's internal memory
var memory = mySupply.$;

// Get the epoch time the supply was initialized
console.log(mySupply.created_on);

Exporting a supply's current state:

// Extract a supply's memory and settings as a base64 string
var b64 = mySupply.toBase64();

// Extract a supply's memory and settings as an object
var obj = mySupply.toObject();

// Extract a supply's memory and settings as a stringified object
var str = mySupply.toString();

Configuring a supply from an exported state:

// Set a supply's memory and settings from a base64 string
mySupply.fromBase64(b64);

// Set a supply's memory and settings from an object
mySupply.toObject(obj);

// Set a supply's memory and settings from a stringified object
mySupply.toString(str);

Check out https://datamining.supply for more info.

Current Tags

  • 0.9.1                                ...           latest (3 years ago)

13 Versions

  • 0.9.1                                ...           3 years ago
  • 0.9.0                                ...           3 years ago
  • 0.8.7                                ...           3 years ago
  • 0.8.6                                ...           3 years ago
  • 0.8.5                                ...           3 years ago
  • 0.8.3                                ...           3 years ago
  • 0.8.2                                ...           4 years ago
  • 0.8.1                                ...           4 years ago
  • 0.8.0                                ...           4 years ago
  • 0.7.3                                ...           4 years ago
  • 0.7.2                                ...           4 years ago
  • 0.7.1                                ...           4 years ago
  • 0.7.0                                ...           4 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 13
Dependencies (7)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |