@bigbinary/neeto-commons-frontend 2.0.1 → 2.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/pure.js CHANGED
@@ -1,8 +1,4 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var ramda = require('ramda');
1
+ import { concat, slice, curry, isNil, complement, findLast, findLastIndex, count, fromPairs, toPairs, path, isEmpty, equals } from 'ramda';
6
2
 
7
3
  function _arrayWithHoles(arr) {
8
4
  if (Array.isArray(arr)) return arr;
@@ -103,7 +99,7 @@ var capitalize = function capitalize(string) {
103
99
  return string.charAt(0).toUpperCase() + string.slice(1);
104
100
  };
105
101
  var truncate = function truncate(string, length) {
106
- return string.length > length ? ramda.concat(ramda.slice(0, length, string), "...") : string;
102
+ return string.length > length ? concat(slice(0, length, string), "...") : string;
107
103
  };
108
104
 
109
105
  var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
@@ -143,12 +139,12 @@ var deepFreezeObject = function deepFreezeObject(object) {
143
139
 
144
140
  return object;
145
141
  };
146
- var matches = ramda.curry(function (pattern, object) {
142
+ var matches = curry(function (pattern, object) {
147
143
  var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
148
144
 
149
145
  if (object === pattern) return true;
150
146
  if (typeof pattern === "function" && pattern(object, __parent)) return true;
151
- if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
147
+ if (isNil(pattern) || isNil(object)) return false;
152
148
  if (_typeof(pattern) !== "object") return false;
153
149
  return Object.entries(pattern).every(function (_ref3) {
154
150
  var _ref4 = _slicedToArray(_ref3, 2),
@@ -163,7 +159,7 @@ var filterNonNull = function filterNonNull(object) {
163
159
  var _ref6 = _slicedToArray(_ref5, 2),
164
160
  v = _ref6[1];
165
161
 
166
- return !ramda.isNil(v);
162
+ return !isNil(v);
167
163
  }).map(function (_ref7) {
168
164
  var _ref8 = _slicedToArray(_ref7, 2),
169
165
  k = _ref8[0],
@@ -191,71 +187,71 @@ function _defineProperty(obj, key, value) {
191
187
  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; }
192
188
 
193
189
  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; }
194
- var removeById = ramda.curry(function (id, array) {
190
+ var removeById = curry(function (id, array) {
195
191
  return array.filter(function (item) {
196
192
  return item.id !== id;
197
193
  });
198
194
  });
199
- var findById = ramda.curry(function (id, array) {
195
+ var findById = curry(function (id, array) {
200
196
  return array.find(function (item) {
201
197
  return item.id === id;
202
198
  });
203
199
  });
204
- var replaceById = ramda.curry(function (id, newItem, array) {
200
+ var replaceById = curry(function (id, newItem, array) {
205
201
  return array.map(function (item) {
206
202
  return item.id === id ? newItem : item;
207
203
  });
208
204
  });
209
- var modifyById = ramda.curry(function (id, modifier, array) {
205
+ var modifyById = curry(function (id, modifier, array) {
210
206
  return array.map(function (item) {
211
207
  return item.id === id ? modifier(item) : item;
212
208
  });
213
209
  });
214
- var findBy = ramda.curry(function (pattern, array) {
210
+ var findBy = curry(function (pattern, array) {
215
211
  return array.find(matches(pattern));
216
212
  });
217
- var removeBy = ramda.curry(function (pattern, array) {
218
- return array.filter(ramda.complement(matches(pattern)));
213
+ var removeBy = curry(function (pattern, array) {
214
+ return array.filter(complement(matches(pattern)));
219
215
  });
220
- var replaceBy = ramda.curry(function (pattern, newItem, array) {
216
+ var replaceBy = curry(function (pattern, newItem, array) {
221
217
  return array.map(function (item) {
222
218
  return matches(pattern, item) ? newItem : item;
223
219
  });
224
220
  });
225
- var modifyBy = ramda.curry(function (pattern, modifier, array) {
221
+ var modifyBy = curry(function (pattern, modifier, array) {
226
222
  return array.map(function (item) {
227
223
  return matches(pattern, item) ? modifier(item) : item;
228
224
  });
229
225
  });
230
- var existsById = ramda.curry(function (id, array) {
226
+ var existsById = curry(function (id, array) {
231
227
  return array.some(function (item) {
232
228
  return item.id === id;
233
229
  });
234
230
  });
235
- var existsBy = ramda.curry(function (pattern, array) {
231
+ var existsBy = curry(function (pattern, array) {
236
232
  return array.some(matches(pattern));
237
233
  });
238
- var findLastBy = ramda.curry(function (pattern, array) {
239
- return ramda.findLast(matches(pattern), array);
234
+ var findLastBy = curry(function (pattern, array) {
235
+ return findLast(matches(pattern), array);
240
236
  });
241
- var findIndexById = ramda.curry(function (id, array) {
237
+ var findIndexById = curry(function (id, array) {
242
238
  return array.findIndex(function (item) {
243
239
  return item.id === id;
244
240
  });
245
241
  });
246
- var findIndexBy = ramda.curry(function (pattern, array) {
242
+ var findIndexBy = curry(function (pattern, array) {
247
243
  return array.findIndex(matches(pattern));
248
244
  });
249
- var findLastIndexBy = ramda.curry(function (pattern, array) {
250
- return ramda.findLastIndex(matches(pattern), array);
245
+ var findLastIndexBy = curry(function (pattern, array) {
246
+ return findLastIndex(matches(pattern), array);
251
247
  });
252
- var filterBy = ramda.curry(function (pattern, array) {
248
+ var filterBy = curry(function (pattern, array) {
253
249
  return array.filter(matches(pattern));
254
250
  });
255
- var countBy = ramda.curry(function (pattern, array) {
256
- return ramda.count(matches(pattern), array);
251
+ var countBy = curry(function (pattern, array) {
252
+ return count(matches(pattern), array);
257
253
  });
258
- var copyKeys = ramda.curry(function (keyMap, objectArray) {
254
+ var copyKeys = curry(function (keyMap, objectArray) {
259
255
  return objectArray.map(function (object) {
260
256
  var shallowCopy = _objectSpread({}, object);
261
257
 
@@ -266,7 +262,7 @@ var copyKeys = ramda.curry(function (keyMap, objectArray) {
266
262
  return shallowCopy;
267
263
  });
268
264
  });
269
- var renameKeys = ramda.curry(function (keyMap, objectArray) {
265
+ var renameKeys = curry(function (keyMap, objectArray) {
270
266
  return objectArray.map(function (object) {
271
267
  var shallowCopy = _objectSpread({}, object);
272
268
 
@@ -278,10 +274,10 @@ var renameKeys = ramda.curry(function (keyMap, objectArray) {
278
274
  return shallowCopy;
279
275
  });
280
276
  });
281
- var copyKeysDeep = ramda.curry(function (keyMap, objectArray) {
277
+ var copyKeysDeep = curry(function (keyMap, objectArray) {
282
278
  var copyKeysSingleObject = function copyKeysSingleObject(object, keyMap) {
283
279
  var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
284
- return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref) {
280
+ return _objectSpread(_objectSpread({}, object), fromPairs(toPairs(keyMap).map(function (_ref) {
285
281
  var _ref2 = _slicedToArray(_ref, 2),
286
282
  destination = _ref2[0],
287
283
  source = _ref2[1];
@@ -289,7 +285,7 @@ var copyKeysDeep = ramda.curry(function (keyMap, objectArray) {
289
285
  if (typeof source === "function") {
290
286
  return [destination, source(object[destination], root)];
291
287
  } else if (Array.isArray(source)) {
292
- return [destination, ramda.path(source, root)];
288
+ return [destination, path(source, root)];
293
289
  } else if (_typeof(source) === "object") {
294
290
  return [destination, copyKeysSingleObject(object[destination], source, root)];
295
291
  }
@@ -339,54 +335,13 @@ var dynamicArray = function dynamicArray(count, elementGenerator) {
339
335
  return elementGenerator(index);
340
336
  });
341
337
  };
342
- var isNotNil = ramda.complement(ramda.isNil);
343
- var isNotEmpty = ramda.complement(ramda.isEmpty);
344
- var notEquals = ramda.curry(function (x, y) {
338
+ var isNotNil = complement(isNil);
339
+ var isNotEmpty = complement(isEmpty);
340
+ var notEquals = curry(function (x, y) {
345
341
  return x !== y;
346
342
  });
347
343
  var isNot = notEquals;
348
- var notEqualsDeep = ramda.complement(ramda.equals);
344
+ var notEqualsDeep = complement(equals);
349
345
  var isNotEqualDeep = notEqualsDeep;
350
346
 
351
- exports.camelToSnakeCase = camelToSnakeCase;
352
- exports.capitalize = capitalize;
353
- exports.copyKeys = copyKeys;
354
- exports.copyKeysDeep = copyKeysDeep;
355
- exports.countBy = countBy;
356
- exports.deepFreezeObject = deepFreezeObject;
357
- exports.dynamicArray = dynamicArray;
358
- exports.existsBy = existsBy;
359
- exports.existsById = existsById;
360
- exports.filterBy = filterBy;
361
- exports.filterNonNull = filterNonNull;
362
- exports.findBy = findBy;
363
- exports.findById = findById;
364
- exports.findIndexBy = findIndexBy;
365
- exports.findIndexById = findIndexById;
366
- exports.findLastBy = findLastBy;
367
- exports.findLastIndexBy = findLastIndexBy;
368
- exports.getRandomInt = getRandomInt;
369
- exports.humanize = humanize;
370
- exports.isNot = isNot;
371
- exports.isNotEmpty = isNotEmpty;
372
- exports.isNotEqualDeep = isNotEqualDeep;
373
- exports.isNotNil = isNotNil;
374
- exports.keysToCamelCase = keysToCamelCase;
375
- exports.keysToSnakeCase = keysToSnakeCase;
376
- exports.matches = matches;
377
- exports.modifyBy = modifyBy;
378
- exports.modifyById = modifyById;
379
- exports.noop = noop;
380
- exports.notEquals = notEquals;
381
- exports.notEqualsDeep = notEqualsDeep;
382
- exports.randomPick = randomPick;
383
- exports.removeBy = removeBy;
384
- exports.removeById = removeById;
385
- exports.renameKeys = renameKeys;
386
- exports.replaceBy = replaceBy;
387
- exports.replaceById = replaceById;
388
- exports.slugify = slugify;
389
- exports.snakeToCamelCase = snakeToCamelCase;
390
- exports.toLabelAndValue = toLabelAndValue;
391
- exports.transformObjectDeep = transformObjectDeep;
392
- exports.truncate = truncate;
347
+ 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, slugify, snakeToCamelCase, toLabelAndValue, transformObjectDeep, truncate };