UNPKG

cooperate

Version:

Convention based composition tool that let's you compose a series of objects into a single object quickly.

37 lines (24 loc) 647 B
// This simple class makes the fluent interface work class MemberMap { constructor(parent, sourceName) { if (!sourceName) { throw new Error("the source field name cannot be null"); } this.sourceName = sourceName; this.parent_ = parent; this.hidden_ = false; } get hidden() { return this.hidden_; } to(targetName) { if (!targetName || typeof targetName !== "string") { throw new Error("the target field name must be a string"); } this.targetName = targetName; return this.parent_; } hide() { this.hidden_ = true; return this.parent_; } } module.exports = MemberMap;