创建 reducer
@param {Array} models model 列表
543935
function createReducers() {
  var models = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  // 已经定义的 namespace
  var existentNamespace = {}; // 根 reducers

  var rootReducers = {};
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    var _loop = function _loop() {
      var model = _step.value;
      var namespace = model.namespace,
          _model$reducers = model.reducers,
          reducers = _model$reducers === void 0 ? {} : _model$reducers,
          _model$state = model.state,
          modelInitState = _model$state === void 0 ? null : _model$state; // 该 model 的 reducers

      var modelReducers = {}; // 检测 namespace 是否有定义

      if (!namespace) {
        throw new Error('namespace 未定义或为空字符串.');
      } // 检测 namespace 是否重复定义(必须全局唯一)


      if (existentNamespace[namespace]) {
        throw new Error("namespace: ".concat(namespace, " \u91CD\u590D\u5B9A\u4E49."));
      } // 检查 reducers 类型


      if (!(0, _utils.isType)(reducers, 'Object')) {
        throw new Error("reducers \u6570\u636E\u7C7B\u578B\u5FC5\u987B\u4E3A\u5BF9\u8C61.");
      } // 获取定义的 reducer


      Object.keys(reducers).forEach(function (name) {
        var reducerName = "".concat(namespace).concat(_constants.NAMESPACE_SEP).concat(name);
        modelReducers[reducerName] = reducers[name];
      }); // 生成该 model 的 根 reducer

      var modelRootReducer = function modelRootReducer() {
        var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : modelInitState;
        var action = arguments.length > 1 ? arguments[1] : undefined;
        return (0, _immer.default)(state, function (draft) {
          var caseReducer = modelReducers[action.type];

          if (caseReducer) {
            return caseReducer(draft, action);
          }

          return draft;
        });
      };

      rootReducers[namespace] = modelRootReducer;
    };

    for (var _iterator = models[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      _loop();
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return != null) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }

  return (0, _redux.combineReducers)(rootReducers);
}
490235
function (model, options) {
        this._index(model);
        if (!model.collection) model.collection = this;
        if (model.on) model.on('all', this._onModelEvent, this);
    }
562501
function () {
        // make a copy of the array for comparisons
        var existingModels = slice.call(this.models);
        var rootModels = slice.call(this.collection.models);
        var newIndexes = {};
        var newModels, toAdd, toRemove;

        this._resetIndexes(newIndexes);

        // reduce base model set by applying filters
        if (this._filters.length) {
            newModels = reduce(this._filters, function (startingArray, filterFunc) {
                return startingArray.filter(filterFunc);
            }, rootModels);
        } else {
            newModels = slice.call(rootModels);
        }

        // sort it
        if (this.comparator) newModels = this._sortModels(newModels, this.comparator);

        newModels.forEach(function (model) {
            this._addIndex(newIndexes, model);
        }, this);

        // Cache a reference to the full filtered set to allow this._filtered.length. Ref: #6
        if (rootModels.length) {
            this._filtered = newModels;
            this._indexes = newIndexes;
        } else {
            this._filtered = [];
            this._resetIndexes(this._indexes);
        }

        // now we've got our new models time to compare
        toAdd = difference(newModels, existingModels);
        toRemove = difference(existingModels, newModels);

        // save 'em
        this.models = newModels;

        forEach(toRemove, bind(function (model) {
            this.trigger('remove', model, this);
        }, this));

        forEach(toAdd, bind(function (model) {
            this.trigger('add', model, this);
        }, this));

        // unless we have the same models in same order trigger `sort`
        if (!isEqual(existingModels, newModels) && this.comparator) {
            this.trigger('sort', this);
        }
    }
708326
function(callback) {
      stageModels(app, models, function(err) {
        models.pop(); // remove snapshot model
        models.pop(); // remove optimizedData model
        callback(err);
      });
    }
1339820
function updateNestedModels() {
  nestedRegistry.models = [];
  _.each(nestedRegistry.views, function(view) {
    var data = (view.obj.model || view.obj.collection);
    if (data) {
      nestedRegistry.models.push(flatRegistry.models[data.getDebugName()]);
    }
  });
}
386988
function(){
      var result = [];

      ko.utils.arrayForEach(this.models(), function(model){
        result.push(model.toJSON());
      });

      return result;
    }
