UNPKG

can

Version:

MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.

1,021 lines (684 loc) 33.8 kB
<!DOCTYPE html> <!--#################################################################### THIS IS A GENERATED FILE -- ANY CHANGES MADE WILL BE OVERWRITTEN INSTEAD CHANGE: source: [object Object] @typedef can-define.types.propDefinition ######################################################################## --> <html lang="en"> <head> <meta charset="utf-8"> <title>CanJS - PropDefinition</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel="stylesheet" type="text/css" href="./static/bundles/bit-docs-site/static.css"> <link rel="shortcut icon" sizes="16x16 24x24 32x32 48x48 64x64" href="/docs/images/canjs_favicon.ico"> <link rel="apple-touch-icon" sizes="57x57" href="../docs/images/canjs_favicon_57x57.png"> <link rel="apple-touch-icon-precomposed" sizes="57x57" href="../docs/images/canjs_favicon_57x57.png"> <link rel="apple-touch-icon" sizes="72x72" href="../docs/images/canjs_favicon_72x72.png"> <link rel="apple-touch-icon" sizes="114x114" href="../docs/images/canjs_favicon_114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="../docs/images/canjs_favicon_128x128.png"> <link rel="apple-touch-icon" sizes="144x144" href="../docs/images/canjs_favicon_144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="../docs/images/canjs_favicon_152x152.png"> <meta content="yes" name="apple-mobile-web-app-capable"> <meta name="apple-mobile-web-app-status-bar-style" content="white-translucent"> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-2302003-11', 'auto'); ga('send', 'pageview'); </script> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger"/> <label for="nav-trigger">Menu</label> <div id="everything"> <div id="left" class="column"> <div class="top-left"> <div class="brand"> <div class="logo"> <a href="../index.html" alt="CanJS"></a> <div class="dropdown project-dropdown"> <a href="https://donejs.com/">DoneJS</a> <a href="http://stealjs.com/">StealJS</a> <a href="http://jquerypp.com/">jQuery ++</a> <a href="https://funcunit.com/">FuncUnit</a> <a href="http://documentjs.com/">DocumentJS</a> </div> </div> <div class="version"> <div class="version-number"> 3.0.0 </div> <div class="dropdown version-dropdown"> <a href="https://v2.canjs.com">2.3.27</a> </div> </div> </div> <div class="search-bar"> <p> &nbsp; </p> </div> </div> <div class="bottom-left"> <div class="social-side-container"> <ul class="social-side"> <li> <a class="header-mobile github" href="https://github.com/canjs/canjs" target="_blank"><img class="social-icon-small" src="../docs/images/github.png">Github</a> </li> <li> <a class="header-mobile twitter" href="https://twitter.com/canjs" target="_blank"><img class="social-icon-small" src="../docs/images/twitter.png">Twitter</a> </li> </ul> <ul class="social-side"> <li> <a class="header-mobile" href="https://gitter.im/canjs/canjs" target="_blank">Chat</a> </li> <li> <a class="header-mobile" href="http://forums.donejs.com/c/canjs" target="_blank">Forum</a> </li> </ul> </div> <ul> <li class=" "> <a class="page" href="guides.html" title="Welcome to CanJS! These guides are here to help you develop and improve your relationship with CanJS. After all, picking a JavaScript framework is a commitment. We want CanJS to be the framework you marry. This page helps you know how advance through the different stages of this relationship:"> Guides </a> </li> <li class=" parent expanded"> <a class="page" href="can-core.html" title="The best, most hardened and generally useful libraries in CanJS."> Core </a> <ul> <li class=" "> <a class="module" href="can-component.html" title="Create a custom element that can be used to manage widgets or application logic."> can-component </a> </li> <li class=" "> <a class="module" href="can-compute.html" title="Create an observable value."> can-compute </a> </li> <li class=" "> <a class="module" href="can-connect.html" title="can-connect provides persisted data middleware. Use it to assemble powerful model layers for any JavaScript project."> can-connect </a> </li> <li class=" parent expanded"> <a class="module" href="can-define.html" title="Exports the define method that defines observable properties and their behavior on a prototype object."> can-define </a> <ul> <li> <span>static</span> <ul> <li class=" "> <a class="property" href="can-define.types.html" title="Defines the type, initial value, and get, set, and serialize behavior for an observable property. All type converters leave null and undefined as is except for the &quot;htmlbool&quot; type converter."> types </a> </li> </ul> </li> <li> <span>types</span> <ul> <li class="current parent expanded"> <a class="typedef" href="can-define.types.propDefinition.html" title="Defines the type, initial value, and get, set, and serialize behavior for an observable property. These behaviors can be specified with as an Object, String, Constructor function, Array, a getter expression, or setter expression."> PropDefinition </a> </li> </ul> </li> <li> <span>behaviors</span> <ul> <li class=" "> <a class="typedef" href="can-define.types.TypeConstructor.html" title="Provides a constructor function to be used to convert any set value into an appropriate value."> Type </a> </li> <li class=" "> <a class="function" href="can-define.types.ValueConstructor.html" title="Provides a constructor function to be used to provide a default value for a property."> Value </a> </li> <li class=" "> <a class="function" href="can-define.types.get.html" title="Specify what happens when a certain property is read on a map. get functions work like a can-compute and automatically update themselves when a dependent observable value is changed."> get </a> </li> <li class=" "> <a class="function" href="can-define.types.serialize.html" title="Defines custom serialization behavior for a property."> serialize </a> </li> <li class=" "> <a class="function" href="can-define.types.set.html" title="Specify what happens when a property value is set."> set </a> </li> <li class=" "> <a class="typedef" href="can-define.types.type.html" title="Converts a value set on an instance into an appropriate value."> type </a> </li> <li class=" "> <a class="function" href="can-define.types.value.html" title="Returns the default value for instances of the defined type. The default value is defined on demand, when the property is read for the first time."> value </a> </li> </ul> </li> </ul> </li> <li class=" "> <a class="module" href="can-define/list/list.html" title="Create observable lists."> can-define/list/list </a> </li> <li class=" "> <a class="module" href="can-define/map/map.html" title="Create observable objects."> can-define/map/map </a> </li> <li class=" "> <a class="function" href="can-route.html" title="Manage browser history and client state by synchronizing the window.location.hash with a map."> can-route </a> </li> <li class=" "> <a class="module" href="can-route-pushstate.html" title="Changes can-route to use pushstate to change the window&#x27;s pathname instead of the hash. var route = require(&quot;can-route-pushstate&quot;); route(&quot;{page}&quot;, { page: &quot;home&quot; }); route.ready(); route.attr(&quot;page&quot;, &quot;user&quot;); location.pathname; // -&gt; &quot;/user&quot;"> can-route-pushstate </a> </li> <li class=" "> <a class="module" href="can-set.html" title="can-set is a utility for comparing sets that are represented by the parameters commonly passed to service requests."> can-set </a> </li> <li class=" "> <a class="module" href="can-stache.html" title="Live binding Mustache and Handlebars-compatible templates."> can-stache </a> </li> <li class=" "> <a class="module" href="can-stache/helpers/route.html" title="Adds stache helpers that use can-route."> can-stache/helpers/route </a> </li> <li class=" "> <a class="module" href="can-stache-bindings.html" title="Provides template event, one-way, and two-way bindings."> can-stache-bindings </a> </li> </ul> </li> <li class=" "> <a class="page" href="can-ecosystem.html" title="Useful libraries that extend or add important features to the core collection."> Ecosystem </a> </li> <li class=" "> <a class="page" href="can-infrastructure.html" title="Utility libraries that power the core and ecosystem collection."> Infrastructure </a> </li> <li class=" "> <a class="page" href="can-legacy.html" title="Former libraries that we still accept patches for, but are not under active development."> Legacy </a> </li> </ul> </div> </div> <div id="right" class="column"> <div class="top-right"> <div class="top-right-top"> <ul class="top-right-bitovi"> <li class="dropdown"> <a href="http://bitovi.com" class="bitovi icon-bits">Bitovi</a> <ul class="dropdown-menu"> <li><a href="http://bitovi.com">Bitovi.com</a></li> <li><a href="http://bitovi.com/blog/">Blog</a></li> <li><a href="http://bitovi.com/consulting/">Consulting</a></li> <li><a href="http://bitovi.com/training/">Training</a></li> <li><a href="http://bitovi.com/open-source/">Open Source</a></li> </ul> </li> </ul> <div class="brand"> <div class="logo"> <a href="../index.html" alt="CanJS"></a> </div> </div> <ul class="top-right-links"> <li> <a href="https://gitter.im/canjs/canjs">Chat</a> </li> <li> <a href="http://forums.donejs.com/c/canjs">Forum</a> </li> <li> <a class="github-button nav-social" href="https://github.com/canjs/canjs" data-count-href="/canjs/canjs/stargazers" data-count-api="/repos/canjs/canjs#stargazers_count">Star</a> </li> <li> <a href="https://twitter.com/canjs" class="twitter-follow-button nav-social" data-show-count="true" data-show-screen-name="false">Follow @canjs</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> </li> </ul> </div> <div class="breadcrumb"> <li><a href="../index.html">CanJS</a></li> / <li><a href="can-core.html">Core</a></li> / <li><a href="can-define.html">can-define</a></li> / <li><a href="can-define.types.propDefinition.html">PropDefinition</a></li> <li class="breadcrumb-dropdown">/ <a> On this page</a> <ul class="on-this-page"></ul> </li> <div class="nav-toggle" title="Back to top"></div> </div> </div> <div class="bottom-right"> <article> <section class="title"> <div class="page-type"> <h1>PropDefinition</h1> <div>typedef</div> </div> <section class="description"> <p>Defines the type, initial value, and get, set, and serialize behavior for an observable property. These behaviors can be specified with as an <code>Object</code>, <code>String</code>, <code>Constructor</code> function, <code>Array</code>, a <code>getter expression</code>, or <code>setter expression</code>.</p> </section> </section> <section class="on-this-page-table"> </section> <section class="title-footer"> <ul class="title-links"> <!-- <li><a href="#">docco</a></li> --> <li><a href="//github.com/canjs/can-define/tree/v1.0.4/docs/types.propDefinition.md">source</a></li> <!-- <li><a href="#">download</a></li> --> <!-- <li><a href="#">tests</a></li> --> </ul> </section> <div class="signature"> <h2 class="signature-title"> <code>Object</code> </h2> <p>Defines multiple behaviors for a single property.</p> <pre><code class="language-js">propertyName: { get: function(){ ... }, set: function(){ ... }, type: function(){ ... }, Type: Constructor, value: function(){ ... }, Value: Constructor, serialize: function(){ ... } } </code></pre> <div class="options"> <h3 class="options-title">Options</h3> <ul> <li> <b>value</b> <code>{<a href="can-define.types.value.html" title="Returns the default value for instances of the defined type. The default value is defined on demand, when the property is read for the first time.">value</a>()}</code>: <p>Specifies the initial value of the property or a function that returns the initial value.</p> <pre><code class="language-js">// A default age of `0`: var Person = DefineMap.extend({ age: { value: 0 }, address: { value: function(){ return {city: &quot;Chicago&quot;, state: &quot;IL&quot;}; }; } }); </code></pre> </li> <li> <b>Value</b> <code>{<a href="can-define.types.ValueConstructor.html" title="Provides a constructor function to be used to provide a default value for a property.">Value</a>()}</code>: <p>Specifies a function that will be called with <code>new</code> whose result is set as the initial value of the attribute.</p> <pre><code class="language-js">// A default empty DefineList of hobbies: var Person = DefineMap.extend({ hobbies: {Value: DefineList} }); new Person().hobbies //-&gt; [] </code></pre> </li> <li> <b>type</b> <code>{<a href="can-define.types.type.html" title="Converts a value set on an instance into an appropriate value.">type</a>()}</code>: <p>Specifies the type of the property. The type can be specified as either a function that returns the type coerced value or one of the <a href="can-define.types.html" title="Defines the type, initial value, and get, set, and serialize behavior for an observable property. All type converters leave null and undefined as is except for the &quot;htmlbool&quot; type converter.">types</a> names.</p> <pre><code class="language-js">var Person = DefineMap.extend({ age: {type: &quot;number&quot;}, hobbies: { type: function(newValue){ if(typeof newValue === &quot;string&quot;) { return newValue.split(&quot;,&quot;) } else if( Array.isArray(newValue) ) { return newValue; } } } }); </code></pre> </li> <li> <b>Type</b> <code>{<a href="can-define.types.TypeConstructor.html" title="Provides a constructor function to be used to convert any set value into an appropriate value.">Type</a>()}</code>: <p>A constructor function that takes the assigned property value as the first argument and called with new. For example, the following will call <code>new Address(newValue)</code> with whatever non null, undefined, or address type is set as a <code>Person</code>'s address property.</p> <pre><code class="language-js">var Address = DefineMap.extend({ street: &quot;string&quot;, state: &quot;string&quot; }); var Person = DefineMap.extend({ address: {Type: Address} }); </code></pre> </li> <li> <b>set</b> <code>{<a href="can-define.types.set.html" title="Specify what happens when a property value is set.">set</a>(newVal, resolve)}</code>: <p>A set function that specifies what should happen when a property is set. <code>set</code> is called with the result of <code>type</code> or <code>Type</code>. The following defines a <code>page</code> setter that updates the map's offset:</p> <pre><code class="language-js">DefineMap.extend({ page: { set: function(newVal){ this.offset = (parseInt(newVal) - 1) * this.limit; } } }); </code></pre> </li> <li> <b>get</b> <code>{<a href="can-define.types.get.html" title="Specify what happens when a certain property is read on a map. get functions work like a can-compute and automatically update themselves when a dependent observable value is changed.">get</a>(lastSetValue)}</code>: <p>A function that specifies how the value is retrieved. The get function is converted to an <a href="can-compute.async.html" title="Create a compute that can set its value after the computed function has been called.">async compute</a>. It should derive its value from other values on the object. The following defines a <code>page</code> getter that reads from a map's offset and limit:</p> <pre><code class="language-js">DefineMap.extend({ page: { get: function (newVal) { return Math.floor(this.offset / this.limit) + 1; } } }); </code></pre> <p>A <code>get</code> definition makes the property <strong>computed</strong> which means it will not be enumerable by default.</p> </li> <li> <b>serialize</b> <code>{<a href="can-define.types.serialize.html" title="Defines custom serialization behavior for a property.">serialize</a>()}</code>: <p>Specifies the behavior of the property when <a href="can-define/map/map.prototype.serialize.html" title="Get a serialized representation of the map instance and its children.">serialize</a> is called.</p> <p>By default, serialize does not include computed values. Properties with a <code>get</code> definition are computed and therefore are not added to the result. Non-computed properties values are serialized if possible and added to the result.</p> <pre><code class="language-js">var Todo = DefineMap.extend({ date: { type: &quot;date&quot;, serialize: function(value) { return value.getTime(); } } }); </code></pre> </li> </ul> </div> </div> <div class="signature"> <h2 class="signature-title"> <code>String</code> </h2> <p>Defines a <a href="can-define.types.type.html" title="Converts a value set on an instance into an appropriate value.">type</a> converter as one of the named types in <a href="can-define.types.html" title="Defines the type, initial value, and get, set, and serialize behavior for an observable property. All type converters leave null and undefined as is except for the &quot;htmlbool&quot; type converter.">types</a>.</p> <pre><code class="language-js">propertyName: &quot;typeName&quot; </code></pre> </div> <div class="signature"> <h2 class="signature-title"> <code>function()</code> </h2> <p>Defines a <a href="can-define.types.TypeConstructor.html" title="Provides a constructor function to be used to convert any set value into an appropriate value.">Type</a> setting with a constructor function. Constructor functions are identified with <a href="can-util/js/types/types.isConstructor.html" title="can-util/js/types/types.isConstructor">isConstructor</a>.</p> <pre><code>propertyName: Constructor </code></pre> </div> <div class="signature"> <h2 class="signature-title"> <code>Array</code> </h2> <p>Defines an inline <a href="can-define/list/list.html" title="Create observable lists.">can-define/list/list</a> Type setting. This is used as a shorthand for creating a property that is an <a href="can-define/list/list.html" title="Create observable lists.">can-define/list/list</a> of another type.</p> <pre><code>propertyName: [Constructor | propDefinitions] </code></pre> <p>For example:</p> <pre><code class="language-js">users: [User], todos: [{complete: &quot;boolean&quot;, name: &quot;string&quot;}] </code></pre> </div> <div class="signature"> <h2 class="signature-title"> <code>GETTER</code> </h2> <p>Defines a property's <a href="can-define.types.get.html" title="Specify what happens when a certain property is read on a map. get functions work like a can-compute and automatically update themselves when a dependent observable value is changed.">get</a> behavior with the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get" title="syntax">syntax</a>.</p> <pre><code class="language-js">get propertyName(){ ... } </code></pre> <p>For example:</p> <pre><code class="language-js">get fullName() { return this.first + &quot; &quot; + this.last; } </code></pre> <p>This is a shorthand for providing an object with a <code>get</code> property like:</p> <pre><code>fullName: { get: function(){ return this.first + &quot; &quot; + this.last; } } </code></pre> <p>You must use an object with a <a href="can-define.types.get.html" title="Specify what happens when a certain property is read on a map. get functions work like a can-compute and automatically update themselves when a dependent observable value is changed.">get</a> property if you want your get to take the <code>lastSetValue</code> or <code>resolve</code> arguments.</p> </div> <div class="signature"> <h2 class="signature-title"> <code>SETTER</code> </h2> <p>Defines a property's <a href="can-define.types.set.html" title="Specify what happens when a property value is set.">set</a> behavior with the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set">set syntax</a>.</p> <pre><code class="language-js">set propertyName(newValue){ ... } </code></pre> <p>For example:</p> <pre><code class="language-js">set fullName(newValue) { var parts = newVal.split(&quot; &quot;); this.first = parts[0]; this.last = parts[1]; } </code></pre> <p>This is a shorthand for providing an object with a <code>set</code> property like:</p> <pre><code>fullName: { set: function(newValue){ var parts = newVal.split(&quot; &quot;); this.first = parts[0]; this.last = parts[1]; } } </code></pre> <p>You must use an object with a <a href="can-define.types.set.html" title="Specify what happens when a property value is set.">set</a> property if you want your set to take the <code>resolve</code> argument.</p> </div> <section class="body"> <h2>Use</h2> <p>A property definition can be defined in several ways. The <code>Object</code> form is the most literal and directly represents a <code>PropDefinition</code> object. The other forms get converted to a <code>PropDefinition</code> as follows:</p> <pre><code class="language-js">DefineMap.extend({ propertyA: Object -&gt; PropertyDefinition propertyB: String -&gt; {type: String} propertyC: Constructor -&gt; {Type: Constructor} propertyD: [PropDefs] -&gt; {Type: DefineList.extend({&quot;#&quot;: PropDefs})&gt;} get propertyE(){...} -&gt; {get: propertyE(){...}} set propertyF(){...} -&gt; {get: propertyF(){...}} method: Function }) </code></pre> <p>Within a property definition, the available properties and their signatures look like:</p> <pre><code class="language-js">DefineMap.extend({ property: { get: function(lastSetValue, resolve){...}, set: function(newValue, resolve){...}, type: function(newValue, prop){...}| Array&lt;PropertyDefinition&gt; | PropertyDefinition, Type: Constructor | Array&lt;PropertyDefinition&gt; | PropertyDefinition, value: function(){...}, Value: Constructor, serialize: Boolean | function(){...} } }) </code></pre> <p>For example:</p> <pre><code class="language-js">var Person = DefineMap.extend(&quot;Person&quot;,{ // a `DefineList` of `Address` addresses: [Address], // A `DefineMap` with a `first` and `last` property name: { type: {first: &quot;string&quot;, last: &quot;string&quot;} }, // A `DefineList of a ``DefineMap` with a `make` and `year` property. cars: { Type: [{make: &quot;string&quot;, year: &quot;number&quot;}] } }); var person = new Person({ addresses: [{street: &quot;1134 Pinetree&quot;}], name: {first: &quot;Kath&quot;, last: &quot;Iann&quot;} cars: [{ make: &quot;Nissan&quot;, year: 2010 }] }); </code></pre> </section> <script type="text/javascript"> var docObject = {"src":{"path":"node_modules/can-define/docs/types.propDefinition.md"},"description":"\nDefines the type, initial value, and get, set, and serialize behavior for an\nobservable property. These behaviors can be specified with as an `Object`, `String`,\n`Constructor` function, `Array`, a `getter expression`, or `setter expression`.\n","type":"typedef","title":"PropDefinition","types":[{"type":"Object","description":"Defines multiple behaviors for a single property.\n\n```js\npropertyName: {\n get: function(){ ... },\n set: function(){ ... },\n type: function(){ ... },\n Type: Constructor,\n value: function(){ ... },\n Value: Constructor,\n serialize: function(){ ... }\n}\n```\n","options":[{"name":"value","description":"Specifies the initial value of the property or\na function that returns the initial value.\n\n```js\n// A default age of `0`:\nvar Person = DefineMap.extend({\n age: {\n value: 0\n },\n address: {\n value: function(){\n return {city: \"Chicago\", state: \"IL\"};\n };\n }\n});\n```\n","types":[{"type":"can-define.types.value"}]},{"name":"Value","description":"Specifies a function that will be called with `new` whose result is\nset as the initial value of the attribute.\n\n```js\n// A default empty DefineList of hobbies:\nvar Person = DefineMap.extend({\n hobbies: {Value: DefineList}\n});\n\nnew Person().hobbies //-> []\n```\n","types":[{"type":"can-define.types.ValueConstructor"}]},{"name":"type","description":"Specifies the type of the\nproperty. The type can be specified as either a function\nthat returns the type coerced value or one of the [can-define.types] names.\n\n```js\nvar Person = DefineMap.extend({\n age: {type: \"number\"},\n hobbies: {\n type: function(newValue){\n if(typeof newValue === \"string\") {\n return newValue.split(\",\")\n } else if( Array.isArray(newValue) ) {\n return newValue;\n }\n }\n }\n});\n```\n","types":[{"type":"can-define.types.type"}]},{"name":"Type","description":"A constructor function that takes\nthe assigned property value as the first argument and called with new. For example, the following will call\n`new Address(newValue)` with whatever non null, undefined, or address type is set as a `Person`'s address property.\n\n```js\nvar Address = DefineMap.extend({\n street: \"string\",\n state: \"string\" \n});\n\nvar Person = DefineMap.extend({\n address: {Type: Address} \n});\n```\n","types":[{"type":"can-define.types.TypeConstructor"}]},{"name":"set","description":"A set function that specifies what should happen when a property is set. `set` is called with the result of `type` or `Type`. The following\ndefines a `page` setter that updates the map's offset:\n\n```js\nDefineMap.extend({\n page: {\n set: function(newVal){\n this.offset = (parseInt(newVal) - 1) * this.limit;\n }\n }\n});\n```\n","types":[{"type":"can-define.types.set"}]},{"name":"get","description":"A function that specifies how the value is retrieved. The get function is\nconverted to an [can-compute.async async compute]. It should derive its value from other values on the object. The following\ndefines a `page` getter that reads from a map's offset and limit:\n\n```js\nDefineMap.extend({\n page: {\n get: function (newVal) {\n\t return Math.floor(this.offset / this.limit) + 1;\n\t}\n }\n});\n```\n\nA `get` definition makes the property __computed__ which means it will not be enumerable by default.\n","types":[{"type":"can-define.types.get"}]},{"name":"serialize","description":"Specifies the behavior of the property when [can-define/map/map::serialize serialize] is called.\n\nBy default, serialize does not include computed values. Properties with a `get` definition\nare computed and therefore are not added to the result. Non-computed properties values are\nserialized if possible and added to the result.\n\n```js\nvar Todo = DefineMap.extend({\n date: {\n type: \"date\",\n serialize: function(value) {\n return value.getTime();\n }\n }\n});\n","types":[{"type":"can-define.types.serialize"}]}]},{"type":"String","description":"Defines a [can-define.types.type] converter as one of the named types in [can-define.types].\n\n```js\npropertyName: \"typeName\"\n```\n"},{"type":"Constructor","description":"Defines a [can-define.types.TypeConstructor Type] setting with a constructor\nfunction. Constructor functions are identified with [can-util/js/types/types.isConstructor].\n\n```\npropertyName: Constructor\n```\n"},{"type":"Array","description":"Defines an inline [can-define/list/list] Type setting. This is\nused as a shorthand for creating a property that is an [can-define/list/list] of another type.\n\n```\npropertyName: [Constructor | propDefinitions]\n```\n\nFor example:\n\n```js\nusers: [User],\ntodos: [{complete: \"boolean\", name: \"string\"}]\n```\n","options":[]},{"type":"GETTER","description":"Defines a property's [can-define.types.get] behavior with the\n[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get syntax].\n\n```js\nget propertyName(){ ... }\n```\n\nFor example:\n\n```js\nget fullName() {\n return this.first + \" \" + this.last;\n}\n```\n\nThis is a shorthand for providing an object with a `get` property like:\n\n```\nfullName: {\n get: function(){\n return this.first + \" \" + this.last;\n }\n}\n```\n\nYou must use an object with a [can-define.types.get] property if you want your get to take the `lastSetValue`\nor `resolve` arguments.\n"},{"type":"SETTER","description":"Defines a property's [can-define.types.set] behavior with the\n[set syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set).\n\n```js\nset propertyName(newValue){ ... }\n```\n\nFor example:\n\n```js\nset fullName(newValue) {\n var parts = newVal.split(\" \");\n this.first = parts[0];\n this.last = parts[1];\n}\n```\n\nThis is a shorthand for providing an object with a `set` property like:\n\n```\nfullName: {\n set: function(newValue){\n var parts = newVal.split(\" \");\n this.first = parts[0];\n this.last = parts[1];\n }\n}\n```\n\nYou must use an object with a [can-define.types.set] property if you want your set to take the `resolve` argument.\n\n"}],"name":"can-define.types.propDefinition","parent":"can-define.typedefs","comment":" ","pathToRoot":".."}; </script> </article> <footer><p>CanJS is part of <a href="http://donejs.com" target="_blank">DoneJS</a>. Created and maintained by the core <a href="https://donejs.com/About.html#section=section_Team" target="_blank">DoneJS team</a> and <a href="http://bitovi.com" target="_blank">Bitovi</a>. <strong>Currently 3.0.0.</strong></p></footer> </div> </div> </div> <script> steal = { instantiated: { "bundles/bit-docs-site/static.css!$css" : null } }; </script> <script type='text/javascript' data-main="bit-docs-site/static" src="./static/node_modules/steal/steal.production.js"></script> <script async defer src="https://buttons.github.io/buttons.js"></script> </body> </html>