hummus-recipe
Version:
A powerful PDF tool for NodeJS based on HummusJS
18 lines (13 loc) • 363 B
text/coffeescript
class Enum
constructor: (, = []) ->
decode: (stream) ->
index = .decode(stream)
return [index] or index
size: ->
.size()
encode: (stream, val) ->
index = .indexOf val
if index is -1
throw new Error "Unknown option in enum: #{val}"
.encode(stream, index)
module.exports = Enum