UNPKG

2.69 kBMarkdownView Raw
1The official [Data Mining & Supply](https://datamining.supply) IO wrapper module.
2
3Currently, 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](https://datamining.supply/docs).
4
5Loading the module:
6-------------------
7```
8var supply = require('@dms/io');
9```
10The **@dms/io** wrapper module loads as a function. Calling this function loads and initializes an instance of the Supply class.
11
12Initializing a Supply:
13------
14
15Some examples for loading a supply using the [/s/running-numbers](https://datamining.supply/s/running-numbers) supply:
16```
17// Using the default options
18var mySupply = supply('running-numbers')
19```
20
21
22```
23// If we have data that looks like this:
24var data = [
25 {
26 id: "ABC",
27 number: 10
28 },
29 {
30 id: "ABC",
31 number: 12
32 },
33 {
34 id: "ABC",
35 number: 15
36 }
37]
38
39
40// ... then we might want to add some options
41var mySupply = supply('supply-name', {
42 inputs: { // Renaming inputs
43 value: "number"
44 },
45 parameters: { // tuning parameters
46 population: false
47 },
48 bypass: [ "id" ] // adding bypass fields
49 });
50```
51
52#### supply(name [,options])
53- __name__ - string name of the supply to load
54
55- __options__ - optional object
56 - __inputs__ - object for remapping input names
57 - __parameters__ - object for tuning this supply's parameters
58 - __bypass__ - array of field names to pass around this supply's logic
59 - __version__ - specific version to load, defaults to newest installed
60
61---
62
63Using a Supply
64--------
65Data 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 `{}`.
66
67__Using a supply's $main route__
68```
69// asynchronously
70mySupply(data, function(err, result){
71 console.log(err, result);
72});
73
74// synchronously
75var result = mySupply(data);
76```
77
78
79Some supplies have multiple routes for data:
80
81__Using a supply's custom $on route__
82```
83// asynchronously
84mySupply.$on('routeName', data, function(err, result){
85 console.log(err, result);
86});
87
88// synchronously
89var result = mySupply.$on('routeName', data);
90```
91
92**Extra Stuff**
93```
94// Check how many points a supply has mined
95console.log(mySupply.points_mined);
96
97// Access a supply's internal memory
98var memory = mySupply.$;
99
100// Get the epoch time the supply was initialized
101console.log(mySupply.created_on);
102```
103
104Check out [https://datamining.supply](https://datamining.supply) for more info.
\No newline at end of file