DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
      • types
        • Set
        • Compares
        • Prop
      • properties
        • Algebra
          • prototype
            • difference
            • equal
            • getSubset
            • getUnion
            • has
            • index
            • intersection
            • properSubset
            • subset
            • union
        • Translate
        • props
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-set
  • /
  • Algebra
  • /
  • index
  • / On this page
    • index

      function
      • source

      algebra.index(set, items, item)

      Returns where item should be inserted into items which is represented by set.

      algebra = new set.Algebra(
        set.props.sort("orderBy")
      );
      algebra.index(
        {orderBy: "age"},
        [{id: 1, age: 3},{id: 2, age: 5},{id: 3, age: 8},{id: 4, age: 10}],
        {id: 6, age: 3}
      )  //-> 2
      

      The default sort property is what is specified by id. This means if that if the sort property is not specified, it will assume the set is sorted by the specified id property.

      Parameters

      1. set {Set}:

        The set that describes items.

      2. items {Array<Object>}:

        An array of data objects.

      3. item {Object}:

        The data object to be inserted.

      Returns

      {Number}:

      The position to insert item.

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.