0.1.0 • Published 8 years ago
@suninfo/array-is-sorted v0.1.0
array-is-sorted
检测数组是否排序的模块
Installation
$ npm install @sunflower/array-is-sortedUsage
默认的排序规则为由小到大。
const checksorted = require('@sunflower/array-is-sorted');
checksorted([1, 3, 5]); // => true
checksorted([3, 1, 5]); // => false自定义排序规则
const checksorted = require('@sunflower/array-is-sorted');
let myfun = function(prev, next) {
return next.charCodeAt() - prev.charCodeAt()
};
checksorted(['a', 'b', 'f'], myfun); // => true
checksorted(['c', 'z', 'm'], myfun); // => falseTests
安装mocha测试框架,然后执行测试命令:
$ yarn
$ npm testLicense
The MIT License
0.1.0
8 years ago