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
package/README.md
CHANGED
@@ -1,8 +1,79 @@
|
|
1
|
-
#
|
1
|
+
# Structured Outputs
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
A TypeScript library for composing
|
4
|
+
[OpenAI structured output schemas](https://platform.openai.com/docs/guides/structured-outputs).
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
### Node
|
9
|
+
|
10
|
+
```sh
|
11
|
+
npm i structured-outputs
|
12
|
+
```
|
13
|
+
|
14
|
+
### Deno
|
15
|
+
|
16
|
+
```ts
|
17
|
+
deno add jsr:@crosshatch/structured-outputs
|
18
|
+
```
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### Basic Usage
|
23
|
+
|
24
|
+
```ts
|
25
|
+
import { ResponseFormat, T } from "structured-outputs"
|
26
|
+
|
27
|
+
// 1. Define the shape of the desired response.
|
28
|
+
const Character = T.object({
|
29
|
+
name: T.string,
|
30
|
+
age: T.number`Ensure between 1 and 110.`,
|
31
|
+
})
|
32
|
+
|
33
|
+
// 2. Create the response format object.
|
34
|
+
const response_format = ResponseFormat("create_character", Character)
|
35
|
+
|
36
|
+
// 3. Utilize the response format to create a chat completion.
|
37
|
+
const response = await openai.chat.completions.create({
|
38
|
+
model: MODEL,
|
39
|
+
messages: [{ role: "system", content: [] }],
|
40
|
+
response_format,
|
41
|
+
})
|
42
|
+
|
43
|
+
// 4. Use `response_format.parseFirstOrThrow` to unwrap the inner data with correct types.
|
44
|
+
const { name, age } = response_format.parseFirstOrThrow(response)
|
45
|
+
```
|
46
|
+
|
47
|
+
For more concise usage, chain off the completions promise.
|
48
|
+
|
49
|
+
```ts
|
50
|
+
const { name, age } = await openai.chat.completions
|
51
|
+
.create({
|
52
|
+
model: MODEL,
|
53
|
+
messages: [{ role: "system", content: [] }],
|
54
|
+
response_format,
|
55
|
+
})
|
56
|
+
.then(response_format.parseFirstOrThrow)
|
57
|
+
```
|
58
|
+
|
59
|
+
We can also attach a description to the response format.
|
60
|
+
|
61
|
+
```diff
|
62
|
+
- ResponseFormat("create_character", Character)
|
63
|
+
+ ResponseFormat("create_character", Character)`
|
64
|
+
+ Create a new character to be the protagonist of a children's story.
|
65
|
+
+ `
|
66
|
+
```
|
67
|
+
|
68
|
+
### Dependency Injection
|
69
|
+
|
70
|
+
```ts
|
71
|
+
const Character = T.object({
|
72
|
+
name: T.string`Preferably names common to those who are {"national identity"}.`,
|
73
|
+
age: T.number`Ensure between 1 and 110.`,
|
74
|
+
})
|
75
|
+
|
76
|
+
const AmericanCharacter = Character.apply({
|
77
|
+
"national identity": "american",
|
78
|
+
})
|
79
|
+
```
|
package/esm/ResponseFormat.d.ts
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
export
|
1
|
+
import type { RootTy } from "./types/mod.js";
|
2
|
+
import type { ChatCompletion, JsonSchema } from "./oai.js";
|
3
|
+
export interface ResponseFormat<T> {
|
4
|
+
(template: TemplateStringsArray, ...quasis: Array<string>): ResponseFormat<T>;
|
4
5
|
type: "json_schema";
|
5
6
|
/** The desired return type in JSON Schema. */
|
6
|
-
json_schema:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
export declare
|
7
|
+
json_schema: JsonSchema;
|
8
|
+
/** Parse the content of the first choice into a typed object. */
|
9
|
+
parseFirstChoice(completion: ChatCompletion): T;
|
10
|
+
/** Parse all choice contents into an array of typed object. */
|
11
|
+
parseChoices(completion: ChatCompletion): Array<T>;
|
12
|
+
}
|
13
|
+
export declare function ResponseFormat<T>(name: string, ty: RootTy<T, never>): ResponseFormat<T>;
|
14
|
+
export declare namespace ResponseFormat {
|
15
|
+
function unwrapFirstChoice(completion: ChatCompletion): string;
|
16
|
+
function unwrapChoices(completions: ChatCompletion): string[];
|
17
|
+
}
|
18
|
+
export declare class ResponseFormatUnwrapError extends Error {
|
19
|
+
readonly name = "UnwrapResponseError";
|
20
|
+
}
|
14
21
|
//# sourceMappingURL=ResponseFormat.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResponseFormat.d.ts","sourceRoot":"","sources":["../src/ResponseFormat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"ResponseFormat.d.ts","sourceRoot":"","sources":["../src/ResponseFormat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAwB,UAAU,EAAE,MAAM,UAAU,CAAA;AAEhF,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;IAC7E,IAAI,EAAE,aAAa,CAAA;IACnB,8CAA8C;IAC9C,WAAW,EAAE,UAAU,CAAA;IACvB,iEAAiE;IACjE,gBAAgB,CAAC,UAAU,EAAE,cAAc,GAAG,CAAC,CAAA;IAC/C,+DAA+D;IAC/D,YAAY,CAAC,UAAU,EAAE,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;CACnD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAEvF;AAoCD,yBAAiB,cAAc,CAAC;IAC9B,SAAgB,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CAMpE;IAED,SAAgB,aAAa,CAAC,WAAW,EAAE,cAAc,GAAG,MAAM,EAAE,CAEnE;CAoBF;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAkB,IAAI,yBAAwB;CAC/C"}
|
package/esm/ResponseFormat.js
CHANGED
@@ -1,13 +1,65 @@
|
|
1
|
-
import {
|
2
|
-
export function ResponseFormat(name,
|
3
|
-
return
|
1
|
+
import { recombineTaggedTemplateArgs } from "./util/recombineTaggedTemplateArgs.js";
|
2
|
+
export function ResponseFormat(name, ty) {
|
3
|
+
return ResponseFormat_(name, ty);
|
4
|
+
}
|
5
|
+
function ResponseFormat_(name, ty, description) {
|
6
|
+
return Object.assign((template, ...quasis) => ResponseFormat_(name, ty, description ? `${description} ${recombineTaggedTemplateArgs(template, quasis)}` : undefined), {
|
4
7
|
type: "json_schema",
|
5
8
|
json_schema: {
|
6
9
|
name,
|
7
10
|
description,
|
8
|
-
schema: schema(
|
11
|
+
schema: ty.schema(),
|
9
12
|
strict: true,
|
10
13
|
},
|
11
|
-
|
14
|
+
parseFirstChoice: (completion) => {
|
15
|
+
return JSON.parse(ResponseFormat.unwrapFirstChoice(completion));
|
16
|
+
},
|
17
|
+
parseChoices: (completion) => {
|
18
|
+
return ResponseFormat.unwrapChoices(completion).map((content) => JSON.parse(content));
|
19
|
+
},
|
20
|
+
toJSON() {
|
21
|
+
const { type, json_schema } = this;
|
22
|
+
return { type, json_schema };
|
23
|
+
},
|
24
|
+
});
|
25
|
+
}
|
26
|
+
(function (ResponseFormat) {
|
27
|
+
function unwrapFirstChoice(completion) {
|
28
|
+
const { choices: [firstChoice] } = completion;
|
29
|
+
if (!firstChoice) {
|
30
|
+
throw new ResponseFormatUnwrapError("No choices contained within the completion response.");
|
31
|
+
}
|
32
|
+
return unwrapChoice(firstChoice);
|
33
|
+
}
|
34
|
+
ResponseFormat.unwrapFirstChoice = unwrapFirstChoice;
|
35
|
+
function unwrapChoices(completions) {
|
36
|
+
return completions.choices.map(unwrapChoice);
|
37
|
+
}
|
38
|
+
ResponseFormat.unwrapChoices = unwrapChoices;
|
39
|
+
function unwrapChoice(choice) {
|
40
|
+
const { finish_reason, message } = choice;
|
41
|
+
if (finish_reason !== "stop") {
|
42
|
+
throw new ResponseFormatUnwrapError(`Completion responded with "${finish_reason}" as finish reason; ${message}`);
|
43
|
+
}
|
44
|
+
const { content, refusal } = message;
|
45
|
+
if (refusal) {
|
46
|
+
throw new ResponseFormatUnwrapError(`Openai refused to fulfill completion request; ${refusal}`);
|
47
|
+
}
|
48
|
+
if (!content) {
|
49
|
+
throw new ResponseFormatUnwrapError("First response choice contained no content.");
|
50
|
+
}
|
51
|
+
return content;
|
52
|
+
}
|
53
|
+
})(ResponseFormat || (ResponseFormat = {}));
|
54
|
+
export class ResponseFormatUnwrapError extends Error {
|
55
|
+
constructor() {
|
56
|
+
super(...arguments);
|
57
|
+
Object.defineProperty(this, "name", {
|
58
|
+
enumerable: true,
|
59
|
+
configurable: true,
|
60
|
+
writable: true,
|
61
|
+
value: "UnwrapResponseError"
|
62
|
+
});
|
63
|
+
}
|
12
64
|
}
|
13
65
|
//# sourceMappingURL=ResponseFormat.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResponseFormat.js","sourceRoot":"","sources":["../src/ResponseFormat.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"ResponseFormat.js","sourceRoot":"","sources":["../src/ResponseFormat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAA;AAcnF,MAAM,UAAU,cAAc,CAAI,IAAY,EAAE,EAAoB;IAClE,OAAO,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAClC,CAAC;AAED,SAAS,eAAe,CACtB,IAAY,EACZ,EAAoB,EACpB,WAAoB;IAEpB,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,QAA8B,EAAE,GAAG,MAAqB,EAAE,EAAE,CAC3D,eAAe,CACb,IAAI,EACJ,EAAE,EACF,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,2BAA2B,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAC5F,EACH;QACE,IAAI,EAAE,aAAsB;QAC5B,WAAW,EAAE;YACX,IAAI;YACJ,WAAW;YACX,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE;YACnB,MAAM,EAAE,IAAI;SACb;QACD,gBAAgB,EAAE,CAAC,UAA0B,EAAK,EAAE;YAClD,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAA;QACjE,CAAC;QACD,YAAY,EAAE,CAAC,UAA0B,EAAY,EAAE;YACrD,OAAO,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;QACvF,CAAC;QACD,MAAM;YACJ,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;YAClC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;QAC9B,CAAC;KACF,CACF,CAAA;AACH,CAAC;AAED,WAAiB,cAAc;IAC7B,SAAgB,iBAAiB,CAAC,UAA0B;QAC1D,MAAM,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,UAAU,CAAA;QAC7C,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,yBAAyB,CAAC,sDAAsD,CAAC,CAAA;QAC7F,CAAC;QACD,OAAO,YAAY,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC;IANe,gCAAiB,oBAMhC,CAAA;IAED,SAAgB,aAAa,CAAC,WAA2B;QACvD,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC9C,CAAC;IAFe,4BAAa,gBAE5B,CAAA;IAED,SAAS,YAAY,CAAC,MAA4B;QAChD,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;QACzC,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;YAC7B,MAAM,IAAI,yBAAyB,CACjC,8BAA8B,aAAa,uBAAuB,OAAO,EAAE,CAC5E,CAAA;QACH,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QACpC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,yBAAyB,CACjC,iDAAiD,OAAO,EAAE,CAC3D,CAAA;QACH,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,yBAAyB,CAAC,6CAA6C,CAAC,CAAA;QACpF,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;AACH,CAAC,EA/BgB,cAAc,KAAd,cAAc,QA+B9B;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAApD;;QACoB;;;;mBAAO,qBAAqB;WAAA;IAChD,CAAC;CAAA"}
|
package/esm/Tool.d.ts
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { RootTy, Schema } from "./types/mod.js";
|
2
|
+
export declare function Tool<T>(name: string, ty: RootTy<T, never>): Tool<T>;
|
3
|
+
export interface Tool<T = any> {
|
4
|
+
(template: TemplateStringsArray, ...quasis: Array<string>): Tool<T>;
|
5
|
+
type: "function";
|
6
|
+
/** The name with which OpenAI recognizes the tool. */
|
7
|
+
name: string;
|
8
|
+
/** A description to inform the LLM of when/how to use the tool. */
|
9
|
+
description?: string;
|
10
|
+
/** The tool implementation's argument type in JSON Schema. */
|
11
|
+
parameters?: Schema;
|
12
|
+
}
|
13
|
+
//# sourceMappingURL=Tool.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Tool.d.ts","sourceRoot":"","sources":["../src/Tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGpD,wBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAEnE;AAuBD,MAAM,WAAW,IAAI,CAAC,CAAC,GAAG,GAAG;IAC3B,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACnE,IAAI,EAAE,UAAU,CAAA;IAChB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
package/esm/Tool.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import { recombineTaggedTemplateArgs } from "./util/recombineTaggedTemplateArgs.js";
|
2
|
+
export function Tool(name, ty) {
|
3
|
+
return Tool_(name, ty);
|
4
|
+
}
|
5
|
+
function Tool_(name, ty, description) {
|
6
|
+
return Object.assign((template, ...quasis) => Tool_(name, ty, description ? `${description} ${recombineTaggedTemplateArgs(template, quasis)}` : undefined), {
|
7
|
+
type: "function",
|
8
|
+
name,
|
9
|
+
description,
|
10
|
+
parameters: ty.schema(),
|
11
|
+
toJson() {
|
12
|
+
const { type, name, description, parameters } = this;
|
13
|
+
return { type, name, description, parameters };
|
14
|
+
},
|
15
|
+
});
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=Tool.js.map
|
package/esm/Tool.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Tool.js","sourceRoot":"","sources":["../src/Tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAA;AAEnF,MAAM,UAAU,IAAI,CAAI,IAAY,EAAE,EAAoB;IACxD,OAAO,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AACxB,CAAC;AAED,SAAS,KAAK,CAAI,IAAY,EAAE,EAAoB,EAAE,WAAoB;IACxE,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,QAA8B,EAAE,GAAG,MAAqB,EAAE,EAAE,CAC3D,KAAK,CACH,IAAI,EACJ,EAAE,EACF,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,2BAA2B,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAC5F,EACH;QACE,IAAI,EAAE,UAAmB;QACzB,IAAI;QACJ,WAAW;QACX,UAAU,EAAE,EAAE,CAAC,MAAM,EAAE;QACvB,MAAM;YACJ,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;YACpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAA;QAChD,CAAC;KACF,CACF,CAAA;AACH,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
declare global {
|
2
|
+
interface Object {
|
3
|
+
/**
|
4
|
+
* Determines whether an object has a property with the specified name.
|
5
|
+
* @param o An object.
|
6
|
+
* @param v A property name.
|
7
|
+
*/
|
8
|
+
hasOwn(o: object, v: PropertyKey): boolean;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
export {};
|
12
|
+
//# sourceMappingURL=_dnt.polyfills.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAeA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
2
|
+
if (!Object.hasOwn) {
|
3
|
+
Object.defineProperty(Object, "hasOwn", {
|
4
|
+
value: function (object, property) {
|
5
|
+
if (object == null) {
|
6
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
7
|
+
}
|
8
|
+
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
9
|
+
},
|
10
|
+
configurable: true,
|
11
|
+
enumerable: false,
|
12
|
+
writable: true,
|
13
|
+
});
|
14
|
+
}
|
15
|
+
export {};
|
16
|
+
//# sourceMappingURL=_dnt.polyfills.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.js","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;QACtC,KAAK,EAAE,UAAU,MAAW,EAAE,QAAa;YACzC,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;YACpE,CAAC;YACD,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;QACxE,CAAC;QACD,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/**
|
2
|
+
* Filters the given array, removing all elements that do not match the given predicate
|
3
|
+
* **in place. This means `array` will be modified!**.
|
4
|
+
*/
|
5
|
+
export declare function filterInPlace<T>(array: Array<T>, predicate: (el: T) => boolean): Array<T>;
|
6
|
+
//# sourceMappingURL=_utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"_utils.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/_utils.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,GAC5B,KAAK,CAAC,CAAC,CAAC,CAeV"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
/**
|
4
|
+
* Filters the given array, removing all elements that do not match the given predicate
|
5
|
+
* **in place. This means `array` will be modified!**.
|
6
|
+
*/
|
7
|
+
export function filterInPlace(array, predicate) {
|
8
|
+
let outputIndex = 0;
|
9
|
+
for (const cur of array) {
|
10
|
+
if (!predicate(cur)) {
|
11
|
+
continue;
|
12
|
+
}
|
13
|
+
array[outputIndex] = cur;
|
14
|
+
outputIndex += 1;
|
15
|
+
}
|
16
|
+
array.splice(outputIndex);
|
17
|
+
return array;
|
18
|
+
}
|
19
|
+
//# sourceMappingURL=_utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"_utils.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/_utils.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AAErC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAe,EACf,SAA6B;IAE7B,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;YACpB,SAAS;QACX,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;QACzB,WAAW,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE1B,OAAO,KAAK,CAAC;AACf,CAAC"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/**
|
2
|
+
* Applies the given aggregator to each group in the given grouping, returning the
|
3
|
+
* results together with the respective group keys
|
4
|
+
*
|
5
|
+
* @typeParam T Type of the values in the input record.
|
6
|
+
* @typeParam A Type of the accumulator value, which will match the returned
|
7
|
+
* record's values.
|
8
|
+
*
|
9
|
+
* @param record The grouping to aggregate.
|
10
|
+
* @param aggregator The function to apply to each group.
|
11
|
+
*
|
12
|
+
* @returns A record with the same keys as the input record, but with the values
|
13
|
+
* being the result of applying the aggregator to each group.
|
14
|
+
*
|
15
|
+
* @example Basic usage
|
16
|
+
* ```ts
|
17
|
+
* import { aggregateGroups } from "@std/collections/aggregate-groups";
|
18
|
+
* import { assertEquals } from "@std/assert";
|
19
|
+
*
|
20
|
+
* const foodProperties = {
|
21
|
+
* Curry: ["spicy", "vegan"],
|
22
|
+
* Omelette: ["creamy", "vegetarian"],
|
23
|
+
* };
|
24
|
+
*
|
25
|
+
* const descriptions = aggregateGroups(
|
26
|
+
* foodProperties,
|
27
|
+
* (current, key, first, acc) => {
|
28
|
+
* return first
|
29
|
+
* ? `${key} is ${current}`
|
30
|
+
* : `${acc} and ${current}`;
|
31
|
+
* },
|
32
|
+
* );
|
33
|
+
*
|
34
|
+
* assertEquals(descriptions, {
|
35
|
+
* Curry: "Curry is spicy and vegan",
|
36
|
+
* Omelette: "Omelette is creamy and vegetarian",
|
37
|
+
* });
|
38
|
+
* ```
|
39
|
+
*/
|
40
|
+
export declare function aggregateGroups<T, A>(record: Readonly<Record<string, ReadonlyArray<T>>>, aggregator: (current: T, key: string, first: boolean, accumulator?: A) => A): Record<string, A>;
|
41
|
+
//# sourceMappingURL=aggregate_groups.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"aggregate_groups.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAClC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAClD,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,GAC1E,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAcnB"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
import { mapEntries } from "./map_entries.js";
|
4
|
+
/**
|
5
|
+
* Applies the given aggregator to each group in the given grouping, returning the
|
6
|
+
* results together with the respective group keys
|
7
|
+
*
|
8
|
+
* @typeParam T Type of the values in the input record.
|
9
|
+
* @typeParam A Type of the accumulator value, which will match the returned
|
10
|
+
* record's values.
|
11
|
+
*
|
12
|
+
* @param record The grouping to aggregate.
|
13
|
+
* @param aggregator The function to apply to each group.
|
14
|
+
*
|
15
|
+
* @returns A record with the same keys as the input record, but with the values
|
16
|
+
* being the result of applying the aggregator to each group.
|
17
|
+
*
|
18
|
+
* @example Basic usage
|
19
|
+
* ```ts
|
20
|
+
* import { aggregateGroups } from "@std/collections/aggregate-groups";
|
21
|
+
* import { assertEquals } from "@std/assert";
|
22
|
+
*
|
23
|
+
* const foodProperties = {
|
24
|
+
* Curry: ["spicy", "vegan"],
|
25
|
+
* Omelette: ["creamy", "vegetarian"],
|
26
|
+
* };
|
27
|
+
*
|
28
|
+
* const descriptions = aggregateGroups(
|
29
|
+
* foodProperties,
|
30
|
+
* (current, key, first, acc) => {
|
31
|
+
* return first
|
32
|
+
* ? `${key} is ${current}`
|
33
|
+
* : `${acc} and ${current}`;
|
34
|
+
* },
|
35
|
+
* );
|
36
|
+
*
|
37
|
+
* assertEquals(descriptions, {
|
38
|
+
* Curry: "Curry is spicy and vegan",
|
39
|
+
* Omelette: "Omelette is creamy and vegetarian",
|
40
|
+
* });
|
41
|
+
* ```
|
42
|
+
*/
|
43
|
+
export function aggregateGroups(record, aggregator) {
|
44
|
+
return mapEntries(record, ([key, values]) => [
|
45
|
+
key,
|
46
|
+
// Need the type assertions here because the reduce type does not support
|
47
|
+
// the type transition we need
|
48
|
+
values.reduce((accumulator, current, currentIndex) => aggregator(current, key, currentIndex === 0, accumulator), undefined),
|
49
|
+
]);
|
50
|
+
}
|
51
|
+
//# sourceMappingURL=aggregate_groups.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"aggregate_groups.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAkD,EAClD,UAA2E;IAE3E,OAAO,UAAU,CACf,MAAM,EACN,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;QACjB,GAAG;QACH,yEAAyE;QACzE,8BAA8B;QAC9B,MAAM,CAAC,MAAM,CACX,CAAC,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,CACrC,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,YAAY,KAAK,CAAC,EAAE,WAAW,CAAC,EAC3D,SAA0B,CACtB;KACP,CACF,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* Creates a record by associating each element of the input array with a key
|
3
|
+
* generated by the selector function.
|
4
|
+
*
|
5
|
+
* If the selector produces the same key for multiple elements, the latest one
|
6
|
+
* will be used (overriding the ones before it).
|
7
|
+
*
|
8
|
+
* @typeParam T Type of the elements in the input array.
|
9
|
+
*
|
10
|
+
* @param array The array to transform.
|
11
|
+
* @param selector The function to extract the key from each element.
|
12
|
+
*
|
13
|
+
* @returns A record with the keys produced by the selector and the elements as
|
14
|
+
* values.
|
15
|
+
*
|
16
|
+
* @example Basic usage
|
17
|
+
* ```ts
|
18
|
+
* import { associateBy } from "@std/collections/associate-by";
|
19
|
+
* import { assertEquals } from "@std/assert";
|
20
|
+
*
|
21
|
+
* const users = [
|
22
|
+
* { id: "a2e", userName: "Anna" },
|
23
|
+
* { id: "5f8", userName: "Arnold" },
|
24
|
+
* { id: "d2c", userName: "Kim" },
|
25
|
+
* ];
|
26
|
+
*
|
27
|
+
* const usersById = associateBy(users, (user) => user.id);
|
28
|
+
*
|
29
|
+
* assertEquals(usersById, {
|
30
|
+
* "a2e": { id: "a2e", userName: "Anna" },
|
31
|
+
* "5f8": { id: "5f8", userName: "Arnold" },
|
32
|
+
* "d2c": { id: "d2c", userName: "Kim" },
|
33
|
+
* });
|
34
|
+
* ```
|
35
|
+
*/
|
36
|
+
export declare function associateBy<T>(array: Iterable<T>, selector: (el: T) => string): Record<string, T>;
|
37
|
+
//# sourceMappingURL=associate_by.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"associate_by.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/associate_by.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAClB,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,MAAM,GAC1B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQnB"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
/**
|
4
|
+
* Creates a record by associating each element of the input array with a key
|
5
|
+
* generated by the selector function.
|
6
|
+
*
|
7
|
+
* If the selector produces the same key for multiple elements, the latest one
|
8
|
+
* will be used (overriding the ones before it).
|
9
|
+
*
|
10
|
+
* @typeParam T Type of the elements in the input array.
|
11
|
+
*
|
12
|
+
* @param array The array to transform.
|
13
|
+
* @param selector The function to extract the key from each element.
|
14
|
+
*
|
15
|
+
* @returns A record with the keys produced by the selector and the elements as
|
16
|
+
* values.
|
17
|
+
*
|
18
|
+
* @example Basic usage
|
19
|
+
* ```ts
|
20
|
+
* import { associateBy } from "@std/collections/associate-by";
|
21
|
+
* import { assertEquals } from "@std/assert";
|
22
|
+
*
|
23
|
+
* const users = [
|
24
|
+
* { id: "a2e", userName: "Anna" },
|
25
|
+
* { id: "5f8", userName: "Arnold" },
|
26
|
+
* { id: "d2c", userName: "Kim" },
|
27
|
+
* ];
|
28
|
+
*
|
29
|
+
* const usersById = associateBy(users, (user) => user.id);
|
30
|
+
*
|
31
|
+
* assertEquals(usersById, {
|
32
|
+
* "a2e": { id: "a2e", userName: "Anna" },
|
33
|
+
* "5f8": { id: "5f8", userName: "Arnold" },
|
34
|
+
* "d2c": { id: "d2c", userName: "Kim" },
|
35
|
+
* });
|
36
|
+
* ```
|
37
|
+
*/
|
38
|
+
export function associateBy(array, selector) {
|
39
|
+
const result = {};
|
40
|
+
for (const element of array) {
|
41
|
+
result[selector(element)] = element;
|
42
|
+
}
|
43
|
+
return result;
|
44
|
+
}
|
45
|
+
//# sourceMappingURL=associate_by.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"associate_by.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/associate_by.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,WAAW,CACzB,KAAkB,EAClB,QAA2B;IAE3B,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;QAC5B,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* Associates each string element of an array with a value returned by a selector
|
3
|
+
* function.
|
4
|
+
*
|
5
|
+
* If any of two pairs would have the same value, the latest one will be used
|
6
|
+
* (overriding the ones before it).
|
7
|
+
*
|
8
|
+
* @typeParam T The type of the values returned by the selector function.
|
9
|
+
*
|
10
|
+
* @param array The array of elements to associate with values.
|
11
|
+
* @param selector The selector function that returns a value for each element.
|
12
|
+
*
|
13
|
+
* @returns An object where each element of the array is associated with a value
|
14
|
+
* returned by the selector function.
|
15
|
+
*
|
16
|
+
* @example Basic usage
|
17
|
+
* ```ts
|
18
|
+
* import { associateWith } from "@std/collections/associate-with";
|
19
|
+
* import { assertEquals } from "@std/assert";
|
20
|
+
*
|
21
|
+
* const names = ["Kim", "Lara", "Jonathan"];
|
22
|
+
*
|
23
|
+
* const namesToLength = associateWith(names, (person) => person.length);
|
24
|
+
*
|
25
|
+
* assertEquals(namesToLength, {
|
26
|
+
* "Kim": 3,
|
27
|
+
* "Lara": 4,
|
28
|
+
* "Jonathan": 8,
|
29
|
+
* });
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
export declare function associateWith<T>(array: Iterable<string>, selector: (key: string) => T): Record<string, T>;
|
33
|
+
//# sourceMappingURL=associate_with.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"associate_with.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/associate_with.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQnB"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
|
+
// This module is browser compatible.
|
3
|
+
/**
|
4
|
+
* Associates each string element of an array with a value returned by a selector
|
5
|
+
* function.
|
6
|
+
*
|
7
|
+
* If any of two pairs would have the same value, the latest one will be used
|
8
|
+
* (overriding the ones before it).
|
9
|
+
*
|
10
|
+
* @typeParam T The type of the values returned by the selector function.
|
11
|
+
*
|
12
|
+
* @param array The array of elements to associate with values.
|
13
|
+
* @param selector The selector function that returns a value for each element.
|
14
|
+
*
|
15
|
+
* @returns An object where each element of the array is associated with a value
|
16
|
+
* returned by the selector function.
|
17
|
+
*
|
18
|
+
* @example Basic usage
|
19
|
+
* ```ts
|
20
|
+
* import { associateWith } from "@std/collections/associate-with";
|
21
|
+
* import { assertEquals } from "@std/assert";
|
22
|
+
*
|
23
|
+
* const names = ["Kim", "Lara", "Jonathan"];
|
24
|
+
*
|
25
|
+
* const namesToLength = associateWith(names, (person) => person.length);
|
26
|
+
*
|
27
|
+
* assertEquals(namesToLength, {
|
28
|
+
* "Kim": 3,
|
29
|
+
* "Lara": 4,
|
30
|
+
* "Jonathan": 8,
|
31
|
+
* });
|
32
|
+
* ```
|
33
|
+
*/
|
34
|
+
export function associateWith(array, selector) {
|
35
|
+
const result = {};
|
36
|
+
for (const element of array) {
|
37
|
+
result[element] = selector(element);
|
38
|
+
}
|
39
|
+
return result;
|
40
|
+
}
|
41
|
+
//# sourceMappingURL=associate_with.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"associate_with.js","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/associate_with.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qCAAqC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAuB,EACvB,QAA4B;IAE5B,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;QAC5B,MAAM,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* Splits the given array into chunks of the given size and returns them.
|
3
|
+
*
|
4
|
+
* @typeParam T Type of the elements in the input array.
|
5
|
+
*
|
6
|
+
* @param array The array to split into chunks.
|
7
|
+
* @param size The size of the chunks. This must be a positive integer.
|
8
|
+
*
|
9
|
+
* @returns An array of chunks of the given size.
|
10
|
+
*
|
11
|
+
* @example Basic usage
|
12
|
+
* ```ts
|
13
|
+
* import { chunk } from "@std/collections/chunk";
|
14
|
+
* import { assertEquals } from "@std/assert";
|
15
|
+
*
|
16
|
+
* const words = [
|
17
|
+
* "lorem",
|
18
|
+
* "ipsum",
|
19
|
+
* "dolor",
|
20
|
+
* "sit",
|
21
|
+
* "amet",
|
22
|
+
* "consetetur",
|
23
|
+
* "sadipscing",
|
24
|
+
* ];
|
25
|
+
* const chunks = chunk(words, 3);
|
26
|
+
*
|
27
|
+
* assertEquals(
|
28
|
+
* chunks,
|
29
|
+
* [
|
30
|
+
* ["lorem", "ipsum", "dolor"],
|
31
|
+
* ["sit", "amet", "consetetur"],
|
32
|
+
* ["sadipscing"],
|
33
|
+
* ],
|
34
|
+
* );
|
35
|
+
* ```
|
36
|
+
*/
|
37
|
+
export declare function chunk<T>(array: readonly T[], size: number): T[][];
|
38
|
+
//# sourceMappingURL=chunk.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/collections/1.0.9/chunk.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAgBjE"}
|