{"size": 882, "ext": "js", "max_stars_repo_path": "build/lib/write.js", "max_stars_repo_name": "Aweary/node-todo", "max_stars_repo_stars_event_min_datetime": "2015-07-27T00:24:36.000Z", "max_stars_repo_stars_event_max_datetime": "2015-07-27T00:24:36.000Z", "max_issues_repo_path": "build/lib/write.js", "max_issues_repo_name": "Aweary/node-todo", "max_issues_repo_issues_event_min_datetime": "2015-07-27T00:19:04.000Z", "max_issues_repo_issues_event_max_datetime": "2015-09-19T23:31:43.000Z", "max_forks_repo_path": "build/lib/write.js", "max_forks_repo_name": "Aweary/node-todo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 21.0, "max_line_length": 97, "alphanum_fraction": 0.6723356009}
'use strict';

Object.defineProperty(exports, '__esModule', {
  value: true
});
exports['default'] = write;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

var _debug = require('debug');

var _debug2 = _interopRequireDefault(_debug);

var _utilJs = require('./util.js');

var debug = (0, _debug2['default'])('todo:write');

/**
* Save the updated task list back to the
* database file.
* @param  {[type]} tasks [description]
* @return {[type]}       [description]
*/

function write(tasks) {

  debug('Writing tasks %o', tasks);
  var source = tasks.path;
  var data = tasks.list;
  var task = tasks.current;

  var stream = _fs2['default'].createWriteStream(source);
  var json = JSON.stringify(data);

  stream.end(json);
}

module.exports = exports['default'];