mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-20 20:42:44 -05:00
22 lines
655 B
JavaScript
22 lines
655 B
JavaScript
import extractValue from './utils/extract-value';
|
|
|
|
export default function decoratorAlias(fn, errorMessage) {
|
|
return function(...params) {
|
|
// determine if user called as @computed('blah', 'blah') or @computed
|
|
if (params.length === 0) {
|
|
throw new Error(errorMessage);
|
|
} else {
|
|
return function(target, key, desc) {
|
|
return {
|
|
enumerable: desc.enumerable,
|
|
configurable: desc.configurable,
|
|
writable: desc.writable,
|
|
initializer: function() {
|
|
var value = extractValue(desc);
|
|
return fn.apply(null, params.concat(value));
|
|
}
|
|
};
|
|
};
|
|
}
|
|
};
|
|
}
|