I appreciate that you want to encapsulate this in a library, but I think this is a case where the benefits of the abstraction are outweighed by the costs.  I'd prefer to see this concept distributed a la copy-pasta and avoid the overhead of the dependency.