denoland / std

The Deno Standard Library
https://jsr.io/@std
MIT License
3.18k stars 623 forks source link

Ensure file name and export of single functions are the same #5660

Closed timreichen closed 3 months ago

timreichen commented 3 months ago

Is your feature request related to a problem? Please describe.

This is very untypical in std, where the export of a single function is normally named the same as the file name (camelcase instead of snakecase). Examples: semver/difference exports difference(), text/to_camel_case.ts exports toCamelCase()

There are some exceptions but this is mainly backed by the effort of single export files.

Describe the solution you'd like

Describe alternatives you've considered

Leave as is.

iuioiua commented 3 months ago

Can you please provide a list of all single symbol files that do conform and a list of those that don't?

timreichen commented 3 months ago

Can you please provide a list of all single symbol files that do conform and a list of those that don't?

These single export files do export correctly:

ulid/ulid.ts does export 'ulid'.
ulid/decode_time.ts does export 'decodeTime'.
ulid/monotonic_ulid.ts does export 'monotonicUlid'.
crypto/timing_safe_equal.ts does export 'timingSafeEqual'.
msgpack/decode.ts does export 'decode'.
msgpack/encode.ts does export 'encode'.
toml/parse.ts does export 'parse'.
toml/stringify.ts does export 'stringify'.
data_structures/red_black_tree.ts does export 'redBlackTree'.
data_structures/binary_search_tree.ts does export 'binarySearchTree'.
data_structures/binary_heap.ts does export 'binaryHeap'.
net/get_network_address.ts does export 'getNetworkAddress'.
net/get_available_port.ts does export 'getAvailablePort'.
dotenv/parse.ts does export 'parse'.
dotenv/stringify.ts does export 'stringify'.
regexp/escape.ts does export 'escape'.
cache/memoize.ts does export 'memoize'.
cache/lru_cache.ts does export 'lruCache'.
archive/tar.ts does export 'tar'.
bytes/repeat.ts does export 'repeat'.
bytes/index_of_needle.ts does export 'indexOfNeedle'.
bytes/copy.ts does export 'copy'.
bytes/ends_with.ts does export 'endsWith'.
bytes/concat.ts does export 'concat'.
bytes/starts_with.ts does export 'startsWith'.
bytes/includes_needle.ts does export 'includesNeedle'.
bytes/last_index_of_needle.ts does export 'lastIndexOfNeedle'.
bytes/equals.ts does export 'equals'.
datetime/parse.ts does export 'parse'.
datetime/format.ts does export 'format'.
datetime/week_of_year.ts does export 'weekOfYear'.
datetime/difference.ts does export 'difference'.
streams/delimiter_stream.ts does export 'delimiterStream'.
streams/byte_slice_stream.ts does export 'byteSliceStream'.
streams/fixed_chunk_stream.ts does export 'fixedChunkStream'.
streams/to_json.ts does export 'toJson'.
streams/to_blob.ts does export 'toBlob'.
streams/limited_bytes_transform_stream.ts does export 'limitedBytesTransformStream'.
streams/to_transform_stream.ts does export 'toTransformStream'.
streams/buffer.ts does export 'buffer'.
streams/concat_readable_streams.ts does export 'concatReadableStreams'.
streams/merge_readable_streams.ts does export 'mergeReadableStreams'.
streams/to_text.ts does export 'toText'.
streams/text_delimiter_stream.ts does export 'textDelimiterStream'.
streams/to_array_buffer.ts does export 'toArrayBuffer'.
streams/text_line_stream.ts does export 'textLineStream'.
streams/zip_readable_streams.ts does export 'zipReadableStreams'.
streams/limited_transform_stream.ts does export 'limitedTransformStream'.
streams/early_zip_readable_streams.ts does export 'earlyZipReadableStreams'.
path/posix/is_absolute.ts does export 'isAbsolute'.
path/posix/extname.ts does export 'extname'.
path/posix/parse.ts does export 'parse'.
path/posix/glob_to_regexp.ts does export 'globToRegexp'.
path/posix/basename.ts does export 'basename'.
path/posix/from_file_url.ts does export 'fromFileUrl'.
path/posix/common.ts does export 'common'.
path/posix/relative.ts does export 'relative'.
path/posix/join.ts does export 'join'.
path/posix/format.ts does export 'format'.
path/posix/to_file_url.ts does export 'toFileUrl'.
path/posix/normalize.ts does export 'normalize'.
path/posix/dirname.ts does export 'dirname'.
path/posix/normalize_glob.ts does export 'normalizeGlob'.
path/posix/is_glob.ts does export 'isGlob'.
path/posix/to_namespaced_path.ts does export 'toNamespacedPath'.
path/posix/resolve.ts does export 'resolve'.
path/posix/join_globs.ts does export 'joinGlobs'.
path/is_absolute.ts does export 'isAbsolute'.
path/extname.ts does export 'extname'.
path/parse.ts does export 'parse'.
path/glob_to_regexp.ts does export 'globToRegexp'.
path/basename.ts does export 'basename'.
path/from_file_url.ts does export 'fromFileUrl'.
path/common.ts does export 'common'.
path/relative.ts does export 'relative'.
path/join.ts does export 'join'.
path/format.ts does export 'format'.
path/to_file_url.ts does export 'toFileUrl'.
path/normalize.ts does export 'normalize'.
path/dirname.ts does export 'dirname'.
path/normalize_glob.ts does export 'normalizeGlob'.
path/is_glob.ts does export 'isGlob'.
path/to_namespaced_path.ts does export 'toNamespacedPath'.
path/resolve.ts does export 'resolve'.
path/windows/is_absolute.ts does export 'isAbsolute'.
path/windows/extname.ts does export 'extname'.
path/windows/parse.ts does export 'parse'.
path/windows/glob_to_regexp.ts does export 'globToRegexp'.
path/windows/basename.ts does export 'basename'.
path/windows/from_file_url.ts does export 'fromFileUrl'.
path/windows/common.ts does export 'common'.
path/windows/relative.ts does export 'relative'.
path/windows/join.ts does export 'join'.
path/windows/format.ts does export 'format'.
path/windows/to_file_url.ts does export 'toFileUrl'.
path/windows/normalize.ts does export 'normalize'.
path/windows/dirname.ts does export 'dirname'.
path/windows/normalize_glob.ts does export 'normalizeGlob'.
path/windows/is_glob.ts does export 'isGlob'.
path/windows/to_namespaced_path.ts does export 'toNamespacedPath'.
path/windows/resolve.ts does export 'resolve'.
path/windows/join_globs.ts does export 'joinGlobs'.
path/join_globs.ts does export 'joinGlobs'.
webgpu/describe_texture_format.ts does export 'describeTextureFormat'.
webgpu/create_capture.ts does export 'createCapture'.
async/debounce.ts does export 'debounce'.
async/deadline.ts does export 'deadline'.
async/delay.ts does export 'delay'.
async/abortable.ts does export 'abortable'.
async/mux_async_iterator.ts does export 'muxAsyncIterator'.
async/tee.ts does export 'tee'.
io/slice_long_to_bytes.ts does export 'sliceLongToBytes'.
io/copy_n.ts does export 'copyN'.
io/to_readable_stream.ts does export 'toReadableStream'.
io/reader_from_stream_reader.ts does export 'readerFromStreamReader'.
io/read_lines.ts does export 'readLines'.
io/read_delim.ts does export 'readDelim'.
io/buffer.ts does export 'buffer'.
io/limited_reader.ts does export 'limitedReader'.
io/to_writable_stream.ts does export 'toWritableStream'.
io/read_long.ts does export 'readLong'.
io/read_short.ts does export 'readShort'.
io/read_int.ts does export 'readInt'.
io/multi_reader.ts does export 'multiReader'.
io/copy.ts does export 'copy'.
io/string_writer.ts does export 'stringWriter'.
io/read_string_delim.ts does export 'readStringDelim'.
io/string_reader.ts does export 'stringReader'.
internal/format.ts does export 'format'.
html/is_valid_custom_element_name.ts does export 'isValidCustomElementName'.
cli/spinner.ts does export 'spinner'.
cli/prompt_secret.ts does export 'promptSecret'.
cli/parse_args.ts does export 'parseArgs'.
cli/unicode_width.ts does export 'unicodeWidth'.
assert/match.ts does export 'match'.
assert/less.ts does export 'less'.
assert/greater.ts does export 'greater'.
assert/rejects.ts does export 'rejects'.
assert/assertion_error.ts does export 'assertionError'.
assert/strict_equals.ts does export 'strictEquals'.
assert/less_or_equal.ts does export 'lessOrEqual'.
assert/greater_or_equal.ts does export 'greaterOrEqual'.
assert/almost_equals.ts does export 'almostEquals'.
assert/fail.ts does export 'fail'.
assert/is_error.ts does export 'isError'.
assert/not_equals.ts does export 'notEquals'.
assert/false.ts does export 'false'.
assert/assert.ts does export 'assert'.
assert/unimplemented.ts does export 'unimplemented'.
assert/string_includes.ts does export 'stringIncludes'.
assert/not_strict_equals.ts does export 'notStrictEquals'.
assert/instance_of.ts does export 'instanceOf'.
assert/equal.ts does export 'equal'.
assert/array_includes.ts does export 'arrayIncludes'.
assert/unreachable.ts does export 'unreachable'.
assert/not_match.ts does export 'notMatch'.
assert/object_match.ts does export 'objectMatch'.
assert/throws.ts does export 'throws'.
assert/equals.ts does export 'equals'.
assert/exists.ts does export 'exists'.
assert/not_instance_of.ts does export 'notInstanceOf'.
url/extname.ts does export 'extname'.
url/basename.ts does export 'basename'.
url/join.ts does export 'join'.
url/normalize.ts does export 'normalize'.
url/dirname.ts does export 'dirname'.
semver/try_parse_range.ts does export 'tryParseRange'.
semver/is_range.ts does export 'isRange'.
semver/compare.ts does export 'compare'.
semver/satisfies.ts does export 'satisfies'.
semver/less_than.ts does export 'lessThan'.
semver/parse.ts does export 'parse'.
semver/greater_than_range.ts does export 'greaterThanRange'.
semver/format_range.ts does export 'formatRange'.
semver/less_or_equal.ts does export 'lessOrEqual'.
semver/greater_or_equal.ts does export 'greaterOrEqual'.
semver/parse_range.ts does export 'parseRange'.
semver/not_equals.ts does export 'notEquals'.
semver/format.ts does export 'format'.
semver/range_intersects.ts does export 'rangeIntersects'.
semver/less_than_range.ts does export 'lessThanRange'.
semver/increment.ts does export 'increment'.
semver/difference.ts does export 'difference'.
semver/min_satisfying.ts does export 'minSatisfying'.
semver/can_parse.ts does export 'canParse'.
semver/greater_than.ts does export 'greaterThan'.
semver/max_satisfying.ts does export 'maxSatisfying'.
semver/is_semver.ts does export 'isSemver'.
semver/try_parse.ts does export 'tryParse'.
semver/equals.ts does export 'equals'.
ini/parse.ts does export 'parse'.
ini/stringify.ts does export 'stringify'.
json/parse_stream.ts does export 'parseStream'.
json/concatenated_json_parse_stream.ts does export 'concatenatedJsonParseStream'.
json/stringify_stream.ts does export 'stringifyStream'.
csv/parse_stream.ts does export 'parseStream'.
csv/parse.ts does export 'parse'.
csv/stringify_stream.ts does export 'stringifyStream'.
csv/stringify.ts does export 'stringify'.
jsonc/parse.ts does export 'parse'.
media_types/parse_media_type.ts does export 'parseMediaType'.
media_types/format_media_type.ts does export 'formatMediaType'.
media_types/all_extensions.ts does export 'allExtensions'.
media_types/extension.ts does export 'extension'.
media_types/type_by_extension.ts does export 'typeByExtension'.
media_types/content_type.ts does export 'contentType'.
media_types/get_charset.ts does export 'getCharset'.
yaml/stringify.ts does export 'stringify'.
log/info.ts does export 'info'.
log/base_handler.ts does export 'baseHandler'.
log/debug.ts does export 'debug'.
log/setup.ts does export 'setup'.
log/rotating_file_handler.ts does export 'rotatingFileHandler'.
log/get_logger.ts does export 'getLogger'.
log/warn.ts does export 'warn'.
log/error.ts does export 'error'.
log/console_handler.ts does export 'consoleHandler'.
log/file_handler.ts does export 'fileHandler'.
log/critical.ts does export 'critical'.
text/compare_similarity.ts does export 'compareSimilarity'.
text/word_similarity_sort.ts does export 'wordSimilaritySort'.
text/levenshtein_distance.ts does export 'levenshteinDistance'.
text/to_camel_case.ts does export 'toCamelCase'.
text/closest_string.ts does export 'closestString'.
text/to_kebab_case.ts does export 'toKebabCase'.
text/to_constant_case.ts does export 'toConstantCase'.
text/to_snake_case.ts does export 'toSnakeCase'.
text/to_pascal_case.ts does export 'toPascalCase'.
collections/associate_with.ts does export 'associateWith'.
collections/union.ts does export 'union'.
collections/invert_by.ts does export 'invertBy'.
collections/filter_values.ts does export 'filterValues'.
collections/max_of.ts does export 'maxOf'.
collections/max_by.ts does export 'maxBy'.
collections/deep_merge.ts does export 'deepMerge'.
collections/max_with.ts does export 'maxWith'.
collections/invert.ts does export 'invert'.
collections/drop_while.ts does export 'dropWhile'.
collections/distinct_by.ts does export 'distinctBy'.
collections/sample.ts does export 'sample'.
collections/aggregate_groups.ts does export 'aggregateGroups'.
collections/drop_last_while.ts does export 'dropLastWhile'.
collections/filter_entries.ts does export 'filterEntries'.
collections/partition_entries.ts does export 'partitionEntries'.
collections/reduce_groups.ts does export 'reduceGroups'.
collections/take_last_while.ts does export 'takeLastWhile'.
collections/running_reduce.ts does export 'runningReduce'.
collections/find_single.ts does export 'findSingle'.
collections/includes_value.ts does export 'includesValue'.
collections/intersect.ts does export 'intersect'.
collections/first_not_nullish_of.ts does export 'firstNotNullishOf'.
collections/zip.ts does export 'zip'.
collections/pick.ts does export 'pick'.
collections/map_values.ts does export 'mapValues'.
collections/join_to_string.ts does export 'joinToString'.
collections/map_keys.ts does export 'mapKeys'.
collections/chunk.ts does export 'chunk'.
collections/take_while.ts does export 'takeWhile'.
collections/permutations.ts does export 'permutations'.
collections/associate_by.ts does export 'associateBy'.
collections/sort_by.ts does export 'sortBy'.
collections/sum_of.ts does export 'sumOf'.
collections/unzip.ts does export 'unzip'.
collections/map_not_nullish.ts does export 'mapNotNullish'.
collections/without_all.ts does export 'withoutAll'.
collections/sliding_windows.ts does export 'slidingWindows'.
collections/partition.ts does export 'partition'.
collections/map_entries.ts does export 'mapEntries'.
collections/min_with.ts does export 'minWith'.
collections/min_by.ts does export 'minBy'.
collections/min_of.ts does export 'minOf'.
collections/distinct.ts does export 'distinct'.
collections/filter_keys.ts does export 'filterKeys'.
collections/omit.ts does export 'omit'.
expect/fn.ts does export 'fn'.
expect/expect.ts does export 'expect'.
assert/match.ts does not export 'match': exports assertMatch.
assert/less.ts does not export 'less': exports assertLess.
assert/greater.ts does not export 'greater': exports assertGreater.
assert/rejects.ts does not export 'rejects': exports assertRejects.
assert/strict_equals.ts does not export 'strictEquals': exports assertStrictEquals.
assert/less_or_equal.ts does not export 'lessOrEqual': exports assertLessOrEqual.
assert/greater_or_equal.ts does not export 'greaterOrEqual': exports assertGreaterOrEqual.
assert/almost_equals.ts does not export 'almostEquals': exports assertAlmostEquals.
assert/is_error.ts does not export 'isError': exports assertIsError.
assert/not_equals.ts does not export 'notEquals': exports assertNotEquals.
assert/false.ts does not export 'false': exports assertFalse.
assert/string_includes.ts does not export 'stringIncludes': exports assertStringIncludes.
assert/not_strict_equals.ts does not export 'notStrictEquals': exports assertNotStrictEquals.
assert/instance_of.ts does not export 'instanceOf': exports assertInstanceOf.
assert/array_includes.ts does not export 'arrayIncludes': exports assertArrayIncludes.
assert/not_match.ts does not export 'notMatch': exports assertNotMatch.
assert/object_match.ts does not export 'objectMatch': exports assertObjectMatch.
assert/throws.ts does not export 'throws': exports assertThrows.
assert/equals.ts does not export 'equals': exports assertEquals.
assert/exists.ts does not export 'exists': exports assertExists.
assert/not_instance_of.ts does not export 'notInstanceOf': exports assertNotInstanceOf.
json/parse_stream.ts does not export 'parseStream': exports JsonParseStream.
json/stringify_stream.ts does not export 'stringifyStream': exports JsonStringifyStream.
csv/parse_stream.ts does not export 'parseStream': exports CsvParseStream.
csv/stringify_stream.ts does not export 'stringifyStream': exports CsvStringifyStream.

