skill-universe 1.1.0
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 +24 -0
- package/bin/skillc.mjs +3 -0
- package/build/dev/javascript/argv/_gleam_artefacts/argv.cache +0 -0
- package/build/dev/javascript/argv/_gleam_artefacts/argv.cache_inline +0 -0
- package/build/dev/javascript/argv/_gleam_artefacts/argv.cache_meta +0 -0
- package/build/dev/javascript/argv/argv.erl +12 -0
- package/build/dev/javascript/argv/argv.mjs +31 -0
- package/build/dev/javascript/argv/argv_ffi.erl +27 -0
- package/build/dev/javascript/argv/argv_ffi.mjs +20 -0
- package/build/dev/javascript/argv/gleam.mjs +1 -0
- package/build/dev/javascript/filepath/_gleam_artefacts/filepath.cache +0 -0
- package/build/dev/javascript/filepath/_gleam_artefacts/filepath.cache_inline +0 -0
- package/build/dev/javascript/filepath/_gleam_artefacts/filepath.cache_meta +0 -0
- package/build/dev/javascript/filepath/filepath.erl +425 -0
- package/build/dev/javascript/filepath/filepath.mjs +529 -0
- package/build/dev/javascript/filepath/filepath_ffi.erl +9 -0
- package/build/dev/javascript/filepath/filepath_ffi.mjs +6 -0
- package/build/dev/javascript/filepath/gleam.mjs +1 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache_inline +0 -0
- package/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache_meta +0 -0
- package/build/dev/javascript/gleam_stdlib/dict.mjs +710 -0
- package/build/dev/javascript/gleam_stdlib/gleam/bit_array.mjs +285 -0
- package/build/dev/javascript/gleam_stdlib/gleam/bool.mjs +313 -0
- package/build/dev/javascript/gleam_stdlib/gleam/bytes_tree.mjs +225 -0
- package/build/dev/javascript/gleam_stdlib/gleam/dict.mjs +456 -0
- package/build/dev/javascript/gleam_stdlib/gleam/dynamic/decode.mjs +985 -0
- package/build/dev/javascript/gleam_stdlib/gleam/dynamic.mjs +35 -0
- package/build/dev/javascript/gleam_stdlib/gleam/float.mjs +572 -0
- package/build/dev/javascript/gleam_stdlib/gleam/function.mjs +6 -0
- package/build/dev/javascript/gleam_stdlib/gleam/int.mjs +832 -0
- package/build/dev/javascript/gleam_stdlib/gleam/io.mjs +8 -0
- package/build/dev/javascript/gleam_stdlib/gleam/list.mjs +3160 -0
- package/build/dev/javascript/gleam_stdlib/gleam/option.mjs +418 -0
- package/build/dev/javascript/gleam_stdlib/gleam/order.mjs +178 -0
- package/build/dev/javascript/gleam_stdlib/gleam/pair.mjs +102 -0
- package/build/dev/javascript/gleam_stdlib/gleam/result.mjs +480 -0
- package/build/dev/javascript/gleam_stdlib/gleam/set.mjs +416 -0
- package/build/dev/javascript/gleam_stdlib/gleam/string.mjs +723 -0
- package/build/dev/javascript/gleam_stdlib/gleam/string_tree.mjs +133 -0
- package/build/dev/javascript/gleam_stdlib/gleam/uri.mjs +1155 -0
- package/build/dev/javascript/gleam_stdlib/gleam.mjs +1 -0
- package/build/dev/javascript/gleam_stdlib/gleam@bit_array.erl +347 -0
- package/build/dev/javascript/gleam_stdlib/gleam@bool.erl +352 -0
- package/build/dev/javascript/gleam_stdlib/gleam@bytes_tree.erl +211 -0
- package/build/dev/javascript/gleam_stdlib/gleam@dict.erl +521 -0
- package/build/dev/javascript/gleam_stdlib/gleam@dynamic.erl +106 -0
- package/build/dev/javascript/gleam_stdlib/gleam@dynamic@decode.erl +1112 -0
- package/build/dev/javascript/gleam_stdlib/gleam@float.erl +764 -0
- package/build/dev/javascript/gleam_stdlib/gleam@function.erl +18 -0
- package/build/dev/javascript/gleam_stdlib/gleam@int.erl +1004 -0
- package/build/dev/javascript/gleam_stdlib/gleam@io.erl +80 -0
- package/build/dev/javascript/gleam_stdlib/gleam@list.erl +2832 -0
- package/build/dev/javascript/gleam_stdlib/gleam@option.erl +413 -0
- package/build/dev/javascript/gleam_stdlib/gleam@order.erl +200 -0
- package/build/dev/javascript/gleam_stdlib/gleam@pair.erl +110 -0
- package/build/dev/javascript/gleam_stdlib/gleam@result.erl +532 -0
- package/build/dev/javascript/gleam_stdlib/gleam@set.erl +433 -0
- package/build/dev/javascript/gleam_stdlib/gleam@string.erl +1012 -0
- package/build/dev/javascript/gleam_stdlib/gleam@string_tree.erl +207 -0
- package/build/dev/javascript/gleam_stdlib/gleam@uri.erl +1049 -0
- package/build/dev/javascript/gleam_stdlib/gleam_stdlib.erl +529 -0
- package/build/dev/javascript/gleam_stdlib/gleam_stdlib.mjs +1050 -0
- package/build/dev/javascript/gleam_version +1 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit.cache +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit.cache_inline +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit.cache_meta +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@internal@gleam_panic.cache +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@internal@gleam_panic.cache_inline +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@internal@gleam_panic.cache_meta +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@internal@reporting.cache +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@internal@reporting.cache_inline +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@internal@reporting.cache_meta +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@should.cache +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@should.cache_inline +0 -0
- package/build/dev/javascript/gleeunit/_gleam_artefacts/gleeunit@should.cache_meta +0 -0
- package/build/dev/javascript/gleeunit/gleam.mjs +1 -0
- package/build/dev/javascript/gleeunit/gleeunit/internal/gleam_panic.mjs +180 -0
- package/build/dev/javascript/gleeunit/gleeunit/internal/gleeunit_gleam_panic_ffi.erl +49 -0
- package/build/dev/javascript/gleeunit/gleeunit/internal/gleeunit_gleam_panic_ffi.mjs +91 -0
- package/build/dev/javascript/gleeunit/gleeunit/internal/reporting.mjs +256 -0
- package/build/dev/javascript/gleeunit/gleeunit/should.mjs +135 -0
- package/build/dev/javascript/gleeunit/gleeunit.erl +89 -0
- package/build/dev/javascript/gleeunit/gleeunit.mjs +62 -0
- package/build/dev/javascript/gleeunit/gleeunit@internal@gleam_panic.erl +56 -0
- package/build/dev/javascript/gleeunit/gleeunit@internal@reporting.erl +343 -0
- package/build/dev/javascript/gleeunit/gleeunit@should.erl +153 -0
- package/build/dev/javascript/gleeunit/gleeunit_ffi.erl +21 -0
- package/build/dev/javascript/gleeunit/gleeunit_ffi.mjs +100 -0
- package/build/dev/javascript/gleeunit/gleeunit_progress.erl +72 -0
- package/build/dev/javascript/prelude.mjs +1575 -0
- package/build/dev/javascript/simplifile/_gleam_artefacts/simplifile.cache +0 -0
- package/build/dev/javascript/simplifile/_gleam_artefacts/simplifile.cache_inline +0 -0
- package/build/dev/javascript/simplifile/_gleam_artefacts/simplifile.cache_meta +0 -0
- package/build/dev/javascript/simplifile/gleam.mjs +1 -0
- package/build/dev/javascript/simplifile/simplifile.erl +893 -0
- package/build/dev/javascript/simplifile/simplifile.mjs +893 -0
- package/build/dev/javascript/simplifile/simplifile_erl.erl +244 -0
- package/build/dev/javascript/simplifile/simplifile_js.mjs +400 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/cli_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/cli_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/cli_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/cli_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/compiler_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/compiler_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/compiler_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/compiler_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/config_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/config_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/config_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/config_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/importer_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/importer_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/importer_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/importer_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/parser_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/parser_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/parser_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/parser_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/path_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/path_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/path_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/path_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/provider_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/provider_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/provider_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/provider_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/registry_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/registry_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/registry_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/registry_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/scaffold_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/scaffold_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/scaffold_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/scaffold_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@compiler.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@compiler.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@compiler.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@compiler.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@config.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@config.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@config.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@config.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@error.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@error.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@error.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@error.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@fs.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@fs.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@fs.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@fs.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@importer.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@importer.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@importer.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@importer.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@parser.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@parser.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@parser.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@parser.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@path.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@path.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@path.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@path.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@platform.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@platform.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@platform.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@platform.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@provider.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@provider.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@provider.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@provider.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@registry.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@registry.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@registry.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@registry.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@scaffold.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@scaffold.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@scaffold.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@scaffold.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@semver.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@semver.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@semver.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@semver.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@shell.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@shell.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@shell.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@shell.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@template.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@template.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@template.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@template.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@types.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@types.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@types.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@types.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@version_constraint.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@version_constraint.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@version_constraint.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@version_constraint.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@yaml.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@yaml.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@yaml.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc@yaml.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/skillc_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/template_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/template_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/template_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/template_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/version_constraint_test.cache +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/version_constraint_test.cache_inline +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/version_constraint_test.cache_meta +0 -0
- package/build/dev/javascript/skillc/_gleam_artefacts/version_constraint_test.cache_warnings +0 -0
- package/build/dev/javascript/skillc/cli_test.mjs +461 -0
- package/build/dev/javascript/skillc/compiler_test.mjs +3089 -0
- package/build/dev/javascript/skillc/config_test.mjs +308 -0
- package/build/dev/javascript/skillc/gleam.main.mjs +2 -0
- package/build/dev/javascript/skillc/gleam.mjs +1 -0
- package/build/dev/javascript/skillc/importer_test.mjs +1643 -0
- package/build/dev/javascript/skillc/parser_test.mjs +1601 -0
- package/build/dev/javascript/skillc/path_test.mjs +26 -0
- package/build/dev/javascript/skillc/provider_test.mjs +221 -0
- package/build/dev/javascript/skillc/registry_test.mjs +359 -0
- package/build/dev/javascript/skillc/scaffold_test.mjs +405 -0
- package/build/dev/javascript/skillc/skillc/compiler.mjs +724 -0
- package/build/dev/javascript/skillc/skillc/config.mjs +172 -0
- package/build/dev/javascript/skillc/skillc/error.mjs +145 -0
- package/build/dev/javascript/skillc/skillc/fs.mjs +40 -0
- package/build/dev/javascript/skillc/skillc/importer.mjs +975 -0
- package/build/dev/javascript/skillc/skillc/parser.mjs +427 -0
- package/build/dev/javascript/skillc/skillc/path.mjs +52 -0
- package/build/dev/javascript/skillc/skillc/platform.mjs +44 -0
- package/build/dev/javascript/skillc/skillc/provider.mjs +86 -0
- package/build/dev/javascript/skillc/skillc/registry.mjs +701 -0
- package/build/dev/javascript/skillc/skillc/scaffold.mjs +117 -0
- package/build/dev/javascript/skillc/skillc/semver.mjs +293 -0
- package/build/dev/javascript/skillc/skillc/shell.mjs +14 -0
- package/build/dev/javascript/skillc/skillc/template.mjs +1177 -0
- package/build/dev/javascript/skillc/skillc/types.mjs +249 -0
- package/build/dev/javascript/skillc/skillc/version_constraint.mjs +290 -0
- package/build/dev/javascript/skillc/skillc/yaml.mjs +51 -0
- package/build/dev/javascript/skillc/skillc.mjs +873 -0
- package/build/dev/javascript/skillc/skillc_ffi.mjs +30 -0
- package/build/dev/javascript/skillc/skillc_test.mjs +5 -0
- package/build/dev/javascript/skillc/template_test.mjs +1638 -0
- package/build/dev/javascript/skillc/version_constraint_test.mjs +1325 -0
- package/build/dev/javascript/yay/_gleam_artefacts/yay.cache +0 -0
- package/build/dev/javascript/yay/_gleam_artefacts/yay.cache_inline +0 -0
- package/build/dev/javascript/yay/_gleam_artefacts/yay.cache_meta +0 -0
- package/build/dev/javascript/yay/gleam.mjs +1 -0
- package/build/dev/javascript/yay/yaml_ffi.erl +106 -0
- package/build/dev/javascript/yay/yaml_ffi.mjs +373 -0
- package/build/dev/javascript/yay/yay.erl +1218 -0
- package/build/dev/javascript/yay/yay.mjs +1403 -0
- package/package.json +28 -0
- package/src/skillc/compiler.gleam +561 -0
- package/src/skillc/config.gleam +91 -0
- package/src/skillc/error.gleam +37 -0
- package/src/skillc/fs.gleam +31 -0
- package/src/skillc/importer.gleam +709 -0
- package/src/skillc/parser.gleam +279 -0
- package/src/skillc/path.gleam +30 -0
- package/src/skillc/platform.gleam +25 -0
- package/src/skillc/provider.gleam +58 -0
- package/src/skillc/registry.gleam +472 -0
- package/src/skillc/scaffold.gleam +112 -0
- package/src/skillc/semver.gleam +165 -0
- package/src/skillc/shell.gleam +12 -0
- package/src/skillc/template.gleam +885 -0
- package/src/skillc/types.gleam +93 -0
- package/src/skillc/version_constraint.gleam +163 -0
- package/src/skillc/yaml.gleam +27 -0
- package/src/skillc.gleam +466 -0
- package/src/skillc_ffi.mjs +30 -0
|
@@ -0,0 +1,1012 @@
|
|
|
1
|
+
-module(gleam@string).
|
|
2
|
+
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
|
|
3
|
+
-define(FILEPATH, "src/gleam/string.gleam").
|
|
4
|
+
-export([is_empty/1, length/1, reverse/1, replace/3, lowercase/1, uppercase/1, compare/2, slice/3, crop/2, drop_end/2, contains/2, starts_with/2, ends_with/2, split_once/2, append/2, concat/1, repeat/2, join/2, pad_start/3, pad_end/3, trim_start/1, trim_end/1, trim/1, pop_grapheme/1, to_graphemes/1, split/2, to_utf_codepoints/1, from_utf_codepoints/1, utf_codepoint/1, utf_codepoint_to_int/1, to_option/1, first/1, last/1, capitalise/1, inspect/1, byte_size/1, drop_start/2]).
|
|
5
|
+
-export_type([direction/0]).
|
|
6
|
+
|
|
7
|
+
-if(?OTP_RELEASE >= 27).
|
|
8
|
+
-define(MODULEDOC(Str), -moduledoc(Str)).
|
|
9
|
+
-define(DOC(Str), -doc(Str)).
|
|
10
|
+
-else.
|
|
11
|
+
-define(MODULEDOC(Str), -compile([])).
|
|
12
|
+
-define(DOC(Str), -compile([])).
|
|
13
|
+
-endif.
|
|
14
|
+
|
|
15
|
+
?MODULEDOC(
|
|
16
|
+
" Strings in Gleam are UTF-8 binaries. They can be written in your code as\n"
|
|
17
|
+
" text surrounded by `\"double quotes\"`.\n"
|
|
18
|
+
).
|
|
19
|
+
|
|
20
|
+
-type direction() :: leading | trailing.
|
|
21
|
+
|
|
22
|
+
-file("src/gleam/string.gleam", 23).
|
|
23
|
+
?DOC(
|
|
24
|
+
" Determines if a `String` is empty.\n"
|
|
25
|
+
"\n"
|
|
26
|
+
" ## Examples\n"
|
|
27
|
+
"\n"
|
|
28
|
+
" ```gleam\n"
|
|
29
|
+
" is_empty(\"\")\n"
|
|
30
|
+
" // -> True\n"
|
|
31
|
+
" ```\n"
|
|
32
|
+
"\n"
|
|
33
|
+
" ```gleam\n"
|
|
34
|
+
" is_empty(\"the world\")\n"
|
|
35
|
+
" // -> False\n"
|
|
36
|
+
" ```\n"
|
|
37
|
+
).
|
|
38
|
+
-spec is_empty(binary()) -> boolean().
|
|
39
|
+
is_empty(Str) ->
|
|
40
|
+
Str =:= <<""/utf8>>.
|
|
41
|
+
|
|
42
|
+
-file("src/gleam/string.gleam", 51).
|
|
43
|
+
?DOC(
|
|
44
|
+
" Gets the number of grapheme clusters in a given `String`.\n"
|
|
45
|
+
"\n"
|
|
46
|
+
" This function has to iterate across the whole string to count the number of\n"
|
|
47
|
+
" graphemes, so it runs in linear time. Avoid using this in a loop.\n"
|
|
48
|
+
"\n"
|
|
49
|
+
" ## Examples\n"
|
|
50
|
+
"\n"
|
|
51
|
+
" ```gleam\n"
|
|
52
|
+
" length(\"Gleam\")\n"
|
|
53
|
+
" // -> 5\n"
|
|
54
|
+
" ```\n"
|
|
55
|
+
"\n"
|
|
56
|
+
" ```gleam\n"
|
|
57
|
+
" length(\"ß↑e̊\")\n"
|
|
58
|
+
" // -> 3\n"
|
|
59
|
+
" ```\n"
|
|
60
|
+
"\n"
|
|
61
|
+
" ```gleam\n"
|
|
62
|
+
" length(\"\")\n"
|
|
63
|
+
" // -> 0\n"
|
|
64
|
+
" ```\n"
|
|
65
|
+
).
|
|
66
|
+
-spec length(binary()) -> integer().
|
|
67
|
+
length(String) ->
|
|
68
|
+
string:length(String).
|
|
69
|
+
|
|
70
|
+
-file("src/gleam/string.gleam", 65).
|
|
71
|
+
?DOC(
|
|
72
|
+
" Reverses a `String`.\n"
|
|
73
|
+
"\n"
|
|
74
|
+
" This function has to iterate across the whole `String` so it runs in linear\n"
|
|
75
|
+
" time. Avoid using this in a loop.\n"
|
|
76
|
+
"\n"
|
|
77
|
+
" ## Examples\n"
|
|
78
|
+
"\n"
|
|
79
|
+
" ```gleam\n"
|
|
80
|
+
" reverse(\"stressed\")\n"
|
|
81
|
+
" // -> \"desserts\"\n"
|
|
82
|
+
" ```\n"
|
|
83
|
+
).
|
|
84
|
+
-spec reverse(binary()) -> binary().
|
|
85
|
+
reverse(String) ->
|
|
86
|
+
_pipe = String,
|
|
87
|
+
_pipe@1 = gleam_stdlib:identity(_pipe),
|
|
88
|
+
_pipe@2 = string:reverse(_pipe@1),
|
|
89
|
+
unicode:characters_to_binary(_pipe@2).
|
|
90
|
+
|
|
91
|
+
-file("src/gleam/string.gleam", 86).
|
|
92
|
+
?DOC(
|
|
93
|
+
" Creates a new `String` by replacing all occurrences of a given substring.\n"
|
|
94
|
+
"\n"
|
|
95
|
+
" ## Examples\n"
|
|
96
|
+
"\n"
|
|
97
|
+
" ```gleam\n"
|
|
98
|
+
" replace(\"www.example.com\", each: \".\", with: \"-\")\n"
|
|
99
|
+
" // -> \"www-example-com\"\n"
|
|
100
|
+
" ```\n"
|
|
101
|
+
"\n"
|
|
102
|
+
" ```gleam\n"
|
|
103
|
+
" replace(\"a,b,c,d,e\", each: \",\", with: \"/\")\n"
|
|
104
|
+
" // -> \"a/b/c/d/e\"\n"
|
|
105
|
+
" ```\n"
|
|
106
|
+
).
|
|
107
|
+
-spec replace(binary(), binary(), binary()) -> binary().
|
|
108
|
+
replace(String, Pattern, Substitute) ->
|
|
109
|
+
_pipe = String,
|
|
110
|
+
_pipe@1 = gleam_stdlib:identity(_pipe),
|
|
111
|
+
_pipe@2 = gleam_stdlib:string_replace(_pipe@1, Pattern, Substitute),
|
|
112
|
+
unicode:characters_to_binary(_pipe@2).
|
|
113
|
+
|
|
114
|
+
-file("src/gleam/string.gleam", 111).
|
|
115
|
+
?DOC(
|
|
116
|
+
" Creates a new `String` with all the graphemes in the input `String` converted to\n"
|
|
117
|
+
" lowercase.\n"
|
|
118
|
+
"\n"
|
|
119
|
+
" Useful for case-insensitive comparisons.\n"
|
|
120
|
+
"\n"
|
|
121
|
+
" ## Examples\n"
|
|
122
|
+
"\n"
|
|
123
|
+
" ```gleam\n"
|
|
124
|
+
" lowercase(\"X-FILES\")\n"
|
|
125
|
+
" // -> \"x-files\"\n"
|
|
126
|
+
" ```\n"
|
|
127
|
+
).
|
|
128
|
+
-spec lowercase(binary()) -> binary().
|
|
129
|
+
lowercase(String) ->
|
|
130
|
+
string:lowercase(String).
|
|
131
|
+
|
|
132
|
+
-file("src/gleam/string.gleam", 127).
|
|
133
|
+
?DOC(
|
|
134
|
+
" Creates a new `String` with all the graphemes in the input `String` converted to\n"
|
|
135
|
+
" uppercase.\n"
|
|
136
|
+
"\n"
|
|
137
|
+
" Useful for case-insensitive comparisons and VIRTUAL YELLING.\n"
|
|
138
|
+
"\n"
|
|
139
|
+
" ## Examples\n"
|
|
140
|
+
"\n"
|
|
141
|
+
" ```gleam\n"
|
|
142
|
+
" uppercase(\"skinner\")\n"
|
|
143
|
+
" // -> \"SKINNER\"\n"
|
|
144
|
+
" ```\n"
|
|
145
|
+
).
|
|
146
|
+
-spec uppercase(binary()) -> binary().
|
|
147
|
+
uppercase(String) ->
|
|
148
|
+
string:uppercase(String).
|
|
149
|
+
|
|
150
|
+
-file("src/gleam/string.gleam", 145).
|
|
151
|
+
?DOC(
|
|
152
|
+
" Compares two `String`s to see which is \"larger\" by comparing their graphemes.\n"
|
|
153
|
+
"\n"
|
|
154
|
+
" This does not compare the size or length of the given `String`s.\n"
|
|
155
|
+
"\n"
|
|
156
|
+
" ## Examples\n"
|
|
157
|
+
"\n"
|
|
158
|
+
" ```gleam\n"
|
|
159
|
+
" compare(\"Anthony\", \"Anthony\")\n"
|
|
160
|
+
" // -> order.Eq\n"
|
|
161
|
+
" ```\n"
|
|
162
|
+
"\n"
|
|
163
|
+
" ```gleam\n"
|
|
164
|
+
" compare(\"A\", \"B\")\n"
|
|
165
|
+
" // -> order.Lt\n"
|
|
166
|
+
" ```\n"
|
|
167
|
+
).
|
|
168
|
+
-spec compare(binary(), binary()) -> gleam@order:order().
|
|
169
|
+
compare(A, B) ->
|
|
170
|
+
case A =:= B of
|
|
171
|
+
true ->
|
|
172
|
+
eq;
|
|
173
|
+
|
|
174
|
+
_ ->
|
|
175
|
+
case gleam_stdlib:less_than(A, B) of
|
|
176
|
+
true ->
|
|
177
|
+
lt;
|
|
178
|
+
|
|
179
|
+
false ->
|
|
180
|
+
gt
|
|
181
|
+
end
|
|
182
|
+
end.
|
|
183
|
+
|
|
184
|
+
-file("src/gleam/string.gleam", 194).
|
|
185
|
+
?DOC(
|
|
186
|
+
" Takes a substring given a start grapheme index and a length. Negative indexes\n"
|
|
187
|
+
" are taken starting from the *end* of the string.\n"
|
|
188
|
+
"\n"
|
|
189
|
+
" This function runs in linear time with the size of the index and the\n"
|
|
190
|
+
" length. Negative indexes are linear with the size of the input string in\n"
|
|
191
|
+
" addition to the other costs.\n"
|
|
192
|
+
"\n"
|
|
193
|
+
" ## Examples\n"
|
|
194
|
+
"\n"
|
|
195
|
+
" ```gleam\n"
|
|
196
|
+
" slice(from: \"gleam\", at_index: 1, length: 2)\n"
|
|
197
|
+
" // -> \"le\"\n"
|
|
198
|
+
" ```\n"
|
|
199
|
+
"\n"
|
|
200
|
+
" ```gleam\n"
|
|
201
|
+
" slice(from: \"gleam\", at_index: 1, length: 10)\n"
|
|
202
|
+
" // -> \"leam\"\n"
|
|
203
|
+
" ```\n"
|
|
204
|
+
"\n"
|
|
205
|
+
" ```gleam\n"
|
|
206
|
+
" slice(from: \"gleam\", at_index: 10, length: 3)\n"
|
|
207
|
+
" // -> \"\"\n"
|
|
208
|
+
" ```\n"
|
|
209
|
+
"\n"
|
|
210
|
+
" ```gleam\n"
|
|
211
|
+
" slice(from: \"gleam\", at_index: -2, length: 2)\n"
|
|
212
|
+
" // -> \"am\"\n"
|
|
213
|
+
" ```\n"
|
|
214
|
+
"\n"
|
|
215
|
+
" ```gleam\n"
|
|
216
|
+
" slice(from: \"gleam\", at_index: -12, length: 2)\n"
|
|
217
|
+
" // -> \"\"\n"
|
|
218
|
+
" ```\n"
|
|
219
|
+
).
|
|
220
|
+
-spec slice(binary(), integer(), integer()) -> binary().
|
|
221
|
+
slice(String, Idx, Len) ->
|
|
222
|
+
case Len =< 0 of
|
|
223
|
+
true ->
|
|
224
|
+
<<""/utf8>>;
|
|
225
|
+
|
|
226
|
+
false ->
|
|
227
|
+
case Idx < 0 of
|
|
228
|
+
true ->
|
|
229
|
+
Translated_idx = string:length(String) + Idx,
|
|
230
|
+
case Translated_idx < 0 of
|
|
231
|
+
true ->
|
|
232
|
+
<<""/utf8>>;
|
|
233
|
+
|
|
234
|
+
false ->
|
|
235
|
+
gleam_stdlib:slice(String, Translated_idx, Len)
|
|
236
|
+
end;
|
|
237
|
+
|
|
238
|
+
false ->
|
|
239
|
+
gleam_stdlib:slice(String, Idx, Len)
|
|
240
|
+
end
|
|
241
|
+
end.
|
|
242
|
+
|
|
243
|
+
-file("src/gleam/string.gleam", 232).
|
|
244
|
+
?DOC(
|
|
245
|
+
" Drops contents of the first `String` that occur before the second `String`.\n"
|
|
246
|
+
" If the `from` string does not contain the `before` string, `from` is\n"
|
|
247
|
+
" returned unchanged.\n"
|
|
248
|
+
"\n"
|
|
249
|
+
" ## Examples\n"
|
|
250
|
+
"\n"
|
|
251
|
+
" ```gleam\n"
|
|
252
|
+
" crop(from: \"The Lone Gunmen\", before: \"Lone\")\n"
|
|
253
|
+
" // -> \"Lone Gunmen\"\n"
|
|
254
|
+
" ```\n"
|
|
255
|
+
).
|
|
256
|
+
-spec crop(binary(), binary()) -> binary().
|
|
257
|
+
crop(String, Substring) ->
|
|
258
|
+
gleam_stdlib:crop_string(String, Substring).
|
|
259
|
+
|
|
260
|
+
-file("src/gleam/string.gleam", 268).
|
|
261
|
+
?DOC(
|
|
262
|
+
" Drops *n* graphemes from the end of a `String`.\n"
|
|
263
|
+
"\n"
|
|
264
|
+
" This function traverses the full string, so it runs in linear time with the\n"
|
|
265
|
+
" size of the string. Avoid using this in a loop.\n"
|
|
266
|
+
"\n"
|
|
267
|
+
" ## Examples\n"
|
|
268
|
+
"\n"
|
|
269
|
+
" ```gleam\n"
|
|
270
|
+
" drop_end(from: \"Cigarette Smoking Man\", up_to: 2)\n"
|
|
271
|
+
" // -> \"Cigarette Smoking M\"\n"
|
|
272
|
+
" ```\n"
|
|
273
|
+
).
|
|
274
|
+
-spec drop_end(binary(), integer()) -> binary().
|
|
275
|
+
drop_end(String, Num_graphemes) ->
|
|
276
|
+
case Num_graphemes =< 0 of
|
|
277
|
+
true ->
|
|
278
|
+
String;
|
|
279
|
+
|
|
280
|
+
false ->
|
|
281
|
+
slice(String, 0, string:length(String) - Num_graphemes)
|
|
282
|
+
end.
|
|
283
|
+
|
|
284
|
+
-file("src/gleam/string.gleam", 296).
|
|
285
|
+
?DOC(
|
|
286
|
+
" Checks if the first `String` contains the second.\n"
|
|
287
|
+
"\n"
|
|
288
|
+
" ## Examples\n"
|
|
289
|
+
"\n"
|
|
290
|
+
" ```gleam\n"
|
|
291
|
+
" contains(does: \"theory\", contain: \"ory\")\n"
|
|
292
|
+
" // -> True\n"
|
|
293
|
+
" ```\n"
|
|
294
|
+
"\n"
|
|
295
|
+
" ```gleam\n"
|
|
296
|
+
" contains(does: \"theory\", contain: \"the\")\n"
|
|
297
|
+
" // -> True\n"
|
|
298
|
+
" ```\n"
|
|
299
|
+
"\n"
|
|
300
|
+
" ```gleam\n"
|
|
301
|
+
" contains(does: \"theory\", contain: \"THE\")\n"
|
|
302
|
+
" // -> False\n"
|
|
303
|
+
" ```\n"
|
|
304
|
+
).
|
|
305
|
+
-spec contains(binary(), binary()) -> boolean().
|
|
306
|
+
contains(Haystack, Needle) ->
|
|
307
|
+
gleam_stdlib:contains_string(Haystack, Needle).
|
|
308
|
+
|
|
309
|
+
-file("src/gleam/string.gleam", 309).
|
|
310
|
+
?DOC(
|
|
311
|
+
" Checks whether the first `String` starts with the second one.\n"
|
|
312
|
+
"\n"
|
|
313
|
+
" ## Examples\n"
|
|
314
|
+
"\n"
|
|
315
|
+
" ```gleam\n"
|
|
316
|
+
" starts_with(\"theory\", \"ory\")\n"
|
|
317
|
+
" // -> False\n"
|
|
318
|
+
" ```\n"
|
|
319
|
+
).
|
|
320
|
+
-spec starts_with(binary(), binary()) -> boolean().
|
|
321
|
+
starts_with(String, Prefix) ->
|
|
322
|
+
gleam_stdlib:string_starts_with(String, Prefix).
|
|
323
|
+
|
|
324
|
+
-file("src/gleam/string.gleam", 322).
|
|
325
|
+
?DOC(
|
|
326
|
+
" Checks whether the first `String` ends with the second one.\n"
|
|
327
|
+
"\n"
|
|
328
|
+
" ## Examples\n"
|
|
329
|
+
"\n"
|
|
330
|
+
" ```gleam\n"
|
|
331
|
+
" ends_with(\"theory\", \"ory\")\n"
|
|
332
|
+
" // -> True\n"
|
|
333
|
+
" ```\n"
|
|
334
|
+
).
|
|
335
|
+
-spec ends_with(binary(), binary()) -> boolean().
|
|
336
|
+
ends_with(String, Suffix) ->
|
|
337
|
+
gleam_stdlib:string_ends_with(String, Suffix).
|
|
338
|
+
|
|
339
|
+
-file("src/gleam/string.gleam", 361).
|
|
340
|
+
?DOC(
|
|
341
|
+
" Splits a `String` a single time on the given substring.\n"
|
|
342
|
+
"\n"
|
|
343
|
+
" Returns an `Error` if substring not present.\n"
|
|
344
|
+
"\n"
|
|
345
|
+
" ## Examples\n"
|
|
346
|
+
"\n"
|
|
347
|
+
" ```gleam\n"
|
|
348
|
+
" split_once(\"home/gleam/desktop/\", on: \"/\")\n"
|
|
349
|
+
" // -> Ok(#(\"home\", \"gleam/desktop/\"))\n"
|
|
350
|
+
" ```\n"
|
|
351
|
+
"\n"
|
|
352
|
+
" ```gleam\n"
|
|
353
|
+
" split_once(\"home/gleam/desktop/\", on: \"?\")\n"
|
|
354
|
+
" // -> Error(Nil)\n"
|
|
355
|
+
" ```\n"
|
|
356
|
+
).
|
|
357
|
+
-spec split_once(binary(), binary()) -> {ok, {binary(), binary()}} |
|
|
358
|
+
{error, nil}.
|
|
359
|
+
split_once(String, Substring) ->
|
|
360
|
+
case string:split(String, Substring) of
|
|
361
|
+
[First, Rest] ->
|
|
362
|
+
{ok, {First, Rest}};
|
|
363
|
+
|
|
364
|
+
_ ->
|
|
365
|
+
{error, nil}
|
|
366
|
+
end.
|
|
367
|
+
|
|
368
|
+
-file("src/gleam/string.gleam", 392).
|
|
369
|
+
?DOC(
|
|
370
|
+
" Creates a new `String` by joining two `String`s together.\n"
|
|
371
|
+
"\n"
|
|
372
|
+
" This function typically copies both `String`s and runs in linear time, but\n"
|
|
373
|
+
" the exact behaviour will depend on how the runtime you are using optimises\n"
|
|
374
|
+
" your code. Benchmark and profile your code if you need to understand its\n"
|
|
375
|
+
" performance better.\n"
|
|
376
|
+
"\n"
|
|
377
|
+
" If you are joining together large string and want to avoid copying any data\n"
|
|
378
|
+
" you may want to investigate using the [`string_tree`](../gleam/string_tree.html)\n"
|
|
379
|
+
" module.\n"
|
|
380
|
+
"\n"
|
|
381
|
+
" ## Examples\n"
|
|
382
|
+
"\n"
|
|
383
|
+
" ```gleam\n"
|
|
384
|
+
" append(to: \"butter\", suffix: \"fly\")\n"
|
|
385
|
+
" // -> \"butterfly\"\n"
|
|
386
|
+
" ```\n"
|
|
387
|
+
).
|
|
388
|
+
-spec append(binary(), binary()) -> binary().
|
|
389
|
+
append(First, Second) ->
|
|
390
|
+
<<First/binary, Second/binary>>.
|
|
391
|
+
|
|
392
|
+
-file("src/gleam/string.gleam", 412).
|
|
393
|
+
-spec concat_loop(list(binary()), binary()) -> binary().
|
|
394
|
+
concat_loop(Strings, Accumulator) ->
|
|
395
|
+
case Strings of
|
|
396
|
+
[String | Strings@1] ->
|
|
397
|
+
concat_loop(Strings@1, <<Accumulator/binary, String/binary>>);
|
|
398
|
+
|
|
399
|
+
[] ->
|
|
400
|
+
Accumulator
|
|
401
|
+
end.
|
|
402
|
+
|
|
403
|
+
-file("src/gleam/string.gleam", 408).
|
|
404
|
+
?DOC(
|
|
405
|
+
" Creates a new `String` by joining many `String`s together.\n"
|
|
406
|
+
"\n"
|
|
407
|
+
" This function copies all the `String`s and runs in linear time.\n"
|
|
408
|
+
"\n"
|
|
409
|
+
" ## Examples\n"
|
|
410
|
+
"\n"
|
|
411
|
+
" ```gleam\n"
|
|
412
|
+
" concat([\"never\", \"the\", \"less\"])\n"
|
|
413
|
+
" // -> \"nevertheless\"\n"
|
|
414
|
+
" ```\n"
|
|
415
|
+
).
|
|
416
|
+
-spec concat(list(binary())) -> binary().
|
|
417
|
+
concat(Strings) ->
|
|
418
|
+
erlang:list_to_binary(Strings).
|
|
419
|
+
|
|
420
|
+
-file("src/gleam/string.gleam", 437).
|
|
421
|
+
-spec repeat_loop(integer(), binary(), binary()) -> binary().
|
|
422
|
+
repeat_loop(Times, Doubling_acc, Acc) ->
|
|
423
|
+
Acc@1 = case Times rem 2 of
|
|
424
|
+
0 ->
|
|
425
|
+
Acc;
|
|
426
|
+
|
|
427
|
+
_ ->
|
|
428
|
+
<<Acc/binary, Doubling_acc/binary>>
|
|
429
|
+
end,
|
|
430
|
+
Times@1 = Times div 2,
|
|
431
|
+
case Times@1 =< 0 of
|
|
432
|
+
true ->
|
|
433
|
+
Acc@1;
|
|
434
|
+
|
|
435
|
+
false ->
|
|
436
|
+
repeat_loop(
|
|
437
|
+
Times@1,
|
|
438
|
+
<<Doubling_acc/binary, Doubling_acc/binary>>,
|
|
439
|
+
Acc@1
|
|
440
|
+
)
|
|
441
|
+
end.
|
|
442
|
+
|
|
443
|
+
-file("src/gleam/string.gleam", 430).
|
|
444
|
+
?DOC(
|
|
445
|
+
" Creates a new `String` by repeating a `String` a given number of times.\n"
|
|
446
|
+
"\n"
|
|
447
|
+
" This function runs in loglinear time.\n"
|
|
448
|
+
"\n"
|
|
449
|
+
" ## Examples\n"
|
|
450
|
+
"\n"
|
|
451
|
+
" ```gleam\n"
|
|
452
|
+
" repeat(\"ha\", times: 3)\n"
|
|
453
|
+
" // -> \"hahaha\"\n"
|
|
454
|
+
" ```\n"
|
|
455
|
+
).
|
|
456
|
+
-spec repeat(binary(), integer()) -> binary().
|
|
457
|
+
repeat(String, Times) ->
|
|
458
|
+
case Times =< 0 of
|
|
459
|
+
true ->
|
|
460
|
+
<<""/utf8>>;
|
|
461
|
+
|
|
462
|
+
false ->
|
|
463
|
+
repeat_loop(Times, String, <<""/utf8>>)
|
|
464
|
+
end.
|
|
465
|
+
|
|
466
|
+
-file("src/gleam/string.gleam", 467).
|
|
467
|
+
-spec join_loop(list(binary()), binary(), binary()) -> binary().
|
|
468
|
+
join_loop(Strings, Separator, Accumulator) ->
|
|
469
|
+
case Strings of
|
|
470
|
+
[] ->
|
|
471
|
+
Accumulator;
|
|
472
|
+
|
|
473
|
+
[String | Strings@1] ->
|
|
474
|
+
join_loop(
|
|
475
|
+
Strings@1,
|
|
476
|
+
Separator,
|
|
477
|
+
<<<<Accumulator/binary, Separator/binary>>/binary,
|
|
478
|
+
String/binary>>
|
|
479
|
+
)
|
|
480
|
+
end.
|
|
481
|
+
|
|
482
|
+
-file("src/gleam/string.gleam", 460).
|
|
483
|
+
?DOC(
|
|
484
|
+
" Joins many `String`s together with a given separator.\n"
|
|
485
|
+
"\n"
|
|
486
|
+
" This function runs in linear time.\n"
|
|
487
|
+
"\n"
|
|
488
|
+
" ## Examples\n"
|
|
489
|
+
"\n"
|
|
490
|
+
" ```gleam\n"
|
|
491
|
+
" join([\"home\",\"evan\",\"Desktop\"], with: \"/\")\n"
|
|
492
|
+
" // -> \"home/evan/Desktop\"\n"
|
|
493
|
+
" ```\n"
|
|
494
|
+
).
|
|
495
|
+
-spec join(list(binary()), binary()) -> binary().
|
|
496
|
+
join(Strings, Separator) ->
|
|
497
|
+
case Strings of
|
|
498
|
+
[] ->
|
|
499
|
+
<<""/utf8>>;
|
|
500
|
+
|
|
501
|
+
[First | Rest] ->
|
|
502
|
+
join_loop(Rest, Separator, First)
|
|
503
|
+
end.
|
|
504
|
+
|
|
505
|
+
-file("src/gleam/string.gleam", 545).
|
|
506
|
+
-spec padding(integer(), binary()) -> binary().
|
|
507
|
+
padding(Size, Pad_string) ->
|
|
508
|
+
Pad_string_length = string:length(Pad_string),
|
|
509
|
+
Num_pads = case Pad_string_length of
|
|
510
|
+
0 -> 0;
|
|
511
|
+
Gleam@denominator -> Size div Gleam@denominator
|
|
512
|
+
end,
|
|
513
|
+
Extra = case Pad_string_length of
|
|
514
|
+
0 -> 0;
|
|
515
|
+
Gleam@denominator@1 -> Size rem Gleam@denominator@1
|
|
516
|
+
end,
|
|
517
|
+
<<(repeat(Pad_string, Num_pads))/binary,
|
|
518
|
+
(slice(Pad_string, 0, Extra))/binary>>.
|
|
519
|
+
|
|
520
|
+
-file("src/gleam/string.gleam", 498).
|
|
521
|
+
?DOC(
|
|
522
|
+
" Pads the start of a `String` until it has a given length.\n"
|
|
523
|
+
"\n"
|
|
524
|
+
" ## Examples\n"
|
|
525
|
+
"\n"
|
|
526
|
+
" ```gleam\n"
|
|
527
|
+
" pad_start(\"121\", to: 5, with: \".\")\n"
|
|
528
|
+
" // -> \"..121\"\n"
|
|
529
|
+
" ```\n"
|
|
530
|
+
"\n"
|
|
531
|
+
" ```gleam\n"
|
|
532
|
+
" pad_start(\"121\", to: 3, with: \".\")\n"
|
|
533
|
+
" // -> \"121\"\n"
|
|
534
|
+
" ```\n"
|
|
535
|
+
"\n"
|
|
536
|
+
" ```gleam\n"
|
|
537
|
+
" pad_start(\"121\", to: 2, with: \".\")\n"
|
|
538
|
+
" // -> \"121\"\n"
|
|
539
|
+
" ```\n"
|
|
540
|
+
).
|
|
541
|
+
-spec pad_start(binary(), integer(), binary()) -> binary().
|
|
542
|
+
pad_start(String, Desired_length, Pad_string) ->
|
|
543
|
+
Current_length = string:length(String),
|
|
544
|
+
To_pad_length = Desired_length - Current_length,
|
|
545
|
+
case To_pad_length =< 0 of
|
|
546
|
+
true ->
|
|
547
|
+
String;
|
|
548
|
+
|
|
549
|
+
false ->
|
|
550
|
+
<<(padding(To_pad_length, Pad_string))/binary, String/binary>>
|
|
551
|
+
end.
|
|
552
|
+
|
|
553
|
+
-file("src/gleam/string.gleam", 531).
|
|
554
|
+
?DOC(
|
|
555
|
+
" Pads the end of a `String` until it has a given length.\n"
|
|
556
|
+
"\n"
|
|
557
|
+
" ## Examples\n"
|
|
558
|
+
"\n"
|
|
559
|
+
" ```gleam\n"
|
|
560
|
+
" pad_end(\"123\", to: 5, with: \".\")\n"
|
|
561
|
+
" // -> \"123..\"\n"
|
|
562
|
+
" ```\n"
|
|
563
|
+
"\n"
|
|
564
|
+
" ```gleam\n"
|
|
565
|
+
" pad_end(\"123\", to: 3, with: \".\")\n"
|
|
566
|
+
" // -> \"123\"\n"
|
|
567
|
+
" ```\n"
|
|
568
|
+
"\n"
|
|
569
|
+
" ```gleam\n"
|
|
570
|
+
" pad_end(\"123\", to: 2, with: \".\")\n"
|
|
571
|
+
" // -> \"123\"\n"
|
|
572
|
+
" ```\n"
|
|
573
|
+
).
|
|
574
|
+
-spec pad_end(binary(), integer(), binary()) -> binary().
|
|
575
|
+
pad_end(String, Desired_length, Pad_string) ->
|
|
576
|
+
Current_length = string:length(String),
|
|
577
|
+
To_pad_length = Desired_length - Current_length,
|
|
578
|
+
case To_pad_length =< 0 of
|
|
579
|
+
true ->
|
|
580
|
+
String;
|
|
581
|
+
|
|
582
|
+
false ->
|
|
583
|
+
<<String/binary, (padding(To_pad_length, Pad_string))/binary>>
|
|
584
|
+
end.
|
|
585
|
+
|
|
586
|
+
-file("src/gleam/string.gleam", 589).
|
|
587
|
+
?DOC(
|
|
588
|
+
" Removes whitespace at the start of a `String`.\n"
|
|
589
|
+
"\n"
|
|
590
|
+
" ## Examples\n"
|
|
591
|
+
"\n"
|
|
592
|
+
" ```gleam\n"
|
|
593
|
+
" trim_start(\" hats \\n\")\n"
|
|
594
|
+
" // -> \"hats \\n\"\n"
|
|
595
|
+
" ```\n"
|
|
596
|
+
).
|
|
597
|
+
-spec trim_start(binary()) -> binary().
|
|
598
|
+
trim_start(String) ->
|
|
599
|
+
string:trim(String, leading).
|
|
600
|
+
|
|
601
|
+
-file("src/gleam/string.gleam", 603).
|
|
602
|
+
?DOC(
|
|
603
|
+
" Removes whitespace at the end of a `String`.\n"
|
|
604
|
+
"\n"
|
|
605
|
+
" ## Examples\n"
|
|
606
|
+
"\n"
|
|
607
|
+
" ```gleam\n"
|
|
608
|
+
" trim_end(\" hats \\n\")\n"
|
|
609
|
+
" // -> \" hats\"\n"
|
|
610
|
+
" ```\n"
|
|
611
|
+
).
|
|
612
|
+
-spec trim_end(binary()) -> binary().
|
|
613
|
+
trim_end(String) ->
|
|
614
|
+
string:trim(String, trailing).
|
|
615
|
+
|
|
616
|
+
-file("src/gleam/string.gleam", 567).
|
|
617
|
+
?DOC(
|
|
618
|
+
" Removes whitespace on both sides of a `String`.\n"
|
|
619
|
+
"\n"
|
|
620
|
+
" Whitespace in this function is the set of nonbreakable whitespace\n"
|
|
621
|
+
" codepoints, defined as Pattern_White_Space in [Unicode Standard Annex #31][1].\n"
|
|
622
|
+
"\n"
|
|
623
|
+
" [1]: https://unicode.org/reports/tr31/\n"
|
|
624
|
+
"\n"
|
|
625
|
+
" ## Examples\n"
|
|
626
|
+
"\n"
|
|
627
|
+
" ```gleam\n"
|
|
628
|
+
" trim(\" hats \\n\")\n"
|
|
629
|
+
" // -> \"hats\"\n"
|
|
630
|
+
" ```\n"
|
|
631
|
+
).
|
|
632
|
+
-spec trim(binary()) -> binary().
|
|
633
|
+
trim(String) ->
|
|
634
|
+
_pipe = String,
|
|
635
|
+
_pipe@1 = trim_start(_pipe),
|
|
636
|
+
trim_end(_pipe@1).
|
|
637
|
+
|
|
638
|
+
-file("src/gleam/string.gleam", 630).
|
|
639
|
+
?DOC(
|
|
640
|
+
" Splits a non-empty `String` into its first element (head) and rest (tail).\n"
|
|
641
|
+
" This lets you pattern match on `String`s exactly as you would with lists.\n"
|
|
642
|
+
"\n"
|
|
643
|
+
" ## Performance\n"
|
|
644
|
+
"\n"
|
|
645
|
+
" There is a notable overhead to using this function, so you may not want to\n"
|
|
646
|
+
" use it in a tight loop. If you wish to efficiently parse a string you may\n"
|
|
647
|
+
" want to use alternatives such as the [splitter package](https://hex.pm/packages/splitter).\n"
|
|
648
|
+
"\n"
|
|
649
|
+
" ## Examples\n"
|
|
650
|
+
"\n"
|
|
651
|
+
" ```gleam\n"
|
|
652
|
+
" pop_grapheme(\"gleam\")\n"
|
|
653
|
+
" // -> Ok(#(\"g\", \"leam\"))\n"
|
|
654
|
+
" ```\n"
|
|
655
|
+
"\n"
|
|
656
|
+
" ```gleam\n"
|
|
657
|
+
" pop_grapheme(\"\")\n"
|
|
658
|
+
" // -> Error(Nil)\n"
|
|
659
|
+
" ```\n"
|
|
660
|
+
).
|
|
661
|
+
-spec pop_grapheme(binary()) -> {ok, {binary(), binary()}} | {error, nil}.
|
|
662
|
+
pop_grapheme(String) ->
|
|
663
|
+
gleam_stdlib:string_pop_grapheme(String).
|
|
664
|
+
|
|
665
|
+
-file("src/gleam/string.gleam", 647).
|
|
666
|
+
-spec to_graphemes_loop(binary(), list(binary())) -> list(binary()).
|
|
667
|
+
to_graphemes_loop(String, Acc) ->
|
|
668
|
+
case gleam_stdlib:string_pop_grapheme(String) of
|
|
669
|
+
{ok, {Grapheme, Rest}} ->
|
|
670
|
+
to_graphemes_loop(Rest, [Grapheme | Acc]);
|
|
671
|
+
|
|
672
|
+
{error, _} ->
|
|
673
|
+
Acc
|
|
674
|
+
end.
|
|
675
|
+
|
|
676
|
+
-file("src/gleam/string.gleam", 641).
|
|
677
|
+
?DOC(
|
|
678
|
+
" Converts a `String` to a list of\n"
|
|
679
|
+
" [graphemes](https://en.wikipedia.org/wiki/Grapheme).\n"
|
|
680
|
+
"\n"
|
|
681
|
+
" ```gleam\n"
|
|
682
|
+
" to_graphemes(\"abc\")\n"
|
|
683
|
+
" // -> [\"a\", \"b\", \"c\"]\n"
|
|
684
|
+
" ```\n"
|
|
685
|
+
).
|
|
686
|
+
-spec to_graphemes(binary()) -> list(binary()).
|
|
687
|
+
to_graphemes(String) ->
|
|
688
|
+
_pipe = String,
|
|
689
|
+
_pipe@1 = to_graphemes_loop(_pipe, []),
|
|
690
|
+
lists:reverse(_pipe@1).
|
|
691
|
+
|
|
692
|
+
-file("src/gleam/string.gleam", 333).
|
|
693
|
+
?DOC(
|
|
694
|
+
" Creates a list of `String`s by splitting a given string on a given substring.\n"
|
|
695
|
+
"\n"
|
|
696
|
+
" ## Examples\n"
|
|
697
|
+
"\n"
|
|
698
|
+
" ```gleam\n"
|
|
699
|
+
" split(\"home/gleam/desktop/\", on: \"/\")\n"
|
|
700
|
+
" // -> [\"home\", \"gleam\", \"desktop\", \"\"]\n"
|
|
701
|
+
" ```\n"
|
|
702
|
+
).
|
|
703
|
+
-spec split(binary(), binary()) -> list(binary()).
|
|
704
|
+
split(X, Substring) ->
|
|
705
|
+
case Substring of
|
|
706
|
+
<<""/utf8>> ->
|
|
707
|
+
to_graphemes(X);
|
|
708
|
+
|
|
709
|
+
_ ->
|
|
710
|
+
_pipe = X,
|
|
711
|
+
_pipe@1 = gleam_stdlib:identity(_pipe),
|
|
712
|
+
_pipe@2 = gleam@string_tree:split(_pipe@1, Substring),
|
|
713
|
+
gleam@list:map(_pipe@2, fun unicode:characters_to_binary/1)
|
|
714
|
+
end.
|
|
715
|
+
|
|
716
|
+
-file("src/gleam/string.gleam", 694).
|
|
717
|
+
-spec to_utf_codepoints_loop(bitstring(), list(integer())) -> list(integer()).
|
|
718
|
+
to_utf_codepoints_loop(Bit_array, Acc) ->
|
|
719
|
+
case Bit_array of
|
|
720
|
+
<<First/utf8, Rest/binary>> ->
|
|
721
|
+
to_utf_codepoints_loop(Rest, [First | Acc]);
|
|
722
|
+
|
|
723
|
+
_ ->
|
|
724
|
+
lists:reverse(Acc)
|
|
725
|
+
end.
|
|
726
|
+
|
|
727
|
+
-file("src/gleam/string.gleam", 689).
|
|
728
|
+
-spec do_to_utf_codepoints(binary()) -> list(integer()).
|
|
729
|
+
do_to_utf_codepoints(String) ->
|
|
730
|
+
to_utf_codepoints_loop(<<String/binary>>, []).
|
|
731
|
+
|
|
732
|
+
-file("src/gleam/string.gleam", 684).
|
|
733
|
+
?DOC(
|
|
734
|
+
" Converts a `String` to a `List` of `UtfCodepoint`.\n"
|
|
735
|
+
"\n"
|
|
736
|
+
" See <https://en.wikipedia.org/wiki/Code_point> and\n"
|
|
737
|
+
" <https://en.wikipedia.org/wiki/Unicode#Codespace_and_Code_Points> for an\n"
|
|
738
|
+
" explanation on code points.\n"
|
|
739
|
+
"\n"
|
|
740
|
+
" ## Examples\n"
|
|
741
|
+
"\n"
|
|
742
|
+
" ```gleam\n"
|
|
743
|
+
" \"a\" |> to_utf_codepoints\n"
|
|
744
|
+
" // -> [UtfCodepoint(97)]\n"
|
|
745
|
+
" ```\n"
|
|
746
|
+
"\n"
|
|
747
|
+
" ```gleam\n"
|
|
748
|
+
" // Semantically the same as:\n"
|
|
749
|
+
" // [\"🏳\", \"️\", \"\", \"🌈\"] or:\n"
|
|
750
|
+
" // [waving_white_flag, variant_selector_16, zero_width_joiner, rainbow]\n"
|
|
751
|
+
" \"🏳️🌈\" |> to_utf_codepoints\n"
|
|
752
|
+
" // -> [\n"
|
|
753
|
+
" // UtfCodepoint(127987),\n"
|
|
754
|
+
" // UtfCodepoint(65039),\n"
|
|
755
|
+
" // UtfCodepoint(8205),\n"
|
|
756
|
+
" // UtfCodepoint(127752),\n"
|
|
757
|
+
" // ]\n"
|
|
758
|
+
" ```\n"
|
|
759
|
+
).
|
|
760
|
+
-spec to_utf_codepoints(binary()) -> list(integer()).
|
|
761
|
+
to_utf_codepoints(String) ->
|
|
762
|
+
do_to_utf_codepoints(String).
|
|
763
|
+
|
|
764
|
+
-file("src/gleam/string.gleam", 734).
|
|
765
|
+
?DOC(
|
|
766
|
+
" Converts a `List` of `UtfCodepoint`s to a `String`.\n"
|
|
767
|
+
"\n"
|
|
768
|
+
" See <https://en.wikipedia.org/wiki/Code_point> and\n"
|
|
769
|
+
" <https://en.wikipedia.org/wiki/Unicode#Codespace_and_Code_Points> for an\n"
|
|
770
|
+
" explanation on code points.\n"
|
|
771
|
+
"\n"
|
|
772
|
+
" ## Examples\n"
|
|
773
|
+
"\n"
|
|
774
|
+
" ```gleam\n"
|
|
775
|
+
" let assert Ok(a) = utf_codepoint(97)\n"
|
|
776
|
+
" let assert Ok(b) = utf_codepoint(98)\n"
|
|
777
|
+
" let assert Ok(c) = utf_codepoint(99)\n"
|
|
778
|
+
" from_utf_codepoints([a, b, c])\n"
|
|
779
|
+
" // -> \"abc\"\n"
|
|
780
|
+
" ```\n"
|
|
781
|
+
).
|
|
782
|
+
-spec from_utf_codepoints(list(integer())) -> binary().
|
|
783
|
+
from_utf_codepoints(Utf_codepoints) ->
|
|
784
|
+
gleam_stdlib:utf_codepoint_list_to_string(Utf_codepoints).
|
|
785
|
+
|
|
786
|
+
-file("src/gleam/string.gleam", 740).
|
|
787
|
+
?DOC(
|
|
788
|
+
" Converts an integer to a `UtfCodepoint`.\n"
|
|
789
|
+
"\n"
|
|
790
|
+
" Returns an `Error` if the integer does not represent a valid UTF codepoint.\n"
|
|
791
|
+
).
|
|
792
|
+
-spec utf_codepoint(integer()) -> {ok, integer()} | {error, nil}.
|
|
793
|
+
utf_codepoint(Value) ->
|
|
794
|
+
case Value of
|
|
795
|
+
I when I > 1114111 ->
|
|
796
|
+
{error, nil};
|
|
797
|
+
|
|
798
|
+
I@1 when (I@1 >= 55296) andalso (I@1 =< 57343) ->
|
|
799
|
+
{error, nil};
|
|
800
|
+
|
|
801
|
+
I@2 when I@2 < 0 ->
|
|
802
|
+
{error, nil};
|
|
803
|
+
|
|
804
|
+
I@3 ->
|
|
805
|
+
{ok, gleam_stdlib:identity(I@3)}
|
|
806
|
+
end.
|
|
807
|
+
|
|
808
|
+
-file("src/gleam/string.gleam", 761).
|
|
809
|
+
?DOC(
|
|
810
|
+
" Converts a `UtfCodepoint` to its ordinal code point value.\n"
|
|
811
|
+
"\n"
|
|
812
|
+
" ## Examples\n"
|
|
813
|
+
"\n"
|
|
814
|
+
" ```gleam\n"
|
|
815
|
+
" let assert [utf_codepoint, ..] = to_utf_codepoints(\"💜\")\n"
|
|
816
|
+
" utf_codepoint_to_int(utf_codepoint)\n"
|
|
817
|
+
" // -> 128156\n"
|
|
818
|
+
" ```\n"
|
|
819
|
+
).
|
|
820
|
+
-spec utf_codepoint_to_int(integer()) -> integer().
|
|
821
|
+
utf_codepoint_to_int(Cp) ->
|
|
822
|
+
gleam_stdlib:identity(Cp).
|
|
823
|
+
|
|
824
|
+
-file("src/gleam/string.gleam", 778).
|
|
825
|
+
?DOC(
|
|
826
|
+
" Converts a `String` into `Option(String)` where an empty `String` becomes\n"
|
|
827
|
+
" `None`.\n"
|
|
828
|
+
"\n"
|
|
829
|
+
" ## Examples\n"
|
|
830
|
+
"\n"
|
|
831
|
+
" ```gleam\n"
|
|
832
|
+
" to_option(\"\")\n"
|
|
833
|
+
" // -> None\n"
|
|
834
|
+
" ```\n"
|
|
835
|
+
"\n"
|
|
836
|
+
" ```gleam\n"
|
|
837
|
+
" to_option(\"hats\")\n"
|
|
838
|
+
" // -> Some(\"hats\")\n"
|
|
839
|
+
" ```\n"
|
|
840
|
+
).
|
|
841
|
+
-spec to_option(binary()) -> gleam@option:option(binary()).
|
|
842
|
+
to_option(String) ->
|
|
843
|
+
case String of
|
|
844
|
+
<<""/utf8>> ->
|
|
845
|
+
none;
|
|
846
|
+
|
|
847
|
+
_ ->
|
|
848
|
+
{some, String}
|
|
849
|
+
end.
|
|
850
|
+
|
|
851
|
+
-file("src/gleam/string.gleam", 801).
|
|
852
|
+
?DOC(
|
|
853
|
+
" Returns the first grapheme cluster in a given `String` and wraps it in a\n"
|
|
854
|
+
" `Result(String, Nil)`. If the `String` is empty, it returns `Error(Nil)`.\n"
|
|
855
|
+
" Otherwise, it returns `Ok(String)`.\n"
|
|
856
|
+
"\n"
|
|
857
|
+
" ## Examples\n"
|
|
858
|
+
"\n"
|
|
859
|
+
" ```gleam\n"
|
|
860
|
+
" first(\"\")\n"
|
|
861
|
+
" // -> Error(Nil)\n"
|
|
862
|
+
" ```\n"
|
|
863
|
+
"\n"
|
|
864
|
+
" ```gleam\n"
|
|
865
|
+
" first(\"icecream\")\n"
|
|
866
|
+
" // -> Ok(\"i\")\n"
|
|
867
|
+
" ```\n"
|
|
868
|
+
).
|
|
869
|
+
-spec first(binary()) -> {ok, binary()} | {error, nil}.
|
|
870
|
+
first(String) ->
|
|
871
|
+
case gleam_stdlib:string_pop_grapheme(String) of
|
|
872
|
+
{ok, {First, _}} ->
|
|
873
|
+
{ok, First};
|
|
874
|
+
|
|
875
|
+
{error, E} ->
|
|
876
|
+
{error, E}
|
|
877
|
+
end.
|
|
878
|
+
|
|
879
|
+
-file("src/gleam/string.gleam", 827).
|
|
880
|
+
?DOC(
|
|
881
|
+
" Returns the last grapheme cluster in a given `String` and wraps it in a\n"
|
|
882
|
+
" `Result(String, Nil)`. If the `String` is empty, it returns `Error(Nil)`.\n"
|
|
883
|
+
" Otherwise, it returns `Ok(String)`.\n"
|
|
884
|
+
"\n"
|
|
885
|
+
" This function traverses the full string, so it runs in linear time with the\n"
|
|
886
|
+
" length of the string. Avoid using this in a loop.\n"
|
|
887
|
+
"\n"
|
|
888
|
+
" ## Examples\n"
|
|
889
|
+
"\n"
|
|
890
|
+
" ```gleam\n"
|
|
891
|
+
" last(\"\")\n"
|
|
892
|
+
" // -> Error(Nil)\n"
|
|
893
|
+
" ```\n"
|
|
894
|
+
"\n"
|
|
895
|
+
" ```gleam\n"
|
|
896
|
+
" last(\"icecream\")\n"
|
|
897
|
+
" // -> Ok(\"m\")\n"
|
|
898
|
+
" ```\n"
|
|
899
|
+
).
|
|
900
|
+
-spec last(binary()) -> {ok, binary()} | {error, nil}.
|
|
901
|
+
last(String) ->
|
|
902
|
+
case gleam_stdlib:string_pop_grapheme(String) of
|
|
903
|
+
{ok, {First, <<""/utf8>>}} ->
|
|
904
|
+
{ok, First};
|
|
905
|
+
|
|
906
|
+
{ok, {_, Rest}} ->
|
|
907
|
+
{ok, slice(Rest, -1, 1)};
|
|
908
|
+
|
|
909
|
+
{error, E} ->
|
|
910
|
+
{error, E}
|
|
911
|
+
end.
|
|
912
|
+
|
|
913
|
+
-file("src/gleam/string.gleam", 845).
|
|
914
|
+
?DOC(
|
|
915
|
+
" Creates a new `String` with the first grapheme in the input `String`\n"
|
|
916
|
+
" converted to uppercase and the remaining graphemes to lowercase.\n"
|
|
917
|
+
"\n"
|
|
918
|
+
" ## Examples\n"
|
|
919
|
+
"\n"
|
|
920
|
+
" ```gleam\n"
|
|
921
|
+
" capitalise(\"mamouna\")\n"
|
|
922
|
+
" // -> \"Mamouna\"\n"
|
|
923
|
+
" ```\n"
|
|
924
|
+
).
|
|
925
|
+
-spec capitalise(binary()) -> binary().
|
|
926
|
+
capitalise(String) ->
|
|
927
|
+
case gleam_stdlib:string_pop_grapheme(String) of
|
|
928
|
+
{ok, {First, Rest}} ->
|
|
929
|
+
append(string:uppercase(First), string:lowercase(Rest));
|
|
930
|
+
|
|
931
|
+
{error, _} ->
|
|
932
|
+
<<""/utf8>>
|
|
933
|
+
end.
|
|
934
|
+
|
|
935
|
+
-file("src/gleam/string.gleam", 876).
|
|
936
|
+
?DOC(
|
|
937
|
+
" Returns a `String` representation of a term in Gleam syntax.\n"
|
|
938
|
+
"\n"
|
|
939
|
+
" This may be occasionally useful for quick-and-dirty printing of values in\n"
|
|
940
|
+
" scripts. For error reporting and other uses prefer constructing strings by\n"
|
|
941
|
+
" pattern matching on the values.\n"
|
|
942
|
+
"\n"
|
|
943
|
+
" ## Limitations\n"
|
|
944
|
+
"\n"
|
|
945
|
+
" The output format of this function is not stable and could change at any\n"
|
|
946
|
+
" time. The output is not suitable for parsing.\n"
|
|
947
|
+
"\n"
|
|
948
|
+
" This function works using runtime reflection, so the output may not be\n"
|
|
949
|
+
" perfectly accurate for data structures where the runtime structure doesn't\n"
|
|
950
|
+
" hold enough information to determine the original syntax. For example,\n"
|
|
951
|
+
" tuples with an Erlang atom in the first position will be mistaken for Gleam\n"
|
|
952
|
+
" records.\n"
|
|
953
|
+
"\n"
|
|
954
|
+
" ## Security and safety\n"
|
|
955
|
+
"\n"
|
|
956
|
+
" There is no limit to how large the strings that this function can produce.\n"
|
|
957
|
+
" Be careful not to call this function with large data structures or you\n"
|
|
958
|
+
" could use very large amounts of memory, potentially causing runtime\n"
|
|
959
|
+
" problems.\n"
|
|
960
|
+
).
|
|
961
|
+
-spec inspect(any()) -> binary().
|
|
962
|
+
inspect(Term) ->
|
|
963
|
+
_pipe = Term,
|
|
964
|
+
_pipe@1 = gleam_stdlib:inspect(_pipe),
|
|
965
|
+
unicode:characters_to_binary(_pipe@1).
|
|
966
|
+
|
|
967
|
+
-file("src/gleam/string.gleam", 900).
|
|
968
|
+
?DOC(
|
|
969
|
+
" Returns the number of bytes in a `String`.\n"
|
|
970
|
+
"\n"
|
|
971
|
+
" This function runs in constant time on Erlang and in linear time on\n"
|
|
972
|
+
" JavaScript.\n"
|
|
973
|
+
"\n"
|
|
974
|
+
" ## Examples\n"
|
|
975
|
+
"\n"
|
|
976
|
+
" ```gleam\n"
|
|
977
|
+
" byte_size(\"🏳️⚧️🏳️🌈👩🏾❤️👨🏻\")\n"
|
|
978
|
+
" // -> 58\n"
|
|
979
|
+
" ```\n"
|
|
980
|
+
).
|
|
981
|
+
-spec byte_size(binary()) -> integer().
|
|
982
|
+
byte_size(String) ->
|
|
983
|
+
erlang:byte_size(String).
|
|
984
|
+
|
|
985
|
+
-file("src/gleam/string.gleam", 245).
|
|
986
|
+
?DOC(
|
|
987
|
+
" Drops *n* graphemes from the start of a `String`.\n"
|
|
988
|
+
"\n"
|
|
989
|
+
" This function runs in linear time with the number of graphemes to drop.\n"
|
|
990
|
+
"\n"
|
|
991
|
+
" ## Examples\n"
|
|
992
|
+
"\n"
|
|
993
|
+
" ```gleam\n"
|
|
994
|
+
" drop_start(from: \"The Lone Gunmen\", up_to: 2)\n"
|
|
995
|
+
" // -> \"e Lone Gunmen\"\n"
|
|
996
|
+
" ```\n"
|
|
997
|
+
).
|
|
998
|
+
-spec drop_start(binary(), integer()) -> binary().
|
|
999
|
+
drop_start(String, Num_graphemes) ->
|
|
1000
|
+
case Num_graphemes =< 0 of
|
|
1001
|
+
true ->
|
|
1002
|
+
String;
|
|
1003
|
+
|
|
1004
|
+
false ->
|
|
1005
|
+
Prefix = gleam_stdlib:slice(String, 0, Num_graphemes),
|
|
1006
|
+
Prefix_size = erlang:byte_size(Prefix),
|
|
1007
|
+
binary:part(
|
|
1008
|
+
String,
|
|
1009
|
+
Prefix_size,
|
|
1010
|
+
erlang:byte_size(String) - Prefix_size
|
|
1011
|
+
)
|
|
1012
|
+
end.
|