@newdash/newdash
Version:
javascript/typescript utility library
32 lines (31 loc) • 884 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortedUniq = void 0;
const baseSortedUniq_1 = __importDefault(require("./.internal/baseSortedUniq"));
/**
* This method is like `uniq` except that it only works
* for sorted arrays.
* If the input array is known to be sorted `sortedUniq` is
* faster than `uniq`.
*
* @since 5.12.0
* @category Array
* @param array The array to inspect.
* @returns Returns the new duplicate free array.
* @example
*
* ```js
* sortedUniq([1, 1, 2])
* // => [1, 2]
* ```
*/
function sortedUniq(array) {
return (array && array.length)
? (0, baseSortedUniq_1.default)(array)
: [];
}
exports.sortedUniq = sortedUniq;
exports.default = sortedUniq;