Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace some of lodash with native functions #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/encoder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

const flattenDeep = require('lodash/flattenDeep')

// Indexes are hexadecimal to make reading the binary output easier.
const valueTypes = {
zero: 0x00,
Expand Down Expand Up @@ -167,7 +165,7 @@ function buildBuffer (numberOrArray) {
return byte
}

const array = flattenDeep(numberOrArray)
const array = numberOrArray.flat(Infinity)
const buffers = new Array(array.length)
let byteLength = 0
for (const [index, element] of array.entries()) {
Expand Down
3 changes: 0 additions & 3 deletions lib/hasLength.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict'

const isLength = require('lodash/isLength')

const hop = Object.prototype.hasOwnProperty

function hasLength (obj) {
return (
Array.isArray(obj) ||
(hop.call(obj, 'length') &&
isLength(obj.length) &&
(obj.length === 0 || '0' in obj))
)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/themeUtils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const cloneDeep = require('lodash/cloneDeep')
const merge = require('lodash/merge')
const cloneDeep = require('lodash.clonedeep')
const merge = require('lodash.merge')

const pluginRegistry = require('./pluginRegistry')

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"esutils": "^2.0.3",
"fast-diff": "^1.2.0",
"js-string-escape": "^1.0.1",
"lodash": "^4.17.15",
"lodash.clonedeep": "^4.5.0",
"lodash.merge": "^4.6.2",
"md5-hex": "^3.0.1",
"semver": "^7.3.2",
"well-known-symbols": "^2.0.0"
Expand Down