transform.js 701 B

1234567891011121314151617181920212223242526
  1. export default function(methods) {
  2. return {
  3. stream: transformer(methods)
  4. };
  5. }
  6. export function transformer(methods) {
  7. return function(stream) {
  8. var s = new TransformStream;
  9. for (var key in methods) s[key] = methods[key];
  10. s.stream = stream;
  11. return s;
  12. };
  13. }
  14. function TransformStream() {}
  15. TransformStream.prototype = {
  16. constructor: TransformStream,
  17. point: function(x, y) { this.stream.point(x, y); },
  18. sphere: function() { this.stream.sphere(); },
  19. lineStart: function() { this.stream.lineStart(); },
  20. lineEnd: function() { this.stream.lineEnd(); },
  21. polygonStart: function() { this.stream.polygonStart(); },
  22. polygonEnd: function() { this.stream.polygonEnd(); }
  23. };