@lowentry/utils 1.17.1 → 1.19.1
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/api-extractor.json +40 -0
- package/build/LeTypes.d.ts +15 -0
- package/build/LeUtils.d.ts +218 -0
- package/build/classes/LinkedList.d.ts +33 -0
- package/build/classes/SerializableMap.d.ts +17 -0
- package/build/index.d.ts +4 -0
- package/index.d.ts +301 -0
- package/index.js +169 -2
- package/index.js.map +1 -1
- package/package.json +7 -6
- package/src/LeUtils.js +1 -1
- package/src/classes/LinkedList.js +145 -0
- package/src/classes/SerializableMap.js +17 -0
- package/src/index.js +2 -0
- package/tests/each.test.js +3 -5
- package/tests/sort.test.js +1 -1
- package/tsconfig.d.ts +1 -3
- package/tsconfig.json +15 -3
- package/jest.config.mjs +0 -10
package/index.js
CHANGED
|
@@ -8,6 +8,12 @@ import _wrapAsyncGenerator from '@babel/runtime/helpers/wrapAsyncGenerator';
|
|
|
8
8
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
9
9
|
import FastDeepEqual from 'fast-deep-equal';
|
|
10
10
|
import CloneDeep from 'clone-deep';
|
|
11
|
+
import _createClass from '@babel/runtime/helpers/createClass';
|
|
12
|
+
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
13
|
+
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
|
|
14
|
+
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
15
|
+
import _inherits from '@babel/runtime/helpers/inherits';
|
|
16
|
+
import _wrapNativeSuper from '@babel/runtime/helpers/wrapNativeSuper';
|
|
11
17
|
|
|
12
18
|
var REGEX_ALL_NON_FLOAT_CHARACTERS = /[^0-9.\-]/g;
|
|
13
19
|
|
|
@@ -689,7 +695,7 @@ var LeUtils = {
|
|
|
689
695
|
*
|
|
690
696
|
* @param {*} elements
|
|
691
697
|
* @param {boolean} [optionalSkipHasOwnPropertyCheck]
|
|
692
|
-
* @
|
|
698
|
+
* @yields {[key:*, value:*]}
|
|
693
699
|
*/
|
|
694
700
|
eachIterator: function eachIterator(elements) {
|
|
695
701
|
var optionalSkipHasOwnPropertyCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -3518,5 +3524,166 @@ var LeUtils = {
|
|
|
3518
3524
|
}()
|
|
3519
3525
|
};
|
|
3520
3526
|
|
|
3521
|
-
|
|
3527
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
3528
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
3529
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
3530
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
3531
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
3532
|
+
var LinkedListNode = /*#__PURE__*/_createClass(
|
|
3533
|
+
/**
|
|
3534
|
+
* @param {*} value
|
|
3535
|
+
*/
|
|
3536
|
+
function LinkedListNode(value) {
|
|
3537
|
+
_classCallCheck(this, LinkedListNode);
|
|
3538
|
+
/** @type {*} */
|
|
3539
|
+
_defineProperty(this, "value", void 0);
|
|
3540
|
+
/** @type {LinkedListNode|null} */
|
|
3541
|
+
_defineProperty(this, "next", null);
|
|
3542
|
+
/** @type {LinkedListNode|null} */
|
|
3543
|
+
_defineProperty(this, "previous", null);
|
|
3544
|
+
this.value = value;
|
|
3545
|
+
});
|
|
3546
|
+
var _head = /*#__PURE__*/new WeakMap();
|
|
3547
|
+
var _tail = /*#__PURE__*/new WeakMap();
|
|
3548
|
+
var _size = /*#__PURE__*/new WeakMap();
|
|
3549
|
+
var LinkedList = /*#__PURE__*/function () {
|
|
3550
|
+
function LinkedList() {
|
|
3551
|
+
_classCallCheck(this, LinkedList);
|
|
3552
|
+
/** @type {LinkedListNode|null} */
|
|
3553
|
+
_classPrivateFieldInitSpec(this, _head, null);
|
|
3554
|
+
/** @type {LinkedListNode|null} */
|
|
3555
|
+
_classPrivateFieldInitSpec(this, _tail, null);
|
|
3556
|
+
/** @type {number} */
|
|
3557
|
+
_classPrivateFieldInitSpec(this, _size, 0);
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
/**
|
|
3561
|
+
* Returns the number of elements in the list.
|
|
3562
|
+
*
|
|
3563
|
+
* @returns {number}
|
|
3564
|
+
*/
|
|
3565
|
+
return _createClass(LinkedList, [{
|
|
3566
|
+
key: "size",
|
|
3567
|
+
get: function get() {
|
|
3568
|
+
return _classPrivateFieldGet(_size, this);
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
/**
|
|
3572
|
+
* Adds a new value to the beginning of the list.
|
|
3573
|
+
*
|
|
3574
|
+
* @param {*} value
|
|
3575
|
+
*/
|
|
3576
|
+
}, {
|
|
3577
|
+
key: "unshift",
|
|
3578
|
+
value: function unshift(value) {
|
|
3579
|
+
var _this$size;
|
|
3580
|
+
var newNode = new LinkedListNode(value);
|
|
3581
|
+
if (_classPrivateFieldGet(_head, this) === null) {
|
|
3582
|
+
_classPrivateFieldSet(_head, this, newNode);
|
|
3583
|
+
_classPrivateFieldSet(_tail, this, newNode);
|
|
3584
|
+
} else {
|
|
3585
|
+
newNode.next = _classPrivateFieldGet(_head, this);
|
|
3586
|
+
_classPrivateFieldGet(_head, this).previous = newNode;
|
|
3587
|
+
_classPrivateFieldSet(_head, this, newNode);
|
|
3588
|
+
}
|
|
3589
|
+
_classPrivateFieldSet(_size, this, (_this$size = _classPrivateFieldGet(_size, this), _this$size++, _this$size));
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
/**
|
|
3593
|
+
* Adds a new value to the end of the list.
|
|
3594
|
+
*
|
|
3595
|
+
* @param {*} value
|
|
3596
|
+
*/
|
|
3597
|
+
}, {
|
|
3598
|
+
key: "push",
|
|
3599
|
+
value: function push(value) {
|
|
3600
|
+
var _this$size3;
|
|
3601
|
+
var newNode = new LinkedListNode(value);
|
|
3602
|
+
if (_classPrivateFieldGet(_tail, this) === null) {
|
|
3603
|
+
_classPrivateFieldSet(_head, this, newNode);
|
|
3604
|
+
_classPrivateFieldSet(_tail, this, newNode);
|
|
3605
|
+
} else {
|
|
3606
|
+
newNode.previous = _classPrivateFieldGet(_tail, this);
|
|
3607
|
+
_classPrivateFieldGet(_tail, this).next = newNode;
|
|
3608
|
+
_classPrivateFieldSet(_tail, this, newNode);
|
|
3609
|
+
}
|
|
3610
|
+
_classPrivateFieldSet(_size, this, (_this$size3 = _classPrivateFieldGet(_size, this), _this$size3++, _this$size3));
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
/**
|
|
3614
|
+
* Removes the first value from the list and returns it.
|
|
3615
|
+
*
|
|
3616
|
+
* @returns {*|undefined}
|
|
3617
|
+
*/
|
|
3618
|
+
}, {
|
|
3619
|
+
key: "shift",
|
|
3620
|
+
value: function shift() {
|
|
3621
|
+
var _this$size5;
|
|
3622
|
+
if (_classPrivateFieldGet(_head, this) === null) {
|
|
3623
|
+
return undefined;
|
|
3624
|
+
}
|
|
3625
|
+
var value = _classPrivateFieldGet(_head, this).value;
|
|
3626
|
+
_classPrivateFieldSet(_head, this, _classPrivateFieldGet(_head, this).next);
|
|
3627
|
+
if (_classPrivateFieldGet(_head, this) !== null) {
|
|
3628
|
+
_classPrivateFieldGet(_head, this).previous = null;
|
|
3629
|
+
} else {
|
|
3630
|
+
_classPrivateFieldSet(_tail, this, null);
|
|
3631
|
+
}
|
|
3632
|
+
_classPrivateFieldSet(_size, this, (_this$size5 = _classPrivateFieldGet(_size, this), _this$size5--, _this$size5));
|
|
3633
|
+
return value;
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
/**
|
|
3637
|
+
* Removes the last value from the list and returns it.
|
|
3638
|
+
*
|
|
3639
|
+
* @returns {*|undefined}
|
|
3640
|
+
*/
|
|
3641
|
+
}, {
|
|
3642
|
+
key: "pop",
|
|
3643
|
+
value: function pop() {
|
|
3644
|
+
var _this$size7;
|
|
3645
|
+
if (_classPrivateFieldGet(_tail, this) === null) {
|
|
3646
|
+
return undefined;
|
|
3647
|
+
}
|
|
3648
|
+
var value = _classPrivateFieldGet(_tail, this).value;
|
|
3649
|
+
_classPrivateFieldSet(_tail, this, _classPrivateFieldGet(_tail, this).previous);
|
|
3650
|
+
if (_classPrivateFieldGet(_tail, this) !== null) {
|
|
3651
|
+
_classPrivateFieldGet(_tail, this).next = null;
|
|
3652
|
+
} else {
|
|
3653
|
+
_classPrivateFieldSet(_head, this, null);
|
|
3654
|
+
}
|
|
3655
|
+
_classPrivateFieldSet(_size, this, (_this$size7 = _classPrivateFieldGet(_size, this), _this$size7--, _this$size7));
|
|
3656
|
+
return value;
|
|
3657
|
+
}
|
|
3658
|
+
}]);
|
|
3659
|
+
}();
|
|
3660
|
+
|
|
3661
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
3662
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
3663
|
+
/**
|
|
3664
|
+
* SerializableMap class extends the native Map to provide a JSON representation.
|
|
3665
|
+
*
|
|
3666
|
+
* This class can only have string keys, as JSON does not support non-string keys.
|
|
3667
|
+
*/
|
|
3668
|
+
var SerializableMap = /*#__PURE__*/function (_Map) {
|
|
3669
|
+
function SerializableMap() {
|
|
3670
|
+
_classCallCheck(this, SerializableMap);
|
|
3671
|
+
return _callSuper(this, SerializableMap, arguments);
|
|
3672
|
+
}
|
|
3673
|
+
_inherits(SerializableMap, _Map);
|
|
3674
|
+
return _createClass(SerializableMap, [{
|
|
3675
|
+
key: "toJSON",
|
|
3676
|
+
value:
|
|
3677
|
+
/**
|
|
3678
|
+
* Returns a JSON representation of the map.
|
|
3679
|
+
*
|
|
3680
|
+
* @returns {object}
|
|
3681
|
+
*/
|
|
3682
|
+
function toJSON() {
|
|
3683
|
+
return Object.fromEntries(this);
|
|
3684
|
+
}
|
|
3685
|
+
}]);
|
|
3686
|
+
}(/*#__PURE__*/_wrapNativeSuper(Map));
|
|
3687
|
+
|
|
3688
|
+
export { ARRAY, FLOAT, FLOAT_ANY, FLOAT_LAX, FLOAT_LAX_ANY, INT, INT_ANY, INT_LAX, INT_LAX_ANY, ISSET, IS_ARRAY, IS_OBJECT, LeUtils, LinkedList, OBJECT, STRING, STRING_ANY, SerializableMap };
|
|
3522
3689
|
//# sourceMappingURL=index.js.map
|