@bbn/bbn 1.0.179 → 1.0.182

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/dist/bbn.js CHANGED
@@ -672,7 +672,7 @@ __webpack_require__.r(__webpack_exports__);
672
672
  /* harmony import */ var _fn_misc_money_js__WEBPACK_IMPORTED_MODULE_168__ = __webpack_require__(/*! ./fn/misc/money.js */ "./dist/fn/misc/money.js");
673
673
  /* harmony import */ var _fn_object_move_js__WEBPACK_IMPORTED_MODULE_169__ = __webpack_require__(/*! ./fn/object/move.js */ "./dist/fn/object/move.js");
674
674
  /* harmony import */ var _fn_object_multiorder_js__WEBPACK_IMPORTED_MODULE_170__ = __webpack_require__(/*! ./fn/object/multiorder.js */ "./dist/fn/object/multiorder.js");
675
- Object(function webpackMissingModule() { var e = new Error("Cannot find module './fn/object/mutateArray.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }());
675
+ /* harmony import */ var _fn_object_mutateArray_js__WEBPACK_IMPORTED_MODULE_171__ = __webpack_require__(/*! ./fn/object/mutateArray.js */ "./dist/fn/object/mutateArray.js");
676
676
  /* harmony import */ var _fn_string_nl2br_js__WEBPACK_IMPORTED_MODULE_172__ = __webpack_require__(/*! ./fn/string/nl2br.js */ "./dist/fn/string/nl2br.js");
677
677
  /* harmony import */ var _fn_object_numProperties_js__WEBPACK_IMPORTED_MODULE_173__ = __webpack_require__(/*! ./fn/object/numProperties.js */ "./dist/fn/object/numProperties.js");
678
678
  /* harmony import */ var _fn_form_objectToFormData_js__WEBPACK_IMPORTED_MODULE_174__ = __webpack_require__(/*! ./fn/form/objectToFormData.js */ "./dist/fn/form/objectToFormData.js");
@@ -1131,7 +1131,7 @@ var fn = {
1131
1131
  money: _fn_misc_money_js__WEBPACK_IMPORTED_MODULE_168__.money,
1132
1132
  move: _fn_object_move_js__WEBPACK_IMPORTED_MODULE_169__.move,
1133
1133
  multiorder: _fn_object_multiorder_js__WEBPACK_IMPORTED_MODULE_170__.multiorder,
1134
- mutateArray: Object(function webpackMissingModule() { var e = new Error("Cannot find module './fn/object/mutateArray.js'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()),
1134
+ mutateArray: _fn_object_mutateArray_js__WEBPACK_IMPORTED_MODULE_171__.mutateArray,
1135
1135
  nl2br: _fn_string_nl2br_js__WEBPACK_IMPORTED_MODULE_172__.nl2br,
1136
1136
  numProperties: _fn_object_numProperties_js__WEBPACK_IMPORTED_MODULE_173__.numProperties,
1137
1137
  objectToFormData: _fn_form_objectToFormData_js__WEBPACK_IMPORTED_MODULE_174__.objectToFormData,
@@ -9286,6 +9286,73 @@ var multiorder = function (arr, orders) {
9286
9286
 
9287
9287
 
9288
9288
 
9289
+ /***/ }),
9290
+
9291
+ /***/ "./dist/fn/object/mutateArray.js":
9292
+ /*!***************************************!*\
9293
+ !*** ./dist/fn/object/mutateArray.js ***!
9294
+ \***************************************/
9295
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9296
+
9297
+ "use strict";
9298
+ __webpack_require__.r(__webpack_exports__);
9299
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9300
+ /* harmony export */ mutateArray: () => (/* binding */ mutateArray)
9301
+ /* harmony export */ });
9302
+ /* harmony import */ var _type_isArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../type/isArray.js */ "./dist/fn/type/isArray.js");
9303
+ /* harmony import */ var _string_hash_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../string/hash.js */ "./dist/fn/string/hash.js");
9304
+
9305
+
9306
+ var mutateArray = function (a1, a2) {
9307
+ if (!(0,_type_isArray_js__WEBPACK_IMPORTED_MODULE_0__.isArray)(a1, a2)) {
9308
+ throw new TypeError('mutateArray can only be called with arrays');
9309
+ }
9310
+ var mapA2 = new Map(a2.map(function (item) { return [(0,_string_hash_js__WEBPACK_IMPORTED_MODULE_1__.hash)(item), item]; }));
9311
+ var a1Pointer = 0;
9312
+ var a2Pointer = 0;
9313
+ var _loop_1 = function () {
9314
+ var a1Item = a1[a1Pointer];
9315
+ var a2Item = a2[a2Pointer];
9316
+ var a1Key = a1Item ? (0,_string_hash_js__WEBPACK_IMPORTED_MODULE_1__.hash)(a1Item) : undefined;
9317
+ var a2Key = (0,_string_hash_js__WEBPACK_IMPORTED_MODULE_1__.hash)(a2Item);
9318
+ if (a1Key === a2Key) {
9319
+ // The items match, move both pointers.
9320
+ a1Pointer++;
9321
+ a2Pointer++;
9322
+ }
9323
+ else if (mapA2.has(a1Key)) {
9324
+ // The item in a1 exists in a2 but is out of order, so it should be moved.
9325
+ // First, find the correct position to move it to.
9326
+ var correctIndex = a1.findIndex(function (item) { return (0,_string_hash_js__WEBPACK_IMPORTED_MODULE_1__.hash)(item) === a2Key; });
9327
+ var itemToMove = a1.splice(correctIndex, 1)[0];
9328
+ a1.splice(a1Pointer, 0, itemToMove);
9329
+ // Now that the item has been moved to the correct position, move pointers.
9330
+ a1Pointer++;
9331
+ a2Pointer++;
9332
+ }
9333
+ else {
9334
+ // The item in a1 does not exist in a2, so it should be removed.
9335
+ a1.splice(a1Pointer, 1);
9336
+ }
9337
+ // If there's no corresponding item in a1 for the current a2 item, insert it.
9338
+ if (a1[a1Pointer] === undefined && a2Pointer < a2.length) {
9339
+ a1.splice(a1Pointer, 0, a2Item);
9340
+ a1Pointer++;
9341
+ a2Pointer++;
9342
+ }
9343
+ };
9344
+ while (a2Pointer < a2.length) {
9345
+ _loop_1();
9346
+ }
9347
+ // If there are any remaining items in a1 that are not in a2, remove them.
9348
+ while (a1.length > a2.length) {
9349
+ a1.pop();
9350
+ }
9351
+ return a1;
9352
+ };
9353
+
9354
+
9355
+
9289
9356
  /***/ }),
9290
9357
 
9291
9358
  /***/ "./dist/fn/object/numProperties.js":