Skip to content

Commit

Permalink
Merge pull request #51 from TheKnarf/fix/remove-unnessesary-deps
Browse files Browse the repository at this point in the history
Remove some unnecessary lodash dependencies
  • Loading branch information
MunGell authored Sep 6, 2020
2 parents d8b0945 + 7955361 commit 2aaa44a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
"dependencies": {
"loader-utils": "^2.0.0",
"lodash.defaultsdeep": "^4.6.1",
"lodash.foreach": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.isobject": "^3.0.2",
"lodash.set": "^4.3.2",
"posthtml-parser": "^0.4.2"
}
Expand Down
13 changes: 7 additions & 6 deletions src/parse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const get = require('lodash.get');
const set = require('lodash.set');
const isObject = require('lodash.isobject');
const forEach = require('lodash.foreach');
const parser = require('posthtml-parser');

/**
Expand All @@ -15,8 +13,8 @@ module.exports.default = function (content) {

const nodes = parser(content);

forEach(nodes, (node) => {
if (isObject(node) && isCorrectTag(node)) {
nodes.forEach((node) => {
if (typeof node == 'object' && isCorrectTag(node)) {
append(output, [node.tag, getType(node)], getContent(node));
}
});
Expand All @@ -41,7 +39,7 @@ function append(object, path, value) {
* @returns {string}
*/
function getContent(node) {
return get(node, 'content', []).join(' ');
return (node.content || []).join(' ');
}

/**
Expand All @@ -55,7 +53,10 @@ function getType(node) {
style: 'text/css'
};

return get(node, 'attrs.type', tagLoaders[node.tag]);
if(typeof node.attrs == 'undefined' || typeof node.attrs.type == 'undefined')
return tagLoaders[node.tag];

return node.attrs.type;
}

/**
Expand Down

0 comments on commit 2aaa44a

Please sign in to comment.