{"size": 9062, "ext": "js", "max_stars_repo_path": "out/_next/static/chunks/pages/docs/manual/v9.0.0/api/js/undefined-ffcec2441195e81e8fe4.js", "max_stars_repo_name": "bobzhang/rescript-lang.org", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "out/_next/static/chunks/pages/docs/manual/v9.0.0/api/js/undefined-ffcec2441195e81e8fe4.js", "max_issues_repo_name": "bobzhang/rescript-lang.org", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "out/_next/static/chunks/pages/docs/manual/v9.0.0/api/js/undefined-ffcec2441195e81e8fe4.js", "max_forks_repo_name": "bobzhang/rescript-lang.org", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 9062.0, "max_line_length": 9062, "alphanum_fraction": 0.6438975944}
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[74844],{22122:function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,{Z:function(){return r}})},17375:function(e,t,n){"use strict";function r(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}n.d(t,{Z:function(){return r}})},3905:function(e,t,n){"use strict";n.d(t,{Zo:function(){return u},kt:function(){return m}});var r=n(67294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=r.createContext({}),s=function(e){var t=r.useContext(l),n=t;return e&&(n="function"===typeof e?e(t):o(o({},t),e)),n},u=function(e){var t=s(e.components);return r.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},c=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,l=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),c=s(n),m=a,g=c["".concat(l,".").concat(m)]||c[m]||d[m]||i;return n?r.createElement(g,o(o({ref:t},u),{},{components:n})):r.createElement(g,o({ref:t},u))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"===typeof e||a){var i=n.length,o=new Array(i);o[0]=c;var p={};for(var l in t)hasOwnProperty.call(t,l)&&(p[l]=t[l]);p.originalType=e,p.mdxType="string"===typeof e?e:a,o[1]=p;for(var s=2;s<i;s++)o[s]=n[s];return r.createElement.apply(null,o)}return r.createElement.apply(null,n)}c.displayName="MDXCreateElement"},96086:function(e){"use strict";var t=Object.assign.bind(Object);e.exports=t,e.exports.default=e.exports},29089:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return u}});var r,a=n(22122),i=n(17375),o=n(67294),p=n(3905),l=(o.createElement,r="Intro",function(e){return console.warn("Component "+r+" was not imported, exported, or provided by MDXProvider as global scope"),(0,p.kt)("div",e)}),s={};function u(e){var t=e.components,n=(0,i.Z)(e,["components"]);return(0,p.kt)("wrapper",(0,a.Z)({},s,n,{components:t,mdxType:"MDXLayout"}),(0,p.kt)("h1",{id:"undefined"},"Undefined"),(0,p.kt)(l,{mdxType:"Intro"},(0,p.kt)("p",null,"Provide utilities around ",(0,p.kt)("inlineCode",{parentName:"p"},"Js.undefined"),".")),(0,p.kt)("h2",{id:"t"},"t"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"prelude",prelude:!0}),"type t<'a> = Js.undefined<'a>\n")),(0,p.kt)("p",null,"Local alias for 'a Js.undefined."),(0,p.kt)("h2",{id:"return"},"return"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let return: 'a => t<'a>\n")),(0,p.kt)("p",null,"Constructs a value of ",(0,p.kt)("inlineCode",{parentName:"p"},"Js.undefined('a)")," containing a value of ",(0,p.kt)("inlineCode",{parentName:"p"},"'a"),"."),(0,p.kt)("h2",{id:"test"},"test"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let test: t<'a> => bool\n")),(0,p.kt)("p",null,"Returns ",(0,p.kt)("inlineCode",{parentName:"p"},"true")," if the given value is empty (undefined), ",(0,p.kt)("inlineCode",{parentName:"p"},"false")," otherwise."),(0,p.kt)("h2",{id:"testany"},"testAny"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let testAny: 'a => bool\n")),(0,p.kt)("p",null,"Since 1.6.1 Returns ",(0,p.kt)("inlineCode",{parentName:"p"},"true")," if the given value is empty (undefined)."),(0,p.kt)("h2",{id:"empty"},"empty"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let empty: t<'a>\n")),(0,p.kt)("p",null,"The empty value, ",(0,p.kt)("inlineCode",{parentName:"p"},"undefined"),"."),(0,p.kt)("h2",{id:"getunsafe"},"getUnsafe"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let getUnsafe: t<'a> => 'a\n")),(0,p.kt)("h2",{id:"getexn"},"getExn"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let getExn: t<'a> => 'a\n")),(0,p.kt)("h2",{id:"bind"},"bind"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let bind: (t<'a>, (. 'a) => 'b) => t<'b>\n")),(0,p.kt)("p",null,"Maps the contained value using the given function.\nIf ",(0,p.kt)("inlineCode",{parentName:"p"},"Js.undefined('a)")," contains a value, that value is unwrapped, mapped to a ",(0,p.kt)("inlineCode",{parentName:"p"},"'b")," using the given function ",(0,p.kt)("inlineCode",{parentName:"p"},"a' => 'b"),", then wrapped back up and returned as ",(0,p.kt)("inlineCode",{parentName:"p"},"Js.undefined('b)"),"."),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"example",example:!0}),'let maybeGreetWorld = (maybeGreeting: Js.undefined<string>) =>\n  Js.Undefined.bind(maybeGreeting, (. greeting) => greeting ++ " world!")\n')),(0,p.kt)("h2",{id:"iter"},"iter"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let iter: (t<'a>, (. 'a) => unit) => unit\n")),(0,p.kt)("p",null,"Iterates over the contained value with the given function.\nIf ",(0,p.kt)("inlineCode",{parentName:"p"},"Js.undefined('a)")," contains a value, that value is unwrapped and applied to the given function."),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"example",example:!0}),"let maybeSay = (maybeMessage: Js.undefined<string>) =>\n  Js.Undefined.iter(maybeMessage, (. message) => Js.log(message))\n")),(0,p.kt)("h2",{id:"fromoption"},"fromOption"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let fromOption: option<'a> => t<'a>\n")),(0,p.kt)("p",null,"Maps ",(0,p.kt)("inlineCode",{parentName:"p"},"option('a)")," to ",(0,p.kt)("inlineCode",{parentName:"p"},"Js.undefined('a)"),".\n",(0,p.kt)("inlineCode",{parentName:"p"},"Some(a)")," => ",(0,p.kt)("inlineCode",{parentName:"p"},"a"),"\n",(0,p.kt)("inlineCode",{parentName:"p"},"None")," => ",(0,p.kt)("inlineCode",{parentName:"p"},"empty")),(0,p.kt)("h2",{id:"from_opt"},"from_opt"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let from_opt: option<'a> => t<'a>\n")),(0,p.kt)("h2",{id:"tooption"},"toOption"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let toOption: t<'a> => option<'a>\n")),(0,p.kt)("p",null,"Maps ",(0,p.kt)("inlineCode",{parentName:"p"},"Js.undefined('a)")," to ",(0,p.kt)("inlineCode",{parentName:"p"},"option('a)"),"\n",(0,p.kt)("inlineCode",{parentName:"p"},"a")," => ",(0,p.kt)("inlineCode",{parentName:"p"},"Some(a)"),"\n",(0,p.kt)("inlineCode",{parentName:"p"},"empty")," => ",(0,p.kt)("inlineCode",{parentName:"p"},"None")),(0,p.kt)("h2",{id:"to_opt"},"to_opt"),(0,p.kt)("pre",null,(0,p.kt)("code",(0,a.Z)({parentName:"pre"},{className:"language-res",metastring:"sig",sig:!0}),"let to_opt: t<'a> => option<'a>\n")))}u.isMDXComponent=!0,u.frontmatter={__ghEditHref:"https://github.com/reason-association/rescript-lang.org/blob/master/pages/docs/manual/v9.0.0/api/js/undefined.mdx"}},1137:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/docs/manual/v9.0.0/api/js/undefined",function(){return n(29089)}])}},function(e){e.O(0,[49774],(function(){return t=1137,e(e.s=t);var t}));var t=e.O();_N_E=t}]);