UNPKG

@ayonli/jsext

Version:

A JavaScript extension package for building strong and modern applications.

70 lines (67 loc) 2.12 kB
'use strict'; var array = require('../array.js'); Array.prototype.first = function first() { return array.first(this); }; Array.prototype.last = function last() { return array.last(this); }; Array.prototype.random = function random(remove = false) { return array.random(this, remove); }; Array.prototype.count = function count(ele) { return array.count(this, ele); }; Array.prototype.equals = function equals(another) { return array.equals(this, another); }; Array.prototype.includesSlice = function includesSlice(slice) { return array.includesSlice(this, slice); }; Array.prototype.startsWith = function startsWith(prefix) { return array.startsWith(this, prefix); }; Array.prototype.endsWith = function endsWith(suffix) { return array.endsWith(this, suffix); }; Array.prototype.split = function split(delimiter) { return array.split(this, delimiter); }; Array.prototype.chunk = function chunk(length) { return array.chunk(this, length); }; Array.prototype.unique = Array.prototype.uniq = function unique() { return array.unique(this); }; Array.prototype.uniqueBy = Array.prototype.uniqBy = function uniqueBy(fn) { return array.uniqueBy(this, fn); }; Array.prototype.shuffle = function shuffle() { return array.shuffle(this); }; Array.prototype.toShuffled = function toShuffled() { return this.slice().shuffle(); }; if (!Array.prototype.toReversed) { Array.prototype.toReversed = function toReversed() { return this.slice().reverse(); }; } if (!Array.prototype.toSorted) { Array.prototype.toSorted = function toSorted(fn) { return this.slice().sort(fn); }; } Array.prototype.orderBy = function orderBy(key, order = "asc") { return array.orderBy(this, key, order); }; Array.prototype.groupBy = function groupBy(fn, type = Object) { return array.groupBy(this, fn, type); }; Array.prototype.keyBy = function keyBy(fn, type = Object) { return array.keyBy(this, fn, type); }; Array.prototype.partition = function partition(predicate) { return array.partition(this, predicate); }; //# sourceMappingURL=array.js.map