locutus 2.0.32 → 2.0.34
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 +3 -0
- package/awk/builtin/int.js +13 -0
- package/awk/builtin/length.js +16 -0
- package/awk/builtin/substr.js +23 -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/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
package/_util/util.js
DELETED
|
@@ -1,620 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
-
|
|
5
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
|
|
7
|
-
var globby = require('globby');
|
|
8
|
-
var path = require('path');
|
|
9
|
-
var fs = require('fs');
|
|
10
|
-
var fsPromises = fs.promises;
|
|
11
|
-
var async = require('async');
|
|
12
|
-
var YAML = require('js-yaml');
|
|
13
|
-
var debug = require('debug')('locutus:utils');
|
|
14
|
-
var indentString = require('indent-string');
|
|
15
|
-
var _ = require('lodash');
|
|
16
|
-
var esprima = require('esprima');
|
|
17
|
-
|
|
18
|
-
var Util = function () {
|
|
19
|
-
function Util(argv) {
|
|
20
|
-
_classCallCheck(this, Util);
|
|
21
|
-
|
|
22
|
-
if (!argv) {
|
|
23
|
-
argv = [];
|
|
24
|
-
}
|
|
25
|
-
this.__src = path.dirname(__dirname);
|
|
26
|
-
this.__root = path.dirname(path.dirname(__dirname));
|
|
27
|
-
this.__test = path.dirname(path.dirname(__dirname)) + '/test';
|
|
28
|
-
|
|
29
|
-
this.globals = {};
|
|
30
|
-
|
|
31
|
-
this.pattern = [this.__src + '/**/**/*.js', '!**/index.js', '!**/_util/**'];
|
|
32
|
-
this.concurrency = 8;
|
|
33
|
-
this.authorKeys = ['original by', 'improved by', 'reimplemented by', 'parts by', 'bugfixed by', 'revised by', 'input by'];
|
|
34
|
-
|
|
35
|
-
this.langDefaults = {
|
|
36
|
-
c: {
|
|
37
|
-
order: 1,
|
|
38
|
-
function_title_template: "[language]'s [category].[function] in JavaScript",
|
|
39
|
-
human: 'C',
|
|
40
|
-
packageType: 'header file',
|
|
41
|
-
inspiration_urls: ['<a href="https://en.cppreference.com/w/c/numeric/math">the C math.h documentation</a>', '<a href="https://sourceware.org/git/?p=glibc.git;a=tree;f=math;hb=HEAD">the C math.h source</a>'],
|
|
42
|
-
function_description_template: 'Here’s what our current JavaScript equivalent to <a href="https://en.cppreference.com/w/c/numeric/[category]/[function]">[language]\'s [function] found in the [category].h header file</a> looks like.'
|
|
43
|
-
},
|
|
44
|
-
golang: {
|
|
45
|
-
order: 2,
|
|
46
|
-
function_title_template: "[language]'s [category].[function] in JavaScript",
|
|
47
|
-
human: 'Go',
|
|
48
|
-
packageType: 'package',
|
|
49
|
-
inspiration_urls: ['<a href="https://golang.org/pkg/strings/">Go strings documentation</a>', '<a href="https://golang.org/src/strings/strings.go">Go strings source</a>', '<a href="https://golang.org/src/strings/example_test.go">Go strings examples source</a>', '<a href="https://gophersjs.com">GopherJS</a>'],
|
|
50
|
-
function_description_template: 'Here’s what our current JavaScript equivalent to <a href="https://golang.org/pkg/[category]/#[function]">[language]\'s [category].[function]</a> looks like.'
|
|
51
|
-
},
|
|
52
|
-
python: {
|
|
53
|
-
order: 3,
|
|
54
|
-
function_title_template: "[language]'s [category].[function] in JavaScript",
|
|
55
|
-
human: 'Python',
|
|
56
|
-
packageType: 'module',
|
|
57
|
-
inspiration_urls: ['<a href="https://docs.python.org/3/library/string.html">the Python 3 standard library string page</a>'],
|
|
58
|
-
function_description_template: 'Here’s what our current JavaScript equivalent to <a href="https://docs.python.org/3/library/[category].html#[category].[function]">[language]\'s [category].[function]</a> looks like.'
|
|
59
|
-
},
|
|
60
|
-
ruby: {
|
|
61
|
-
order: 4,
|
|
62
|
-
function_title_template: "[language]'s [category].[function] in JavaScript",
|
|
63
|
-
human: 'Ruby',
|
|
64
|
-
packageType: 'module',
|
|
65
|
-
inspiration_urls: ['<a href="https://ruby-doc.org/core-2.2.2/Math.html">the Ruby core documentation</a>'],
|
|
66
|
-
function_description_template: 'Here’s what our current JavaScript equivalent to <a href="https://ruby-doc.org/core-2.2.2/[category].html#method-c-[function]">[language]\'s [category].[function]</a> looks like.'
|
|
67
|
-
},
|
|
68
|
-
php: {
|
|
69
|
-
order: 5,
|
|
70
|
-
function_title_template: "[language]'s [function] in JavaScript",
|
|
71
|
-
human: 'PHP',
|
|
72
|
-
packageType: 'extension',
|
|
73
|
-
inspiration_urls: ['<a href="https://php.net/manual/en/book.strings.php">the PHP string documentation</a>', '<a href="https://github.com/php/php-src/blob/master/ext/standard/string.c#L5338">the PHP string source</a>', '<a href="https://github.com/php/php-src/blob/master/ext/standard/tests/strings/str_pad_variation1.phpt">a PHP str_pad test</a>'],
|
|
74
|
-
function_description_template: 'Here’s what our current JavaScript equivalent to <a href="https://php.net/manual/en/function.[functiondashed].php">[language]\'s [function]</a> looks like.',
|
|
75
|
-
alias: ['/categories/', '/categories/array/', '/categories/bc/', '/categories/ctype/', '/categories/datetime/', '/categories/exec/', '/categories/filesystem/', '/categories/funchand/', '/categories/i18n/', '/categories/index/', '/categories/info/', '/categories/json/', '/categories/math/', '/categories/misc/', '/categories/net/', '/categories/network/', '/categories/pcre/', '/categories/strings/', '/categories/url/', '/categories/var/', '/categories/xdiff/', '/categories/xml/', '/functions/index/', '/functions/', '/packages/', '/packages/index/']
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
this.allowSkip = argv.indexOf('--noskip') === -1;
|
|
80
|
-
|
|
81
|
-
this._reindexBuffer = {};
|
|
82
|
-
this._injectwebBuffer = {};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
_createClass(Util, [{
|
|
86
|
-
key: 'injectweb',
|
|
87
|
-
value: function injectweb(cb) {
|
|
88
|
-
var self = this;
|
|
89
|
-
this._runFunctionOnAll(this._injectwebOne, function (err) {
|
|
90
|
-
if (err) {
|
|
91
|
-
return cb(err);
|
|
92
|
-
}
|
|
93
|
-
for (var indexHtml in self._injectwebBuffer) {
|
|
94
|
-
debug('writing: ' + indexHtml);
|
|
95
|
-
fs.writeFileSync(indexHtml, self._injectwebBuffer[indexHtml], 'utf-8');
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: 'reindex',
|
|
101
|
-
value: function reindex(cb) {
|
|
102
|
-
var self = this;
|
|
103
|
-
self._reindexBuffer = {};
|
|
104
|
-
self._runFunctionOnAll(self._reindexOne, function (err) {
|
|
105
|
-
if (err) {
|
|
106
|
-
return cb(err);
|
|
107
|
-
}
|
|
108
|
-
for (var indexJs in self._reindexBuffer) {
|
|
109
|
-
var requires = self._reindexBuffer[indexJs];
|
|
110
|
-
requires.sort();
|
|
111
|
-
debug('writing: ' + indexJs);
|
|
112
|
-
fs.writeFileSync(indexJs, requires.join('\n') + '\n', 'utf-8');
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
key: 'writetests',
|
|
118
|
-
value: function writetests(cb) {
|
|
119
|
-
this._runFunctionOnAll(this._writetestOne, cb);
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: '_runFunctionOnAll',
|
|
123
|
-
value: function _runFunctionOnAll(runFunc, cb) {
|
|
124
|
-
var self = this;
|
|
125
|
-
|
|
126
|
-
var q = async.queue(function (fullpath, callback) {
|
|
127
|
-
self._load.bind(self, fullpath, {}, function (err, params) {
|
|
128
|
-
if (err) {
|
|
129
|
-
return callback(err);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
runFunc.bind(self, params, callback)();
|
|
133
|
-
})();
|
|
134
|
-
}, self.concurrency);
|
|
135
|
-
|
|
136
|
-
debug({
|
|
137
|
-
pattern: self.pattern
|
|
138
|
-
});
|
|
139
|
-
var files = globby.sync(self.pattern);
|
|
140
|
-
|
|
141
|
-
q.push(files);
|
|
142
|
-
|
|
143
|
-
q.drain = cb;
|
|
144
|
-
}
|
|
145
|
-
}, {
|
|
146
|
-
key: '_reindexOne',
|
|
147
|
-
value: function _reindexOne(params, cb) {
|
|
148
|
-
var fullpath = this.__src + '/' + params.filepath;
|
|
149
|
-
var dir = path.dirname(fullpath);
|
|
150
|
-
var basefile = path.basename(fullpath, '.js');
|
|
151
|
-
var indexJs = dir + '/index.js';
|
|
152
|
-
|
|
153
|
-
var module = basefile;
|
|
154
|
-
if (basefile === 'Index2') {
|
|
155
|
-
module = 'Index';
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!this._reindexBuffer[indexJs]) {
|
|
159
|
-
this._reindexBuffer[indexJs] = [];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
var line = 'module.exports.' + module + " = require('./" + basefile + "')";
|
|
163
|
-
this._reindexBuffer[indexJs].push(line);
|
|
164
|
-
return cb(null);
|
|
165
|
-
}
|
|
166
|
-
}, {
|
|
167
|
-
key: '_injectwebOne',
|
|
168
|
-
value: function _injectwebOne(params, cb) {
|
|
169
|
-
var authors = {};
|
|
170
|
-
this.authorKeys.forEach(function (key) {
|
|
171
|
-
if (params.headKeys[key]) {
|
|
172
|
-
authors[key] = _.flattenDeep(params.headKeys[key]);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
var langPath = [this.__root, '/website/source/', params.language].join('');
|
|
177
|
-
|
|
178
|
-
var langIndexPath = langPath + '/index.html';
|
|
179
|
-
var catPath = langPath + '/' + params.category;
|
|
180
|
-
var catIndexPath = catPath + '/' + 'index.html';
|
|
181
|
-
var funcPath = catPath + '/' + params.func_name + '.html';
|
|
182
|
-
|
|
183
|
-
if (!this._injectwebBuffer[langIndexPath]) {
|
|
184
|
-
var langTitle = '';
|
|
185
|
-
langTitle += this.langDefaults[params.language].human + ' ';
|
|
186
|
-
langTitle += this.langDefaults[params.language].packageType + 's ';
|
|
187
|
-
langTitle += ' in JavaScript';
|
|
188
|
-
|
|
189
|
-
var langData = Object.assign({}, this.langDefaults[params.language], {
|
|
190
|
-
warning: 'This file is auto generated by `yarn web:inject`, do not edit by hand',
|
|
191
|
-
type: 'language',
|
|
192
|
-
layout: 'language',
|
|
193
|
-
language: params.language,
|
|
194
|
-
title: langTitle
|
|
195
|
-
});
|
|
196
|
-
this._injectwebBuffer[langIndexPath] = '---' + '\n' + YAML.dump(langData).trim() + '\n' + '---' + '\n';
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (!this._injectwebBuffer[catIndexPath]) {
|
|
200
|
-
var catTitle = '';
|
|
201
|
-
catTitle += this.langDefaults[params.language].human + "'s ";
|
|
202
|
-
catTitle += params.category + ' ';
|
|
203
|
-
catTitle += this.langDefaults[params.language].packageType + ' ';
|
|
204
|
-
catTitle += ' in JavaScript';
|
|
205
|
-
|
|
206
|
-
var catData = {
|
|
207
|
-
warning: 'This file is auto generated by `yarn web:inject`, do not edit by hand',
|
|
208
|
-
type: 'category',
|
|
209
|
-
layout: 'category',
|
|
210
|
-
language: params.language,
|
|
211
|
-
category: params.category,
|
|
212
|
-
title: catTitle
|
|
213
|
-
};
|
|
214
|
-
this._injectwebBuffer[catIndexPath] = '---' + '\n' + YAML.dump(catData).trim() + '\n' + '---' + '\n';
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
var functionTitle = this.langDefaults[params.language].function_title_template.replace(/\[language]/g, this.langDefaults[params.language].human).replace(/\[category]/g, params.category).replace(/\[function]/g, params.func_name).replace(/\[functiondashed]/g, params.func_name.replace(/_/g, '-'));
|
|
218
|
-
|
|
219
|
-
var functionDescription = this.langDefaults[params.language].function_description_template.replace(/\[language]/g, this.langDefaults[params.language].human).replace(/\[category]/g, params.category).replace(/\[function]/g, params.func_name).replace(/\[functiondashed]/g, params.func_name.replace(/_/g, '-'));
|
|
220
|
-
|
|
221
|
-
var funcData = {
|
|
222
|
-
warning: 'This file is auto generated by `yarn web:inject`, do not edit by hand',
|
|
223
|
-
examples: (params.headKeys.example || []).map(function (lines, i) {
|
|
224
|
-
return lines.join('\n');
|
|
225
|
-
}),
|
|
226
|
-
returns: (params.headKeys.returns || []).map(function (lines, i) {
|
|
227
|
-
return lines.join('\n');
|
|
228
|
-
}),
|
|
229
|
-
dependencies: [],
|
|
230
|
-
authors: authors || {},
|
|
231
|
-
notes: (params.headKeys.note || []).map(function (lines, i) {
|
|
232
|
-
return lines.join('\n');
|
|
233
|
-
}),
|
|
234
|
-
type: 'function',
|
|
235
|
-
layout: 'function',
|
|
236
|
-
title: functionTitle,
|
|
237
|
-
description: functionDescription,
|
|
238
|
-
function: params.func_name,
|
|
239
|
-
category: params.category,
|
|
240
|
-
language: params.language,
|
|
241
|
-
permalink: params.language + '/' + params.category + '/' + params.func_name + '/',
|
|
242
|
-
alias: ['/functions/' + params.language + '/' + params.func_name + '/', '/functions/' + params.category + '/' + params.func_name + '/', '/' + params.language + '/' + params.func_name + '/']
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
if (params.language === 'php') {
|
|
246
|
-
funcData.alias.push('/functions/' + params.func_name + '/');
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
var buf = '---' + '\n' + YAML.dump(funcData).trim() + '\n' + '---' + '\n';
|
|
250
|
-
|
|
251
|
-
buf += '{% codeblock lang:javascript %}' + params.code + '{% endcodeblock %}';
|
|
252
|
-
|
|
253
|
-
fsPromises.mkdir(path.dirname(funcPath), { recursive: true }).then(function () {
|
|
254
|
-
fs.writeFile(funcPath, buf, 'utf-8', cb);
|
|
255
|
-
}, function (err) {
|
|
256
|
-
throw new Error('Could not mkdir for ' + funcPath + '. ' + err);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
}, {
|
|
260
|
-
key: '_addRequire',
|
|
261
|
-
value: function _addRequire(name, relativeSrcForTest) {
|
|
262
|
-
return ['var ', name, " = require('", relativeSrcForTest, "') // eslint-disable-line no-unused-vars,camelcase"].join('');
|
|
263
|
-
}
|
|
264
|
-
}, {
|
|
265
|
-
key: '_writetestOne',
|
|
266
|
-
value: function _writetestOne(params, cb) {
|
|
267
|
-
var self = this;
|
|
268
|
-
|
|
269
|
-
if (!params.func_name) {
|
|
270
|
-
throw new Error('No func_name in ' + JSON.stringify(params));
|
|
271
|
-
}
|
|
272
|
-
if (!params.headKeys) {
|
|
273
|
-
throw new Error('No headKeys in ' + params.func_name);
|
|
274
|
-
}
|
|
275
|
-
if (!params.headKeys.example) {
|
|
276
|
-
throw new Error('No example in ' + params.func_name);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
var basename = path.basename(params.filepath);
|
|
280
|
-
var subdir = path.dirname(params.filepath);
|
|
281
|
-
var testpath = this.__test + '/generated/' + subdir + '/test-' + basename;
|
|
282
|
-
var testdir = path.dirname(testpath);
|
|
283
|
-
var relativeSrcForTestDir = path.relative(testdir, self.__src);
|
|
284
|
-
var relativeTestFileForRoot = path.relative(self.__root, testpath);
|
|
285
|
-
|
|
286
|
-
// console.log(relativeSrcForTestDir)
|
|
287
|
-
// process.exit(1)
|
|
288
|
-
|
|
289
|
-
var testProps = '';
|
|
290
|
-
if (params.headKeys.test) {
|
|
291
|
-
testProps = params.headKeys.test[0][0];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
var describeSkip = '';
|
|
295
|
-
if (self.allowSkip && testProps.indexOf('skip-all') !== -1) {
|
|
296
|
-
describeSkip = '.skip';
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
var codez = [];
|
|
300
|
-
|
|
301
|
-
codez.push('// warning: This file is auto generated by `yarn build:tests`');
|
|
302
|
-
codez.push('// Do not edit by hand!');
|
|
303
|
-
codez.push('');
|
|
304
|
-
codez.push('\'use strict\'');
|
|
305
|
-
codez.push('');
|
|
306
|
-
|
|
307
|
-
// Add globals
|
|
308
|
-
for (var global in self.globals) {
|
|
309
|
-
codez.push('var ' + global + ' = ' + self.globals[global]);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Set timezone for testing dates
|
|
313
|
-
// Not ideal: https://stackoverflow.com/questions/8083410/how-to-set-default-timezone-in-node-js
|
|
314
|
-
codez.push("process.env.TZ = 'UTC'");
|
|
315
|
-
|
|
316
|
-
codez.push('var ' + 'expect' + " = require('chai').expect");
|
|
317
|
-
|
|
318
|
-
// Add language-wide dependencies
|
|
319
|
-
// @todo: It would be great if we could remove this
|
|
320
|
-
if (params.language === 'php') {
|
|
321
|
-
codez.push(self._addRequire('ini_set', relativeSrcForTestDir + '/' + 'php/info/ini_set'));
|
|
322
|
-
codez.push(self._addRequire('ini_get', relativeSrcForTestDir + '/' + 'php/info/ini_get'));
|
|
323
|
-
if (params.func_name === 'localeconv') {
|
|
324
|
-
codez.push(self._addRequire('setlocale', relativeSrcForTestDir + '/' + 'php/strings/setlocale'));
|
|
325
|
-
}
|
|
326
|
-
if (params.func_name === 'i18n_loc_get_default') {
|
|
327
|
-
codez.push(self._addRequire('i18n_loc_set_default', relativeSrcForTestDir + '/' + 'php/i18n/i18n_loc_set_default'));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// Add the main function to test
|
|
332
|
-
codez.push(self._addRequire(params.func_name, relativeSrcForTestDir + '/' + params.filepath));
|
|
333
|
-
|
|
334
|
-
codez.push('');
|
|
335
|
-
|
|
336
|
-
codez.push(['describe', describeSkip, "('src/", params.filepath, ' (tested in ', relativeTestFileForRoot, ")', function () {"].join(''));
|
|
337
|
-
|
|
338
|
-
// Run each example
|
|
339
|
-
for (var i in params.headKeys.example) {
|
|
340
|
-
if (!params.headKeys.returns[i] || !params.headKeys.returns[i].length) {
|
|
341
|
-
throw new Error('There is no return for example ' + i, test, params);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
var humanIndex = parseInt(i, 10) + 1;
|
|
345
|
-
var itSkip = '';
|
|
346
|
-
if (self.allowSkip && testProps.indexOf('skip-' + humanIndex) !== -1) {
|
|
347
|
-
itSkip = '.skip';
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
codez.push([' it', itSkip, "('should pass example ", humanIndex, "', function (done) {"].join(''));
|
|
351
|
-
|
|
352
|
-
var body = [];
|
|
353
|
-
|
|
354
|
-
var testExpected = params.headKeys.returns[i].join('\n');
|
|
355
|
-
|
|
356
|
-
body.push('var expected = ' + testExpected);
|
|
357
|
-
|
|
358
|
-
// Execute line by line (see date.js why)
|
|
359
|
-
// We need result be the last result of the example code
|
|
360
|
-
for (var j in params.headKeys.example[i]) {
|
|
361
|
-
if (parseInt(j, 10) === params.headKeys.example[i].length - 1) {
|
|
362
|
-
// last action gets saved
|
|
363
|
-
body.push('var result = ' + params.headKeys.example[i][j].replace('var $result = ', ''));
|
|
364
|
-
} else {
|
|
365
|
-
body.push(params.headKeys.example[i][j]);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
body.push('expect(result).to.deep.equal(expected)');
|
|
370
|
-
body.push('done()');
|
|
371
|
-
|
|
372
|
-
codez.push(indentString(body.join('\n'), ' ', 4));
|
|
373
|
-
|
|
374
|
-
codez.push(' })');
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
codez.push('})');
|
|
378
|
-
codez.push('');
|
|
379
|
-
|
|
380
|
-
var code = codez.join('\n');
|
|
381
|
-
|
|
382
|
-
// Write to disk
|
|
383
|
-
fsPromises.mkdir(testdir, { recursive: true }).then(function () {
|
|
384
|
-
debug('writing: ' + testpath);
|
|
385
|
-
fs.writeFile(testpath, code, 'utf-8', cb);
|
|
386
|
-
}, function (err) {
|
|
387
|
-
throw new Error(err);
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// Environment-specific file opener. function name needs to
|
|
392
|
-
// be translated to code. The difficulty is in finding the
|
|
393
|
-
// category.
|
|
394
|
-
|
|
395
|
-
}, {
|
|
396
|
-
key: '_opener',
|
|
397
|
-
value: function _opener(fileOrName, requesterParams, cb) {
|
|
398
|
-
var self = this;
|
|
399
|
-
var pattern = void 0;
|
|
400
|
-
|
|
401
|
-
var language = requesterParams.language || '*';
|
|
402
|
-
|
|
403
|
-
if (path.basename(fileOrName, '.js').indexOf('.') !== -1) {
|
|
404
|
-
// periods in the basename, like: unicode.utf8.RuneCountInString or strings.sprintf
|
|
405
|
-
pattern = self.__src + '/' + language + '/' + fileOrName.replace(/\./g, '/') + '.js';
|
|
406
|
-
} else if (fileOrName.indexOf('/') === -1) {
|
|
407
|
-
// no slashes, like: sprintf
|
|
408
|
-
pattern = self.__src + '/' + language + '/*/' + fileOrName + '.js';
|
|
409
|
-
} else if (fileOrName.substr(0, 1) === '/') {
|
|
410
|
-
// absolute path, like: /Users/john/code/locutus/php/strings/sprintf.js
|
|
411
|
-
pattern = fileOrName;
|
|
412
|
-
} else {
|
|
413
|
-
// relative path, like: php/strings/sprintf.js
|
|
414
|
-
pattern = self.__src + '/' + fileOrName;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
pattern = pattern.replace('golang/strings/Index.js', 'golang/strings/Index2.js');
|
|
418
|
-
debug('loading: ' + pattern);
|
|
419
|
-
var files = globby.sync(pattern, {});
|
|
420
|
-
|
|
421
|
-
if (files.length !== 1) {
|
|
422
|
-
var msg = 'Found ' + files.length + ' occurances of ' + fileOrName + ' via pattern: ' + pattern;
|
|
423
|
-
return cb(new Error(msg));
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
var filepath = files[0];
|
|
427
|
-
|
|
428
|
-
if (path.basename(filepath) === 'index.js') {
|
|
429
|
-
return cb(null);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (!filepath) {
|
|
433
|
-
return cb(new Error('Could not find ' + pattern));
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
fs.readFile(filepath, 'utf-8', function (err, code) {
|
|
437
|
-
if (err) {
|
|
438
|
-
return cb(new Error('Error while opening ' + filepath + '. ' + err));
|
|
439
|
-
}
|
|
440
|
-
return cb(null, filepath, code);
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
}, {
|
|
444
|
-
key: '_load',
|
|
445
|
-
value: function _load(fileOrName, requesterParams, cb) {
|
|
446
|
-
var self = this;
|
|
447
|
-
self._opener(fileOrName, requesterParams, function (err, fullpath, code) {
|
|
448
|
-
if (err) {
|
|
449
|
-
return cb(err);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
var filepath = path.relative(self.__src, fullpath);
|
|
453
|
-
self._parse(filepath, code, cb);
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
}, {
|
|
457
|
-
key: '_findDependencies',
|
|
458
|
-
value: function _findDependencies(fileOrName, requesterParams, dependencies, cb) {
|
|
459
|
-
var self = this;
|
|
460
|
-
|
|
461
|
-
if (!requesterParams.headKeys['depends on'] || !requesterParams.headKeys['depends on'].length) {
|
|
462
|
-
if (cb) {
|
|
463
|
-
cb(null, {});
|
|
464
|
-
}
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
var i = void 0;
|
|
469
|
-
var depCodePath = void 0;
|
|
470
|
-
var loaded = 0;
|
|
471
|
-
for (i in requesterParams.headKeys['depends on']) {
|
|
472
|
-
depCodePath = requesterParams.headKeys['depends on'][i][0];
|
|
473
|
-
|
|
474
|
-
self._load(depCodePath, requesterParams, function (err, params) {
|
|
475
|
-
if (err) {
|
|
476
|
-
return cb(err);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
dependencies[depCodePath] = params;
|
|
480
|
-
self._findDependencies(depCodePath, params, dependencies);
|
|
481
|
-
|
|
482
|
-
if (cb && ++loaded === requesterParams.headKeys['depends on'].length) {
|
|
483
|
-
cb(null, dependencies);
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}, {
|
|
489
|
-
key: '_parse',
|
|
490
|
-
value: function _parse(filepath, code, cb) {
|
|
491
|
-
if (!code) {
|
|
492
|
-
return cb(new Error('Unable to parse ' + filepath + '. Received no code'));
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
if (filepath.indexOf('/') === -1) {
|
|
496
|
-
return cb(new Error("Parse only accepts relative filepaths. Received: '" + filepath + "'"));
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
var parts = filepath.split('/');
|
|
500
|
-
var language = parts.shift();
|
|
501
|
-
var codepath = parts.join('.');
|
|
502
|
-
var name = parts.pop();
|
|
503
|
-
var category = parts.join('.');
|
|
504
|
-
|
|
505
|
-
var ast = esprima.parseScript(code, { comment: true, loc: true, range: true });
|
|
506
|
-
|
|
507
|
-
// find module.exports in the code
|
|
508
|
-
var moduleExports = ast.body.filter(function (node) {
|
|
509
|
-
try {
|
|
510
|
-
var leftArg = node.expression.left;
|
|
511
|
-
var rightArg = node.expression.right;
|
|
512
|
-
|
|
513
|
-
return leftArg.object.name === 'module' && leftArg.property.name === 'exports' && rightArg.type === 'FunctionExpression' && rightArg.id.type === 'Identifier' && !!rightArg.id.name;
|
|
514
|
-
} catch (err) {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
// if file contains more than one export, fail
|
|
520
|
-
if (moduleExports.length !== 1) {
|
|
521
|
-
return cb(Error('File ' + filepath + ' is allowed to contain exactly one module.exports'));
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// get the only export
|
|
525
|
-
var exp = moduleExports[0];
|
|
526
|
-
|
|
527
|
-
// look for function name and param list
|
|
528
|
-
var funcName = exp.expression.right.id.name;
|
|
529
|
-
var funcParams = exp.expression.right.params.map(function (p) {
|
|
530
|
-
return p.name;
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
// remember the lines where the function is defined
|
|
534
|
-
var funcLoc = exp.expression.right.loc;
|
|
535
|
-
|
|
536
|
-
// since comments are not included in the AST
|
|
537
|
-
// but are offered in ast.comments
|
|
538
|
-
// remember the location of first function body statement/expression
|
|
539
|
-
var firstFuncBodyElementLoc = exp.expression.right.body.body[0].loc;
|
|
540
|
-
|
|
541
|
-
// get all line comments which are located between function signature definition
|
|
542
|
-
// and first function body element
|
|
543
|
-
var headComments = ast.comments.filter(function (c) {
|
|
544
|
-
return c.type === 'Line' && c.loc.start.line >= funcLoc.start.line && c.loc.end.line <= firstFuncBodyElementLoc.start.line;
|
|
545
|
-
}).map(function (c) {
|
|
546
|
-
return c.value.trim();
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
if (headComments.length === 0) {
|
|
550
|
-
var msg = 'Unable to parse ' + filepath + '. Did not find any comments in function definition';
|
|
551
|
-
return cb(new Error(msg));
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
var headKeys = this._headKeys(headComments);
|
|
555
|
-
|
|
556
|
-
var params = {
|
|
557
|
-
headKeys: headKeys,
|
|
558
|
-
name: name,
|
|
559
|
-
filepath: filepath,
|
|
560
|
-
codepath: codepath,
|
|
561
|
-
code: code,
|
|
562
|
-
language: language,
|
|
563
|
-
category: category,
|
|
564
|
-
func_name: funcName,
|
|
565
|
-
func_arguments: funcParams
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
this._findDependencies(filepath, params, {}, function (err, dependencies) {
|
|
569
|
-
if (err) {
|
|
570
|
-
return cb(err);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
params.dependencies = dependencies;
|
|
574
|
-
return cb(null, params);
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
}, {
|
|
578
|
-
key: '_headKeys',
|
|
579
|
-
value: function _headKeys(headLines) {
|
|
580
|
-
var i = void 0;
|
|
581
|
-
var keys = {};
|
|
582
|
-
var match = [];
|
|
583
|
-
var dmatch = [];
|
|
584
|
-
var key = '';
|
|
585
|
-
var val = '';
|
|
586
|
-
var num = 0;
|
|
587
|
-
|
|
588
|
-
for (i in headLines) {
|
|
589
|
-
if (!(match = headLines[i].match(/^\s*\W?\s*([a-z 0-9]+)\s*:\s*(.*)\s*$/))) {
|
|
590
|
-
continue;
|
|
591
|
-
}
|
|
592
|
-
key = match[1];
|
|
593
|
-
val = match[2];
|
|
594
|
-
|
|
595
|
-
if (dmatch = key.match(/^(\w+)\s+(\d+)$/)) {
|
|
596
|
-
// Things like examples and notes can be grouped
|
|
597
|
-
key = dmatch[1];
|
|
598
|
-
num = dmatch[2] - 1;
|
|
599
|
-
} else {
|
|
600
|
-
num = 0;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
if (!keys[key]) {
|
|
604
|
-
keys[key] = [];
|
|
605
|
-
}
|
|
606
|
-
if (!keys[key][num]) {
|
|
607
|
-
keys[key][num] = [];
|
|
608
|
-
}
|
|
609
|
-
keys[key][num].push(val);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
return keys;
|
|
613
|
-
}
|
|
614
|
-
}]);
|
|
615
|
-
|
|
616
|
-
return Util;
|
|
617
|
-
}();
|
|
618
|
-
|
|
619
|
-
module.exports = Util;
|
|
620
|
-
//# sourceMappingURL=util.js.map
|