From a01406ab0d347b5a1a9a0f59395fe6d464b0f962 Mon Sep 17 00:00:00 2001 From: Joe Wollard Date: Tue, 10 May 2016 21:38:10 -0400 Subject: [PATCH] Version bump + soft tabs. --- package.json | 2 +- simple-plist.js | 135 ++++++++++++++++++++++++------------------------ 2 files changed, 68 insertions(+), 69 deletions(-) diff --git a/package.json b/package.json index 290fbd5..271ee0c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/wollardj/node-simple-plist.git" }, - "version": "0.0.4", + "version": "0.1.4", "description": "A wrapper utility for interacting with plist data.", "main": "simple-plist.js", "keywords": [ diff --git a/simple-plist.js b/simple-plist.js index 29c1b8d..850b3e8 100644 --- a/simple-plist.js +++ b/simple-plist.js @@ -1,7 +1,7 @@ var bplistParser = require('bplist-parser'), - bplistCreator = require('bplist-creator'), - plist = require('plist'), - fs = require('fs'); + bplistCreator = require('bplist-creator'), + plist = require('plist'), + fs = require('fs'); // reveal the underlying modules exports.plist = plist; @@ -9,95 +9,94 @@ exports.bplistCreator = bplistCreator; exports.bplistParser = bplistParser; -// Parses the given file and returns its contents as a native JavaScript object. +// Parses the given file and returns its contents as a native JavaScript +// object. exports.readFileSync = function(aFile) { - var contents = fs.readFileSync(aFile); + var contents = fs.readFileSync(aFile); - if (contents.length === 0) { - console.error("Unable to read file '%s'", aFile); - return {}; - } - return exports.parse(contents, aFile); + if (contents.length === 0) { + console.error("Unable to read file '%s'", aFile); + return {}; + } + return exports.parse(contents, aFile); }; exports.readFile = function(aFile, callback) { - var results; - - fs.readFile(aFile, function(err, contents){ - if (err) { - callback(err); - } - else { - - try { - results = exports.parse(contents, aFile); - callback(null,results); - } - catch(err) { - callback(err); - } - - } - }); + var results; + + fs.readFile(aFile, function(err, contents){ + if (err) { + callback(err); + } + else { + try { + results = exports.parse(contents, aFile); + callback(null,results); + } + catch(err) { + callback(err); + } + } + }); } exports.writeFileSync = function(aFile, anObject, options) { - var data = plist.build(anObject); - fs.writeFileSync(aFile, data, options); + var data = plist.build(anObject); + fs.writeFileSync(aFile, data, options); }; exports.writeFile = function(aFile, anObject, options, callback) { - if (arguments.length === 3 && typeof options === 'function') { - callback = options; - options = undefined; - } - var data = plist.build(anObject); - fs.writeFile(aFile, data, options, callback); + if (arguments.length === 3 && typeof options === 'function') { + callback = options; + options = undefined; + } + var data = plist.build(anObject); + fs.writeFile(aFile, data, options, callback); }; exports.writeBinaryFileSync = function(aFile, anObject, options) { - var data = bplistCreator(anObject); - fs.writeFileSync(aFile, data, options); + var data = bplistCreator(anObject); + fs.writeFileSync(aFile, data, options); }; exports.writeBinaryFile = function(aFile, anObject, options, callback) { - if (arguments.length === 3 && typeof options === 'function') { - callback = options; - options = undefined; - } + if (arguments.length === 3 && typeof options === 'function') { + callback = options; + options = undefined; + } - var data = bplistCreator(anObject); - fs.writeFile(aFile, data, options, callback); + var data = bplistCreator(anObject); + fs.writeFile(aFile, data, options, callback); }; exports.stringify = function(anObject) { - return plist.build(anObject); + return plist.build(anObject); }; exports.parse = function(aStringOrBuffer, aFile) { - var results, - firstByte = aStringOrBuffer[0]; - try { - if (firstByte === 60 || firstByte === '<') { - results = plist.parse(aStringOrBuffer.toString()); - } - else if (firstByte === 98) { - results = bplistParser.parseBuffer(aStringOrBuffer)[0]; - } - else { - if (aFile != undefined) { - console.error("Unable to determine format for '%s'", aFile); - } - else { - console.error("Unable to determine format for plist aStringOrBuffer: '%s'", aStringOrBuffer); - } - results = {}; - } - } - catch(e) { - throw Error("'%s' has errors", aFile); - } - return results; + var results, + firstByte = aStringOrBuffer[0]; + try { + if (firstByte === 60 || firstByte === '<') { + results = plist.parse(aStringOrBuffer.toString()); + } + else if (firstByte === 98) { + results = bplistParser.parseBuffer(aStringOrBuffer)[0]; + } + else { + if (aFile != undefined) { + console.error("Unable to determine format for '%s'", aFile); + } + else { + console.error("Unable to determine format for plist aStringOrBuffer: '%s'", aStringOrBuffer); + } + results = {}; + } + } + catch(e) { + throw Error("'%s' has errors", aFile); + } + return results; }