These single export file names probably should be changed (v4 oddly does not have a generate() function like the other uuid versions):

front_matter/toml.ts does not export 'toml': exports extract.
front_matter/json.ts does not export 'json': exports extract.
front_matter/any.ts does not export 'any': exports extract.
front_matter/yaml.ts does not export 'yaml': exports extract.
fmt/bytes.ts does not export 'bytes': exports format.
fmt/duration.ts does not export 'duration': exports format.
webgpu/texture_with_data.ts does not export 'textureWithData': exports createTextureWithData.
async/pool.ts does not export 'pool': exports pooledMap.
testing/types.ts does not export 'types': exports assertType.
media_types/vendor/db.ts does not export 'db': exports default.
uuid/v4.ts does not export 'v4': exports validate.
kt3k commented 3 months ago

fmt/bytes.ts does not export 'bytes': exports format. fmt/duration.ts does not export 'duration': exports format.

These two will conflict if we try to rename them format. Also all fmt endpoints don't follow single export pattern. I see different consistency existing in fmt package.

testing/types.ts does not export 'types': exports assertType.

There are many other type assertion utilities defined in this endpoint. I'd rather see this endpoint is collective export endpoint.

uuid/v4.ts does not export 'v4': exports validate.

This seems designed this way to make it consistent with other endpoints in the package

kt3k commented 3 months ago

Single export pattern is what we prefer when it makes sense, but there are many exception packages which don't follow it like http testing, fmt, etc. In my view the pattern is not mandatory. I personally don't consider these as errors.

iuioiua commented 3 months ago

As Yoshiya points out, there are reasons for the current module names that take the package and its modules into consideration as a whole. However, I understand the concern regarding seemingly inconsistent module names. But these aren't sufficient enough to justify making breaking changes to stable packages now. Closing as there's nothing to action here. Thanks for the input, either way, Tim!

timreichen commented 3 months ago

As Yoshiya points out, there are reasons for the current module names that take the package and its modules into consideration as a whole. However, I understand the concern regarding seemingly inconsistent module names. But these aren't sufficient enough to justify making breaking changes to stable packages now. Closing as there's nothing to action here. Thanks for the input, either way, Tim!

Thanks for the clarification. While I agree that some modules may not follow that convention for various reasons, front_matter is a different matter. These function names overlap and as such are re-exported differently in the mod.ts. fmt with name overlaps doesn't have a mod.ts. So in my eyes this is more like a bug where mod exports are not the same as in the single export files.