-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactory.js
23 lines (21 loc) · 1003 Bytes
/
Factory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as datasetIo from './dataset.js'
import * as streamIo from './stream.js'
class Factory {
init () {
this.io = {
dataset: {
fromText: (mediaType, text, args) => datasetIo.fromText(mediaType, text, { ...args, factory: this }),
fromURL: (url, args) => datasetIo.fromURL(url, { ...args, factory: this }),
toText: (mediaType, dataset, args) => datasetIo.toText(mediaType, dataset, { ...args, factory: this }),
toURL: (url, dataset, args) => datasetIo.toURL(url, dataset, { ...args, factory: this })
},
stream: {
fromText: (mediaType, text, args) => streamIo.fromText(mediaType, text, { ...args, factory: this }),
fromURL: (url, args) => streamIo.fromURL(url, { ...args, factory: this }),
toText: (mediaType, stream, args) => streamIo.toText(mediaType, stream, { ...args, factory: this }),
toURL: (url, stream, args) => streamIo.toURL(url, { ...args, factory: this })
}
}
}
}
export default Factory