Skip to content

Commit

Permalink
release: v1.38.2
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jul 3, 2023
1 parent e097dcf commit f811223
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.38.2 (4 Jul 2023)

* fix(remove): loop through undefined values

## v1.38.1 (19 Apr 2023)

* fix(isHidden): position fixed always return true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "licia",
"version": "1.38.1",
"version": "1.38.2",
"description": "Useful utility collection with zero dependencies",
"bin": {
"licia": "./bin/licia.js"
Expand Down
5 changes: 3 additions & 2 deletions src/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ exports = function(arr, iterator, ctx) {
const len = arr.length;

while (++i < len) {
const val = arr[i];
const realIdx = i - ret.length;
const val = arr[realIdx];

if (iterator(val, i, arr)) {
ret.push(val);
arr.splice(i, 1);
arr.splice(realIdx, 1);
}
}

Expand Down
28 changes: 28 additions & 0 deletions test/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,31 @@ const evens = remove(arr, function(val) {
});
expect(arr).to.eql([1, 3, 5]);
expect(evens).to.eql([2, 4]);

const people = [
{
name: 'john',
age: 24
},
{
name: 'jane',
age: 23
},
{
name: 'kitty',
age: 24
}
];

const jane = remove(people, item => item.name === 'jane');
expect(people).to.eql([
{
name: 'john',
age: 24
},
{
name: 'kitty',
age: 24
}
]);
expect(jane).to.eql([{ name: 'jane', age: 23 }]);

0 comments on commit f811223

Please sign in to comment.