@bigbinary/neeto-commons-frontend 2.0.7 → 2.0.9
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/README.md +1 -1
- package/initializers.cjs.js +17 -21
- package/initializers.js +17 -21
- package/package.json +2 -2
- package/pure.cjs.js +49 -41
- package/pure.d.ts +3 -1
- package/pure.js +49 -42
- package/react-utils.cjs.js +8 -1
- package/react-utils.d.ts +3 -3
- package/react-utils.js +8 -1
- package/utils.cjs.js +1950 -514
- package/utils.js +1950 -515
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The commons frontend library for Neeto Applications.
|
|
|
7
7
|
Install from npm:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
yarn add "@bigbinary/neeto-commons-frontend@2.0.
|
|
10
|
+
yarn add "@bigbinary/neeto-commons-frontend@2.0.9"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
This package relies on the host project's tailwind configuration. So add
|
package/initializers.cjs.js
CHANGED
|
@@ -113,20 +113,26 @@ var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
116
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
117
|
+
|
|
118
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
119
|
+
object = objectPreProcessor(object);
|
|
120
|
+
}
|
|
121
|
+
|
|
116
122
|
if (Array.isArray(object)) {
|
|
117
123
|
return object.map(function (obj) {
|
|
118
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
124
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
119
125
|
});
|
|
120
126
|
} else if (object === null || _typeof(object) !== "object") {
|
|
121
127
|
return object;
|
|
122
128
|
}
|
|
123
129
|
|
|
124
|
-
return Object.fromEntries(Object.entries(object).map(function (
|
|
125
|
-
var
|
|
126
|
-
key =
|
|
127
|
-
value =
|
|
130
|
+
return Object.fromEntries(Object.entries(object).map(function (_ref3) {
|
|
131
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
132
|
+
key = _ref4[0],
|
|
133
|
+
value = _ref4[1];
|
|
128
134
|
|
|
129
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
135
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
130
136
|
}));
|
|
131
137
|
};
|
|
132
138
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -135,21 +141,11 @@ var keysToCamelCase = function keysToCamelCase(object) {
|
|
|
135
141
|
});
|
|
136
142
|
};
|
|
137
143
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
return serializedObj;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return Object.fromEntries(Object.entries(serializedObj).map(function (_ref3) {
|
|
147
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
148
|
-
key = _ref4[0],
|
|
149
|
-
value = _ref4[1];
|
|
150
|
-
|
|
151
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
152
|
-
}));
|
|
144
|
+
return transformObjectDeep(object, function (key, value) {
|
|
145
|
+
return [camelToSnakeCase(key), value];
|
|
146
|
+
}, function (object) {
|
|
147
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
148
|
+
});
|
|
153
149
|
};
|
|
154
150
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
155
151
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
package/initializers.js
CHANGED
|
@@ -103,20 +103,26 @@ var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
106
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
107
|
+
|
|
108
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
109
|
+
object = objectPreProcessor(object);
|
|
110
|
+
}
|
|
111
|
+
|
|
106
112
|
if (Array.isArray(object)) {
|
|
107
113
|
return object.map(function (obj) {
|
|
108
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
114
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
109
115
|
});
|
|
110
116
|
} else if (object === null || _typeof(object) !== "object") {
|
|
111
117
|
return object;
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
return Object.fromEntries(Object.entries(object).map(function (
|
|
115
|
-
var
|
|
116
|
-
key =
|
|
117
|
-
value =
|
|
120
|
+
return Object.fromEntries(Object.entries(object).map(function (_ref3) {
|
|
121
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
122
|
+
key = _ref4[0],
|
|
123
|
+
value = _ref4[1];
|
|
118
124
|
|
|
119
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
125
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
120
126
|
}));
|
|
121
127
|
};
|
|
122
128
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -125,21 +131,11 @@ var keysToCamelCase = function keysToCamelCase(object) {
|
|
|
125
131
|
});
|
|
126
132
|
};
|
|
127
133
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
return serializedObj;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return Object.fromEntries(Object.entries(serializedObj).map(function (_ref3) {
|
|
137
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
138
|
-
key = _ref4[0],
|
|
139
|
-
value = _ref4[1];
|
|
140
|
-
|
|
141
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
142
|
-
}));
|
|
134
|
+
return transformObjectDeep(object, function (key, value) {
|
|
135
|
+
return [camelToSnakeCase(key), value];
|
|
136
|
+
}, function (object) {
|
|
137
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
138
|
+
});
|
|
143
139
|
};
|
|
144
140
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
145
141
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"lint-staged": "^12.3.7",
|
|
82
82
|
"mixpanel-browser": "^2.45.0",
|
|
83
83
|
"prettier": "^2.6.2",
|
|
84
|
-
"
|
|
84
|
+
"qs": "^6.11.0",
|
|
85
85
|
"ramda": "^0.28.0",
|
|
86
86
|
"react": "^17.0.2",
|
|
87
87
|
"react-dom": "17.0.2",
|
package/pure.cjs.js
CHANGED
|
@@ -106,21 +106,43 @@ var truncate = function truncate(string, length) {
|
|
|
106
106
|
return string.length > length ? ramda.concat(ramda.slice(0, length, string), "...") : string;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
+
var matchesImpl = function matchesImpl(pattern, object) {
|
|
110
|
+
var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
|
|
111
|
+
|
|
112
|
+
if (object === pattern) return true;
|
|
113
|
+
if (typeof pattern === "function" && pattern(object, __parent)) return true;
|
|
114
|
+
if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
|
|
115
|
+
if (_typeof(pattern) !== "object") return false;
|
|
116
|
+
return Object.entries(pattern).every(function (_ref) {
|
|
117
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
118
|
+
key = _ref2[0],
|
|
119
|
+
value = _ref2[1];
|
|
120
|
+
|
|
121
|
+
return matchesImpl(value, object[key], __parent);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
109
125
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
126
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
127
|
+
|
|
128
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
129
|
+
object = objectPreProcessor(object);
|
|
130
|
+
}
|
|
131
|
+
|
|
110
132
|
if (Array.isArray(object)) {
|
|
111
133
|
return object.map(function (obj) {
|
|
112
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
134
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
113
135
|
});
|
|
114
136
|
} else if (object === null || _typeof(object) !== "object") {
|
|
115
137
|
return object;
|
|
116
138
|
}
|
|
117
139
|
|
|
118
|
-
return Object.fromEntries(Object.entries(object).map(function (
|
|
119
|
-
var
|
|
120
|
-
key =
|
|
121
|
-
value =
|
|
140
|
+
return Object.fromEntries(Object.entries(object).map(function (_ref3) {
|
|
141
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
142
|
+
key = _ref4[0],
|
|
143
|
+
value = _ref4[1];
|
|
122
144
|
|
|
123
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
145
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
124
146
|
}));
|
|
125
147
|
};
|
|
126
148
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -134,21 +156,18 @@ var keysToSnakeCase = function keysToSnakeCase(object) {
|
|
|
134
156
|
});
|
|
135
157
|
};
|
|
136
158
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
151
|
-
}));
|
|
159
|
+
return transformObjectDeep(object, function (key, value) {
|
|
160
|
+
return [camelToSnakeCase(key), value];
|
|
161
|
+
}, function (object) {
|
|
162
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
var preprocessForSerialization = function preprocessForSerialization(object) {
|
|
166
|
+
return transformObjectDeep(object, function (key, value) {
|
|
167
|
+
return [key, value];
|
|
168
|
+
}, function (object) {
|
|
169
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
170
|
+
});
|
|
152
171
|
};
|
|
153
172
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
154
173
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
|
@@ -161,30 +180,18 @@ var deepFreezeObject = function deepFreezeObject(object) {
|
|
|
161
180
|
return object;
|
|
162
181
|
};
|
|
163
182
|
var matches = /*#__PURE__*/ramda.curry(function (pattern, object) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (object === pattern) return true;
|
|
167
|
-
if (typeof pattern === "function" && pattern(object, __parent)) return true;
|
|
168
|
-
if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
|
|
169
|
-
if (_typeof(pattern) !== "object") return false;
|
|
170
|
-
return Object.entries(pattern).every(function (_ref5) {
|
|
171
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
172
|
-
key = _ref6[0],
|
|
173
|
-
value = _ref6[1];
|
|
174
|
-
|
|
175
|
-
return matches(value, object[key], __parent);
|
|
176
|
-
});
|
|
183
|
+
return matchesImpl(pattern, object);
|
|
177
184
|
});
|
|
178
185
|
var filterNonNull = function filterNonNull(object) {
|
|
179
|
-
return Object.fromEntries(Object.entries(object).filter(function (
|
|
180
|
-
var
|
|
181
|
-
v =
|
|
186
|
+
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
187
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
188
|
+
v = _ref6[1];
|
|
182
189
|
|
|
183
190
|
return !ramda.isNil(v);
|
|
184
|
-
}).map(function (
|
|
185
|
-
var
|
|
186
|
-
k =
|
|
187
|
-
v =
|
|
191
|
+
}).map(function (_ref7) {
|
|
192
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
193
|
+
k = _ref8[0],
|
|
194
|
+
v = _ref8[1];
|
|
188
195
|
|
|
189
196
|
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
190
197
|
}));
|
|
@@ -396,6 +403,7 @@ exports.modifyById = modifyById;
|
|
|
396
403
|
exports.noop = noop;
|
|
397
404
|
exports.notEquals = notEquals;
|
|
398
405
|
exports.notEqualsDeep = notEqualsDeep;
|
|
406
|
+
exports.preprocessForSerialization = preprocessForSerialization;
|
|
399
407
|
exports.randomPick = randomPick;
|
|
400
408
|
exports.removeBy = removeBy;
|
|
401
409
|
exports.removeById = removeById;
|
package/pure.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ export function replaceById<T>(id: any, entityArray: T[]): T[];
|
|
|
170
170
|
export function replaceById(id: any): <T>(entityArray: T[]) => T[];
|
|
171
171
|
|
|
172
172
|
export function serializeKeysToSnakeCase(object: object): object;
|
|
173
|
+
export function preprocessForSerialization(object: object): object;
|
|
173
174
|
export function slugify(string: string): string;
|
|
174
175
|
export function snakeToCamelCase(string: string): string;
|
|
175
176
|
export function toLabelAndValue(string: string): {
|
|
@@ -178,7 +179,8 @@ export function toLabelAndValue(string: string): {
|
|
|
178
179
|
};
|
|
179
180
|
export function transformObjectDeep(
|
|
180
181
|
object: object,
|
|
181
|
-
keyValueTransformer: (key: string | number | symbol, object: any) => any[]
|
|
182
|
+
keyValueTransformer: (key: string | number | symbol, object: any) => any[],
|
|
183
|
+
objectPreProcessor?: (object: any) => any
|
|
182
184
|
): object;
|
|
183
185
|
|
|
184
186
|
export function truncate(string: string, length: number): string;
|
package/pure.js
CHANGED
|
@@ -102,21 +102,43 @@ var truncate = function truncate(string, length) {
|
|
|
102
102
|
return string.length > length ? concat(slice(0, length, string), "...") : string;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
var matchesImpl = function matchesImpl(pattern, object) {
|
|
106
|
+
var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
|
|
107
|
+
|
|
108
|
+
if (object === pattern) return true;
|
|
109
|
+
if (typeof pattern === "function" && pattern(object, __parent)) return true;
|
|
110
|
+
if (isNil(pattern) || isNil(object)) return false;
|
|
111
|
+
if (_typeof(pattern) !== "object") return false;
|
|
112
|
+
return Object.entries(pattern).every(function (_ref) {
|
|
113
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
114
|
+
key = _ref2[0],
|
|
115
|
+
value = _ref2[1];
|
|
116
|
+
|
|
117
|
+
return matchesImpl(value, object[key], __parent);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
105
121
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
122
|
+
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
123
|
+
|
|
124
|
+
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
125
|
+
object = objectPreProcessor(object);
|
|
126
|
+
}
|
|
127
|
+
|
|
106
128
|
if (Array.isArray(object)) {
|
|
107
129
|
return object.map(function (obj) {
|
|
108
|
-
return transformObjectDeep(obj, keyValueTransformer);
|
|
130
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
109
131
|
});
|
|
110
132
|
} else if (object === null || _typeof(object) !== "object") {
|
|
111
133
|
return object;
|
|
112
134
|
}
|
|
113
135
|
|
|
114
|
-
return Object.fromEntries(Object.entries(object).map(function (
|
|
115
|
-
var
|
|
116
|
-
key =
|
|
117
|
-
value =
|
|
136
|
+
return Object.fromEntries(Object.entries(object).map(function (_ref3) {
|
|
137
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
138
|
+
key = _ref4[0],
|
|
139
|
+
value = _ref4[1];
|
|
118
140
|
|
|
119
|
-
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
|
|
141
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
120
142
|
}));
|
|
121
143
|
};
|
|
122
144
|
var keysToCamelCase = function keysToCamelCase(object) {
|
|
@@ -130,21 +152,18 @@ var keysToSnakeCase = function keysToSnakeCase(object) {
|
|
|
130
152
|
});
|
|
131
153
|
};
|
|
132
154
|
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
|
|
147
|
-
}));
|
|
155
|
+
return transformObjectDeep(object, function (key, value) {
|
|
156
|
+
return [camelToSnakeCase(key), value];
|
|
157
|
+
}, function (object) {
|
|
158
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
var preprocessForSerialization = function preprocessForSerialization(object) {
|
|
162
|
+
return transformObjectDeep(object, function (key, value) {
|
|
163
|
+
return [key, value];
|
|
164
|
+
}, function (object) {
|
|
165
|
+
return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
|
|
166
|
+
});
|
|
148
167
|
};
|
|
149
168
|
var deepFreezeObject = function deepFreezeObject(object) {
|
|
150
169
|
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
|
@@ -157,30 +176,18 @@ var deepFreezeObject = function deepFreezeObject(object) {
|
|
|
157
176
|
return object;
|
|
158
177
|
};
|
|
159
178
|
var matches = /*#__PURE__*/curry(function (pattern, object) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (object === pattern) return true;
|
|
163
|
-
if (typeof pattern === "function" && pattern(object, __parent)) return true;
|
|
164
|
-
if (isNil(pattern) || isNil(object)) return false;
|
|
165
|
-
if (_typeof(pattern) !== "object") return false;
|
|
166
|
-
return Object.entries(pattern).every(function (_ref5) {
|
|
167
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
168
|
-
key = _ref6[0],
|
|
169
|
-
value = _ref6[1];
|
|
170
|
-
|
|
171
|
-
return matches(value, object[key], __parent);
|
|
172
|
-
});
|
|
179
|
+
return matchesImpl(pattern, object);
|
|
173
180
|
});
|
|
174
181
|
var filterNonNull = function filterNonNull(object) {
|
|
175
|
-
return Object.fromEntries(Object.entries(object).filter(function (
|
|
176
|
-
var
|
|
177
|
-
v =
|
|
182
|
+
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
183
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
184
|
+
v = _ref6[1];
|
|
178
185
|
|
|
179
186
|
return !isNil(v);
|
|
180
|
-
}).map(function (
|
|
181
|
-
var
|
|
182
|
-
k =
|
|
183
|
-
v =
|
|
187
|
+
}).map(function (_ref7) {
|
|
188
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
189
|
+
k = _ref8[0],
|
|
190
|
+
v = _ref8[1];
|
|
184
191
|
|
|
185
192
|
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
186
193
|
}));
|
|
@@ -361,4 +368,4 @@ var isNot = notEquals;
|
|
|
361
368
|
var notEqualsDeep = /*#__PURE__*/complement(equals);
|
|
362
369
|
var isNotEqualDeep = notEqualsDeep;
|
|
363
370
|
|
|
364
|
-
export { camelToSnakeCase, capitalize, copyKeys, copyKeysDeep, countBy, deepFreezeObject, dynamicArray, existsBy, existsById, filterBy, filterNonNull, findBy, findById, findIndexBy, findIndexById, findLastBy, findLastIndexBy, getRandomInt, humanize, isNot, isNotEmpty, isNotEqualDeep, isNotNil, keysToCamelCase, keysToSnakeCase, matches, modifyBy, modifyById, noop, notEquals, notEqualsDeep, randomPick, removeBy, removeById, renameKeys, replaceBy, replaceById, serializeKeysToSnakeCase, slugify, snakeToCamelCase, toLabelAndValue, transformObjectDeep, truncate };
|
|
371
|
+
export { camelToSnakeCase, capitalize, copyKeys, copyKeysDeep, countBy, deepFreezeObject, dynamicArray, existsBy, existsById, filterBy, filterNonNull, findBy, findById, findIndexBy, findIndexById, findLastBy, findLastIndexBy, getRandomInt, humanize, isNot, isNotEmpty, isNotEqualDeep, isNotNil, keysToCamelCase, keysToSnakeCase, matches, modifyBy, modifyById, noop, notEquals, notEqualsDeep, preprocessForSerialization, randomPick, removeBy, removeById, renameKeys, replaceBy, replaceById, serializeKeysToSnakeCase, slugify, snakeToCamelCase, toLabelAndValue, transformObjectDeep, truncate };
|
package/react-utils.cjs.js
CHANGED
|
@@ -451,7 +451,8 @@ function useDebounce(value) {
|
|
|
451
451
|
var useFuncDebounce = function useFuncDebounce(func) {
|
|
452
452
|
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
453
453
|
var timer = React.useRef(null);
|
|
454
|
-
|
|
454
|
+
|
|
455
|
+
var debouncedFunc = function debouncedFunc() {
|
|
455
456
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
456
457
|
args[_key] = arguments[_key];
|
|
457
458
|
}
|
|
@@ -461,6 +462,12 @@ var useFuncDebounce = function useFuncDebounce(func) {
|
|
|
461
462
|
return func.apply(void 0, args);
|
|
462
463
|
}, delay);
|
|
463
464
|
};
|
|
465
|
+
|
|
466
|
+
debouncedFunc.cancel = function () {
|
|
467
|
+
return clearTimeout(timer.current);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
return debouncedFunc;
|
|
464
471
|
};
|
|
465
472
|
|
|
466
473
|
var getStorageValue = function getStorageValue(key, defaultValue) {
|
package/react-utils.d.ts
CHANGED
|
@@ -37,10 +37,10 @@ export const Sidebar: React.FC<{
|
|
|
37
37
|
}>;
|
|
38
38
|
|
|
39
39
|
export function useDebounce<T>(value: T, delay?: number): T;
|
|
40
|
-
export function useFuncDebounce<
|
|
41
|
-
func:
|
|
40
|
+
export function useFuncDebounce<F extends Function>(
|
|
41
|
+
func: F,
|
|
42
42
|
delay?: number
|
|
43
|
-
): (
|
|
43
|
+
): (F & { cancel: () => void };
|
|
44
44
|
export function useLocalStorage<T>(
|
|
45
45
|
key: string,
|
|
46
46
|
initialValue?: T
|
package/react-utils.js
CHANGED
|
@@ -419,7 +419,8 @@ function useDebounce(value) {
|
|
|
419
419
|
var useFuncDebounce = function useFuncDebounce(func) {
|
|
420
420
|
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
421
421
|
var timer = useRef(null);
|
|
422
|
-
|
|
422
|
+
|
|
423
|
+
var debouncedFunc = function debouncedFunc() {
|
|
423
424
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
424
425
|
args[_key] = arguments[_key];
|
|
425
426
|
}
|
|
@@ -429,6 +430,12 @@ var useFuncDebounce = function useFuncDebounce(func) {
|
|
|
429
430
|
return func.apply(void 0, args);
|
|
430
431
|
}, delay);
|
|
431
432
|
};
|
|
433
|
+
|
|
434
|
+
debouncedFunc.cancel = function () {
|
|
435
|
+
return clearTimeout(timer.current);
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
return debouncedFunc;
|
|
432
439
|
};
|
|
433
440
|
|
|
434
441
|
var getStorageValue = function getStorageValue(key, defaultValue) {
|