mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2025-01-11 04:25:52 +00:00
36103fbca0
* Testing some option types over the API. * v0.17.0-rc.6 * Removing a few to better test. * v0.17.0-rc.7 * Simpler again. * v0.17.0-rc.8 * Trying swan.io boxed * v0.17.0-rc.13 * Trying option-t * v0.17.0-rc.14 * Adding rust-style Options using @sniptt/monads - Also added serialization with class-transformer * v0.17.0-rc.15 * Trying to fix encodeGetParams. * v0.17.0-rc.16 * Trying to fix encodeGetParams 2. * v0.17.0-rc.17 * Using init constructors. * v0.17.0-rc.18 * v0.17.0-rc.19 * Add more type info. * v0.17.0-rc.20 * Adding reflect-metadata * v0.17.0-rc.21 * Adding type to siteview.site * v0.17.0-rc.22 * Adding rest of nested types. * v0.17.0-rc.23 * Adding toOption function. * v0.17.0-rc.24 * Trying to fix send. * v0.17.0-rc.25 * Try to stringify jsonres. * v0.17.0-rc.26 * Try to stringify jsonres 2. * v0.17.0-rc.27 * Adding toOption function. * v0.17.0-rc.28 * Forgot to type a communityview. * v0.17.0-rc.29 * Forgot to type a registrationapplicationview. * v0.17.0-rc.30
15 lines
356 B
TypeScript
15 lines
356 B
TypeScript
import { Option, Some } from "@sniptt/monads";
|
|
|
|
/**
|
|
* Converts an option to an undefined. Necessary for API requests.
|
|
*/
|
|
export function toUndefined<T>(opt: Option<T>) {
|
|
return opt.isSome() ? opt.unwrap() : undefined;
|
|
}
|
|
|
|
/**
|
|
* Converts a null value to an option.
|
|
*/
|
|
export function toOption<T>(val: T): Option<T> {
|
|
return Some(val || undefined);
|
|
}
|