UNPKG

fluxtuate

Version:

a javascript ES7 library for handling complex data transactions

33 lines (24 loc) 974 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = inject; var _internals = require("./_internals"); function processProperty(iKey, target, key, descriptor) { if (key === undefined) throw new Error("You can't inject values to classes, only to class properties of type function!"); if (typeof descriptor.value === "function") throw new Error("You can only inject values to properties of the class!"); target[key] = {}; target[key][_internals.injectionKey] = iKey; descriptor.configurable = true; return descriptor; } function inject(iKey) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } if (args.length === 0) { return processProperty.bind(this, iKey); } else if (args.length === 2) { return processProperty.apply(this, [args[0], iKey].concat(args)); } }