UNPKG

sensecap

Version:

## Install ``` npm install sensecap --save ```

28 lines (23 loc) 806 B
var commonMethods = { /** * 分页 */ pagination: function (pageNo, pageSize, array) { var offset = (pageNo - 1) * pageSize return (offset + pageSize >= array.length) ? array.slice(offset, array.length) : array.slice(offset, offset + pageSize) }, copyList: function (targetList, sourceList) { for (var i = 0; i < targetList.length; i++) { for (var j = 0; j < sourceList.length; j++) { if (targetList[i].deviceEui === sourceList[j].device_eui) { for (var attr in sourceList[j]) { targetList[i][attr] = sourceList[j][attr]; } break; } } } return targetList; } } module.exports = commonMethods;