12345678910111213141516171819202122232425262728 |
- /**
- * 序号列表生成函数
- *
- * @param {Number} start 起始值
- * @param {Number} stop 结束值
- * @param {Number} step 自增值
- * @return {Object}
- */
- function range (start, stop, step) {
- var index, len
- var result = []
- var args = arguments
- if (args.length < 2) {
- stop = args[0]
- start = 0
- }
- index = start >> 0
- len = stop >> 0
- if (index < stop) {
- step = step >> 0 || 1
- for (; index < len; index += step) {
- result.push(index)
- }
- }
- return result
- }
- module.exports = range
|