UNPKG

abstract-things

Version:

Base for building libraries that interact with physical things, such as IoT-devices

21 lines (18 loc) 356 B
'use strict'; module.exports = class Code { constructor(id, description) { this.id = id; this.description = description; } static parse(value) { const idx = value.indexOf(':'); if(idx >= 0) { return new Code( value.substring(0, idx).trim(), value.substring(idx+1).trim() ); } else { return new Code(value.trim()); } } };