27 lines
478 B
JavaScript
27 lines
478 B
JavaScript
'use strict'
|
|
|
|
class Base {
|
|
constructor (name, code, implementation, alphabet) {
|
|
this.name = name
|
|
this.code = code
|
|
this.alphabet = alphabet
|
|
if (implementation && alphabet) {
|
|
this.engine = implementation(alphabet)
|
|
}
|
|
}
|
|
|
|
encode (stringOrBuffer) {
|
|
return this.engine.encode(stringOrBuffer)
|
|
}
|
|
|
|
decode (stringOrBuffer) {
|
|
return this.engine.decode(stringOrBuffer)
|
|
}
|
|
|
|
isImplemented () {
|
|
return this.engine
|
|
}
|
|
}
|
|
|
|
module.exports = Base
|