Replace lodash with ramda.

This commit is contained in:
Alexandre Gigliotti
2015-09-21 10:16:38 -07:00
parent dad1267607
commit 99eed58f96
4 changed files with 16 additions and 13 deletions

View File

@@ -1,17 +1,18 @@
var _ = require('lodash');
var co = require('co'); var co = require('co');
var cheerio = require('cheerio'); var cheerio = require('cheerio');
var fs = require('mz/fs'); var fs = require('mz/fs');
var inlineStyle = require('./inline-style'); var inlineStyle = require('./inline-style');
var inlineImg = require('./inline-img'); var inlineImg = require('./inline-img');
var inlineLinkLess = require('./inline-link-less'); var inlineLinkLess = require('./inline-link-less');
var R = require('ramda');
var Ru = require('@panosoft/ramda-utils');
var inline = co.wrap(function * (html, options) { var inline = co.wrap(function * (html, options) {
options = _.defaults(options || {}, { options = Ru.defaults({
filename: null, filename: null,
less: {}, less: {},
verbose: false verbose: false
}); }, options || {});
var filename; var filename;
try { try {
filename = html; filename = html;
@@ -48,7 +49,7 @@ var inline = co.wrap(function * (html, options) {
var result = { var result = {
html: html, html: html,
files: _.unique(_.flatten(files, true)) files: R.uniq(R.flatten(files, true))
}; };
return (options.verbose ? result : result.html); return (options.verbose ? result : result.html);
}); });

View File

@@ -1,9 +1,9 @@
var _ = require('lodash');
var datauri = require('datauri'); var datauri = require('datauri');
var isLocalPath = require('is-local-path'); var isLocalPath = require('is-local-path');
var path = require('path'); var path = require('path');
var postcss = require('postcss'); var postcss = require('postcss');
var postcssUrl = require('postcss-url'); var postcssUrl = require('postcss-url');
var R = require('ramda');
var url = require('url'); var url = require('url');
/** /**
@@ -15,7 +15,7 @@ var url = require('url');
*/ */
var clean = function (path) { var clean = function (path) {
path = url.parse(path); path = url.parse(path);
path = _.pick(path, ['protocol', 'host', 'pathname']); path = R.pick(['protocol', 'host', 'pathname'], path);
path = url.format(path); path = url.format(path);
path = decodeURI(path); path = decodeURI(path);
return path; return path;

View File

@@ -1,14 +1,15 @@
var _ = require('lodash');
var co = require('co'); var co = require('co');
var cheerio = require('cheerio'); var cheerio = require('cheerio');
var fs = require('mz/fs'); var fs = require('mz/fs');
var isLocalPath = require('is-local-path'); var isLocalPath = require('is-local-path');
var less = require('less'); var less = require('less');
var path = require('path'); var path = require('path');
var R = require('ramda');
var Ru = require('@panosoft/ramda-utils');
var url = require('url'); var url = require('url');
var render = co.wrap(function * (filename, options) { var render = co.wrap(function * (filename, options) {
options = _.assign(options || {}, { options = R.merge(options || {}, {
filename: filename filename: filename
}); });
var contents = yield fs.readFile(filename, 'utf8'); var contents = yield fs.readFile(filename, 'utf8');
@@ -23,9 +24,9 @@ var render = co.wrap(function * (filename, options) {
var inline = co.wrap(function * (html, filename, options) { var inline = co.wrap(function * (html, filename, options) {
var files = []; var files = [];
var basedir = path.dirname(filename); var basedir = path.dirname(filename);
options = _.defaults(options || {}, { options = Ru.defaults({
relativeUrls: true relativeUrls: true
}); }, options || {});
// TODO Import less links // TODO Import less links
// get links // get links
@@ -52,9 +53,9 @@ var inline = co.wrap(function * (html, filename, options) {
}); });
// create list of imported files from all outputs, unique listing // create list of imported files from all outputs, unique listing
files.push(_.map(outputs, function (output) { files.push(R.map(function (output) {
return output.imports; return output.imports;
})); }, outputs));
return { return {
html: $.xml(), html: $.xml(),

View File

@@ -10,15 +10,16 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@panosoft/ramda-utils": "^0.1.12",
"cheerio": "^0.19.0", "cheerio": "^0.19.0",
"co": "^4.6.0", "co": "^4.6.0",
"datauri": "^0.7.1", "datauri": "^0.7.1",
"is-local-path": "^0.1.0", "is-local-path": "^0.1.0",
"less": "^2.5.1", "less": "^2.5.1",
"lodash": "^3.10.0",
"mz": "^2.0.0", "mz": "^2.0.0",
"postcss": "^5.0.0", "postcss": "^5.0.0",
"postcss-url": "^5.0.0", "postcss-url": "^5.0.0",
"ramda": "^0.17.1",
"string": "^3.3.0" "string": "^3.3.0"
}, },
"devDependencies": { "devDependencies": {