Skip to content

Commit 2dedbb8

Browse files
committed
fix(standard): standard --fix
1 parent 55a2007 commit 2dedbb8

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

index.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class Duck extends Function {
5252
gf = arg[fns[i]]
5353
if (!gf ||
5454
(gf.hasMethod
55-
? !gf.hasMethod.apply(gf, args)
56-
: typeof gf === 'function')) {
55+
? !gf.hasMethod.apply(gf, args)
56+
: typeof gf === 'function')) {
5757
return false
5858
}
5959
}
@@ -81,7 +81,7 @@ Duck.prototype.isProtocol = true
8181
const Protoduck = module.exports = define(['duck'], {
8282
createGenfun: ['duck', _metaCreateGenfun],
8383
addMethod: ['duck', _metaAddMethod]
84-
}, {name: 'Protoduck'})
84+
}, { name: 'Protoduck' })
8585

8686
const noImplFound = module.exports.noImplFound = genfun.noApplicableMethod
8787

@@ -168,22 +168,22 @@ function defineMethod (duck, name, target, types, impls) {
168168
if (!Object.prototype.hasOwnProperty.call(target, name)) {
169169
// Make a genfun if there's nothing there
170170
const gf = useMetaobject
171-
? duck._metaobject.createGenfun(duck, target, name, null)
172-
: _metaCreateGenfun(duck, target, name, null)
171+
? duck._metaobject.createGenfun(duck, target, name, null)
172+
: _metaCreateGenfun(duck, target, name, null)
173173
target[name] = gf
174174
} else if (typeof target[name] === 'function' && !target[name].isGenfun) {
175175
// Turn non-gf functions into genfuns
176176
const gf = useMetaobject
177-
? duck._metaobject.createGenfun(duck, target, name, target[name])
178-
: _metaCreateGenfun(duck, target, name, target[name])
177+
? duck._metaobject.createGenfun(duck, target, name, target[name])
178+
: _metaCreateGenfun(duck, target, name, target[name])
179179
target[name] = gf
180180
}
181181

182182
const fn = impls[name] || duck._defaultImpls[name]
183183
if (fn) { // checkImpls made sure this is safe
184184
useMetaobject
185-
? duck._metaobject.addMethod(duck, target, name, methodTypes, fn)
186-
: _metaAddMethod(duck, target, name, methodTypes, fn)
185+
? duck._metaobject.addMethod(duck, target, name, methodTypes, fn)
186+
: _metaAddMethod(duck, target, name, methodTypes, fn)
187187
}
188188
}
189189

