devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
76 lines (74 loc) • 2.45 kB
JavaScript
/**
* DevExtreme (cjs/__internal/data/m_array_store.js)
* Version: 24.2.6
* Build date: Mon Mar 17 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _array_utils = require("../../common/data/array_utils");
var _errors = require("../../common/data/errors");
var _query = _interopRequireDefault(require("../../common/data/query"));
var _utils = require("../../common/data/utils");
var _abstract_store = _interopRequireDefault(require("../../data/abstract_store"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
const ArrayStore = _abstract_store.default.inherit({
ctor(options) {
if (Array.isArray(options)) {
options = {
data: options
}
} else {
options = options || {}
}
this.callBase(options);
const initialArray = options.data;
if (initialArray && !Array.isArray(initialArray)) {
throw _errors.errors.Error("E4006")
}
this._array = initialArray || []
},
createQuery() {
return (0, _query.default)(this._array, {
errorHandler: this._errorHandler
})
},
_byKeyImpl(key) {
const index = (0, _array_utils.indexByKey)(this, this._array, key);
if (-1 === index) {
return (0, _utils.rejectedPromise)(_errors.errors.Error("E4009"))
}
return (0, _utils.trivialPromise)(this._array[index])
},
_insertImpl(values) {
return (0, _array_utils.insert)(this, this._array, values)
},
_pushImpl(changes) {
(0, _array_utils.applyBatch)({
keyInfo: this,
data: this._array,
changes: changes
})
},
_updateImpl(key, values) {
return (0, _array_utils.update)(this, this._array, key, values)
},
_removeImpl(key) {
return (0, _array_utils.remove)(this, this._array, key)
},
clear() {
this._eventsStrategy.fireEvent("modifying");
this._array = [];
this._eventsStrategy.fireEvent("modified")
}
}, "array");
var _default = exports.default = ArrayStore;