@instructure/debounce 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/debounce
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/debounce
@@ -1,16 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "debounce", {
7
- enumerable: true,
8
- get: function () {
9
- return _debounce.debounce;
10
- }
11
- });
12
- exports.default = void 0;
13
- var _debounce = require("./debounce");
14
1
  /*
15
2
  * The MIT License (MIT)
16
3
  *
@@ -34,4 +21,17 @@ var _debounce = require("./debounce");
34
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
22
  * SOFTWARE.
36
23
  */
37
- var _default = exports.default = _debounce.debounce;
24
+
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/debounce",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A debounce util made by Instructure Inc.",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "@babel/runtime": "^7.27.6"
18
18
  },
19
19
  "devDependencies": {
20
- "@instructure/ui-babel-preset": "11.6.0"
20
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"
@@ -27,10 +27,8 @@
27
27
  ".": {
28
28
  "types": "./types/index.d.ts",
29
29
  "import": "./es/index.js",
30
- "require": "./lib/index.js",
31
30
  "default": "./es/index.js"
32
31
  },
33
- "./lib/*": "./lib/*",
34
32
  "./es/*": "./es/*",
35
33
  "./types/*": "./types/*",
36
34
  "./package.json": "./package.json",
@@ -40,7 +38,7 @@
40
38
  "lint": "ui-scripts lint",
41
39
  "lint:fix": "ui-scripts lint --fix",
42
40
  "clean": "ui-scripts clean",
43
- "build": "ui-scripts build --modules es,cjs",
41
+ "build": "ui-scripts build",
44
42
  "build:watch": "ui-scripts build --watch",
45
43
  "build:types": "tsc -p tsconfig.build.json"
46
44
  }
package/lib/debounce.js DELETED
@@ -1,169 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.debounce = debounce;
7
- exports.default = void 0;
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- /**
33
- * ---
34
- * category: utilities/utils
35
- * ---
36
- * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed
37
- * since the last time the debounced function was invoked. The debounced function comes with a cancel
38
- * method to cancel delayed func invocations and a flush method to immediately invoke them. Provide options
39
- * to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout.
40
- * The func is invoked with the last arguments provided to the debounced function. Subsequent calls to the
41
- * debounced function return the result of the last func invocation.
42
- *
43
- * [lodash.debounce](https://github.com/lodash/lodash/blob/master/debounce.js)
44
- * doesn't work well with [sinon fakeTimers](http://sinonjs.org/releases/v1.17.7/fake-timers/)
45
- * so this is forked from the lodash source.
46
- *
47
- * Note: Modified from the original to check for cancelled boolean before invoking func to prevent React setState
48
- * on unmounted components.
49
- * For a cool explanation see https://css-tricks.com/debouncing-throttling-explained-examples/
50
- *
51
- * @module debounce
52
- *
53
- * @param func The function to debounce.
54
- * @param wait The number of milliseconds to delay.
55
- * @param options options object.
56
- * @returns Returns the new debounced function.
57
- */
58
- function debounce(func, wait = 0, options = {}) {
59
- let lastArgs;
60
- let lastThis;
61
- let result;
62
- let lastCallTime;
63
- let lastInvokeTime = 0;
64
- let timers = [];
65
- if (typeof func !== 'function') {
66
- throw new TypeError('Expected a function');
67
- }
68
- const leading = !!options.leading;
69
- const maxing = 'maxWait' in options;
70
- const trailing = 'trailing' in options ? !!options.trailing : true;
71
- const maxWait = maxing ? Math.max(+!options.maxWait || 0, wait) : 0;
72
- function invokeFunc(time) {
73
- const args = lastArgs;
74
- const thisArg = lastThis;
75
- lastArgs = void 0;
76
- lastThis = void 0;
77
- lastInvokeTime = time;
78
- result = func.apply(thisArg, args);
79
- return result;
80
- }
81
- function leadingEdge(time) {
82
- // Reset any `maxWait` timer.
83
- lastInvokeTime = time;
84
- // Start the timer for the trailing edge.
85
- timers.push(setTimeout(timerExpired, wait));
86
- // Invoke the leading edge.
87
- return leading ? invokeFunc(time) : result;
88
- }
89
- function remainingWait(time) {
90
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
91
- // @ts-ignore
92
- const timeSinceLastCall = time - lastCallTime;
93
- const timeSinceLastInvoke = time - lastInvokeTime;
94
- const result = wait - timeSinceLastCall;
95
- return maxing ? Math.min(result, maxWait - timeSinceLastInvoke) : result;
96
- }
97
- function shouldInvoke(time) {
98
- if (typeof lastCallTime === 'undefined') {
99
- return true;
100
- }
101
- const timeSinceLastCall = time - lastCallTime;
102
- const timeSinceLastInvoke = time - lastInvokeTime;
103
-
104
- // Either this is the first call, activity has stopped and we're at the
105
- // trailing edge, the system time has gone backwards and we're treating
106
- // it as the trailing edge, or we've hit the `maxWait` limit.
107
- return timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
108
- }
109
- function timerExpired() {
110
- const time = Date.now();
111
- if (shouldInvoke(time)) {
112
- trailingEdge(time);
113
- } else {
114
- // Restart the timer.
115
- timers.push(setTimeout(timerExpired, remainingWait(time)));
116
- }
117
- }
118
- function trailingEdge(time) {
119
- clearAllTimers();
120
- // Only invoke if we have `lastArgs` which means `func` has been
121
- // debounced at least once.
122
- if (trailing && lastArgs) {
123
- return invokeFunc(time);
124
- }
125
- lastArgs = lastThis = void 0;
126
- return result;
127
- }
128
- function cancel() {
129
- clearAllTimers();
130
- lastInvokeTime = 0;
131
- lastCallTime = 0;
132
- lastArgs = lastThis = void 0;
133
- }
134
- function flush() {
135
- return timers.length === 0 ? result : trailingEdge(Date.now());
136
- }
137
- function clearAllTimers() {
138
- timers.forEach(timerId => clearTimeout(timerId));
139
- timers = [];
140
- }
141
- function debounced(...args) {
142
- const time = Date.now();
143
- const isInvoking = shouldInvoke(time);
144
- lastArgs = args;
145
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
146
- // @ts-ignore
147
- // eslint-disable-next-line @typescript-eslint/no-this-alias
148
- lastThis = this;
149
- lastCallTime = time;
150
- if (isInvoking) {
151
- if (timers.length === 0) {
152
- return leadingEdge(lastCallTime);
153
- }
154
- if (maxing) {
155
- // Handle invocations in a tight loop.
156
- timers.push(setTimeout(timerExpired, wait));
157
- return invokeFunc(lastCallTime);
158
- }
159
- }
160
- if (timers.length === 0) {
161
- timers.push(setTimeout(timerExpired, wait));
162
- }
163
- return result;
164
- }
165
- debounced.cancel = cancel;
166
- debounced.flush = flush;
167
- return debounced;
168
- }
169
- var _default = exports.default = debounce;
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}