@aws-amplify/storage 4.4.10 → 4.4.12-unstable.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.4.11](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.4.10...@aws-amplify/storage@4.4.11) (2021-12-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-amplify/storage
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [4.4.10](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.4.9...@aws-amplify/storage@4.4.10) (2021-12-02)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @aws-amplify/storage
|
|
@@ -46700,10 +46700,21 @@ const numRegex = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-
|
|
|
46700
46700
|
// const octRegex = /0x[a-z0-9]+/;
|
|
46701
46701
|
// const binRegex = /0x[a-z0-9]+/;
|
|
46702
46702
|
|
|
46703
|
+
|
|
46704
|
+
//polyfill
|
|
46705
|
+
if (!Number.parseInt && window.parseInt) {
|
|
46706
|
+
Number.parseInt = window.parseInt;
|
|
46707
|
+
}
|
|
46708
|
+
if (!Number.parseFloat && window.parseFloat) {
|
|
46709
|
+
Number.parseFloat = window.parseFloat;
|
|
46710
|
+
}
|
|
46711
|
+
|
|
46712
|
+
|
|
46703
46713
|
const consider = {
|
|
46704
46714
|
hex : true,
|
|
46705
46715
|
leadingZeros: true,
|
|
46706
46716
|
decimalPoint: "\.",
|
|
46717
|
+
eNotation: true
|
|
46707
46718
|
//skipLike: /regex/
|
|
46708
46719
|
};
|
|
46709
46720
|
|
|
@@ -46719,7 +46730,10 @@ function toNumber(str, options = {}){
|
|
|
46719
46730
|
if(!str || typeof str !== "string" ) return str;
|
|
46720
46731
|
|
|
46721
46732
|
let trimmedStr = str.trim();
|
|
46722
|
-
|
|
46733
|
+
// if(trimmedStr === "0.0") return 0;
|
|
46734
|
+
// else if(trimmedStr === "+0.0") return 0;
|
|
46735
|
+
// else if(trimmedStr === "-0.0") return -0;
|
|
46736
|
+
|
|
46723
46737
|
if(options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;
|
|
46724
46738
|
else if (options.hex && hexRegex.test(trimmedStr)) {
|
|
46725
46739
|
return Number.parseInt(trimmedStr, 16);
|
|
@@ -46731,19 +46745,79 @@ function toNumber(str, options = {}){
|
|
|
46731
46745
|
//separate negative sign, leading zeros, and rest number
|
|
46732
46746
|
const match = numRegex.exec(trimmedStr);
|
|
46733
46747
|
if(match){
|
|
46734
|
-
const
|
|
46748
|
+
const sign = match[1];
|
|
46735
46749
|
const leadingZeros = match[2];
|
|
46736
|
-
|
|
46750
|
+
let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros
|
|
46751
|
+
//trim ending zeros for floating number
|
|
46752
|
+
|
|
46737
46753
|
const eNotation = match[4] || match[6];
|
|
46738
|
-
if(leadingZeros.length
|
|
46739
|
-
else if(!options.leadingZeros && leadingZeros.length > 0) return str;
|
|
46740
|
-
else
|
|
46754
|
+
if(!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str; //-0123
|
|
46755
|
+
else if(!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str; //0123
|
|
46756
|
+
else{//no leading zeros or leading zeros are allowed
|
|
46757
|
+
const num = Number(trimmedStr);
|
|
46758
|
+
const numStr = "" + num;
|
|
46759
|
+
if(numStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation
|
|
46760
|
+
if(options.eNotation) return num;
|
|
46761
|
+
else return str;
|
|
46762
|
+
}else if(eNotation){ //given number has enotation
|
|
46763
|
+
if(options.eNotation) return num;
|
|
46764
|
+
else return str;
|
|
46765
|
+
}else if(trimmedStr.indexOf(".") !== -1){ //floating number
|
|
46766
|
+
// const decimalPart = match[5].substr(1);
|
|
46767
|
+
// const intPart = trimmedStr.substr(0,trimmedStr.indexOf("."));
|
|
46768
|
+
|
|
46769
|
+
|
|
46770
|
+
// const p = numStr.indexOf(".");
|
|
46771
|
+
// const givenIntPart = numStr.substr(0,p);
|
|
46772
|
+
// const givenDecPart = numStr.substr(p+1);
|
|
46773
|
+
if(numStr === "0" && (numTrimmedByZeros === "") ) return num; //0.0
|
|
46774
|
+
else if(numStr === numTrimmedByZeros) return num; //0.456. 0.79000
|
|
46775
|
+
else if( sign && numStr === "-"+numTrimmedByZeros) return num;
|
|
46776
|
+
else return str;
|
|
46777
|
+
}
|
|
46778
|
+
|
|
46779
|
+
if(leadingZeros){
|
|
46780
|
+
// if(numTrimmedByZeros === numStr){
|
|
46781
|
+
// if(options.leadingZeros) return num;
|
|
46782
|
+
// else return str;
|
|
46783
|
+
// }else return str;
|
|
46784
|
+
if(numTrimmedByZeros === numStr) return num;
|
|
46785
|
+
else if(sign+numTrimmedByZeros === numStr) return num;
|
|
46786
|
+
else return str;
|
|
46787
|
+
}
|
|
46788
|
+
|
|
46789
|
+
if(trimmedStr === numStr) return num;
|
|
46790
|
+
else if(trimmedStr === sign+numStr) return num;
|
|
46791
|
+
// else{
|
|
46792
|
+
// //number with +/- sign
|
|
46793
|
+
// trimmedStr.test(/[-+][0-9]);
|
|
46794
|
+
|
|
46795
|
+
// }
|
|
46796
|
+
return str;
|
|
46797
|
+
}
|
|
46798
|
+
// else if(!eNotation && trimmedStr && trimmedStr !== Number(trimmedStr) ) return str;
|
|
46799
|
+
|
|
46741
46800
|
}else{ //non-numeric string
|
|
46742
46801
|
return str;
|
|
46743
46802
|
}
|
|
46744
46803
|
}
|
|
46745
46804
|
}
|
|
46746
46805
|
|
|
46806
|
+
/**
|
|
46807
|
+
*
|
|
46808
|
+
* @param {string} numStr without leading zeros
|
|
46809
|
+
* @returns
|
|
46810
|
+
*/
|
|
46811
|
+
function trimZeros(numStr){
|
|
46812
|
+
if(numStr && numStr.indexOf(".") !== -1){//float
|
|
46813
|
+
numStr = numStr.replace(/0+$/, ""); //remove ending zeros
|
|
46814
|
+
if(numStr === ".") numStr = "0";
|
|
46815
|
+
else if(numStr[0] === ".") numStr = "0"+numStr;
|
|
46816
|
+
else if(numStr[numStr.length-1] === ".") numStr = numStr.substr(0,numStr.length-1);
|
|
46817
|
+
return numStr;
|
|
46818
|
+
}
|
|
46819
|
+
return numStr;
|
|
46820
|
+
}
|
|
46747
46821
|
module.exports = toNumber
|
|
46748
46822
|
|
|
46749
46823
|
|