locutus 2.0.34 → 2.0.35
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/awk/builtin/index.js +2 -0
- package/awk/builtin/tolower.js +11 -0
- package/awk/builtin/toupper.js +11 -0
- package/lua/string/index.js +3 -0
- package/lua/string/lower.js +11 -0
- package/lua/string/sub.js +33 -0
- package/lua/string/upper.js +11 -0
- package/package.json +1 -1
package/awk/builtin/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function tolower(s) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/tolower/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: tolower('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: tolower('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(s).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function toupper(s) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/toupper/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: toupper('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: toupper('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(s).toUpperCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function lower(s) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/lower/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: lower('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: lower('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(s).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = function sub(s, i, j) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/sub/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Lua uses 1-based indexing, negative indices count from end
|
|
6
|
+
// example 1: sub('Hello', 1, 3)
|
|
7
|
+
// returns 1: 'Hel'
|
|
8
|
+
// example 2: sub('Hello', 2)
|
|
9
|
+
// returns 2: 'ello'
|
|
10
|
+
// example 3: sub('Hello', -2)
|
|
11
|
+
// returns 3: 'lo'
|
|
12
|
+
|
|
13
|
+
s = String(s)
|
|
14
|
+
const len = s.length
|
|
15
|
+
|
|
16
|
+
// Convert Lua 1-based index to JS 0-based
|
|
17
|
+
// Negative indices count from end in Lua
|
|
18
|
+
let start = i < 0 ? len + i : i - 1
|
|
19
|
+
let end = j === undefined ? len : j < 0 ? len + j + 1 : j
|
|
20
|
+
|
|
21
|
+
// Clamp to valid range
|
|
22
|
+
if (start < 0) {
|
|
23
|
+
start = 0
|
|
24
|
+
}
|
|
25
|
+
if (end > len) {
|
|
26
|
+
end = len
|
|
27
|
+
}
|
|
28
|
+
if (start >= end) {
|
|
29
|
+
return ''
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return s.substring(start, end)
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function upper(s) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/upper/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: upper('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: upper('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(s).toUpperCase()
|
|
11
|
+
}
|