You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/from-to.js
+54-76Lines changed: 54 additions & 76 deletions
Original file line number
Diff line number
Diff line change
@@ -12,51 +12,21 @@ import arrayBack from 'array-back'
12
12
* arr {string[]} - Input array. Only mutated if `options.remove` is set.
13
13
* [options.rtol] {boolean} - Enable right-to-left scans. Either that or pass in a custom iterator. TODO.
14
14
* [options.remove] {boolean} - Remove from source array
15
-
* [options.inclusive] {boolean} - If `true` includes the to item.
16
-
* [options.from] {string[]|function[]}
17
-
* [options.to] {string[]|function[]} - A "Stop Here" function. Set one or more strings as the terminating arg. Or, from the function `fn(arg, index, argv, valueIndex)`, return true for the first arg that is out of range. Set `inclusive` to also include it.
18
-
* [options.toInclude] {string[]|function[]} - From the function `fn(arg, index, argv, valueIndex)`, return true for the first arg that is out of range. Set `inclusive` to also include it.
19
-
* [options.noFurtherThan] {function}
20
-
* [options.toEnd] {boolean}
15
+
* [options.from] {string[]|function[]} - String literal or a [findIndex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) callback function.
16
+
* [options.to] {string[]|function[]} - A "Stop Here" function. Set one or more strings as the terminating arg. Or, from the function `fn(arg, index, argv, valueIndex)`, return true for the first arg that is out of range. Set `inclusive` to also include it. To will always search to the end of the input array.
@@ -101,18 +66,18 @@ test.set('--option value', async function () {
101
66
a.deepEqual(arr,['one','here','more'])
102
67
})
103
68
104
-
/* TODO: GET RID of noFurtherThan and inclusive - too confusing to use and code. Stick with "stop here", "no further than here" behaviour which is not inclusive. (default behaviour used by array.slice) */
105
-
only.set('--option value without remove',asyncfunction(){
69
+
test.set('--option value, no remove',asyncfunction(){
test.set('--option value value ...',asyncfunction(){
117
82
constarr=['one','here','--option','there','more']
118
83
constresult=fromTo(arr,{
@@ -124,5 +89,26 @@ test.set('--option value value ...', async function () {
124
89
a.deepEqual(arr,['one','here'])
125
90
})
126
91
92
+
skip.set('from many, to many',asyncfunction(){
93
+
constvalidCommands=[
94
+
'/help',
95
+
'/users',
96
+
'/rooms',
97
+
'/clientSessions',
98
+
'/roomSessions',
99
+
'/members',
100
+
'/nick',
101
+
'/join',
102
+
]
103
+
104
+
constarr=['/join','r','/nick','lloyd']
105
+
constresult=fromTo(arr,{
106
+
from: validCommands,
107
+
to: validCommands
108
+
})
109
+
/* Priority should be given to "first in the array", not "first in the from list". Is order in the argv more meaningful than order in the from list? */
0 commit comments