@baleada/logic 0.20.27 → 0.20.28
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/lib/index.cjs +12 -12
- package/lib/index.d.ts +1 -1
- package/lib/index.js +12 -12
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -2719,7 +2719,7 @@ class Grantable {
|
|
|
2719
2719
|
const defaultOptions$2 = {
|
|
2720
2720
|
initialLocation: 0
|
|
2721
2721
|
};
|
|
2722
|
-
const defaultNavigateOptions = {
|
|
2722
|
+
const defaultNavigateOptions = { allow: "possible" };
|
|
2723
2723
|
const defaultNextAndPreviousOptions = {
|
|
2724
2724
|
distance: 1,
|
|
2725
2725
|
loops: true
|
|
@@ -2760,8 +2760,8 @@ class Navigateable {
|
|
|
2760
2760
|
return this;
|
|
2761
2761
|
}
|
|
2762
2762
|
navigate(location, options = {}) {
|
|
2763
|
-
const {
|
|
2764
|
-
this._navigate(location, {
|
|
2763
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2764
|
+
this._navigate(location, { allow });
|
|
2765
2765
|
this.navigated();
|
|
2766
2766
|
return this;
|
|
2767
2767
|
}
|
|
@@ -2769,10 +2769,10 @@ class Navigateable {
|
|
|
2769
2769
|
this.computedStatus = "navigated";
|
|
2770
2770
|
}
|
|
2771
2771
|
_navigate(location, options = {}) {
|
|
2772
|
-
const {
|
|
2772
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2773
2773
|
const ensuredLocation = (() => {
|
|
2774
|
-
if (
|
|
2775
|
-
if (location < 0 &&
|
|
2774
|
+
if (allow === "possible") {
|
|
2775
|
+
if (location < 0 && allow === "possible") {
|
|
2776
2776
|
return 0;
|
|
2777
2777
|
}
|
|
2778
2778
|
if (location > this.array.length - 1) {
|
|
@@ -2784,8 +2784,8 @@ class Navigateable {
|
|
|
2784
2784
|
this.computedLocation = ensuredLocation;
|
|
2785
2785
|
}
|
|
2786
2786
|
next(options = {}) {
|
|
2787
|
-
const { distance, loops,
|
|
2788
|
-
if (
|
|
2787
|
+
const { distance, loops, allow } = { ...defaultNextAndPreviousOptions, ...defaultNavigateOptions, ...options }, newLocation = (() => {
|
|
2788
|
+
if (allow === "any") {
|
|
2789
2789
|
return this.location + distance;
|
|
2790
2790
|
}
|
|
2791
2791
|
const lastLocation = this.array.length - 1;
|
|
@@ -2803,7 +2803,7 @@ class Navigateable {
|
|
|
2803
2803
|
return newLocation2;
|
|
2804
2804
|
})();
|
|
2805
2805
|
})();
|
|
2806
|
-
this._navigate(newLocation, {
|
|
2806
|
+
this._navigate(newLocation, { allow });
|
|
2807
2807
|
this.nexted();
|
|
2808
2808
|
return this;
|
|
2809
2809
|
}
|
|
@@ -2811,8 +2811,8 @@ class Navigateable {
|
|
|
2811
2811
|
this.computedStatus = "navigated to next";
|
|
2812
2812
|
}
|
|
2813
2813
|
previous(options = {}) {
|
|
2814
|
-
const { distance, loops,
|
|
2815
|
-
if (
|
|
2814
|
+
const { distance, loops, allow } = { ...defaultNextAndPreviousOptions, ...defaultNavigateOptions, ...options }, newLocation = (() => {
|
|
2815
|
+
if (allow === "any") {
|
|
2816
2816
|
return this.location - distance;
|
|
2817
2817
|
}
|
|
2818
2818
|
if (this.location - distance >= 0) {
|
|
@@ -2829,7 +2829,7 @@ class Navigateable {
|
|
|
2829
2829
|
return newLocation2;
|
|
2830
2830
|
})();
|
|
2831
2831
|
})();
|
|
2832
|
-
this._navigate(newLocation, {
|
|
2832
|
+
this._navigate(newLocation, { allow });
|
|
2833
2833
|
this.previoused();
|
|
2834
2834
|
return this;
|
|
2835
2835
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -705,7 +705,7 @@ declare type NavigateableOptions = {
|
|
|
705
705
|
};
|
|
706
706
|
declare type NavigateableStatus = 'ready' | 'navigated' | 'navigated to next' | 'navigated to previous' | 'navigated to random' | 'navigated to first' | 'navigated to last';
|
|
707
707
|
declare type NavigateOptions = {
|
|
708
|
-
|
|
708
|
+
allow?: 'possible' | 'any';
|
|
709
709
|
};
|
|
710
710
|
declare type NextAndPreviousOptions = {
|
|
711
711
|
distance?: number;
|
package/lib/index.js
CHANGED
|
@@ -2708,7 +2708,7 @@ class Grantable {
|
|
|
2708
2708
|
const defaultOptions$2 = {
|
|
2709
2709
|
initialLocation: 0
|
|
2710
2710
|
};
|
|
2711
|
-
const defaultNavigateOptions = {
|
|
2711
|
+
const defaultNavigateOptions = { allow: "possible" };
|
|
2712
2712
|
const defaultNextAndPreviousOptions = {
|
|
2713
2713
|
distance: 1,
|
|
2714
2714
|
loops: true
|
|
@@ -2749,8 +2749,8 @@ class Navigateable {
|
|
|
2749
2749
|
return this;
|
|
2750
2750
|
}
|
|
2751
2751
|
navigate(location, options = {}) {
|
|
2752
|
-
const {
|
|
2753
|
-
this._navigate(location, {
|
|
2752
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2753
|
+
this._navigate(location, { allow });
|
|
2754
2754
|
this.navigated();
|
|
2755
2755
|
return this;
|
|
2756
2756
|
}
|
|
@@ -2758,10 +2758,10 @@ class Navigateable {
|
|
|
2758
2758
|
this.computedStatus = "navigated";
|
|
2759
2759
|
}
|
|
2760
2760
|
_navigate(location, options = {}) {
|
|
2761
|
-
const {
|
|
2761
|
+
const { allow } = { ...defaultNavigateOptions, ...options };
|
|
2762
2762
|
const ensuredLocation = (() => {
|
|
2763
|
-
if (
|
|
2764
|
-
if (location < 0 &&
|
|
2763
|
+
if (allow === "possible") {
|
|
2764
|
+
if (location < 0 && allow === "possible") {
|
|
2765
2765
|
return 0;
|
|
2766
2766
|
}
|
|
2767
2767
|
if (location > this.array.length - 1) {
|
|
@@ -2773,8 +2773,8 @@ class Navigateable {
|
|
|
2773
2773
|
this.computedLocation = ensuredLocation;
|
|
2774
2774
|
}
|
|
2775
2775
|
next(options = {}) {
|
|
2776
|
-
const { distance, loops,
|
|
2777
|
-
if (
|
|
2776
|
+
const { distance, loops, allow } = { ...defaultNextAndPreviousOptions, ...defaultNavigateOptions, ...options }, newLocation = (() => {
|
|
2777
|
+
if (allow === "any") {
|
|
2778
2778
|
return this.location + distance;
|
|
2779
2779
|
}
|
|
2780
2780
|
const lastLocation = this.array.length - 1;
|
|
@@ -2792,7 +2792,7 @@ class Navigateable {
|
|
|
2792
2792
|
return newLocation2;
|
|
2793
2793
|
})();
|
|
2794
2794
|
})();
|
|
2795
|
-
this._navigate(newLocation, {
|
|
2795
|
+
this._navigate(newLocation, { allow });
|
|
2796
2796
|
this.nexted();
|
|
2797
2797
|
return this;
|
|
2798
2798
|
}
|
|
@@ -2800,8 +2800,8 @@ class Navigateable {
|
|
|
2800
2800
|
this.computedStatus = "navigated to next";
|
|
2801
2801
|
}
|
|
2802
2802
|
previous(options = {}) {
|
|
2803
|
-
const { distance, loops,
|
|
2804
|
-
if (
|
|
2803
|
+
const { distance, loops, allow } = { ...defaultNextAndPreviousOptions, ...defaultNavigateOptions, ...options }, newLocation = (() => {
|
|
2804
|
+
if (allow === "any") {
|
|
2805
2805
|
return this.location - distance;
|
|
2806
2806
|
}
|
|
2807
2807
|
if (this.location - distance >= 0) {
|
|
@@ -2818,7 +2818,7 @@ class Navigateable {
|
|
|
2818
2818
|
return newLocation2;
|
|
2819
2819
|
})();
|
|
2820
2820
|
})();
|
|
2821
|
-
this._navigate(newLocation, {
|
|
2821
|
+
this._navigate(newLocation, { allow });
|
|
2822
2822
|
this.previoused();
|
|
2823
2823
|
return this;
|
|
2824
2824
|
}
|