source: node_modules/es-toolkit/dist/compat/array/dropRightWhile.js@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 1.5 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const dropRightWhile$1 = require('../../array/dropRightWhile.js');
6const identity = require('../../function/identity.js');
7const property = require('../object/property.js');
8const isArrayLike = require('../predicate/isArrayLike.js');
9const matches = require('../predicate/matches.js');
10const matchesProperty = require('../predicate/matchesProperty.js');
11
12function dropRightWhile(arr, predicate = identity.identity) {
13 if (!isArrayLike.isArrayLike(arr)) {
14 return [];
15 }
16 return dropRightWhileImpl(Array.from(arr), predicate);
17}
18function 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
41exports.dropRightWhile = dropRightWhile;
Note: See TracBrowser for help on using the repository browser.