UNPKG

objfile

Version:

Read from + write to + update INI and JSON files via a simple asynchronous API

44 lines (34 loc) 1.05 kB
// Generated by CoffeeScript 1.9.1 var IniFile, ObjFile, ini, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; ini = require('ini'); ObjFile = require('../file'); IniFile = (function(superClass) { extend(IniFile, superClass); function IniFile() { return IniFile.__super__.constructor.apply(this, arguments); } IniFile.decode = function(raw, cb) { var err; try { return cb(null, ini.parse(raw)); } catch (_error) { err = _error; return cb(err); } }; IniFile.encode = function(data, cb) { var err; try { return cb(null, ini.stringify(data, { whitespace: true })); } catch (_error) { err = _error; return cb(err); } }; return IniFile; })(ObjFile); module.exports = IniFile;