Completed
Push — master ( 9ae94f...036dfa )
by Taavo-Taur
01:13
created

src/index.js   A

Complexity

Total Complexity 5
Complexity/F 5

Size

Lines of Code 48
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 1
dl 0
loc 48
rs 10
wmc 5
mnd 2
bc 4
fnc 1
bpm 4
cpm 5
noi 4

1 Function

Rating   Name   Duplication   Size   Complexity  
B ???.install 0 23 5
1
import {matcher} from 'feathers-commons/lib/utils'
2
3
import Syncer from './syncer'
4
import syncerMixin from './mixin'
5
import {warn} from './utils'
6
7
const defaults = {
8
	driver: Syncer,
9
	idField: 'id',
10
	matcher
11
}
12
13
export default {
14
	/**
15
	 * Install to vue
16
	 *
17
	 * @function
18
	 * @param {Vue} Vue - Vue
19
	 * @param {Object} options - Options
20
	 * @param {Function} [options.driver] - Custom driver to use
1 ignored issue
show
Documentation Bug introduced by
The parameter [options.driver] does not exist. Did you maybe mean options instead?
Loading history...
21
	 * @param {Object} [options.feathers] - Feathers client
1 ignored issue
show
Documentation Bug introduced by
The parameter [options.feathers] does not exist. Did you maybe mean options instead?
Loading history...
22
	 * @param {string} [options.idField] - Default ID field
1 ignored issue
show
Documentation Bug introduced by
The parameter [options.idField] does not exist. Did you maybe mean options instead?
Loading history...
23
	 * @param {Function} [options.matcher] - Matcher creator
1 ignored issue
show
Documentation Bug introduced by
The parameter [options.matcher] does not exist. Did you maybe mean options instead?
Loading history...
24
	 */
25
	install: function (Vue, options = {}) {
26
		const extend = Vue.util.extend
27
		// Deprecation Warning: 0.3
28
		// Deprecate: 0.4
29
		/* istanbul ignore next */
30
		if (options.driverOptions && options.driverOptions.feathers) {
31
			if (process.env.NODE_ENV !== 'production') {
32
				warn('Deprecation warning: driverOptions.feathers to be deprecated in favor of just feathers')
33
			}
34
			options.feathers = options.driverOptions.feathers
35
		}
36
		// Vue 2.0 has util.toObject, but 1.0 doesn't
37
		options = extend(extend({}, defaults), options)
38
39
		if (!('feathers' in options)) {
40
			throw new Error('No feathers instance set in options')
41
		}
42
43
		Vue.$syncer = options
44
		Vue.mixin(syncerMixin(Vue))
45
		// Mixin handling
46
		Vue.config.optionMergeStrategies.sync = Vue.config.optionMergeStrategies.props
47
	}
48
}
49