src/index.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 3

Size

Lines of Code 50
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
nc 1
dl 0
loc 50
ccs 11
cts 11
cp 1
cc 0
crap 0
rs 10
noi 0
wmc 3
mnd 1
bc 3
fnc 1
bpm 3
cpm 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A ???.install 0 20 3
1
import filter from 'feathers-query-filters'
2
import {matcher} from 'feathers-commons/lib/utils'
3
4
import aliasesMixinMaker from './aliases'
5
import Syncer from './syncer'
6
import syncerMixin from './mixin'
7
8 8
const defaults = {
9
	aliases: false,
10
	driver: Syncer,
11
	filter,
12
	idField: 'id',
13
	matcher
14
}
15
16
export default {
17
	/**
18
	 * Install to vue
19
	 *
20
	 * @function
21
	 * @param {Vue} Vue - Vue
22
	 * @param {Object} options - Options
23
	 * @param {Function} [options.aliases] - Aliases to enable
24
	 * @param {Function} [options.driver] - Custom driver to use
25
	 * @param {Function} [options.filter] - Query filter parser
26
	 * @param {Object} [options.feathers] - Feathers client
27
	 * @param {string} [options.idField] - Default ID field
28
	 * @param {Function} [options.matcher] - Matcher creator
29
	 */
30
	install(Vue, options = {}) {
31 36
		const extend = Vue.util.extend
32
		// Vue 2.0 has util.toObject, but 1.0 doesn't
33 36
		options = extend(extend({}, defaults), options)
34
35 36
		if (!('feathers' in options)) {
36 1
			throw new Error('No feathers instance set in options')
37
		}
38
39 35
		Vue.$syncer = options
40 35
		Vue.prototype.$feathers = options.feathers
41
42 35
		Vue.mixin(syncerMixin(Vue))
43
		// Mixin handling
44 35
		Vue.config.optionMergeStrategies.sync = Vue.config.optionMergeStrategies.props
45
46 35
		if (options.aliases) {
47 1
			Vue.mixin(aliasesMixinMaker(options.aliases))
48
		}
49
	}
50
}
51