Skip to content

Commit e31946f

Browse files
authored
Merge pull request #49 from shayneo/install-method
Install method
2 parents 246c0b6 + c3d49e3 commit e31946f

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-fuse",
3-
"version": "2.0.3",
3+
"version": "2.1.0",
44
"description": "A Vue.js pluggin for fuzzy search library, Fuse.js",
55
"author": "Shayne O'Sullivan <shayneosull@gmail.com>",
66
"license": "MIT",

src/index.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import Vue from 'vue'
21
import VueFuse from './components/VueFuse.vue'
32
import Fuse from 'fuse.js'
43

5-
Vue.component(VueFuse.name, VueFuse)
6-
Vue.prototype.$search = function (term, list, options) {
7-
return new Promise(function (resolve, reject) {
8-
var run = new Fuse(list, options)
9-
var results = run.search(term)
10-
resolve(results)
11-
})
4+
function install(Vue) {
5+
Vue.component(VueFuse.name, VueFuse)
6+
Vue.prototype.$search = function (term, list, options) {
7+
return new Promise(function (resolve, reject) {
8+
var run = new Fuse(list, options)
9+
var results = run.search(term)
10+
resolve(results)
11+
})
12+
}
1213
}
13-
export default { VueFuse }
14+
15+
// to be registered via Vue.use() as well as Vue.component()
16+
VueFuse.install = install
17+
18+
// Export component by default
19+
export default VueFuse

0 commit comments

Comments
 (0)