Skip to content

Commit

Permalink
fix: shrink lodash dependencies a package ignore files
Browse files Browse the repository at this point in the history
  • Loading branch information
makeros committed Oct 21, 2020
1 parent 21b3b3b commit 5f69be2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
logs
*.log
npm-debug.log*

.DS_Store
# Runtime data
pids
*.pid
Expand Down
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ test/
.eslintrc.yml
.gitignore
.npmignore
__mocks__
.vscode/
.circleci/
.DS_Store
4 changes: 2 additions & 2 deletions lib/transformer/custom-gelf.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const _ = require('lodash')
const get = require('lodash.get')

module.exports = function (data, customSchema) {
return Object.entries(customSchema.properties)
.reduce((acc, entry) => {
const sourcePath = entry[1].source ? entry[1].source : entry[0]
acc[entry[0]] = _.get(data, sourcePath, undefined)
acc[entry[0]] = get(data, sourcePath, undefined)
return acc
}, {})
}
3 changes: 1 addition & 2 deletions lib/transformer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ module.exports = function (opts) {

function setMessageField (opts) {
return function (data) {
const msg = data[opts.messageField]
data.msg = data[opts.messageField] ? msg : 'No msg property found or msg is empty'
data.msg = data[opts.messageField] ? data[opts.messageField] : 'No msg property found or msg is empty'
return data
}
}
4 changes: 2 additions & 2 deletions lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const crypto = require('crypto')
const deflate = require('zlib').deflate
const dgram = require('dgram')
const EventEmitter = require('events').EventEmitter
const _ = require('lodash')
const pick = require('lodash.pick')
const utils = require('./utils')

var Transport = function (opts) {
const self = this

self.config = _.pick(opts, ['host', 'port', 'maxChunkSize'])
self.config = pick(opts, ['host', 'port', 'maxChunkSize'])
self.stringify = utils.stringify(opts)

self.on('log', function (gelf) {
Expand Down
13 changes: 12 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"commander": "^3.0.1",
"fast-json-parse": "^1.0.3",
"fast-json-stringify": "^1.15.4",
"lodash": "^4.17.15",
"lodash.get": "^4.4.2",
"lodash.pick": "^4.4.0",
"pump": "^3.0.0",
"readable-stream": "^3.4.0",
"split2": "^3.1.1",
Expand Down

0 comments on commit 5f69be2

Please sign in to comment.