@native-systems/utility 2.3.2 → 2.5.0
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/index.cjs +100 -11
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +100 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -687,6 +687,14 @@ var PgException = /*#__PURE__*/ (function (Error1) {
|
|
|
687
687
|
return PgException;
|
|
688
688
|
})(_wrap_native_super(Error));
|
|
689
689
|
|
|
690
|
+
function _array_like_to_array$1(arr, len) {
|
|
691
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
692
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
693
|
+
return arr2;
|
|
694
|
+
}
|
|
695
|
+
function _array_without_holes(arr) {
|
|
696
|
+
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
|
|
697
|
+
}
|
|
690
698
|
function _class_call_check$8(instance, Constructor) {
|
|
691
699
|
if (!(instance instanceof Constructor)) {
|
|
692
700
|
throw new TypeError('Cannot call a class as a function');
|
|
@@ -718,7 +726,48 @@ function _define_property$3(obj, key, value) {
|
|
|
718
726
|
}
|
|
719
727
|
return obj;
|
|
720
728
|
}
|
|
729
|
+
function _instanceof$1(left, right) {
|
|
730
|
+
if (
|
|
731
|
+
right != null &&
|
|
732
|
+
typeof Symbol !== 'undefined' &&
|
|
733
|
+
right[Symbol.hasInstance]
|
|
734
|
+
) {
|
|
735
|
+
return !!right[Symbol.hasInstance](left);
|
|
736
|
+
} else {
|
|
737
|
+
return left instanceof right;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
function _iterable_to_array(iter) {
|
|
741
|
+
if (
|
|
742
|
+
(typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
|
|
743
|
+
iter['@@iterator'] != null
|
|
744
|
+
)
|
|
745
|
+
return Array.from(iter);
|
|
746
|
+
}
|
|
747
|
+
function _non_iterable_spread() {
|
|
748
|
+
throw new TypeError(
|
|
749
|
+
'Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
function _to_consumable_array(arr) {
|
|
753
|
+
return (
|
|
754
|
+
_array_without_holes(arr) ||
|
|
755
|
+
_iterable_to_array(arr) ||
|
|
756
|
+
_unsupported_iterable_to_array$1(arr) ||
|
|
757
|
+
_non_iterable_spread()
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
761
|
+
if (!o) return;
|
|
762
|
+
if (typeof o === 'string') return _array_like_to_array$1(o, minLen);
|
|
763
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
764
|
+
if (n === 'Object' && o.constructor) n = o.constructor.name;
|
|
765
|
+
if (n === 'Map' || n === 'Set') return Array.from(n);
|
|
766
|
+
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
767
|
+
return _array_like_to_array$1(o, minLen);
|
|
768
|
+
}
|
|
721
769
|
var LOG_LEVEL = 'log';
|
|
770
|
+
var LOG_STACKS = process.env.LOG_STACKS === '1';
|
|
722
771
|
var NO_OP = function (_message) {
|
|
723
772
|
for (
|
|
724
773
|
var _len = arguments.length,
|
|
@@ -731,6 +780,37 @@ var NO_OP = function (_message) {
|
|
|
731
780
|
}
|
|
732
781
|
return undefined;
|
|
733
782
|
};
|
|
783
|
+
var serializeArg = function (arg) {
|
|
784
|
+
if (_instanceof$1(arg, Error)) {
|
|
785
|
+
if (LOG_STACKS) return arg;
|
|
786
|
+
var data = {
|
|
787
|
+
name: arg.name,
|
|
788
|
+
message: arg.message,
|
|
789
|
+
};
|
|
790
|
+
if (arg.code !== undefined) data.code = arg.code;
|
|
791
|
+
return data;
|
|
792
|
+
}
|
|
793
|
+
return arg;
|
|
794
|
+
};
|
|
795
|
+
var wrap = function (fn) {
|
|
796
|
+
return function (message) {
|
|
797
|
+
for (
|
|
798
|
+
var _len = arguments.length,
|
|
799
|
+
optionalParams = new Array(_len > 1 ? _len - 1 : 0),
|
|
800
|
+
_key = 1;
|
|
801
|
+
_key < _len;
|
|
802
|
+
_key++
|
|
803
|
+
) {
|
|
804
|
+
optionalParams[_key - 1] = arguments[_key];
|
|
805
|
+
}
|
|
806
|
+
fn.apply(
|
|
807
|
+
void 0,
|
|
808
|
+
[serializeArg(message)].concat(
|
|
809
|
+
_to_consumable_array(optionalParams.map(serializeArg))
|
|
810
|
+
)
|
|
811
|
+
);
|
|
812
|
+
};
|
|
813
|
+
};
|
|
734
814
|
var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
735
815
|
function ConsoleLogger(options) {
|
|
736
816
|
_class_call_check$8(this, ConsoleLogger);
|
|
@@ -740,23 +820,24 @@ var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
|
740
820
|
_define_property$3(this, 'dev', void 0);
|
|
741
821
|
_define_property$3(this, 'debug', void 0);
|
|
742
822
|
var level = (options || {}).level;
|
|
743
|
-
this.error = console.error.bind(console);
|
|
823
|
+
this.error = wrap(console.error.bind(console));
|
|
744
824
|
this.warn = NO_OP;
|
|
745
825
|
this.log = NO_OP;
|
|
746
826
|
switch (level) {
|
|
747
827
|
case 'warn':
|
|
748
|
-
this.warn = console.warn.bind(console);
|
|
828
|
+
this.warn = wrap(console.warn.bind(console));
|
|
749
829
|
break;
|
|
750
830
|
case 'log':
|
|
751
|
-
this.warn = console.warn.bind(console);
|
|
752
|
-
this.log = console.log.bind(console);
|
|
831
|
+
this.warn = wrap(console.warn.bind(console));
|
|
832
|
+
this.log = wrap(console.log.bind(console));
|
|
753
833
|
break;
|
|
754
834
|
}
|
|
755
835
|
this.dev =
|
|
756
836
|
process.env.NODE_ENV === 'development'
|
|
757
|
-
? console.log.bind(console)
|
|
837
|
+
? wrap(console.log.bind(console))
|
|
758
838
|
: NO_OP;
|
|
759
|
-
this.debug =
|
|
839
|
+
this.debug =
|
|
840
|
+
process.env.DEBUG === '1' ? wrap(console.log.bind(console)) : NO_OP;
|
|
760
841
|
}
|
|
761
842
|
_create_class$8(ConsoleLogger, [
|
|
762
843
|
{
|
|
@@ -783,22 +864,23 @@ var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
|
783
864
|
key: 'enable',
|
|
784
865
|
value: function enable() {
|
|
785
866
|
Object.defineProperty(this, 'error', {
|
|
786
|
-
value: console.error.bind(console),
|
|
867
|
+
value: wrap(console.error.bind(console)),
|
|
787
868
|
});
|
|
788
869
|
Object.defineProperty(this, 'warn', {
|
|
789
|
-
value: console.warn.bind(console),
|
|
870
|
+
value: wrap(console.warn.bind(console)),
|
|
790
871
|
});
|
|
791
872
|
Object.defineProperty(this, 'log', {
|
|
792
|
-
value: console.log.bind(console),
|
|
873
|
+
value: wrap(console.log.bind(console)),
|
|
793
874
|
});
|
|
794
875
|
Object.defineProperty(this, 'dev', {
|
|
795
876
|
value:
|
|
796
877
|
process.env.NODE_ENV === 'development'
|
|
797
|
-
? console.log.bind(console)
|
|
878
|
+
? wrap(console.log.bind(console))
|
|
798
879
|
: NO_OP,
|
|
799
880
|
});
|
|
800
881
|
Object.defineProperty(this, 'debug', {
|
|
801
|
-
value:
|
|
882
|
+
value:
|
|
883
|
+
process.env.DEBUG === '1' ? wrap(console.log.bind(console)) : NO_OP,
|
|
802
884
|
});
|
|
803
885
|
},
|
|
804
886
|
},
|
|
@@ -1829,6 +1911,12 @@ var LanguageHandler = /*#__PURE__*/ (function () {
|
|
|
1829
1911
|
return LanguageHandler;
|
|
1830
1912
|
})();
|
|
1831
1913
|
|
|
1914
|
+
function countryCodeToFlag(countryCode) {
|
|
1915
|
+
return countryCode.toUpperCase().replace(/./g, function (char) {
|
|
1916
|
+
return String.fromCodePoint(0x1f1e6 + char.charCodeAt(0) - 65);
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1832
1920
|
exports.CookieHelper = CookieHelper;
|
|
1833
1921
|
exports.DateFormatter = DateFormatter;
|
|
1834
1922
|
exports.FormSanitizer = FormSanitizer;
|
|
@@ -1841,6 +1929,7 @@ exports.NativeException = NativeException;
|
|
|
1841
1929
|
exports.PatternCompiler = PatternCompiler;
|
|
1842
1930
|
exports.PgException = PgException;
|
|
1843
1931
|
exports.PostgresError = PostgresError;
|
|
1932
|
+
exports.countryCodeToFlag = countryCodeToFlag;
|
|
1844
1933
|
exports.eqPlugin = eqPlugin;
|
|
1845
1934
|
exports.generatePrefix = generatePrefix;
|
|
1846
1935
|
exports.logger = logger;
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -685,6 +685,14 @@ var PgException = /*#__PURE__*/ (function (Error1) {
|
|
|
685
685
|
return PgException;
|
|
686
686
|
})(_wrap_native_super(Error));
|
|
687
687
|
|
|
688
|
+
function _array_like_to_array$1(arr, len) {
|
|
689
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
690
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
691
|
+
return arr2;
|
|
692
|
+
}
|
|
693
|
+
function _array_without_holes(arr) {
|
|
694
|
+
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
|
|
695
|
+
}
|
|
688
696
|
function _class_call_check$8(instance, Constructor) {
|
|
689
697
|
if (!(instance instanceof Constructor)) {
|
|
690
698
|
throw new TypeError('Cannot call a class as a function');
|
|
@@ -716,7 +724,48 @@ function _define_property$3(obj, key, value) {
|
|
|
716
724
|
}
|
|
717
725
|
return obj;
|
|
718
726
|
}
|
|
727
|
+
function _instanceof$1(left, right) {
|
|
728
|
+
if (
|
|
729
|
+
right != null &&
|
|
730
|
+
typeof Symbol !== 'undefined' &&
|
|
731
|
+
right[Symbol.hasInstance]
|
|
732
|
+
) {
|
|
733
|
+
return !!right[Symbol.hasInstance](left);
|
|
734
|
+
} else {
|
|
735
|
+
return left instanceof right;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function _iterable_to_array(iter) {
|
|
739
|
+
if (
|
|
740
|
+
(typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
|
|
741
|
+
iter['@@iterator'] != null
|
|
742
|
+
)
|
|
743
|
+
return Array.from(iter);
|
|
744
|
+
}
|
|
745
|
+
function _non_iterable_spread() {
|
|
746
|
+
throw new TypeError(
|
|
747
|
+
'Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
function _to_consumable_array(arr) {
|
|
751
|
+
return (
|
|
752
|
+
_array_without_holes(arr) ||
|
|
753
|
+
_iterable_to_array(arr) ||
|
|
754
|
+
_unsupported_iterable_to_array$1(arr) ||
|
|
755
|
+
_non_iterable_spread()
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
759
|
+
if (!o) return;
|
|
760
|
+
if (typeof o === 'string') return _array_like_to_array$1(o, minLen);
|
|
761
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
762
|
+
if (n === 'Object' && o.constructor) n = o.constructor.name;
|
|
763
|
+
if (n === 'Map' || n === 'Set') return Array.from(n);
|
|
764
|
+
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
765
|
+
return _array_like_to_array$1(o, minLen);
|
|
766
|
+
}
|
|
719
767
|
var LOG_LEVEL = 'log';
|
|
768
|
+
var LOG_STACKS = process.env.LOG_STACKS === '1';
|
|
720
769
|
var NO_OP = function (_message) {
|
|
721
770
|
for (
|
|
722
771
|
var _len = arguments.length,
|
|
@@ -729,6 +778,37 @@ var NO_OP = function (_message) {
|
|
|
729
778
|
}
|
|
730
779
|
return undefined;
|
|
731
780
|
};
|
|
781
|
+
var serializeArg = function (arg) {
|
|
782
|
+
if (_instanceof$1(arg, Error)) {
|
|
783
|
+
if (LOG_STACKS) return arg;
|
|
784
|
+
var data = {
|
|
785
|
+
name: arg.name,
|
|
786
|
+
message: arg.message,
|
|
787
|
+
};
|
|
788
|
+
if (arg.code !== undefined) data.code = arg.code;
|
|
789
|
+
return data;
|
|
790
|
+
}
|
|
791
|
+
return arg;
|
|
792
|
+
};
|
|
793
|
+
var wrap = function (fn) {
|
|
794
|
+
return function (message) {
|
|
795
|
+
for (
|
|
796
|
+
var _len = arguments.length,
|
|
797
|
+
optionalParams = new Array(_len > 1 ? _len - 1 : 0),
|
|
798
|
+
_key = 1;
|
|
799
|
+
_key < _len;
|
|
800
|
+
_key++
|
|
801
|
+
) {
|
|
802
|
+
optionalParams[_key - 1] = arguments[_key];
|
|
803
|
+
}
|
|
804
|
+
fn.apply(
|
|
805
|
+
void 0,
|
|
806
|
+
[serializeArg(message)].concat(
|
|
807
|
+
_to_consumable_array(optionalParams.map(serializeArg))
|
|
808
|
+
)
|
|
809
|
+
);
|
|
810
|
+
};
|
|
811
|
+
};
|
|
732
812
|
var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
733
813
|
function ConsoleLogger(options) {
|
|
734
814
|
_class_call_check$8(this, ConsoleLogger);
|
|
@@ -738,23 +818,24 @@ var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
|
738
818
|
_define_property$3(this, 'dev', void 0);
|
|
739
819
|
_define_property$3(this, 'debug', void 0);
|
|
740
820
|
var level = (options || {}).level;
|
|
741
|
-
this.error = console.error.bind(console);
|
|
821
|
+
this.error = wrap(console.error.bind(console));
|
|
742
822
|
this.warn = NO_OP;
|
|
743
823
|
this.log = NO_OP;
|
|
744
824
|
switch (level) {
|
|
745
825
|
case 'warn':
|
|
746
|
-
this.warn = console.warn.bind(console);
|
|
826
|
+
this.warn = wrap(console.warn.bind(console));
|
|
747
827
|
break;
|
|
748
828
|
case 'log':
|
|
749
|
-
this.warn = console.warn.bind(console);
|
|
750
|
-
this.log = console.log.bind(console);
|
|
829
|
+
this.warn = wrap(console.warn.bind(console));
|
|
830
|
+
this.log = wrap(console.log.bind(console));
|
|
751
831
|
break;
|
|
752
832
|
}
|
|
753
833
|
this.dev =
|
|
754
834
|
process.env.NODE_ENV === 'development'
|
|
755
|
-
? console.log.bind(console)
|
|
835
|
+
? wrap(console.log.bind(console))
|
|
756
836
|
: NO_OP;
|
|
757
|
-
this.debug =
|
|
837
|
+
this.debug =
|
|
838
|
+
process.env.DEBUG === '1' ? wrap(console.log.bind(console)) : NO_OP;
|
|
758
839
|
}
|
|
759
840
|
_create_class$8(ConsoleLogger, [
|
|
760
841
|
{
|
|
@@ -781,22 +862,23 @@ var ConsoleLogger = /*#__PURE__*/ (function () {
|
|
|
781
862
|
key: 'enable',
|
|
782
863
|
value: function enable() {
|
|
783
864
|
Object.defineProperty(this, 'error', {
|
|
784
|
-
value: console.error.bind(console),
|
|
865
|
+
value: wrap(console.error.bind(console)),
|
|
785
866
|
});
|
|
786
867
|
Object.defineProperty(this, 'warn', {
|
|
787
|
-
value: console.warn.bind(console),
|
|
868
|
+
value: wrap(console.warn.bind(console)),
|
|
788
869
|
});
|
|
789
870
|
Object.defineProperty(this, 'log', {
|
|
790
|
-
value: console.log.bind(console),
|
|
871
|
+
value: wrap(console.log.bind(console)),
|
|
791
872
|
});
|
|
792
873
|
Object.defineProperty(this, 'dev', {
|
|
793
874
|
value:
|
|
794
875
|
process.env.NODE_ENV === 'development'
|
|
795
|
-
? console.log.bind(console)
|
|
876
|
+
? wrap(console.log.bind(console))
|
|
796
877
|
: NO_OP,
|
|
797
878
|
});
|
|
798
879
|
Object.defineProperty(this, 'debug', {
|
|
799
|
-
value:
|
|
880
|
+
value:
|
|
881
|
+
process.env.DEBUG === '1' ? wrap(console.log.bind(console)) : NO_OP,
|
|
800
882
|
});
|
|
801
883
|
},
|
|
802
884
|
},
|
|
@@ -1827,6 +1909,12 @@ var LanguageHandler = /*#__PURE__*/ (function () {
|
|
|
1827
1909
|
return LanguageHandler;
|
|
1828
1910
|
})();
|
|
1829
1911
|
|
|
1912
|
+
function countryCodeToFlag(countryCode) {
|
|
1913
|
+
return countryCode.toUpperCase().replace(/./g, function (char) {
|
|
1914
|
+
return String.fromCodePoint(0x1f1e6 + char.charCodeAt(0) - 65);
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1830
1918
|
export {
|
|
1831
1919
|
CookieHelper,
|
|
1832
1920
|
DateFormatter,
|
|
@@ -1840,6 +1928,7 @@ export {
|
|
|
1840
1928
|
PatternCompiler,
|
|
1841
1929
|
PgException,
|
|
1842
1930
|
PostgresError,
|
|
1931
|
+
countryCodeToFlag,
|
|
1843
1932
|
eqPlugin,
|
|
1844
1933
|
generatePrefix,
|
|
1845
1934
|
logger,
|