dropInstanceCommon.js 980 B

12345678910111213141516171819202122232425262728
  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. callback = getCallback.apply(this, arguments);
  6. options = (typeof options !== 'function' && options) || {};
  7. if (!options.name) {
  8. const currentConfig = this.config();
  9. options.name = options.name || currentConfig.name;
  10. options.storeName = options.storeName || currentConfig.storeName;
  11. }
  12. let promise;
  13. if (!options.name) {
  14. promise = Promise.reject('Invalid arguments');
  15. }
  16. else {
  17. promise = new Promise(resolve => {
  18. if (!options.storeName) {
  19. resolve(`${options.name}/`);
  20. }
  21. else {
  22. resolve(getKeyPrefix(options, this._defaultConfig));
  23. }
  24. });
  25. }
  26. return { promise, callback };
  27. }
  28. //# sourceMappingURL=dropInstanceCommon.js.map