Skip to content

Commit ba586c2

Browse files
committed
Update to esmodules and ava version
1 parent 10cefab commit ba586c2

16 files changed

Lines changed: 86 additions & 90 deletions

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "dop",
3+
"type": "module",
34
"version": "1.5.4",
45
"main": "dist/dop.js",
56
"browser": "dist/dop.umd.js",
@@ -31,11 +32,10 @@
3132
"server",
3233
"client"
3334
],
34-
"dependencies": {},
3535
"devDependencies": {
3636
"@rollup/plugin-buble": "^0.20.0",
3737
"@rollup/plugin-json": "^4.0.1",
38-
"ava": "^2.4.0",
38+
"ava": "^6.4.1",
3939
"ejson": "^2.2.0",
4040
"esm": "^3.2.25",
4141
"lodash": "^4.17.15",
@@ -56,9 +56,6 @@
5656
"ava": {
5757
"files": [
5858
"!test/utils.js"
59-
],
60-
"require": [
61-
"esm"
6259
]
6360
}
6461
}

test/.addType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import { applyPatch, encode, decode, addType } from '../src'
2+
import { applyPatch, encode, decode, addType } from '../src/index.js'
33
import Splice from '../src/types/Splice'
44
import { getNewPlain } from '../src/util/getset'
55
import { isPlainObject } from '../src/util/is'

test/api.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import test from 'ava'
2-
import dop from '../src'
3-
import { createNode } from '../src'
2+
import dop from '../src/index.js'
43

