diff --git a/index.js b/index.js index 730186b..94f7cc4 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,5 @@ -var json = typeof JSON !== undefined ? JSON : require('jsonify'); -var map = require('array-map'); -var filter = require('array-filter'); -var reduce = require('array-reduce'); - exports.quote = function (xs) { - return map(xs, function (s) { + return xs.map(function (s) { if (s && typeof s === 'object') { return s.op.replace(/(.)/g, '\\$1'); } @@ -36,13 +31,13 @@ for (var i = 0; i < 4; i++) { exports.parse = function (s, env, opts) { var mapped = parse(s, env, opts); if (typeof env !== 'function') return mapped; - return reduce(mapped, function (acc, s) { + return mapped.reduce(function (acc, s) { if (typeof s === 'object') return acc.concat(s); var xs = s.split(RegExp('(' + TOKEN + '.*?' + TOKEN + ')', 'g')); if (xs.length === 1) return acc.concat(xs[0]); - return acc.concat(map(filter(xs, Boolean), function (x) { + return acc.concat(xs.filter(Boolean).map(function (x) { if (RegExp('^' + TOKEN).test(x)) { - return json.parse(x.split(TOKEN)[1]); + return JSON.parse(x.split(TOKEN)[1]); } else return x; })); @@ -54,13 +49,13 @@ function parse (s, env, opts) { '(' + CONTROL + ')', // control chars '(' + BAREWORD + '|' + SINGLE_QUOTE + '|' + DOUBLE_QUOTE + ')*' ].join('|'), 'g'); - var match = filter(s.match(chunker), Boolean); + var match = s.match(chunker).filter(Boolean); var commented = false; if (!match) return []; if (!env) env = {}; if (!opts) opts = {}; - return map(match, function (s, j) { + return match.map(function (s, j) { if (commented) { return; } @@ -192,7 +187,7 @@ function parse (s, env, opts) { if (r === undefined) r = ''; if (typeof r === 'object') { - return pre + TOKEN + json.stringify(r) + TOKEN; + return pre + TOKEN + JSON.stringify(r) + TOKEN; } else return pre + r; } diff --git a/package.json b/package.json index 1b98b28..716e911 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,5 @@ "url": "http://substack.net" }, "license": "MIT", - "dependencies": { - "jsonify": "~0.0.0", - "array-filter": "~0.0.0", - "array-reduce": "~0.0.0", - "array-map": "~0.0.0" - } + "dependencies": {} }