@@ -256,8 +256,8 @@ function installMethodErrorMessage (proto, gf, target, name) {
256256
proto.name ? `${proto.name}#` : ''
257257
}${name}(${[].map.call(args, typeName).join(', ')}). You must implement ${
258258
proto.name
259-
? formatMethod(proto, name, true)
260-
: `the protocol ${formatMethod(proto, name)} belongs to`
259+
? formatMethod(proto, name, true)
260+
: `the protocol ${formatMethod(proto, name)} belongs to`
261261
} in order to call ${typeName(thisArg)}#${name}(${
262262
[].map.call(args, typeName).join(', ')
263263
}).`
@@ -330,8 +330,8 @@ class Constraint {
330330
const thisType = (
331331
this.thisIdx === 'this' || this.thisIdx == null
332332
)
333-
? target
334-
: types[this.thisIdx]
333+
? target
334+
: types[this.thisIdx]
335335
const parentTypes = this.indices.map(idx => {
336336
if (idx === 'this') {
337337
return target

test/constraints.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const duck = require('..')
77
test('basic constraint definitions', t => {
88
const Functor = duck.define(['f'], {
99
map: ['f']
10-
}, {name: 'Functor'})
10+
}, { name: 'Functor' })
1111

1212
const Apply = duck.define(['b'], {
1313
ap: ['b']
@@ -55,7 +55,7 @@ test('basic constraint definitions', t => {
5555
test('`this` as type identifier', t => {
5656
const Foo = duck.define(['a'], {
5757
frob: ['a']
58-
}, {name: 'Foo'})
58+
}, { name: 'Foo' })
5959
const Bar = duck.define(['b'], {
6060
frab: ['b']
6161
}, {
@@ -94,7 +94,7 @@ test('`this` as type identifier', t => {
9494
test('shorthand constraints', t => {
9595
const Functor = duck.define(['f'], {
9696
map: ['f']
97-
}, {name: 'Functor'})
97+
}, { name: 'Functor' })
9898
const Apply = duck.define(['f'], {
9999
ap: ['f']
100100
}, {

test/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ test('derivation', t => {
3939
const Show = duck.define(['exemplar'], {
4040
show: ['exemplar'],
4141
meh: [function () {}]
42-
}, {name: 'Show'})
42+
}, { name: 'Show' })
4343
t.notOk(Show.isDerivable, 'disallows derivation if any fns have no defaults')
4444
t.throws(() => {
4545
Show.impl(obj, [obj])
4646
}, /Missing implementation for Show#show\(exemplar\)/)
4747

48-
const withShow = {show () { return 'success' }}
48+
const withShow = { show () { return 'success' } }
4949
Show.impl(withShow)
5050
t.equal(withShow.show(), 'success', 'default method used')
5151
t.ok(withShow.show.isGenfun, 'method converted to genfun')
@@ -55,7 +55,7 @@ test('derivation', t => {
5555
test('defines implementations for protocol functions', t => {
5656
const Eq = duck.define(['a'], {
5757
eq: ['a']
58-
}, {name: 'Eq'})
58+
}, { name: 'Eq' })
5959
class Obj {}
6060
Eq.impl(Obj, [Obj], {
6161
eq (a) { return this === a }
@@ -83,7 +83,7 @@ test('errors if too many types specified', t => {
8383
test('treats missing types in impls as Object', t => {
8484
const Foo = duck.define(['a', 'b'], {
8585
frob: ['a', 'b']
86-
}, {name: 'Foo'})
86+
}, { name: 'Foo' })
8787
Foo.impl(Number, [Number], {
8888
frob (n, anything) {
8989
return this + n + anything
@@ -98,15 +98,15 @@ test('treats missing types in impls as Object', t => {
9898
})
9999

100100
test('errors if an extra function is implemented', t => {
101-
const Eq = duck.define(['a'], { eq: ['a'] }, {name: 'Eq'})
101+
const Eq = duck.define(['a'], { eq: ['a'] }, { name: 'Eq' })
102102
t.throws(() => {
103103
Eq.impl(Number, [Number], { eq () {}, extra () {} })
104104
}, /extra\(\) was included in the impl, but is not part of Eq/i)
105105
t.done()
106106
})
107107

108108
test('errors if a function without a default is not implemented', t => {
109-
const Eq = duck.define(['a'], { eq: ['a'] }, {name: 'Eq'})
109+
const Eq = duck.define(['a'], { eq: ['a'] }, { name: 'Eq' })
110110
const obj = {}
111111
t.throws(function () {
112112
Eq.impl(obj, [obj], { })

test/mop.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ test('MOP: createGenfun', t => {
1616
})
1717
const Show = duck.define({
1818
show: []
19-
}, {metaobject})
19+
}, { metaobject })
2020
const obj = {}
21-
Show.impl(obj, {show () { return 'ok' }})
21+
Show.impl(obj, { show () { return 'ok' } })
2222
t.equal(obj.show(), 'ok', 'method defined correctly')
2323
t.deepEqual(obj.show.duck, null, 'no duck property')
2424
t.equal(obj.show.metaProp, 'hello', 'extra prop added to gf')
@@ -36,9 +36,9 @@ test('MOP: addMethod', t => {
3636
})
3737
const Show = duck.define({
3838
show: []
39-
}, {metaobject})
39+
}, { metaobject })
4040
const obj = {}
41-
Show.impl(obj, {show () { return 'ok' }})
41+
Show.impl(obj, { show () { return 'ok' } })
4242
t.equal(obj.show(), 'ok', 'method defined correctly')
4343
})
4444

@@ -54,9 +54,9 @@ test('MOP: Protoduck as metaobject', t => {
5454
})
5555
const Show = duck.define({
5656
show: []
57-
}, {metaobject})
57+
}, { metaobject })
5858
const obj = {}
59-
Show.impl(obj, {show () { return 'ok' }})
59+
Show.impl(obj, { show () { return 'ok' } })
6060
t.equal(obj.show(), 'ok', 'method defined correctly')
6161
t.equal(obj.show.duck, Show, 'duck property is there')
6262
t.ok(true, 'none of the declared methods executed when meta === Protoduck')

0 commit comments

Comments
 (0)