source: node_modules/es-toolkit/dist/compat/array/dropRightWhile.mjs@ ba17441

Last change on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import { dropRightWhile as dropRightWhile$1 } from '../../array/dropRightWhile.mjs';
2import { identity } from '../../function/identity.mjs';
3import { property } from '../object/property.mjs';
4import { isArrayLike } from '../predicate/isArrayLike.mjs';
5import { matches } from '../predicate/matches.mjs';
6import { matchesProperty } from '../predicate/matchesProperty.mjs';
7
8function dropRightWhile(arr, predicate = identity) {
9 if (!isArrayLike(arr)) {
10 return [];
11 }
12 return dropRightWhileImpl(Array.from(arr), predicate);
13}
14function dropRightWhileImpl(arr, predicate) {
15 switch (typeof predicate) {
16 case 'function': {
17 return dropRightWhile$1(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));
18 }
19 case 'object': {
20 if (Array.isArray(predicate) && predicate.length === 2) {
21 const key = predicate[0];
22 const value = predicate[1];
23 return dropRightWhile$1(arr, matchesProperty(key, value));
24 }
25 else {
26 return dropRightWhile$1(arr, matches(predicate));
27 }
28 }
29 case 'symbol':
30 case 'number':
31 case 'string': {
32 return dropRightWhile$1(arr, property(predicate));
33 }
34 }
35}
36
37export { dropRightWhile };
Note: See TracBrowser for help on using the repository browser.