structured-outputs 0.1.0-beta.2 → 0.1.0-beta.21
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +77 -6
- package/esm/ResponseFormat.d.ts +18 -11
- package/esm/ResponseFormat.d.ts.map +1 -1
- package/esm/ResponseFormat.js +57 -5
- package/esm/ResponseFormat.js.map +1 -1
- package/esm/Tool.d.ts +13 -0
- package/esm/Tool.d.ts.map +1 -0
- package/esm/Tool.js +17 -0
- package/esm/Tool.js.map +1 -0
- package/esm/_dnt.polyfills.d.ts +12 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +16 -0
- package/esm/_dnt.polyfills.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts +6 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.js +19 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts +41 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.js +51 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts +37 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.js +45 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts +33 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.js +41 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts +38 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.js +51 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts +322 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.js +96 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts +23 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.js +28 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts +26 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.js +39 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts +26 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.js +33 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts +25 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.js +34 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts +32 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.js +43 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts +36 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.js +46 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts +35 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.js +46 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts +31 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.js +45 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts +32 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.js +42 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts +29 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.js +39 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts +25 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.js +36 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert.d.ts +29 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert.js +29 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts +34 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.js +46 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts +75 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.js +59 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts +37 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.js +47 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts +33 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.js +42 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts +32 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.js +43 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts +71 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.js +13 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts +117 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.js +15 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts +61 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.js +17 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts +29 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.js +41 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts +115 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.js +15 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts +61 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.js +17 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts +25 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.js +37 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/mod.d.ts +73 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/mod.js +75 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/mod.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/omit.d.ts +24 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/omit.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/omit.js +29 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/omit.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition.d.ts +60 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition.js +16 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts +39 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.js +54 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts +27 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.js +58 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/pick.d.ts +25 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/pick.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/pick.js +33 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/pick.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts +35 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.js +40 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts +27 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.js +32 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sample.d.ts +24 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sample.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sample.js +35 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sample.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts +66 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.js +57 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts +161 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.js +30 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts +29 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.js +37 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts +27 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.js +34 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts +30 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.js +39 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/union.d.ts +24 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/union.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/union.js +34 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/union.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts +32 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.js +46 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts +23 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.js +28 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.js.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/zip.d.ts +34 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/zip.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/zip.js +43 -0
- package/esm/deps/jsr.io/@std/collections/1.0.9/zip.js.map +1 -0
- package/esm/mod.d.ts +3 -14
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +3 -10
- package/esm/mod.js.map +1 -1
- package/esm/oai.d.ts +5 -0
- package/esm/oai.d.ts.map +1 -0
- package/esm/oai.js +2 -0
- package/esm/oai.js.map +1 -0
- package/esm/types/Ref.d.ts +4 -0
- package/esm/types/Ref.d.ts.map +1 -0
- package/esm/types/Ref.js +11 -0
- package/esm/types/Ref.js.map +1 -0
- package/esm/types/RootTy.d.ts +8 -0
- package/esm/types/RootTy.d.ts.map +1 -0
- package/esm/types/RootTy.js +19 -0
- package/esm/types/RootTy.js.map +1 -0
- package/esm/types/Ty.d.ts +27 -0
- package/esm/types/Ty.d.ts.map +1 -0
- package/esm/types/Ty.js +17 -0
- package/esm/types/Ty.js.map +1 -0
- package/esm/types/array.d.ts +3 -0
- package/esm/types/array.d.ts.map +1 -0
- package/esm/types/array.js +9 -0
- package/esm/types/array.js.map +1 -0
- package/esm/types/constant.d.ts +3 -0
- package/esm/types/constant.d.ts.map +1 -0
- package/esm/types/constant.js +8 -0
- package/esm/types/constant.js.map +1 -0
- package/esm/types/constantUnion.d.ts +3 -0
- package/esm/types/constantUnion.d.ts.map +1 -0
- package/esm/types/constantUnion.js +25 -0
- package/esm/types/constantUnion.js.map +1 -0
- package/esm/types/leaves.d.ts +6 -0
- package/esm/types/leaves.d.ts.map +1 -0
- package/esm/types/leaves.js +18 -0
- package/esm/types/leaves.js.map +1 -0
- package/esm/types/mod.d.ts +11 -0
- package/esm/types/mod.d.ts.map +1 -0
- package/esm/types/mod.js +11 -0
- package/esm/types/mod.js.map +1 -0
- package/esm/types/object.d.ts +6 -0
- package/esm/types/object.d.ts.map +1 -0
- package/esm/{object.js → types/object.js} +4 -4
- package/esm/types/object.js.map +1 -0
- package/esm/types/std/Option.d.ts +7 -0
- package/esm/types/std/Option.d.ts.map +1 -0
- package/esm/types/std/Option.js +9 -0
- package/esm/types/std/Option.js.map +1 -0
- package/esm/types/std/Wrapper.d.ts +7 -0
- package/esm/types/std/Wrapper.d.ts.map +1 -0
- package/esm/types/std/Wrapper.js +5 -0
- package/esm/types/std/Wrapper.js.map +1 -0
- package/esm/types/std/mod.d.ts +3 -0
- package/esm/types/std/mod.d.ts.map +1 -0
- package/esm/types/std/mod.js +3 -0
- package/esm/types/std/mod.js.map +1 -0
- package/esm/types/taggedUnion.d.ts +8 -0
- package/esm/types/taggedUnion.d.ts.map +1 -0
- package/esm/types/taggedUnion.js +20 -0
- package/esm/types/taggedUnion.js.map +1 -0
- package/esm/util/phantoms.d.ts +2 -0
- package/esm/util/phantoms.d.ts.map +1 -0
- package/esm/util/phantoms.js +4 -0
- package/esm/util/phantoms.js.map +1 -0
- package/esm/util/recombineTaggedTemplateArgs.d.ts +2 -0
- package/esm/util/recombineTaggedTemplateArgs.d.ts.map +1 -0
- package/esm/util/recombineTaggedTemplateArgs.js +4 -0
- package/esm/util/recombineTaggedTemplateArgs.js.map +1 -0
- package/package.json +7 -9
- package/src/ResponseFormat.ts +80 -22
- package/src/Tool.ts +38 -0
- package/src/_dnt.polyfills.ts +27 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/_utils.ts +26 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.ts +62 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/associate_by.ts +50 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/associate_with.ts +46 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/chunk.ts +56 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/deep_merge.ts +578 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/distinct.ts +29 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/distinct_by.ts +42 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/drop_last_while.ts +36 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/drop_while.ts +39 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/filter_entries.ts +48 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/filter_keys.ts +51 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/filter_values.ts +51 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/find_single.ts +48 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.ts +47 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/includes_value.ts +45 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/intersect.ts +35 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/invert.ts +38 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/invert_by.ts +56 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/join_to_string.ts +109 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/map_entries.ts +53 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/map_keys.ts +47 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.ts +49 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/map_values.ts +96 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/max_by.ts +153 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/max_of.ts +90 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/max_with.ts +46 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/min_by.ts +151 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/min_of.ts +90 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/min_with.ts +42 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/mod.ts +76 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/omit.ts +34 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/partition.ts +85 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/partition_entries.ts +58 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/permutations.ts +66 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/pick.ts +34 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/reduce_groups.ts +45 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/running_reduce.ts +38 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/sample.ts +36 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/sliding_windows.ts +86 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/sort_by.ts +219 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/sum_of.ts +42 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/take_last_while.ts +37 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/take_while.ts +44 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/union.ts +36 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/unzip.ts +50 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/without_all.ts +28 -0
- package/src/deps/jsr.io/@std/collections/1.0.9/zip.ts +49 -0
- package/src/mod.ts +3 -18
- package/src/oai.ts +5 -0
- package/src/types/Ref.ts +16 -0
- package/src/types/RootTy.ts +40 -0
- package/src/types/Ty.ts +57 -0
- package/src/types/array.ts +9 -0
- package/src/types/constant.ts +8 -0
- package/src/types/constantUnion.ts +27 -0
- package/src/types/leaves.ts +21 -0
- package/src/types/mod.ts +10 -0
- package/src/types/object.ts +15 -0
- package/src/types/std/Option.ts +15 -0
- package/src/types/std/Wrapper.ts +8 -0
- package/src/types/std/mod.ts +2 -0
- package/src/types/taggedUnion.ts +28 -0
- package/src/util/phantoms.ts +3 -0
- package/src/util/recombineTaggedTemplateArgs.ts +6 -0
- package/esm/F.d.ts +0 -13
- package/esm/F.d.ts.map +0 -1
- package/esm/F.js +0 -10
- package/esm/F.js.map +0 -1
- package/esm/_base.d.ts +0 -13
- package/esm/_base.d.ts.map +0 -1
- package/esm/_base.js +0 -40
- package/esm/_base.js.map +0 -1
- package/esm/array.d.ts +0 -4
- package/esm/array.d.ts.map +0 -1
- package/esm/array.js +0 -9
- package/esm/array.js.map +0 -1
- package/esm/common.d.ts +0 -6
- package/esm/common.d.ts.map +0 -1
- package/esm/common.js +0 -2
- package/esm/common.js.map +0 -1
- package/esm/literal.d.ts +0 -4
- package/esm/literal.d.ts.map +0 -1
- package/esm/literal.js +0 -8
- package/esm/literal.js.map +0 -1
- package/esm/number.d.ts +0 -4
- package/esm/number.d.ts.map +0 -1
- package/esm/number.js +0 -8
- package/esm/number.js.map +0 -1
- package/esm/object.d.ts +0 -7
- package/esm/object.d.ts.map +0 -1
- package/esm/object.js.map +0 -1
- package/esm/schema.d.ts +0 -4
- package/esm/schema.d.ts.map +0 -1
- package/esm/schema.js +0 -9
- package/esm/schema.js.map +0 -1
- package/esm/string.d.ts +0 -4
- package/esm/string.d.ts.map +0 -1
- package/esm/string.js +0 -8
- package/esm/string.js.map +0 -1
- package/esm/union.d.ts +0 -6
- package/esm/union.d.ts.map +0 -1
- package/esm/union.js +0 -8
- package/esm/union.js.map +0 -1
- package/src/F.ts +0 -27
- package/src/_base.ts +0 -25
- package/src/array.ts +0 -11
- package/src/common.ts +0 -6
- package/src/literal.ts +0 -10
- package/src/number.ts +0 -10
- package/src/object.ts +0 -17
- package/src/schema.ts +0 -10
- package/src/string.ts +0 -10
- package/src/union.ts +0 -12
@@ -0,0 +1,219 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
/** Order option for {@linkcode SortByOptions}. */
|
5
|
+
export type Order = "asc" | "desc";
|
6
|
+
|
7
|
+
/** Options for {@linkcode sortBy}. */
|
8
|
+
export type SortByOptions = {
|
9
|
+
/**
|
10
|
+
* The order to sort the elements in.
|
11
|
+
*
|
12
|
+
* @default {"asc"}
|
13
|
+
*/
|
14
|
+
order: Order;
|
15
|
+
};
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Returns all elements in the given collection, sorted by their result using
|
19
|
+
* the given selector. The selector function is called only once for each
|
20
|
+
* element. Ascending or descending order can be specified through the `order`
|
21
|
+
* option. By default, the elements are sorted in ascending order.
|
22
|
+
*
|
23
|
+
* Note: If you want to process any iterable, use the new version of
|
24
|
+
* `sortBy` from `@std/collections/unstable-sort-by`.
|
25
|
+
*
|
26
|
+
* @typeParam T The type of the array elements.
|
27
|
+
*
|
28
|
+
* @param array The array to sort.
|
29
|
+
* @param selector The selector function to get the value to sort by.
|
30
|
+
* @param options The options for sorting.
|
31
|
+
*
|
32
|
+
* @returns A new array containing all elements sorted by the selector.
|
33
|
+
*
|
34
|
+
* @example Usage
|
35
|
+
* ```ts
|
36
|
+
* import { sortBy } from "@std/collections/sort-by";
|
37
|
+
* import { assertEquals } from "@std/assert";
|
38
|
+
*
|
39
|
+
* const people = [
|
40
|
+
* { name: "Anna", age: 34 },
|
41
|
+
* { name: "Kim", age: 42 },
|
42
|
+
* { name: "John", age: 23 },
|
43
|
+
* ];
|
44
|
+
* const sortedByAge = sortBy(people, (person) => person.age);
|
45
|
+
*
|
46
|
+
* assertEquals(sortedByAge, [
|
47
|
+
* { name: "John", age: 23 },
|
48
|
+
* { name: "Anna", age: 34 },
|
49
|
+
* { name: "Kim", age: 42 },
|
50
|
+
* ]);
|
51
|
+
*
|
52
|
+
* const sortedByAgeDesc = sortBy(people, (person) => person.age, { order: "desc" });
|
53
|
+
*
|
54
|
+
* assertEquals(sortedByAgeDesc, [
|
55
|
+
* { name: "Kim", age: 42 },
|
56
|
+
* { name: "Anna", age: 34 },
|
57
|
+
* { name: "John", age: 23 },
|
58
|
+
* ]);
|
59
|
+
* ```
|
60
|
+
*/
|
61
|
+
export function sortBy<T>(
|
62
|
+
array: readonly T[],
|
63
|
+
selector: (el: T) => number,
|
64
|
+
options?: SortByOptions,
|
65
|
+
): T[];
|
66
|
+
/**
|
67
|
+
* Returns all elements in the given collection, sorted by their result using
|
68
|
+
* the given selector. The selector function is called only once for each
|
69
|
+
* element. Ascending or descending order can be specified through the `order`
|
70
|
+
* option. By default, the elements are sorted in ascending order.
|
71
|
+
*
|
72
|
+
* @typeParam T The type of the array elements.
|
73
|
+
*
|
74
|
+
* @param array The array to sort.
|
75
|
+
* @param selector The selector function to get the value to sort by.
|
76
|
+
* @param options The options for sorting.
|
77
|
+
*
|
78
|
+
* @returns A new array containing all elements sorted by the selector.
|
79
|
+
*
|
80
|
+
* @example Usage
|
81
|
+
* ```ts
|
82
|
+
* import { sortBy } from "@std/collections/sort-by";
|
83
|
+
* import { assertEquals } from "@std/assert";
|
84
|
+
*
|
85
|
+
* const people = [
|
86
|
+
* { name: "Anna" },
|
87
|
+
* { name: "Kim" },
|
88
|
+
* { name: "John" },
|
89
|
+
* ];
|
90
|
+
* const sortedByName = sortBy(people, (it) => it.name);
|
91
|
+
*
|
92
|
+
* assertEquals(sortedByName, [
|
93
|
+
* { name: "Anna" },
|
94
|
+
* { name: "John" },
|
95
|
+
* { name: "Kim" },
|
96
|
+
* ]);
|
97
|
+
* ```
|
98
|
+
*/
|
99
|
+
export function sortBy<T>(
|
100
|
+
array: readonly T[],
|
101
|
+
selector: (el: T) => string,
|
102
|
+
options?: SortByOptions,
|
103
|
+
): T[];
|
104
|
+
/**
|
105
|
+
* Returns all elements in the given collection, sorted by their result using
|
106
|
+
* the given selector. The selector function is called only once for each
|
107
|
+
* element. Ascending or descending order can be specified through the `order`
|
108
|
+
* option. By default, the elements are sorted in ascending order.
|
109
|
+
*
|
110
|
+
* @typeParam T The type of the array elements.
|
111
|
+
*
|
112
|
+
* @param array The array to sort.
|
113
|
+
* @param selector The selector function to get the value to sort by.
|
114
|
+
* @param options The options for sorting.
|
115
|
+
*
|
116
|
+
* @returns A new array containing all elements sorted by the selector.
|
117
|
+
*
|
118
|
+
* @example Usage
|
119
|
+
* ```ts
|
120
|
+
* import { sortBy } from "@std/collections/sort-by";
|
121
|
+
* import { assertEquals } from "@std/assert";
|
122
|
+
*
|
123
|
+
* const people = [
|
124
|
+
* { name: "Anna", age: 34n },
|
125
|
+
* { name: "Kim", age: 42n },
|
126
|
+
* { name: "John", age: 23n },
|
127
|
+
* ];
|
128
|
+
*
|
129
|
+
* const sortedByAge = sortBy(people, (person) => person.age);
|
130
|
+
*
|
131
|
+
* assertEquals(sortedByAge, [
|
132
|
+
* { name: "John", age: 23n },
|
133
|
+
* { name: "Anna", age: 34n },
|
134
|
+
* { name: "Kim", age: 42n },
|
135
|
+
* ]);
|
136
|
+
* ```
|
137
|
+
*/
|
138
|
+
|
139
|
+
export function sortBy<T>(
|
140
|
+
array: readonly T[],
|
141
|
+
selector: (el: T) => bigint,
|
142
|
+
options?: SortByOptions,
|
143
|
+
): T[];
|
144
|
+
/**
|
145
|
+
* Returns all elements in the given collection, sorted by their result using
|
146
|
+
* the given selector. The selector function is called only once for each
|
147
|
+
* element. Ascending or descending order can be specified through the `order`
|
148
|
+
* option. By default, the elements are sorted in ascending order.
|
149
|
+
*
|
150
|
+
* @typeParam T The type of the array elements.
|
151
|
+
*
|
152
|
+
* @param array The array to sort.
|
153
|
+
* @param selector The selector function to get the value to sort by.
|
154
|
+
* @param options The options for sorting.
|
155
|
+
*
|
156
|
+
* @returns A new array containing all elements sorted by the selector.
|
157
|
+
*
|
158
|
+
* @example Usage
|
159
|
+
* ```ts
|
160
|
+
* import { sortBy } from "@std/collections/sort-by";
|
161
|
+
* import { assertEquals } from "@std/assert";
|
162
|
+
*
|
163
|
+
* const people = [
|
164
|
+
* { name: "Anna", startedAt: new Date("2020-01-01") },
|
165
|
+
* { name: "Kim", startedAt: new Date("2020-03-01") },
|
166
|
+
* { name: "John", startedAt: new Date("2020-06-01") },
|
167
|
+
* ];
|
168
|
+
*
|
169
|
+
* const sortedByStartedAt = sortBy(people, (people) => people.startedAt);
|
170
|
+
*
|
171
|
+
* assertEquals(sortedByStartedAt, [
|
172
|
+
* { name: "Anna", startedAt: new Date("2020-01-01") },
|
173
|
+
* { name: "Kim", startedAt: new Date("2020-03-01") },
|
174
|
+
* { name: "John", startedAt: new Date("2020-06-01") },
|
175
|
+
* ]);
|
176
|
+
* ```
|
177
|
+
*/
|
178
|
+
export function sortBy<T>(
|
179
|
+
array: readonly T[],
|
180
|
+
selector: (el: T) => Date,
|
181
|
+
options?: SortByOptions,
|
182
|
+
): T[];
|
183
|
+
export function sortBy<T>(
|
184
|
+
array: readonly T[],
|
185
|
+
selector:
|
186
|
+
| ((el: T) => number)
|
187
|
+
| ((el: T) => string)
|
188
|
+
| ((el: T) => bigint)
|
189
|
+
| ((el: T) => Date),
|
190
|
+
options?: SortByOptions,
|
191
|
+
): T[] {
|
192
|
+
const len = array.length;
|
193
|
+
const indexes = new Array<number>(len);
|
194
|
+
const selectors = new Array<ReturnType<typeof selector> | null>(len);
|
195
|
+
const order = options?.order ?? "asc";
|
196
|
+
|
197
|
+
array.forEach((element, index) => {
|
198
|
+
indexes[index] = index;
|
199
|
+
const selected = selector(element);
|
200
|
+
selectors[index] = Number.isNaN(selected) ? null : selected;
|
201
|
+
});
|
202
|
+
|
203
|
+
indexes.sort((ai, bi) => {
|
204
|
+
let a = selectors[ai]!;
|
205
|
+
let b = selectors[bi]!;
|
206
|
+
if (order === "desc") {
|
207
|
+
[a, b] = [b, a];
|
208
|
+
}
|
209
|
+
if (a === null) return 1;
|
210
|
+
if (b === null) return -1;
|
211
|
+
return a > b ? 1 : a < b ? -1 : 0;
|
212
|
+
});
|
213
|
+
|
214
|
+
for (let i = 0; i < len; i++) {
|
215
|
+
(indexes as unknown as T[])[i] = array[indexes[i]!] as T;
|
216
|
+
}
|
217
|
+
|
218
|
+
return indexes as unknown as T[];
|
219
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Applies the given selector to all elements in the given collection and
|
6
|
+
* calculates the sum of the results.
|
7
|
+
*
|
8
|
+
* @typeParam T The type of the array elements.
|
9
|
+
*
|
10
|
+
* @param array The array to calculate the sum of.
|
11
|
+
* @param selector The selector function to get the value to sum.
|
12
|
+
*
|
13
|
+
* @returns The sum of all elements in the collection.
|
14
|
+
*
|
15
|
+
* @example Basic usage
|
16
|
+
* ```ts
|
17
|
+
* import { sumOf } from "@std/collections/sum-of";
|
18
|
+
* import { assertEquals } from "@std/assert";
|
19
|
+
*
|
20
|
+
* const people = [
|
21
|
+
* { name: "Anna", age: 34 },
|
22
|
+
* { name: "Kim", age: 42 },
|
23
|
+
* { name: "John", age: 23 },
|
24
|
+
* ];
|
25
|
+
*
|
26
|
+
* const totalAge = sumOf(people, (person) => person.age);
|
27
|
+
*
|
28
|
+
* assertEquals(totalAge, 99);
|
29
|
+
* ```
|
30
|
+
*/
|
31
|
+
export function sumOf<T>(
|
32
|
+
array: Iterable<T>,
|
33
|
+
selector: (el: T) => number,
|
34
|
+
): number {
|
35
|
+
let sum = 0;
|
36
|
+
|
37
|
+
for (const i of array) {
|
38
|
+
sum += selector(i);
|
39
|
+
}
|
40
|
+
|
41
|
+
return sum;
|
42
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Returns all elements in the given array after the last element that does not
|
6
|
+
* match the given predicate.
|
7
|
+
*
|
8
|
+
* @typeParam T The type of the array elements.
|
9
|
+
*
|
10
|
+
* @param array The array to take elements from.
|
11
|
+
* @param predicate The predicate function to determine if an element should be
|
12
|
+
* included.
|
13
|
+
*
|
14
|
+
* @returns A new array containing all elements after the last element that does
|
15
|
+
* not match the predicate.
|
16
|
+
*
|
17
|
+
* @example Basic usage
|
18
|
+
* ```ts
|
19
|
+
* import { takeLastWhile } from "@std/collections/take-last-while";
|
20
|
+
* import { assertEquals } from "@std/assert";
|
21
|
+
*
|
22
|
+
* const numbers = [1, 2, 3, 4, 5, 6];
|
23
|
+
*
|
24
|
+
* const result = takeLastWhile(numbers, (number) => number > 4);
|
25
|
+
*
|
26
|
+
* assertEquals(result, [5, 6]);
|
27
|
+
* ```
|
28
|
+
*/
|
29
|
+
export function takeLastWhile<T>(
|
30
|
+
array: readonly T[],
|
31
|
+
predicate: (el: T) => boolean,
|
32
|
+
): T[] {
|
33
|
+
let offset = array.length;
|
34
|
+
while (0 < offset && predicate(array[offset - 1] as T)) offset--;
|
35
|
+
|
36
|
+
return array.slice(offset, array.length);
|
37
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Returns all elements in the given collection until the first element that
|
6
|
+
* does not match the given predicate.
|
7
|
+
*
|
8
|
+
* Note: If you want to process any iterable, use the new version of
|
9
|
+
* `takeWhile` from `@std/collections/unstable-take-while`.
|
10
|
+
*
|
11
|
+
* @typeParam T The type of the array elements.
|
12
|
+
*
|
13
|
+
* @param array The array to take elements from.
|
14
|
+
* @param predicate The predicate function to determine if an element should be
|
15
|
+
* included.
|
16
|
+
*
|
17
|
+
* @returns A new array containing all elements until the first element that
|
18
|
+
* does not match the predicate.
|
19
|
+
*
|
20
|
+
* @example Basic usage
|
21
|
+
* ```ts
|
22
|
+
* import { takeWhile } from "@std/collections/take-while";
|
23
|
+
* import { assertEquals } from "@std/assert";
|
24
|
+
*
|
25
|
+
* const numbers = [1, 2, 3, 4, 5, 6];
|
26
|
+
*
|
27
|
+
* const result = takeWhile(numbers, (number) => number < 4);
|
28
|
+
*
|
29
|
+
* assertEquals(result, [1, 2, 3]);
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
export function takeWhile<T>(
|
33
|
+
array: readonly T[],
|
34
|
+
predicate: (el: T) => boolean,
|
35
|
+
): T[] {
|
36
|
+
let offset = 0;
|
37
|
+
const length = array.length;
|
38
|
+
|
39
|
+
while (length > offset && predicate(array[offset] as T)) {
|
40
|
+
offset++;
|
41
|
+
}
|
42
|
+
|
43
|
+
return array.slice(0, offset);
|
44
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Returns all distinct elements that appear in any of the given arrays.
|
6
|
+
*
|
7
|
+
* @typeParam T The type of the array elements.
|
8
|
+
*
|
9
|
+
* @param arrays The arrays to get the union of.
|
10
|
+
*
|
11
|
+
* @returns A new array containing all distinct elements from the given arrays.
|
12
|
+
*
|
13
|
+
* @example Basic usage
|
14
|
+
* ```ts
|
15
|
+
* import { union } from "@std/collections/union";
|
16
|
+
* import { assertEquals } from "@std/assert";
|
17
|
+
*
|
18
|
+
* const soupIngredients = ["Pepper", "Carrots", "Leek"];
|
19
|
+
* const saladIngredients = ["Carrots", "Radicchio", "Pepper"];
|
20
|
+
*
|
21
|
+
* const shoppingList = union(soupIngredients, saladIngredients);
|
22
|
+
*
|
23
|
+
* assertEquals(shoppingList, ["Pepper", "Carrots", "Leek", "Radicchio"]);
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
export function union<T>(...arrays: Iterable<T>[]): T[] {
|
27
|
+
const set = new Set<T>();
|
28
|
+
|
29
|
+
for (const array of arrays) {
|
30
|
+
for (const element of array) {
|
31
|
+
set.add(element);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
return Array.from(set);
|
36
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Builds two separate arrays from the given array of 2-tuples, with the first
|
6
|
+
* returned array holding all first tuple elements and the second one holding
|
7
|
+
* all the second elements.
|
8
|
+
*
|
9
|
+
* @typeParam T The type of the first tuple elements.
|
10
|
+
* @typeParam U The type of the second tuple elements.
|
11
|
+
*
|
12
|
+
* @param pairs The array of 2-tuples to unzip.
|
13
|
+
*
|
14
|
+
* @returns A tuple containing two arrays, the first one holding all first tuple
|
15
|
+
* elements and the second one holding all second elements.
|
16
|
+
*
|
17
|
+
* @example Basic usage
|
18
|
+
* ```ts
|
19
|
+
* import { unzip } from "@std/collections/unzip";
|
20
|
+
* import { assertEquals } from "@std/assert";
|
21
|
+
*
|
22
|
+
* const parents = [
|
23
|
+
* ["Maria", "Jeff"],
|
24
|
+
* ["Anna", "Kim"],
|
25
|
+
* ["John", "Leroy"],
|
26
|
+
* ] as [string, string][];
|
27
|
+
*
|
28
|
+
* const [moms, dads] = unzip(parents);
|
29
|
+
*
|
30
|
+
* assertEquals(moms, ["Maria", "Anna", "John"]);
|
31
|
+
* assertEquals(dads, ["Jeff", "Kim", "Leroy"]);
|
32
|
+
* ```
|
33
|
+
*/
|
34
|
+
export function unzip<T, U>(pairs: readonly [T, U][]): [T[], U[]] {
|
35
|
+
const { length } = pairs;
|
36
|
+
|
37
|
+
const result: [T[], U[]] = [
|
38
|
+
new Array<T>(length),
|
39
|
+
new Array<U>(length),
|
40
|
+
];
|
41
|
+
|
42
|
+
for (let i = 0; i < length; ++i) {
|
43
|
+
const pair = pairs[i] as [T, U];
|
44
|
+
|
45
|
+
result[0][i] = pair[0];
|
46
|
+
result[1][i] = pair[1];
|
47
|
+
}
|
48
|
+
|
49
|
+
return result;
|
50
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Returns an array excluding all given values.
|
6
|
+
*
|
7
|
+
* @typeParam T The type of the array elements.
|
8
|
+
*
|
9
|
+
* @param array The array to exclude values from.
|
10
|
+
* @param values The values to exclude from the array.
|
11
|
+
*
|
12
|
+
* @returns A new array containing all elements from the given array except the
|
13
|
+
* ones that are in the values array.
|
14
|
+
*
|
15
|
+
* @example Basic usage
|
16
|
+
* ```ts
|
17
|
+
* import { withoutAll } from "@std/collections/without-all";
|
18
|
+
* import { assertEquals } from "@std/assert";
|
19
|
+
*
|
20
|
+
* const withoutList = withoutAll([2, 1, 2, 3], [1, 2]);
|
21
|
+
*
|
22
|
+
* assertEquals(withoutList, [3]);
|
23
|
+
* ```
|
24
|
+
*/
|
25
|
+
export function withoutAll<T>(array: readonly T[], values: readonly T[]): T[] {
|
26
|
+
const toExclude = new Set(values);
|
27
|
+
return array.filter((it) => !toExclude.has(it));
|
28
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
|
4
|
+
import { minOf } from "./min_of.js";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Builds N-tuples of elements from the given N arrays with matching indices,
|
8
|
+
* stopping when the smallest array's end is reached.
|
9
|
+
*
|
10
|
+
* @typeParam T the type of the tuples produced by this function.
|
11
|
+
*
|
12
|
+
* @param arrays The arrays to zip.
|
13
|
+
*
|
14
|
+
* @returns A new array containing N-tuples of elements from the given arrays.
|
15
|
+
*
|
16
|
+
* @example Basic usage
|
17
|
+
* ```ts
|
18
|
+
* import { zip } from "@std/collections/zip";
|
19
|
+
* import { assertEquals } from "@std/assert";
|
20
|
+
*
|
21
|
+
* const numbers = [1, 2, 3, 4];
|
22
|
+
* const letters = ["a", "b", "c", "d"];
|
23
|
+
* const pairs = zip(numbers, letters);
|
24
|
+
*
|
25
|
+
* assertEquals(
|
26
|
+
* pairs,
|
27
|
+
* [
|
28
|
+
* [1, "a"],
|
29
|
+
* [2, "b"],
|
30
|
+
* [3, "c"],
|
31
|
+
* [4, "d"],
|
32
|
+
* ],
|
33
|
+
* );
|
34
|
+
* ```
|
35
|
+
*/
|
36
|
+
export function zip<T extends unknown[]>(
|
37
|
+
...arrays: { [K in keyof T]: ReadonlyArray<T[K]> }
|
38
|
+
): T[] {
|
39
|
+
const minLength = minOf(arrays, (element) => element.length) ?? 0;
|
40
|
+
|
41
|
+
const result: T[] = new Array(minLength);
|
42
|
+
|
43
|
+
for (let i = 0; i < minLength; i += 1) {
|
44
|
+
const arr = arrays.map((it) => it[i]);
|
45
|
+
result[i] = arr as T;
|
46
|
+
}
|
47
|
+
|
48
|
+
return result;
|
49
|
+
}
|
package/src/mod.ts
CHANGED
@@ -1,19 +1,4 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
import type { ObjectTy } from "./object.js"
|
4
|
-
import type { StringTy } from "./string.js"
|
5
|
-
|
6
|
-
export type RootTy = NumberTy | StringTy | ObjectTy | ArrayTy
|
7
|
-
|
8
|
-
// moderate --exclude _base.ts code_critique.ts
|
9
|
-
|
10
|
-
export * from "./array.js"
|
11
|
-
export * from "./common.js"
|
12
|
-
export * from "./F.js"
|
13
|
-
export * from "./literal.js"
|
14
|
-
export * from "./number.js"
|
15
|
-
export * from "./object.js"
|
1
|
+
import "./_dnt.polyfills.js";
|
2
|
+
export * as T from "./types/mod.js"
|
16
3
|
export * from "./ResponseFormat.js"
|
17
|
-
export * from "./
|
18
|
-
export * from "./string.js"
|
19
|
-
export * from "./union.js"
|
4
|
+
export * from "./Tool.js"
|
package/src/oai.ts
ADDED
package/src/types/Ref.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { Applied, Schema, Ty } from "./Ty.js"
|
2
|
+
import { recombineTaggedTemplateArgs } from "../util/recombineTaggedTemplateArgs.js"
|
3
|
+
|
4
|
+
export type Ref = (ty: Ty) => Schema
|
5
|
+
|
6
|
+
export function Ref(applied: Applied): Ref {
|
7
|
+
return (ty) => {
|
8
|
+
applied = { ...applied, ...ty.applied }
|
9
|
+
const description = ty.descriptions
|
10
|
+
.map(({ template, placeheld }) =>
|
11
|
+
recombineTaggedTemplateArgs(template, placeheld.map((k) => applied[k]!))
|
12
|
+
)
|
13
|
+
.join(" ")
|
14
|
+
return ty.toSchema(description, Ref(applied))
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { phantoms } from "../util/phantoms.js"
|
2
|
+
import { Ref } from "./Ref.js"
|
3
|
+
import type { Applied, Description, Schema, ToSchema, Ty } from "./Ty.js"
|
4
|
+
|
5
|
+
export function RootTy<T, P extends string = never>(
|
6
|
+
toSchema: ToSchema,
|
7
|
+
descriptions: Array<Description> = [],
|
8
|
+
applied: Applied = {},
|
9
|
+
): RootTy<T, P> {
|
10
|
+
return Object.assign(
|
11
|
+
<P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2) =>
|
12
|
+
RootTy<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...descriptions], applied),
|
13
|
+
phantoms<{ [Ty.T]: T; [Ty.P]: P }>(),
|
14
|
+
{
|
15
|
+
toSchema,
|
16
|
+
descriptions,
|
17
|
+
applied,
|
18
|
+
apply: <A extends Partial<Record<P, string | number>>>(values: A) => {
|
19
|
+
return RootTy<T, Exclude<P, keyof A>>(toSchema, descriptions, { ...applied, ...values })
|
20
|
+
},
|
21
|
+
schema(this: RootTy<T, never>) {
|
22
|
+
return Ref({})(this)
|
23
|
+
},
|
24
|
+
isRoot(): this is RootTy {
|
25
|
+
return true
|
26
|
+
},
|
27
|
+
},
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
31
|
+
export interface RootTy<T = any, P extends string = string> extends Ty<T, P> {
|
32
|
+
<P2 extends Array<string>>(
|
33
|
+
template: TemplateStringsArray,
|
34
|
+
...placeheld: P2
|
35
|
+
): RootTy<T, P | P2[number]>
|
36
|
+
apply: <A extends Partial<Record<P, number | string>>>(
|
37
|
+
values: A,
|
38
|
+
) => RootTy<T, Exclude<P, keyof A>>
|
39
|
+
schema(this: RootTy<T, never>): Schema
|
40
|
+
}
|
package/src/types/Ty.ts
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
import type { Ref } from "./Ref.js"
|
2
|
+
import { phantoms } from "../util/phantoms.js"
|
3
|
+
import type { RootTy } from "./RootTy.js"
|
4
|
+
|
5
|
+
export function Ty<T, P extends string = never>(
|
6
|
+
toSchema: ToSchema,
|
7
|
+
descriptions: Array<Description> = [],
|
8
|
+
applied: Applied = {},
|
9
|
+
): Ty<T, P> {
|
10
|
+
return Object.assign(
|
11
|
+
<P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2) =>
|
12
|
+
Ty<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...descriptions], applied),
|
13
|
+
phantoms<{ [Ty.T]: T; [Ty.P]: P }>(),
|
14
|
+
{
|
15
|
+
toSchema,
|
16
|
+
descriptions,
|
17
|
+
applied,
|
18
|
+
apply: <A extends Partial<Record<P, string | number>>>(values: A) => {
|
19
|
+
return Ty<T, Exclude<P, keyof A>>(toSchema, descriptions, { ...applied, ...values })
|
20
|
+
},
|
21
|
+
isRoot(): this is RootTy {
|
22
|
+
return false
|
23
|
+
},
|
24
|
+
},
|
25
|
+
)
|
26
|
+
}
|
27
|
+
|
28
|
+
export interface Ty<T = any, P extends string = string> {
|
29
|
+
<P2 extends Array<string>>(
|
30
|
+
template: TemplateStringsArray,
|
31
|
+
...placeheld: P2
|
32
|
+
): Ty<T, P | P2[number]>
|
33
|
+
[Ty.T]: T
|
34
|
+
[Ty.P]: P
|
35
|
+
toSchema: ToSchema
|
36
|
+
descriptions: Array<Description>
|
37
|
+
applied: Applied
|
38
|
+
apply: <A extends Partial<Record<P, number | string>>>(values: A) => Ty<T, Exclude<P, keyof A>>
|
39
|
+
isRoot(): this is RootTy
|
40
|
+
}
|
41
|
+
|
42
|
+
export namespace Ty {
|
43
|
+
export type T = typeof T
|
44
|
+
export declare const T: unique symbol
|
45
|
+
export type P = typeof P
|
46
|
+
export declare const P: unique symbol
|
47
|
+
}
|
48
|
+
|
49
|
+
export type ToSchema = (description: string | undefined, ref: Ref) => Schema
|
50
|
+
export type Schema = Record<string, unknown>
|
51
|
+
|
52
|
+
export interface Description {
|
53
|
+
template: TemplateStringsArray
|
54
|
+
placeheld: Array<string>
|
55
|
+
}
|
56
|
+
|
57
|
+
export type Applied = Record<string, number | string>
|