2025-04-19 15:38:48 +08:00

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