douglasduteil/ng2in1

View on GitHub
src/annotations.js

Summary

Maintainability
A
0 mins
Test Coverage
//

import {
  Component,
  Template
  } from './annotationTypes';

export const ComponentAnnotation = _defaultAnnotationDecorator(Component);
export const TemplateAnnotation = _defaultAnnotationDecorator(Template);

////

function _defaultAnnotationDecorator(AnnotationClass) {
  return function (options) {
    return _appendToTargetAnnotations
      .bind(null, new AnnotationClass(options));
  };
}

function _appendToTargetAnnotations(annotation, target) {
  target.annotations = target.annotations || [];
  target.annotations.push(annotation);
}