diff --git a/index.js b/index.js new file mode 100644 index 0000000..d7385ae --- /dev/null +++ b/index.js @@ -0,0 +1,13 @@ +/** + * Parser functions. + */ + +var parserFunctions = require('./lib/parse'); +Object.keys(parserFunctions).forEach(function (k) { exports[k] = parserFunctions[k]; }); + +/** + * Builder functions. + */ + +var builderFunctions = require('./lib/build'); +Object.keys(builderFunctions).forEach(function (k) { exports[k] = builderFunctions[k]; }); diff --git a/lib/build.js b/lib/build.js index e2b9454..83ea557 100644 --- a/lib/build.js +++ b/lib/build.js @@ -1,4 +1,3 @@ - /** * Module dependencies. */ diff --git a/lib/node.js b/lib/node.js deleted file mode 100644 index ac18e32..0000000 --- a/lib/node.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Module dependencies. - */ - -var fs = require('fs'); -var parse = require('./parse'); -var deprecate = require('util-deprecate'); - -/** - * Module exports. - */ - -exports.parseFile = deprecate(parseFile, '`parseFile()` is deprecated. ' + - 'Use `parseString()` instead.'); -exports.parseFileSync = deprecate(parseFileSync, '`parseFileSync()` is deprecated. ' + - 'Use `parseStringSync()` instead.'); - -/** - * Parses file `filename` as a .plist file. - * Invokes `fn` callback function when done. - * - * @param {String} filename - name of the file to read - * @param {Function} fn - callback function - * @api public - * @deprecated use parseString() instead - */ - -function parseFile (filename, fn) { - fs.readFile(filename, { encoding: 'utf8' }, onread); - function onread (err, inxml) { - if (err) return fn(err); - parse.parseString(inxml, fn); - } -} - -/** - * Parses file `filename` as a .plist file. - * Returns a when done. - * - * @param {String} filename - name of the file to read - * @param {Function} fn - callback function - * @api public - * @deprecated use parseStringSync() instead - */ - -function parseFileSync (filename) { - var inxml = fs.readFileSync(filename, 'utf8'); - return parse.parseStringSync(inxml); -} diff --git a/lib/parse.js b/lib/parse.js index 0df6a22..c7709e6 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1,9 +1,7 @@ - /** * Module dependencies. */ -var deprecate = require('util-deprecate'); var DOMParser = require('xmldom').DOMParser; /** @@ -11,10 +9,6 @@ var DOMParser = require('xmldom').DOMParser; */ exports.parse = parse; -exports.parseString = deprecate(parseString, '`parseString()` is deprecated. ' + - 'It\'s not actually async. Use `parse()` instead.'); -exports.parseStringSync = deprecate(parseStringSync, '`parseStringSync()` is ' + - 'deprecated. Use `parse()` instead.'); /** * We ignore raw text (usually whitespace), , @@ -71,52 +65,6 @@ function parse (xml) { return plist; } -/** - * Parses a Plist XML string. Returns an Object. Takes a `callback` function. - * - * @param {String} xml - the XML String to decode - * @param {Function} callback - callback function - * @returns {Mixed} the decoded value from the Plist XML - * @api public - * @deprecated not actually async. use parse() instead - */ - -function parseString (xml, callback) { - var doc, error, plist; - try { - doc = new DOMParser().parseFromString(xml); - plist = parsePlistXML(doc.documentElement); - } catch(e) { - error = e; - } - callback(error, plist); -} - -/** - * Parses a Plist XML string. Returns an Object. - * - * @param {String} xml - the XML String to decode - * @param {Function} callback - callback function - * @returns {Mixed} the decoded value from the Plist XML - * @api public - * @deprecated use parse() instead - */ - -function parseStringSync (xml) { - var doc = new DOMParser().parseFromString(xml); - var plist; - if (doc.documentElement.nodeName !== 'plist') { - throw new Error('malformed document. First element should be '); - } - plist = parsePlistXML(doc.documentElement); - - // if the plist is an array with 1 element, pull it out of the array - if (plist.length == 1) { - plist = plist[0]; - } - return plist; -} - /** * Convert an XML based plist document into a JSON representation. * diff --git a/lib/plist.js b/lib/plist.js deleted file mode 100644 index 00a4167..0000000 --- a/lib/plist.js +++ /dev/null @@ -1,23 +0,0 @@ - -var i; - -/** - * Parser functions. - */ - -var parserFunctions = require('./parse'); -for (i in parserFunctions) exports[i] = parserFunctions[i]; - -/** - * Builder functions. - */ - -var builderFunctions = require('./build'); -for (i in builderFunctions) exports[i] = builderFunctions[i]; - -/** - * Add Node.js-specific functions (they're deprecated…). - */ - -var nodeFunctions = require('./node'); -for (i in nodeFunctions) exports[i] = nodeFunctions[i]; diff --git a/package.json b/package.json index e6592cd..b9b247b 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,11 @@ "parser", "xml" ], - "main": "lib/plist.js", + "main": "index.js", "dependencies": { "base64-js": "1.1.2", "xmlbuilder": "8.2.2", - "xmldom": "0.1.x", - "util-deprecate": "1.0.2" + "xmldom": "0.1.x" }, "devDependencies": { "browserify": "13.0.1",