Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

Commit ffd3757

Browse files
author
Irfan Maulana
committed
v.1.2.0 add truncate and cut
1 parent 9920519 commit ffd3757

6 files changed

+23
-13
lines changed

VueStringFilter.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,11 @@ const VueStringFilter = {
3838
})
3939

4040
Vue.filter('truncate', function (value, count) {
41-
if (typeof value === 'string') {
42-
return value.length < count ? value : value.slice(0, count) + '...'
43-
} else {
44-
return value
45-
}
41+
value.length < count ? value : value.slice(0, count) + '...'
4642
})
4743

4844
Vue.filter('cut', function (value, count) {
49-
if (typeof value === 'string') {
50-
return value.length < count ? value : value.slice(0, count)
51-
} else {
52-
return value
53-
}
45+
return value.length < count ? value : value.slice(0, count)
5446
})
5547

5648
}

dist/VueStringFilter.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueStringFilter.bundle.js.gz

-7 Bytes
Binary file not shown.

dist/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/VueStringFilter.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ describe('test VueStringFilter', () => {
5454

5555
localVue.use(VueStringFilter)
5656

57+
let wrapper = shallow(App, {
58+
localVue
59+
})
60+
})
61+
it('Test truncate', () => {
62+
let localVue = createLocalVue()
63+
64+
localVue.use(VueStringFilter)
65+
66+
let wrapper = shallow(App, {
67+
localVue
68+
})
69+
})
70+
it('Test cut', () => {
71+
let localVue = createLocalVue()
72+
73+
localVue.use(VueStringFilter)
74+
5775
let wrapper = shallow(App, {
5876
localVue
5977
})

0 commit comments

Comments
 (0)