locutus 2.0.36 → 2.0.38
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/cos.js +11 -0
- package/awk/builtin/exp.js +11 -0
- package/awk/builtin/index.js +5 -0
- package/awk/builtin/log.js +11 -0
- package/awk/builtin/sin.js +11 -0
- package/awk/builtin/sqrt.js +11 -0
- package/clojure/string/blank.js +17 -0
- package/clojure/string/index.js +5 -0
- package/clojure/string/lower_case.js +12 -0
- package/clojure/string/reverse.js +11 -0
- package/clojure/string/trim.js +11 -0
- package/clojure/string/upper_case.js +12 -0
- package/elixir/String/downcase.js +11 -0
- package/elixir/String/index.js +4 -0
- package/elixir/String/length.js +11 -0
- package/elixir/String/reverse.js +11 -0
- package/elixir/String/upcase.js +11 -0
- package/julia/Base/index.js +2 -0
- package/julia/Base/lowercase.js +11 -0
- package/julia/Base/uppercase.js +11 -0
- package/lua/math/cos.js +11 -0
- package/lua/math/index.js +5 -0
- package/lua/math/max.js +11 -0
- package/lua/math/min.js +11 -0
- package/lua/math/sin.js +11 -0
- package/lua/math/sqrt.js +11 -0
- package/lua/string/index.js +3 -0
- package/lua/string/len.js +11 -0
- package/lua/string/rep.js +14 -0
- package/lua/string/reverse.js +11 -0
- package/package.json +2 -2
- package/perl/core/index.js +1 -0
- package/perl/core/reverse.js +12 -0
- package/php/ctype/ctype_cntrl.js +7 -6
- package/php/ctype/ctype_space.js +5 -4
- package/php/strings/quoted_printable_decode.js +1 -0
- package/php/strings/quoted_printable_encode.js +11 -10
- package/php/strings/strcoll.js +6 -5
- package/php/strings/wordwrap.js +16 -15
- package/r/base/index.js +7 -0
- package/r/base/max.js +11 -0
- package/r/base/min.js +11 -0
- package/r/base/nchar.js +11 -0
- package/r/base/round.js +15 -0
- package/r/base/sqrt.js +11 -0
- package/r/base/tolower.js +11 -0
- package/r/base/toupper.js +11 -0
- package/{_data/rosetta.yml → rosetta.yml} +48 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function cos(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/cos/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: cos(0)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: cos(1)
|
|
8
|
+
// returns 2: 0.5403023058681398
|
|
9
|
+
|
|
10
|
+
return Math.cos(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function exp(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/exp/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: exp(0)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: exp(1)
|
|
8
|
+
// returns 2: 2.718281828459045
|
|
9
|
+
|
|
10
|
+
return Math.exp(x)
|
|
11
|
+
}
|
package/awk/builtin/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
module.exports.cos = require('./cos')
|
|
2
|
+
module.exports.exp = require('./exp')
|
|
1
3
|
module.exports.int = require('./int')
|
|
2
4
|
module.exports.length = require('./length')
|
|
5
|
+
module.exports.log = require('./log')
|
|
6
|
+
module.exports.sin = require('./sin')
|
|
7
|
+
module.exports.sqrt = require('./sqrt')
|
|
3
8
|
module.exports.substr = require('./substr')
|
|
4
9
|
module.exports.tolower = require('./tolower')
|
|
5
10
|
module.exports.toupper = require('./toupper')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function log(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/log/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: log(1)
|
|
6
|
+
// returns 1: 0
|
|
7
|
+
// example 2: log(2.718281828459045)
|
|
8
|
+
// returns 2: 1
|
|
9
|
+
|
|
10
|
+
return Math.log(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sin(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/sin/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sin(0)
|
|
6
|
+
// returns 1: 0
|
|
7
|
+
// example 2: sin(1)
|
|
8
|
+
// returns 2: 0.8414709848078965
|
|
9
|
+
|
|
10
|
+
return Math.sin(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sqrt(x) {
|
|
2
|
+
// discuss at: https://locutus.io/awk/sqrt/
|
|
3
|
+
// parity verified: GNU AWK 5.3
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sqrt(16)
|
|
6
|
+
// returns 1: 4
|
|
7
|
+
// example 2: sqrt(2)
|
|
8
|
+
// returns 2: 1.4142135623730951
|
|
9
|
+
|
|
10
|
+
return Math.sqrt(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = function blank(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/blank/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Clojure uses blank?, JS uses blank
|
|
6
|
+
// example 1: blank('')
|
|
7
|
+
// returns 1: true
|
|
8
|
+
// example 2: blank(' ')
|
|
9
|
+
// returns 2: true
|
|
10
|
+
// example 3: blank('hello')
|
|
11
|
+
// returns 3: false
|
|
12
|
+
|
|
13
|
+
if (s === null || s === undefined) {
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
return String(s).trim().length === 0
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = function lower_case(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/lower_case/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Clojure uses lower-case, JS uses lower_case
|
|
6
|
+
// example 1: lower_case('HELLO')
|
|
7
|
+
// returns 1: 'hello'
|
|
8
|
+
// example 2: lower_case('Hello World')
|
|
9
|
+
// returns 2: 'hello world'
|
|
10
|
+
|
|
11
|
+
return String(s).toLowerCase()
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function reverse(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/reverse/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: reverse('hello')
|
|
6
|
+
// returns 1: 'olleh'
|
|
7
|
+
// example 2: reverse('abc')
|
|
8
|
+
// returns 2: 'cba'
|
|
9
|
+
|
|
10
|
+
return String(s).split('').reverse().join('')
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function trim(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/trim/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: trim(' hello ')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: trim('abc')
|
|
8
|
+
// returns 2: 'abc'
|
|
9
|
+
|
|
10
|
+
return String(s).trim()
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = function upper_case(s) {
|
|
2
|
+
// discuss at: https://locutus.io/clojure/upper_case/
|
|
3
|
+
// parity verified: Clojure 1.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Clojure uses upper-case, JS uses upper_case
|
|
6
|
+
// example 1: upper_case('hello')
|
|
7
|
+
// returns 1: 'HELLO'
|
|
8
|
+
// example 2: upper_case('Hello World')
|
|
9
|
+
// returns 2: 'HELLO WORLD'
|
|
10
|
+
|
|
11
|
+
return String(s).toUpperCase()
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function downcase(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/downcase/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: downcase('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: downcase('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(string).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function length(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/length/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: length('hello')
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: length('')
|
|
8
|
+
// returns 2: 0
|
|
9
|
+
|
|
10
|
+
return String(string).length
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function reverse(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/reverse/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: reverse('hello')
|
|
6
|
+
// returns 1: 'olleh'
|
|
7
|
+
// example 2: reverse('abc')
|
|
8
|
+
// returns 2: 'cba'
|
|
9
|
+
|
|
10
|
+
return String(string).split('').reverse().join('')
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function upcase(string) {
|
|
2
|
+
// discuss at: https://locutus.io/elixir/upcase/
|
|
3
|
+
// parity verified: Elixir 1.18
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: upcase('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: upcase('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(string).toUpperCase()
|
|
11
|
+
}
|
package/julia/Base/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function lowercase(s) {
|
|
2
|
+
// discuss at: https://locutus.io/julia/lowercase/
|
|
3
|
+
// parity verified: Julia 1.11
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: lowercase('HELLO')
|
|
6
|
+
// returns 1: 'hello'
|
|
7
|
+
// example 2: lowercase('Hello World')
|
|
8
|
+
// returns 2: 'hello world'
|
|
9
|
+
|
|
10
|
+
return String(s).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function uppercase(s) {
|
|
2
|
+
// discuss at: https://locutus.io/julia/uppercase/
|
|
3
|
+
// parity verified: Julia 1.11
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: uppercase('hello')
|
|
6
|
+
// returns 1: 'HELLO'
|
|
7
|
+
// example 2: uppercase('Hello World')
|
|
8
|
+
// returns 2: 'HELLO WORLD'
|
|
9
|
+
|
|
10
|
+
return String(s).toUpperCase()
|
|
11
|
+
}
|
package/lua/math/cos.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function cos(x) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/cos/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: cos(0)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: cos(1)
|
|
8
|
+
// returns 2: 0.5403023058681398
|
|
9
|
+
|
|
10
|
+
return Math.cos(x)
|
|
11
|
+
}
|
package/lua/math/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
module.exports.abs = require('./abs')
|
|
2
2
|
module.exports.ceil = require('./ceil')
|
|
3
|
+
module.exports.cos = require('./cos')
|
|
3
4
|
module.exports.floor = require('./floor')
|
|
5
|
+
module.exports.max = require('./max')
|
|
6
|
+
module.exports.min = require('./min')
|
|
7
|
+
module.exports.sin = require('./sin')
|
|
8
|
+
module.exports.sqrt = require('./sqrt')
|
package/lua/math/max.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function max(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/max/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: max(1, 5, 3)
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: max(-1, -5)
|
|
8
|
+
// returns 2: -1
|
|
9
|
+
|
|
10
|
+
return Math.max(...args)
|
|
11
|
+
}
|
package/lua/math/min.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function min(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/min/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: min(1, 5, 3)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: min(-1, -5)
|
|
8
|
+
// returns 2: -5
|
|
9
|
+
|
|
10
|
+
return Math.min(...args)
|
|
11
|
+
}
|
package/lua/math/sin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sin(x) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/sin/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sin(0)
|
|
6
|
+
// returns 1: 0
|
|
7
|
+
// example 2: sin(1)
|
|
8
|
+
// returns 2: 0.8414709848078965
|
|
9
|
+
|
|
10
|
+
return Math.sin(x)
|
|
11
|
+
}
|
package/lua/math/sqrt.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sqrt(x) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/sqrt/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sqrt(16)
|
|
6
|
+
// returns 1: 4
|
|
7
|
+
// example 2: sqrt(2)
|
|
8
|
+
// returns 2: 1.4142135623730951
|
|
9
|
+
|
|
10
|
+
return Math.sqrt(x)
|
|
11
|
+
}
|
package/lua/string/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function len(s) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/len/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: len('hello')
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: len('')
|
|
8
|
+
// returns 2: 0
|
|
9
|
+
|
|
10
|
+
return String(s).length
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = function rep(s, n) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/rep/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: rep('ab', 3)
|
|
6
|
+
// returns 1: 'ababab'
|
|
7
|
+
// example 2: rep('x', 5)
|
|
8
|
+
// returns 2: 'xxxxx'
|
|
9
|
+
|
|
10
|
+
if (n <= 0) {
|
|
11
|
+
return ''
|
|
12
|
+
}
|
|
13
|
+
return String(s).repeat(n)
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function reverse(s) {
|
|
2
|
+
// discuss at: https://locutus.io/lua/reverse/
|
|
3
|
+
// parity verified: Lua 5.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: reverse('hello')
|
|
6
|
+
// returns 1: 'olleh'
|
|
7
|
+
// example 2: reverse('abc')
|
|
8
|
+
// returns 2: 'cba'
|
|
9
|
+
|
|
10
|
+
return String(s).split('').reverse().join('')
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "locutus",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.38",
|
|
4
4
|
"description": "Locutus other languages' standard libraries to JavaScript for fun and educational purposes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"php",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"packageManager": "yarn@4.12.0",
|
|
83
83
|
"engines": {
|
|
84
|
-
"node": ">=
|
|
84
|
+
"node": ">= 10",
|
|
85
85
|
"yarn": ">= 1"
|
|
86
86
|
},
|
|
87
87
|
"readmeFilename": "README.md"
|
package/perl/core/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = function reverse(str) {
|
|
2
|
+
// discuss at: https://locutus.io/perl/reverse/
|
|
3
|
+
// parity verified: Perl 5.40
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: In scalar context, reverses string characters
|
|
6
|
+
// example 1: reverse('hello')
|
|
7
|
+
// returns 1: 'olleh'
|
|
8
|
+
// example 2: reverse('abc')
|
|
9
|
+
// returns 2: 'cba'
|
|
10
|
+
|
|
11
|
+
return String(str).split('').reverse().join('')
|
|
12
|
+
}
|
package/php/ctype/ctype_cntrl.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
module.exports = function ctype_cntrl(text) {
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
2
|
+
// discuss at: https://locutus.io/php/ctype_cntrl/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Brett Zamir (https://brett-zamir.me)
|
|
5
|
+
// example 1: ctype_cntrl('\u0020')
|
|
6
|
+
// returns 1: false
|
|
7
|
+
// example 2: ctype_cntrl('\u001F')
|
|
8
|
+
// returns 2: true
|
|
8
9
|
|
|
9
10
|
const setlocale = require('../strings/setlocale')
|
|
10
11
|
if (typeof text !== 'string') {
|
package/php/ctype/ctype_space.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module.exports = function ctype_space(text) {
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// discuss at: https://locutus.io/php/ctype_space/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Brett Zamir (https://brett-zamir.me)
|
|
5
|
+
// example 1: ctype_space('\t\n')
|
|
6
|
+
// returns 1: true
|
|
6
7
|
|
|
7
8
|
const setlocale = require('../strings/setlocale')
|
|
8
9
|
if (typeof text !== 'string') {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module.exports = function quoted_printable_decode(str) {
|
|
2
2
|
// discuss at: https://locutus.io/php/quoted_printable_decode/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
3
4
|
// original by: Ole Vrijenhoek
|
|
4
5
|
// bugfixed by: Brett Zamir (https://brett-zamir.me)
|
|
5
6
|
// bugfixed by: Theriault (https://github.com/Theriault)
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
module.exports = function quoted_printable_encode(str) {
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
2
|
+
// discuss at: https://locutus.io/php/quoted_printable_encode/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Theriault (https://github.com/Theriault)
|
|
5
|
+
// improved by: Brett Zamir (https://brett-zamir.me)
|
|
6
|
+
// improved by: Theriault (https://github.com/Theriault)
|
|
7
|
+
// example 1: quoted_printable_encode('a=b=c')
|
|
8
|
+
// returns 1: 'a=3Db=3Dc'
|
|
9
|
+
// example 2: quoted_printable_encode('abc \r\n123 \r\n')
|
|
10
|
+
// returns 2: 'abc =20\r\n123 =20\r\n'
|
|
11
|
+
// example 3: quoted_printable_encode('0123456789012345678901234567890123456789012345678901234567890123456789012345')
|
|
12
|
+
// returns 3: '012345678901234567890123456789012345678901234567890123456789012345678901234=\r\n5'
|
|
12
13
|
|
|
13
14
|
const hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
|
|
14
15
|
const RFC2045Encode1IN = / \r\n|\r\n|[^!-<>-~ ]/gm
|
package/php/strings/strcoll.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
module.exports = function strcoll(str1, str2) {
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
2
|
+
// discuss at: https://locutus.io/php/strcoll/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Brett Zamir (https://brett-zamir.me)
|
|
5
|
+
// improved by: Brett Zamir (https://brett-zamir.me)
|
|
6
|
+
// example 1: strcoll('a', 'b')
|
|
7
|
+
// returns 1: -1
|
|
7
8
|
|
|
8
9
|
const setlocale = require('../strings/setlocale')
|
|
9
10
|
|
package/php/strings/wordwrap.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
module.exports = function wordwrap(str, intWidth, strBreak, cut) {
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
2
|
+
// discuss at: https://locutus.io/php/wordwrap/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Jonas Raoni Soares Silva (https://www.jsfromhell.com)
|
|
5
|
+
// improved by: Nick Callen
|
|
6
|
+
// improved by: Kevin van Zonneveld (https://kvz.io)
|
|
7
|
+
// improved by: Sakimori
|
|
8
|
+
// revised by: Jonas Raoni Soares Silva (https://www.jsfromhell.com)
|
|
9
|
+
// bugfixed by: Michael Grier
|
|
10
|
+
// bugfixed by: Feras ALHAEK
|
|
11
|
+
// improved by: Rafał Kukawski (https://kukawski.net)
|
|
12
|
+
// example 1: wordwrap('Kevin van Zonneveld', 6, '|', true)
|
|
13
|
+
// returns 1: 'Kevin|van|Zonnev|eld'
|
|
14
|
+
// example 2: wordwrap('The quick brown fox jumped over the lazy dog.', 20, '<br />\n')
|
|
15
|
+
// returns 2: 'The quick brown fox<br />\njumped over the lazy<br />\ndog.'
|
|
16
|
+
// example 3: wordwrap('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.')
|
|
17
|
+
// returns 3: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim\nveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat.'
|
|
17
18
|
|
|
18
19
|
intWidth = arguments.length >= 2 ? +intWidth : 75
|
|
19
20
|
strBreak = arguments.length >= 3 ? '' + strBreak : '\n'
|
package/r/base/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
module.exports.abs = require('./abs')
|
|
2
2
|
module.exports.ceiling = require('./ceiling')
|
|
3
3
|
module.exports.floor = require('./floor')
|
|
4
|
+
module.exports.max = require('./max')
|
|
5
|
+
module.exports.min = require('./min')
|
|
6
|
+
module.exports.nchar = require('./nchar')
|
|
7
|
+
module.exports.round = require('./round')
|
|
8
|
+
module.exports.sqrt = require('./sqrt')
|
|
9
|
+
module.exports.tolower = require('./tolower')
|
|
10
|
+
module.exports.toupper = require('./toupper')
|
package/r/base/max.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function max(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/r/max/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: max(1, 5, 3)
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: max(-1, -5)
|
|
8
|
+
// returns 2: -1
|
|
9
|
+
|
|
10
|
+
return Math.max(...args)
|
|
11
|
+
}
|
package/r/base/min.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function min(...args) {
|
|
2
|
+
// discuss at: https://locutus.io/r/min/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: min(1, 5, 3)
|
|
6
|
+
// returns 1: 1
|
|
7
|
+
// example 2: min(-1, -5)
|
|
8
|
+
// returns 2: -5
|
|
9
|
+
|
|
10
|
+
return Math.min(...args)
|
|
11
|
+
}
|
package/r/base/nchar.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function nchar(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/nchar/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: nchar('hello')
|
|
6
|
+
// returns 1: 5
|
|
7
|
+
// example 2: nchar('')
|
|
8
|
+
// returns 2: 0
|
|
9
|
+
|
|
10
|
+
return String(x).length
|
|
11
|
+
}
|
package/r/base/round.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = function round(x, digits) {
|
|
2
|
+
// discuss at: https://locutus.io/r/round/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: round(3.14159)
|
|
6
|
+
// returns 1: 3
|
|
7
|
+
// example 2: round(3.14159, 2)
|
|
8
|
+
// returns 2: 3.14
|
|
9
|
+
|
|
10
|
+
if (digits === undefined || digits === 0) {
|
|
11
|
+
return Math.round(x)
|
|
12
|
+
}
|
|
13
|
+
const factor = Math.pow(10, digits)
|
|
14
|
+
return Math.round(x * factor) / factor
|
|
15
|
+
}
|
package/r/base/sqrt.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function sqrt(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/sqrt/
|
|
3
|
+
// parity verified: R 4.4
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// example 1: sqrt(16)
|
|
6
|
+
// returns 1: 4
|
|
7
|
+
// example 2: sqrt(2)
|
|
8
|
+
// returns 2: 1.4142135623730951
|
|
9
|
+
|
|
10
|
+
return Math.sqrt(x)
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function tolower(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/tolower/
|
|
3
|
+
// parity verified: R 4.4
|
|
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(x).toLowerCase()
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function toupper(x) {
|
|
2
|
+
// discuss at: https://locutus.io/r/toupper/
|
|
3
|
+
// parity verified: R 4.4
|
|
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(x).toUpperCase()
|
|
11
|
+
}
|
|
@@ -16,22 +16,40 @@ string_length:
|
|
|
16
16
|
- ruby/String/length
|
|
17
17
|
- perl/core/length
|
|
18
18
|
- awk/builtin/length
|
|
19
|
+
- lua/string/len
|
|
20
|
+
- elixir/String/length
|
|
21
|
+
- r/base/nchar
|
|
19
22
|
|
|
20
23
|
string_lowercase:
|
|
21
24
|
- php/strings/strtolower
|
|
22
25
|
- ruby/String/downcase
|
|
23
26
|
- golang/strings/ToLower
|
|
27
|
+
- lua/string/lower
|
|
28
|
+
- perl/core/lc
|
|
29
|
+
- awk/builtin/tolower
|
|
30
|
+
- r/base/tolower
|
|
31
|
+
- julia/Base/lowercase
|
|
32
|
+
- elixir/String/downcase
|
|
33
|
+
- clojure/string/lower_case
|
|
24
34
|
|
|
25
35
|
string_uppercase:
|
|
26
36
|
- php/strings/strtoupper
|
|
27
37
|
- ruby/String/upcase
|
|
28
38
|
- golang/strings/ToUpper
|
|
39
|
+
- lua/string/upper
|
|
40
|
+
- perl/core/uc
|
|
41
|
+
- awk/builtin/toupper
|
|
42
|
+
- r/base/toupper
|
|
43
|
+
- julia/Base/uppercase
|
|
44
|
+
- elixir/String/upcase
|
|
45
|
+
- clojure/string/upper_case
|
|
29
46
|
|
|
30
47
|
string_trim:
|
|
31
48
|
- php/strings/trim
|
|
32
49
|
- ruby/String/strip
|
|
33
50
|
- golang/strings/TrimSpace
|
|
34
51
|
- golang/strings/Trim
|
|
52
|
+
- clojure/string/trim
|
|
35
53
|
|
|
36
54
|
string_rtrim:
|
|
37
55
|
- php/strings/rtrim
|
|
@@ -54,6 +72,10 @@ string_ends_with:
|
|
|
54
72
|
string_reverse:
|
|
55
73
|
- php/strings/strrev
|
|
56
74
|
- ruby/String/reverse
|
|
75
|
+
- lua/string/reverse
|
|
76
|
+
- perl/core/reverse
|
|
77
|
+
- elixir/String/reverse
|
|
78
|
+
- clojure/string/reverse
|
|
57
79
|
|
|
58
80
|
string_split:
|
|
59
81
|
- php/strings/explode
|
|
@@ -79,6 +101,7 @@ string_last_index:
|
|
|
79
101
|
string_repeat:
|
|
80
102
|
- php/strings/str_repeat
|
|
81
103
|
- golang/strings/Repeat
|
|
104
|
+
- lua/string/rep
|
|
82
105
|
|
|
83
106
|
string_capitalize:
|
|
84
107
|
- php/strings/ucfirst
|
|
@@ -104,6 +127,8 @@ string_count:
|
|
|
104
127
|
string_substring:
|
|
105
128
|
- php/strings/substr
|
|
106
129
|
- awk/builtin/substr
|
|
130
|
+
- lua/string/sub
|
|
131
|
+
- perl/core/substr
|
|
107
132
|
|
|
108
133
|
# =============================================================================
|
|
109
134
|
# MATH OPERATIONS
|
|
@@ -113,16 +138,21 @@ math_sqrt:
|
|
|
113
138
|
- php/math/sqrt
|
|
114
139
|
- python/math/sqrt
|
|
115
140
|
- ruby/Math/sqrt
|
|
141
|
+
- lua/math/sqrt
|
|
142
|
+
- awk/builtin/sqrt
|
|
143
|
+
- r/base/sqrt
|
|
116
144
|
|
|
117
145
|
math_exp:
|
|
118
146
|
- php/math/exp
|
|
119
147
|
- python/math/exp
|
|
120
148
|
- ruby/Math/exp
|
|
149
|
+
- awk/builtin/exp
|
|
121
150
|
|
|
122
151
|
math_log:
|
|
123
152
|
- php/math/log
|
|
124
153
|
- python/math/log
|
|
125
154
|
- ruby/Math/log
|
|
155
|
+
- awk/builtin/log
|
|
126
156
|
|
|
127
157
|
math_log10:
|
|
128
158
|
- php/math/log10
|
|
@@ -136,10 +166,14 @@ math_log2:
|
|
|
136
166
|
math_sin:
|
|
137
167
|
- php/math/sin
|
|
138
168
|
- ruby/Math/sin
|
|
169
|
+
- lua/math/sin
|
|
170
|
+
- awk/builtin/sin
|
|
139
171
|
|
|
140
172
|
math_cos:
|
|
141
173
|
- php/math/cos
|
|
142
174
|
- ruby/Math/cos
|
|
175
|
+
- lua/math/cos
|
|
176
|
+
- awk/builtin/cos
|
|
143
177
|
|
|
144
178
|
math_tan:
|
|
145
179
|
- php/math/tan
|
|
@@ -198,6 +232,20 @@ math_abs:
|
|
|
198
232
|
- elixir/Kernel/abs
|
|
199
233
|
- clojure/Math/abs
|
|
200
234
|
|
|
235
|
+
math_max:
|
|
236
|
+
- php/math/max
|
|
237
|
+
- lua/math/max
|
|
238
|
+
- r/base/max
|
|
239
|
+
|
|
240
|
+
math_min:
|
|
241
|
+
- php/math/min
|
|
242
|
+
- lua/math/min
|
|
243
|
+
- r/base/min
|
|
244
|
+
|
|
245
|
+
math_round:
|
|
246
|
+
- php/math/round
|
|
247
|
+
- r/base/round
|
|
248
|
+
|
|
201
249
|
math_fabs:
|
|
202
250
|
- python/math/fabs
|
|
203
251
|
|