jkuri / macstats

Mac OS X Statistics - Battery, Fans, CPU

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose API

zekenie opened this issue · comments

It would be very useful for me if this package could be required and output could be generated programatically.

I exposed API as you suggested. Please see README for more information.

Maybe if the main script of the package module exported this api as well as being the CLI it would be easier

Oh, and sorry for not reading the readme 😳

The main script purpose is to display the data right away when you need it, without passing any parameters or whatever.
Why it would be easier? You still need to require some script, now you need to include the script located in lib/api.js.
Example:

let API = require('path/to/you/node_modules/macstats/lib/api');

API().then((api) => {
  console.log(api.battery.percentage); 
});

Regards, Jan

The only reason it would be easier is you could say

let macstats = require('macstats');
macstats.then( api => api.battery...

Its not a huge deal, it just would mean I don't have to know the project's folder structure

Ok, you can still fork the repository and make it fit your needs.