-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Refactor _remove as _erase via generic _concat.
- Loading branch information
1 parent
d3e6cf9
commit 127b5f8
Showing
5 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import assert from 'assert'; | ||
import Node from './Node.js'; | ||
import _concat from './_concat.js'; | ||
|
||
/** | ||
* Erase range [x, y) from list. Range cannot be empty. | ||
* | ||
* @param {Node} x Inclusive beginning of range to erase. | ||
* @param {Node} y Exclusive end of range to erase. | ||
*/ | ||
export default function _erase(x, y) { | ||
assert(x instanceof Node); | ||
_concat(x.prev, y); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import test from 'ava'; | ||
|
||
import {list} from '@iterable-iterator/list'; | ||
|
||
import {values, from, _remove} from '#module'; | ||
|
||
test('_remove', (t) => { | ||
const l = from('abc'); | ||
_remove(l.next); | ||
t.is(list(values(l)).join(''), 'ac'); | ||
}); |