locutus 2.0.32 → 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/README.md +18 -0
- package/_data/rosetta.yml +325 -0
- package/awk/builtin/index.js +5 -0
- package/awk/builtin/int.js +13 -0
- package/awk/builtin/length.js +16 -0
- package/awk/builtin/substr.js +23 -0
- package/awk/builtin/tolower.js +11 -0
- package/awk/builtin/toupper.js +11 -0
- package/c/ctype/index.js +8 -0
- package/c/ctype/isalnum.js +15 -0
- package/c/ctype/isalpha.js +17 -0
- package/c/ctype/isdigit.js +15 -0
- package/c/ctype/islower.js +15 -0
- package/c/ctype/isspace.js +15 -0
- package/c/ctype/isupper.js +15 -0
- package/c/ctype/tolower.js +15 -0
- package/c/ctype/toupper.js +15 -0
- package/c/index.js +2 -5
- package/c/math/abs.js +14 -18
- package/c/math/frexp.js +19 -20
- package/c/math/index.js +2 -5
- package/c/stdio/index.js +1 -4
- package/c/stdio/sprintf.js +71 -81
- package/c/stdlib/atof.js +15 -0
- package/c/stdlib/atoi.js +17 -0
- package/c/stdlib/index.js +2 -0
- package/c/string/index.js +5 -0
- package/c/string/strcat.js +12 -0
- package/c/string/strchr.js +15 -0
- package/c/string/strcmp.js +21 -0
- package/c/string/strlen.js +12 -0
- package/c/string/strstr.js +15 -0
- package/clojure/Math/abs.js +13 -0
- package/clojure/Math/ceil.js +15 -0
- package/clojure/Math/floor.js +14 -0
- package/clojure/Math/index.js +3 -0
- package/elixir/Float/ceil.js +16 -0
- package/elixir/Float/floor.js +14 -0
- package/elixir/Float/index.js +2 -0
- package/elixir/Kernel/abs.js +13 -0
- package/elixir/Kernel/index.js +1 -0
- package/golang/index.js +1 -4
- package/golang/strconv/Atoi.js +26 -0
- package/golang/strconv/FormatBool.js +12 -0
- package/golang/strconv/FormatInt.js +21 -0
- package/golang/strconv/Itoa.js +14 -0
- package/golang/strconv/ParseBool.js +35 -0
- package/golang/strconv/ParseInt.js +27 -0
- package/golang/strconv/index.js +6 -0
- package/golang/strings/Compare.js +19 -0
- package/golang/strings/Contains.js +7 -9
- package/golang/strings/ContainsAny.js +18 -0
- package/golang/strings/Count.js +20 -22
- package/golang/strings/EqualFold.js +13 -0
- package/golang/strings/Fields.js +12 -0
- package/golang/strings/HasPrefix.js +15 -0
- package/golang/strings/HasSuffix.js +20 -0
- package/golang/strings/Index.js +11 -0
- package/golang/strings/Index2.js +9 -11
- package/golang/strings/IndexAny.js +18 -0
- package/golang/strings/Join.js +16 -0
- package/golang/strings/LastIndex.js +10 -12
- package/golang/strings/LastIndexAny.js +18 -0
- package/golang/strings/Repeat.js +19 -0
- package/golang/strings/Replace.js +44 -0
- package/golang/strings/Split.js +24 -0
- package/golang/strings/ToLower.js +9 -0
- package/golang/strings/ToUpper.js +9 -0
- package/golang/strings/Trim.js +19 -0
- package/golang/strings/TrimLeft.js +15 -0
- package/golang/strings/TrimPrefix.js +14 -0
- package/golang/strings/TrimRight.js +15 -0
- package/golang/strings/TrimSpace.js +10 -0
- package/golang/strings/TrimSuffix.js +14 -0
- package/golang/strings/index.js +25 -7
- package/index.js +5 -8
- package/julia/Base/abs.js +13 -0
- package/julia/Base/ceil.js +16 -0
- package/julia/Base/floor.js +14 -0
- package/julia/Base/index.js +3 -0
- package/lua/math/abs.js +13 -0
- package/lua/math/ceil.js +16 -0
- package/lua/math/floor.js +14 -0
- package/lua/math/index.js +3 -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 +37 -51
- package/perl/POSIX/ceil.js +16 -0
- package/perl/POSIX/floor.js +14 -0
- package/perl/POSIX/index.js +2 -0
- package/perl/core/index.js +1 -0
- package/perl/core/length.js +16 -0
- package/php/_helpers/_bc.js +524 -515
- package/php/_helpers/_phpCastString.js +20 -25
- package/php/_helpers/_php_cast_float.js +5 -10
- package/php/_helpers/_php_cast_int.js +6 -11
- package/php/_helpers/index.js +4 -7
- package/php/array/array_change_key_case.js +11 -16
- package/php/array/array_chunk.js +20 -23
- package/php/array/array_column.js +22 -72
- package/php/array/array_combine.js +13 -18
- package/php/array/array_count_values.js +35 -39
- package/php/array/array_diff.js +11 -14
- package/php/array/array_diff_assoc.js +11 -14
- package/php/array/array_diff_key.js +11 -14
- package/php/array/array_diff_uassoc.js +15 -19
- package/php/array/array_diff_ukey.js +14 -17
- package/php/array/array_fill.js +11 -13
- package/php/array/array_fill_keys.js +5 -8
- package/php/array/array_filter.js +12 -13
- package/php/array/array_flip.js +13 -15
- package/php/array/array_intersect.js +13 -16
- package/php/array/array_intersect_assoc.js +13 -16
- package/php/array/array_intersect_key.js +15 -18
- package/php/array/array_intersect_uassoc.js +17 -20
- package/php/array/array_intersect_ukey.js +17 -20
- package/php/array/array_key_exists.js +4 -7
- package/php/array/array_keys.js +22 -24
- package/php/array/array_map.js +24 -29
- package/php/array/array_merge.js +22 -25
- package/php/array/array_merge_recursive.js +51 -27
- package/php/array/array_multisort.js +138 -130
- package/php/array/array_pad.js +24 -26
- package/php/array/array_pop.js +10 -13
- package/php/array/array_product.js +15 -17
- package/php/array/array_push.js +16 -19
- package/php/array/array_rand.js +11 -14
- package/php/array/array_reduce.js +11 -14
- package/php/array/array_replace.js +9 -12
- package/php/array/array_replace_recursive.js +20 -24
- package/php/array/array_reverse.js +12 -15
- package/php/array/array_search.js +27 -29
- package/php/array/array_shift.js +3 -6
- package/php/array/array_slice.js +37 -39
- package/php/array/array_splice.js +64 -69
- package/php/array/array_sum.js +7 -12
- package/php/array/array_udiff.js +14 -17
- package/php/array/array_udiff_assoc.js +14 -17
- package/php/array/array_udiff_uassoc.js +17 -20
- package/php/array/array_uintersect.js +16 -19
- package/php/array/array_uintersect_uassoc.js +18 -21
- package/php/array/array_unique.js +12 -15
- package/php/array/array_unshift.js +4 -7
- package/php/array/array_values.js +11 -13
- package/php/array/array_walk.js +10 -15
- package/php/array/array_walk_recursive.js +15 -20
- package/php/array/arsort.js +50 -52
- package/php/array/asort.js +50 -51
- package/php/array/count.js +15 -14
- package/php/array/current.js +30 -32
- package/php/array/each.js +32 -35
- package/php/array/end.js +27 -30
- package/php/array/in_array.js +7 -10
- package/php/array/index.js +73 -76
- package/php/array/key.js +32 -34
- package/php/array/krsort.js +50 -51
- package/php/array/ksort.js +50 -51
- package/php/array/natcasesort.js +37 -38
- package/php/array/natsort.js +35 -36
- package/php/array/next.js +34 -36
- package/php/array/pos.js +10 -12
- package/php/array/prev.js +32 -34
- package/php/array/range.js +30 -33
- package/php/array/reset.js +24 -27
- package/php/array/rsort.js +47 -49
- package/php/array/shuffle.js +16 -18
- package/php/array/sizeof.js +3 -6
- package/php/array/sort.js +43 -45
- package/php/array/uasort.js +19 -21
- package/php/array/uksort.js +22 -24
- package/php/array/usort.js +20 -22
- package/php/bc/bcadd.js +16 -19
- package/php/bc/bccomp.js +12 -15
- package/php/bc/bcdiv.js +17 -20
- package/php/bc/bcmul.js +16 -19
- package/php/bc/bcround.js +21 -24
- package/php/bc/bcscale.js +8 -11
- package/php/bc/bcsub.js +16 -19
- package/php/bc/index.js +7 -10
- package/php/ctype/ctype_alnum.js +14 -16
- package/php/ctype/ctype_alpha.js +14 -16
- package/php/ctype/ctype_cntrl.js +9 -12
- package/php/ctype/ctype_digit.js +14 -16
- package/php/ctype/ctype_graph.js +14 -16
- package/php/ctype/ctype_lower.js +14 -16
- package/php/ctype/ctype_print.js +14 -16
- package/php/ctype/ctype_punct.js +14 -16
- package/php/ctype/ctype_space.js +9 -12
- package/php/ctype/ctype_upper.js +14 -16
- package/php/ctype/ctype_xdigit.js +14 -16
- package/php/ctype/index.js +11 -14
- package/php/datetime/checkdate.js +15 -17
- package/php/datetime/date.js +142 -123
- package/php/datetime/date_parse.js +18 -21
- package/php/datetime/getdate.js +38 -24
- package/php/datetime/gettimeofday.js +7 -10
- package/php/datetime/gmdate.js +17 -16
- package/php/datetime/gmmktime.js +23 -25
- package/php/datetime/gmstrftime.js +17 -14
- package/php/datetime/idate.js +44 -38
- package/php/datetime/index.js +15 -18
- package/php/datetime/microtime.js +11 -14
- package/php/datetime/mktime.js +14 -17
- package/php/datetime/strftime.js +122 -113
- package/php/datetime/strptime.js +210 -191
- package/php/datetime/strtotime.js +615 -496
- package/php/datetime/time.js +11 -13
- package/php/exec/escapeshellarg.js +16 -18
- package/php/exec/index.js +1 -4
- package/php/filesystem/basename.js +22 -24
- package/php/filesystem/dirname.js +12 -14
- package/php/filesystem/file_exists.js +9 -11
- package/php/filesystem/file_get_contents.js +3 -6
- package/php/filesystem/index.js +6 -9
- package/php/filesystem/pathinfo.js +47 -46
- package/php/filesystem/realpath.js +16 -19
- package/php/funchand/call_user_func.js +4 -7
- package/php/funchand/call_user_func_array.js +19 -22
- package/php/funchand/create_function.js +4 -7
- package/php/funchand/function_exists.js +4 -8
- package/php/funchand/get_defined_functions.js +25 -32
- package/php/funchand/index.js +5 -8
- package/php/i18n/i18n_loc_get_default.js +7 -10
- package/php/i18n/i18n_loc_set_default.js +12 -15
- package/php/i18n/index.js +2 -5
- package/php/index.js +20 -23
- package/php/info/assert_options.js +25 -27
- package/php/info/getenv.js +8 -10
- package/php/info/index.js +6 -9
- package/php/info/ini_get.js +9 -12
- package/php/info/ini_set.js +32 -34
- package/php/info/set_time_limit.js +8 -11
- package/php/info/version_compare.js +43 -44
- package/php/json/index.js +3 -6
- package/php/json/json_decode.js +42 -28
- package/php/json/json_encode.js +89 -66
- package/php/json/json_last_error.js +11 -13
- package/php/math/abs.js +2 -5
- package/php/math/acos.js +2 -5
- package/php/math/acosh.js +7 -9
- package/php/math/asin.js +2 -5
- package/php/math/asinh.js +7 -9
- package/php/math/atan.js +7 -9
- package/php/math/atan2.js +7 -9
- package/php/math/atanh.js +2 -5
- package/php/math/base_convert.js +8 -10
- package/php/math/bindec.js +12 -14
- package/php/math/ceil.js +7 -9
- package/php/math/cos.js +7 -9
- package/php/math/cosh.js +7 -9
- package/php/math/decbin.js +16 -18
- package/php/math/dechex.js +3 -6
- package/php/math/decoct.js +13 -15
- package/php/math/deg2rad.js +8 -10
- package/php/math/exp.js +7 -9
- package/php/math/expm1.js +9 -11
- package/php/math/floor.js +7 -9
- package/php/math/fmod.js +27 -29
- package/php/math/getrandmax.js +7 -9
- package/php/math/hexdec.js +10 -12
- package/php/math/hypot.js +8 -11
- package/php/math/index.js +46 -49
- package/php/math/is_finite.js +9 -14
- package/php/math/is_infinite.js +9 -14
- package/php/math/is_nan.js +8 -13
- package/php/math/lcg_value.js +8 -10
- package/php/math/log.js +8 -10
- package/php/math/log10.js +12 -14
- package/php/math/log1p.js +15 -17
- package/php/math/max.js +54 -59
- package/php/math/min.js +54 -59
- package/php/math/mt_getrandmax.js +7 -9
- package/php/math/mt_rand.js +15 -17
- package/php/math/octdec.js +8 -10
- package/php/math/pi.js +2 -5
- package/php/math/pow.js +2 -5
- package/php/math/rad2deg.js +8 -10
- package/php/math/rand.js +15 -17
- package/php/math/round.js +48 -49
- package/php/math/sin.js +7 -9
- package/php/math/sinh.js +7 -9
- package/php/math/sqrt.js +7 -9
- package/php/math/tan.js +7 -9
- package/php/math/tanh.js +8 -10
- package/php/misc/index.js +2 -5
- package/php/misc/pack.js +173 -165
- package/php/misc/uniqid.js +20 -23
- package/php/net-gopher/gopher_parsedir.js +27 -29
- package/php/net-gopher/index.js +1 -4
- package/php/network/index.js +6 -9
- package/php/network/inet_ntop.js +15 -15
- package/php/network/inet_pton.js +30 -34
- package/php/network/ip2long.js +25 -15
- package/php/network/long2ip.js +8 -10
- package/php/network/setcookie.js +11 -13
- package/php/network/setrawcookie.js +16 -19
- package/php/pcre/index.js +4 -7
- package/php/pcre/preg_match.js +3 -6
- package/php/pcre/preg_quote.js +2 -5
- package/php/pcre/preg_replace.js +8 -11
- package/php/pcre/sql_regcase.js +17 -20
- package/php/strings/addcslashes.js +86 -88
- package/php/strings/addslashes.js +15 -16
- package/php/strings/bin2hex.js +19 -43
- package/php/strings/chop.js +8 -10
- package/php/strings/chr.js +12 -14
- package/php/strings/chunk_split.js +15 -17
- package/php/strings/convert_cyr_string.js +137 -50
- package/php/strings/convert_uuencode.js +35 -38
- package/php/strings/count_chars.js +29 -27
- package/php/strings/crc32.js +276 -21
- package/php/strings/echo.js +28 -30
- package/php/strings/explode.js +31 -26
- package/php/strings/get_html_translation_table.js +123 -122
- package/php/strings/hex2bin.js +21 -21
- package/php/strings/html_entity_decode.js +31 -33
- package/php/strings/htmlentities.js +38 -34
- package/php/strings/htmlspecialchars.js +20 -23
- package/php/strings/htmlspecialchars_decode.js +19 -21
- package/php/strings/implode.js +23 -27
- package/php/strings/index.js +91 -94
- package/php/strings/join.js +8 -10
- package/php/strings/lcfirst.js +9 -11
- package/php/strings/levenshtein.js +37 -39
- package/php/strings/localeconv.js +12 -15
- package/php/strings/ltrim.js +12 -14
- package/php/strings/md5.js +216 -223
- package/php/strings/md5_file.js +17 -19
- package/php/strings/metaphone.js +112 -117
- package/php/strings/money_format.js +139 -126
- package/php/strings/nl2br.js +24 -26
- package/php/strings/nl_langinfo.js +32 -35
- package/php/strings/number_format.js +19 -22
- package/php/strings/ord.js +19 -21
- package/php/strings/parse_str.js +53 -56
- package/php/strings/printf.js +6 -9
- package/php/strings/quoted_printable_decode.js +7 -10
- package/php/strings/quoted_printable_encode.js +19 -20
- package/php/strings/quotemeta.js +7 -9
- package/php/strings/rtrim.js +14 -16
- package/php/strings/setlocale.js +148 -104
- package/php/strings/sha1.js +108 -106
- package/php/strings/sha1_file.js +15 -17
- package/php/strings/similar_text.js +34 -33
- package/php/strings/soundex.js +34 -36
- package/php/strings/split.js +8 -10
- package/php/strings/sprintf.js +112 -114
- package/php/strings/sscanf.js +99 -96
- package/php/strings/str_getcsv.js +37 -32
- package/php/strings/str_ireplace.js +50 -55
- package/php/strings/str_pad.js +18 -21
- package/php/strings/str_repeat.js +14 -16
- package/php/strings/str_replace.js +32 -37
- package/php/strings/str_rot13.js +15 -17
- package/php/strings/str_shuffle.js +12 -15
- package/php/strings/str_split.js +19 -21
- package/php/strings/str_word_count.js +51 -50
- package/php/strings/strcasecmp.js +12 -14
- package/php/strings/strchr.js +10 -12
- package/php/strings/strcmp.js +12 -14
- package/php/strings/strcoll.js +9 -12
- package/php/strings/strcspn.js +30 -25
- package/php/strings/strip_tags.js +50 -52
- package/php/strings/stripos.js +12 -14
- package/php/strings/stripslashes.js +8 -10
- package/php/strings/stristr.js +15 -17
- package/php/strings/strlen.js +23 -26
- package/php/strings/strnatcasecmp.js +6 -8
- package/php/strings/strnatcmp.js +47 -46
- package/php/strings/strncasecmp.js +30 -32
- package/php/strings/strncmp.js +5 -7
- package/php/strings/strpbrk.js +12 -14
- package/php/strings/strpos.js +11 -13
- package/php/strings/strrchr.js +7 -10
- package/php/strings/strrev.js +188 -10
- package/php/strings/strripos.js +16 -18
- package/php/strings/strrpos.js +20 -22
- package/php/strings/strspn.js +24 -26
- package/php/strings/strstr.js +20 -22
- package/php/strings/strtok.js +14 -16
- package/php/strings/strtolower.js +8 -10
- package/php/strings/strtoupper.js +8 -10
- package/php/strings/strtr.js +38 -43
- package/php/strings/substr.js +14 -18
- package/php/strings/substr_compare.js +18 -20
- package/php/strings/substr_count.js +11 -14
- package/php/strings/substr_replace.js +5 -8
- package/php/strings/trim.js +53 -32
- package/php/strings/ucfirst.js +11 -13
- package/php/strings/ucwords.js +3 -6
- package/php/strings/vprintf.js +6 -9
- package/php/strings/vsprintf.js +8 -10
- package/php/strings/wordwrap.js +32 -35
- package/php/url/base64_decode.js +42 -40
- package/php/url/base64_encode.js +51 -53
- package/php/url/http_build_query.js +27 -32
- package/php/url/index.js +8 -11
- package/php/url/parse_url.js +61 -25
- package/php/url/rawurldecode.js +8 -8
- package/php/url/rawurlencode.js +9 -6
- package/php/url/urldecode.js +9 -8
- package/php/url/urlencode.js +11 -6
- package/php/var/boolval.js +31 -33
- package/php/var/doubleval.js +10 -12
- package/php/var/empty.js +11 -16
- package/php/var/floatval.js +13 -15
- package/php/var/gettype.js +22 -23
- package/php/var/index.js +30 -33
- package/php/var/intval.js +35 -39
- package/php/var/is_array.js +27 -31
- package/php/var/is_binary.js +2 -5
- package/php/var/is_bool.js +10 -12
- package/php/var/is_buffer.js +2 -5
- package/php/var/is_callable.js +34 -35
- package/php/var/is_double.js +10 -12
- package/php/var/is_float.js +12 -14
- package/php/var/is_int.js +20 -22
- package/php/var/is_integer.js +12 -14
- package/php/var/is_long.js +3 -6
- package/php/var/is_null.js +9 -11
- package/php/var/is_numeric.js +30 -6
- package/php/var/is_object.js +4 -9
- package/php/var/is_real.js +3 -6
- package/php/var/is_scalar.js +2 -8
- package/php/var/is_string.js +9 -11
- package/php/var/is_unicode.js +12 -15
- package/php/var/isset.js +9 -12
- package/php/var/print_r.js +49 -53
- package/php/var/serialize.js +47 -52
- package/php/var/serialize.vitest.ts +10 -0
- package/php/var/strval.js +10 -13
- package/php/var/unserialize.js +168 -202
- package/php/var/var_dump.js +105 -104
- package/php/var/var_export.js +64 -66
- package/php/xdiff/index.js +2 -5
- package/php/xdiff/xdiff_string_diff.js +240 -226
- package/php/xdiff/xdiff_string_patch.js +98 -93
- package/php/xml/index.js +2 -5
- package/php/xml/utf8_decode.js +40 -42
- package/php/xml/utf8_encode.js +40 -42
- package/python/index.js +1 -4
- package/python/math/ceil.js +17 -0
- package/python/math/exp.js +12 -0
- package/python/math/fabs.js +14 -0
- package/python/math/factorial.js +29 -0
- package/python/math/floor.js +14 -0
- package/python/math/gcd.js +23 -0
- package/python/math/index.js +15 -0
- package/python/math/isfinite.js +14 -0
- package/python/math/isinf.js +14 -0
- package/python/math/isnan.js +14 -0
- package/python/math/log.js +16 -0
- package/python/math/log10.js +14 -0
- package/python/math/log2.js +14 -0
- package/python/math/pow.js +14 -0
- package/python/math/sqrt.js +14 -0
- package/python/math/trunc.js +14 -0
- package/python/string/ascii_letters.js +14 -14
- package/python/string/ascii_lowercase.js +12 -16
- package/python/string/ascii_uppercase.js +12 -16
- package/python/string/capwords.js +4 -7
- package/python/string/digits.js +10 -0
- package/python/string/hexdigits.js +10 -0
- package/python/string/index.js +10 -8
- package/python/string/octdigits.js +10 -0
- package/python/string/printable.js +15 -0
- package/python/string/punctuation.js +5 -7
- package/python/string/whitespace.js +10 -0
- package/r/base/abs.js +13 -0
- package/r/base/ceiling.js +16 -0
- package/r/base/floor.js +14 -0
- package/r/base/index.js +3 -0
- package/ruby/Array/compact.js +18 -0
- package/ruby/Array/first.js +22 -0
- package/ruby/Array/flatten.js +22 -0
- package/ruby/Array/index.js +6 -0
- package/ruby/Array/last.js +22 -0
- package/ruby/Array/sample.js +31 -0
- package/ruby/Array/uniq.js +16 -0
- package/ruby/Math/acos.js +2 -5
- package/ruby/Math/asin.js +11 -0
- package/ruby/Math/atan.js +11 -0
- package/ruby/Math/cbrt.js +13 -0
- package/ruby/Math/cos.js +12 -0
- package/ruby/Math/cosh.js +11 -0
- package/ruby/Math/exp.js +11 -0
- package/ruby/Math/index.js +15 -4
- package/ruby/Math/log.js +11 -0
- package/ruby/Math/log10.js +13 -0
- package/ruby/Math/log2.js +13 -0
- package/ruby/Math/sin.js +12 -0
- package/ruby/Math/sinh.js +11 -0
- package/ruby/Math/sqrt.js +13 -0
- package/ruby/Math/tan.js +11 -0
- package/ruby/Math/tanh.js +11 -0
- package/ruby/String/capitalize.js +19 -0
- package/ruby/String/chomp.js +27 -0
- package/ruby/String/chop.js +25 -0
- package/ruby/String/downcase.js +10 -0
- package/ruby/String/end_with.js +17 -0
- package/ruby/String/include.js +12 -0
- package/ruby/String/index.js +11 -0
- package/ruby/String/length.js +12 -0
- package/ruby/String/reverse.js +12 -0
- package/ruby/String/start_with.js +14 -0
- package/ruby/String/strip.js +12 -0
- package/ruby/String/upcase.js +10 -0
- package/ruby/index.js +1 -4
- package/_util/cli.js +0 -14
- package/_util/cli.js.map +0 -1
- package/_util/util.js +0 -620
- package/_util/util.js.map +0 -1
- package/c/index.js.map +0 -1
- package/c/math/abs.js.map +0 -1
- package/c/math/frexp.js.map +0 -1
- package/c/math/index.js.map +0 -1
- package/c/stdio/index.js.map +0 -1
- package/c/stdio/sprintf.js.map +0 -1
- package/golang/index.js.map +0 -1
- package/golang/strings/Contains.js.map +0 -1
- package/golang/strings/Count.js.map +0 -1
- package/golang/strings/Index2.js.map +0 -1
- package/golang/strings/LastIndex.js.map +0 -1
- package/golang/strings/index.js.map +0 -1
- package/index.js.map +0 -1
- package/php/_helpers/_bc.js.map +0 -1
- package/php/_helpers/_phpCastString.js.map +0 -1
- package/php/_helpers/_php_cast_float.js.map +0 -1
- package/php/_helpers/_php_cast_int.js.map +0 -1
- package/php/_helpers/index.js.map +0 -1
- package/php/array/array_change_key_case.js.map +0 -1
- package/php/array/array_chunk.js.map +0 -1
- package/php/array/array_column.js.map +0 -1
- package/php/array/array_combine.js.map +0 -1
- package/php/array/array_count_values.js.map +0 -1
- package/php/array/array_diff.js.map +0 -1
- package/php/array/array_diff_assoc.js.map +0 -1
- package/php/array/array_diff_key.js.map +0 -1
- package/php/array/array_diff_uassoc.js.map +0 -1
- package/php/array/array_diff_ukey.js.map +0 -1
- package/php/array/array_fill.js.map +0 -1
- package/php/array/array_fill_keys.js.map +0 -1
- package/php/array/array_filter.js.map +0 -1
- package/php/array/array_flip.js.map +0 -1
- package/php/array/array_intersect.js.map +0 -1
- package/php/array/array_intersect_assoc.js.map +0 -1
- package/php/array/array_intersect_key.js.map +0 -1
- package/php/array/array_intersect_uassoc.js.map +0 -1
- package/php/array/array_intersect_ukey.js.map +0 -1
- package/php/array/array_key_exists.js.map +0 -1
- package/php/array/array_keys.js.map +0 -1
- package/php/array/array_map.js.map +0 -1
- package/php/array/array_merge.js.map +0 -1
- package/php/array/array_merge_recursive.js.map +0 -1
- package/php/array/array_multisort.js.map +0 -1
- package/php/array/array_pad.js.map +0 -1
- package/php/array/array_pop.js.map +0 -1
- package/php/array/array_product.js.map +0 -1
- package/php/array/array_push.js.map +0 -1
- package/php/array/array_rand.js.map +0 -1
- package/php/array/array_reduce.js.map +0 -1
- package/php/array/array_replace.js.map +0 -1
- package/php/array/array_replace_recursive.js.map +0 -1
- package/php/array/array_reverse.js.map +0 -1
- package/php/array/array_search.js.map +0 -1
- package/php/array/array_shift.js.map +0 -1
- package/php/array/array_slice.js.map +0 -1
- package/php/array/array_splice.js.map +0 -1
- package/php/array/array_sum.js.map +0 -1
- package/php/array/array_udiff.js.map +0 -1
- package/php/array/array_udiff_assoc.js.map +0 -1
- package/php/array/array_udiff_uassoc.js.map +0 -1
- package/php/array/array_uintersect.js.map +0 -1
- package/php/array/array_uintersect_uassoc.js.map +0 -1
- package/php/array/array_unique.js.map +0 -1
- package/php/array/array_unshift.js.map +0 -1
- package/php/array/array_values.js.map +0 -1
- package/php/array/array_walk.js.map +0 -1
- package/php/array/array_walk_recursive.js.map +0 -1
- package/php/array/arsort.js.map +0 -1
- package/php/array/asort.js.map +0 -1
- package/php/array/count.js.map +0 -1
- package/php/array/current.js.map +0 -1
- package/php/array/each.js.map +0 -1
- package/php/array/end.js.map +0 -1
- package/php/array/in_array.js.map +0 -1
- package/php/array/index.js.map +0 -1
- package/php/array/key.js.map +0 -1
- package/php/array/krsort.js.map +0 -1
- package/php/array/ksort.js.map +0 -1
- package/php/array/natcasesort.js.map +0 -1
- package/php/array/natsort.js.map +0 -1
- package/php/array/next.js.map +0 -1
- package/php/array/pos.js.map +0 -1
- package/php/array/prev.js.map +0 -1
- package/php/array/range.js.map +0 -1
- package/php/array/reset.js.map +0 -1
- package/php/array/rsort.js.map +0 -1
- package/php/array/shuffle.js.map +0 -1
- package/php/array/sizeof.js.map +0 -1
- package/php/array/sort.js.map +0 -1
- package/php/array/uasort.js.map +0 -1
- package/php/array/uksort.js.map +0 -1
- package/php/array/usort.js.map +0 -1
- package/php/bc/bcadd.js.map +0 -1
- package/php/bc/bccomp.js.map +0 -1
- package/php/bc/bcdiv.js.map +0 -1
- package/php/bc/bcmul.js.map +0 -1
- package/php/bc/bcround.js.map +0 -1
- package/php/bc/bcscale.js.map +0 -1
- package/php/bc/bcsub.js.map +0 -1
- package/php/bc/index.js.map +0 -1
- package/php/ctype/ctype_alnum.js.map +0 -1
- package/php/ctype/ctype_alpha.js.map +0 -1
- package/php/ctype/ctype_cntrl.js.map +0 -1
- package/php/ctype/ctype_digit.js.map +0 -1
- package/php/ctype/ctype_graph.js.map +0 -1
- package/php/ctype/ctype_lower.js.map +0 -1
- package/php/ctype/ctype_print.js.map +0 -1
- package/php/ctype/ctype_punct.js.map +0 -1
- package/php/ctype/ctype_space.js.map +0 -1
- package/php/ctype/ctype_upper.js.map +0 -1
- package/php/ctype/ctype_xdigit.js.map +0 -1
- package/php/ctype/index.js.map +0 -1
- package/php/datetime/checkdate.js.map +0 -1
- package/php/datetime/date.js.map +0 -1
- package/php/datetime/date_parse.js.map +0 -1
- package/php/datetime/getdate.js.map +0 -1
- package/php/datetime/gettimeofday.js.map +0 -1
- package/php/datetime/gmdate.js.map +0 -1
- package/php/datetime/gmmktime.js.map +0 -1
- package/php/datetime/gmstrftime.js.map +0 -1
- package/php/datetime/idate.js.map +0 -1
- package/php/datetime/index.js.map +0 -1
- package/php/datetime/microtime.js.map +0 -1
- package/php/datetime/mktime.js.map +0 -1
- package/php/datetime/strftime.js.map +0 -1
- package/php/datetime/strptime.js.map +0 -1
- package/php/datetime/strtotime.js.map +0 -1
- package/php/datetime/time.js.map +0 -1
- package/php/exec/escapeshellarg.js.map +0 -1
- package/php/exec/index.js.map +0 -1
- package/php/filesystem/basename.js.map +0 -1
- package/php/filesystem/dirname.js.map +0 -1
- package/php/filesystem/file_exists.js.map +0 -1
- package/php/filesystem/file_get_contents.js.map +0 -1
- package/php/filesystem/index.js.map +0 -1
- package/php/filesystem/pathinfo.js.map +0 -1
- package/php/filesystem/realpath.js.map +0 -1
- package/php/funchand/call_user_func.js.map +0 -1
- package/php/funchand/call_user_func_array.js.map +0 -1
- package/php/funchand/create_function.js.map +0 -1
- package/php/funchand/function_exists.js.map +0 -1
- package/php/funchand/get_defined_functions.js.map +0 -1
- package/php/funchand/index.js.map +0 -1
- package/php/i18n/i18n_loc_get_default.js.map +0 -1
- package/php/i18n/i18n_loc_set_default.js.map +0 -1
- package/php/i18n/index.js.map +0 -1
- package/php/index.js.map +0 -1
- package/php/info/assert_options.js.map +0 -1
- package/php/info/getenv.js.map +0 -1
- package/php/info/index.js.map +0 -1
- package/php/info/ini_get.js.map +0 -1
- package/php/info/ini_set.js.map +0 -1
- package/php/info/set_time_limit.js.map +0 -1
- package/php/info/version_compare.js.map +0 -1
- package/php/json/index.js.map +0 -1
- package/php/json/json_decode.js.map +0 -1
- package/php/json/json_encode.js.map +0 -1
- package/php/json/json_last_error.js.map +0 -1
- package/php/math/abs.js.map +0 -1
- package/php/math/acos.js.map +0 -1
- package/php/math/acosh.js.map +0 -1
- package/php/math/asin.js.map +0 -1
- package/php/math/asinh.js.map +0 -1
- package/php/math/atan.js.map +0 -1
- package/php/math/atan2.js.map +0 -1
- package/php/math/atanh.js.map +0 -1
- package/php/math/base_convert.js.map +0 -1
- package/php/math/bindec.js.map +0 -1
- package/php/math/ceil.js.map +0 -1
- package/php/math/cos.js.map +0 -1
- package/php/math/cosh.js.map +0 -1
- package/php/math/decbin.js.map +0 -1
- package/php/math/dechex.js.map +0 -1
- package/php/math/decoct.js.map +0 -1
- package/php/math/deg2rad.js.map +0 -1
- package/php/math/exp.js.map +0 -1
- package/php/math/expm1.js.map +0 -1
- package/php/math/floor.js.map +0 -1
- package/php/math/fmod.js.map +0 -1
- package/php/math/getrandmax.js.map +0 -1
- package/php/math/hexdec.js.map +0 -1
- package/php/math/hypot.js.map +0 -1
- package/php/math/index.js.map +0 -1
- package/php/math/is_finite.js.map +0 -1
- package/php/math/is_infinite.js.map +0 -1
- package/php/math/is_nan.js.map +0 -1
- package/php/math/lcg_value.js.map +0 -1
- package/php/math/log.js.map +0 -1
- package/php/math/log10.js.map +0 -1
- package/php/math/log1p.js.map +0 -1
- package/php/math/max.js.map +0 -1
- package/php/math/min.js.map +0 -1
- package/php/math/mt_getrandmax.js.map +0 -1
- package/php/math/mt_rand.js.map +0 -1
- package/php/math/octdec.js.map +0 -1
- package/php/math/pi.js.map +0 -1
- package/php/math/pow.js.map +0 -1
- package/php/math/rad2deg.js.map +0 -1
- package/php/math/rand.js.map +0 -1
- package/php/math/round.js.map +0 -1
- package/php/math/sin.js.map +0 -1
- package/php/math/sinh.js.map +0 -1
- package/php/math/sqrt.js.map +0 -1
- package/php/math/tan.js.map +0 -1
- package/php/math/tanh.js.map +0 -1
- package/php/misc/index.js.map +0 -1
- package/php/misc/pack.js.map +0 -1
- package/php/misc/uniqid.js.map +0 -1
- package/php/net-gopher/gopher_parsedir.js.map +0 -1
- package/php/net-gopher/index.js.map +0 -1
- package/php/network/index.js.map +0 -1
- package/php/network/inet_ntop.js.map +0 -1
- package/php/network/inet_pton.js.map +0 -1
- package/php/network/ip2long.js.map +0 -1
- package/php/network/long2ip.js.map +0 -1
- package/php/network/setcookie.js.map +0 -1
- package/php/network/setrawcookie.js.map +0 -1
- package/php/pcre/index.js.map +0 -1
- package/php/pcre/preg_match.js.map +0 -1
- package/php/pcre/preg_quote.js.map +0 -1
- package/php/pcre/preg_replace.js.map +0 -1
- package/php/pcre/sql_regcase.js.map +0 -1
- package/php/strings/addcslashes.js.map +0 -1
- package/php/strings/addslashes.js.map +0 -1
- package/php/strings/bin2hex.js.map +0 -1
- package/php/strings/chop.js.map +0 -1
- package/php/strings/chr.js.map +0 -1
- package/php/strings/chunk_split.js.map +0 -1
- package/php/strings/convert_cyr_string.js.map +0 -1
- package/php/strings/convert_uuencode.js.map +0 -1
- package/php/strings/count_chars.js.map +0 -1
- package/php/strings/crc32.js.map +0 -1
- package/php/strings/echo.js.map +0 -1
- package/php/strings/explode.js.map +0 -1
- package/php/strings/get_html_translation_table.js.map +0 -1
- package/php/strings/hex2bin.js.map +0 -1
- package/php/strings/html_entity_decode.js.map +0 -1
- package/php/strings/htmlentities.js.map +0 -1
- package/php/strings/htmlspecialchars.js.map +0 -1
- package/php/strings/htmlspecialchars_decode.js.map +0 -1
- package/php/strings/implode.js.map +0 -1
- package/php/strings/index.js.map +0 -1
- package/php/strings/join.js.map +0 -1
- package/php/strings/lcfirst.js.map +0 -1
- package/php/strings/levenshtein.js.map +0 -1
- package/php/strings/localeconv.js.map +0 -1
- package/php/strings/ltrim.js.map +0 -1
- package/php/strings/md5.js.map +0 -1
- package/php/strings/md5_file.js.map +0 -1
- package/php/strings/metaphone.js.map +0 -1
- package/php/strings/money_format.js.map +0 -1
- package/php/strings/nl2br.js.map +0 -1
- package/php/strings/nl_langinfo.js.map +0 -1
- package/php/strings/number_format.js.map +0 -1
- package/php/strings/ord.js.map +0 -1
- package/php/strings/parse_str.js.map +0 -1
- package/php/strings/printf.js.map +0 -1
- package/php/strings/quoted_printable_decode.js.map +0 -1
- package/php/strings/quoted_printable_encode.js.map +0 -1
- package/php/strings/quotemeta.js.map +0 -1
- package/php/strings/rtrim.js.map +0 -1
- package/php/strings/setlocale.js.map +0 -1
- package/php/strings/sha1.js.map +0 -1
- package/php/strings/sha1_file.js.map +0 -1
- package/php/strings/similar_text.js.map +0 -1
- package/php/strings/soundex.js.map +0 -1
- package/php/strings/split.js.map +0 -1
- package/php/strings/sprintf.js.map +0 -1
- package/php/strings/sscanf.js.map +0 -1
- package/php/strings/str_getcsv.js.map +0 -1
- package/php/strings/str_ireplace.js.map +0 -1
- package/php/strings/str_pad.js.map +0 -1
- package/php/strings/str_repeat.js.map +0 -1
- package/php/strings/str_replace.js.map +0 -1
- package/php/strings/str_rot13.js.map +0 -1
- package/php/strings/str_shuffle.js.map +0 -1
- package/php/strings/str_split.js.map +0 -1
- package/php/strings/str_word_count.js.map +0 -1
- package/php/strings/strcasecmp.js.map +0 -1
- package/php/strings/strchr.js.map +0 -1
- package/php/strings/strcmp.js.map +0 -1
- package/php/strings/strcoll.js.map +0 -1
- package/php/strings/strcspn.js.map +0 -1
- package/php/strings/strip_tags.js.map +0 -1
- package/php/strings/stripos.js.map +0 -1
- package/php/strings/stripslashes.js.map +0 -1
- package/php/strings/stristr.js.map +0 -1
- package/php/strings/strlen.js.map +0 -1
- package/php/strings/strnatcasecmp.js.map +0 -1
- package/php/strings/strnatcmp.js.map +0 -1
- package/php/strings/strncasecmp.js.map +0 -1
- package/php/strings/strncmp.js.map +0 -1
- package/php/strings/strpbrk.js.map +0 -1
- package/php/strings/strpos.js.map +0 -1
- package/php/strings/strrchr.js.map +0 -1
- package/php/strings/strrev.js.map +0 -1
- package/php/strings/strripos.js.map +0 -1
- package/php/strings/strrpos.js.map +0 -1
- package/php/strings/strspn.js.map +0 -1
- package/php/strings/strstr.js.map +0 -1
- package/php/strings/strtok.js.map +0 -1
- package/php/strings/strtolower.js.map +0 -1
- package/php/strings/strtoupper.js.map +0 -1
- package/php/strings/strtr.js.map +0 -1
- package/php/strings/substr.js.map +0 -1
- package/php/strings/substr_compare.js.map +0 -1
- package/php/strings/substr_count.js.map +0 -1
- package/php/strings/substr_replace.js.map +0 -1
- package/php/strings/trim.js.map +0 -1
- package/php/strings/ucfirst.js.map +0 -1
- package/php/strings/ucwords.js.map +0 -1
- package/php/strings/vprintf.js.map +0 -1
- package/php/strings/vsprintf.js.map +0 -1
- package/php/strings/wordwrap.js.map +0 -1
- package/php/url/base64_decode.js.map +0 -1
- package/php/url/base64_encode.js.map +0 -1
- package/php/url/http_build_query.js.map +0 -1
- package/php/url/index.js.map +0 -1
- package/php/url/parse_url.js.map +0 -1
- package/php/url/rawurldecode.js.map +0 -1
- package/php/url/rawurlencode.js.map +0 -1
- package/php/url/urldecode.js.map +0 -1
- package/php/url/urlencode.js.map +0 -1
- package/php/var/boolval.js.map +0 -1
- package/php/var/doubleval.js.map +0 -1
- package/php/var/empty.js.map +0 -1
- package/php/var/floatval.js.map +0 -1
- package/php/var/gettype.js.map +0 -1
- package/php/var/index.js.map +0 -1
- package/php/var/intval.js.map +0 -1
- package/php/var/is_array.js.map +0 -1
- package/php/var/is_binary.js.map +0 -1
- package/php/var/is_bool.js.map +0 -1
- package/php/var/is_buffer.js.map +0 -1
- package/php/var/is_callable.js.map +0 -1
- package/php/var/is_double.js.map +0 -1
- package/php/var/is_float.js.map +0 -1
- package/php/var/is_int.js.map +0 -1
- package/php/var/is_integer.js.map +0 -1
- package/php/var/is_long.js.map +0 -1
- package/php/var/is_null.js.map +0 -1
- package/php/var/is_numeric.js.map +0 -1
- package/php/var/is_object.js.map +0 -1
- package/php/var/is_real.js.map +0 -1
- package/php/var/is_scalar.js.map +0 -1
- package/php/var/is_string.js.map +0 -1
- package/php/var/is_unicode.js.map +0 -1
- package/php/var/isset.js.map +0 -1
- package/php/var/print_r.js.map +0 -1
- package/php/var/serialize.js.map +0 -1
- package/php/var/serialize.mocha.js +0 -14
- package/php/var/serialize.mocha.js.map +0 -1
- package/php/var/strval.js.map +0 -1
- package/php/var/unserialize.js.map +0 -1
- package/php/var/var_dump.js.map +0 -1
- package/php/var/var_export.js.map +0 -1
- package/php/xdiff/index.js.map +0 -1
- package/php/xdiff/xdiff_string_diff.js.map +0 -1
- package/php/xdiff/xdiff_string_patch.js.map +0 -1
- package/php/xml/index.js.map +0 -1
- package/php/xml/utf8_decode.js.map +0 -1
- package/php/xml/utf8_encode.js.map +0 -1
- package/python/index.js.map +0 -1
- package/python/string/ascii_letters.js.map +0 -1
- package/python/string/ascii_lowercase.js.map +0 -1
- package/python/string/ascii_uppercase.js.map +0 -1
- package/python/string/capwords.js.map +0 -1
- package/python/string/index.js.map +0 -1
- package/python/string/punctuation.js.map +0 -1
- package/ruby/Math/acos.js.map +0 -1
- package/ruby/Math/index.js.map +0 -1
- package/ruby/index.js.map +0 -1
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
module.exports = function xdiff_string_patch(originalStr, patch, flags, errorObj) {
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
2
|
+
// discuss at: https://locutus.io/php/xdiff_string_patch/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Brett Zamir (https://brett-zamir.me)
|
|
5
|
+
// improved by: Steven Levithan (stevenlevithan.com)
|
|
6
|
+
// note 1: The XDIFF_PATCH_IGNORESPACE flag and the error argument are not
|
|
7
|
+
// note 1: currently supported.
|
|
8
|
+
// note 2: This has not been tested exhaustively yet.
|
|
9
|
+
// note 3: The errorObj parameter (optional) if used must be passed in as a
|
|
10
|
+
// note 3: object. The errors will then be written by reference into it's `value` property
|
|
11
|
+
// example 1: xdiff_string_patch('', '@@ -0,0 +1,1 @@\n+Hello world!')
|
|
12
|
+
// returns 1: 'Hello world!'
|
|
14
13
|
|
|
15
14
|
// First two functions were adapted from Steven Levithan, also under an MIT license
|
|
16
15
|
// Adapted from XRegExp 1.5.0
|
|
@@ -18,184 +17,190 @@ module.exports = function xdiff_string_patch(originalStr, patch, flags, errorObj
|
|
|
18
17
|
// MIT License
|
|
19
18
|
// <https://xregexp.com>
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
const _getNativeFlags = function (regex) {
|
|
22
21
|
// Proposed for ES4; included in AS3
|
|
23
|
-
return [
|
|
24
|
-
|
|
22
|
+
return [
|
|
23
|
+
regex.global ? 'g' : '',
|
|
24
|
+
regex.ignoreCase ? 'i' : '',
|
|
25
|
+
regex.multiline ? 'm' : '',
|
|
26
|
+
regex.extended ? 'x' : '',
|
|
27
|
+
regex.sticky ? 'y' : '',
|
|
28
|
+
].join('')
|
|
29
|
+
}
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
const _cbSplit = function (string, sep) {
|
|
27
32
|
// If separator `s` is not a regex, use the native `split`
|
|
28
33
|
if (!(sep instanceof RegExp)) {
|
|
29
34
|
// Had problems to get it to work here using prototype test
|
|
30
|
-
return String.prototype.split.apply(string, arguments)
|
|
35
|
+
return String.prototype.split.apply(string, arguments)
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const str = String(string)
|
|
38
|
+
const output = []
|
|
39
|
+
let lastLastIndex = 0
|
|
40
|
+
let match
|
|
41
|
+
let lastLength
|
|
42
|
+
const limit = Infinity
|
|
43
|
+
const x = sep._xregexp
|
|
39
44
|
// This is required if not `s.global`, and it avoids needing to set `s.lastIndex` to zero
|
|
40
45
|
// and restore it to its original value when we're done using the regex
|
|
41
46
|
// Brett paring down
|
|
42
|
-
|
|
47
|
+
const s = new RegExp(sep.source, _getNativeFlags(sep) + 'g')
|
|
43
48
|
if (x) {
|
|
44
49
|
s._xregexp = {
|
|
45
50
|
source: x.source,
|
|
46
|
-
captureNames: x.captureNames ? x.captureNames.slice(0) : null
|
|
47
|
-
}
|
|
51
|
+
captureNames: x.captureNames ? x.captureNames.slice(0) : null,
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
while (match = s.exec(str)) {
|
|
55
|
+
while ((match = s.exec(str))) {
|
|
51
56
|
// Run the altered `exec` (required for `lastIndex` fix, etc.)
|
|
52
57
|
if (s.lastIndex > lastLastIndex) {
|
|
53
|
-
output.push(str.slice(lastLastIndex, match.index))
|
|
58
|
+
output.push(str.slice(lastLastIndex, match.index))
|
|
54
59
|
|
|
55
60
|
if (match.length > 1 && match.index < str.length) {
|
|
56
|
-
Array.prototype.push.apply(output, match.slice(1))
|
|
61
|
+
Array.prototype.push.apply(output, match.slice(1))
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
lastLength = match[0].length
|
|
60
|
-
lastLastIndex = s.lastIndex
|
|
64
|
+
lastLength = match[0].length
|
|
65
|
+
lastLastIndex = s.lastIndex
|
|
61
66
|
|
|
62
67
|
if (output.length >= limit) {
|
|
63
|
-
break
|
|
68
|
+
break
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
if (s.lastIndex === match.index) {
|
|
68
|
-
s.lastIndex
|
|
73
|
+
s.lastIndex++
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
if (lastLastIndex === str.length) {
|
|
73
78
|
if (!s.test('') || lastLength) {
|
|
74
|
-
output.push('')
|
|
79
|
+
output.push('')
|
|
75
80
|
}
|
|
76
81
|
} else {
|
|
77
|
-
output.push(str.slice(lastLastIndex))
|
|
82
|
+
output.push(str.slice(lastLastIndex))
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
return output.length > limit ? output.slice(0, limit) : output
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
return output.length > limit ? output.slice(0, limit) : output
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let i = 0
|
|
89
|
+
let ll = 0
|
|
90
|
+
let ranges = []
|
|
91
|
+
let lastLinePos = 0
|
|
92
|
+
let firstChar = ''
|
|
93
|
+
const rangeExp = /^@@\s+-(\d+),(\d+)\s+\+(\d+),(\d+)\s+@@$/
|
|
94
|
+
const lineBreaks = /\r?\n/
|
|
95
|
+
const lines = _cbSplit(patch.replace(/(\r?\n)+$/, ''), lineBreaks)
|
|
96
|
+
const origLines = _cbSplit(originalStr, lineBreaks)
|
|
97
|
+
const newStrArr = []
|
|
98
|
+
let linePos = 0
|
|
99
|
+
const errors = ''
|
|
100
|
+
let optTemp = 0 // Both string & integer (constant) input is allowed
|
|
101
|
+
const OPTS = {
|
|
97
102
|
// Unsure of actual PHP values, so better to rely on string
|
|
98
103
|
XDIFF_PATCH_NORMAL: 1,
|
|
99
104
|
XDIFF_PATCH_REVERSE: 2,
|
|
100
|
-
XDIFF_PATCH_IGNORESPACE: 4
|
|
105
|
+
XDIFF_PATCH_IGNORESPACE: 4,
|
|
106
|
+
}
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return false
|
|
108
|
+
// Input defaulting & sanitation
|
|
109
|
+
if (typeof originalStr !== 'string' || !patch) {
|
|
110
|
+
return false
|
|
105
111
|
}
|
|
106
112
|
if (!flags) {
|
|
107
|
-
flags = 'XDIFF_PATCH_NORMAL'
|
|
113
|
+
flags = 'XDIFF_PATCH_NORMAL'
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
if (typeof flags !== 'number') {
|
|
111
117
|
// Allow for a single string or an array of string flags
|
|
112
|
-
flags = [].concat(flags)
|
|
118
|
+
flags = [].concat(flags)
|
|
113
119
|
for (i = 0; i < flags.length; i++) {
|
|
114
120
|
// Resolve string input to bitwise e.g. 'XDIFF_PATCH_NORMAL' becomes 1
|
|
115
121
|
if (OPTS[flags[i]]) {
|
|
116
|
-
optTemp = optTemp | OPTS[flags[i]]
|
|
122
|
+
optTemp = optTemp | OPTS[flags[i]]
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
|
-
flags = optTemp
|
|
125
|
+
flags = optTemp
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
if (flags & OPTS.XDIFF_PATCH_NORMAL) {
|
|
123
129
|
for (i = 0, ll = lines.length; i < ll; i++) {
|
|
124
|
-
ranges = lines[i].match(rangeExp)
|
|
130
|
+
ranges = lines[i].match(rangeExp)
|
|
125
131
|
if (ranges) {
|
|
126
|
-
lastLinePos = linePos
|
|
127
|
-
linePos = ranges[1] - 1
|
|
132
|
+
lastLinePos = linePos
|
|
133
|
+
linePos = ranges[1] - 1
|
|
128
134
|
while (lastLinePos < linePos) {
|
|
129
|
-
newStrArr[newStrArr.length] = origLines[lastLinePos++]
|
|
135
|
+
newStrArr[newStrArr.length] = origLines[lastLinePos++]
|
|
130
136
|
}
|
|
131
137
|
while (lines[++i] && rangeExp.exec(lines[i]) === null) {
|
|
132
|
-
firstChar = lines[i].charAt(0)
|
|
138
|
+
firstChar = lines[i].charAt(0)
|
|
133
139
|
switch (firstChar) {
|
|
134
140
|
case '-':
|
|
135
141
|
// Skip including that line
|
|
136
|
-
++linePos
|
|
137
|
-
break
|
|
142
|
+
++linePos
|
|
143
|
+
break
|
|
138
144
|
case '+':
|
|
139
|
-
newStrArr[newStrArr.length] = lines[i].slice(1)
|
|
140
|
-
break
|
|
145
|
+
newStrArr[newStrArr.length] = lines[i].slice(1)
|
|
146
|
+
break
|
|
141
147
|
case ' ':
|
|
142
|
-
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
143
|
-
break
|
|
148
|
+
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
149
|
+
break
|
|
144
150
|
default:
|
|
145
151
|
// Reconcile with returning errrors arg?
|
|
146
|
-
throw new Error('Unrecognized initial character in unidiff line')
|
|
152
|
+
throw new Error('Unrecognized initial character in unidiff line')
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
if (lines[i]) {
|
|
150
|
-
i
|
|
156
|
+
i--
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
160
|
while (linePos > 0 && linePos < origLines.length) {
|
|
155
|
-
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
161
|
+
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
156
162
|
}
|
|
157
163
|
} else if (flags & OPTS.XDIFF_PATCH_REVERSE) {
|
|
158
164
|
// Only differs from above by a few lines
|
|
159
165
|
for (i = 0, ll = lines.length; i < ll; i++) {
|
|
160
|
-
ranges = lines[i].match(rangeExp)
|
|
166
|
+
ranges = lines[i].match(rangeExp)
|
|
161
167
|
if (ranges) {
|
|
162
|
-
lastLinePos = linePos
|
|
163
|
-
linePos = ranges[3] - 1
|
|
168
|
+
lastLinePos = linePos
|
|
169
|
+
linePos = ranges[3] - 1
|
|
164
170
|
while (lastLinePos < linePos) {
|
|
165
|
-
newStrArr[newStrArr.length] = origLines[lastLinePos++]
|
|
171
|
+
newStrArr[newStrArr.length] = origLines[lastLinePos++]
|
|
166
172
|
}
|
|
167
173
|
while (lines[++i] && rangeExp.exec(lines[i]) === null) {
|
|
168
|
-
firstChar = lines[i].charAt(0)
|
|
174
|
+
firstChar = lines[i].charAt(0)
|
|
169
175
|
switch (firstChar) {
|
|
170
176
|
case '-':
|
|
171
|
-
newStrArr[newStrArr.length] = lines[i].slice(1)
|
|
172
|
-
break
|
|
177
|
+
newStrArr[newStrArr.length] = lines[i].slice(1)
|
|
178
|
+
break
|
|
173
179
|
case '+':
|
|
174
180
|
// Skip including that line
|
|
175
|
-
++linePos
|
|
176
|
-
break
|
|
181
|
+
++linePos
|
|
182
|
+
break
|
|
177
183
|
case ' ':
|
|
178
|
-
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
179
|
-
break
|
|
184
|
+
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
185
|
+
break
|
|
180
186
|
default:
|
|
181
187
|
// Reconcile with returning errrors arg?
|
|
182
|
-
throw new Error('Unrecognized initial character in unidiff line')
|
|
188
|
+
throw new Error('Unrecognized initial character in unidiff line')
|
|
183
189
|
}
|
|
184
190
|
}
|
|
185
191
|
if (lines[i]) {
|
|
186
|
-
i
|
|
192
|
+
i--
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
195
|
}
|
|
190
196
|
while (linePos > 0 && linePos < origLines.length) {
|
|
191
|
-
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
197
|
+
newStrArr[newStrArr.length] = origLines[linePos++]
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
if (errorObj) {
|
|
196
|
-
errorObj.value = errors
|
|
202
|
+
errorObj.value = errors
|
|
197
203
|
}
|
|
198
204
|
|
|
199
|
-
return newStrArr.join('\n')
|
|
200
|
-
}
|
|
201
|
-
//# sourceMappingURL=xdiff_string_patch.js.map
|
|
205
|
+
return newStrArr.join('\n')
|
|
206
|
+
}
|
package/php/xml/index.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.utf8_decode = require('./utf8_decode');
|
|
4
|
-
module.exports.utf8_encode = require('./utf8_encode');
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
module.exports.utf8_decode = require('./utf8_decode')
|
|
2
|
+
module.exports.utf8_encode = require('./utf8_encode')
|
package/php/xml/utf8_decode.js
CHANGED
|
@@ -1,61 +1,59 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
module.exports = function utf8_decode(strData) {
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
// discuss at: https://locutus.io/php/utf8_decode/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Webtoolkit.info (https://www.webtoolkit.info/)
|
|
5
|
+
// input by: Aman Gupta
|
|
6
|
+
// input by: Brett Zamir (https://brett-zamir.me)
|
|
7
|
+
// improved by: Kevin van Zonneveld (https://kvz.io)
|
|
8
|
+
// improved by: Norman "zEh" Fuchs
|
|
9
|
+
// bugfixed by: hitwork
|
|
10
|
+
// bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
|
|
11
|
+
// bugfixed by: Kevin van Zonneveld (https://kvz.io)
|
|
12
|
+
// bugfixed by: kirilloid
|
|
13
|
+
// bugfixed by: w35l3y (https://www.wesley.eti.br)
|
|
14
|
+
// example 1: utf8_decode('Kevin van Zonneveld')
|
|
15
|
+
// returns 1: 'Kevin van Zonneveld'
|
|
16
|
+
|
|
17
|
+
const tmpArr = []
|
|
18
|
+
let i = 0
|
|
19
|
+
let c1 = 0
|
|
20
|
+
let seqlen = 0
|
|
21
|
+
|
|
22
|
+
strData += ''
|
|
24
23
|
|
|
25
24
|
while (i < strData.length) {
|
|
26
|
-
c1 = strData.charCodeAt(i) & 0xff
|
|
27
|
-
seqlen = 0
|
|
25
|
+
c1 = strData.charCodeAt(i) & 0xff
|
|
26
|
+
seqlen = 0
|
|
28
27
|
|
|
29
28
|
// https://en.wikipedia.org/wiki/UTF-8#Codepage_layout
|
|
30
29
|
if (c1 <= 0xbf) {
|
|
31
|
-
c1 = c1 & 0x7f
|
|
32
|
-
seqlen = 1
|
|
30
|
+
c1 = c1 & 0x7f
|
|
31
|
+
seqlen = 1
|
|
33
32
|
} else if (c1 <= 0xdf) {
|
|
34
|
-
c1 = c1 & 0x1f
|
|
35
|
-
seqlen = 2
|
|
33
|
+
c1 = c1 & 0x1f
|
|
34
|
+
seqlen = 2
|
|
36
35
|
} else if (c1 <= 0xef) {
|
|
37
|
-
c1 = c1 & 0x0f
|
|
38
|
-
seqlen = 3
|
|
36
|
+
c1 = c1 & 0x0f
|
|
37
|
+
seqlen = 3
|
|
39
38
|
} else {
|
|
40
|
-
c1 = c1 & 0x07
|
|
41
|
-
seqlen = 4
|
|
39
|
+
c1 = c1 & 0x07
|
|
40
|
+
seqlen = 4
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
for (
|
|
45
|
-
c1 = c1 << 0x06 | strData.charCodeAt(ai + i) & 0x3f
|
|
43
|
+
for (let ai = 1; ai < seqlen; ++ai) {
|
|
44
|
+
c1 = (c1 << 0x06) | (strData.charCodeAt(ai + i) & 0x3f)
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
if (seqlen === 4) {
|
|
49
|
-
c1 -= 0x10000
|
|
50
|
-
tmpArr.push(String.fromCharCode(0xd800 | c1 >> 10 & 0x3ff))
|
|
51
|
-
tmpArr.push(String.fromCharCode(0xdc00 | c1 & 0x3ff))
|
|
48
|
+
c1 -= 0x10000
|
|
49
|
+
tmpArr.push(String.fromCharCode(0xd800 | ((c1 >> 10) & 0x3ff)))
|
|
50
|
+
tmpArr.push(String.fromCharCode(0xdc00 | (c1 & 0x3ff)))
|
|
52
51
|
} else {
|
|
53
|
-
tmpArr.push(String.fromCharCode(c1))
|
|
52
|
+
tmpArr.push(String.fromCharCode(c1))
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
i += seqlen
|
|
55
|
+
i += seqlen
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
return tmpArr.join('')
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=utf8_decode.js.map
|
|
58
|
+
return tmpArr.join('')
|
|
59
|
+
}
|
package/php/xml/utf8_encode.js
CHANGED
|
@@ -1,69 +1,67 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
module.exports = function utf8_encode(argString) {
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
2
|
+
// discuss at: https://locutus.io/php/utf8_encode/
|
|
3
|
+
// parity verified: PHP 8.3
|
|
4
|
+
// original by: Webtoolkit.info (https://www.webtoolkit.info/)
|
|
5
|
+
// improved by: Kevin van Zonneveld (https://kvz.io)
|
|
6
|
+
// improved by: sowberry
|
|
7
|
+
// improved by: Jack
|
|
8
|
+
// improved by: Yves Sucaet
|
|
9
|
+
// improved by: kirilloid
|
|
10
|
+
// bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
|
|
11
|
+
// bugfixed by: Onno Marsman (https://twitter.com/onnomarsman)
|
|
12
|
+
// bugfixed by: Ulrich
|
|
13
|
+
// bugfixed by: Rafał Kukawski (https://blog.kukawski.pl)
|
|
14
|
+
// bugfixed by: kirilloid
|
|
15
|
+
// example 1: utf8_encode('Kevin van Zonneveld')
|
|
16
|
+
// returns 1: 'Kevin van Zonneveld'
|
|
18
17
|
|
|
19
18
|
if (argString === null || typeof argString === 'undefined') {
|
|
20
|
-
return ''
|
|
19
|
+
return ''
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
// .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const string = argString + ''
|
|
24
|
+
let utftext = ''
|
|
25
|
+
let start
|
|
26
|
+
let end
|
|
27
|
+
let stringl = 0
|
|
29
28
|
|
|
30
|
-
start = end = 0
|
|
31
|
-
stringl = string.length
|
|
32
|
-
for (
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
start = end = 0
|
|
30
|
+
stringl = string.length
|
|
31
|
+
for (let n = 0; n < stringl; n++) {
|
|
32
|
+
let c1 = string.charCodeAt(n)
|
|
33
|
+
let enc = null
|
|
35
34
|
|
|
36
35
|
if (c1 < 128) {
|
|
37
|
-
end
|
|
36
|
+
end++
|
|
38
37
|
} else if (c1 > 127 && c1 < 2048) {
|
|
39
|
-
enc = String.fromCharCode(c1 >> 6 | 192, c1 & 63 | 128)
|
|
38
|
+
enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128)
|
|
40
39
|
} else if ((c1 & 0xf800) !== 0xd800) {
|
|
41
|
-
enc = String.fromCharCode(c1 >> 12 | 224, c1 >> 6 & 63 | 128, c1 & 63 | 128)
|
|
40
|
+
enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128)
|
|
42
41
|
} else {
|
|
43
42
|
// surrogate pairs
|
|
44
43
|
if ((c1 & 0xfc00) !== 0xd800) {
|
|
45
|
-
throw new RangeError('Unmatched trail surrogate at ' + n)
|
|
44
|
+
throw new RangeError('Unmatched trail surrogate at ' + n)
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
const c2 = string.charCodeAt(++n)
|
|
48
47
|
if ((c2 & 0xfc00) !== 0xdc00) {
|
|
49
|
-
throw new RangeError('Unmatched lead surrogate at ' + (n - 1))
|
|
48
|
+
throw new RangeError('Unmatched lead surrogate at ' + (n - 1))
|
|
50
49
|
}
|
|
51
|
-
c1 = ((c1 & 0x3ff) << 10) + (c2 & 0x3ff) + 0x10000
|
|
52
|
-
enc = String.fromCharCode(c1 >> 18 | 240, c1 >> 12 & 63 | 128, c1 >> 6 & 63 | 128, c1 & 63 | 128)
|
|
50
|
+
c1 = ((c1 & 0x3ff) << 10) + (c2 & 0x3ff) + 0x10000
|
|
51
|
+
enc = String.fromCharCode((c1 >> 18) | 240, ((c1 >> 12) & 63) | 128, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128)
|
|
53
52
|
}
|
|
54
53
|
if (enc !== null) {
|
|
55
54
|
if (end > start) {
|
|
56
|
-
utftext += string.slice(start, end)
|
|
55
|
+
utftext += string.slice(start, end)
|
|
57
56
|
}
|
|
58
|
-
utftext += enc
|
|
59
|
-
start = end = n + 1
|
|
57
|
+
utftext += enc
|
|
58
|
+
start = end = n + 1
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
if (end > start) {
|
|
64
|
-
utftext += string.slice(start, stringl)
|
|
63
|
+
utftext += string.slice(start, stringl)
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
return utftext
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=utf8_encode.js.map
|
|
66
|
+
return utftext
|
|
67
|
+
}
|
package/python/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = function ceil(x) {
|
|
2
|
+
// discuss at: https://locutus.io/python/ceil/
|
|
3
|
+
// parity verified: Python 3.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Returns the smallest integer >= x
|
|
6
|
+
// note 2: JS Math.ceil(-0.5) returns -0, but Python returns 0
|
|
7
|
+
// example 1: ceil(4.2)
|
|
8
|
+
// returns 1: 5
|
|
9
|
+
// example 2: ceil(-0.5)
|
|
10
|
+
// returns 2: 0
|
|
11
|
+
// example 3: ceil(3)
|
|
12
|
+
// returns 3: 3
|
|
13
|
+
|
|
14
|
+
const result = Math.ceil(x)
|
|
15
|
+
// Convert -0 to 0 for Python compatibility
|
|
16
|
+
return Object.is(result, -0) ? 0 : result
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = function exp(x) {
|
|
2
|
+
// discuss at: https://locutus.io/python/exp/
|
|
3
|
+
// parity verified: Python 3.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Returns e raised to the power of x
|
|
6
|
+
// example 1: exp(0)
|
|
7
|
+
// returns 1: 1
|
|
8
|
+
// example 2: exp(1)
|
|
9
|
+
// returns 2: 2.718281828459045
|
|
10
|
+
|
|
11
|
+
return Math.exp(x)
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = function fabs(x) {
|
|
2
|
+
// discuss at: https://locutus.io/python/fabs/
|
|
3
|
+
// parity verified: Python 3.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Returns the absolute value of x as a float
|
|
6
|
+
// example 1: fabs(-5)
|
|
7
|
+
// returns 1: 5
|
|
8
|
+
// example 2: fabs(3.14)
|
|
9
|
+
// returns 2: 3.14
|
|
10
|
+
// example 3: fabs(-2.5)
|
|
11
|
+
// returns 3: 2.5
|
|
12
|
+
|
|
13
|
+
return Math.abs(x)
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module.exports = function factorial(n) {
|
|
2
|
+
// discuss at: https://locutus.io/python/factorial/
|
|
3
|
+
// parity verified: Python 3.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Returns n! (n factorial)
|
|
6
|
+
// example 1: factorial(5)
|
|
7
|
+
// returns 1: 120
|
|
8
|
+
// example 2: factorial(0)
|
|
9
|
+
// returns 2: 1
|
|
10
|
+
// example 3: factorial(1)
|
|
11
|
+
// returns 3: 1
|
|
12
|
+
|
|
13
|
+
n = parseInt(n, 10)
|
|
14
|
+
|
|
15
|
+
if (n < 0) {
|
|
16
|
+
throw new Error('factorial() not defined for negative values')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (n === 0 || n === 1) {
|
|
20
|
+
return 1
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let result = 1
|
|
24
|
+
for (let i = 2; i <= n; i++) {
|
|
25
|
+
result *= i
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = function floor(x) {
|
|
2
|
+
// discuss at: https://locutus.io/python/floor/
|
|
3
|
+
// parity verified: Python 3.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Returns the largest integer <= x
|
|
6
|
+
// example 1: floor(4.9)
|
|
7
|
+
// returns 1: 4
|
|
8
|
+
// example 2: floor(-0.5)
|
|
9
|
+
// returns 2: -1
|
|
10
|
+
// example 3: floor(3)
|
|
11
|
+
// returns 3: 3
|
|
12
|
+
|
|
13
|
+
return Math.floor(x)
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module.exports = function gcd(a, b) {
|
|
2
|
+
// discuss at: https://locutus.io/python/gcd/
|
|
3
|
+
// parity verified: Python 3.12
|
|
4
|
+
// original by: Kevin van Zonneveld (https://kvz.io)
|
|
5
|
+
// note 1: Returns the greatest common divisor of a and b
|
|
6
|
+
// example 1: gcd(48, 18)
|
|
7
|
+
// returns 1: 6
|
|
8
|
+
// example 2: gcd(0, 5)
|
|
9
|
+
// returns 2: 5
|
|
10
|
+
// example 3: gcd(7, 0)
|
|
11
|
+
// returns 3: 7
|
|
12
|
+
|
|
13
|
+
a = Math.abs(parseInt(a, 10))
|
|
14
|
+
b = Math.abs(parseInt(b, 10))
|
|
15
|
+
|
|
16
|
+
while (b !== 0) {
|
|
17
|
+
const temp = b
|
|
18
|
+
b = a % b
|
|
19
|
+
a = temp
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return a
|
|
23
|
+
}
|