@bigbinary/neeto-commons-frontend 0.0.1 → 0.0.2
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 +41 -9
- package/initializers.cjs.js +438 -0
- package/initializers.d.ts +59 -0
- package/initializers.js +307 -74
- package/package.json +26 -7
- package/pure.cjs.js +418 -0
- package/pure.d.ts +186 -0
- package/pure.js +78 -99
- package/{react.js → react-utils.cjs.js} +228 -65
- package/react-utils.d.ts +99 -0
- package/react-utils.js +1309 -0
- package/utils.cjs.js +2781 -0
- package/utils.d.ts +43 -0
- package/utils.js +2203 -46
package/pure.cjs.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var ramda = require('ramda');
|
|
6
|
+
|
|
7
|
+
function _arrayWithHoles(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function _iterableToArrayLimit(arr, i) {
|
|
12
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
13
|
+
|
|
14
|
+
if (_i == null) return;
|
|
15
|
+
var _arr = [];
|
|
16
|
+
var _n = true;
|
|
17
|
+
var _d = false;
|
|
18
|
+
|
|
19
|
+
var _s, _e;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
23
|
+
_arr.push(_s.value);
|
|
24
|
+
|
|
25
|
+
if (i && _arr.length === i) break;
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
_d = true;
|
|
29
|
+
_e = err;
|
|
30
|
+
} finally {
|
|
31
|
+
try {
|
|
32
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
33
|
+
} finally {
|
|
34
|
+
if (_d) throw _e;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return _arr;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _arrayLikeToArray(arr, len) {
|
|
42
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
43
|
+
|
|
44
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
45
|
+
arr2[i] = arr[i];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return arr2;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
52
|
+
if (!o) return;
|
|
53
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
54
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
57
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _nonIterableRest() {
|
|
61
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _slicedToArray(arr, i) {
|
|
65
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function _typeof(obj) {
|
|
69
|
+
"@babel/helpers - typeof";
|
|
70
|
+
|
|
71
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
72
|
+
return typeof obj;
|
|
73
|
+
} : function (obj) {
|
|
74
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
75
|
+
}, _typeof(obj);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var slugify = function slugify(string) {
|
|
79
|
+
return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
|
|
80
|
+
.replace(/&/g, "-and-") // Replace & with 'and'
|
|
81
|
+
.replace(/[^\w-]+/g, "") // Remove all non-word characters
|
|
82
|
+
.replace(/--+/g, "-") // Replace multiple - with single -
|
|
83
|
+
.replace(/^-+/, "") // Trim - from start of text
|
|
84
|
+
.replace(/-+$/, "");
|
|
85
|
+
}; // Trim - from end of text
|
|
86
|
+
|
|
87
|
+
var humanize = function humanize(string) {
|
|
88
|
+
string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
|
|
89
|
+
string = string.charAt(0).toUpperCase() + string.slice(1);
|
|
90
|
+
return string;
|
|
91
|
+
};
|
|
92
|
+
var snakeToCamelCase = function snakeToCamelCase(string) {
|
|
93
|
+
return string.replace(/(_\w)/g, function (letter) {
|
|
94
|
+
return letter[1].toUpperCase();
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
var camelToSnakeCase = function camelToSnakeCase(string) {
|
|
98
|
+
return string.replace(/[A-Z]/g, function (letter) {
|
|
99
|
+
return "_".concat(letter.toLowerCase());
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
var capitalize = function capitalize(string) {
|
|
103
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
104
|
+
};
|
|
105
|
+
var truncate = function truncate(string, length) {
|
|
106
|
+
return string.length > length ? ramda.concat(ramda.slice(0, length, string), "...") : string;
|
|
107
|
+
};
|
|
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
|
+
|
|
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
|
+
|
|
132
|
+
if (Array.isArray(object)) {
|
|
133
|
+
return object.map(function (obj) {
|
|
134
|
+
return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
|
|
135
|
+
});
|
|
136
|
+
} else if (object === null || _typeof(object) !== "object") {
|
|
137
|
+
return object;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return Object.fromEntries(Object.entries(object).map(function (_ref3) {
|
|
141
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
142
|
+
key = _ref4[0],
|
|
143
|
+
value = _ref4[1];
|
|
144
|
+
|
|
145
|
+
return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
|
|
146
|
+
}));
|
|
147
|
+
};
|
|
148
|
+
var keysToCamelCase = function keysToCamelCase(object) {
|
|
149
|
+
return transformObjectDeep(object, function (key, value) {
|
|
150
|
+
return [snakeToCamelCase(key), value];
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
var keysToSnakeCase = function keysToSnakeCase(object) {
|
|
154
|
+
return transformObjectDeep(object, function (key, value) {
|
|
155
|
+
return [camelToSnakeCase(key), value];
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
|
|
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
|
+
});
|
|
171
|
+
};
|
|
172
|
+
var deepFreezeObject = function deepFreezeObject(object) {
|
|
173
|
+
if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
|
|
174
|
+
Object.keys(object).forEach(function (property) {
|
|
175
|
+
return deepFreezeObject(object[property]);
|
|
176
|
+
});
|
|
177
|
+
Object.freeze(object);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return object;
|
|
181
|
+
};
|
|
182
|
+
var matches = /*#__PURE__*/ramda.curry(function (pattern, object) {
|
|
183
|
+
return matchesImpl(pattern, object);
|
|
184
|
+
});
|
|
185
|
+
var filterNonNull = function filterNonNull(object) {
|
|
186
|
+
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
187
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
188
|
+
v = _ref6[1];
|
|
189
|
+
|
|
190
|
+
return !ramda.isNil(v);
|
|
191
|
+
}).map(function (_ref7) {
|
|
192
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
193
|
+
k = _ref8[0],
|
|
194
|
+
v = _ref8[1];
|
|
195
|
+
|
|
196
|
+
return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
|
|
197
|
+
}));
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
function _defineProperty(obj, key, value) {
|
|
201
|
+
if (key in obj) {
|
|
202
|
+
Object.defineProperty(obj, key, {
|
|
203
|
+
value: value,
|
|
204
|
+
enumerable: true,
|
|
205
|
+
configurable: true,
|
|
206
|
+
writable: true
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
obj[key] = value;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return obj;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
216
|
+
|
|
217
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
218
|
+
var removeById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
219
|
+
return array.filter(function (item) {
|
|
220
|
+
return item.id !== id;
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
var findById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
224
|
+
return array.find(function (item) {
|
|
225
|
+
return item.id === id;
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
var replaceById = /*#__PURE__*/ramda.curry(function (id, newItem, array) {
|
|
229
|
+
return array.map(function (item) {
|
|
230
|
+
return item.id === id ? newItem : item;
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
var modifyById = /*#__PURE__*/ramda.curry(function (id, modifier, array) {
|
|
234
|
+
return array.map(function (item) {
|
|
235
|
+
return item.id === id ? modifier(item) : item;
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
var findBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
239
|
+
return array.find(matches(pattern));
|
|
240
|
+
});
|
|
241
|
+
var removeBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
242
|
+
return array.filter(ramda.complement(matches(pattern)));
|
|
243
|
+
});
|
|
244
|
+
var replaceBy = /*#__PURE__*/ramda.curry(function (pattern, newItem, array) {
|
|
245
|
+
return array.map(function (item) {
|
|
246
|
+
return matches(pattern, item) ? newItem : item;
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
var modifyBy = /*#__PURE__*/ramda.curry(function (pattern, modifier, array) {
|
|
250
|
+
return array.map(function (item) {
|
|
251
|
+
return matches(pattern, item) ? modifier(item) : item;
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
var existsById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
255
|
+
return array.some(function (item) {
|
|
256
|
+
return item.id === id;
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
var existsBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
260
|
+
return array.some(matches(pattern));
|
|
261
|
+
});
|
|
262
|
+
var findLastBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
263
|
+
return ramda.findLast(matches(pattern), array);
|
|
264
|
+
});
|
|
265
|
+
var findIndexById = /*#__PURE__*/ramda.curry(function (id, array) {
|
|
266
|
+
return array.findIndex(function (item) {
|
|
267
|
+
return item.id === id;
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
var findIndexBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
271
|
+
return array.findIndex(matches(pattern));
|
|
272
|
+
});
|
|
273
|
+
var findLastIndexBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
274
|
+
return ramda.findLastIndex(matches(pattern), array);
|
|
275
|
+
});
|
|
276
|
+
var filterBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
277
|
+
return array.filter(matches(pattern));
|
|
278
|
+
});
|
|
279
|
+
var countBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
|
|
280
|
+
return ramda.count(matches(pattern), array);
|
|
281
|
+
});
|
|
282
|
+
var copyKeys = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
|
|
283
|
+
return objectArray.map(function (object) {
|
|
284
|
+
var shallowCopy = _objectSpread({}, object);
|
|
285
|
+
|
|
286
|
+
for (var source in keyMap) {
|
|
287
|
+
shallowCopy[keyMap[source]] = object[source];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return shallowCopy;
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
var renameKeys = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
|
|
294
|
+
return objectArray.map(function (object) {
|
|
295
|
+
var shallowCopy = _objectSpread({}, object);
|
|
296
|
+
|
|
297
|
+
for (var source in keyMap) {
|
|
298
|
+
shallowCopy[keyMap[source]] = object[source];
|
|
299
|
+
delete shallowCopy[source];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return shallowCopy;
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
var copyKeysDeep = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
|
|
306
|
+
var copyKeysSingleObject = function copyKeysSingleObject(object, keyMap) {
|
|
307
|
+
var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
|
|
308
|
+
return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref) {
|
|
309
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
310
|
+
destination = _ref2[0],
|
|
311
|
+
source = _ref2[1];
|
|
312
|
+
|
|
313
|
+
if (typeof source === "function") {
|
|
314
|
+
return [destination, source(object[destination], root)];
|
|
315
|
+
} else if (Array.isArray(source)) {
|
|
316
|
+
return [destination, ramda.path(source, root)];
|
|
317
|
+
} else if (_typeof(source) === "object") {
|
|
318
|
+
return [destination, copyKeysSingleObject(object[destination], source, root)];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return [destination, object[source]];
|
|
322
|
+
})));
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
return objectArray.map(function (object) {
|
|
326
|
+
return copyKeysSingleObject(object, keyMap);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
var noop = function noop() {};
|
|
331
|
+
var toLabelAndValue = function toLabelAndValue(string) {
|
|
332
|
+
return {
|
|
333
|
+
label: string,
|
|
334
|
+
value: string
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
var getRandomInt = function getRandomInt() {
|
|
338
|
+
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
|
|
339
|
+
var b = arguments.length > 1 ? arguments[1] : undefined;
|
|
340
|
+
|
|
341
|
+
if (b) {
|
|
342
|
+
a = Math.ceil(a);
|
|
343
|
+
b = Math.floor(b);
|
|
344
|
+
} else {
|
|
345
|
+
b = a;
|
|
346
|
+
a = 0;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return Math.floor(Math.random() * (b - a) + a);
|
|
350
|
+
};
|
|
351
|
+
var randomPick = function randomPick() {
|
|
352
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
353
|
+
args[_key] = arguments[_key];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
var randomNumber = getRandomInt(0, args.length);
|
|
357
|
+
return args[randomNumber];
|
|
358
|
+
};
|
|
359
|
+
var dynamicArray = function dynamicArray(count, elementGenerator) {
|
|
360
|
+
return Array.from({
|
|
361
|
+
length: count
|
|
362
|
+
}, function (_, index) {
|
|
363
|
+
return elementGenerator(index);
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
var isNotNil = /*#__PURE__*/ramda.complement(ramda.isNil);
|
|
367
|
+
var isNotEmpty = /*#__PURE__*/ramda.complement(ramda.isEmpty);
|
|
368
|
+
var notEquals = /*#__PURE__*/ramda.curry(function (x, y) {
|
|
369
|
+
return x !== y;
|
|
370
|
+
});
|
|
371
|
+
var isNot = notEquals;
|
|
372
|
+
var notEqualsDeep = /*#__PURE__*/ramda.complement(ramda.equals);
|
|
373
|
+
var isNotEqualDeep = notEqualsDeep;
|
|
374
|
+
|
|
375
|
+
exports.camelToSnakeCase = camelToSnakeCase;
|
|
376
|
+
exports.capitalize = capitalize;
|
|
377
|
+
exports.copyKeys = copyKeys;
|
|
378
|
+
exports.copyKeysDeep = copyKeysDeep;
|
|
379
|
+
exports.countBy = countBy;
|
|
380
|
+
exports.deepFreezeObject = deepFreezeObject;
|
|
381
|
+
exports.dynamicArray = dynamicArray;
|
|
382
|
+
exports.existsBy = existsBy;
|
|
383
|
+
exports.existsById = existsById;
|
|
384
|
+
exports.filterBy = filterBy;
|
|
385
|
+
exports.filterNonNull = filterNonNull;
|
|
386
|
+
exports.findBy = findBy;
|
|
387
|
+
exports.findById = findById;
|
|
388
|
+
exports.findIndexBy = findIndexBy;
|
|
389
|
+
exports.findIndexById = findIndexById;
|
|
390
|
+
exports.findLastBy = findLastBy;
|
|
391
|
+
exports.findLastIndexBy = findLastIndexBy;
|
|
392
|
+
exports.getRandomInt = getRandomInt;
|
|
393
|
+
exports.humanize = humanize;
|
|
394
|
+
exports.isNot = isNot;
|
|
395
|
+
exports.isNotEmpty = isNotEmpty;
|
|
396
|
+
exports.isNotEqualDeep = isNotEqualDeep;
|
|
397
|
+
exports.isNotNil = isNotNil;
|
|
398
|
+
exports.keysToCamelCase = keysToCamelCase;
|
|
399
|
+
exports.keysToSnakeCase = keysToSnakeCase;
|
|
400
|
+
exports.matches = matches;
|
|
401
|
+
exports.modifyBy = modifyBy;
|
|
402
|
+
exports.modifyById = modifyById;
|
|
403
|
+
exports.noop = noop;
|
|
404
|
+
exports.notEquals = notEquals;
|
|
405
|
+
exports.notEqualsDeep = notEqualsDeep;
|
|
406
|
+
exports.preprocessForSerialization = preprocessForSerialization;
|
|
407
|
+
exports.randomPick = randomPick;
|
|
408
|
+
exports.removeBy = removeBy;
|
|
409
|
+
exports.removeById = removeById;
|
|
410
|
+
exports.renameKeys = renameKeys;
|
|
411
|
+
exports.replaceBy = replaceBy;
|
|
412
|
+
exports.replaceById = replaceById;
|
|
413
|
+
exports.serializeKeysToSnakeCase = serializeKeysToSnakeCase;
|
|
414
|
+
exports.slugify = slugify;
|
|
415
|
+
exports.snakeToCamelCase = snakeToCamelCase;
|
|
416
|
+
exports.toLabelAndValue = toLabelAndValue;
|
|
417
|
+
exports.transformObjectDeep = transformObjectDeep;
|
|
418
|
+
exports.truncate = truncate;
|
package/pure.d.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
export type Primitives = symbol | string | number | boolean | null | undefined;
|
|
2
|
+
export type ObjectAndPrimitives = Primitives | object;
|
|
3
|
+
type KeyType = string | number | symbol;
|
|
4
|
+
|
|
5
|
+
type Matchable<Obj, Parent, key extends keyof Obj> =
|
|
6
|
+
| ((object: Obj[key], parent: Parent) => boolean)
|
|
7
|
+
| MatchPattern<Obj[key], Parent>
|
|
8
|
+
| Primitives;
|
|
9
|
+
|
|
10
|
+
type MatchPattern<Obj = any, Parent = Obj> = Obj extends any[]
|
|
11
|
+
?
|
|
12
|
+
| Matchable<Obj, Parent, number>[]
|
|
13
|
+
| { [key: number]: Matchable<Obj, Parent, number> }
|
|
14
|
+
: Obj extends Primitives
|
|
15
|
+
? Obj
|
|
16
|
+
:
|
|
17
|
+
| {
|
|
18
|
+
[key in keyof Partial<Obj>]: Matchable<Obj, Parent, key>;
|
|
19
|
+
} & {
|
|
20
|
+
[key: KeyType]: Matchable<any, Parent, KeyType>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function camelToSnakeCase(string: string): string;
|
|
24
|
+
export function capitalize(string: string): string;
|
|
25
|
+
|
|
26
|
+
export function copyKeys<T>(
|
|
27
|
+
keyMap: { [key in keyof Partial<T>]: string },
|
|
28
|
+
objectArray: T[]
|
|
29
|
+
): (T & { [key: string]: any })[];
|
|
30
|
+
export function copyKeys(keyMap: {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
}): <T>(objectArray: T[]) => (T & { [key: string]: any })[];
|
|
33
|
+
|
|
34
|
+
export function copyKeysDeep(keyMap: object, objectArray: object[]): object[];
|
|
35
|
+
export function copyKeysDeep(
|
|
36
|
+
keyMap: object
|
|
37
|
+
): (objectArray: object[]) => object[];
|
|
38
|
+
|
|
39
|
+
export function countBy<T>(pattern: MatchPattern<T>, entityArray: T[]): number;
|
|
40
|
+
export function countBy(
|
|
41
|
+
pattern: MatchPattern
|
|
42
|
+
): (entityArray: object[]) => number;
|
|
43
|
+
|
|
44
|
+
export function deepFreezeObject<T>(object: T): Readonly<T>;
|
|
45
|
+
|
|
46
|
+
export function dynamicArray<T>(
|
|
47
|
+
count: number,
|
|
48
|
+
elementGenerator: (index: number) => T
|
|
49
|
+
): T[];
|
|
50
|
+
|
|
51
|
+
export function existsBy<T>(
|
|
52
|
+
pattern: MatchPattern<T>,
|
|
53
|
+
entityArray: T[]
|
|
54
|
+
): boolean;
|
|
55
|
+
export function existsBy(
|
|
56
|
+
pattern: MatchPattern
|
|
57
|
+
): (entityArray: object[]) => boolean;
|
|
58
|
+
|
|
59
|
+
export function existsById(id: any, entityArray: object[]): boolean;
|
|
60
|
+
export function existsById(id: any): (entityArray: object[]) => boolean;
|
|
61
|
+
|
|
62
|
+
export function filterBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
|
|
63
|
+
export function filterBy(pattern: MatchPattern): <T>(entityArray: T[]) => T[];
|
|
64
|
+
|
|
65
|
+
export function filterNonNull(object: object): object;
|
|
66
|
+
|
|
67
|
+
export function findBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
|
|
68
|
+
export function findBy(pattern: MatchPattern): <T>(entityArray: T[]) => T;
|
|
69
|
+
|
|
70
|
+
export function findById<T>(id: any, entityArray: T[]): T;
|
|
71
|
+
export function findById(id: any): <T>(entityArray: T[]) => T;
|
|
72
|
+
|
|
73
|
+
export function findIndexBy<T>(
|
|
74
|
+
pattern: MatchPattern<T>,
|
|
75
|
+
entityArray: T[]
|
|
76
|
+
): number;
|
|
77
|
+
export function findIndexBy(
|
|
78
|
+
pattern: MatchPattern
|
|
79
|
+
): (entityArray: object[]) => number;
|
|
80
|
+
|
|
81
|
+
export function findIndexById(id: any, entityArray: object[]): number;
|
|
82
|
+
export function findIndexById(id: any): (entityArray: object[]) => number;
|
|
83
|
+
|
|
84
|
+
export function findLastBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T;
|
|
85
|
+
export function findLastBy(pattern: MatchPattern): <T>(entityArray: T[]) => T;
|
|
86
|
+
|
|
87
|
+
export function findLastIndexBy(id: any, entityArray: object[]): number;
|
|
88
|
+
export function findLastIndexBy(id: any): (entityArray: object[]) => number;
|
|
89
|
+
|
|
90
|
+
export function getRandomInt(a?: number, b?: number): number;
|
|
91
|
+
export function humanize(string: string): string;
|
|
92
|
+
|
|
93
|
+
export function isNot(a: any, b: any): boolean;
|
|
94
|
+
export function isNot(a: any): (b: any) => boolean;
|
|
95
|
+
|
|
96
|
+
export const isNotEmpty: (a: any) => boolean;
|
|
97
|
+
|
|
98
|
+
export function isNotEqualDeep(a: any, b: any): boolean;
|
|
99
|
+
export function isNotEqualDeep(a: any): (b: any) => boolean;
|
|
100
|
+
|
|
101
|
+
export const isNotNil: (a: any) => boolean;
|
|
102
|
+
|
|
103
|
+
export function keysToCamelCase(object: any): any;
|
|
104
|
+
export function keysToSnakeCase(object: any): any;
|
|
105
|
+
|
|
106
|
+
export function matches<T>(pattern: MatchPattern<T>, data: T): boolean;
|
|
107
|
+
export function matches(pattern: MatchPattern): (data: any) => boolean;
|
|
108
|
+
|
|
109
|
+
export function modifyBy<T>(
|
|
110
|
+
pattern: MatchPattern<T>,
|
|
111
|
+
modifier: (previous: T) => T,
|
|
112
|
+
entityArray: T[]
|
|
113
|
+
): T[];
|
|
114
|
+
export function modifyBy<T>(
|
|
115
|
+
pattern: MatchPattern<T>,
|
|
116
|
+
modifier: (previous: T) => T
|
|
117
|
+
): (entityArray: T[]) => T[];
|
|
118
|
+
export function modifyBy(
|
|
119
|
+
pattern: MatchPattern
|
|
120
|
+
): <T>(modifier: (previous: T) => T, entityArray: T[]) => T[];
|
|
121
|
+
export function modifyBy(
|
|
122
|
+
pattern: MatchPattern
|
|
123
|
+
): <T>(modifier: (previous: T) => T) => (entityArray: T[]) => T[];
|
|
124
|
+
|
|
125
|
+
export function modifyById<T>(
|
|
126
|
+
id: any,
|
|
127
|
+
modifier: (previous: T) => T,
|
|
128
|
+
entityArray: T[]
|
|
129
|
+
): T[];
|
|
130
|
+
export function modifyById<T>(
|
|
131
|
+
id: any,
|
|
132
|
+
modifier: (previous: T) => T
|
|
133
|
+
): (entityArray: T[]) => T[];
|
|
134
|
+
export function modifyById(
|
|
135
|
+
id: any
|
|
136
|
+
): <T>(modifier: (previous: T) => T, entityArray: T[]) => T[];
|
|
137
|
+
export function modifyById(
|
|
138
|
+
id: any
|
|
139
|
+
): <T>(modifier: (previous: T) => T) => (entityArray: T[]) => T[];
|
|
140
|
+
|
|
141
|
+
export function noop(...args: any[]): void;
|
|
142
|
+
|
|
143
|
+
export function notEquals(a: any, b: any): boolean;
|
|
144
|
+
export function notEquals(a: any): (b: any) => boolean;
|
|
145
|
+
|
|
146
|
+
export function notEqualsDeep(a: any, b: any): boolean;
|
|
147
|
+
export function notEqualsDeep(a: any): (b: any) => boolean;
|
|
148
|
+
|
|
149
|
+
export function randomPick<T>(...args: T[]): T;
|
|
150
|
+
|
|
151
|
+
export function removeBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
|
|
152
|
+
export function removeBy(pattern: MatchPattern): <T>(entityArray: T[]) => T[];
|
|
153
|
+
|
|
154
|
+
export function removeById<T>(id: any, entityArray: T[]): T[];
|
|
155
|
+
export function removeById(id: any): <T>(entityArray: T[]) => T[];
|
|
156
|
+
|
|
157
|
+
export function renameKeys<T, M extends { [key in keyof Partial<T>]: string }>(
|
|
158
|
+
keyMap: M,
|
|
159
|
+
entityArray: T[]
|
|
160
|
+
): (Omit<T, keyof M> & { [key: string]: any })[];
|
|
161
|
+
|
|
162
|
+
export function renameKeys<M extends { [key: string]: string }>(
|
|
163
|
+
keyMap: M
|
|
164
|
+
): <T>(entityArray: T[]) => (Omit<T, keyof M> & { [key: string]: any })[];
|
|
165
|
+
|
|
166
|
+
export function replaceBy<T>(pattern: MatchPattern<T>, entityArray: T[]): T[];
|
|
167
|
+
export function replaceBy(pattern: MatchPattern): <T>(entityArray: T[]) => T[];
|
|
168
|
+
|
|
169
|
+
export function replaceById<T>(id: any, entityArray: T[]): T[];
|
|
170
|
+
export function replaceById(id: any): <T>(entityArray: T[]) => T[];
|
|
171
|
+
|
|
172
|
+
export function serializeKeysToSnakeCase(object: object): object;
|
|
173
|
+
export function preprocessForSerialization(object: object): object;
|
|
174
|
+
export function slugify(string: string): string;
|
|
175
|
+
export function snakeToCamelCase(string: string): string;
|
|
176
|
+
export function toLabelAndValue(string: string): {
|
|
177
|
+
label: string;
|
|
178
|
+
value: string;
|
|
179
|
+
};
|
|
180
|
+
export function transformObjectDeep(
|
|
181
|
+
object: object,
|
|
182
|
+
keyValueTransformer: (key: string | number | symbol, object: any) => any[],
|
|
183
|
+
objectPreProcessor?: (object: any) => any
|
|
184
|
+
): object;
|
|
185
|
+
|
|
186
|
+
export function truncate(string: string, length: number): string;
|