lib/collection/property-list.js
function (item, before) {
        if (!_.isObject(item)) { return; } // do not proceed on empty param

        var duplicate = this.indexOf(item),
            index;

        // remove from previous list
        PropertyList.isPropertyList(item[__PARENT]) && (item[__PARENT] !== this) && item[__PARENT].remove(item);
        // inject the parent reference
        _.assignHidden(item, __PARENT, this);

        // ensure that we do not double insert things into member array
        (duplicate > -1) && this.members.splice(duplicate, 1);
        // find the position of the reference element
        before && (before = this.indexOf(before));

        // inject to the members array ata position or at the end in case no item is there for reference
        (before > -1) ? this.members.splice(before, 0, item) : this.members.push(item);

        // store reference by id, so create the index string. we first ensure that the index value is truthy and then
        // recheck that the string conversion of the same is truthy as well.
        if ((index = item[this._postman_listIndexKey]) && (index = String(index))) {
            // desensitise case, if the property needs it to be
            this._postman_listIndexCaseInsensitive && (index = index.toLowerCase());

            // if multiple values are allowed, the reference may contain an array of items, mapped to an index.
            if (this._postman_listAllowsMultipleValues && this.reference.hasOwnProperty(index)) {

                // if the value is not an array, convert it to an array.
                !_.isArray(this.reference[index]) && (this.reference[index] = [this.reference[index]]);

                // add the item to the array of items corresponding to this index
                this.reference[index].push(item);
            }
            else {
                this.reference[index] = item;
            }
        }
    }
function (item, before) {
        if (!_.isObject(item)) { return; } // do not proceed on empty param

        var duplicate = this.indexOf(item),
            index;

        // remove from previous list
        PropertyList.isPropertyList(item[__PARENT]) && (item[__PARENT] !== this) && item[__PARENT].remove(item);
        // inject the parent reference
        _.assignHidden(item, __PARENT, this);

        // ensure that we do not double insert things into member array
        (duplicate > -1) && this.members.splice(duplicate, 1);
        // find the position of the reference element
        before && (before = this.indexOf(before));

        // inject to the members array ata position or at the end in case no item is there for reference
        (before > -1) ? this.members.splice(before, 0, item) : this.members.push(item);

        // store reference by id, so create the index string. we first ensure that the index value is truthy and then
        // recheck that the string conversion of the same is truthy as well.
        if ((index = item[this._postman_listIndexKey]) && (index = String(index))) {
            // desensitise case, if the property needs it to be
            this._postman_listIndexCaseInsensitive && (index = index.toLowerCase());

            // if multiple values are allowed, the reference may contain an array of items, mapped to an index.
            if (this._postman_listAllowsMultipleValues && this.reference.hasOwnProperty(index)) {

                // if the value is not an array, convert it to an array.
                !_.isArray(this.reference[index]) && (this.reference[index] = [this.reference[index]]);

                // add the item to the array of items corresponding to this index
                this.reference[index].push(item);
            }
            else {
                this.reference[index] = item;
            }
        }
    }
function ( item , before ) { if ( ! _ . isObject ( item ) ) { return ; } // do not proceed on empty param var duplicate = this . indexOf ( item ) , index ; // remove from previous list PropertyList . isPropertyList ( item [ __PARENT ] ) && ( item [ __PARENT ] !== this ) && item [ __PARENT ] . remove ( item ) ; // inject the parent reference _ . assignHidden ( item , __PARENT , this ) ; // ensure that we do not double insert things into member array ( duplicate > - 1 ) && this . members . splice ( duplicate , 1 ) ; // find the position of the reference element before && ( before = this . indexOf ( before ) ) ; // inject to the members array ata position or at the end in case no item is there for reference ( before > - 1 ) ? this . members . splice ( before , 0 , item ) : this . members . push ( item ) ; // store reference by id, so create the index string. we first ensure that the index value is truthy and then // recheck that the string conversion of the same is truthy as well. if ( ( index = item [ this . _postman_listIndexKey ] ) && ( index = String ( index ) ) ) { // desensitise case, if the property needs it to be this . _postman_listIndexCaseInsensitive && ( index = index . toLowerCase ( ) ) ; // if multiple values are allowed, the reference may contain an array of items, mapped to an index. if ( this . _postman_listAllowsMultipleValues && this . reference . hasOwnProperty ( index ) ) { // if the value is not an array, convert it to an array. ! _ . isArray ( this . reference [ index ] ) && ( this . reference [ index ] = [ this . reference [ index ] ] ) ; // add the item to the array of items corresponding to this index this . reference [ index ] . push ( item ) ; } else { this . reference [ index ] = item ; } } }
Insert an element at the end of this list. When a reference member specified via second parameter is found, the
member is inserted at an index before the reference member.

@param {PropertyList.Type} item
@param {PropertyList.Type|String} [before]
Insert an element at the end of this list . When a reference member specified via second parameter is found the member is inserted at an index before the reference member .