@cdk8s/awscdk-resolver 0.0.594 → 0.0.596
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/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +3 -3
- package/node_modules/@aws-sdk/core/dist-cjs/index.js +47 -2297
- package/node_modules/@aws-sdk/core/dist-es/index.js +3 -3
- package/node_modules/@aws-sdk/core/dist-types/index.d.ts +5 -5
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/index.d.ts +5 -5
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +4 -1
- package/node_modules/@aws-sdk/credential-provider-sso/dist-es/resolveSSOCredentials.js +4 -1
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -5
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/anynum/LICENSE +21 -0
- package/node_modules/anynum/README.md +142 -0
- package/node_modules/anynum/anynum.js +135 -0
- package/node_modules/anynum/digitTable.js +116 -0
- package/node_modules/anynum/package.json +42 -0
- package/node_modules/strnum/CHANGELOG.md +8 -0
- package/node_modules/strnum/README.md +9 -0
- package/node_modules/strnum/package.json +4 -1
- package/node_modules/strnum/strnum.js +9 -1
- package/package.json +4 -4
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { TABLE, TABLE_OFFSET, HIGH_MAP, NOT_DIGIT } from './digitTable.js';
|
|
4
|
+
|
|
5
|
+
const CHAR_0 = 48; // '0'.charCodeAt(0)
|
|
6
|
+
const CHAR_9 = 57; // '9'.charCodeAt(0)
|
|
7
|
+
const CHAR_MINUS = 45; // '-'.charCodeAt(0)
|
|
8
|
+
|
|
9
|
+
// Unicode minus/hyphen variants worth normalizing to ASCII '-' in numeric context:
|
|
10
|
+
// U+2212 MINUS SIGN − (mathematically correct minus)
|
|
11
|
+
// U+FF0D FULLWIDTH HYPHEN-MINUS - (Japanese fullwidth context)
|
|
12
|
+
// U+FE63 SMALL HYPHEN-MINUS ﹣ (small form variant)
|
|
13
|
+
//
|
|
14
|
+
// NOT normalized (deliberate):
|
|
15
|
+
// U+2013 EN DASH – (punctuation, not a numeric sign)
|
|
16
|
+
// U+2014 EM DASH — (punctuation)
|
|
17
|
+
// U+2010 HYPHEN ‐ (typographic hyphen)
|
|
18
|
+
//
|
|
19
|
+
// Rationale: only characters a human or locale formatter would plausibly use
|
|
20
|
+
// as a numeric minus sign are normalized. Dashes used for punctuation are left
|
|
21
|
+
// alone to avoid mangling non-numeric strings.
|
|
22
|
+
const MINUS_SET = new Set([0x2212, 0xFF0D, 0xFE63]);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Normalize all Unicode decimal digit characters in a string to ASCII (0-9),
|
|
26
|
+
* and normalize Unicode minus variants to ASCII '-' (U+002D).
|
|
27
|
+
*
|
|
28
|
+
* Non-digit, non-minus characters are passed through unchanged.
|
|
29
|
+
*
|
|
30
|
+
* Performance design:
|
|
31
|
+
* - Fast path: if the string has no convertible characters, return it unchanged
|
|
32
|
+
* (zero allocation).
|
|
33
|
+
* - BMP digits (0x0660..0xFFFF excl. surrogates): flat Uint8Array lookup (O(1)).
|
|
34
|
+
* - Supplementary plane digits (> 0xFFFF, encoded as surrogate pairs): Map lookup.
|
|
35
|
+
* - Minus variants: checked inline with a small fixed Set.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} str
|
|
38
|
+
* @returns {string}
|
|
39
|
+
*/
|
|
40
|
+
function anynum(str) {
|
|
41
|
+
if (typeof str !== 'string') return str;
|
|
42
|
+
|
|
43
|
+
const len = str.length;
|
|
44
|
+
if (len === 0) return str;
|
|
45
|
+
|
|
46
|
+
// Scan for first character needing conversion.
|
|
47
|
+
// If none found, return original string (zero allocation).
|
|
48
|
+
let firstHit = -1;
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < len; i++) {
|
|
51
|
+
const cc = str.charCodeAt(i);
|
|
52
|
+
|
|
53
|
+
// ASCII digit or ASCII minus — already normalized, skip fast
|
|
54
|
+
if ((cc >= CHAR_0 && cc <= CHAR_9) || cc === CHAR_MINUS) continue;
|
|
55
|
+
|
|
56
|
+
// Below first unicode digit script — check minus variants only
|
|
57
|
+
if (cc < TABLE_OFFSET) {
|
|
58
|
+
if (MINUS_SET.has(cc)) { firstHit = i; break; }
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Surrogate pairs live in BMP range 0xD800-0xDFFF — check before TABLE
|
|
63
|
+
if (cc >= 0xD800 && cc <= 0xDBFF) {
|
|
64
|
+
if (i + 1 < len) {
|
|
65
|
+
const low = str.charCodeAt(i + 1);
|
|
66
|
+
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
67
|
+
const cp = 0x10000 + ((cc - 0xD800) << 10) + (low - 0xDC00);
|
|
68
|
+
if (HIGH_MAP.has(cp)) { firstHit = i; break; }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// BMP non-surrogate: flat table lookup; also check minus variants in this range
|
|
75
|
+
if (TABLE[cc - TABLE_OFFSET] !== NOT_DIGIT || MINUS_SET.has(cc)) {
|
|
76
|
+
firstHit = i;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Nothing to replace — return original, zero allocation
|
|
82
|
+
if (firstHit === -1) return str;
|
|
83
|
+
|
|
84
|
+
// Build result: copy unchanged prefix, then convert from firstHit onward
|
|
85
|
+
const chars = [];
|
|
86
|
+
|
|
87
|
+
if (firstHit > 0) chars.push(str.slice(0, firstHit));
|
|
88
|
+
|
|
89
|
+
for (let i = firstHit; i < len; i++) {
|
|
90
|
+
const cc = str.charCodeAt(i);
|
|
91
|
+
|
|
92
|
+
// ASCII digit or ASCII minus — pass through
|
|
93
|
+
if ((cc >= CHAR_0 && cc <= CHAR_9) || cc === CHAR_MINUS) {
|
|
94
|
+
chars.push(str[i]);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Below TABLE_OFFSET — check minus variants, else pass through
|
|
99
|
+
if (cc < TABLE_OFFSET) {
|
|
100
|
+
chars.push(MINUS_SET.has(cc) ? '-' : str[i]);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Surrogate pairs
|
|
105
|
+
if (cc >= 0xD800 && cc <= 0xDBFF) {
|
|
106
|
+
if (i + 1 < len) {
|
|
107
|
+
const low = str.charCodeAt(i + 1);
|
|
108
|
+
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
109
|
+
const cp = 0x10000 + ((cc - 0xD800) << 10) + (low - 0xDC00);
|
|
110
|
+
const d = HIGH_MAP.get(cp);
|
|
111
|
+
if (d !== undefined) {
|
|
112
|
+
chars.push(String.fromCharCode(d + 48));
|
|
113
|
+
i++; // consume low surrogate
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
chars.push(str[i]);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// BMP non-surrogate: flat table lookup + minus variants
|
|
123
|
+
if (MINUS_SET.has(cc)) {
|
|
124
|
+
chars.push('-');
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const d = TABLE[cc - TABLE_OFFSET];
|
|
128
|
+
chars.push(d !== NOT_DIGIT ? String.fromCharCode(d + 48) : str[i]);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return chars.join('');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { anynum };
|
|
135
|
+
export default anynum;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flat lookup table: maps Unicode code point → ASCII digit (0-9).
|
|
3
|
+
* Only decimal digit characters (Unicode category Nd) are included.
|
|
4
|
+
*
|
|
5
|
+
* Strategy: Int32Array of size (maxCodePoint - minCodePoint + 1).
|
|
6
|
+
* Value 0xFF means "not a digit". Value 0-9 is the ASCII digit value.
|
|
7
|
+
* This gives O(1) lookup with no branching, no bisect, no loop.
|
|
8
|
+
*
|
|
9
|
+
* Memory: range is 0x0660 to 0x1FBF0 → ~129,936 entries × 1 byte = ~127 KB.
|
|
10
|
+
* Acceptable for a one-time init; lookup is a single array index.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// All known Unicode Nd (decimal digit) script zero code points.
|
|
14
|
+
// Each script has exactly 10 consecutive digits: zero+0 .. zero+9.
|
|
15
|
+
const SCRIPT_ZEROS = [
|
|
16
|
+
// Basic Latin (ASCII) — included for completeness / pass-through
|
|
17
|
+
0x0030, // 0-9
|
|
18
|
+
|
|
19
|
+
// Arabic scripts
|
|
20
|
+
0x0660, // Arabic-Indic ٠١٢٣٤٥٦٧٨٩
|
|
21
|
+
0x06F0, // Extended Arabic-Indic (Urdu/Persian/Sindhi) ۰۱۲۳
|
|
22
|
+
|
|
23
|
+
// Indic scripts
|
|
24
|
+
0x0966, // Devanagari ०१२३४५६७८९
|
|
25
|
+
0x09E6, // Bengali ০১২৩৪৫৬৭৮৯
|
|
26
|
+
0x0A66, // Gurmukhi ੦੧੨੩੪੫੬੭੮੯
|
|
27
|
+
0x0AE6, // Gujarati ૦૧૨૩૪૫૬૭૮૯
|
|
28
|
+
0x0B66, // Odia ୦୧୨୩୪୫୬୭୮୯
|
|
29
|
+
0x0BE6, // Tamil ௦௧௨௩௪௫௬௭௮௯
|
|
30
|
+
0x0C66, // Telugu ౦౧౨౩౪౫౬౭౮౯
|
|
31
|
+
0x0CE6, // Kannada ೦೧೨೩೪೫೬೭೮೯
|
|
32
|
+
0x0D66, // Malayalam ൦൧൨൩൪൫൬൭൮൯
|
|
33
|
+
0x0DE6, // Sinhala Archaic ෦෧෨෩෪෫෬෭෮෯
|
|
34
|
+
|
|
35
|
+
// Southeast Asian scripts
|
|
36
|
+
0x0E50, // Thai ๐๑๒๓๔๕๖๗๘๙
|
|
37
|
+
0x0ED0, // Lao ໐໑໒໓໔໕໖໗໘໙
|
|
38
|
+
0x0F20, // Tibetan ༠༡༢༣༤༥༦༧༨༩
|
|
39
|
+
0x1040, // Myanmar ၀၁၂၃၄၅၆၇၈၉
|
|
40
|
+
0x1090, // Myanmar Shan ႐႑႒႓႔႕႖႗႘႙
|
|
41
|
+
0x17E0, // Khmer ០១២៣៤៥៦៧៨៩
|
|
42
|
+
0x1810, // Mongolian ᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙
|
|
43
|
+
0x1946, // Limbu ᥆᥇᥈᥉᥊᥋᥌᥍᥎᥏
|
|
44
|
+
0x19D0, // New Tai Lue ᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙
|
|
45
|
+
0x1A80, // Tai Tham Hora ᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉
|
|
46
|
+
0x1A90, // Tai Tham Tham ᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙
|
|
47
|
+
0x1B50, // Balinese ᭐᭑᭒᭓᭔᭕᭖᭗᭘᭙
|
|
48
|
+
0x1BB0, // Sundanese ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹
|
|
49
|
+
0x1C40, // Lepcha ᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉
|
|
50
|
+
0x1C50, // Ol Chiki ᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙
|
|
51
|
+
|
|
52
|
+
// Fullwidth (CJK context)
|
|
53
|
+
0xFF10, // Fullwidth 0123456789
|
|
54
|
+
|
|
55
|
+
// Mathematical digit variants (Unicode math block)
|
|
56
|
+
0x1D7CE, // Mathematical Bold
|
|
57
|
+
0x1D7D8, // Mathematical Double-Struck
|
|
58
|
+
0x1D7E2, // Mathematical Sans-Serif
|
|
59
|
+
0x1D7EC, // Mathematical Sans-Serif Bold
|
|
60
|
+
0x1D7F6, // Mathematical Monospace
|
|
61
|
+
|
|
62
|
+
// Other scripts
|
|
63
|
+
0x104A0, // Osmanya 𐒠𐒡𐒢𐒣𐒤𐒥𐒦𐒧𐒨𐒩
|
|
64
|
+
0x10D30, // Hanifi Rohingya 𐴰𐴱𐴲𐴳𐴴𐴵𐴶𐴷𐴸𐴹
|
|
65
|
+
0x11066, // Brahmi 𑁦𑁧𑁨𑁩𑁪𑁫𑁬𑁭𑁮𑁯
|
|
66
|
+
0x110F0, // Sora Sompeng 𑃰𑃱𑃲𑃳𑃴𑃵𑃶𑃷𑃸𑃹
|
|
67
|
+
0x11136, // Chakma 𑄶𑄷𑄸𑄹𑄺𑄻𑄼𑄽𑄾𑄿
|
|
68
|
+
0x111D0, // Sharada 𑇐𑇑𑇒𑇓𑇔𑇕𑇖𑇗𑇘𑇙
|
|
69
|
+
0x112F0, // Khudawadi 𑋰𑋱𑋲𑋳𑋴𑋵𑋶𑋷𑋸𑋹
|
|
70
|
+
0x11450, // Newa 𑑐𑑑𑑒𑑓𑑔𑑕𑑖𑑗𑑘𑑙
|
|
71
|
+
0x114D0, // Tirhuta 𑓐𑓑𑓒𑓓𑓔𑓕𑓖𑓗𑓘𑓙
|
|
72
|
+
0x11650, // Modi 𑙐𑙑𑙒𑙓𑙔𑙕𑙖𑙗𑙘𑙙
|
|
73
|
+
0x116C0, // Takri 𑛀𑛁𑛂𑛃𑛄𑛅𑛆𑛇𑛈𑛉
|
|
74
|
+
0x11730, // Ahom 𑜰𑜱𑜲𑜳𑜴𑜵𑜶𑜷𑜸𑜹
|
|
75
|
+
0x118E0, // Warang Citi 𑣠𑣡𑣢𑣣𑣤𑣥𑣦𑣧𑣨𑣩
|
|
76
|
+
0x11950, // Dives Akuru 𑥐𑥑𑥒𑥓𑥔𑥕𑥖𑥗𑥘𑥙
|
|
77
|
+
0x11BF0, // Khitan Small Script
|
|
78
|
+
0x11C50, // Bhaiksuki 𑱐𑱑𑱒𑱓𑱔𑱕𑱖𑱗𑱘𑱙
|
|
79
|
+
0x11D50, // Masaram Gondi 𑵐𑵑𑵒𑵓𑵔𑵕𑵖𑵗𑵘𑵙
|
|
80
|
+
0x11DA0, // Gunjala Gondi 𑶠𑶡𑶢𑶣𑶤𑶥𑶦𑶧𑶨𑶩
|
|
81
|
+
0x11F50, // Kawi 𑽐𑽑𑽒𑽓𑽔𑽕𑽖𑽗𑽘𑽙
|
|
82
|
+
0x16A60, // Mro 𖩠𖩡𖩢𖩣𖩤𖩥𖩦𖩧𖩨𖩩
|
|
83
|
+
0x16AC0, // Tangsa 𖫀𖫁𖫂𖫃𖫄𖫅𖫆𖫇𖫈𖫉
|
|
84
|
+
0x16B50, // Pahawh Hmong 𖭐𖭑𖭒𖭓𖭔𖭕𖭖𖭗𖭘𖭙
|
|
85
|
+
0x1E140, // Nyiakeng Puachue Hmong 𞅀𞅁𞅂𞅃𞅄𞅅𞅆𞅇𞅈𞅉
|
|
86
|
+
0x1E2F0, // Wancho 𞋰𞋱𞋲𞋳𞋴𞋵𞋶𞋷𞋸𞋹
|
|
87
|
+
0x1E4F0, // Nag Mundari 𞓰𞓱𞓲𞓳𞓴𞓵𞓶𞓷𞓸𞓹
|
|
88
|
+
0x1E950, // Adlam 𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙
|
|
89
|
+
0x1FBF0, // Segmented digit symbols 🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
// Build a sparse Map for scripts above 0xFFFF (surrogate-pair range).
|
|
93
|
+
// These can't go into a flat Uint8Array indexed by code point efficiently.
|
|
94
|
+
const NOT_DIGIT = 0xFF;
|
|
95
|
+
const HIGH_MAP = new Map(); // codePoint → digit value (0-9)
|
|
96
|
+
|
|
97
|
+
const LOW_MAX = 0xFFFF;
|
|
98
|
+
const LOW_MIN = 0x0660; // first non-ASCII digit script
|
|
99
|
+
|
|
100
|
+
// Flat Uint8Array covering 0x0660 .. 0xFFFF
|
|
101
|
+
const TABLE_OFFSET = LOW_MIN;
|
|
102
|
+
const TABLE_SIZE = LOW_MAX - LOW_MIN + 1;
|
|
103
|
+
const TABLE = new Uint8Array(TABLE_SIZE).fill(NOT_DIGIT);
|
|
104
|
+
|
|
105
|
+
for (const zero of SCRIPT_ZEROS) {
|
|
106
|
+
for (let d = 0; d < 10; d++) {
|
|
107
|
+
const cp = zero + d;
|
|
108
|
+
if (cp <= LOW_MAX) {
|
|
109
|
+
TABLE[cp - TABLE_OFFSET] = d;
|
|
110
|
+
} else {
|
|
111
|
+
HIGH_MAP.set(cp, d);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { TABLE, TABLE_OFFSET, HIGH_MAP, NOT_DIGIT };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "anynum",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to ASCII numerals. Zero dependencies, performance-first.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./anynum.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"anynum.js",
|
|
9
|
+
"digitTable.js",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "jasmine tests/anynum.test.js",
|
|
14
|
+
"bench": "node test/bench.js"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"unicode",
|
|
18
|
+
"digits",
|
|
19
|
+
"normalize",
|
|
20
|
+
"devanagari",
|
|
21
|
+
"arabic",
|
|
22
|
+
"hindi",
|
|
23
|
+
"japanese",
|
|
24
|
+
"indic",
|
|
25
|
+
"asian",
|
|
26
|
+
"math",
|
|
27
|
+
"numerals",
|
|
28
|
+
"strnum"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/NaturalIntelligence/anynum"
|
|
33
|
+
},
|
|
34
|
+
"author": "Amit Gupta (https://solothought.work/)",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"funding": [
|
|
37
|
+
{
|
|
38
|
+
"type": "github",
|
|
39
|
+
"url": "https://github.com/sponsors/NaturalIntelligence"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
|
|
2
|
+
**2.4.0 / 2026-06-09**
|
|
3
|
+
- support unicode numerals using 'anynum'
|
|
4
|
+
|
|
5
|
+
**2.3.0 / 2026-05-07**
|
|
6
|
+
- support octal and binary, test with @byspec/numbers
|
|
7
|
+
- test with @byspec/numbers
|
|
8
|
+
|
|
9
|
+
|
|
2
10
|
**2.2.3 / 2026-04-07**
|
|
3
11
|
- remove unnecessary files from npm package
|
|
4
12
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# strnum
|
|
2
2
|
Parse string into Number based on configuration
|
|
3
3
|
|
|
4
|
+
[](https://npm-compare.com/strnum)
|
|
5
|
+
[](https://www.npmjs.com/package/strnum)
|
|
6
|
+
[](https://github.com/NaturalIntelligence/strnum)
|
|
7
|
+
|
|
4
8
|
## Users
|
|
5
9
|
|
|
6
10
|
<a href="https://github.com/aws-amplify" target="_blank"><img src="https://avatars.githubusercontent.com/u/41077760?s=100&v=4"></a>
|
|
@@ -86,6 +90,10 @@ toNumber("1.0e-2"); //0.01)
|
|
|
86
90
|
|
|
87
91
|
toNumber("+1212121212"); // 1212121212
|
|
88
92
|
toNumber("+1212121212", { skipLike: /\+[0-9]{10}/} )); //"+1212121212"
|
|
93
|
+
|
|
94
|
+
toNumber("1e1000", { unicode: true, infinity: "original" }); //"1e1000"
|
|
95
|
+
toNumber("1000", { unicode: true }); //1000
|
|
96
|
+
toNumber("1000", { unicode: false }); //"1000"
|
|
89
97
|
```
|
|
90
98
|
|
|
91
99
|
Supported Options
|
|
@@ -95,6 +103,7 @@ leadingZeros: true, //when number with leading zeros like 08 should be parsed. 0
|
|
|
95
103
|
eNotation: true, //when number with eNotation or number parsed in eNotation should be considered
|
|
96
104
|
skipLike: /regex/ //when string should not be parsed when it matches the specified regular expression
|
|
97
105
|
infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
|
|
106
|
+
unicode: false, //when number with unicode numerals should be parsed
|
|
98
107
|
```
|
|
99
108
|
|
|
100
109
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strnum",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Parse String to Number based on configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "strnum.js",
|
|
@@ -28,5 +28,8 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@byspec/numbers": "^0.1.1",
|
|
30
30
|
"jasmine": "^5.6.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"anynum": "^1.0.0"
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -3,6 +3,8 @@ const binRegex = /^0b[01]+$/;
|
|
|
3
3
|
const octRegex = /^0o[0-7]+$/;
|
|
4
4
|
const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
|
|
5
5
|
|
|
6
|
+
import anynum from "anynum";
|
|
7
|
+
|
|
6
8
|
const consider = {
|
|
7
9
|
hex: true,
|
|
8
10
|
binary: false,
|
|
@@ -12,6 +14,7 @@ const consider = {
|
|
|
12
14
|
eNotation: true,
|
|
13
15
|
//skipLike: /regex/,
|
|
14
16
|
infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
|
|
17
|
+
unicode: false,
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
export default function toNumber(str, options = {}) {
|
|
@@ -23,7 +26,12 @@ export default function toNumber(str, options = {}) {
|
|
|
23
26
|
if (trimmedStr.length === 0) return str;
|
|
24
27
|
else if (options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;
|
|
25
28
|
else if (trimmedStr === "0") return 0;
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
if (options.unicode) {
|
|
31
|
+
trimmedStr = anynum(trimmedStr);
|
|
32
|
+
if (trimmedStr === "0") return 0; // re-check after normalization
|
|
33
|
+
}
|
|
34
|
+
if (options.hex && hexRegex.test(trimmedStr)) {
|
|
27
35
|
return parse_int(trimmedStr, 16);
|
|
28
36
|
} else if (options.binary && binRegex.test(trimmedStr)) {
|
|
29
37
|
return parse_int(trimmedStr, 2);
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"organization": false
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@cdk8s/projen-common": "0.0.
|
|
45
|
+
"@cdk8s/projen-common": "0.0.710",
|
|
46
46
|
"@stylistic/eslint-plugin": "^2",
|
|
47
47
|
"@types/fs-extra": "^11.0.4",
|
|
48
48
|
"@types/jest": "^27",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"aws-cdk": "^2.1126.0",
|
|
53
53
|
"aws-cdk-lib": "2.195.0",
|
|
54
54
|
"cdk8s": "2.68.91",
|
|
55
|
-
"cdk8s-cli": "^2.207.
|
|
55
|
+
"cdk8s-cli": "^2.207.20",
|
|
56
56
|
"commit-and-tag-version": "^12",
|
|
57
57
|
"constructs": "10.3.0",
|
|
58
58
|
"eslint": "^9",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"constructs": "^10.3.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
80
|
+
"@aws-sdk/client-cloudformation": "^3.1065.0"
|
|
81
81
|
},
|
|
82
82
|
"bundledDependencies": [
|
|
83
83
|
"@aws-sdk/client-cloudformation"
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"version": "0.0.
|
|
96
|
+
"version": "0.0.596",
|
|
97
97
|
"jest": {
|
|
98
98
|
"coverageProvider": "v8",
|
|
99
99
|
"testMatch": [
|