@wordpress/compose 8.7.2-next.v.202608281122.0 → 8.7.2-next.v.202609031004.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/build/higher-order/pipe.cjs.map +1 -1
  3. package/build-module/higher-order/pipe.mjs.map +1 -1
  4. package/build-types/higher-order/compose.d.ts +1 -1
  5. package/build-types/higher-order/compose.d.ts.map +1 -1
  6. package/build-types/higher-order/pipe.d.ts +2 -2
  7. package/build-types/higher-order/pipe.d.ts.map +1 -1
  8. package/package.json +12 -11
  9. package/src/higher-order/pipe.ts +1 -1
  10. package/src/higher-order/test/compose.ts +12 -11
  11. package/src/higher-order/test/pipe.ts +12 -11
  12. package/src/hooks/use-media-query/test/ssr.jsx +1 -3
  13. package/src/utils/create-higher-order-component/test/index.jsx +1 -0
  14. package/src/utils/debounce/test/index.ts +4 -3
  15. package/src/utils/observable-map/test/index.js +3 -2
  16. package/src/utils/throttle/test/index.ts +18 -17
  17. /package/src/higher-order/pure/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  18. /package/src/higher-order/with-global-events/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  19. /package/src/higher-order/with-global-events/test/{listener.js → listener.jsdom.test.js} +0 -0
  20. /package/src/higher-order/with-instance-id/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  21. /package/src/higher-order/with-state/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  22. /package/src/hooks/use-copy-on-click/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  23. /package/src/hooks/use-copy-to-clipboard/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  24. /package/src/hooks/use-dialog/test/{index.tsx → index.jsdom.test.tsx} +0 -0
  25. /package/src/hooks/use-disabled/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  26. /package/src/hooks/use-drop-zone/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  27. /package/src/hooks/use-focus-outside/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  28. /package/src/hooks/use-instance-id/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  29. /package/src/hooks/use-media-query/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  30. /package/src/hooks/use-merge-refs/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  31. /package/src/hooks/use-observable-value/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  32. /package/src/hooks/use-state-with-history/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  33. /package/src/hooks/use-viewport-match/test/{index.jsx → index.jsdom.test.jsx} +0 -0
  34. /package/src/utils/subscribe-delegated-listener/test/{index.js → index.jsdom.test.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 8.7.1-next.0 (2026-08-28)
5
+ ## 8.7.1-next.0 (2026-09-03)
6
6
 
7
7
  ### Internal
8
8
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/higher-order/pipe.ts"],
4
- "sourcesContent": ["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://lodash.com/docs/4#flow\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: Function[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://lodash.com/docs/4#flow\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],
4
+ "sourcesContent": ["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://lodash.com/docs/4#flow\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: ( Function | Function[] )[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://lodash.com/docs/4#flow\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiDA,IAAM,WACL,CAAE,UAAmB,UACrB,IAAK,UACL,IAAK,SAAqB;AACzB,QAAM,YAAY,MAAM,KAAK;AAC7B,MAAK,SAAU;AACd,cAAU,QAAQ;AAAA,EACnB;AACA,SAAO,UAAU;AAAA,IAChB,CAAE,MAAM,SAAU,CAAE,KAAM,GAAG,IAAK,CAAE;AAAA,IACpC;AAAA,EACD,EAAG,CAAE;AACN;AAUD,IAAM,OAAO,SAAS;AAItB,IAAO,eAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/higher-order/pipe.ts"],
4
- "sourcesContent": ["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://lodash.com/docs/4#flow\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: Function[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://lodash.com/docs/4#flow\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],
4
+ "sourcesContent": ["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://lodash.com/docs/4#flow\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: ( Function | Function[] )[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://lodash.com/docs/4#flow\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],
5
5
  "mappings": ";AAiDA,IAAM,WACL,CAAE,UAAmB,UACrB,IAAK,UACL,IAAK,SAAqB;AACzB,QAAM,YAAY,MAAM,KAAK;AAC7B,MAAK,SAAU;AACd,cAAU,QAAQ;AAAA,EACnB;AACA,SAAO,UAAU;AAAA,IAChB,CAAE,MAAM,SAAU,CAAE,KAAM,GAAG,IAAK,CAAE;AAAA,IACpC;AAAA,EACD,EAAG,CAAE;AACN;AAUD,IAAM,OAAO,SAAS;AAItB,IAAO,eAAQ;",
6
6
  "names": []
7
7
  }
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @see https://lodash.com/docs/4#flow-right
8
8
  */
9
- declare const compose: (...funcs: Function[]) => (...args: unknown[]) => unknown;
9
+ declare const compose: (...funcs: (Function | Function[])[]) => (...args: unknown[]) => unknown;
10
10
  export default compose;
11
11
  //# sourceMappingURL=compose.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/higher-order/compose.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,QAAA,MAAM,OAAO,2DAAmB,CAAC;eAElB,OAAO"}
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/higher-order/compose.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,QAAA,MAAM,OAAO,0EAAmB,CAAC;eAElB,OAAO"}
@@ -46,7 +46,7 @@
46
46
  *
47
47
  * @param {boolean} reverse True if right-to-left, false for left-to-right composition.
48
48
  */
49
- declare const basePipe: (reverse?: boolean) => (...funcs: Function[]) => (...args: unknown[]) => unknown;
49
+ declare const basePipe: (reverse?: boolean) => (...funcs: (Function | Function[])[]) => (...args: unknown[]) => unknown;
50
50
  /**
51
51
  * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
52
52
  * composition, where each successive invocation is supplied the return value of the previous.
@@ -55,7 +55,7 @@ declare const basePipe: (reverse?: boolean) => (...funcs: Function[]) => (...arg
55
55
  *
56
56
  * @see https://lodash.com/docs/4#flow
57
57
  */
58
- declare const pipe: (...funcs: Function[]) => (...args: unknown[]) => unknown;
58
+ declare const pipe: (...funcs: (Function | Function[])[]) => (...args: unknown[]) => unknown;
59
59
  export { basePipe };
60
60
  export default pipe;
61
61
  //# sourceMappingURL=pipe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../src/higher-order/pipe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,aACF,OAAO,gBACN,QAAQ,EAAE,eACX,OAAO,EAAE,YASnB,CAAC;AAEH;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,aApBG,QAAQ,EAAE,eACX,OAAO,EAAE,YAmBE,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,CAAC;eAEL,IAAI"}
1
+ {"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../src/higher-order/pipe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,aACF,OAAO,gBACN,CAAE,QAAQ,GAAG,QAAQ,EAAE,CAAE,EAAE,eAC5B,OAAO,EAAE,YASnB,CAAC;AAEH;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,aApBG,CAAE,QAAQ,GAAG,QAAQ,EAAE,CAAE,EAAE,eAC5B,OAAO,EAAE,YAmBE,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,CAAC;eAEL,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/compose",
3
- "version": "8.7.2-next.v.202608281122.0",
3
+ "version": "8.7.2-next.v.202609031004.0",
4
4
  "description": "WordPress higher-order components (HOCs).",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -46,14 +46,14 @@
46
46
  "sideEffects": false,
47
47
  "dependencies": {
48
48
  "@types/mousetrap": "^1.6.8",
49
- "@wordpress/deprecated": "^4.54.1-next.v.202608281122.0",
50
- "@wordpress/dom": "^4.54.1-next.v.202608281122.0",
51
- "@wordpress/element": "^8.6.2-next.v.202608281122.0",
52
- "@wordpress/is-shallow-equal": "^5.54.1-next.v.202608281122.0",
53
- "@wordpress/keycodes": "^4.54.1-next.v.202608281122.0",
54
- "@wordpress/priority-queue": "^3.54.1-next.v.202608281122.0",
55
- "@wordpress/private-apis": "^1.54.1-next.v.202608281122.0",
56
- "@wordpress/undo-manager": "^1.54.1-next.v.202608281122.0",
49
+ "@wordpress/deprecated": "^4.54.1-next.v.202609031004.0",
50
+ "@wordpress/dom": "^4.54.1-next.v.202609031004.0",
51
+ "@wordpress/element": "^8.6.2-next.v.202609031004.0",
52
+ "@wordpress/is-shallow-equal": "^5.54.1-next.v.202609031004.0",
53
+ "@wordpress/keycodes": "^4.54.1-next.v.202609031004.0",
54
+ "@wordpress/priority-queue": "^3.54.1-next.v.202609031004.0",
55
+ "@wordpress/private-apis": "^1.54.2-next.v.202609031004.0",
56
+ "@wordpress/undo-manager": "^1.54.1-next.v.202609031004.0",
57
57
  "change-case": "^4.1.2",
58
58
  "mousetrap": "^1.6.5",
59
59
  "use-memo-one": "^1.1.1"
@@ -64,7 +64,8 @@
64
64
  "@testing-library/user-event": "^14.6.1",
65
65
  "@types/jest": "^30.0.0",
66
66
  "mock-match-media": "^0.4.2",
67
- "react-dom": "^18.3.1"
67
+ "react-dom": "^18.3.1",
68
+ "vitest": "^4.1.10"
68
69
  },
69
70
  "peerDependencies": {
70
71
  "@types/react": "^18 || ^19",
@@ -78,5 +79,5 @@
78
79
  "publishConfig": {
79
80
  "access": "public"
80
81
  },
81
- "gitHead": "de479d415171765f7b573c81aeec5334ff506a12"
82
+ "gitHead": "7275d6c6d93b542fca3cd98cdb9c7344ddd11e19"
82
83
  }
@@ -49,7 +49,7 @@
49
49
  */
50
50
  const basePipe =
51
51
  ( reverse: boolean = false ) =>
52
- ( ...funcs: Function[] ) =>
52
+ ( ...funcs: ( Function | Function[] )[] ) =>
53
53
  ( ...args: unknown[] ) => {
54
54
  const functions = funcs.flat();
55
55
  if ( reverse ) {
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import compose from '../compose';
2
3
 
3
4
  describe( 'compose', () => {
@@ -6,27 +7,27 @@ describe( 'compose', () => {
6
7
  } );
7
8
 
8
9
  it( 'executes functions right-to-left when passed as separate arguments', () => {
9
- const a = ( value ) => ( value += 'a' );
10
- const b = ( value ) => ( value += 'b' );
11
- const c = ( value ) => ( value += 'c' );
10
+ const a = ( value: string ) => ( value += 'a' );
11
+ const b = ( value: string ) => ( value += 'b' );
12
+ const c = ( value: string ) => ( value += 'c' );
12
13
 
13
14
  expect( compose( a, b, c )( 'test' ) ).toBe( 'testcba' );
14
15
  } );
15
16
 
16
17
  it( 'executes functions right-to-left when passed as a single array', () => {
17
- const a = ( value ) => ( value += 'a' );
18
- const b = ( value ) => ( value += 'b' );
19
- const c = ( value ) => ( value += 'c' );
18
+ const a = ( value: string ) => ( value += 'a' );
19
+ const b = ( value: string ) => ( value += 'b' );
20
+ const c = ( value: string ) => ( value += 'c' );
20
21
 
21
22
  expect( compose( [ a, b, c ] )( 'test' ) ).toBe( 'testcba' );
22
23
  } );
23
24
 
24
25
  it( 'executes functions right-to-left when passed as a mix of separate arguments and arrays', () => {
25
- const a = ( value ) => ( value += 'a' );
26
- const b = ( value ) => ( value += 'b' );
27
- const c = ( value ) => ( value += 'c' );
28
- const d = ( value ) => ( value += 'd' );
29
- const e = ( value ) => ( value += 'e' );
26
+ const a = ( value: string ) => ( value += 'a' );
27
+ const b = ( value: string ) => ( value += 'b' );
28
+ const c = ( value: string ) => ( value += 'c' );
29
+ const d = ( value: string ) => ( value += 'd' );
30
+ const e = ( value: string ) => ( value += 'e' );
30
31
 
31
32
  expect( compose( [ a, b ], c, [ d ], e )( 'test' ) ).toBe(
32
33
  'testedcba'
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import pipe from '../pipe';
2
3
 
3
4
  describe( 'pipe', () => {
@@ -6,27 +7,27 @@ describe( 'pipe', () => {
6
7
  } );
7
8
 
8
9
  it( 'executes functions left-to-right when passed as separate arguments', () => {
9
- const a = ( value ) => ( value += 'a' );
10
- const b = ( value ) => ( value += 'b' );
11
- const c = ( value ) => ( value += 'c' );
10
+ const a = ( value: string ) => ( value += 'a' );
11
+ const b = ( value: string ) => ( value += 'b' );
12
+ const c = ( value: string ) => ( value += 'c' );
12
13
 
13
14
  expect( pipe( a, b, c )( 'test' ) ).toBe( 'testabc' );
14
15
  } );
15
16
 
16
17
  it( 'executes functions left-to-right when passed as a single array', () => {
17
- const a = ( value ) => ( value += 'a' );
18
- const b = ( value ) => ( value += 'b' );
19
- const c = ( value ) => ( value += 'c' );
18
+ const a = ( value: string ) => ( value += 'a' );
19
+ const b = ( value: string ) => ( value += 'b' );
20
+ const c = ( value: string ) => ( value += 'c' );
20
21
 
21
22
  expect( pipe( [ a, b, c ] )( 'test' ) ).toBe( 'testabc' );
22
23
  } );
23
24
 
24
25
  it( 'executes functions left-to-right when passed as a mix of separate arguments and arrays', () => {
25
- const a = ( value ) => ( value += 'a' );
26
- const b = ( value ) => ( value += 'b' );
27
- const c = ( value ) => ( value += 'c' );
28
- const d = ( value ) => ( value += 'd' );
29
- const e = ( value ) => ( value += 'e' );
26
+ const a = ( value: string ) => ( value += 'a' );
27
+ const b = ( value: string ) => ( value += 'b' );
28
+ const c = ( value: string ) => ( value += 'c' );
29
+ const d = ( value: string ) => ( value += 'd' );
30
+ const e = ( value: string ) => ( value += 'e' );
30
31
 
31
32
  expect( pipe( [ a, b ], c, [ d ], e )( 'test' ) ).toBe( 'testabcde' );
32
33
  } );
@@ -1,6 +1,4 @@
1
- /**
2
- * @jest-environment node
3
- */
1
+ import { describe, expect, it } from 'vitest';
4
2
  import { renderToString } from 'react-dom/server';
5
3
  import useMediaQuery from '../';
6
4
  import useViewportMatch from '../../use-viewport-match';
@@ -1,3 +1,4 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { Component } from '@wordpress/element';
2
3
  import { createHigherOrderComponent } from '../';
3
4
 
@@ -1,6 +1,7 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { debounce } from '../index';
2
3
 
3
- const identity = ( value ) => value;
4
+ const identity = < T >( value: T ) => value;
4
5
 
5
6
  describe( 'debounce', () => {
6
7
  it( 'should debounce a function', () => {
@@ -326,12 +327,12 @@ describe( 'debounce', () => {
326
327
 
327
328
  it( 'should invoke the trailing call with the correct arguments and `this` binding', () => {
328
329
  return new Promise( ( done ) => {
329
- let actual;
330
+ let actual: unknown[] | undefined;
330
331
  let callCount = 0;
331
332
  const object = {};
332
333
 
333
334
  const debounced = debounce(
334
- function ( ...args ) {
335
+ function ( this: object, ...args: unknown[] ) {
335
336
  actual = [ this ];
336
337
  Array.prototype.push.apply( actual, args );
337
338
  return ++callCount !== 2;
@@ -1,11 +1,12 @@
1
+ import { describe, expect, test, vi } from 'vitest';
1
2
  import { observableMap } from '..';
2
3
 
3
4
  describe( 'ObservableMap', () => {
4
5
  test( 'should observe individual values', () => {
5
6
  const map = observableMap();
6
7
 
7
- const listenerA = jest.fn();
8
- const listenerB = jest.fn();
8
+ const listenerA = vi.fn();
9
+ const listenerB = vi.fn();
9
10
 
10
11
  const unsubA = map.subscribe( 'a', listenerA );
11
12
  const unsubB = map.subscribe( 'b', listenerB );
@@ -1,14 +1,15 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
1
2
  import { throttle } from '../index';
2
3
 
3
- const identity = ( value ) => value;
4
+ const identity = < T >( value: T ) => value;
4
5
 
5
6
  describe( 'throttle', () => {
6
7
  beforeEach( () => {
7
- jest.useFakeTimers();
8
+ vi.useFakeTimers();
8
9
  } );
9
10
 
10
11
  afterEach( () => {
11
- jest.useRealTimers();
12
+ vi.useRealTimers();
12
13
  } );
13
14
 
14
15
  it( 'should throttle a function', () => {
@@ -24,7 +25,7 @@ describe( 'throttle', () => {
24
25
  const lastCount = callCount;
25
26
  expect( callCount ).toBeGreaterThan( 0 );
26
27
 
27
- jest.advanceTimersByTime( 64 );
28
+ vi.advanceTimersByTime( 64 );
28
29
 
29
30
  expect( callCount ).toBeGreaterThan( lastCount );
30
31
  } );
@@ -35,7 +36,7 @@ describe( 'throttle', () => {
35
36
 
36
37
  expect( results ).toStrictEqual( [ 'a', 'a' ] );
37
38
 
38
- jest.advanceTimersByTime( 64 );
39
+ vi.advanceTimersByTime( 64 );
39
40
 
40
41
  results = [ throttled( 'c' ), throttled( 'd' ) ];
41
42
  expect( results[ 0 ] ).not.toBe( 'a' );
@@ -61,7 +62,7 @@ describe( 'throttle', () => {
61
62
  throttled();
62
63
  throttled();
63
64
 
64
- jest.advanceTimersByTime( 64 );
65
+ vi.advanceTimersByTime( 64 );
65
66
 
66
67
  expect( callCount ).toBe( 2 );
67
68
  global.Date.now = globalDateNow;
@@ -76,7 +77,7 @@ describe( 'throttle', () => {
76
77
  throttled();
77
78
  expect( callCount ).toBe( 1 );
78
79
 
79
- jest.advanceTimersByTime( 64 );
80
+ vi.advanceTimersByTime( 64 );
80
81
 
81
82
  expect( callCount ).toBe( 1 );
82
83
  } );
@@ -100,11 +101,11 @@ describe( 'throttle', () => {
100
101
  const start = Date.now();
101
102
  while ( Date.now() - start < limit ) {
102
103
  throttled();
103
- jest.advanceTimersByTime( 1 );
104
+ vi.advanceTimersByTime( 1 );
104
105
  }
105
106
  const actual = callCount;
106
107
 
107
- jest.advanceTimersByTime( 1 );
108
+ vi.advanceTimersByTime( 1 );
108
109
 
109
110
  expect( actual ).toBeGreaterThan( 1 );
110
111
  }
@@ -124,16 +125,16 @@ describe( 'throttle', () => {
124
125
 
125
126
  throttled();
126
127
 
127
- jest.advanceTimersByTime( 192 );
128
+ vi.advanceTimersByTime( 192 );
128
129
 
129
130
  expect( callCount ).toBe( 1 );
130
131
  throttled();
131
132
 
132
- jest.advanceTimersByTime( 64 );
133
+ vi.advanceTimersByTime( 64 );
133
134
 
134
135
  expect( callCount ).toBe( 1 );
135
136
 
136
- jest.advanceTimersByTime( 130 );
137
+ vi.advanceTimersByTime( 130 );
137
138
 
138
139
  expect( callCount ).toBe( 2 );
139
140
  } );
@@ -152,7 +153,7 @@ describe( 'throttle', () => {
152
153
  throttled();
153
154
  expect( callCount ).toBe( 1 );
154
155
 
155
- jest.advanceTimersByTime( 128 );
156
+ vi.advanceTimersByTime( 128 );
156
157
 
157
158
  expect( callCount ).toBe( 2 );
158
159
  } );
@@ -193,7 +194,7 @@ describe( 'throttle', () => {
193
194
  expect( withoutTrailing( 'a' ) ).toBe( 'a' );
194
195
  expect( withoutTrailing( 'b' ) ).toBe( 'a' );
195
196
 
196
- jest.advanceTimersByTime( 256 );
197
+ vi.advanceTimersByTime( 256 );
197
198
 
198
199
  expect( withCount ).toBe( 2 );
199
200
  expect( withoutCount ).toBe( 1 );
@@ -213,12 +214,12 @@ describe( 'throttle', () => {
213
214
  throttled();
214
215
  throttled();
215
216
 
216
- jest.advanceTimersByTime( 96 );
217
+ vi.advanceTimersByTime( 96 );
217
218
 
218
219
  throttled();
219
220
  throttled();
220
221
 
221
- jest.advanceTimersByTime( 96 );
222
+ vi.advanceTimersByTime( 96 );
222
223
 
223
224
  expect( callCount ).toBeGreaterThan( 1 );
224
225
  } );
@@ -245,7 +246,7 @@ describe( 'throttle', () => {
245
246
  expect( results ).toStrictEqual( [ 'a', 'a', 'a' ] );
246
247
  expect( callCount ).toBe( 1 );
247
248
 
248
- jest.advanceTimersByTime( 64 );
249
+ vi.advanceTimersByTime( 64 );
249
250
 
250
251
  expect( callCount ).toBe( 2 );
251
252
  global.Date.now = globalDateNow;