UNPKG

customerservice188

Version:

188

23 lines 578 B
/** * 客户Service */ exports.CustomerService = function () { this.customers = []; // 添加客户 this.add = function (cstm) { this.customers.push(cstm); } // 根据客户名字移除 this.remove = function (name) { for (var i = 0; i < this.customers.length; ++i) { if (this.customers[i].name === name) { this.customers.splice(i, 1); break; } } } // 获取所有客户 this.findAll = function () { return this.customers; } }