dropInstanceCommon.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. import { getCallback } from './getCallback';
  2. import { getKeyPrefix } from './getKeyPrefix';
  3. //tslint:disable-next-line:no-ignored-initial-value
  4. export function dropInstanceCommon(options, callback) {
  5. var _this = this;
  6. callback = getCallback.apply(this, arguments);
  7. options = (typeof options !== 'function' && options) || {};
  8. if (!options.name) {
  9. var currentConfig = this.config();
  10. options.name = options.name || currentConfig.name;
  11. options.storeName = options.storeName || currentConfig.storeName;
  12. }
  13. var promise;
  14. if (!options.name) {
  15. promise = Promise.reject('Invalid arguments');
  16. }
  17. else {
  18. promise = new Promise(function (resolve) {
  19. if (!options.storeName) {
  20. resolve(options.name + "/");
  21. }
  22. else {
  23. resolve(getKeyPrefix(options, _this._defaultConfig));
  24. }
  25. });
  26. }
  27. return { promise: promise, callback: callback };
  28. }
  29. //# sourceMappingURL=dropInstanceCommon.js.map