607682
function(models){
        var currentLen = this.length;

        // Cloning after converting to an Array because it should be dereferenced
        // in order to continue the while loop when erasing from this._models
        models = Array.from(models).slice();

        this.act(function(){
            var l = models.length,
                i = 0;

            while(l--){
                this._remove(models[i++]);
            }
        });

        // Signal change when the collection of models change
        if (!this.isActive() && this._changed) {
             this.signalChange();

             this.resetChange();
        }

        return this;
    }
825718
function(models, out)
  {
    var target = out || this.cloneEmpty();

    for (var i = 0; i < models.length; i++)
    {
      var a = models[ i ];
      var key = this.buildKeyFromInput( a );

      if ( this.has( key ) )
      {
        target.push( a );
      }
    }

    return target;
  }
395593
function requireModel (...models) {
  return Comp => {
    if (!models || models.length === 0) {
      return
    }

    Comp.finisher = function (_constructor) {
      class Wrapper extends _constructor {

        static contextTypes = {
          tempo: PropTypes.object,
          ..._constructor.contextTypes
        }

        constructor (props, context) {
          super(...arguments)
          const { storeState } = props
          const { tempo } = context

          models.forEach((model) => {
            tempo.model(model)
          })
          const newStoreState = tempo.getState()
          // WARNING react-rudex默认并不会立即更新mapStateToProps中的storeState入参，
          // 导致在子组件树中使用刚注册的model的state会出错，所以在这里主动将新状态更新到当前渲染的状态上。
          Object.assign(storeState, newStoreState)
        }
      }

      let EnhancedComp = connect((storeState, ownProps) => {
        return { storeState }
      }, dispatch => ({ dispatch }))(Wrapper)

      return EnhancedComp
    }
  }
}
390102
function init(_models) {
  _.forEach(_models, (model) =>  {
    models[model.modelName] = model;
  });

  generateTypeDefs(models);
  generateNodeDefinitions(models);
}
165946
function(model, attrs) {
      attrs = attrs || _.keys(_.result(model, 'validation') || {});
      return _.reduce(attrs, function(memo, key) {
        memo[key] = void 0;
        return memo;
      }, {});
    }
973778
function reduxifyReducer (reducer, collectionName = null) {
  return (state = [], action) => {
    const collection = createReduxifyCollection(state, collectionName)
    const changeset = reducer(collection, action)

    // the changesets returned by the reduxify collections are just plain synchronous methods
    return changeset && changeset !== collection
      ? applyChangeset(state, changeset)
      : state
  }

  function applyChangeset (state, changeset) {
    if (typeof changeset !== 'function') {
      console.error('Reduxify changeset is a plain function. Instead got:', changeset)
      throw new Error('Reduxify changeset is a plain function.')
    }
    // the changesets returned by the reduxify collections are just plain synchronous methods
    return changeset(state)
  }
}
584657
public static function deleteAllProperties(&$models)
    {
        $storageHandlers = PropertyStorageHelper::getHandlersForModel(reset($models));

        Yii::beginProfile('Fill properties for models');

        foreach ($storageHandlers as $handler) {
            Yii::beginProfile($handler);

            $handler->deleteAllProperties($models);

            Yii::endProfile($handler);
        }
        Yii::endProfile('Fill properties for models');
        return $models;
    }
436332
function collectDependencies(dependencies, model, models) {
  if (!model || dependencies.has(model.modelClass)) {
    return;
  }
  dependencies.add(model.modelClass);
  if (model.modelDependencies) {
    model.modelDependencies.forEach((dep) =>
      collectDependencies(dependencies, dep, models)
    );
  }
}
1247253
function reducer(props, map, key) {
  return Object.assign({}, map, {
    [key]: props[key],
  });
}
1080832
public function delete($models)
    {
        $index = $this->algolia->initIndex($models->first()->searchableAs());

        $index->deleteObjects(
            $models->map(function ($model) {
                return $model->getScoutKey();
            })->values()->all()
        );
    }
1066799
public function setModels($models)
    {
        if (!is_object($models)) {
            if (is_array($models)) {
                $models = collect($models);
            }
        }

        if(class_basename($models->first()) == 'stdClass')
        {
            $models = $models->map(function ($array) {
                return new BlankModel($array);
            });
        }

        $this->models = $models;
    }