54
const exported = {
65
version: true,

test/apply_patch.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava'
2-
import { applyPatch, TYPE } from '../src'
3-
import { testPatchUnpatch } from './utils'
2+
import { applyPatch, TYPE } from '../src/index.js'
3+
import { testPatchUnpatch } from './utils.js'
44

55
test('1 / https://tools.ietf.org/html/rfc7386 ', function (t) {
66
const target = { a: 'b' }
@@ -220,8 +220,8 @@ test('basic mutation', function (t) {
220220
})
221221

222222
test('basic mutations', function (t) {
223-
const func1 = () => {}
224-
const func2 = () => {}
223+
const func1 = () => { }
224+
const func2 = () => { }
225225
const target = { number: 1, bool: false, string: 'hello', func: func1 }
226226
const patch = { number: 2, bool: true, string: 'world', func: func2 }
227227
const expected = { number: 2, bool: true, string: 'world', func: func2 }
@@ -365,7 +365,7 @@ test('mutating multiple levels not defineds / inverted', function (t) {
365365
})
366366

367367
test('function to target', function (t) {
368-
const target = { prop: () => {} }
368+
const target = { prop: () => { } }
369369
const patch = { prop: {} }
370370
const expected = { prop: {} }
371371
const fnpatch = (d) => {
@@ -383,7 +383,7 @@ test('function to target', function (t) {
383383
})
384384

385385
test('target to function', function (t) {
386-
const f = () => {}
386+
const f = () => { }
387387
const target = { prop: {} }
388388
const patch = { prop: f }
389389
const expected = { prop: f }
@@ -402,7 +402,7 @@ test('target to function', function (t) {
402402
})
403403

404404
test('plain to noplain', function (t) {
405-
function Foo() {}
405+
function Foo() { }
406406
const instance = new Foo()
407407
instance.prop = 2
408408

@@ -425,7 +425,7 @@ test('plain to noplain', function (t) {
425425
})
426426

427427
test('noplain to plain', function (t) {
428-
function Foo() {}
428+
function Foo() { }
429429
const instance = new Foo()
430430
instance.prop = 2
431431

@@ -605,7 +605,7 @@ test('should assign `undefined` values', function (t) {
605605
})
606606

607607
test('should assign non array/buffer/typed-array/plain-target source values directly', function (t) {
608-
function Foo() {}
608+
function Foo() { }
609609
const values = [
610610
new Foo(),
611611
new Boolean(),

test/create_node.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava'
2-
import { createNode } from '../src'
3-
import { RPC_CREATOR } from '../src/const'
2+
import { createNode } from '../src/index.js'
3+
import { RPC_CREATOR } from '../src/const.js'
44

55
test('Api', async (t) => {
66
const server = createNode()
@@ -59,7 +59,7 @@ test('Callback pattern example', async (t) => {
5959
test('Calling a defined function .message must return true', async (t) => {
6060
const server = createNode()
6161
const client = createNode()
62-
const callClient = server.open(client.message, () => {})
62+
const callClient = server.open(client.message, () => { })
6363
const callServer = client.open((msg) => {
6464
t.is(server.message(msg), true)
6565
})
@@ -79,7 +79,7 @@ test('Calling a not defined function .message must return false', async (t) => {
7979
test('Response (reject or resolve must delete request)', async (t) => {
8080
const server = createNode()
8181
const client = createNode()
82-
server.open(client.message, (v) => {})
82+
server.open(client.message, (v) => { })
8383
const callServer = client.open(server.message)
8484
t.is(Object.keys(client.requests).length, 0)
8585
callServer().then((v) => {
@@ -114,8 +114,8 @@ test('Passing same functions should not create a new one', async (t) => {
114114
)
115115

116116
// Server side
117-
const receiveFromClient = () => {}
118-
const repeated = () => {}
117+
const receiveFromClient = () => { }
118+
const repeated = () => { }
119119
const callClient = server.open(client.message, receiveFromClient)
120120
callClient(repeated, repeated, receiveFromClient)
121121
})
@@ -250,7 +250,7 @@ test('rpc is created if rpcFilter returns the rpc itself', async (t) => {
250250
})
251251
t.is(callClient, n)
252252
const callServer = client.open(server.message)
253-
callServer(() => {})
253+
callServer(() => { })
254254
})
255255

256256
test('rpcFilter API', async (t) => {
@@ -304,9 +304,9 @@ test('rpcFilter API', async (t) => {
304304
server.open(client.message, entryFunction)
305305
const callServer = client.open(server.message)
306306
const objServer = await callServer(() => {
307-
return () => {}
307+
return () => { }
308308
})
309-
objServer.login({ value: 2, fn: () => {} })
309+
objServer.login({ value: 2, fn: () => { } })
310310
})
311311

312312
test('registerRpc & createRpc', async (t) => {

test/create_store.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import { createStore, TYPE } from '../src'
2+
import { createStore, TYPE } from '../src/index.js'
33

44
test('createStore', function (t) {
55
const state = { number: 1 }
@@ -19,8 +19,8 @@ test('createStore', function (t) {
1919
test('subscribe', function (t) {
2020
const state = { prop: true }
2121
const store = createStore(state)
22-
const listener = () => {}
23-
const filter = () => {}
22+
const listener = () => { }
23+
const filter = () => { }
2424
store.subscribe(listener, filter)
2525
t.true(store.listeners.has(listener))
2626
t.is(store.listeners.get(listener), filter)
@@ -33,7 +33,7 @@ test('subscribe', function (t) {
3333
test('unsubscribe from subscribe', function (t) {
3434
const state = { prop: true }
3535
const store = createStore(state)
36-
const listener = () => {}
36+
const listener = () => { }
3737
const unsubscribe = store.subscribe(listener)
3838
t.true(store.listeners.has(listener))
3939
t.is(store.listeners.size, 1)
@@ -45,7 +45,7 @@ test('unsubscribe from subscribe', function (t) {
4545
test('unsubscribe', function (t) {
4646
const state = { prop: true }
4747
const store = createStore(state)
48-
const listener = () => {}
48+
const listener = () => { }
4949
store.subscribe(listener)
5050
t.true(store.listeners.has(listener))
5151
t.is(store.listeners.size, 1)
@@ -58,7 +58,7 @@ test('applyPatch', function (t) {
5858
const state = { prop: false }
5959
const store = createStore(state)
6060
const patch = { prop: true }
61-
const listener = (p) => {}
61+
const listener = (p) => { }
6262
store.subscribe(listener)
6363
const outputs = store.applyPatch(patch)
6464
t.true(Array.isArray(outputs))
@@ -78,7 +78,7 @@ test('applyPatch', function (t) {
7878
test('applyPatch with function', function (t) {
7979
const state = { prop: false }
8080
const store = createStore(state)
81-
const listener = (p) => {}
81+
const listener = (p) => { }
8282
store.subscribe(listener)
8383
const outputs = store.applyPatch((draft) => {
8484
draft.prop = true
@@ -100,7 +100,7 @@ test('subscribe filter', function (t) {
100100
const store = createStore(initialstate)
101101
const patch = { prop: true, newprop: true }
102102
const filter = (mutation) => mutation.prop !== 'newprop'
103-
store.subscribe(() => {}, filter)
103+
store.subscribe(() => { }, filter)
104104
const result = store.applyPatch(patch)
105105
const [output] = result
106106
t.not(output.patch, patch)
@@ -114,11 +114,11 @@ test('subscribe output of applyPatch must return same length that listeners', fu
114114
const store = createStore({ prop: false })
115115
const patch = { prop: true, newprop: true }
116116
store.subscribe(
117-
() => {},
117+
() => { },
118118
() => false
119119
)
120120
store.subscribe(
121-
() => {},
121+
() => { },
122122
() => true
123123
)
124124
const output = store.applyPatch(patch)
@@ -133,11 +133,11 @@ test('filtered patches by createPatchAndUnpatchFromMutations must be the same as
133133
const store = createStore({ params: { a: 1, b: 2 } })
134134
const patch = { params: TYPE.Replace({ c: 3 }) }
135135
store.subscribe(
136-
() => {},
136+
() => { },
137137
() => false
138138
)
139139
store.subscribe(
140-
() => {},
140+
() => { },
141141
() => true
142142
)
143143
const output = store.applyPatch(patch)

test/getset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import { getDeep } from '../src/util/getset'
2+
import { getDeep } from '../src/util/getset.js'
33

44
test('getDeep', function (t) {
55
const object = { first: 1, second: { third: 4 } }

test/merge.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import dop from '../src'
2+
import dop from '../src/index.js'
33
import _ from 'lodash' // https://github.com/lodash/lodash/blob/master/test/merge.test.js
44
import R from 'ramda'
55

@@ -50,7 +50,7 @@ function run(merge, name) {
5050
})
5151

5252
test(name + ': should merge onto function `object` values', function (t) {
53-
function Foo() {}
53+
function Foo() { }
5454

5555
var source = { a: 1 },
5656
actual = merge(Foo, source)
@@ -62,7 +62,7 @@ function run(merge, name) {
6262
test(
6363
name + ': should merge first source object properties to function',
6464
function (t) {
65-
var fn = function () {},
65+
var fn = function () { },
6666
object = { prop: {} },
6767
actual = merge({ prop: fn }, object)
6868

@@ -72,9 +72,9 @@ function run(merge, name) {
7272

7373
test(
7474
name +
75-
': should merge first and second source object properties to function',
75+
': should merge first and second source object properties to function',
7676
function (t) {
77-
var fn = function () {},
77+
var fn = function () { },
7878
object = { prop: {} },
7979
actual = merge({ prop: fn }, { prop: fn }, object)
8080

@@ -85,7 +85,7 @@ function run(merge, name) {
8585
test(
8686
name + ': should not merge onto function values of sources',
8787
function (t) {
88-
var source1 = { a: function () {} },
88+
var source1 = { a: function () { } },
8989
source2 = { a: { b: 2 } },
9090
expected = { a: { b: 2 } },
9191
actual = merge({}, source1, source2)
@@ -99,7 +99,7 @@ function run(merge, name) {
9999
)
100100

101101
test(name + ': should merge onto non-plain `object` values', function (t) {
102-
function Foo() {}
102+
function Foo() { }
103103

104104
var object = new Foo(),
105105
actual = merge(object, { a: 1 })
@@ -128,19 +128,19 @@ function run(merge, name) {
128128

129129
test(
130130
name +
131-
': should assign non array/buffer/typed-array/plain-object source values directly',
131+
': should assign non array/buffer/typed-array/plain-object source values directly',
132132
function (t) {
133-
function Foo() {}
133+
function Foo() { }
134134

135135
var values = [
136-
new Foo(),
137-
new Boolean(),
138-
new Date(),
139-
Foo,
140-
new Number(),
141-
new String(),
142-
new RegExp(),
143-
],
136+
new Foo(),
137+
new Boolean(),
138+
new Date(),
139+
Foo,
140+
new Number(),
141+
new String(),
142+
new RegExp(),
143+
],
144144
expected = _.map(values, () => true)
145145

146146
var actual = _.map(values, function (value) {
@@ -190,7 +190,7 @@ function run(merge, name) {
190190

191191
test(
192192
name +
193-
': should skip merging when `object` and `source` are the same value',
193+
': should skip merging when `object` and `source` are the same value',
194194
function (t) {
195195
var object = {},
196196
pass = true
@@ -213,7 +213,7 @@ function run(merge, name) {
213213

214214
test(
215215
name +
216-
': should convert strings to arrays when merging arrays of `source`',
216+
': should convert strings to arrays when merging arrays of `source`',
217217
function (t) {
218218
var object = { a: 'abcde' },
219219
actual = merge(object, { a: ['x', 'y', 'z'] })
@@ -236,7 +236,7 @@ function run(merge, name) {
236236
symbol: Symbol('sym'),
237237
date: new Date(),
238238
regexp: /molamazo/g,
239-
f: () => {},
239+
f: () => { },
240240
function: function () {
241241
console.log(arguments)
242242
},

0 commit comments

Comments
 (0)