UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

858 lines (648 loc) 15.1 kB
# Rosetta Stone Mappings # Maps semantically equivalent functions across languages. # When adding a new function, check if an equivalent exists and add it here. # Format: group_name -> list of "language/category/function" paths # # IMPORTANT: Keep this file updated when adding functions! # See CONTRIBUTING.md for details. # ============================================================================= # STRING OPERATIONS # ============================================================================= string_length: - php/strings/strlen - c/string/strlen - ruby/String/length - perl/core/length - powershell/string/length - tcl/string/length - rust/str/len - awk/builtin/length - lua/string/len - elixir/String/length - r/base/nchar string_lowercase: - php/strings/strtolower - ruby/String/downcase - golang/strings/ToLower - powershell/string/tolower - tcl/string/tolower - rust/str/to_lowercase - lua/string/lower - perl/core/lc - awk/builtin/tolower - r/base/tolower - julia/Base/lowercase - elixir/String/downcase - clojure/string/lower_case string_uppercase: - php/strings/strtoupper - ruby/String/upcase - golang/strings/ToUpper - powershell/string/toupper - tcl/string/toupper - rust/str/to_uppercase - lua/string/upper - perl/core/uc - awk/builtin/toupper - r/base/toupper - julia/Base/uppercase - elixir/String/upcase - clojure/string/upper_case string_trim: - php/strings/trim - ruby/String/strip - golang/strings/TrimSpace - golang/strings/Trim - powershell/string/trim - tcl/string/trim - rust/str/trim - clojure/string/trim string_ltrim: - php/strings/ltrim - powershell/string/trimstart - tcl/string/trimleft - rust/str/trim_start string_rtrim: - php/strings/rtrim - php/strings/chop - powershell/string/trimend - ruby/String/chop - ruby/String/chomp - tcl/string/trimright - perl/core/chop - rust/str/trim_end string_chomp: - perl/core/chomp string_contains: - powershell/string/contains - rust/str/contains - golang/strings/Contains - ruby/String/include string_starts_with: - powershell/string/startswith - rust/str/starts_with - golang/strings/HasPrefix - ruby/String/start_with string_ends_with: - powershell/string/endswith - rust/str/ends_with - golang/strings/HasSuffix - ruby/String/end_with string_reverse: - php/strings/strrev - ruby/String/reverse - tcl/string/reverse - lua/string/reverse - perl/core/reverse - elixir/String/reverse - clojure/string/reverse string_split: - php/strings/explode - golang/strings/Split - swift/String/split string_split_n: - golang/strings/SplitN - rust/str/splitn string_rsplit_n: - rust/str/rsplitn string_split_once: - rust/str/split_once string_rsplit_once: - rust/str/rsplit_once string_split_terminator: - rust/str/split_terminator string_rsplit_terminator: - rust/str/rsplit_terminator string_strip_prefix: - rust/str/strip_prefix - ruby/String/delete_prefix string_strip_suffix: - rust/str/strip_suffix - ruby/String/delete_suffix string_lines: - rust/str/lines string_join: - php/strings/implode - golang/strings/Join path_join: - golang/path/Join - golang/filepath/Join string_replace: - php/strings/str_replace - powershell/string/replace - rust/str/replace - golang/strings/Replace - swift/String/replacingOccurrences - elixir/String/replace regex_replace: - php/pcre/preg_replace - ruby/String/gsub - python/re/sub regex_replace_with_count: - python/re/subn collection_group_by: - ruby/Array/group_by - kotlin/collections/groupBy array_binary_search: - ruby/Array/bsearch array_binary_search_index: - ruby/Array/bsearch_index array_bisect_left: - python/bisect/bisect_left array_bisect_right: - python/bisect/bisect - python/bisect/bisect_right array_filter_map: - ruby/Array/filter_map array_first_key: - php/array/array_key_first array_last_key: - php/array/array_key_last array_is_list: - php/array/array_is_list path_relative: - golang/filepath/Rel path_clean: - golang/path/Clean - golang/filepath/Clean path_base: - golang/path/Base - golang/filepath/Base path_dir: - golang/path/Dir - golang/filepath/Dir path_ext: - golang/path/Ext - golang/filepath/Ext path_is_abs: - golang/path/IsAbs - golang/filepath/IsAbs calendar_is_leap_year: - python/calendar/isleap calendar_leapdays: - python/calendar/leapdays calendar_month_range: - python/calendar/monthrange calendar_weekday: - python/calendar/weekday calendar_week_header: - python/calendar/weekheader calendar_month_matrix: - python/calendar/monthcalendar calendar_timegm: - python/calendar/timegm calendar_format_week: - python/calendar/week calendar_format_month: - python/calendar/month calendar_format_year: - python/calendar/calendar calendar_format_string: - python/calendar/formatstring iterable_accumulate: - python/itertools/accumulate iterable_batch: - python/itertools/batched iterable_chain: - python/itertools/chain iterable_combinations: - python/itertools/combinations iterable_combinations_with_replacement: - python/itertools/combinations_with_replacement iterable_compress: - python/itertools/compress iterable_slice: - python/itertools/islice iterable_pairwise: - python/itertools/pairwise iterable_product: - python/itertools/product iterable_zip_longest: - python/itertools/zip_longest integer_square_root: - python/math/isqrt numeric_product: - php/array/array_product statistics_mean: - python/statistics/mean statistics_fmean: - python/statistics/fmean - r/stats/weighted_mean statistics_median: - python/statistics/median - r/stats/median statistics_median_low: - python/statistics/median_low statistics_median_high: - python/statistics/median_high statistics_mode: - python/statistics/mode statistics_multimode: - python/statistics/multimode statistics_population_standard_deviation: - python/statistics/pstdev statistics_sample_standard_deviation: - python/statistics/stdev - r/stats/sd statistics_population_variance: - python/statistics/pvariance statistics_sample_variance: - python/statistics/variance - r/stats/variance statistics_geometric_mean: - python/statistics/geometric_mean statistics_harmonic_mean: - python/statistics/harmonic_mean statistics_linear_regression: - python/statistics/linear_regression statistics_grouped_median: - python/statistics/median_grouped statistics_quantiles: - python/statistics/quantiles - r/stats/quantile statistics_five_number_summary: - r/stats/fivenum statistics_median_absolute_deviation: - r/stats/mad statistics_covariance: - python/statistics/covariance - r/stats/cov statistics_correlation: - python/statistics/correlation - r/stats/cor - python/math/prod sequence_partition_by: - clojure/core/partition_by sequence_interpose: - clojure/core/interpose enumerable_reduce_while: - elixir/Enum/reduce_while enumerable_reduce: - python/functools/reduce enumerable_zip: - ruby/Array/zip - elixir/Enum/zip lua_string_replace_with_count: - lua/string/gsub string_equal: - tcl/string/equal numeric_sign: - r/base/sign numeric_type: - lua/math/type list_permutations: - python/itertools/permutations - ruby/Array/permutation - haskell/list/permutations matrix_transpose: - haskell/list/transpose string_index: - php/strings/strpos - powershell/string/indexof - rust/str/find - golang/strings/Index - golang/strings/Index2 - tcl/string/first string_last_index: - php/strings/strrpos - powershell/string/lastindexof - rust/str/rfind - golang/strings/LastIndex - tcl/string/last string_repeat: - php/strings/str_repeat - golang/strings/Repeat - tcl/string/repeat - lua/string/rep string_capitalize: - php/strings/ucfirst - ruby/String/capitalize - perl/core/ucfirst string_uncapitalize: - php/strings/lcfirst - perl/core/lcfirst string_compare: - php/strings/strcmp - c/string/strcmp - golang/strings/Compare string_substring_search: - php/strings/strstr - c/string/strstr string_char_search: - php/strings/strchr - c/string/strchr string_count: - php/strings/substr_count - golang/strings/Count string_close_matches: - python/difflib/get_close_matches string_diff: - python/difflib/ndiff string_substring: - php/strings/substr - awk/builtin/substr - lua/string/sub - perl/core/substr # ============================================================================= # MATH OPERATIONS # ============================================================================= math_frexp: - c/math/frexp math_sqrt: - php/math/sqrt - python/math/sqrt - ruby/Math/sqrt - lua/math/sqrt - awk/builtin/sqrt - r/base/sqrt math_exp: - php/math/exp - python/math/exp - ruby/Math/exp - awk/builtin/exp math_log: - php/math/log - python/math/log - ruby/Math/log - awk/builtin/log math_log10: - php/math/log10 - python/math/log10 - ruby/Math/log10 math_log2: - python/math/log2 - ruby/Math/log2 math_sin: - php/math/sin - python/math/sin - ruby/Math/sin - lua/math/sin - awk/builtin/sin math_cos: - php/math/cos - python/math/cos - ruby/Math/cos - lua/math/cos - awk/builtin/cos math_tan: - php/math/tan - python/math/tan - ruby/Math/tan math_asin: - php/math/asin - python/math/asin - ruby/Math/asin math_acos: - php/math/acos - python/math/acos - ruby/Math/acos math_atan: - php/math/atan - python/math/atan - ruby/Math/atan math_atan2: - php/math/atan2 - python/math/atan2 - ruby/Math/atan2 math_acosh: - php/math/acosh - python/math/acosh math_asinh: - php/math/asinh - python/math/asinh math_atanh: - php/math/atanh - python/math/atanh math_sinh: - php/math/sinh - python/math/sinh - ruby/Math/sinh math_cosh: - php/math/cosh - python/math/cosh - ruby/Math/cosh math_tanh: - php/math/tanh - python/math/tanh - ruby/Math/tanh math_degrees: - python/math/degrees math_radians: - python/math/radians math_hypot: - php/math/hypot - python/math/hypot - ruby/Math/hypot math_expm1: - php/math/expm1 - python/math/expm1 math_copysign: - python/math/copysign math_ceil: - php/math/ceil - python/math/ceil - perl/POSIX/ceil - lua/math/ceil - r/base/ceiling - julia/Base/ceil - elixir/Float/ceil - clojure/Math/ceil math_floor: - php/math/floor - python/math/floor - perl/POSIX/floor - lua/math/floor - r/base/floor - julia/Base/floor - elixir/Float/floor - clojure/Math/floor math_abs: - php/math/abs - c/math/abs - lua/math/abs - r/base/abs - julia/Base/abs - elixir/Kernel/abs - clojure/Math/abs - perl/core/abs math_max: - php/math/max - lua/math/max - r/base/max math_min: - php/math/min - lua/math/min - r/base/min math_round: - php/math/round - r/base/round math_fabs: - python/math/fabs math_pow: - php/math/pow - python/math/pow - python/operator/pow math_cbrt: - ruby/Math/cbrt math_trunc: - python/math/trunc - awk/builtin/int - perl/core/int math_factorial: - python/math/factorial math_gcd: - python/math/gcd math_isfinite: - php/math/is_finite - python/math/isfinite math_isinf: - php/math/is_infinite - python/math/isinf math_isnan: - php/math/is_nan - python/math/isnan # ============================================================================= # CHARACTER TYPE CHECKING # ============================================================================= char_isalnum: - php/ctype/ctype_alnum - c/ctype/isalnum char_isalpha: - php/ctype/ctype_alpha - c/ctype/isalpha char_isdigit: - php/ctype/ctype_digit - c/ctype/isdigit char_islower: - php/ctype/ctype_lower - c/ctype/islower char_isupper: - php/ctype/ctype_upper - c/ctype/isupper char_isspace: - php/ctype/ctype_space - c/ctype/isspace char_tolower: - c/ctype/tolower char_toupper: - c/ctype/toupper char_from_codepoint: - php/strings/chr - perl/core/chr char_to_codepoint: - php/strings/ord - perl/core/ord # ============================================================================= # TYPE CONVERSION # ============================================================================= string_to_int: - php/var/intval - c/stdlib/atoi - golang/strconv/Atoi int_to_string: - golang/strconv/Itoa string_to_float: - c/stdlib/atof parse_int: - golang/strconv/ParseInt format_int: - golang/strconv/FormatInt parse_bool: - golang/strconv/ParseBool format_bool: - golang/strconv/FormatBool string_regex_escape: - php/strings/quotemeta - perl/core/quotemeta # ============================================================================= # OPERATORS # ============================================================================= arithmetic_add: - python/operator/add arithmetic_subtract: - python/operator/sub arithmetic_multiply: - python/operator/mul arithmetic_true_divide: - python/operator/truediv arithmetic_floor_divide: - python/operator/floordiv arithmetic_modulo: - python/operator/mod sequence_concat: - python/operator/concat collection_contains: - python/operator/contains collection_count_of: - python/operator/countOf collection_index_of: - python/operator/indexOf collection_getitem: - python/operator/getitem comparison_equal: - python/operator/eq comparison_not_equal: - python/operator/ne comparison_greater_than: - python/operator/gt comparison_greater_equal: - python/operator/ge comparison_less_than: - python/operator/lt comparison_less_equal: - python/operator/le identity_is: - python/operator/is_ identity_is_not: - python/operator/is_not bitwise_and: - python/operator/and_ bitwise_or: - python/operator/or_ bitwise_xor: - python/operator/xor bitwise_not: - python/operator/inv - python/operator/invert bitwise_left_shift: - python/operator/lshift bitwise_right_shift: - python/operator/rshift unary_positive: - python/operator/pos unary_negative: - python/operator/neg truthiness: - python/operator/truth - python/operator/not_ # ============================================================================= # ARRAY/COLLECTION OPERATIONS # ============================================================================= array_first: - php/array/reset - ruby/Array/first array_last: - php/array/end - ruby/Array/last array_unique: - php/array/array_unique - ruby/Array/uniq array_flatten: - ruby/Array/flatten array_compact: - ruby/Array/compact array_sample: - ruby/Array/sample binary_unpack: - php/misc/unpack # ============================================================================= # FORMATTING # ============================================================================= sprintf: - php/strings/sprintf - c/stdio/sprintf date_format: - php/datetime/date - golang/time/Format date_parse_in_location: - golang/time/ParseInLocation