UNPKG

roslib

Version:

The standard ROS Javascript Library

18 lines (17 loc) 552 B
/** * Mixin a feature to the core/Ros prototype. * For example, mixin(Ros, ['Topic'], {Topic: <Topic>}) * will add a topic bound to any Ros instances so a user * can call `var topic = ros.Topic({name: '/foo'});` * * @author Graeme Yeates - github.com/megawac */ module.exports = function(Ros, classes, features) { classes.forEach(function(className) { var Class = features[className]; Ros.prototype[className] = function(options) { options.ros = this; return new Class(options); }; }); };