UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

36 lines (35 loc) 997 B
/** * DevExtreme (esm/__internal/core/utils/m_locker.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/ */ import errors from "../../../core/errors"; const Locker = function() { const info = {}; const currentCount = function(lockName) { return info[lockName] || 0 }; return { obtain(lockName) { info[lockName] = currentCount(lockName) + 1 }, release(lockName) { const count = currentCount(lockName); if (count < 1) { throw errors.Error("E0014") } if (1 === count) { delete info[lockName] } else { info[lockName] = count - 1 } }, locked: lockName => currentCount(lockName) > 0 } }; export { Locker };