@wordpress/priority-queue 2.25.0 → 2.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.26.0 (2023-02-01)
6
+
5
7
  ## 2.25.0 (2023-01-11)
6
8
 
7
9
  ## 2.24.0 (2023-01-02)
package/build/index.js CHANGED
@@ -77,46 +77,51 @@ var _requestIdleCallback = _interopRequireDefault(require("./request-idle-callba
77
77
  * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
78
78
  */
79
79
  const createQueue = () => {
80
- /** @type {WPPriorityQueueContext[]} */
81
- let waitingList = [];
82
- /** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */
83
-
84
- let elementsMap = new WeakMap();
80
+ /** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */
81
+ const waitingList = new Map();
85
82
  let isRunning = false;
86
83
  /**
87
84
  * Callback to process as much queue as time permits.
88
85
  *
86
+ * Map Iteration follows the original insertion order. This means that here
87
+ * we can iterate the queue and know that the first contexts which were
88
+ * added will be run first. On the other hand, if anyone adds a new callback
89
+ * for an existing context it will supplant the previously-set callback for
90
+ * that context because we reassigned that map key's value.
91
+ *
92
+ * In the case that a callback adds a new callback to its own context then
93
+ * the callback it adds will appear at the end of the iteration and will be
94
+ * run only after all other existing contexts have finished executing.
95
+ *
89
96
  * @param {IdleDeadline|number} deadline Idle callback deadline object, or
90
97
  * animation frame timestamp.
91
98
  */
92
99
 
93
100
  const runWaitingList = deadline => {
94
- const hasTimeRemaining = typeof deadline === 'number' ? () => false : () => deadline.timeRemaining() > 0;
101
+ for (const [nextElement, callback] of waitingList) {
102
+ waitingList.delete(nextElement);
103
+ callback();
95
104
 
96
- do {
97
- if (waitingList.length === 0) {
98
- isRunning = false;
99
- return;
105
+ if ('number' === typeof deadline || deadline.timeRemaining() <= 0) {
106
+ break;
100
107
  }
108
+ }
101
109
 
102
- const nextElement =
103
- /** @type {WPPriorityQueueContext} */
104
- waitingList.shift();
105
- const callback =
106
- /** @type {WPPriorityQueueCallback} */
107
- elementsMap.get(nextElement); // If errors with undefined callbacks are encountered double check that all of your useSelect calls
108
- // have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected
109
- // loops and race conditions in the queue.
110
-
111
- callback();
112
- elementsMap.delete(nextElement);
113
- } while (hasTimeRemaining());
110
+ if (waitingList.size === 0) {
111
+ isRunning = false;
112
+ return;
113
+ }
114
114
 
115
115
  (0, _requestIdleCallback.default)(runWaitingList);
116
116
  };
117
117
  /**
118
118
  * Add a callback to the queue for a given context.
119
119
  *
120
+ * If errors with undefined callbacks are encountered double check that
121
+ * all of your useSelect calls have the right dependencies set correctly
122
+ * in their second parameter. Missing dependencies can cause unexpected
123
+ * loops and race conditions in the queue.
124
+ *
120
125
  * @type {WPPriorityQueueAdd}
121
126
  *
122
127
  * @param {WPPriorityQueueContext} element Context object.
@@ -125,11 +130,7 @@ const createQueue = () => {
125
130
 
126
131
 
127
132
  const add = (element, item) => {
128
- if (!elementsMap.has(element)) {
129
- waitingList.push(element);
130
- }
131
-
132
- elementsMap.set(element, item);
133
+ waitingList.set(element, item);
133
134
 
134
135
  if (!isRunning) {
135
136
  isRunning = true;
@@ -149,16 +150,13 @@ const createQueue = () => {
149
150
 
150
151
 
151
152
  const flush = element => {
152
- if (!elementsMap.has(element)) {
153
+ const callback = waitingList.get(element);
154
+
155
+ if (undefined === callback) {
153
156
  return false;
154
157
  }
155
158
 
156
- const index = waitingList.indexOf(element);
157
- waitingList.splice(index, 1);
158
- const callback =
159
- /** @type {WPPriorityQueueCallback} */
160
- elementsMap.get(element);
161
- elementsMap.delete(element);
159
+ waitingList.delete(element);
162
160
  callback();
163
161
  return true;
164
162
  };
@@ -176,14 +174,7 @@ const createQueue = () => {
176
174
 
177
175
 
178
176
  const cancel = element => {
179
- if (!elementsMap.has(element)) {
180
- return false;
181
- }
182
-
183
- const index = waitingList.indexOf(element);
184
- waitingList.splice(index, 1);
185
- elementsMap.delete(element);
186
- return true;
177
+ return waitingList.delete(element);
187
178
  };
188
179
  /**
189
180
  * Reset the queue without running the pending callbacks.
@@ -193,8 +184,7 @@ const createQueue = () => {
193
184
 
194
185
 
195
186
  const reset = () => {
196
- waitingList = [];
197
- elementsMap = new WeakMap();
187
+ waitingList.clear();
198
188
  isRunning = false;
199
189
  };
200
190
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["createQueue","waitingList","elementsMap","WeakMap","isRunning","runWaitingList","deadline","hasTimeRemaining","timeRemaining","length","nextElement","shift","callback","get","delete","add","element","item","has","push","set","flush","index","indexOf","splice","cancel","reset"],"mappings":"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","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {WPPriorityQueueContext[]} */\n\tlet waitingList = [];\n\n\t/** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */\n\tlet elementsMap = new WeakMap();\n\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tconst hasTimeRemaining =\n\t\t\ttypeof deadline === 'number'\n\t\t\t\t? () => false\n\t\t\t\t: () => deadline.timeRemaining() > 0;\n\n\t\tdo {\n\t\t\tif ( waitingList.length === 0 ) {\n\t\t\t\tisRunning = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextElement = /** @type {WPPriorityQueueContext} */ (\n\t\t\t\twaitingList.shift()\n\t\t\t);\n\t\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\t\telementsMap.get( nextElement )\n\t\t\t);\n\t\t\t// If errors with undefined callbacks are encountered double check that all of your useSelect calls\n\t\t\t// have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected\n\t\t\t// loops and race conditions in the queue.\n\t\t\tcallback();\n\t\t\telementsMap.delete( nextElement );\n\t\t} while ( hasTimeRemaining() );\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\twaitingList.push( element );\n\t\t}\n\t\telementsMap.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\telementsMap.get( element )\n\t\t);\n\t\telementsMap.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\telementsMap.delete( element );\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList = [];\n\t\telementsMap = new WeakMap();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["createQueue","waitingList","Map","isRunning","runWaitingList","deadline","nextElement","callback","delete","timeRemaining","size","add","element","item","set","flush","get","undefined","cancel","reset","clear"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,MAAM;AAChC;AACA,QAAMC,WAAW,GAAG,IAAIC,GAAJ,EAApB;AACA,MAAIC,SAAS,GAAG,KAAhB;AAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,QAAMC,cAAc,GAAKC,QAAF,IAAgB;AACtC,SAAM,MAAM,CAAEC,WAAF,EAAeC,QAAf,CAAZ,IAAyCN,WAAzC,EAAuD;AACtDA,MAAAA,WAAW,CAACO,MAAZ,CAAoBF,WAApB;AACAC,MAAAA,QAAQ;;AAER,UACC,aAAa,OAAOF,QAApB,IACAA,QAAQ,CAACI,aAAT,MAA4B,CAF7B,EAGE;AACD;AACA;AACD;;AAED,QAAKR,WAAW,CAACS,IAAZ,KAAqB,CAA1B,EAA8B;AAC7BP,MAAAA,SAAS,GAAG,KAAZ;AACA;AACA;;AAED,sCAAqBC,cAArB;AACA,GAnBD;AAqBA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMO,GAAG,GAAG,CAAEC,OAAF,EAAWC,IAAX,KAAqB;AAChCZ,IAAAA,WAAW,CAACa,GAAZ,CAAiBF,OAAjB,EAA0BC,IAA1B;;AACA,QAAK,CAAEV,SAAP,EAAmB;AAClBA,MAAAA,SAAS,GAAG,IAAZ;AACA,wCAAqBC,cAArB;AACA;AACD,GAND;AAQA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMW,KAAK,GAAKH,OAAF,IAAe;AAC5B,UAAML,QAAQ,GAAGN,WAAW,CAACe,GAAZ,CAAiBJ,OAAjB,CAAjB;;AACA,QAAKK,SAAS,KAAKV,QAAnB,EAA8B;AAC7B,aAAO,KAAP;AACA;;AAEDN,IAAAA,WAAW,CAACO,MAAZ,CAAoBI,OAApB;AACAL,IAAAA,QAAQ;AAER,WAAO,IAAP;AACA,GAVD;AAYA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMW,MAAM,GAAKN,OAAF,IAAe;AAC7B,WAAOX,WAAW,CAACO,MAAZ,CAAoBI,OAApB,CAAP;AACA,GAFD;AAIA;AACD;AACA;AACA;AACA;;;AACC,QAAMO,KAAK,GAAG,MAAM;AACnBlB,IAAAA,WAAW,CAACmB,KAAZ;AACAjB,IAAAA,SAAS,GAAG,KAAZ;AACA,GAHD;;AAKA,SAAO;AACNQ,IAAAA,GADM;AAENI,IAAAA,KAFM;AAGNG,IAAAA,MAHM;AAINC,IAAAA;AAJM,GAAP;AAMA,CApHM","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */\n\tconst waitingList = new Map();\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * Map Iteration follows the original insertion order. This means that here\n\t * we can iterate the queue and know that the first contexts which were\n\t * added will be run first. On the other hand, if anyone adds a new callback\n\t * for an existing context it will supplant the previously-set callback for\n\t * that context because we reassigned that map key's value.\n\t *\n\t * In the case that a callback adds a new callback to its own context then\n\t * the callback it adds will appear at the end of the iteration and will be\n\t * run only after all other existing contexts have finished executing.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tfor ( const [ nextElement, callback ] of waitingList ) {\n\t\t\twaitingList.delete( nextElement );\n\t\t\tcallback();\n\n\t\t\tif (\n\t\t\t\t'number' === typeof deadline ||\n\t\t\t\tdeadline.timeRemaining() <= 0\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( waitingList.size === 0 ) {\n\t\t\tisRunning = false;\n\t\t\treturn;\n\t\t}\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * If errors with undefined callbacks are encountered double check that\n\t * all of your useSelect calls have the right dependencies set correctly\n\t * in their second parameter. Missing dependencies can cause unexpected\n\t * loops and race conditions in the queue.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\twaitingList.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tconst callback = waitingList.get( element );\n\t\tif ( undefined === callback ) {\n\t\t\treturn false;\n\t\t}\n\n\t\twaitingList.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\treturn waitingList.delete( element );\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList.clear();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
@@ -67,46 +67,51 @@ import requestIdleCallback from './request-idle-callback';
67
67
  */
68
68
 
69
69
  export const createQueue = () => {
70
- /** @type {WPPriorityQueueContext[]} */
71
- let waitingList = [];
72
- /** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */
73
-
74
- let elementsMap = new WeakMap();
70
+ /** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */
71
+ const waitingList = new Map();
75
72
  let isRunning = false;
76
73
  /**
77
74
  * Callback to process as much queue as time permits.
78
75
  *
76
+ * Map Iteration follows the original insertion order. This means that here
77
+ * we can iterate the queue and know that the first contexts which were
78
+ * added will be run first. On the other hand, if anyone adds a new callback
79
+ * for an existing context it will supplant the previously-set callback for
80
+ * that context because we reassigned that map key's value.
81
+ *
82
+ * In the case that a callback adds a new callback to its own context then
83
+ * the callback it adds will appear at the end of the iteration and will be
84
+ * run only after all other existing contexts have finished executing.
85
+ *
79
86
  * @param {IdleDeadline|number} deadline Idle callback deadline object, or
80
87
  * animation frame timestamp.
81
88
  */
82
89
 
83
90
  const runWaitingList = deadline => {
84
- const hasTimeRemaining = typeof deadline === 'number' ? () => false : () => deadline.timeRemaining() > 0;
91
+ for (const [nextElement, callback] of waitingList) {
92
+ waitingList.delete(nextElement);
93
+ callback();
85
94
 
86
- do {
87
- if (waitingList.length === 0) {
88
- isRunning = false;
89
- return;
95
+ if ('number' === typeof deadline || deadline.timeRemaining() <= 0) {
96
+ break;
90
97
  }
98
+ }
91
99
 
92
- const nextElement =
93
- /** @type {WPPriorityQueueContext} */
94
- waitingList.shift();
95
- const callback =
96
- /** @type {WPPriorityQueueCallback} */
97
- elementsMap.get(nextElement); // If errors with undefined callbacks are encountered double check that all of your useSelect calls
98
- // have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected
99
- // loops and race conditions in the queue.
100
-
101
- callback();
102
- elementsMap.delete(nextElement);
103
- } while (hasTimeRemaining());
100
+ if (waitingList.size === 0) {
101
+ isRunning = false;
102
+ return;
103
+ }
104
104
 
105
105
  requestIdleCallback(runWaitingList);
106
106
  };
107
107
  /**
108
108
  * Add a callback to the queue for a given context.
109
109
  *
110
+ * If errors with undefined callbacks are encountered double check that
111
+ * all of your useSelect calls have the right dependencies set correctly
112
+ * in their second parameter. Missing dependencies can cause unexpected
113
+ * loops and race conditions in the queue.
114
+ *
110
115
  * @type {WPPriorityQueueAdd}
111
116
  *
112
117
  * @param {WPPriorityQueueContext} element Context object.
@@ -115,11 +120,7 @@ export const createQueue = () => {
115
120
 
116
121
 
117
122
  const add = (element, item) => {
118
- if (!elementsMap.has(element)) {
119
- waitingList.push(element);
120
- }
121
-
122
- elementsMap.set(element, item);
123
+ waitingList.set(element, item);
123
124
 
124
125
  if (!isRunning) {
125
126
  isRunning = true;
@@ -139,16 +140,13 @@ export const createQueue = () => {
139
140
 
140
141
 
141
142
  const flush = element => {
142
- if (!elementsMap.has(element)) {
143
+ const callback = waitingList.get(element);
144
+
145
+ if (undefined === callback) {
143
146
  return false;
144
147
  }
145
148
 
146
- const index = waitingList.indexOf(element);
147
- waitingList.splice(index, 1);
148
- const callback =
149
- /** @type {WPPriorityQueueCallback} */
150
- elementsMap.get(element);
151
- elementsMap.delete(element);
149
+ waitingList.delete(element);
152
150
  callback();
153
151
  return true;
154
152
  };
@@ -166,14 +164,7 @@ export const createQueue = () => {
166
164
 
167
165
 
168
166
  const cancel = element => {
169
- if (!elementsMap.has(element)) {
170
- return false;
171
- }
172
-
173
- const index = waitingList.indexOf(element);
174
- waitingList.splice(index, 1);
175
- elementsMap.delete(element);
176
- return true;
167
+ return waitingList.delete(element);
177
168
  };
178
169
  /**
179
170
  * Reset the queue without running the pending callbacks.
@@ -183,8 +174,7 @@ export const createQueue = () => {
183
174
 
184
175
 
185
176
  const reset = () => {
186
- waitingList = [];
187
- elementsMap = new WeakMap();
177
+ waitingList.clear();
188
178
  isRunning = false;
189
179
  };
190
180
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["requestIdleCallback","createQueue","waitingList","elementsMap","WeakMap","isRunning","runWaitingList","deadline","hasTimeRemaining","timeRemaining","length","nextElement","shift","callback","get","delete","add","element","item","has","push","set","flush","index","indexOf","splice","cancel","reset"],"mappings":"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","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {WPPriorityQueueContext[]} */\n\tlet waitingList = [];\n\n\t/** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */\n\tlet elementsMap = new WeakMap();\n\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tconst hasTimeRemaining =\n\t\t\ttypeof deadline === 'number'\n\t\t\t\t? () => false\n\t\t\t\t: () => deadline.timeRemaining() > 0;\n\n\t\tdo {\n\t\t\tif ( waitingList.length === 0 ) {\n\t\t\t\tisRunning = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextElement = /** @type {WPPriorityQueueContext} */ (\n\t\t\t\twaitingList.shift()\n\t\t\t);\n\t\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\t\telementsMap.get( nextElement )\n\t\t\t);\n\t\t\t// If errors with undefined callbacks are encountered double check that all of your useSelect calls\n\t\t\t// have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected\n\t\t\t// loops and race conditions in the queue.\n\t\t\tcallback();\n\t\t\telementsMap.delete( nextElement );\n\t\t} while ( hasTimeRemaining() );\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\twaitingList.push( element );\n\t\t}\n\t\telementsMap.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\telementsMap.get( element )\n\t\t);\n\t\telementsMap.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\telementsMap.delete( element );\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList = [];\n\t\telementsMap = new WeakMap();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["requestIdleCallback","createQueue","waitingList","Map","isRunning","runWaitingList","deadline","nextElement","callback","delete","timeRemaining","size","add","element","item","set","flush","get","undefined","cancel","reset","clear"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,MAAM;AAChC;AACA,QAAMC,WAAW,GAAG,IAAIC,GAAJ,EAApB;AACA,MAAIC,SAAS,GAAG,KAAhB;AAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,QAAMC,cAAc,GAAKC,QAAF,IAAgB;AACtC,SAAM,MAAM,CAAEC,WAAF,EAAeC,QAAf,CAAZ,IAAyCN,WAAzC,EAAuD;AACtDA,MAAAA,WAAW,CAACO,MAAZ,CAAoBF,WAApB;AACAC,MAAAA,QAAQ;;AAER,UACC,aAAa,OAAOF,QAApB,IACAA,QAAQ,CAACI,aAAT,MAA4B,CAF7B,EAGE;AACD;AACA;AACD;;AAED,QAAKR,WAAW,CAACS,IAAZ,KAAqB,CAA1B,EAA8B;AAC7BP,MAAAA,SAAS,GAAG,KAAZ;AACA;AACA;;AAEDJ,IAAAA,mBAAmB,CAAEK,cAAF,CAAnB;AACA,GAnBD;AAqBA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMO,GAAG,GAAG,CAAEC,OAAF,EAAWC,IAAX,KAAqB;AAChCZ,IAAAA,WAAW,CAACa,GAAZ,CAAiBF,OAAjB,EAA0BC,IAA1B;;AACA,QAAK,CAAEV,SAAP,EAAmB;AAClBA,MAAAA,SAAS,GAAG,IAAZ;AACAJ,MAAAA,mBAAmB,CAAEK,cAAF,CAAnB;AACA;AACD,GAND;AAQA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMW,KAAK,GAAKH,OAAF,IAAe;AAC5B,UAAML,QAAQ,GAAGN,WAAW,CAACe,GAAZ,CAAiBJ,OAAjB,CAAjB;;AACA,QAAKK,SAAS,KAAKV,QAAnB,EAA8B;AAC7B,aAAO,KAAP;AACA;;AAEDN,IAAAA,WAAW,CAACO,MAAZ,CAAoBI,OAApB;AACAL,IAAAA,QAAQ;AAER,WAAO,IAAP;AACA,GAVD;AAYA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMW,MAAM,GAAKN,OAAF,IAAe;AAC7B,WAAOX,WAAW,CAACO,MAAZ,CAAoBI,OAApB,CAAP;AACA,GAFD;AAIA;AACD;AACA;AACA;AACA;;;AACC,QAAMO,KAAK,GAAG,MAAM;AACnBlB,IAAAA,WAAW,CAACmB,KAAZ;AACAjB,IAAAA,SAAS,GAAG,KAAZ;AACA,GAHD;;AAKA,SAAO;AACNQ,IAAAA,GADM;AAENI,IAAAA,KAFM;AAGNG,IAAAA,MAHM;AAINC,IAAAA;AAJM,GAAP;AAMA,CApHM","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */\n\tconst waitingList = new Map();\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * Map Iteration follows the original insertion order. This means that here\n\t * we can iterate the queue and know that the first contexts which were\n\t * added will be run first. On the other hand, if anyone adds a new callback\n\t * for an existing context it will supplant the previously-set callback for\n\t * that context because we reassigned that map key's value.\n\t *\n\t * In the case that a callback adds a new callback to its own context then\n\t * the callback it adds will appear at the end of the iteration and will be\n\t * run only after all other existing contexts have finished executing.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tfor ( const [ nextElement, callback ] of waitingList ) {\n\t\t\twaitingList.delete( nextElement );\n\t\t\tcallback();\n\n\t\t\tif (\n\t\t\t\t'number' === typeof deadline ||\n\t\t\t\tdeadline.timeRemaining() <= 0\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( waitingList.size === 0 ) {\n\t\t\tisRunning = false;\n\t\t\treturn;\n\t\t}\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * If errors with undefined callbacks are encountered double check that\n\t * all of your useSelect calls have the right dependencies set correctly\n\t * in their second parameter. Missing dependencies can cause unexpected\n\t * loops and race conditions in the queue.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\twaitingList.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tconst callback = waitingList.get( element );\n\t\tif ( undefined === callback ) {\n\t\t\treturn false;\n\t\t}\n\n\t\twaitingList.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\treturn waitingList.delete( element );\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList.clear();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAoEO,+BAFK,eAAe,CAkI1B;;;;sCA5LY,MAAI,IAAI;;;;qCAMR,EAAE;;;;2CAMO,sBAAsB,QAAM,uBAAuB,KAAG,IAAI;;;;6CAM1D,sBAAsB,KAAG,OAAO;;;;mCAMzC,MAAI,IAAI;;;;;;;;SAQP,kBAAkB;;;;WAClB,oBAAoB;;;;YACpB,oBAAoB;;;;WACpB,oBAAoB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAoEO,+BAFK,eAAe,CAsH1B;;;;sCAhLY,MAAI,IAAI;;;;qCAMR,EAAE;;;;2CAMO,sBAAsB,QAAM,uBAAuB,KAAG,IAAI;;;;6CAM1D,sBAAsB,KAAG,OAAO;;;;mCAMzC,MAAI,IAAI;;;;;;;;SAQP,kBAAkB;;;;WAClB,oBAAoB;;;;YACpB,oBAAoB;;;;WACpB,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/priority-queue",
3
- "version": "2.25.0",
3
+ "version": "2.26.1",
4
4
  "description": "Generic browser priority queue.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "204c880ff65295768e9695dfee6c7a9fee1fdd05"
37
+ "gitHead": "e9ff92d836928aba65dde94d9d193bc401a934d7"
38
38
  }
package/src/index.js CHANGED
@@ -67,44 +67,43 @@ import requestIdleCallback from './request-idle-callback';
67
67
  * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
68
68
  */
69
69
  export const createQueue = () => {
70
- /** @type {WPPriorityQueueContext[]} */
71
- let waitingList = [];
72
-
73
- /** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */
74
- let elementsMap = new WeakMap();
75
-
70
+ /** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */
71
+ const waitingList = new Map();
76
72
  let isRunning = false;
77
73
 
78
74
  /**
79
75
  * Callback to process as much queue as time permits.
80
76
  *
77
+ * Map Iteration follows the original insertion order. This means that here
78
+ * we can iterate the queue and know that the first contexts which were
79
+ * added will be run first. On the other hand, if anyone adds a new callback
80
+ * for an existing context it will supplant the previously-set callback for
81
+ * that context because we reassigned that map key's value.
82
+ *
83
+ * In the case that a callback adds a new callback to its own context then
84
+ * the callback it adds will appear at the end of the iteration and will be
85
+ * run only after all other existing contexts have finished executing.
86
+ *
81
87
  * @param {IdleDeadline|number} deadline Idle callback deadline object, or
82
88
  * animation frame timestamp.
83
89
  */
84
90
  const runWaitingList = ( deadline ) => {
85
- const hasTimeRemaining =
86
- typeof deadline === 'number'
87
- ? () => false
88
- : () => deadline.timeRemaining() > 0;
89
-
90
- do {
91
- if ( waitingList.length === 0 ) {
92
- isRunning = false;
93
- return;
91
+ for ( const [ nextElement, callback ] of waitingList ) {
92
+ waitingList.delete( nextElement );
93
+ callback();
94
+
95
+ if (
96
+ 'number' === typeof deadline ||
97
+ deadline.timeRemaining() <= 0
98
+ ) {
99
+ break;
94
100
  }
101
+ }
95
102
 
96
- const nextElement = /** @type {WPPriorityQueueContext} */ (
97
- waitingList.shift()
98
- );
99
- const callback = /** @type {WPPriorityQueueCallback} */ (
100
- elementsMap.get( nextElement )
101
- );
102
- // If errors with undefined callbacks are encountered double check that all of your useSelect calls
103
- // have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected
104
- // loops and race conditions in the queue.
105
- callback();
106
- elementsMap.delete( nextElement );
107
- } while ( hasTimeRemaining() );
103
+ if ( waitingList.size === 0 ) {
104
+ isRunning = false;
105
+ return;
106
+ }
108
107
 
109
108
  requestIdleCallback( runWaitingList );
110
109
  };
@@ -112,16 +111,18 @@ export const createQueue = () => {
112
111
  /**
113
112
  * Add a callback to the queue for a given context.
114
113
  *
114
+ * If errors with undefined callbacks are encountered double check that
115
+ * all of your useSelect calls have the right dependencies set correctly
116
+ * in their second parameter. Missing dependencies can cause unexpected
117
+ * loops and race conditions in the queue.
118
+ *
115
119
  * @type {WPPriorityQueueAdd}
116
120
  *
117
121
  * @param {WPPriorityQueueContext} element Context object.
118
122
  * @param {WPPriorityQueueCallback} item Callback function.
119
123
  */
120
124
  const add = ( element, item ) => {
121
- if ( ! elementsMap.has( element ) ) {
122
- waitingList.push( element );
123
- }
124
- elementsMap.set( element, item );
125
+ waitingList.set( element, item );
125
126
  if ( ! isRunning ) {
126
127
  isRunning = true;
127
128
  requestIdleCallback( runWaitingList );
@@ -139,16 +140,12 @@ export const createQueue = () => {
139
140
  * @return {boolean} Whether flush was performed.
140
141
  */
141
142
  const flush = ( element ) => {
142
- if ( ! elementsMap.has( element ) ) {
143
+ const callback = waitingList.get( element );
144
+ if ( undefined === callback ) {
143
145
  return false;
144
146
  }
145
147
 
146
- const index = waitingList.indexOf( element );
147
- waitingList.splice( index, 1 );
148
- const callback = /** @type {WPPriorityQueueCallback} */ (
149
- elementsMap.get( element )
150
- );
151
- elementsMap.delete( element );
148
+ waitingList.delete( element );
152
149
  callback();
153
150
 
154
151
  return true;
@@ -166,15 +163,7 @@ export const createQueue = () => {
166
163
  * @return {boolean} Whether any callbacks got cancelled.
167
164
  */
168
165
  const cancel = ( element ) => {
169
- if ( ! elementsMap.has( element ) ) {
170
- return false;
171
- }
172
-
173
- const index = waitingList.indexOf( element );
174
- waitingList.splice( index, 1 );
175
- elementsMap.delete( element );
176
-
177
- return true;
166
+ return waitingList.delete( element );
178
167
  };
179
168
 
180
169
  /**
@@ -183,8 +172,7 @@ export const createQueue = () => {
183
172
  * @type {WPPriorityQueueReset}
184
173
  */
185
174
  const reset = () => {
186
- waitingList = [];
187
- elementsMap = new WeakMap();
175
+ waitingList.clear();
188
176
  isRunning = false;
189
177
  };
190
178
 
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/requestidlecallback/index.d.ts","./src/request-idle-callback.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},{"version":"9b66eb641b8ff1824e4d04022ba1a051c5c10746ea94147b24c2f5e27c5f9c88","affectsGlobalScope":true},"d7da0a20216d07d275da4d90bef16c4229b9c3251e2d68ef0762f9bb20e70594","4de4926f27ba2917ff0afe8021ff358b78098358aa83e4cf05afee9905709d73"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[46]],"referencedMap":[[47,1]],"exportedModulesMap":[[47,1]],"semanticDiagnosticsPerFile":[45,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,47,46]},"version":"4.4.2"}
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/requestidlecallback/index.d.ts","./src/request-idle-callback.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},{"version":"9b66eb641b8ff1824e4d04022ba1a051c5c10746ea94147b24c2f5e27c5f9c88","affectsGlobalScope":true},"d7da0a20216d07d275da4d90bef16c4229b9c3251e2d68ef0762f9bb20e70594","77efe10d427aee10bf7c467d6d9a0e4f0fcb84811d679be612d53b2e8dd17a76"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[46]],"referencedMap":[[47,1]],"exportedModulesMap":[[47,1]],"semanticDiagnosticsPerFile":[45,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,47,46]},"version":"4.4.2"}