Skip to content

Instantly share code, notes, and snippets.

@akagomez
Forked from justinbmeyer/GREADME.md
Last active June 8, 2016 18:23
Show Gist options
  • Save akagomez/463fbc857aab737e8ba4f4002689432d to your computer and use it in GitHub Desktop.
Save akagomez/463fbc857aab737e8ba4f4002689432d to your computer and use it in GitHub Desktop.

API

can.DefineMap.extend([name,] [static,] prototype)

Extends can.DefineMap, or constructor functions derived from can.DefineMap, to create a new constructor function.

var Person = can.DefineMap.extend(
  "Person",
  {seal: true},
  {
    first: "string",
    last: "string",
    fullName: {
      get: function(){
        return this.first+" "+this.last;
      }
    }
  })
arguments:
- __name__ `{String}`: Provides an optional name for this type that will show up nicely in debuggers.
  • static {Object}: Static properties that are set directly on the constructor function.

  • prototype {Object<String,can-define-map.propDefinition>}: A definition of the properties or methods on this type.

returns:
  • {can-define-map}: A DefineMap constructor function.

new can.DefineMap([props])

Creates a new instance of DefineMap or an extended DefineMap.

var person = new can.DefineMap({
  first: "Justin",
  last: "Meyer"
})
arguments:
- __props__ `{Object}`: Properties and values to seed the map with.
returns:
  • {can-define-map}: An instance of can.DefineMap with the properties from props.

map.each( callback(item, propName ) )

each iterates through the Map, calling a function for each property value and key.

arguments:
- __callback__ `{function(item, propName)}`: the function to call for each property The value and key of each property will be passed as the first and second arguments, respectively, to the callback. If the callback returns false, the loop will stop.
returns:
  • {can.Map}: this Map, for chaining
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment