Skip to content

Commit 6fcf032

Browse files
committed
refactor: get rid of lodash
The only used lodash function is `isBoolean` which can easily be self implemented.
1 parent 772c41c commit 6fcf032

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

config/webpack.config.common.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module.exports = merge(base, {
2020
'jsqr': 'jsqr',
2121
'babel-runtime': 'babel-runtime',
2222
'webrtc-adapter': 'webrtc-adapter',
23-
'lodash/isBoolean': 'lodash/isBoolean',
2423
},
2524
plugins: [
2625
new webpack.optimize.UglifyJsPlugin({

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"vue-component",
1313
"qrcode",
1414
"qrcode-reader",
15-
"qrcode-scanner"
15+
"qrcode-scanner",
16+
"webrtc"
1617
],
1718
"license": "MIT",
1819
"main": "dist/vue-qrcode-reader.common.js",
@@ -84,7 +85,6 @@
8485
"dependencies": {
8586
"babel-runtime": "^6.26.0",
8687
"jsqr": "^1.1.0",
87-
"lodash": "^4.17.4",
8888
"webrtc-adapter": "^6.2.1"
8989
}
9090
}

src/components/QrcodeReader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<script>
3434
import { keepScanning } from '../misc/scanner.js'
3535
import Camera from '../misc/camera.js'
36-
import isBoolean from 'lodash/isBoolean'
36+
import { isBoolean } from '../misc/util.js'
3737
import QrcodeDropZone from './QrcodeDropZone.vue'
3838
import CommonAPI from '../mixins/CommonAPI.vue'
3939

src/components/QrcodeStream.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<script>
3333
import { keepScanning } from '../misc/scanner.js'
3434
import Camera from '../misc/camera.js'
35-
import isBoolean from 'lodash/isBoolean'
35+
import { isBoolean, emptyObject } from '../misc/util.js'
3636
import CommonAPI from '../mixins/CommonAPI.vue'
3737
3838
export default {
@@ -47,7 +47,7 @@ export default {
4747
4848
camera: {
4949
type: [Object, Boolean],
50-
default: () => ({}), // empty object
50+
default: emptyObject
5151
},
5252
5353
track: {
@@ -164,6 +164,7 @@ export default {
164164
deep: true,
165165
166166
handler () {
167+
debugger
167168
this.$emit('init', this.init())
168169
},
169170
},

src/misc/util.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
export function isBoolean (value) {
3+
return value === true || value === false
4+
}
5+
6+
export function emptyObject () {
7+
return {}
8+
}

0 commit comments

Comments
 (0)