Skip to content

Instantly share code, notes, and snippets.

@BigAB
Forked from akagomez/GREADME.md
Last active June 8, 2016 18:25
Show Gist options
  • Save BigAB/fa96d836f6ec522ed2f571e37ed3fc42 to your computer and use it in GitHub Desktop.
Save BigAB/fa96d836f6ec522ed2f571e37ed3fc42 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