@wordpress/preferences-persistence 1.9.0 → 1.10.0
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
@@ -13,8 +13,8 @@ exports.default = debounceAsync;
|
|
13
13
|
* - The second is never called.
|
14
14
|
* - The third happens `delayMS` milliseconds after the first has resolved.
|
15
15
|
*
|
16
|
-
* This is distinct from `
|
17
|
-
* resolution.
|
16
|
+
* This is distinct from `{ debounce } from @wordpress/compose` in that it
|
17
|
+
* waits for promise resolution.
|
18
18
|
*
|
19
19
|
* @param {Function} func A function that returns a promise.
|
20
20
|
* @param {number} delayMS A delay in milliseconds.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","catch","error","finally","clearTimeout","setTimeout"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,CAAwBC,IAAxB,EAA8BC,OAA9B,EAAwC;AACtD,MAAIC,SAAJ;AACA,MAAIC,aAAJ;AAEA,SAAO,eAAeC,SAAf,GAAoC;AAAA,sCAAPC,IAAO;AAAPA,MAAAA,IAAO;AAAA;;AAC1C;AACA;AACA,QAAK,CAAEF,aAAF,IAAmB,CAAED,SAA1B,EAAsC;AACrC,aAAO,IAAII,OAAJ,CAAa,CAAEC,OAAF,EAAWC,MAAX,KAAuB;AAC1C;AACAL,QAAAA,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAL,CAAJ,CACdI,IADc,CACR,YAAmB;AACzBF,UAAAA,OAAO,CAAE,YAAF,CAAP;AACA,SAHc,EAIdG,KAJc,CAILC,KAAF,IAAa;AACpBH,UAAAA,MAAM,CAAEG,KAAF,CAAN;AACA,SANc,EAOdC,OAPc,CAOL,MAAM;AACf;AACA;AACAT,UAAAA,aAAa,GAAG,IAAhB;AACA,SAXc,CAAhB;AAYA,OAdM,CAAP;AAeA;;AAED,QAAKA,aAAL,EAAqB;AACpB;AACA,YAAMA,aAAN;AACA,KAxByC,CA0B1C;AACA;;;AACA,QAAKD,SAAL,EAAiB;AAChBW,MAAAA,YAAY,CAAEX,SAAF,CAAZ;AACAA,MAAAA,SAAS,GAAG,IAAZ;AACA,KA/ByC,CAiC1C;;;AACA,WAAO,IAAII,OAAJ,CAAa,CAAEC,OAAF,EAAWC,MAAX,KAAuB;AAC1C;AACAN,MAAAA,SAAS,GAAGY,UAAU,CAAE,MAAM;AAC7BX,QAAAA,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAL,CAAJ,CACdI,IADc,CACR,YAAmB;AACzBF,UAAAA,OAAO,CAAE,YAAF,CAAP;AACA,SAHc,EAIdG,KAJc,CAILC,KAAF,IAAa;AACpBH,UAAAA,MAAM,CAAEG,KAAF,CAAN;AACA,SANc,EAOdC,OAPc,CAOL,MAAM;AACf;AACA;AACAT,UAAAA,aAAa,GAAG,IAAhB;AACAD,UAAAA,SAAS,GAAG,IAAZ;AACA,SAZc,CAAhB;AAaA,OAdqB,EAcnBD,OAdmB,CAAtB;AAeA,KAjBM,CAAP;AAkBA,GApDD;AAqDA","sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `
|
1
|
+
{"version":3,"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","catch","error","finally","clearTimeout","setTimeout"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,CAAwBC,IAAxB,EAA8BC,OAA9B,E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AAaA,OAdqB,EAcnBD,OAdmB,CAAtB;AAeA,KAjBM,CAAP;AAkBA,GApDD;AAqDA","sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `{ debounce } from @wordpress/compose` in that it\n * waits for promise resolution.\n *\n * @param {Function} func A function that returns a promise.\n * @param {number} delayMS A delay in milliseconds.\n *\n * @return {Function} A function that debounce whatever function is passed\n * to it.\n */\nexport default function debounceAsync( func, delayMS ) {\n\tlet timeoutId;\n\tlet activePromise;\n\n\treturn async function debounced( ...args ) {\n\t\t// This is a leading edge debounce. If there's no promise or timeout\n\t\t// in progress, call the debounced function immediately.\n\t\tif ( ! activePromise && ! timeoutId ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t// Keep a reference to the promise.\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\tif ( activePromise ) {\n\t\t\t// Let any active promises finish before queuing the next request.\n\t\t\tawait activePromise;\n\t\t}\n\n\t\t// Clear any active timeouts, abandoning any requests that have\n\t\t// been queued but not been made.\n\t\tif ( timeoutId ) {\n\t\t\tclearTimeout( timeoutId );\n\t\t\ttimeoutId = null;\n\t\t}\n\n\t\t// Trigger any trailing edge calls to the function.\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t// Schedule the next request but with a delay.\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t\ttimeoutId = null;\n\t\t\t\t\t} );\n\t\t\t}, delayMS );\n\t\t} );\n\t};\n}\n"]}
|
@@ -6,8 +6,8 @@
|
|
6
6
|
* - The second is never called.
|
7
7
|
* - The third happens `delayMS` milliseconds after the first has resolved.
|
8
8
|
*
|
9
|
-
* This is distinct from `
|
10
|
-
* resolution.
|
9
|
+
* This is distinct from `{ debounce } from @wordpress/compose` in that it
|
10
|
+
* waits for promise resolution.
|
11
11
|
*
|
12
12
|
* @param {Function} func A function that returns a promise.
|
13
13
|
* @param {number} delayMS A delay in milliseconds.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","catch","error","finally","clearTimeout","setTimeout"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,aAAT,CAAwBC,IAAxB,EAA8BC,OAA9B,EAAwC;AACtD,MAAIC,SAAJ;AACA,MAAIC,aAAJ;AAEA,SAAO,eAAeC,SAAf,GAAoC;AAAA,sCAAPC,IAAO;AAAPA,MAAAA,IAAO;AAAA;;AAC1C;AACA;AACA,QAAK,CAAEF,aAAF,IAAmB,CAAED,SAA1B,EAAsC;AACrC,aAAO,IAAII,OAAJ,CAAa,CAAEC,OAAF,EAAWC,MAAX,KAAuB;AAC1C;AACAL,QAAAA,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAL,CAAJ,CACdI,IADc,CACR,YAAmB;AACzBF,UAAAA,OAAO,CAAE,YAAF,CAAP;AACA,SAHc,EAIdG,KAJc,CAILC,KAAF,IAAa;AACpBH,UAAAA,MAAM,CAAEG,KAAF,CAAN;AACA,SANc,EAOdC,OAPc,CAOL,MAAM;AACf;AACA;AACAT,UAAAA,aAAa,GAAG,IAAhB;AACA,SAXc,CAAhB;AAYA,OAdM,CAAP;AAeA;;AAED,QAAKA,aAAL,EAAqB;AACpB;AACA,YAAMA,aAAN;AACA,KAxByC,CA0B1C;AACA;;;AACA,QAAKD,SAAL,EAAiB;AAChBW,MAAAA,YAAY,CAAEX,SAAF,CAAZ;AACAA,MAAAA,SAAS,GAAG,IAAZ;AACA,KA/ByC,CAiC1C;;;AACA,WAAO,IAAII,OAAJ,CAAa,CAAEC,OAAF,EAAWC,MAAX,KAAuB;AAC1C;AACAN,MAAAA,SAAS,GAAGY,UAAU,CAAE,MAAM;AAC7BX,QAAAA,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAL,CAAJ,CACdI,IADc,CACR,YAAmB;AACzBF,UAAAA,OAAO,CAAE,YAAF,CAAP;AACA,SAHc,EAIdG,KAJc,CAILC,KAAF,IAAa;AACpBH,UAAAA,MAAM,CAAEG,KAAF,CAAN;AACA,SANc,EAOdC,OAPc,CAOL,MAAM;AACf;AACA;AACAT,UAAAA,aAAa,GAAG,IAAhB;AACAD,UAAAA,SAAS,GAAG,IAAZ;AACA,SAZc,CAAhB;AAaA,OAdqB,EAcnBD,OAdmB,CAAtB;AAeA,KAjBM,CAAP;AAkBA,GApDD;AAqDA","sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `
|
1
|
+
{"version":3,"sources":["@wordpress/preferences-persistence/src/create/debounce-async.js"],"names":["debounceAsync","func","delayMS","timeoutId","activePromise","debounced","args","Promise","resolve","reject","then","catch","error","finally","clearTimeout","setTimeout"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,aAAT,CAAwBC,IAAxB,EAA8BC,OAA9B,EAAwC;AACtD,MAAIC,SAAJ;AACA,MAAIC,aAAJ;AAEA,SAAO,eAAeC,SAAf,GAAoC;AAAA,sCAAPC,IAAO;AAAPA,MAAAA,IAAO;AAAA;;AAC1C;AACA;AACA,QAAK,CAAEF,aAAF,IAAmB,CAAED,SAA1B,EAAsC;AACrC,aAAO,IAAII,OAAJ,CAAa,CAAEC,OAAF,EAAWC,MAAX,KAAuB;AAC1C;AACAL,QAAAA,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAL,CAAJ,CACdI,IADc,CACR,YAAmB;AACzBF,UAAAA,OAAO,CAAE,YAAF,CAAP;AACA,SAHc,EAIdG,KAJc,CAILC,KAAF,IAAa;AACpBH,UAAAA,MAAM,CAAEG,KAAF,CAAN;AACA,SANc,EAOdC,OAPc,CAOL,MAAM;AACf;AACA;AACAT,UAAAA,aAAa,GAAG,IAAhB;AACA,SAXc,CAAhB;AAYA,OAdM,CAAP;AAeA;;AAED,QAAKA,aAAL,EAAqB;AACpB;AACA,YAAMA,aAAN;AACA,KAxByC,CA0B1C;AACA;;;AACA,QAAKD,SAAL,EAAiB;AAChBW,MAAAA,YAAY,CAAEX,SAAF,CAAZ;AACAA,MAAAA,SAAS,GAAG,IAAZ;AACA,KA/ByC,CAiC1C;;;AACA,WAAO,IAAII,OAAJ,CAAa,CAAEC,OAAF,EAAWC,MAAX,KAAuB;AAC1C;AACAN,MAAAA,SAAS,GAAGY,UAAU,CAAE,MAAM;AAC7BX,QAAAA,aAAa,GAAGH,IAAI,CAAE,GAAGK,IAAL,CAAJ,CACdI,IADc,CACR,YAAmB;AACzBF,UAAAA,OAAO,CAAE,YAAF,CAAP;AACA,SAHc,EAIdG,KAJc,CAILC,KAAF,IAAa;AACpBH,UAAAA,MAAM,CAAEG,KAAF,CAAN;AACA,SANc,EAOdC,OAPc,CAOL,MAAM;AACf;AACA;AACAT,UAAAA,aAAa,GAAG,IAAhB;AACAD,UAAAA,SAAS,GAAG,IAAZ;AACA,SAZc,CAAhB;AAaA,OAdqB,EAcnBD,OAdmB,CAAtB;AAeA,KAjBM,CAAP;AAkBA,GApDD;AAqDA","sourcesContent":["/**\n * Performs a leading edge debounce of async functions.\n *\n * If three functions are throttled at the same time:\n * - The first happens immediately.\n * - The second is never called.\n * - The third happens `delayMS` milliseconds after the first has resolved.\n *\n * This is distinct from `{ debounce } from @wordpress/compose` in that it\n * waits for promise resolution.\n *\n * @param {Function} func A function that returns a promise.\n * @param {number} delayMS A delay in milliseconds.\n *\n * @return {Function} A function that debounce whatever function is passed\n * to it.\n */\nexport default function debounceAsync( func, delayMS ) {\n\tlet timeoutId;\n\tlet activePromise;\n\n\treturn async function debounced( ...args ) {\n\t\t// This is a leading edge debounce. If there's no promise or timeout\n\t\t// in progress, call the debounced function immediately.\n\t\tif ( ! activePromise && ! timeoutId ) {\n\t\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t\t// Keep a reference to the promise.\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\tif ( activePromise ) {\n\t\t\t// Let any active promises finish before queuing the next request.\n\t\t\tawait activePromise;\n\t\t}\n\n\t\t// Clear any active timeouts, abandoning any requests that have\n\t\t// been queued but not been made.\n\t\tif ( timeoutId ) {\n\t\t\tclearTimeout( timeoutId );\n\t\t\ttimeoutId = null;\n\t\t}\n\n\t\t// Trigger any trailing edge calls to the function.\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\t// Schedule the next request but with a delay.\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tactivePromise = func( ...args )\n\t\t\t\t\t.then( ( ...thenArgs ) => {\n\t\t\t\t\t\tresolve( ...thenArgs );\n\t\t\t\t\t} )\n\t\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t\treject( error );\n\t\t\t\t\t} )\n\t\t\t\t\t.finally( () => {\n\t\t\t\t\t\t// As soon this promise is complete, clear the way for the\n\t\t\t\t\t\t// next one to happen immediately.\n\t\t\t\t\t\tactivePromise = null;\n\t\t\t\t\t\ttimeoutId = null;\n\t\t\t\t\t} );\n\t\t\t}, delayMS );\n\t\t} );\n\t};\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/preferences-persistence",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.10.0",
|
4
4
|
"description": "Persistence utilities for `wordpress/preferences`.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -28,10 +28,10 @@
|
|
28
28
|
"sideEffects": false,
|
29
29
|
"dependencies": {
|
30
30
|
"@babel/runtime": "^7.16.0",
|
31
|
-
"@wordpress/api-fetch": "^6.
|
31
|
+
"@wordpress/api-fetch": "^6.15.0"
|
32
32
|
},
|
33
33
|
"publishConfig": {
|
34
34
|
"access": "public"
|
35
35
|
},
|
36
|
-
"gitHead": "
|
36
|
+
"gitHead": "23e136283fa1d3b8d9d8b33869f871ad5eb77726"
|
37
37
|
}
|
@@ -6,8 +6,8 @@
|
|
6
6
|
* - The second is never called.
|
7
7
|
* - The third happens `delayMS` milliseconds after the first has resolved.
|
8
8
|
*
|
9
|
-
* This is distinct from `
|
10
|
-
* resolution.
|
9
|
+
* This is distinct from `{ debounce } from @wordpress/compose` in that it
|
10
|
+
* waits for promise resolution.
|
11
11
|
*
|
12
12
|
* @param {Function} func A function that returns a promise.
|
13
13
|
* @param {number} delayMS A delay in milliseconds.
|