| [a762898] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const dropRightWhile$1 = require('../../array/dropRightWhile.js');
|
|---|
| 6 | const identity = require('../../function/identity.js');
|
|---|
| 7 | const property = require('../object/property.js');
|
|---|
| 8 | const isArrayLike = require('../predicate/isArrayLike.js');
|
|---|
| 9 | const matches = require('../predicate/matches.js');
|
|---|
| 10 | const matchesProperty = require('../predicate/matchesProperty.js');
|
|---|
| 11 |
|
|---|
| 12 | function dropRightWhile(arr, predicate = identity.identity) {
|
|---|
| 13 | if (!isArrayLike.isArrayLike(arr)) {
|
|---|
| 14 | return [];
|
|---|
| 15 | }
|
|---|
| 16 | return dropRightWhileImpl(Array.from(arr), predicate);
|
|---|
| 17 | }
|
|---|
| 18 | function dropRightWhileImpl(arr, predicate) {
|
|---|
| 19 | switch (typeof predicate) {
|
|---|
| 20 | case 'function': {
|
|---|
| 21 | return dropRightWhile$1.dropRightWhile(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
|
|---|
| 22 | }
|
|---|
| 23 | case 'object': {
|
|---|
| 24 | if (Array.isArray(predicate) && predicate.length === 2) {
|
|---|
| 25 | const key = predicate[0];
|
|---|
| 26 | const value = predicate[1];
|
|---|
| 27 | return dropRightWhile$1.dropRightWhile(arr, matchesProperty.matchesProperty(key, value));
|
|---|
| 28 | }
|
|---|
| 29 | else {
|
|---|
| 30 | return dropRightWhile$1.dropRightWhile(arr, matches.matches(predicate));
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
| 33 | case 'symbol':
|
|---|
| 34 | case 'number':
|
|---|
| 35 | case 'string': {
|
|---|
| 36 | return dropRightWhile$1.dropRightWhile(arr, property.property(predicate));
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | exports.dropRightWhile = dropRightWhile;
|
|---|